Advertisement
sbaldovi

fuse_gtk_menu_01.diff

Mar 22nd, 2012
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 21.11 KB | None | 0 0
  1. Index: utils.c
  2. ===================================================================
  3. --- utils.c (revision 4684)
  4. +++ utils.c (working copy)
  5. @@ -337,10 +337,12 @@
  6.      case UTILS_AUXILIARY_LIB: strncpy( ctx->path, "PROGDIR:lib/", PATH_MAX); return 1;
  7.      case UTILS_AUXILIARY_ROM: strncpy( ctx->path, "PROGDIR:roms/", PATH_MAX); return 1;
  8.      case UTILS_AUXILIARY_WIDGET: strncpy( ctx->path, "PROGDIR:ui/widget/", PATH_MAX); return 1;
  9. +    case UTILS_AUXILIARY_GTK: strncpy( ctx->path, "PROGDIR:ui/gtk/", PATH_MAX); return 1;
  10.  #else
  11.      case UTILS_AUXILIARY_LIB: path_segment = "lib"; break;
  12.      case UTILS_AUXILIARY_ROM: path_segment = "roms"; break;
  13.      case UTILS_AUXILIARY_WIDGET: path_segment = "ui/widget"; break;
  14. +    case UTILS_AUXILIARY_GTK: path_segment = "ui/gtk"; break;
  15.  #endif
  16.      default:
  17.        ui_error( UI_ERROR_ERROR, "unknown auxiliary file type %d", ctx->type );
  18. Index: utils.h
  19. ===================================================================
  20. --- utils.h (revision 4684)
  21. +++ utils.h (working copy)
  22. @@ -43,6 +43,7 @@
  23.    UTILS_AUXILIARY_LIB,     /* Something from the lib/ directory */
  24.    UTILS_AUXILIARY_ROM,     /* Something from the roms/ directory */
  25.    UTILS_AUXILIARY_WIDGET,  /* Something from the widget/ directory */
  26. +  UTILS_AUXILIARY_GTK,     /* Something from the gtk/ directory */
  27.  
  28.  } utils_aux_type;
  29.  
  30. Index: menu.h
  31. ===================================================================
  32. --- menu.h  (revision 4684)
  33. +++ menu.h  (working copy)
  34. @@ -34,11 +34,13 @@
  35.  
  36.  #ifdef UI_GTK
  37.  
  38. +#include "compat.h"
  39.  #include <gtk/gtk.h>
  40.  
  41. -#define MENU_CALLBACK( name ) void name( GtkWidget *widget, gpointer data )
  42. +#define MENU_CALLBACK( name ) \
  43. +  void name( GtkAction *gtk_action GCC_UNUSED, gpointer data GCC_UNUSED )
  44.  #define MENU_CALLBACK_WITH_ACTION( name ) \
  45. -  void name( gpointer data, guint action, GtkWidget *widget )
  46. +  void name( GtkAction *gtk_action GCC_UNUSED, guint action )
  47.  
  48.  #else          /* #ifdef UI_GTK */
  49.  
  50. @@ -153,7 +155,7 @@
  51.  MENU_DETAIL( menu_joystick_2_detail );
  52.  
  53.  MENU_CALLBACK( menu_machine_pause );
  54. -MENU_CALLBACK( menu_machine_reset );
  55. +MENU_CALLBACK_WITH_ACTION( menu_machine_reset );
  56.  MENU_CALLBACK( menu_machine_select );
  57.  MENU_DETAIL( menu_machine_detail );
  58.  MENU_CALLBACK( menu_machine_debugger );
  59. Index: menu_data.pl
  60. ===================================================================
  61. --- menu_data.pl    (revision 4684)
  62. +++ menu_data.pl    (working copy)
  63. @@ -31,8 +31,8 @@
  64.  sub cname ($);
  65.  sub dump_widget ($);
  66.  sub _dump_widget ($$);
  67. -sub dump_gtk ($);
  68. -sub _dump_gtk ($$$);
  69. +sub dump_gtk ($$);
  70. +sub _dump_gtk ($$$$$);
  71.  sub dump_win32 ($$);
  72.  sub _dump_win32 ($$$$);
  73.  
  74. @@ -40,9 +40,9 @@
  75.  
  76.  my $ui = shift;
  77.  my $filename;
  78. +my $mode = 'none';
  79.  
  80.  # for Win32:
  81. -my $mode;
  82.  my $idmnum = 100;
  83.  
  84.  if( $ui eq 'win32' ) {
  85. @@ -50,12 +50,17 @@
  86.  
  87.    $mode = shift;
  88.    $filename = 'menu_data.' . $mode;
  89. +} elsif( $ui eq 'gtk' ) {
  90. +  die "$0: dump_gtk: which mode -- c, or ui?" unless @ARGV >= 1;
  91. +
  92. +  $mode = shift;
  93. +  $filename = 'menu_data.' . $mode;
  94.  } else {
  95.    $filename = 'menu_data.c';
  96.  }
  97.  
  98.  print Fuse::GPL( $filename . ': menu structure for Fuse',
  99. -        '2004-2007 Philip Kendall, Stuart Brady, Marek Januszewski' ) . << "CODE";
  100. +        '2004-2007 Philip Kendall, Stuart Brady, Marek Januszewski' ) . << "CODE" if $mode ne 'ui';
  101.  
  102.  /* This file is autogenerated from menu_data.dat by $0.
  103.     Any changes made here will not be preserved. */
  104. @@ -106,7 +111,7 @@
  105.  }
  106.  
  107.  if( $ui eq 'gtk' ) {
  108. -    dump_gtk( \%menus );
  109. +    dump_gtk( $mode, \%menus );
  110.  } elsif( $ui eq 'widget' ) {
  111.      dump_widget( \%menus );
  112.  } elsif( $ui eq 'win32' ) {
  113. @@ -211,62 +216,124 @@
  114.      print $s;
  115.  }
  116.  
  117. -sub dump_gtk ($) {
  118. +sub dump_gtk ($$) {
  119.  
  120. -    my( $menu ) = @_;
  121. +  my( $mode, $menu ) = @_;
  122.  
  123. +  if( $mode eq 'c' ) {
  124. +
  125.      print << "HEADERS";
  126.  #include <gtk/gtk.h>
  127.  
  128.  HEADERS
  129.  
  130. -    print "GtkItemFactoryEntry gtkui_menu_data[] = {\n\n";
  131. +    print "/* Bindings to callbacks with action */\n";
  132.  
  133. -    _dump_gtk( $menu, '', 'menu' );
  134. +    _dump_gtk( 'callbacks', $menu, '', 'menu', '  ' );
  135.  
  136. +    print "GtkActionEntry gtkui_menu_data[] = {\n\n";
  137. +
  138. +    _dump_gtk( 'actions', $menu, '', 'menu', '  ' );
  139. +
  140.      print << "CODE";
  141.  
  142.  };
  143.  
  144.  guint gtkui_menu_data_size =
  145. -  sizeof( gtkui_menu_data ) / sizeof( GtkItemFactoryEntry );
  146. +  sizeof( gtkui_menu_data ) / sizeof( GtkActionEntry );
  147.  CODE
  148. -  
  149. +
  150. + } elsif( $mode eq 'ui' ) {
  151. +
  152. +    print << "XML";
  153. +<?xml version="1.0" encoding="utf-8"?>
  154. +<ui>
  155. +  <menubar name='MainMenu'>
  156. +XML
  157. +
  158. +    _dump_gtk( 'ui', $menu, '', 'menu', '    ' );
  159. +
  160. +    print << "XML";
  161. +  </menubar>
  162. +</ui>
  163. +XML
  164. +
  165. +  }
  166.  }
  167.  
  168. -sub _dump_gtk ($$$) {
  169. +sub _dump_gtk ($$$$$) {
  170.  
  171. -    my( $menu, $gtk_path, $cpath ) = @_;
  172. +  my( $mode, $menu, $gtk_path, $cpath, $spaces ) = @_;
  173.  
  174. -    foreach my $item ( @{ $menu->{submenu} } ) {
  175. +  foreach my $item ( @{ $menu->{submenu} } ) {
  176.  
  177. -   my $name = $item->{name};
  178. -   $name =~ s/_// if !$gtk_path;
  179. +    next if $item->{type} eq 'Separator' && $mode ne 'ui';
  180.  
  181. -   print "  { \"$gtk_path/$name\", ";
  182. +    #Remove toplevel accelerators
  183. +    my $name = $item->{name};
  184. +    $name =~ s/_// if !$gtk_path;
  185. +    my $label = $name;
  186.  
  187. -   if( $item->{hotkey} ) {
  188. -       print "\"$item->{hotkey}\"";
  189. -   } else {
  190. -       print 'NULL';
  191. -   }
  192. +    my $action_name = $name;
  193. +    $action_name =~ s/_//;
  194. +    $action_name = $gtk_path . "/" . $action_name;
  195. +    $action_name =~ s|/|_|g;
  196. +    $action_name =~ s/_//;
  197. +    $action_name = uc( cname( $action_name ) );
  198.  
  199. -   print ", ";
  200. +    $name =~ s/_// if $gtk_path;
  201. +    my $new_cpath = "${cpath}_" . cname( $name );
  202. +    my $function;
  203. +    my $binded_function = $item->{function} || $new_cpath;
  204.  
  205. -   $name =~ s/_// if $gtk_path;
  206. -   my $new_cpath = "${cpath}_" . cname( $name );
  207. +    if( $item->{type} eq 'Item' && $item->{action} ) {
  208. +      $function = $new_cpath;
  209. +    } else {
  210. +      $function = $binded_function;
  211. +    }
  212.  
  213. -   if( $item->{type} eq 'Item' ) {
  214. -       my $function = $item->{function} || $new_cpath;
  215. -       print $function;
  216. -   } else {
  217. -       print 'NULL';
  218. -   }
  219. +    if( $mode eq 'callbacks' ) {
  220. +      if( $item->{type} eq 'Item' && $item->{action} ) {
  221. +        print "MENU_CALLBACK( ", $function, " )\n{\n";
  222. +        print "  $binded_function( gtk_action, $item->{action} );\n}\n\n";
  223. +      }
  224. +    } elsif( $mode eq 'ui' ) {
  225. +      if( $item->{type} eq 'Item' ) {
  226. +        print "$spaces<menuitem name='$name' action='$action_name'/>\n";
  227. +      } elsif( $item->{type} eq 'Separator' ) {
  228. +        print "$spaces<separator/>\n";
  229. +      } else {
  230. +        print "$spaces<menu name='", $name, "' action='", $action_name, "'>\n";
  231. +      }
  232. +    } else {
  233. +      #action_name, stock_id, label
  234. +      print "  { \"$action_name\", NULL, \"$label\", ";
  235.  
  236. -   print ", ", $item->{action} || 0, ", \"<$item->{type}>\", NULL },\n";
  237. +      #hotkey
  238. +      if( $item->{hotkey} ) {
  239. +        print "\"$item->{hotkey}\"";
  240. +      } else {
  241. +        print 'NULL';
  242. +      }
  243.  
  244. -   _dump_gtk( $item, "$gtk_path/$name", $new_cpath ) if $item->{submenu};
  245. +      #tooltip
  246. +      print ", NULL, ";
  247. +
  248. +      #callback
  249. +      if( $item->{type} eq 'Item' ) {
  250. +        print "G_CALLBACK( ", $function, " )";
  251. +      } else {
  252. +        print "NULL";
  253. +      }
  254. +
  255. +      print " },\n";
  256.      }
  257. +
  258. +    _dump_gtk( $mode, $item, "$gtk_path/$name", $new_cpath, $spaces . "  " )
  259. +               if $item->{submenu};
  260. +
  261. +    print "$spaces</menu>\n" if $mode eq 'ui' && $item->{type} eq 'Branch';
  262. +  }
  263.  }
  264.  
  265.  sub dump_win32 ($$) {
  266.  
  267. Property changes on: ui/gtk
  268. ___________________________________________________________________
  269. Modified: svn:ignore
  270.    - *.la
  271. *.lo
  272. .deps
  273. .libs
  274. Makefile
  275. Makefile.in
  276. keysyms.c
  277. menu_data.c
  278. options.c
  279. options.h
  280. options_internals.h
  281.  
  282.    + *.la
  283. *.lo
  284. .deps
  285. .libs
  286. Makefile
  287. Makefile.in
  288. keysyms.c
  289. menu_data.c
  290. options.c
  291. options.h
  292. options_internals.h
  293. menu_data.ui
  294.  
  295.  
  296. Index: ui/gtk/browse.c
  297. ===================================================================
  298. --- ui/gtk/browse.c (revision 4684)
  299. +++ ui/gtk/browse.c (working copy)
  300. @@ -59,8 +59,8 @@
  301.  static int dialog_created; /* Have we created the dialog box yet? */
  302.  
  303.  void
  304. -menu_media_tape_browse( GtkWidget *widget GCC_UNUSED,
  305. -           gpointer data GCC_UNUSED )
  306. +menu_media_tape_browse( GtkAction *gtk_action GCC_UNUSED,
  307. +                        gpointer data GCC_UNUSED )
  308.  {
  309.    /* Firstly, stop emulation */
  310.    fuse_emulation_pause();
  311. Index: ui/gtk/gtkjoystick.c
  312. ===================================================================
  313. --- ui/gtk/gtkjoystick.c    (revision 4684)
  314. +++ ui/gtk/gtkjoystick.c    (working copy)
  315. @@ -130,9 +130,8 @@
  316.  static const guint key_menu_count = sizeof( key_menu ) / sizeof( key_menu[0] );
  317.  
  318.  void
  319. -menu_options_joysticks_select( gpointer callback_data GCC_UNUSED,
  320. -                  guint callback_action,
  321. -                  GtkWidget *widget GCC_UNUSED )
  322. +menu_options_joysticks_select( GtkAction *gtk_action GCC_UNUSED,
  323. +                               guint callback_action )
  324.  {
  325.    GtkWidget *dialog, *hbox, *vbox;
  326.    struct joystick_info info;
  327. Index: ui/gtk/memory.c
  328. ===================================================================
  329. --- ui/gtk/memory.c (revision 4684)
  330. +++ ui/gtk/memory.c (working copy)
  331. @@ -86,8 +86,8 @@
  332.  }
  333.  
  334.  void
  335. -menu_machine_memorybrowser( GtkWidget *widget GCC_UNUSED,
  336. -               gpointer data GCC_UNUSED )
  337. +menu_machine_memorybrowser( GtkAction *gtk_action GCC_UNUSED,
  338. +                            gpointer data GCC_UNUSED )
  339.  {
  340.    GtkWidget *dialog, *box, *clist, *scrollbar;
  341.    GtkAdjustment *adjustment;
  342. Index: ui/gtk/gtkinternals.h
  343. ===================================================================
  344. --- ui/gtk/gtkinternals.h   (revision 4684)
  345. +++ ui/gtk/gtkinternals.h   (working copy)
  346. @@ -128,7 +128,7 @@
  347.   * The menu data (menu_data.c)
  348.   */
  349.  
  350. -extern GtkItemFactoryEntry gtkui_menu_data[];
  351. +extern GtkActionEntry gtkui_menu_data[];
  352.  extern guint gtkui_menu_data_size;
  353.  
  354.  /*
  355. Index: ui/gtk/gtkui.c
  356. ===================================================================
  357. --- ui/gtk/gtkui.c  (revision 4684)
  358. +++ ui/gtk/gtkui.c  (working copy)
  359. @@ -61,15 +61,9 @@
  360.  /* The area into which the screen will be drawn */
  361.  GtkWidget *gtkui_drawing_area;
  362.  
  363. -/* Popup menu widget(s), as invoked by F1 */
  364. -GtkWidget *gtkui_menu_popup;
  365. +/* The UIManager used to create the menu bar */
  366. +GtkUIManager *ui_manager_menu = NULL;
  367.  
  368. -/* The item factory used to create the menu bar */
  369. -GtkItemFactory *menu_factory;
  370. -
  371. -/* And that used to create the popup menus */
  372. -GtkItemFactory *popup_factory;
  373. -
  374.  /* True if we were paused via the Machine/Pause menu item */
  375.  static int paused = 0;
  376.  
  377. @@ -91,7 +85,7 @@
  378.  
  379.  static gboolean gtkui_make_menu(GtkAccelGroup **accel_group,
  380.                 GtkWidget **menu_bar,
  381. -               GtkItemFactoryEntry *menu_data,
  382. +               GtkActionEntry *menu_data,
  383.                 guint menu_data_size);
  384.  
  385.  static gboolean gtkui_lose_focus( GtkWidget*, GdkEvent*, gpointer );
  386. @@ -188,8 +182,12 @@
  387.    box = gtk_vbox_new( FALSE, 0 );
  388.    gtk_container_add(GTK_CONTAINER(gtkui_window), box);
  389.  
  390. -  gtkui_make_menu( &accel_group, &menu_bar, gtkui_menu_data,
  391. -          gtkui_menu_data_size );
  392. +  if( gtkui_make_menu( &accel_group, &menu_bar, gtkui_menu_data,
  393. +                       gtkui_menu_data_size ) ) {
  394. +    fprintf(stderr,"%s: couldn't make menus %s:%d\n",
  395. +       fuse_progname,__FILE__,__LINE__);
  396. +    return 1;
  397. +  }
  398.  
  399.    gtk_window_add_accel_group( GTK_WINDOW(gtkui_window), accel_group );
  400.    gtk_box_pack_start( GTK_BOX(box), menu_bar, FALSE, FALSE, 0 );
  401. @@ -233,24 +231,44 @@
  402.  static gboolean
  403.  gtkui_make_menu(GtkAccelGroup **accel_group,
  404.                  GtkWidget **menu_bar,
  405. -                GtkItemFactoryEntry *menu_data,
  406. +                GtkActionEntry *menu_data,
  407.                  guint menu_data_size)
  408.  {
  409. -  *accel_group = gtk_accel_group_new();
  410. -  menu_factory = gtk_item_factory_new( GTK_TYPE_MENU_BAR, "<main>",
  411. -                      *accel_group );
  412. -  gtk_item_factory_create_items( menu_factory, menu_data_size, menu_data,
  413. -                NULL);
  414. -  *menu_bar = gtk_item_factory_get_widget( menu_factory, "<main>" );
  415. +  *accel_group = NULL;
  416. +  *menu_bar = NULL;
  417. +  GError *error = NULL;
  418. +  char ui_file[ PATH_MAX ];
  419. +
  420. +  ui_manager_menu = gtk_ui_manager_new();
  421. +
  422. +  /* Load actions */
  423. +  GtkActionGroup *menu_action_group = gtk_action_group_new( "MenuActionGroup" );
  424. +  gtk_action_group_add_actions( menu_action_group, menu_data, menu_data_size,
  425. +                                NULL );
  426. +  gtk_ui_manager_insert_action_group( ui_manager_menu, menu_action_group, 0 );
  427. +  g_object_unref( menu_action_group );
  428. +
  429. +  /* Load the UI */
  430. +  if( utils_find_file_path( "menu_data.ui", ui_file, UTILS_AUXILIARY_GTK ) ) {
  431. +    fprintf( stderr, "%s: Error getting path for menu_data.ui\n",
  432. +                     fuse_progname );
  433. +    return TRUE;
  434. +  }
  435. +
  436. +  guint ui_menu_id = gtk_ui_manager_add_ui_from_file( ui_manager_menu, ui_file,
  437. +                                                      &error );
  438. +  if( error ) {
  439. +    g_error_free( error );
  440. +    return TRUE;
  441. +  }
  442. +  else if( !ui_menu_id ) return TRUE;
  443. +
  444. +  *accel_group = gtk_ui_manager_get_accel_group( ui_manager_menu );
  445. +
  446. +  *menu_bar = gtk_ui_manager_get_widget( ui_manager_menu, "/MainMenu" );
  447.    g_signal_connect( G_OBJECT( *menu_bar ), "deactivate",
  448.             G_CALLBACK( gtkui_menu_deactivate ), NULL );
  449.  
  450. -  /* We have to recreate the menus for the popup, unfortunately... */
  451. -  popup_factory = gtk_item_factory_new( GTK_TYPE_MENU, "<main>", NULL );
  452. -  gtk_item_factory_create_items( popup_factory, menu_data_size, menu_data,
  453. -                NULL);
  454. -  gtkui_menu_popup = gtk_item_factory_get_widget( popup_factory, "<main>" );
  455. -
  456.    /* Start various menus in the 'off' state */
  457.    ui_menu_activate( UI_MENU_ITEM_AY_LOGGING, 0 );
  458.    ui_menu_activate( UI_MENU_ITEM_FILE_MOVIE_RECORDING, 0 );
  459. @@ -262,22 +280,6 @@
  460.    return FALSE;
  461.  }
  462.  
  463. -static void
  464. -gtkui_popup_menu_pos( GtkMenu *menu GCC_UNUSED, gint *xp, gint *yp,
  465. -             GtkWidget *data GCC_UNUSED )
  466. -{
  467. -  gdk_window_get_position( gtkui_window->window, xp, yp );
  468. -}
  469. -
  470. -/* Popup main menu, as invoked by F1. */
  471. -void
  472. -gtkui_popup_menu(void)
  473. -{
  474. -  gtk_menu_popup( GTK_MENU(gtkui_menu_popup), NULL, NULL,
  475. -         (GtkMenuPositionFunc)gtkui_popup_menu_pos, NULL,
  476. -         0, 0 );
  477. -}
  478. -
  479.  int
  480.  ui_event(void)
  481.  {
  482. @@ -292,6 +294,8 @@
  483.    /* Don't display the window whilst doing all this! */
  484.    gtk_widget_hide( gtkui_window );
  485.  
  486. +  g_object_unref( ui_manager_menu );
  487. +
  488.    return 0;
  489.  }
  490.  
  491. @@ -360,15 +364,16 @@
  492.  
  493.  /* Called by the main window on a "delete-event" */
  494.  static gboolean
  495. -gtkui_delete( GtkWidget *widget, GdkEvent *event GCC_UNUSED, gpointer data )
  496. +gtkui_delete( GtkWidget *widget GCC_UNUSED, GdkEvent *event GCC_UNUSED,
  497. +              gpointer data GCC_UNUSED )
  498.  {
  499. -  menu_file_exit( widget, data );
  500. +  menu_file_exit( NULL, NULL );
  501.    return TRUE;
  502.  }
  503.  
  504.  /* Called by the menu when File/Exit selected */
  505.  void
  506. -menu_file_exit( GtkWidget *widget GCC_UNUSED, gpointer data GCC_UNUSED )
  507. +menu_file_exit( GtkAction *gtk_action GCC_UNUSED, gpointer data GCC_UNUSED )
  508.  {
  509.    if( gtkui_confirm( "Exit Fuse?" ) ) {
  510.  
  511. @@ -472,7 +477,7 @@
  512.  
  513.  /* Machine/Pause */
  514.  void
  515. -menu_machine_pause( GtkWidget *widget GCC_UNUSED, gpointer data GCC_UNUSED )
  516. +menu_machine_pause( GtkAction *gtk_action GCC_UNUSED, gpointer data GCC_UNUSED )
  517.  {
  518.    int error;
  519.  
  520. @@ -499,9 +504,9 @@
  521.  
  522.  /* Called by the menu when Machine/Reset selected */
  523.  void
  524. -menu_machine_reset( GtkWidget *widget GCC_UNUSED, gpointer data )
  525. +menu_machine_reset( GtkAction *gtk_action GCC_UNUSED, guint action )
  526.  {
  527. -  int hard_reset = GPOINTER_TO_INT( data );
  528. +  int hard_reset = action;
  529.  
  530.    if( gtkui_confirm( "Reset?" ) && machine_reset( hard_reset ) ) {
  531.      ui_error( UI_ERROR_ERROR, "couldn't reset machine: giving up!" );
  532. @@ -513,7 +518,8 @@
  533.  
  534.  /* Called by the menu when Machine/Select selected */
  535.  void
  536. -menu_machine_select( GtkWidget *widget GCC_UNUSED, gpointer data GCC_UNUSED )
  537. +menu_machine_select( GtkAction *gtk_action GCC_UNUSED,
  538. +                     gpointer data GCC_UNUSED )
  539.  {
  540.    gtkui_select_info dialog;
  541.  
  542. @@ -587,7 +593,8 @@
  543.  }
  544.  
  545.  void
  546. -menu_machine_debugger( GtkWidget *widget GCC_UNUSED, gpointer data GCC_UNUSED )
  547. +menu_machine_debugger( GtkAction *gtk_action GCC_UNUSED,
  548. +                       gpointer data GCC_UNUSED )
  549.  {
  550.    debugger_mode = DEBUGGER_MODE_HALTED;
  551.    if( paused ) ui_debugger_activate();
  552. @@ -602,13 +609,13 @@
  553.  }
  554.  
  555.  void
  556. -menu_help_keyboard( GtkWidget *widget GCC_UNUSED, gpointer data GCC_UNUSED )
  557. +menu_help_keyboard( GtkAction *gtk_action GCC_UNUSED, gpointer data GCC_UNUSED )
  558.  {
  559.    gtkui_picture( "keyboard.scr", 0 );
  560.  }
  561.  
  562.  void
  563. -menu_help_about( GtkWidget *widget GCC_UNUSED, gpointer data GCC_UNUSED )
  564. +menu_help_about( GtkAction *gtk_action GCC_UNUSED, gpointer data GCC_UNUSED )
  565.  {
  566.    gtk_show_about_dialog( GTK_WINDOW( gtkui_window ),
  567.                           "name", "Fuse",
  568. @@ -634,7 +641,12 @@
  569.  {
  570.    GtkWidget *menu_item;
  571.  
  572. -  menu_item = gtk_item_factory_get_widget( menu_factory, path );
  573. +  /* Translate UI-indepentment path to GTK UI path */
  574. +  gchar *full_path = g_strdup_printf ("/MainMenu%s", path );
  575. +
  576. +  menu_item = gtk_ui_manager_get_widget( ui_manager_menu, full_path );
  577. +  g_free( full_path );
  578. +
  579.    if( !menu_item ) {
  580.      ui_error( UI_ERROR_ERROR, "couldn't get menu item '%s' from menu_factory",
  581.           path );
  582. @@ -642,14 +654,6 @@
  583.    }
  584.    gtk_widget_set_sensitive( menu_item, active );
  585.  
  586. -  menu_item = gtk_item_factory_get_widget( popup_factory, path );
  587. -  if( !menu_item ) {
  588. -    ui_error( UI_ERROR_ERROR, "couldn't get menu item '%s' from popup_factory",
  589. -         path );
  590. -    return 1;
  591. -  }
  592. -  gtk_widget_set_sensitive( menu_item, active );
  593. -
  594.    return 0;
  595.  }
  596.  
  597. Index: ui/gtk/binary.c
  598. ===================================================================
  599. --- ui/gtk/binary.c (revision 4684)
  600. +++ ui/gtk/binary.c (working copy)
  601. @@ -54,8 +54,8 @@
  602.  static void save_data( GtkButton *button, gpointer user_data );
  603.  
  604.  void
  605. -menu_file_loadbinarydata( GtkWidget *widget GCC_UNUSED, gpointer data
  606. -             GCC_UNUSED )
  607. +menu_file_loadbinarydata( GtkAction *gtk_action GCC_UNUSED,
  608. +                          gpointer data GCC_UNUSED )
  609.  {
  610.    struct binary_info info;
  611.  
  612. @@ -203,8 +203,8 @@
  613.  }
  614.    
  615.  void
  616. -menu_file_savebinarydata( GtkWidget *widget GCC_UNUSED, gpointer data
  617. -             GCC_UNUSED )
  618. +menu_file_savebinarydata( GtkAction *gtk_action GCC_UNUSED,
  619. +                          gpointer data GCC_UNUSED )
  620.  {
  621.    struct binary_info info;
  622.  
  623. Index: ui/gtk/pokefinder.c
  624. ===================================================================
  625. --- ui/gtk/pokefinder.c (revision 4684)
  626. +++ ui/gtk/pokefinder.c (working copy)
  627. @@ -67,8 +67,8 @@
  628.  libspectrum_word possible_offset[ MAX_POSSIBLE ];
  629.  
  630.  void
  631. -menu_machine_pokefinder( GtkWidget *widget GCC_UNUSED,
  632. -            gpointer data GCC_UNUSED )
  633. +menu_machine_pokefinder( GtkAction *gtk_action GCC_UNUSED,
  634. +                         gpointer data GCC_UNUSED )
  635.  {
  636.    int error;
  637.  
  638. Index: ui/gtk/Makefile.am
  639. ===================================================================
  640. --- ui/gtk/Makefile.am  (revision 4684)
  641. +++ ui/gtk/Makefile.am  (working copy)
  642. @@ -42,6 +42,7 @@
  643.              keysyms.c \
  644.              memory.c \
  645.              menu_data.c \
  646. +            menu_data.ui \
  647.                  options.c \
  648.              picture.c \
  649.              pixmaps.c \
  650. @@ -56,6 +57,7 @@
  651.  
  652.  BUILT_SOURCES = keysyms.c \
  653.         menu_data.c \
  654. +       menu_data.ui \
  655.         options.c \
  656.         options_internals.h
  657.  
  658. @@ -63,8 +65,11 @@
  659.     @PERL@ -I$(srcdir)/../../perl $(srcdir)/../../keysyms.pl gtk $(srcdir)/../../keysyms.dat > $@.tmp && mv $@.tmp $@
  660.  
  661.  menu_data.c: $(srcdir)/../../perl/cpp-perl.pl $(srcdir)/../../menu_data.pl $(srcdir)/../../menu_data.dat ../../config.h
  662. -   @PERL@ $(srcdir)/../../perl/cpp-perl.pl ../../config.h $(srcdir)/../../menu_data.dat | @PERL@ -I$(srcdir)/../../perl $(srcdir)/../../menu_data.pl gtk > $@.tmp && mv $@.tmp $@
  663. +   @PERL@ $(srcdir)/../../perl/cpp-perl.pl ../../config.h $(srcdir)/../../menu_data.dat | @PERL@ -I$(srcdir)/../../perl $(srcdir)/../../menu_data.pl gtk c > $@.tmp && mv $@.tmp $@
  664.  
  665. +menu_data.ui: $(srcdir)/../../perl/cpp-perl.pl $(srcdir)/../../menu_data.pl $(srcdir)/../../menu_data.dat ../../config.h
  666. +   @PERL@ $(srcdir)/../../perl/cpp-perl.pl ../../config.h $(srcdir)/../../menu_data.dat | @PERL@ -I$(srcdir)/../../perl $(srcdir)/../../menu_data.pl gtk ui > $@.tmp && mv $@.tmp $@
  667. +
  668.  options.c: $(srcdir)/../../perl/cpp-perl.pl ../../config.h $(srcdir)/options.pl $(srcdir)/../../ui/options.dat $(srcdir)/../../perl/Fuse.pm $(srcdir)/../../perl/Fuse/Dialog.pm
  669.     @PERL@ $(srcdir)/../../perl/cpp-perl.pl ../../config.h $(srcdir)/../../ui/options.dat | @PERL@ -I$(srcdir)/../../perl $(srcdir)/options.pl - > $@.tmp && mv $@.tmp $@
  670.  
  671. @@ -78,5 +83,6 @@
  672.  
  673.  CLEANFILES = keysyms.c \
  674.          menu_data.c \
  675. +        menu_data.ui \
  676.          options.c \
  677.          options_internals.h
  678. Index: ui/gtk/pokemem.c
  679. ===================================================================
  680. --- ui/gtk/pokemem.c    (revision 4684)
  681. +++ ui/gtk/pokemem.c    (working copy)
  682. @@ -78,7 +78,7 @@
  683.                             gchar *new_text, gpointer user_data );
  684.  
  685.  void
  686. -menu_machine_pokememory( GtkWidget *widget GCC_UNUSED,
  687. +menu_machine_pokememory( GtkAction *gtk_action GCC_UNUSED,
  688.                           gpointer data GCC_UNUSED )
  689.  {
  690.    fuse_emulation_pause();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement