summaryrefslogtreecommitdiff
path: root/interface.c
blob: ad5a0b7729ced157b063c4e376cf56369ff48ced (plain)
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
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
/*
 * DO NOT EDIT THIS FILE - it is generated by Glade.
 */

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

#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>

#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>

#include "callbacks.h"
#include "interface.h"
#include "support.h"

#define GLADE_HOOKUP_OBJECT(component,widget,name) \
  g_object_set_data_full (G_OBJECT (component), name, \
    gtk_widget_ref (widget), (GDestroyNotify) gtk_widget_unref)

#define GLADE_HOOKUP_OBJECT_NO_REF(component,widget,name) \
  g_object_set_data (G_OBJECT (component), name, widget)

GtkWidget*
create_mainwin (void)
{
  GtkWidget *mainwin;
  GtkWidget *vbox1;
  GtkWidget *hbox2;
  GtkWidget *handlebox1;
  GtkWidget *menubar1;
  GtkWidget *menuitem1;
  GtkWidget *menuitem1_menu;
  GtkWidget *open;
  GtkWidget *separator2;
  GtkWidget *add_files;
  GtkWidget *add_folder1;
  GtkWidget *separator1;
  GtkWidget *preferences1;
  GtkWidget *separatormenuitem1;
  GtkWidget *quit1;
  GtkWidget *edit1;
  GtkWidget *edit1_menu;
  GtkWidget *clear1;
  GtkWidget *select_all1;
  GtkWidget *selection1;
  GtkWidget *selection1_menu;
  GtkWidget *remove1;
  GtkWidget *crop1;
  GtkWidget *menuitem4;
  GtkWidget *menuitem4_menu;
  GtkWidget *about1;
  GtkWidget *handlebox2;
  GtkWidget *hbox3;
  GtkWidget *stopbtn;
  GtkWidget *image1;
  GtkWidget *playbtn;
  GtkWidget *image2;
  GtkWidget *pausebtn;
  GtkWidget *image3;
  GtkWidget *prevbtn;
  GtkWidget *image4;
  GtkWidget *nextbtn;
  GtkWidget *image5;
  GtkWidget *playrand;
  GtkWidget *alignment1;
  GtkWidget *hbox4;
  GtkWidget *image6;
  GtkWidget *label3;
  GtkWidget *handlebox3;
  GtkWidget *volume;
  GtkWidget *handlebox4;
  GtkWidget *playpos;
  GtkWidget *_;
  GtkWidget *playlist;
  GtkWidget *playscroll;
  GtkWidget *statusbar1;
  GtkAccelGroup *accel_group;

  accel_group = gtk_accel_group_new ();

  mainwin = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (mainwin), "DeaDBeeF");
  gtk_window_set_default_size (GTK_WINDOW (mainwin), 750, 650);

  vbox1 = gtk_vbox_new (FALSE, 0);
  gtk_widget_show (vbox1);
  gtk_container_add (GTK_CONTAINER (mainwin), vbox1);

  hbox2 = gtk_hbox_new (FALSE, 0);
  gtk_widget_show (hbox2);
  gtk_box_pack_start (GTK_BOX (vbox1), hbox2, FALSE, FALSE, 0);

  handlebox1 = gtk_handle_box_new ();
  gtk_widget_show (handlebox1);
  gtk_box_pack_start (GTK_BOX (hbox2), handlebox1, FALSE, TRUE, 0);

  menubar1 = gtk_menu_bar_new ();
  gtk_widget_show (menubar1);
  gtk_container_add (GTK_CONTAINER (handlebox1), menubar1);

  menuitem1 = gtk_menu_item_new_with_mnemonic ("_File");
  gtk_widget_show (menuitem1);
  gtk_container_add (GTK_CONTAINER (menubar1), menuitem1);

  menuitem1_menu = gtk_menu_new ();
  gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem1), menuitem1_menu);

  open = gtk_image_menu_item_new_from_stock ("gtk-open", accel_group);
  gtk_widget_show (open);
  gtk_container_add (GTK_CONTAINER (menuitem1_menu), open);

  separator2 = gtk_separator_menu_item_new ();
  gtk_widget_show (separator2);
  gtk_container_add (GTK_CONTAINER (menuitem1_menu), separator2);
  gtk_widget_set_sensitive (separator2, FALSE);

  add_files = gtk_menu_item_new_with_mnemonic ("Add files");
  gtk_widget_show (add_files);
  gtk_container_add (GTK_CONTAINER (menuitem1_menu), add_files);

  add_folder1 = gtk_menu_item_new_with_mnemonic ("Add folder");
  gtk_widget_show (add_folder1);
  gtk_container_add (GTK_CONTAINER (menuitem1_menu), add_folder1);

  separator1 = gtk_separator_menu_item_new ();
  gtk_widget_show (separator1);
  gtk_container_add (GTK_CONTAINER (menuitem1_menu), separator1);
  gtk_widget_set_sensitive (separator1, FALSE);

  preferences1 = gtk_menu_item_new_with_mnemonic ("_Preferences");
  gtk_widget_show (preferences1);
  gtk_container_add (GTK_CONTAINER (menuitem1_menu), preferences1);

  separatormenuitem1 = gtk_separator_menu_item_new ();
  gtk_widget_show (separatormenuitem1);
  gtk_container_add (GTK_CONTAINER (menuitem1_menu), separatormenuitem1);
  gtk_widget_set_sensitive (separatormenuitem1, FALSE);

  quit1 = gtk_image_menu_item_new_from_stock ("gtk-quit", accel_group);
  gtk_widget_show (quit1);
  gtk_container_add (GTK_CONTAINER (menuitem1_menu), quit1);

  edit1 = gtk_menu_item_new_with_mnemonic ("Edit");
  gtk_widget_show (edit1);
  gtk_container_add (GTK_CONTAINER (menubar1), edit1);

  edit1_menu = gtk_menu_new ();
  gtk_menu_item_set_submenu (GTK_MENU_ITEM (edit1), edit1_menu);

  clear1 = gtk_image_menu_item_new_from_stock ("gtk-clear", accel_group);
  gtk_widget_show (clear1);
  gtk_container_add (GTK_CONTAINER (edit1_menu), clear1);

  select_all1 = gtk_image_menu_item_new_from_stock ("gtk-select-all", accel_group);
  gtk_widget_show (select_all1);
  gtk_container_add (GTK_CONTAINER (edit1_menu), select_all1);

  selection1 = gtk_menu_item_new_with_mnemonic ("Selection");
  gtk_widget_show (selection1);
  gtk_container_add (GTK_CONTAINER (edit1_menu), selection1);

  selection1_menu = gtk_menu_new ();
  gtk_menu_item_set_submenu (GTK_MENU_ITEM (selection1), selection1_menu);

  remove1 = gtk_image_menu_item_new_from_stock ("gtk-remove", accel_group);
  gtk_widget_show (remove1);
  gtk_container_add (GTK_CONTAINER (selection1_menu), remove1);

  crop1 = gtk_menu_item_new_with_mnemonic ("Crop");
  gtk_widget_show (crop1);
  gtk_container_add (GTK_CONTAINER (selection1_menu), crop1);

  menuitem4 = gtk_menu_item_new_with_mnemonic ("_Help");
  gtk_widget_show (menuitem4);
  gtk_container_add (GTK_CONTAINER (menubar1), menuitem4);

  menuitem4_menu = gtk_menu_new ();
  gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem4), menuitem4_menu);

  about1 = gtk_menu_item_new_with_mnemonic ("_About");
  gtk_widget_show (about1);
  gtk_container_add (GTK_CONTAINER (menuitem4_menu), about1);

  handlebox2 = gtk_handle_box_new ();
  gtk_widget_show (handlebox2);
  gtk_box_pack_start (GTK_BOX (hbox2), handlebox2, FALSE, TRUE, 0);

  hbox3 = gtk_hbox_new (FALSE, 0);
  gtk_widget_show (hbox3);
  gtk_container_add (GTK_CONTAINER (handlebox2), hbox3);

  stopbtn = gtk_button_new ();
  gtk_widget_show (stopbtn);
  gtk_box_pack_start (GTK_BOX (hbox3), stopbtn, FALSE, FALSE, 0);
  gtk_button_set_relief (GTK_BUTTON (stopbtn), GTK_RELIEF_NONE);

  image1 = gtk_image_new_from_stock ("gtk-media-stop", GTK_ICON_SIZE_BUTTON);
  gtk_widget_show (image1);
  gtk_container_add (GTK_CONTAINER (stopbtn), image1);

  playbtn = gtk_button_new ();
  gtk_widget_show (playbtn);
  gtk_box_pack_start (GTK_BOX (hbox3), playbtn, FALSE, FALSE, 0);
  gtk_button_set_relief (GTK_BUTTON (playbtn), GTK_RELIEF_NONE);

  image2 = gtk_image_new_from_stock ("gtk-media-play", GTK_ICON_SIZE_BUTTON);
  gtk_widget_show (image2);
  gtk_container_add (GTK_CONTAINER (playbtn), image2);

  pausebtn = gtk_button_new ();
  gtk_widget_show (pausebtn);
  gtk_box_pack_start (GTK_BOX (hbox3), pausebtn, FALSE, FALSE, 0);
  gtk_button_set_relief (GTK_BUTTON (pausebtn), GTK_RELIEF_NONE);

  image3 = gtk_image_new_from_stock ("gtk-media-pause", GTK_ICON_SIZE_BUTTON);
  gtk_widget_show (image3);
  gtk_container_add (GTK_CONTAINER (pausebtn), image3);

  prevbtn = gtk_button_new ();
  gtk_widget_show (prevbtn);
  gtk_box_pack_start (GTK_BOX (hbox3), prevbtn, FALSE, FALSE, 0);
  gtk_button_set_relief (GTK_BUTTON (prevbtn), GTK_RELIEF_NONE);

  image4 = gtk_image_new_from_stock ("gtk-media-previous", GTK_ICON_SIZE_BUTTON);
  gtk_widget_show (image4);
  gtk_container_add (GTK_CONTAINER (prevbtn), image4);

  nextbtn = gtk_button_new ();
  gtk_widget_show (nextbtn);
  gtk_box_pack_start (GTK_BOX (hbox3), nextbtn, FALSE, FALSE, 0);
  gtk_button_set_relief (GTK_BUTTON (nextbtn), GTK_RELIEF_NONE);

  image5 = gtk_image_new_from_stock ("gtk-media-next", GTK_ICON_SIZE_BUTTON);
  gtk_widget_show (image5);
  gtk_container_add (GTK_CONTAINER (nextbtn), image5);

  playrand = gtk_button_new ();
  gtk_widget_show (playrand);
  gtk_box_pack_start (GTK_BOX (hbox3), playrand, FALSE, FALSE, 0);
  gtk_button_set_relief (GTK_BUTTON (playrand), GTK_RELIEF_NONE);

  alignment1 = gtk_alignment_new (0.5, 0.5, 0, 0);
  gtk_widget_show (alignment1);
  gtk_container_add (GTK_CONTAINER (playrand), alignment1);

  hbox4 = gtk_hbox_new (FALSE, 2);
  gtk_widget_show (hbox4);
  gtk_container_add (GTK_CONTAINER (alignment1), hbox4);

  image6 = gtk_image_new_from_stock ("gtk-media-play", GTK_ICON_SIZE_BUTTON);
  gtk_widget_show (image6);
  gtk_box_pack_start (GTK_BOX (hbox4), image6, FALSE, FALSE, 0);

  label3 = gtk_label_new_with_mnemonic ("?");
  gtk_widget_show (label3);
  gtk_box_pack_start (GTK_BOX (hbox4), label3, FALSE, FALSE, 0);

  handlebox3 = gtk_handle_box_new ();
  gtk_widget_show (handlebox3);
  gtk_box_pack_start (GTK_BOX (hbox2), handlebox3, FALSE, TRUE, 0);
  gtk_container_set_border_width (GTK_CONTAINER (handlebox3), 1);

  volume = gtk_hscale_new (GTK_ADJUSTMENT (gtk_adjustment_new (100, 0, 100, 0, 0, 0)));
  gtk_widget_show (volume);
  gtk_container_add (GTK_CONTAINER (handlebox3), volume);
  gtk_widget_set_size_request (volume, 80, -1);
  GTK_WIDGET_UNSET_FLAGS (volume, GTK_CAN_FOCUS);
  gtk_scale_set_draw_value (GTK_SCALE (volume), FALSE);

  handlebox4 = gtk_handle_box_new ();
  gtk_widget_show (handlebox4);
  gtk_box_pack_start (GTK_BOX (hbox2), handlebox4, FALSE, TRUE, 0);
  gtk_container_set_border_width (GTK_CONTAINER (handlebox4), 1);

  playpos = gtk_hscale_new (GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, 1000, 0, 0, 0)));
  gtk_widget_show (playpos);
  gtk_container_add (GTK_CONTAINER (handlebox4), playpos);
  gtk_widget_set_size_request (playpos, 200, -1);
  GTK_WIDGET_UNSET_FLAGS (playpos, GTK_CAN_FOCUS);
  gtk_scale_set_draw_value (GTK_SCALE (playpos), FALSE);

  _ = gtk_hbox_new (FALSE, 0);
  gtk_widget_show (_);
  gtk_box_pack_start (GTK_BOX (vbox1), _, TRUE, TRUE, 0);

  playlist = gtk_drawing_area_new ();
  gtk_widget_show (playlist);
  gtk_box_pack_start (GTK_BOX (_), playlist, TRUE, TRUE, 0);
  gtk_widget_set_events (playlist, GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK);

  playscroll = gtk_vscrollbar_new (GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, 1, 1, 0, 0)));
  gtk_widget_show (playscroll);
  gtk_box_pack_start (GTK_BOX (_), playscroll, FALSE, FALSE, 0);

  statusbar1 = gtk_statusbar_new ();
  gtk_widget_show (statusbar1);
  gtk_box_pack_start (GTK_BOX (vbox1), statusbar1, FALSE, FALSE, 0);

  g_signal_connect ((gpointer) mainwin, "destroy",
                    G_CALLBACK (gtk_main_quit),
                    NULL);
  g_signal_connect ((gpointer) open, "activate",
                    G_CALLBACK (on_open_activate),
                    NULL);
  g_signal_connect ((gpointer) add_files, "activate",
                    G_CALLBACK (on_add_files_activate),
                    NULL);
  g_signal_connect ((gpointer) add_folder1, "activate",
                    G_CALLBACK (on_add_folder1_activate),
                    NULL);
  g_signal_connect ((gpointer) preferences1, "activate",
                    G_CALLBACK (on_preferences1_activate),
                    NULL);
  g_signal_connect ((gpointer) quit1, "activate",
                    G_CALLBACK (on_quit1_activate),
                    NULL);
  g_signal_connect ((gpointer) clear1, "activate",
                    G_CALLBACK (on_clear1_activate),
                    NULL);
  g_signal_connect ((gpointer) select_all1, "activate",
                    G_CALLBACK (on_select_all1_activate),
                    NULL);
  g_signal_connect ((gpointer) remove1, "activate",
                    G_CALLBACK (on_remove1_activate),
                    NULL);
  g_signal_connect ((gpointer) crop1, "activate",
                    G_CALLBACK (on_crop1_activate),
                    NULL);
  g_signal_connect ((gpointer) about1, "activate",
                    G_CALLBACK (on_about1_activate),
                    NULL);
  g_signal_connect ((gpointer) stopbtn, "clicked",
                    G_CALLBACK (on_stopbtn_clicked),
                    NULL);
  g_signal_connect ((gpointer) playbtn, "clicked",
                    G_CALLBACK (on_playbtn_clicked),
                    NULL);
  g_signal_connect ((gpointer) pausebtn, "clicked",
                    G_CALLBACK (on_pausebtn_clicked),
                    NULL);
  g_signal_connect ((gpointer) prevbtn, "clicked",
                    G_CALLBACK (on_prevbtn_clicked),
                    NULL);
  g_signal_connect ((gpointer) nextbtn, "clicked",
                    G_CALLBACK (on_nextbtn_clicked),
                    NULL);
  g_signal_connect ((gpointer) playrand, "clicked",
                    G_CALLBACK (on_playrand_clicked),
                    NULL);
  g_signal_connect ((gpointer) volume, "value_changed",
                    G_CALLBACK (on_volume_value_changed),
                    NULL);
  g_signal_connect ((gpointer) playpos, "value_changed",
                    G_CALLBACK (on_playpos_value_changed),
                    NULL);
  g_signal_connect ((gpointer) playlist, "configure_event",
                    G_CALLBACK (on_playlist_configure_event),
                    NULL);
  g_signal_connect ((gpointer) playlist, "expose_event",
                    G_CALLBACK (on_playlist_expose_event),
                    NULL);
  g_signal_connect ((gpointer) playlist, "realize",
                    G_CALLBACK (on_playlist_realize),
                    NULL);
  g_signal_connect ((gpointer) playlist, "button_press_event",
                    G_CALLBACK (on_playlist_button_press_event),
                    NULL);
  g_signal_connect ((gpointer) playlist, "scroll_event",
                    G_CALLBACK (on_playlist_scroll_event),
                    NULL);
  g_signal_connect ((gpointer) playscroll, "value_changed",
                    G_CALLBACK (on_playscroll_value_changed),
                    NULL);

  /* Store pointers to all widgets, for use by lookup_widget(). */
  GLADE_HOOKUP_OBJECT_NO_REF (mainwin, mainwin, "mainwin");
  GLADE_HOOKUP_OBJECT (mainwin, vbox1, "vbox1");
  GLADE_HOOKUP_OBJECT (mainwin, hbox2, "hbox2");
  GLADE_HOOKUP_OBJECT (mainwin, handlebox1, "handlebox1");
  GLADE_HOOKUP_OBJECT (mainwin, menubar1, "menubar1");
  GLADE_HOOKUP_OBJECT (mainwin, menuitem1, "menuitem1");
  GLADE_HOOKUP_OBJECT (mainwin, menuitem1_menu, "menuitem1_menu");
  GLADE_HOOKUP_OBJECT (mainwin, open, "open");
  GLADE_HOOKUP_OBJECT (mainwin, separator2, "separator2");
  GLADE_HOOKUP_OBJECT (mainwin, add_files, "add_files");
  GLADE_HOOKUP_OBJECT (mainwin, add_folder1, "add_folder1");
  GLADE_HOOKUP_OBJECT (mainwin, separator1, "separator1");
  GLADE_HOOKUP_OBJECT (mainwin, preferences1, "preferences1");
  GLADE_HOOKUP_OBJECT (mainwin, separatormenuitem1, "separatormenuitem1");
  GLADE_HOOKUP_OBJECT (mainwin, quit1, "quit1");
  GLADE_HOOKUP_OBJECT (mainwin, edit1, "edit1");
  GLADE_HOOKUP_OBJECT (mainwin, edit1_menu, "edit1_menu");
  GLADE_HOOKUP_OBJECT (mainwin, clear1, "clear1");
  GLADE_HOOKUP_OBJECT (mainwin, select_all1, "select_all1");
  GLADE_HOOKUP_OBJECT (mainwin, selection1, "selection1");
  GLADE_HOOKUP_OBJECT (mainwin, selection1_menu, "selection1_menu");
  GLADE_HOOKUP_OBJECT (mainwin, remove1, "remove1");
  GLADE_HOOKUP_OBJECT (mainwin, crop1, "crop1");
  GLADE_HOOKUP_OBJECT (mainwin, menuitem4, "menuitem4");
  GLADE_HOOKUP_OBJECT (mainwin, menuitem4_menu, "menuitem4_menu");
  GLADE_HOOKUP_OBJECT (mainwin, about1, "about1");
  GLADE_HOOKUP_OBJECT (mainwin, handlebox2, "handlebox2");
  GLADE_HOOKUP_OBJECT (mainwin, hbox3, "hbox3");
  GLADE_HOOKUP_OBJECT (mainwin, stopbtn, "stopbtn");
  GLADE_HOOKUP_OBJECT (mainwin, image1, "image1");
  GLADE_HOOKUP_OBJECT (mainwin, playbtn, "playbtn");
  GLADE_HOOKUP_OBJECT (mainwin, image2, "image2");
  GLADE_HOOKUP_OBJECT (mainwin, pausebtn, "pausebtn");
  GLADE_HOOKUP_OBJECT (mainwin, image3, "image3");
  GLADE_HOOKUP_OBJECT (mainwin, prevbtn, "prevbtn");
  GLADE_HOOKUP_OBJECT (mainwin, image4, "image4");
  GLADE_HOOKUP_OBJECT (mainwin, nextbtn, "nextbtn");
  GLADE_HOOKUP_OBJECT (mainwin, image5, "image5");
  GLADE_HOOKUP_OBJECT (mainwin, playrand, "playrand");
  GLADE_HOOKUP_OBJECT (mainwin, alignment1, "alignment1");
  GLADE_HOOKUP_OBJECT (mainwin, hbox4, "hbox4");
  GLADE_HOOKUP_OBJECT (mainwin, image6, "image6");
  GLADE_HOOKUP_OBJECT (mainwin, label3, "label3");
  GLADE_HOOKUP_OBJECT (mainwin, handlebox3, "handlebox3");
  GLADE_HOOKUP_OBJECT (mainwin, volume, "volume");
  GLADE_HOOKUP_OBJECT (mainwin, handlebox4, "handlebox4");
  GLADE_HOOKUP_OBJECT (mainwin, playpos, "playpos");
  GLADE_HOOKUP_OBJECT (mainwin, _, "_");
  GLADE_HOOKUP_OBJECT (mainwin, playlist, "playlist");
  GLADE_HOOKUP_OBJECT (mainwin, playscroll, "playscroll");
  GLADE_HOOKUP_OBJECT (mainwin, statusbar1, "statusbar1");

  gtk_window_add_accel_group (GTK_WINDOW (mainwin), accel_group);

  return mainwin;
}