File: misc.h

package info (click to toggle)
gtkpod 0.99.14-3
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 7,716 kB
  • ctags: 3,266
  • sloc: ansic: 43,120; sh: 4,837; xml: 1,316; lex: 637; perl: 264; makefile: 236; awk: 73; python: 35
file content (255 lines) | stat: -rw-r--r-- 9,358 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
/*
|  Copyright (C) 2002-2007 Jorg Schuler <jcsjcs at users sourceforge net>
|  Part of the gtkpod project.
| 
|  URL: http://www.gtkpod.org/
|  URL: http://gtkpod.sourceforge.net/
|
|  This program is free software; you can redistribute it and/or modify
|  it under the terms of the GNU General Public License as published by
|  the Free Software Foundation; either version 2 of the License, or
|  (at your option) any later version.
|
|  This program is distributed in the hope that it will be useful,
|  but WITHOUT ANY WARRANTY; without even the implied warranty of
|  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
|  GNU General Public License for more details.
|
|  You should have received a copy of the GNU General Public License
|  along with this program; if not, write to the Free Software
|  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|  iTunes and iPod are trademarks of Apple
|
|  This product is not supported/written/published by Apple!
|
|  $Id: misc.h 1908 2008-01-03 14:38:30Z Sikon $
*/

#ifndef __MISC_H__
#define __MISC_H__

#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
#include <glade/glade.h>
#include <stdio.h>
#include <libxml/xmlversion.h>
#include <libxml/xmlmemory.h>
#include "file.h"
#include "display_itdb.h"
#include "display.h"
#include "confirmation.h"
#include "time.h"


#define C_FREE(a) {g_free(a); a=NULL;}

/* where to find the scripts */
extern const gchar *SCRIPTDIR;

/* version of GTK_CHECK_VERSION that uses the runtime variables
   gtk_*_version... instead of the compile-time constants
   GTK_*_VERSION */
#define	RUNTIME_GTK_CHECK_VERSION(major,minor,micro)	\
    (gtk_major_version > (major) || \
     (gtk_major_version == (major) && gtk_minor_version > (minor)) || \
     (gtk_major_version == (major) && gtk_minor_version == (minor) && \
      gtk_micro_version >= (micro)))

/* compare a and b, return sign (a-b) -- it has to be this way rather
   than just calculate a-b, because a and b might be unsigned... */
#define COMP(a,b) (a<b ? -1:a>b ? +1:0)

/* Response for the Apply button (we cannot use GTK_RESPONSE_APPLY)
 * because that is only emitted if a filename is present */
enum { RESPONSE_APPLY = 5 };

/* indicates whether widgets are currently blocked */
extern gboolean widgets_blocked;
/* full path to 'gtkpod.glade', defined in main.c */
extern gchar *xml_file;

/* Some symbols not necessarily defined */

gchar *utf8_strcasestr (const gchar *haystack, const gchar *needle);

gchar *get_user_string (gchar *title, gchar *message, gchar *dflt,
			gchar *opt_msg, gboolean *opt_state, const gchar *accept_button);
Playlist *add_new_pl_user_name (iTunesDB *itdb, gchar *dflt, gint32 pos);
void add_new_pl_or_spl_user_name (iTunesDB *itdb, gchar *dflt, gint32 pos);
void create_add_files_fileselector (void);
void create_add_playlists_fileselector (void);
gchar *concat_dir (G_CONST_RETURN gchar *dir, G_CONST_RETURN gchar *file);
gchar *concat_dir_if_relative (G_CONST_RETURN gchar *base_dir,
			       G_CONST_RETURN gchar *rel_dir);
float get_ms_since (GTimeVal *old_time, gboolean update);
gint get_sort_tab_number (gchar *text);
gboolean parse_tracks_from_string (gchar **s, Track **track);
gboolean parse_artwork_from_string(gchar **s, Artwork **artwork);
void gtkpod_init (int argc, char *argv[]);
void gtkpod_shutdown (void);

gchar *get_allowed_percent_char (void);
T_item TM_to_T (TM_item sm);
T_item char_to_T (char c);
T_item ST_to_T (ST_CAT_item st);
const gchar *get_tm_string (TM_item tm);
const gchar *get_tm_tooltip (TM_item tm);
const gchar *get_t_string (T_item t);
const gchar *get_t_tooltip (T_item t);

void delete_playlist_head (DeleteAction deleteaction);
void delete_track_head (DeleteAction deleteaction);
void delete_entry_head (gint entry_inst, DeleteAction deleteaction);

void delete_populate_settings (struct DeleteData *dd,
			       gchar **label, gchar **title,
			       gboolean *confirm_again,
			       gchar **confirm_again_key,
			       GString **str);

void block_widgets (void);
void release_widgets (void);
void update_blocked_widget (GtkWidget *w, gboolean sens);

/*void mount_ipod(void);
  void unmount_ipod(void);*/
void call_script (gchar *script, ...);

gchar **build_argv_from_strings (const gchar *first_arg, ...);

void delete_track_ok (struct DeleteData *dd);

void gtkpod_warning (const gchar *format, ...);
void gtkpod_warning_simple (const gchar *format, ...);
void gtkpod_warning_hig (GtkWindow *parent,
						 GtkMessageType icon,
						 const gchar *primary_text,
						 const gchar *secondary_text);

