Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | This patch enable owl menu, which is hidden in the title bar to save space on |
| 2 | small screen. It has not been used for a long time, rebase needed. |
| 3 | |
| 4 | Upstream-Status: Inappropriate [enable feature] |
| 5 | |
| 6 | Index: src/gtk.c |
| 7 | =================================================================== |
| 8 | --- src/gtk.c (revision 22) |
| 9 | +++ src/gtk.c (working copy) |
| 10 | @@ -28,6 +28,8 @@ |
| 11 | #include <gdk/gdkx.h> |
| 12 | #include <gdk-pixbuf/gdk-pixbuf.h> |
| 13 | |
| 14 | +#include <libowl/owlwindowmenu.h> |
| 15 | + |
| 16 | #include <librsvg/rsvg.h> |
| 17 | |
| 18 | #include <X11/Xlib.h> |
| 19 | @@ -1237,6 +1239,7 @@ |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | +#if 0 |
| 24 | static void |
| 25 | add_widget (GtkUIManager *merge, |
| 26 | GtkWidget *widget, |
| 27 | @@ -1247,10 +1250,11 @@ |
| 28 | gtk_box_pack_start (box, widget, FALSE, FALSE, 0); |
| 29 | |
| 30 | toplevel = gtk_widget_get_toplevel (GTK_WIDGET (box)); |
| 31 | - gtk_widget_show_all (toplevel); |
| 32 | } |
| 33 | +#endif |
| 34 | |
| 35 | static GtkActionEntry toplevel_actions[] = { |
| 36 | + { "Top", NULL, "" }, |
| 37 | { "Game", NULL, N_("Game") }, |
| 38 | { "Settings", NULL, N_("Settings") }, |
| 39 | { "Help", NULL, N_("Help") }, |
| 40 | @@ -1303,11 +1307,13 @@ |
| 41 | frontend *fe) |
| 42 | { |
| 43 | GString *xml; |
| 44 | + GError *error = NULL; |
| 45 | gboolean presets = FALSE; |
| 46 | GSList *radio_group = NULL; |
| 47 | int i; |
| 48 | |
| 49 | - xml = g_string_new ("<ui><menubar><placeholder name=\"TypePlaceholder\">" |
| 50 | + xml = g_string_new ("<ui><menubar><menu name=\"TopMenu\" action=\"Top\">" |
| 51 | + "<placeholder name=\"TypePlaceholder\">" |
| 52 | "<menu name=\"SettingsMenu\" action=\"Settings\">"); |
| 53 | |
| 54 | for (i = 0; i < midend_num_presets(fe->me); i++) { |
| 55 | @@ -1359,8 +1365,14 @@ |
| 56 | "<menuitem name=\"CustomMenu\" action=\"Custom\"/>"); |
| 57 | } |
| 58 | |
| 59 | - g_string_append (xml, "</menu></placeholder></menubar></ui>"); |
| 60 | - gtk_ui_manager_add_ui_from_string (merge, xml->str, -1, NULL); |
| 61 | + g_string_append (xml, "</menu></placeholder></menu></menubar></ui>"); |
| 62 | + |
| 63 | + gtk_ui_manager_add_ui_from_string (merge, xml->str, -1, &error); |
| 64 | + if (error != NULL) { |
| 65 | + g_warning ("Error adding custom: %s", error->message); |
| 66 | + g_error_free (error); |
| 67 | + } |
| 68 | + |
| 69 | g_string_free (xml, TRUE); |
| 70 | } |
| 71 | |
| 72 | @@ -1434,6 +1446,7 @@ |
| 73 | new_window(char *arg, char **error) |
| 74 | { |
| 75 | frontend *fe; |
| 76 | + GError *err = NULL; |
| 77 | GtkBox *vbox; |
| 78 | GtkUIManager *merge; |
| 79 | GtkActionGroup *actions; |
| 80 | @@ -1496,8 +1509,6 @@ |
| 81 | gtk_window_add_accel_group(GTK_WINDOW(fe->window), fe->accelgroup); |
| 82 | |
| 83 | merge = gtk_ui_manager_new (); |
| 84 | - g_signal_connect (G_OBJECT (merge), "add_widget", |
| 85 | - G_CALLBACK (add_widget), vbox); |
| 86 | |
| 87 | actions = gtk_action_group_new ("PuzzleActions"); |
| 88 | gtk_action_group_add_actions (actions, toplevel_actions, |
| 89 | @@ -1509,22 +1520,39 @@ |
| 90 | |
| 91 | gtk_ui_manager_insert_action_group (merge, actions, 0); |
| 92 | |
| 93 | - gtk_ui_manager_add_ui_from_file (merge, DATADIR "/oh-puzzles/ui/menu.xml", NULL); |
| 94 | + gtk_ui_manager_add_ui_from_file (merge, DATADIR "/oh-puzzles/ui/menu.xml", |
| 95 | + &err); |
| 96 | + if (err != NULL) { |
| 97 | + g_warning ("Error making UI: %s", err->message); |
| 98 | + g_error_free (err); |
| 99 | + err = NULL; |
| 100 | + } |
| 101 | |
| 102 | if (thegame.can_solve) { |
| 103 | - char *str = "<ui><menubar><menu name=\"GameMenu\" action=\"Game\">" |
| 104 | + char *str = "<ui><menubar><menu name=\"TopMenu\" action=\"Top\">" |
| 105 | + "<menu name=\"GameMenu\" action=\"Game\">" |
| 106 | "<placeholder name=\"SolvePlaceholder\">" |
| 107 | "<separator name=\"SolveSep\"/>" |
| 108 | "<menuitem name=\"SolveMenu\" action=\"Solve\"/>" |
| 109 | - "</placeholder></menu></menubar></ui>"; |
| 110 | + "</placeholder></menu></menu></menubar></ui>"; |
| 111 | |
| 112 | - gtk_ui_manager_add_ui_from_string (merge, str, -1, NULL); |
| 113 | + gtk_ui_manager_add_ui_from_string (merge, str, -1, &err); |
| 114 | + if (err != NULL) { |
| 115 | + g_warning ("Error adding solve. %s", err->message); |
| 116 | + g_error_free (err); |
| 117 | + } |
| 118 | } |
| 119 | |
| 120 | if ((n = midend_num_presets(fe->me)) > 0 || thegame.can_configure) { |
| 121 | generate_settings_menu (merge, actions, fe); |
| 122 | } |
| 123 | |
| 124 | + /* Do this so that the menu is packed now instead of in the idle loop */ |
| 125 | + gtk_ui_manager_ensure_update (merge); |
| 126 | + |
| 127 | + owl_set_window_menu_item (GTK_WINDOW (fe->window), |
| 128 | + GTK_MENU_ITEM (gtk_ui_manager_get_widget (merge, "/menubar/TopMenu"))); |
| 129 | + |
| 130 | setup_colours (fe); |
| 131 | setup_pixbufs (fe); |
| 132 | |
| 133 | @@ -1572,7 +1600,7 @@ |
| 134 | GDK_BUTTON_RELEASE_MASK | |
| 135 | GDK_BUTTON_MOTION_MASK); |
| 136 | |
| 137 | - /* The window is shown once the menubar has been added */ |
| 138 | + gtk_widget_show_all (fe->window); |
| 139 | return fe; |
| 140 | } |
| 141 | |
| 142 | Index: src/menu.xml |
| 143 | =================================================================== |
| 144 | --- src/menu.xml (revision 22) |
| 145 | +++ src/menu.xml (working copy) |
| 146 | @@ -1,26 +1,25 @@ |
| 147 | <ui> |
| 148 | <menubar> |
| 149 | -<menu name="GameMenu" action="Game"> |
| 150 | - <menuitem name="NewMenu" action="New"/> |
| 151 | - <menuitem name="RestartMenu" action="Restart"/> |
| 152 | -<!-- <menuitem name="SpecificMenu" action="Specific"/> --> |
| 153 | - <menuitem name="RandomMenu" action="Random"/> |
| 154 | - <separator name="GameSep1"/> |
| 155 | - <menuitem name="LoadMenu" action="Load"/> |
| 156 | - <menuitem name="SaveMenu" action="Save"/> |
| 157 | - <separator name="GameSep2"/> |
| 158 | - <menuitem name="UndoMenu" action="Undo"/> |
| 159 | - <menuitem name="RedoMenu" action="Redo"/> |
| 160 | - <placeholder name="CopyPlaceholder"/> |
| 161 | - <placeholder name="SolvePlaceholder"/> |
| 162 | - <separator name="GameSep3"/> |
| 163 | - <menuitem name="QuitMenu" action="Quit"/> |
| 164 | -</menu> |
| 165 | +<menu name="TopMenu" action="Top"> |
| 166 | + <menu name="GameMenu" action="Game"> |
| 167 | + <menuitem name="NewMenu" action="New"/> |
| 168 | + <menuitem name="RestartMenu" action="Restart"/> |
| 169 | + <!-- <menuitem name="SpecificMenu" action="Specific"/> --> |
| 170 | + <menuitem name="RandomMenu" action="Random"/> |
| 171 | + <separator name="GameSep1"/> |
| 172 | + <menuitem name="LoadMenu" action="Load"/> |
| 173 | + <menuitem name="SaveMenu" action="Save"/> |
| 174 | + <separator name="GameSep2"/> |
| 175 | + <menuitem name="UndoMenu" action="Undo"/> |
| 176 | + <menuitem name="RedoMenu" action="Redo"/> |
| 177 | + <placeholder name="CopyPlaceholder"/> |
| 178 | + <placeholder name="SolvePlaceholder"/> |
| 179 | + </menu> |
| 180 | |
| 181 | -<placeholder name="TypePlaceholder"/> |
| 182 | - |
| 183 | -<menu name="HelpMenu" action="Help"> |
| 184 | + <placeholder name="TypePlaceholder"/> |
| 185 | <menuitem name="AboutMenu" action="About"/> |
| 186 | + <menuitem name="QuitMenu" action="Quit"/> |
| 187 | + |
| 188 | </menu> |
| 189 | </menubar> |
| 190 | </ui> |
| 191 | Index: src/Makefile.am |
| 192 | =================================================================== |
| 193 | --- src/Makefile.am (revision 22) |
| 194 | +++ src/Makefile.am (working copy) |
| 195 | @@ -10,7 +10,7 @@ |
| 196 | lightup loopy map mines net netslide pattern pegs rect samegame \ |
| 197 | sixteen slant solo tents twiddle untangle |
| 198 | |
| 199 | -libpuzzles_la_LIBADD = $(PUZZLES_LIBS) |
| 200 | +libpuzzles_la_LIBADD = $(PUZZLES_LIBS) -lowl |
| 201 | libpuzzles_la_SOURCES = combi.c \ |
| 202 | configuration.c \ |
| 203 | drawing.c \ |