~siretart/gxine/bug.542506

« back to all changes in this revision

Viewing changes to src/menu.c

  • Committer: Bazaar Package Importer
  • Author(s): Siggi Langauf
  • Date: 2005-01-05 01:49:18 UTC
  • mto: (2.1.1 etch) (1.1.9 upstream)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20050105014918-wgldiqcd79ck2b0v
Tags: upstream-0.4.1
ImportĀ upstreamĀ versionĀ 0.4.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 * along with this program; if not, write to the Free Software
16
16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
17
 *
18
 
 * $Id: menu.c,v 1.13 2003/03/09 11:42:28 guenter Exp $
 
18
 * $Id: menu.c,v 1.33 2004/12/15 19:23:19 dsalt Exp $
19
19
 *
20
20
 * main/context menu creation / handling
21
21
 */
22
22
 
23
 
#include "config.h"
 
23
#include "globals.h"
24
24
 
25
25
#include <string.h>
 
26
#include <gdk/gdkkeysyms.h>
26
27
 
27
28
#include "menu.h"
28
 
#include "globals.h"
29
 
#include "gtkxine.h"
30
29
#include "playlist.h"
31
 
#include "actions.h"
 
30
#include "engine.h"
32
31
#include "utils.h"
 
32
#include "gtkvideo.h"
 
33
#include "vis.h"
33
34
 
34
35
/* global pointers to menus: */
35
36
 
36
 
GtkMenuShell *media_menu;
 
37
GtkWidget *popup_menu = NULL, *menubar = NULL;
37
38
 
38
 
static GtkItemFactory *item_factory;
 
39
GtkMenuShell *media_menu[2] = { NULL, NULL };
 
40
GtkCheckMenuItem *fullscreen_menu_item[2] = { NULL, NULL },
 
41
                 *deinterlace_menu_item[2] = { NULL, NULL },
 
42
                 *auto_resize_menu_item[2] = { NULL, NULL },
 
43
                 *toolbar_item[3][2] = { { NULL, NULL }, { NULL, NULL },
 
44
                                         { NULL, NULL } };
 
45
GSList *aspect_menu_items[2] = { NULL, NULL };
39
46
 