gchar *time_time_to_string (time_t t);
gchar *time_fromtime_to_string (time_t t);
gchar *time_totime_to_string (time_t t);
time_t time_string_to_time (const gchar *str);
time_t time_string_to_fromtime (const gchar *str);
time_t time_string_to_totime (const gchar *str);
time_t time_get_time (Track *track, T_item t_item);
gchar *time_field_to_string (Track *track, T_item t_item);
void time_set_time (Track *track, time_t t, T_item t_item);

gchar *get_filesize_as_string (double size);

gint compare_string (const gchar *str1, const gchar *str2);
void compare_string_fuzzy_generate_keys (void);
gint compare_string_fuzzy (const gchar *str1, const gchar *str2);
gint compare_string_case_insensitive (const gchar *str1,
				      const gchar *str2);
gint compare_string_start_case_insensitive (const gchar *haystack,
					    const gchar *needle);

gchar *filename_from_uri (const char *uri,
			  char      **hostname,
			  GError    **error);

void generate_category_playlists (iTunesDB *itdb, T_item cat);
Playlist *generate_displayed_playlist (void);
Playlist *generate_selected_playlist (void);
void randomize_current_playlist (void);
Playlist *generate_random_playlist (iTunesDB *itdb);
Playlist *generate_not_listed_playlist (iTunesDB *itdb);
Playlist *generate_playlist_with_name (iTunesDB *itdb, GList *tracks,
				       gchar *pl_name, gboolean del_old);
Playlist *generate_new_playlist (iTunesDB *itdb, GList *tracks);
void most_listened_pl (iTunesDB *itdb);
void never_listened_pl (iTunesDB *itdb);
void last_listened_pl(iTunesDB *itdb);
void most_rated_pl(iTunesDB *itdb);
void since_last_pl(iTunesDB *itdb);
void each_rating_pl (iTunesDB *itdb);

guint32 utf16_strlen (gunichar2 *utf16);
gunichar2 *utf16_strdup (gunichar2 *utf16);

void check_db (iTunesDB *db);

gboolean mkdirhier(const gchar *dirname, gboolean silent);
gboolean mkdirhierfile(const gchar *filename);
gint64 get_size_of_directory (const gchar *dir);
gchar *convert_filename (const gchar *filename);

guint32 replaygain_to_soundcheck (gdouble gain);
gdouble soundcheck_to_replaygain (guint32 soundcheck);


void option_set_radio_button (GladeXML *win_xml,
			      const gchar *prefs_string,
			      const gchar **widgets,
			      gint dflt);
gint option_get_radio_button (GladeXML *win_xml,
			      const gchar *prefs_string,
			      const gchar **widgets);
void option_set_folder (GtkFileChooser *fc,
			const gchar *prefs_string);
void option_get_folder (GtkFileChooser *fc,
			const gchar *prefs_string,
			gchar **value);
void option_set_filename (GtkFileChooser *fc,
			  const gchar *prefs_string);
void option_get_filename (GtkFileChooser *fc,
			  const gchar *prefs_string,
			  gchar **value);
void option_set_string (GladeXML *win_xml,
			const gchar *name,
			const gchar *dflt);
void option_get_string (GladeXML *win_xml,
			const gchar *name,
			gchar **value);
void option_set_toggle_button (GladeXML *win_xml,
			       const gchar *name,
			       gboolean dflt);
gboolean option_get_toggle_button (GladeXML *win_xml,
				   const gchar *name);

gchar *get_string_from_template (Track *track,
				 const gchar *template,
				 gboolean is_filename,
				 gboolean silent);
gchar *get_string_from_full_template (Track *track,
				      const gchar *full_template,
				      gboolean is_filename);

GList *glist_duplicate (GList *list);

gchar *which (const gchar *exe);

GladeXML *gtkpod_xml_new (const gchar *xml_file, const gchar *name);
GtkWidget *gtkpod_xml_get_widget (GladeXML *xml, const gchar *name);

gchar *get_itdb_prefs_key (gint index, const gchar *subkey);
gchar *get_playlist_prefs_key (gint index, Playlist *pl, const gchar *subkey);
gint get_itdb_index (iTunesDB *itdb);
gchar *get_itdb_prefs_string (iTunesDB *itdb, const gchar *subkey);
gchar *get_playlist_prefs_string (Playlist *playlist, const gchar *subkey);
gint get_itdb_prefs_int (iTunesDB *itdb, const gchar *subkey);
gint get_playlist_prefs_int (Playlist *playlist, const gchar *subkey);
gboolean get_itdb_prefs_string_value (iTunesDB *itdb, const gchar *subkey,
				      gchar **value);
gboolean get_itdb_prefs_int_value (iTunesDB *itdb, const gchar *subkey,
				   gint *value);
void set_itdb_prefs_string (iTunesDB *itdb,
			    const gchar *subkey, const gchar *value);
void set_itdb_index_prefs_string (gint index,
				  const gchar *subkey, const gchar *value);
void set_itdb_prefs_int (iTunesDB *itdb, const gchar *subkey, gint value);
void set_itdb_index_prefs_int (gint index,
			       const gchar *subkey, gint value);
void remove_itdb_prefs (iTunesDB *itdb);
void load_ipod_prefs (iTunesDB *itdb, const gchar *mountpoint);
gboolean save_ipod_prefs (iTunesDB *itdb, const gchar *mountpoint);

gboolean get_offline (iTunesDB *itdb);
#endif