[a2776f]: uget-gtk / UgApp-gtk.h  Maximize  Restore  History

Download this file

389 lines (338 with data), 10.5 kB

  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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
/*
*
* Copyright (C) 2005-2011 by C.H. Huang
* plushuang.tw@gmail.com
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* ---
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
* You must obey the GNU Lesser General Public License in all respects
* for all of the code used other than OpenSSL. If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. If you
* do not wish to do so, delete this exception statement from your
* version. If you delete this exception statement from all source
* files in the program, then also delete it here.
*
*/
#ifndef UG_APP_GTK_H
#define UG_APP_GTK_H
#include <gtk/gtk.h>
// uglib
#include <UgApp-base.h>
#include <UgIpc.h>
#include <UgOption.h>
#include <UgXmlrpc.h>
#include <UgRunning.h>
#include <UgSetting.h>
#include <UgSummary.h>
#include <UgCategory-gtk.h>
#include <UgCategoryWidget.h>
#ifdef HAVE_APP_INDICATOR
#include <libappindicator/app-indicator.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
#define UG_APP_GTK_DIR "uGet"
#define UG_APP_GTK_SETTING_FILE "Setting.xml"
#define UG_APP_GTK_CATEGORY_FILE "CategoryList.xml"
#define UG_APP_GTK_DOWNLOAD_FILE "DownloadList.xml"
#define UG_APP_GTK_ICON_NAME "uget-icon"
#define UG_APP_GTK_ICON_ERROR_NAME "uget-error"
#define UG_APP_GTK_ICON_ACTIVE_NAME "uget-downloading"
#define UG_APP_GTK_ACCEL_PATH_CTRL_N "<uGet>/New/Download"
#define UG_APP_GTK_CATEGORY_STOCK GTK_STOCK_DND_MULTIPLE
typedef struct UgAppGtk UgAppGtk;
// implemented in UgApp-gtk-main.c
const gchar* ug_get_data_dir (void);
// return g_get_user_config_dir () + UG_APP_GTK_DIR + "attachment"
const gchar* ug_get_attachment_dir (void);
// ----------------------------------------------------------------------------
// UgAppGtk: Uget application for GTK+
struct UgAppGtk
{
// command argument, IPC, UgRunning
UgIpc ipc; // initialize in UgApp-gtk-main.c
UgOption option; // initialize in UgApp-gtk-main.c
UgRunning running;
UgSetting setting; // UgSetting.h
gboolean user_action; // some job stop by user
UgScheduleState schedule_state;
// Launch application
GRegex* launch_regex;
// aria2 plug-in
struct
{
UgXmlrpc xmlrpc;
gboolean launched;
} aria2;
// Clipboard
struct UgClipboard
{
GtkClipboard* self;
gchar* text;
GRegex* regex;
} clipboard;
// dialogs
struct UgDialogs
{
GtkWidget* error;
GtkWidget* message;
GtkWidget* close_confirmation;
GtkWidget* delete_confirmation;
GtkWidget* setting;
} dialogs;
// -------------------------------------------------------
// GUI (initialize in UgApp-gtk-gui.c)
GtkAccelGroup* accel_group;
UgCategoryWidget cwidget;
UgSummary summary;
// --------------------------------
// System tray icon
struct UgTrayIcon
{
#ifdef HAVE_APP_INDICATOR
AppIndicator* indicator;
#else
GtkStatusIcon* self;
#endif
gboolean error_occurred;
guint last_status;
struct UgTrayIconMenu
{
GtkWidget* self; // (GtkMenu) pop-up menu
GtkWidget* create_download;
GtkWidget* create_clipboard;
GtkWidget* create_torrent;
GtkWidget* create_metalink;
GtkWidget* settings;
GtkWidget* about;
GtkWidget* show_window;
GtkWidget* offline_mode;
GtkWidget* quit;
} menu;
} trayicon;
// --------------------------------
// Main Window
struct UgWindow
{
GtkWindow* self;
// layout
GtkPaned* vpaned; // right side (UgDownloadWidget and UgSummary)
GtkPaned* hpaned; // separate left side and right side
} window;
// --------------------------------
// status bar
struct UgStatusbar
{
GtkStatusbar* self;
GtkLabel* speed;
} statusbar;
// --------------------------------
// Toolbar
struct UgToolbar
{
GtkWidget* self; // GtkToolbar
// GtkToolItem
GtkWidget* create;
// GtkMenuItem
// menu for tool button
GtkWidget* create_download;
GtkWidget* create_category;
GtkWidget* create_batch;
GtkWidget* create_clipboard;
GtkWidget* create_torrent;
GtkWidget* create_metalink;
// GtkToolItem
GtkWidget* save;
GtkWidget* runnable;
GtkWidget* pause;
GtkWidget* properties;
GtkWidget* move_up;
GtkWidget* move_down;
GtkWidget* move_top;
GtkWidget* move_bottom;
} toolbar;
// --------------------------------
// Menubar --- start ---
struct UgMenubar
{
GtkWidget* self; // GtkMenuBar
// GtkWidget* self; // GtkMenu*
// GtkWidget* shell; // GtkMenuShell*
// GtkWidget* other; // GtkMenuItem*
struct UgFileMenu
{
// file.create
struct UgFileCreateMenu
{
GtkWidget* download;
GtkWidget* category;
GtkWidget* batch;
GtkWidget* from_clipboard;
GtkWidget* torrent;
GtkWidget* metalink;
} create;
// file.save
GtkWidget* save;
// file.import & export
GtkWidget* import_html;
GtkWidget* import_text;
GtkWidget* export_text;
GtkWidget* offline_mode;
GtkWidget* quit;
} file;
struct UgEditMenu
{
GtkWidget* clipboard_monitor;
GtkWidget* clipboard_option;
GtkWidget* shutdown;
GtkWidget* settings;
} edit;
struct UgViewMenu
{
GtkWidget* toolbar;
GtkWidget* statusbar;
GtkWidget* category;
GtkWidget* summary;
struct UgViewItemMenu
{
GtkWidget* name;
GtkWidget* folder;
GtkWidget* category;
// GtkWidget* elapsed;
GtkWidget* url;
GtkWidget* message;
} summary_items;
struct UgViewColMenu
{
GtkWidget* self; // GtkMenu
GtkWidget* completed;
GtkWidget* total;
GtkWidget* percent;
GtkWidget* elapsed; // consuming time
GtkWidget* left; // remaining time
GtkWidget* speed;
GtkWidget* up_speed;
GtkWidget* retry;
GtkWidget* category;
GtkWidget* url;
GtkWidget* added_on;
GtkWidget* completed_on;
} columns; // download columns
} view;
struct UgCategoryMenu
{
GtkWidget* self; // GtkMenu
GtkWidget* create;
GtkWidget* delete;
GtkWidget* properties;
} category;
struct UgDownloadMenu
{
GtkWidget* self; // GtkMenu
GtkWidget* create;
GtkWidget* delete;
GtkWidget* delete_file; // delete file and data.
GtkWidget* open;
GtkWidget* open_folder; // open containing folder
GtkWidget* runnable;
GtkWidget* pause;
struct UgDownloadMoveToMenu
{
GtkWidget* self; // GtkMenu
GtkWidget* item; // GtkMenuItem
// This array used for mapping menu item and it's category
// index 0, 2, 4, 6... GtkMenuItem*
// index 1, 3, 5, 7... UgCategoryGtk*
GPtrArray* array;
} move_to;
GtkWidget* move_up;
GtkWidget* move_down;
GtkWidget* move_top;
GtkWidget* move_bottom;
GtkWidget* properties;
} download;
struct UgHelpMenu
{
GtkWidget* about_uget;
} help;
} menubar;
// Menubar --- end ---
// --------------------------------
};
// use function name "ug_app_xxx" to replace "ug_app_gtk_xxx" here.
// ug_app_init is easy to understand, ug_app_gtk_init and ug_appgtk_init are not.
void ug_app_init (UgAppGtk* app);
void ug_app_quit (UgAppGtk* app);
void ug_app_save (UgAppGtk* app);
void ug_app_load (UgAppGtk* app);
void ug_app_set_setting (UgAppGtk* app, UgSetting* setting);
void ug_app_get_setting (UgAppGtk* app, UgSetting* setting);
// UgApp-gtk-gui.c
void ug_app_init_gui (UgAppGtk* app);
// UgApp-gtk-callback.c
void ug_app_init_callback (UgAppGtk* app);
// UgApp-gtk-timeout.c
void ug_app_init_timeout (UgAppGtk* app);
// --------------------------------------------------------
// UgClipboard
void ug_clipboard_init (struct UgClipboard* clipboard, const gchar* pattern);
void ug_clipboard_set_pattern (struct UgClipboard* clipboard, const gchar* pattern);
void ug_clipboard_set_text (struct UgClipboard* clipboard, gchar* text);
GList* ug_clipboard_get_uris (struct UgClipboard* clipboard);
GList* ug_clipboard_get_matched (struct UgClipboard* clipboard, const gchar* text);
// --------------------------------------------------------
// UgTrayIcon and UgStatusbar
void ug_trayicon_set_info (struct UgTrayIcon* trayicon, guint n_active, gdouble speed);
void ug_trayicon_set_visible (struct UgTrayIcon* trayicon, gboolean visible);
void ug_statusbar_set_info (struct UgStatusbar* statusbar, UgDownloadWidget* dwidget);
void ug_statusbar_set_speed (struct UgStatusbar* statusbar, gdouble speed);
// --------------------------------------------------------
// utility and integrate functions
void ug_app_confirm_to_quit (UgAppGtk* app);
void ug_app_confirm_to_delete (UgAppGtk* app, GCallback response, gpointer response_data);
void ug_app_show_message (UgAppGtk* app, GtkMessageType type, const gchar* message);
void ug_app_window_close (UgAppGtk* app);
void ug_app_trayicon_decide_visible (UgAppGtk* app);
void ug_app_menubar_sync_category (UgAppGtk* app, gboolean reset);
void ug_app_reset_download_column (UgAppGtk* app);
void ug_app_decide_download_sensitive (UgAppGtk* app);
void ug_app_decide_category_sensitive (UgAppGtk* app);
void ug_app_decide_bt_meta_sensitive (UgAppGtk* app);
// --------------------------------------------------------
// aria2
#ifdef HAVE_PLUGIN_ARIA2
void ug_app_aria2_init (UgAppGtk* app);
gboolean ug_app_aria2_setup (UgAppGtk* app);
gboolean ug_app_aria2_launch (UgAppGtk* app);
void ug_app_aria2_shutdown (UgAppGtk* app);
#else
#define ug_app_aria2_init(app)
#define ug_app_aria2_setup(app)
#define ug_app_aria2_launch(app)
#define ug_app_aria2_shutdown(app)
#endif // HAVE_PLUGIN_ARIA2
#ifdef __cplusplus
}
#endif
#endif // End of UG_APP_GTK_H