40
47
/*
41
48
 * context menu
66
73
  char **mrls, *mrl;
67
74
  int    n, i, pos;
68
75
 
69
 
  mrls = gtk_xine_get_autoplay_mrls (GTK_XINE(gtx), data, &n);
 
76
  mrls = xine_get_autoplay_mrls (xine, data, &n);
70
77
 
71
78
  if (!mrls) {
72
79
    playlist_logo();
73
 
    display_error ("Autoplay Input Plugin Failed", 
74
 
                   "Autoplay for input plugin '%s' failed.\n"
75
 
                   "Check engine output for further details.",
 
80
    display_error (_("Autoplay input plugin failed"),
 
81
                   _("Autoplay for input plugin '%s' failed.\n"
 
82
                     "Check engine output for further details."),
76
83
                   data);
77
84
    return;
78
85
  }
81
88
  while (mrl) {
82
89
 
83
90
    if (pos<0)
84
 
      pos = playlist_add_mrl (mrl);
 
91
      pos = playlist_add_mrl (mrl, -1);
85
92
    else
86
 
      playlist_add_mrl (mrl);
 
93
      playlist_add_mrl (mrl, -1);
87
94
 
88
95
    mrl = mrls[++i];
89
96
  }
91
98
  playlist_play (pos);
92
99
}
93
100
 
94
 
static void add_autoplay_entries (GtkMenuShell *submenu) {
 
101
static void add_autoplay_entries (GtkMenuShell *submenu, int index) {
95
102
 
96
 
  GtkWidget    *item;
 
103
  GtkWidget    *item = NULL;
97
104
  int           i;
98
 
  char        **autoplay_ids = gtk_xine_get_autoplay_input_plugin_ids (GTK_XINE(gtx));
 
105
  const char *const *autoplay_ids = xine_get_autoplay_input_plugin_ids (xine);
 
106
 
 
107
  static const struct {
 
108
    char id[8];
 
109
    const char *stock;
 
110
  } stock[] = {
 
111
    { "VCD", GTK_STOCK_CDROM },
 
112
    { "VCDO", GTK_STOCK_CDROM },
 
113
    { "DVD", GTK_STOCK_CDROM },
 
114
    { "CD", GTK_STOCK_CDROM },
 
115
  };
99
116
 
100
117
  if (!autoplay_ids) {
101
 
    printf ("menu: warning: didn't get any autoplay entries\n");
 
118
    logprintf ("menu: warning: didn't get any autoplay entries\n");
102
119
    return;
103
120
  }
104
121
 
105
122
  i=0;
106
123
  while (autoplay_ids[i]) {
 
124
    int j = sizeof (stock) / sizeof (stock[0]);
 
125
    while (j--)
 
126
      if (!strcmp (autoplay_ids[i], stock[j].id))
 
127
      {
 
128
        item = gtk_image_menu_item_new_with_label (autoplay_ids[i]);
 
129
        gtk_image_menu_item_set_image
 
130
          (GTK_IMAGE_MENU_ITEM(item),
 
131
           gtk_image_new_from_stock (stock[j].stock, GTK_ICON_SIZE_MENU));
 
132
        break;
 
133
      }
 
134
    if (j < 0)
 
135
      item = gtk_menu_item_new_with_label (autoplay_ids[i]);
107
136
 
108
 
    item = gtk_menu_item_new_with_label (autoplay_ids[i]);
109
137
    g_signal_connect (GTK_OBJECT(item), "activate", 
110
138
                        G_CALLBACK (autoplay_cb), 
111
139
                        (gpointer) strdup (autoplay_ids[i]));
112
140
 
113
 
    gtk_menu_shell_insert (submenu, item, 6);
 
141
    gtk_menu_shell_insert (submenu, item, ++index);
114
142
    gtk_widget_show(item);
115
143
 
116
144
    i++;
124
152
  if (gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget))) {
125
153
    xine_cfg_entry_t vis_entry;
126
154
 
127
 
    if (gtk_xine_config_lookup_entry (GTK_XINE (gtx), "misc.vis",
128
 
                                      &vis_entry)) {
 
155
    if (xine_config_lookup_entry (xine, "misc.vis", &vis_entry))
 
156
    {
129
157
      vis_entry.str_value = data;
130
 
      gtk_xine_config_update_entry (GTK_XINE(gtx), &vis_entry);
 
158
      xine_config_update_entry (xine, &vis_entry);
131
159
    }
132
 
    gtk_xine_set_vis (GTK_XINE(gtx), data);
 
160
 
 
161
    pthread_mutex_lock (&engine_lock);
 
162
    vis_set (GTK_VIDEO(gtv), data, &audio_port);
 
163
    pthread_mutex_unlock (&engine_lock);
133
164
  }
134
165
}
135
166
 
142
173
  GSList            *group;
143
174
  const char *const *pol;
144
175
 
145
 
  vis = gtk_xine_config_register_string (GTK_XINE (gtx), "misc.vis", "none",
146
 
                                         "Default visualization setting",
147
 
                                         NULL, 40, NULL, NULL);
 
176
  vis = xine_config_register_string (xine, "misc.vis", "none",
 
177
                                     _("Default visualisation setting"),
 
178
                                     NULL, 40, NULL, CONFIG_DATA_NONE);
148
179
 
149
180
  group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (none_item));
150
181
  if (!strcasecmp (vis, "none"))
151
182
    gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(none_item), TRUE);
152
183
 
153
 
  pol = gtk_xine_list_post_plugins_typed (GTK_XINE (gtx),
154
 
                                          XINE_POST_TYPE_AUDIO_VISUALIZATION);
155
 
    
 
184
  pol = xine_list_post_plugins_typed (xine, XINE_POST_TYPE_AUDIO_VISUALIZATION);
156
185
  if (pol) {
157
186
 
158
187
    i = 0;
163
192
      group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM(item));
164
193
 
165
194
      g_signal_connect (GTK_OBJECT(item), "activate", 
166
 
                        G_CALLBACK (vis_cb), 
167
 
                        (gpointer) strdup (pol[i]));
 
195
                        G_CALLBACK (vis_cb), (gpointer) strdup (pol[i]));
168
196
 
169
197
      gtk_menu_shell_insert (submenu, item, 1);
170
198
      gtk_widget_show(item);
178
206
}
179
207
 
180
208
static void open_cb (void) {
181
 
  action_exec ("open_show ();", NULL, NULL);
 
209
  engine_exec ("open_show ();", NULL, NULL);
182
210
}
183
211
 
184
212
static void open_mrl_cb(void) {
185
 
  action_exec ("open_mrl_show ();", NULL, NULL);
 
213
  engine_exec ("open_mrl_show ();", NULL, NULL);
 
214
}
 
215
 
 
216
static void playlist_cb(void) {
 
217
  engine_exec ("playlist_show ();", NULL, NULL);
186
218
}
187
219
 
188
220
static void preferences_cb(void) {
189
 
  action_exec ("preferences_show ();", NULL, NULL);
 
221
  engine_exec ("preferences_show ();", NULL, NULL);
190
222
}
191
223
 
192
224
static void keybindings_cb(void) {
193
 
  action_exec ("keybindings_show ();", NULL, NULL);
 
225
  engine_exec ("keybindings_show ();", NULL, NULL);
194
226
}
195
227
 
196
228
static void exit_cb(void) {
197
 
  action_exec ("exit ();", NULL, NULL);
 
229
  engine_exec ("exit ();", NULL, NULL);
198
230
}
199
231
 
200
232
static void fullscreen_cb(void) {
201
 
  action_exec ("set_fullscreen ();", NULL, NULL);
202
 
}
203
 
 
204
 
static void factor_50_cb(void) {
205
 
  action_exec ("set_video_size (50);", NULL, NULL);
206
 
}
207
 
 
208
 
static void factor_100_cb(void) {
209
 
  action_exec ("set_video_size (100);", NULL, NULL);
210
 
}
211
 
 
212
 
static void factor_200_cb(void) {
213
 
  action_exec ("set_video_size (200);", NULL, NULL);
 
233
  engine_exec ("set_fullscreen ();", NULL, NULL);
 
234
}
 
235
 
 
236
static void tbar_toggle_cb (void)
 
237
{
 
238
  engine_exec ("toolbar_show ();", NULL, NULL);
 
239
}
 
240
 
 
241
static void tbar_position_cb(gpointer data, guint action, GtkWidget *widget)
 
242
{
 
243
  v_engine_exec ("set_toolbar_position (%d);", NULL, NULL, action);
 
244
}
 
245
 
 
246
static void factor_cb(gpointer data, guint action, GtkWidget *widget)
 
247
{
 
248
  v_engine_exec ("set_video_size (%d);", NULL, NULL, action);
214
249
}
215
250
 
216
251
static void zoom_in_cb(void) {
217
 
  action_exec ("set_zoom (get_zoom()+5);", NULL, NULL);
 
252
  engine_exec ("set_zoom (get_zoom()+5);", NULL, NULL);
218
253
}
219
254
static void zoom_out_cb(void) {
220
 
  action_exec ("set_zoom (get_zoom()-5);", NULL, NULL);
221
 
}
222
 
 
223
 
static void aspect_auto_cb(void) {
224
 
  action_exec ("set_aspect (0);", NULL, NULL);
225
 
}
226
 
 
227
 
static void aspect_square_cb(void) {
228
 
  action_exec ("set_aspect (1);", NULL, NULL);
229
 
}
230
 
 
231
 
static void aspect_4_3_cb(void) {
232
 
  action_exec ("set_aspect (2);", NULL, NULL);
233
 
}
234
 
 
235
 
static void aspect_16_9_cb(void) {
236
 
  action_exec ("set_aspect (3);", NULL, NULL);
237
 
}
238
 
 
239
 
static void aspect_dt_cb(void) {
240
 
  action_exec ("set_aspect (42);", NULL, NULL);
 
255
  engine_exec ("set_zoom (get_zoom()-5);", NULL, NULL);
 
256
}
 
257
static void zoom_100_cb(void) {
 
258
  engine_exec ("set_zoom (100);", NULL, NULL);
 
259
}
 
260
 
 
261
static void aspect_cb(gpointer data, guint action, GtkWidget *widget)
 
262
{
 
263
  v_engine_exec ("set_aspect (%d);", NULL, NULL, action);
241
264
}
242
265
 
243
266
static void deinterlace_cb (gpointer callback_data,
245
268
                            GtkWidget *widget) {
246
269
 
247
270
  if (gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget)))
248
 
    action_exec ("set_deinterlace (1);", NULL, NULL);
249
 
  else
250
 
    action_exec ("set_deinterlace (0);", NULL, NULL);
 
271
    engine_exec ("set_deinterlace (1);", NULL, NULL);
 
272
  else
 
273
    engine_exec ("set_deinterlace (0);", NULL, NULL);
 
274
}
 
275
 
 
276
static void auto_resize_cb (gpointer callback_data,
 
277
                            guint callback_action,
 
278
                            GtkWidget *widget) {
 
279
 
 
280
  if (gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget)))
 
281
    engine_exec ("set_auto_resize (1);", NULL, NULL);
 
282
  else
 
283
    engine_exec ("set_auto_resize (0);", NULL, NULL);
251
284
}
252
285
 
253
286
static void mediamarks_add_cb(void) {
254
 
  action_exec ("mm_add_show ();", NULL, NULL);
 
287
  engine_exec ("mm_add_show ();", NULL, NULL);
255
288
}
256
289
 
257
290
static void mediamarks_manage_cb(void) {
258
 
  action_exec ("mm_manage_show ();", NULL, NULL);
 
291
  engine_exec ("mm_manage_show ();", NULL, NULL);
259
292
}
260
293
 
261
294
static void mediamarks_import_cb(void) {
262
 
  action_exec ("import_mediamarks ();", NULL, NULL);
 
295
  engine_exec ("import_mediamarks ();", NULL, NULL);
263
296
}
264
297
 
265
298
static void about_cb(void) {
266
 
  action_exec ("about_show ();", NULL, NULL);
 
299
  engine_exec ("about_show ();", NULL, NULL);
267
300
}
268
301
 
269
302
static void log_cb(void) {
270
 
  action_exec ("log_show ();", NULL, NULL);
 
303
  engine_exec ("log_show ();", NULL, NULL);
271
304
}
272
305
 
273
306
static void stream_info_cb(void) {
274
 
  action_exec ("stream_info_show ();", NULL, NULL);
 
307
  engine_exec ("stream_info_show ();", NULL, NULL);
275
308
}
276
309
 
277
310
static void wizards_cb(void) {
278
 
  action_exec ("run_wizards ();", NULL, NULL);
 
311
  engine_exec ("run_wizards ();", NULL, NULL);
279
312
}
280
313
 
281
314
static void snapshot_cb(void) {
282
 
  action_exec ("snapshot ();", NULL, NULL);
 
315
  engine_exec ("snapshot ();", NULL, NULL);
283
316
}
284
317
 
285
318
static void vis_none_cb (gpointer callback_data,
288
321
  if (gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget))) {
289
322
    xine_cfg_entry_t vis_entry;
290
323
 
291
 
    if (gtk_xine_config_lookup_entry (GTK_XINE (gtx), "misc.vis",
292
 
                                      &vis_entry)) {
 
324
    if (xine_config_lookup_entry (xine, "misc.vis", &vis_entry))
 
325
    {
293
326
      vis_entry.str_value = "none";
294
 
      gtk_xine_config_update_entry (GTK_XINE(gtx), &vis_entry);
 
327
      xine_config_update_entry (xine, &vis_entry);
295
328
    }
296
 
    action_exec ("set_vis (\"none\");", NULL, NULL);
 
329
    engine_exec ("set_vis (\"none\");", NULL, NULL);
297
330
  }
298
331
}
299
332
 
300
 
static void sub_auto_cb (gpointer callback_data,
301
 
                         guint callback_action,
302
 
                         GtkWidget *widget) {
303
 
  if (gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget)))
304
 
    action_exec ("set_sub (-1);", NULL, NULL);
305
 
}
306
 
 
307
 
static void sub_none_cb (gpointer callback_data,
308
 
                         guint callback_action,
309
 
                         GtkWidget *widget) {
310
 
  if (gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget)))
311
 
    action_exec ("set_sub (-2);", NULL, NULL);
312
 
}
313
 
 
314
 
static void sub_ch0_cb(gpointer callback_data,
315
 
                       guint callback_action,
316
 
                       GtkWidget *widget) {
317
 
  if (gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget)))
318
 
    action_exec ("set_sub (0);", NULL, NULL);
319
 
}
320
 
 
321
 
static void sub_ch1_cb(gpointer callback_data,
322
 
                       guint callback_action,
323
 
                       GtkWidget *widget) {
324
 
  if (gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget)))
325
 
    action_exec ("set_sub (1);", NULL, NULL);
326
 
}
327
 
 
328
 
static void sub_ch2_cb(gpointer callback_data,
329
 
                       guint callback_action,
330
 
                       GtkWidget *widget) {
331
 
  if (gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget)))
332
 
    action_exec ("set_sub (2);", NULL, NULL);
333
 
}
334
 
 
335
 
static void sub_ch3_cb(gpointer callback_data,
336
 
                       guint callback_action,
337
 
                       GtkWidget *widget) {
338
 
  if (gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget)))
339
 
    action_exec ("set_sub (3);", NULL, NULL);
340
 
}
341
 
 
342
 
static void sub_ch4_cb(gpointer callback_data,
343
 
                       guint callback_action,
344
 
                       GtkWidget *widget) {
345
 
  if (gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget)))
346
 
    action_exec ("set_sub (4);", NULL, NULL);
347
 
}
348
 
 
349
 
static void sub_ch5_cb(gpointer callback_data,
350
 
                       guint callback_action,
351
 
                       GtkWidget *widget) {
352
 
  if (gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget)))
353
 
    action_exec ("set_sub (5);", NULL, NULL);
354
 
}
355
 
 
356
 
static void sub_ch6_cb(gpointer callback_data,
357
 
                       guint callback_action,
358
 
                       GtkWidget *widget) {
359
 
  if (gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget)))
360
 
    action_exec ("set_sub (6);", NULL, NULL);
361
 
}
362
 
 
363
 
static void sub_ch7_cb(gpointer callback_data,
364
 
                       guint callback_action,
365
 
                       GtkWidget *widget) {
366
 
  if (gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget)))
367
 
    action_exec ("set_sub (7);", NULL, NULL);
368
 
}
369
 
 
 
333
static void settings_cb(void) {
 
334
  engine_exec ("settings_show ();", NULL, NULL);
 
335
}
 
336
 
 
337
static void sub_cb (gpointer data, guint action, GtkWidget *widget)
 
338
{
 
339
  if (gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget)))
 
340
    v_engine_exec ("set_sub (%d);", NULL, NULL, action);
 
341
}
 
342
 
 
343
static void popdown_idle_cb (GtkWidget *widget)
 
344
{
 
345
  gdk_threads_enter ();
 
346
  gtk_menu_popdown (GTK_MENU(widget));
 
347
  gdk_threads_leave ();
 
348
}
 
349
 
 
350
static gboolean popup_key_cb (GtkWidget *widget, GdkEventKey *event,
 
351
                              gpointer data)
 
352
{
 
353
  if (event->keyval != GDK_F10 || (event->state & GXINE_MODIFIER_MASK))
 
354
    return FALSE;
 
355
  g_idle_add ((GSourceFunc) popdown_idle_cb, widget);
 
356
  return TRUE;
 
357
}
 
358
 
 
359
#define STOCK(x) "<StockItem>", GTK_STOCK_##x
 
360
#define ASPECT(x) aspect_cb, XINE_VO_ASPECT_##x
370
361
static GtkItemFactoryEntry menu_items[] = {
371
 
  { "/_File",                  NULL,         NULL, 0, "<Branch>" },
372
 
  { "/File/_Open...",          "<control>O", open_cb, 0, NULL },
373
 
  { "/File/Open _MRL...",      "<control>M", open_mrl_cb, 0, NULL },
374
 
  { "/File/sep0",              NULL,         NULL, 0, "<Separator>" },
375
 
  { "/File/Preferences...",    NULL,         preferences_cb, 0, NULL },
376
 
  { "/File/Keybindings...",    NULL,         keybindings_cb, 0, NULL },
377
 
  { "/File/sep1",              NULL,         NULL, 0, "<Separator>" },
378
 
  { "/File/sep2",              NULL,         NULL, 0, "<Separator>" },
379
 
  { "/File/Snapshot...",       "<control>S", snapshot_cb, 0, NULL },
380
 
  { "/File/sep3",              NULL,         NULL, 0, "<Separator>" },
381
 
  { "/File/Quit",              "<control>Q", exit_cb, 0, NULL },
382
 
  { "/_View",                  NULL,         NULL, 0, "<Branch>" },
383
 
  { "/View/_Fullscreen mode",  "<control>F", fullscreen_cb, 0, NULL },
384
 
  { "/View/sep3",              NULL,         NULL, 0, "<Separator>" },
385
 
  { "/View/_50%",              NULL,         factor_50_cb, 0, NULL },
386
 
  { "/View/_100%",             NULL,         factor_100_cb, 0, NULL },
387
 
  { "/View/_200%",             NULL,         factor_200_cb, 0, NULL },
388
 
  { "/View/sep4",              NULL,         NULL, 0, "<Separator>" },
389
 
  { "/View/Zoom in",           NULL,         zoom_in_cb, 0, NULL },
390
 
  { "/View/Zoom out",          NULL,         zoom_out_cb, 0, NULL },
391
 
  { "/View/sep5",              NULL,         NULL, 0, "<Separator>" },
392
 
  { "/View/_DeInterlace",      "<control>I", deinterlace_cb, 0, "<CheckItem>" }, 
393
 
  { "/View/_Aspect ratio",     NULL,         NULL, 0, "<Branch>" },
394
 
  { "/View/Aspect ratio/Auto", NULL,         aspect_auto_cb, 0, NULL},
395
 
  { "/View/Aspect ratio/Square",NULL,        aspect_square_cb, 0, NULL},
396
 
  { "/View/Aspect ratio/4:3",  NULL,         aspect_4_3_cb, 0, NULL},
397
 
  { "/View/Aspect ratio/16:9", NULL,         aspect_16_9_cb, 0, NULL},
398
 
  { "/View/Aspect ratio/Don't touch", NULL,  aspect_dt_cb, 0, NULL},
399
 
  { "/View/sep6",              NULL,         NULL, 0, "<Separator>" },
400
 
  { "/View/_Visualizations",   NULL,         NULL, 0, "<Branch>" },
401
 
  { "/View/Visualizations/None", NULL,       vis_none_cb, 0, "<RadioItem>"},
402
 
  { "/View/sep7",              NULL,         NULL, 0, "<Separator>" },
403
 
  { "/View/_Subtitles",        NULL,         NULL, 0, "<Branch>" },
404
 
  { "/View/Subtitles/Auto",    NULL,         sub_auto_cb, 0, "<RadioItem>"},
405
 
  { "/View/Subtitles/None",    NULL,         sub_none_cb, 0, "/View/Subtitles/Auto"},
406
 
  { "/View/Subtitles/Channel 0", NULL,       sub_ch0_cb, 0, "/View/Subtitles/Auto"},
407
 
  { "/View/Subtitles/Channel 1", NULL,       sub_ch1_cb, 0, "/View/Subtitles/Auto"},
408
 
  { "/View/Subtitles/Channel 2", NULL,       sub_ch2_cb, 0, "/View/Subtitles/Auto"},
409
 
  { "/View/Subtitles/Channel 3", NULL,       sub_ch3_cb, 0, "/View/Subtitles/Auto"},
410
 
  { "/View/Subtitles/Channel 4", NULL,       sub_ch4_cb, 0, "/View/Subtitles/Auto"},
411
 
  { "/View/Subtitles/Channel 5", NULL,       sub_ch5_cb, 0, "/View/Subtitles/Auto"},
412
 
  { "/View/Subtitles/Channel 6", NULL,       sub_ch6_cb, 0, "/View/Subtitles/Auto"},
413
 
  { "/View/Subtitles/Channel 7", NULL,       sub_ch7_cb, 0, "/View/Subtitles/Auto"},
414
 
  { "/_Media",                 NULL,         NULL, 0, "<Branch>" },
415
 
  { "/Media/_Add Mediamark...","<control>D", mediamarks_add_cb, 0, NULL },
416
 
  { "/Media/_Manage Medimarks...","<control>B", mediamarks_manage_cb, 0, NULL },
417
 
  { "/Media/_Import Medimarks...",NULL,      mediamarks_import_cb, 0, NULL },
418
 
  { "/Media/sep8",             NULL,         NULL, 0, "<Separator>" },
419
 
  { "/_Help",                  NULL,         NULL, 0, "<LastBranch>" },
420
 
  { "/Help/About...",          NULL,         about_cb, 0, NULL },
421
 
  { "/Help/Engine _Log...",    "<control>L", log_cb, 0, NULL },
422
 
  { "/Help/Stream _Info...",   NULL,         stream_info_cb, 0, NULL },
423
 
  { "/Help/sep6",              NULL,         NULL, 0, "<Separator>" },
424
 
  { "/Help/_Re-run setup wizards...", NULL,  wizards_cb, 0, NULL },
 
362
  { N_("/_File"),                       NULL,           NULL, 0,                "<Branch>" },
 
363
  { N_("/File/_Open..."),               "<control>O",   open_cb, 0,             STOCK(OPEN) },
 
364
  { N_("/File/Open _MRL..."),           "<control>M",   open_mrl_cb, 0,         NULL },
 
365
  { N_("/File/Play_list..."),           NULL,           playlist_cb, 0,         NULL },
 
366
  { "/File/sep0",                       NULL,           NULL, 0,                "<Separator>" },
 
367
  { N_("/File/_Preferences..."),        NULL,           preferences_cb, 0,      STOCK(PREFERENCES) },
 
368
  { N_("/File/_Keybindings..."),        NULL,           keybindings_cb, 0,      NULL },
 
369
  { "/File/sep1",                       NULL,           NULL, 0,                "<Separator>" },
 
370
  { "/File/sep2",                       NULL,           NULL, 0,                "<Separator>" },
 
371
  { N_("/File/_Snapshot..."),           "<control>S",   snapshot_cb, 0,         NULL },
 
372
  { "/File/sep3",                       NULL,           NULL, 0,                "<Separator>" },
 
373
  { N_("/File/_Quit"),                  "<control>Q",   exit_cb, 0,             STOCK(QUIT) },
 
374
  { N_("/_View"),                       NULL,           NULL, 0,                "<Branch>" },
 
375
  { N_("/View/_Fullscreen mode"),       "<control>F",   fullscreen_cb, 0,       "<CheckItem>" },
 
376
  { N_("/View/Fullscreen _toolbar"),    NULL,           NULL, 0,                "<Branch>" },
 
377
  { N_("/View/Fullscreen toolbar/_Visible"),    NULL,   tbar_toggle_cb, 0,      "<CheckItem>" },
 
378
  { N_("/View/Fullscreen toolbar/At _top"),     NULL,   tbar_position_cb, 1,    "<RadioItem>" },
 
379
  { N_("/View/Fullscreen toolbar/At _bottom"),  NULL,   tbar_position_cb, 0,    "/View/Fullscreen toolbar/At top" },
 
380
  { "/View/sep3",                       NULL,           NULL, 0,                "<Separator>" },
 
381
  { N_("/View/_50%"),                   NULL,           factor_cb, 50,          NULL },
 
382
  { N_("/View/_100%"),                  NULL,           factor_cb, 100,         NULL },
 
383
  { N_("/View/_200%"),                  NULL,           factor_cb, 200,         NULL },
 
384
  { "/View/sep4",                       NULL,           NULL, 0,                "<Separator>" },
 
385
  { N_("/View/Zoom _in"),               NULL,           zoom_in_cb, 0,          STOCK(ZOOM_IN) },
 
386
  { N_("/View/Zoom _out"),              NULL,           zoom_out_cb, 0,         STOCK(ZOOM_OUT) },
 
387
  { N_("/View/_Zoom 100%"),             NULL,           zoom_100_cb, 0,         STOCK(ZOOM_100) },
 
388
  { "/View/sep5",                       NULL,           NULL, 0,                "<Separator>" },
 
389
  { N_("/View/_Deinterlace"),           "<control>I",   deinterlace_cb, 0,      "<CheckItem>" },
 
390
  { N_("/View/Auto _resize"),           NULL,           auto_resize_cb, 0,      "<CheckItem>" },
 
391
  { N_("/View/_Aspect ratio"),          NULL,           NULL, 0,                "<Branch>" },
 
392
  { N_("/View/Aspect ratio/_Auto"),     NULL,           ASPECT(AUTO),           "<RadioItem>" },
 
393
  { N_("/View/Aspect ratio/_Square"),   NULL,           ASPECT(SQUARE),         "/View/Aspect ratio/Auto"},
 
394
  { N_("/View/Aspect ratio/_4:3"),      NULL,           ASPECT(4_3),            "/View/Aspect ratio/Auto"},
 
395
  { N_("/View/Aspect ratio/_16:9"),     NULL,           ASPECT(ANAMORPHIC),     "/View/Aspect ratio/Auto"},
 
396
  { N_("/View/Aspect ratio/_2:1"),      NULL,           ASPECT(DVB),            "/View/Aspect ratio/Auto"},
 
397
  { N_("/View/A\\/V _settings..."),     NULL,           settings_cb, 0,         NULL },
 
398
  { "/View/sep6",                       NULL,           NULL, 0,                "<Separator>" },
 
399
  { N_("/View/_Visualisations"),        NULL,           NULL, 0,                "<Branch>" },
 
400
  { N_("/View/Visualisations/_None"),   NULL,           vis_none_cb, 0,         "<RadioItem>"},
 
401
  { "/View/sep7",                       NULL,           NULL, 0,                "<Separator>" },
 
402
  { N_("/View/_Subtitles"),             NULL,           NULL, 0,                "<Branch>" },
 
403
  { N_("/View/Subtitles/_Auto"),        NULL,           sub_cb, -1,             "<RadioItem>"},
 
404
  { N_("/View/Subtitles/_None"),        NULL,           sub_cb, -2,             "/View/Subtitles/Auto"},
 
405
  { N_("/View/Subtitles/Channel _0"),   NULL,           sub_cb, 0,              "/View/Subtitles/Auto"},
 
406
  { N_("/View/Subtitles/Channel _1"),   NULL,           sub_cb, 1,              "/View/Subtitles/Auto"},
 
407
  { N_("/View/Subtitles/Channel _2"),   NULL,           sub_cb, 2,              "/View/Subtitles/Auto"},
 
408
  { N_("/View/Subtitles/Channel _3"),   NULL,           sub_cb, 3,              "/View/Subtitles/Auto"},
 
409
  { N_("/View/Subtitles/Channel _4"),   NULL,           sub_cb, 4,              "/View/Subtitles/Auto"},
 
410
  { N_("/View/Subtitles/Channel _5"),   NULL,           sub_cb, 5,              "/View/Subtitles/Auto"},
 
411
  { N_("/View/Subtitles/Channel _6"),   NULL,           sub_cb, 6,              "/View/Subtitles/Auto"},
 
412
  { N_("/View/Subtitles/Channel _7"),   NULL,           sub_cb, 7,              "/View/Subtitles/Auto"},
 
413
  { N_("/_Media"),                      NULL,           NULL, 0,                "<Branch>" },
 
414
  { N_("/Media/_Add media mark..."),    "<control>D",   mediamarks_add_cb, 0,   STOCK(NEW) },
 
415
  { N_("/Media/_Manage media marks..."), "<control>B",  mediamarks_manage_cb, 0, NULL },
 
416
  { N_("/Media/_Import media marks..."), NULL,          mediamarks_import_cb, 0, STOCK(OPEN) },
 
417
  { "/Media/sep8",                      NULL,           NULL, 0,                "<Separator>" },
 
418
  { N_("/_Help"),                       NULL,           NULL, 0,                "<LastBranch>" },
 
419
  { N_("/Help/_About..."),              NULL,           about_cb, 0,            NULL },
 
420
  { N_("/Help/Engine _Log..."),         "<control>L",   log_cb, 0,              NULL },
 
421
  { N_("/Help/Stream _Info..."),        NULL,           stream_info_cb, 0,      NULL },
 
422
  { "/Help/sep6",                       NULL,           NULL, 0,                "<Separator>" },
 
423
  { N_("/Help/_Re-run setup wizards..."), NULL,         wizards_cb, 0,          NULL },
425
424
};
426
425
 
427
 
GtkWidget *create_menus (GtkWidget *window) {
428
 
 
429
 
  GtkAccelGroup    *accel_group;
430
 
  gint              nmenu_items = sizeof (menu_items) / sizeof (menu_items[0]);
 
426
GtkWidget *create_menu_tree (GtkItemFactory **factory, GtkWidget *window,
 
427
                             GtkAccelGroup **accel,
 
428
                             GtkItemFactoryEntry *menu_items,
 
429
                             gint nmenu_items)
 
430
{
 
431
  if (window)
 
432
  {
 
433
    GtkAccelGroup *accel_group =
 
434
      (accel && *accel) ? *accel : gtk_accel_group_new ();
 
435
    if (accel)
 
436
      *accel = accel_group;
 
437
    *factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>",
 
438
                                     accel_group);
 
439
#ifdef ENABLE_NLS
 
440
    gtk_item_factory_set_translate_func (GTK_ITEM_FACTORY (*factory),
 
441
                                         (GtkTranslateFunc) gettext,
 
442
                                         NULL, NULL);
 
443
#endif
 
444
    gtk_item_factory_create_items (*factory, nmenu_items, menu_items, NULL);
 
445
    gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
 
446
  }
 
447
  else
 
448
  {
 
449
    *factory = gtk_item_factory_new (GTK_TYPE_MENU, "<main>", NULL);
 
450
#ifdef ENABLE_NLS
 
451
    gtk_item_factory_set_translate_func (GTK_ITEM_FACTORY (*factory),
 
452
                                         (GtkTranslateFunc) gettext,
 
453
                                         NULL, NULL);
 
454
#endif
 
455
    gtk_item_factory_create_items (*factory, nmenu_items, menu_items, NULL);
 
456
  }
 
457
 
 
458
  return gtk_item_factory_get_widget (*factory, "<main>");
 
459
}
 
460
 
 
461
 
 
462
void create_menus (GtkWidget *window)
 
463
{
 
464
  GtkItemFactory *item_factory[2];
431
465
  GtkRadioMenuItem *none_item;
432
 
 
433
 
  accel_group = gtk_accel_group_new ();
434
 
 
435
 
  item_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>", 
436
 
                                       accel_group);
437
 
 
438
 
  gtk_item_factory_create_items (item_factory, nmenu_items, menu_items, NULL);
439
 
 
440
 
  gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
441
 
 
442
 
  media_menu = GTK_MENU_SHELL (gtk_item_factory_get_widget (item_factory, "/Media"));
443
 
 
444
 
  add_autoplay_entries (GTK_MENU_SHELL (gtk_item_factory_get_widget (item_factory, "/File")));
445
 
  none_item = GTK_RADIO_MENU_ITEM (gtk_item_factory_get_item (item_factory, "/View/Visualizations/None"));
446
 
  add_vis_entries (GTK_MENU_SHELL (gtk_item_factory_get_widget (item_factory, "/View/Visualizations")), none_item) ;
447
 
 
448
 
 
449
 
  return gtk_item_factory_get_widget (item_factory, "<main>");
 
466
  int i;
 
467
 
 
468
  if (window)
 
469
    menubar = create_menu_tree (&item_factory[0], window, NULL,
 
470
                                menu_items, num_menu_items (menu_items));
 
471
  popup_menu = create_menu_tree (&item_factory[1], NULL, NULL,
 
472
                                 menu_items, num_menu_items (menu_items));
 
473
 
 
474
  for (i = !window; i < 2; ++i)
 
475
  {
 
476
    GtkMenuShell *menu;
 
477
    xine_cfg_entry_t entry;
 
478
 
 
479
    media_menu[i] = GTK_MENU_SHELL (gtk_item_factory_get_widget (item_factory[i], "/Media"));
 
480
 
 
481
    fullscreen_menu_item[i]  = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_item (item_factory[i], "/View/Fullscreen mode"));
 
482
 
 
483
    deinterlace_menu_item[i] = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_item (item_factory[i], "/View/Deinterlace"));
 
484
    if (xine_config_lookup_entry (xine, "gui.deinterlace_by_default", &entry))
 
485
      deinterlace_menu_item[i]->active = entry.num_value;
 
486
 
 
487
    auto_resize_menu_item[i] = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_item (item_factory[i], "/View/Auto resize"));
 
488
    auto_resize_menu_item[i]->active = TRUE;
 
489
 
 
490
    toolbar_item[0][i] = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_item (item_factory[i], "/View/Fullscreen toolbar/Visible"));
 
491
    toolbar_item[1][i] = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_item (item_factory[i], "/View/Fullscreen toolbar/At bottom"));
 
492
    toolbar_item[2][i] = GTK_CHECK_MENU_ITEM (gtk_item_factory_get_item (item_factory[i], "/View/Fullscreen toolbar/At top"));
 
493
    if (xine_config_lookup_entry (xine, "gui.fullscreen_toolbar", &entry))
 
494
    {
 
495
      toolbar_item[0][i]->active = (entry.num_value >> 1) & 1;
 
496
      toolbar_item[1][i]->active = (entry.num_value & 1);
 
497
      toolbar_item[2][i]->active = !(entry.num_value & 1);
 
498
    }
 
499
 
 
500
    none_item = GTK_RADIO_MENU_ITEM (gtk_item_factory_get_item (item_factory[i], "/View/Aspect ratio/Auto"));
 
501
    aspect_menu_items[i] = gtk_radio_menu_item_get_group (none_item);
 
502
 
 
503
    menu = GTK_MENU_SHELL (gtk_item_factory_get_widget (item_factory[i],
 
504
                                                        "/File"));
 
505
    add_autoplay_entries (menu, g_list_index (menu->children,
 
506
                                  gtk_item_factory_get_widget (item_factory[i],
 
507
                                                               "/File/sep1")));
 
508
 
 
509
    none_item = GTK_RADIO_MENU_ITEM (gtk_item_factory_get_item (item_factory[i], "/View/Visualisations/None"));
 
510
    add_vis_entries (GTK_MENU_SHELL (gtk_item_factory_get_widget (item_factory[i], "/View/Visualisations")), none_item);
 
511
 
 
512
  }
 
513
 
 
514
  g_signal_connect (GTK_OBJECT(popup_menu), "key-press-event",
 
515
                    G_CALLBACK(popup_key_cb), NULL);
450
516
}
451