+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
-<!--Generated with glade3 3.4.5 on Wed May 6 22:39:03 2009 -->
-<glade-interface>
- <widget class="GtkWindow" id="gargoyle-gtk">
- <property name="title" translatable="yes">Gargoyle GTK</property>
- <property name="default_width">500</property>
- <property name="default_height">600</property>
- <signal name="delete_event" handler="on_window_delete_event"/>
- <child>
- <widget class="GtkVBox" id="vbox">
- <property name="visible">True</property>
- <child>
- <widget class="GtkMenuBar" id="menubar">
- <property name="visible">True</property>
- <child>
- <widget class="GtkMenuItem" id="file_menu">
- <property name="visible">True</property>
- <property name="label" translatable="yes">_File</property>
- <property name="use_underline">True</property>
- <child>
- <widget class="GtkMenu" id="menu1">
- <property name="visible">True</property>
- <child>
- <widget class="GtkImageMenuItem" id="file_open">
- <property name="visible">True</property>
- <property name="tooltip" translatable="yes">Opens an interactive fiction game</property>
- <property name="label" translatable="yes">gtk-open</property>
- <property name="use_underline">True</property>
- <property name="use_stock">True</property>
- </widget>
- </child>
- <child>
- <widget class="GtkSeparatorMenuItem" id="separatormenuitem1">
- <property name="visible">True</property>
- </widget>
- </child>
- <child>
- <widget class="GtkImageMenuItem" id="file_quit">
- <property name="visible">True</property>
- <property name="label" translatable="yes">gtk-quit</property>
- <property name="use_underline">True</property>
- <property name="use_stock">True</property>
- <signal name="activate" handler="on_file_quit_activate"/>
- </widget>
- </child>
- </widget>
- </child>
- </widget>
- </child>
- <child>
- <widget class="GtkMenuItem" id="edit_menu">
- <property name="visible">True</property>
- <property name="label" translatable="yes">_Edit</property>
- <property name="use_underline">True</property>
- <child>
- <widget class="GtkMenu" id="menu2">
- <property name="visible">True</property>
- <child>
- <widget class="GtkImageMenuItem" id="edit_cut_menu_item">
- <property name="visible">True</property>
- <property name="label" translatable="yes">gtk-cut</property>
- <property name="use_underline">True</property>
- <property name="use_stock">True</property>
- </widget>
- </child>
- <child>
- <widget class="GtkImageMenuItem" id="edit_copy_menu_item">
- <property name="visible">True</property>
- <property name="label" translatable="yes">gtk-copy</property>
- <property name="use_underline">True</property>
- <property name="use_stock">True</property>
- </widget>
- </child>
- <child>
- <widget class="GtkImageMenuItem" id="edit_paste_menu_item">
- <property name="visible">True</property>
- <property name="label" translatable="yes">gtk-paste</property>
- <property name="use_underline">True</property>
- <property name="use_stock">True</property>
- </widget>
- </child>
- <child>
- <widget class="GtkImageMenuItem" id="edit_delete_menu_item">
- <property name="visible">True</property>
- <property name="label" translatable="yes">gtk-delete</property>
- <property name="use_underline">True</property>
- <property name="use_stock">True</property>
- </widget>
- </child>
- </widget>
- </child>
- </widget>
- </child>
- <child>
- <widget class="GtkMenuItem" id="game_menu">
- <property name="visible">True</property>
- <property name="label" translatable="yes">_Game</property>
- <property name="use_underline">True</property>
- <child>
- <widget class="GtkMenu" id="menu4">
- <property name="visible">True</property>
- <child>
- <widget class="GtkImageMenuItem" id="game_save_menu_item">
- <property name="visible">True</property>
- <property name="tooltip" translatable="yes">Saves your progress in the game</property>
- <property name="label" translatable="yes">_Save</property>
- <property name="use_underline">True</property>
- <child internal-child="image">
- <widget class="GtkImage" id="menu-item-image13">
- <property name="stock">gtk-save</property>
- </widget>
- </child>
- </widget>
- </child>
- <child>
- <widget class="GtkImageMenuItem" id="game_restore_menu_item">
- <property name="visible">True</property>
- <property name="tooltip" translatable="yes">Restores a previously saved game</property>
- <property name="label" translatable="yes">_Restore</property>
- <property name="use_underline">True</property>
- <child internal-child="image">
- <widget class="GtkImage" id="menu-item-image12">
- <property name="stock">gtk-open</property>
- </widget>
- </child>
- </widget>
- </child>
- <child>
- <widget class="GtkImageMenuItem" id="game_restart_menu_item">
- <property name="visible">True</property>
- <property name="tooltip" translatable="yes">Restart the game</property>
- <property name="label" translatable="yes">Res_tart</property>
- <property name="use_underline">True</property>
- <child internal-child="image">
- <widget class="GtkImage" id="menu-item-image11">
- <property name="visible">True</property>
- <property name="stock">gtk-refresh</property>
- </widget>
- </child>
- </widget>
- </child>
- </widget>
- </child>
- </widget>
- </child>
- <child>
- <widget class="GtkMenuItem" id="help_menu">
- <property name="visible">True</property>
- <property name="label" translatable="yes">_Help</property>
- <property name="use_underline">True</property>
- <child>
- <widget class="GtkMenu" id="menu3">
- <property name="visible">True</property>
- <child>
- <widget class="GtkImageMenuItem" id="help_about_menu_item">
- <property name="visible">True</property>
- <property name="label" translatable="yes">gtk-about</property>
- <property name="use_underline">True</property>
- <property name="use_stock">True</property>
- </widget>
- </child>
- </widget>
- </child>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="expand">False</property>
- </packing>
- </child>
- <child>
- <widget class="GtkToolbar" id="toolbar">
- <property name="visible">True</property>
- <child>
- <widget class="GtkToolButton" id="save_tool_button">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Save</property>
- <property name="stock_id">gtk-save</property>
- <signal name="clicked" handler="on_save_tool_button_clicked"/>
- </widget>
- <packing>
- <property name="homogeneous">True</property>
- </packing>
- </child>
- <child>
- <widget class="GtkToolButton" id="restore_tool_button">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Restore</property>
- <property name="stock_id">gtk-open</property>
- </widget>
- <packing>
- <property name="homogeneous">True</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </widget>
- </child>
- </widget>
-</glade-interface>
/* Global pointers to widgets */
GtkBuilder *builder = NULL;
+GtkUIManager *uimanager = NULL;
GtkWidget *window = NULL;
GtkWidget *glk = NULL;
g_printerr("Stopped!\n");
}
+static GObject *
+load_object(const gchar *name)
+{
+ GObject *retval;
+ if( (retval = gtk_builder_get_object(builder, name)) == NULL) {
+ error_dialog(NULL, NULL, "Error while getting object '%s'", name);
+ g_error("Error while getting object '%s'", name);
+ }
+ return retval;
+}
+
static void
create_window(void)
{
- if( (window = GTK_WIDGET(gtk_builder_get_object(builder, "gargoyle-gtk"))) == NULL ) {
- error_dialog(NULL, NULL, "Error while getting main window object");
+ GError *error = NULL;
+
+ builder = gtk_builder_new();
+ if( !gtk_builder_add_from_file(builder, "chimara.ui", &error) ) {
+ error_dialog(NULL, error, "Error while building interface: ");
return;
}
+ window = GTK_WIDGET(load_object("chimara"));
+ GtkActionGroup *actiongroup = GTK_ACTION_GROUP(load_object("actiongroup"));
+
+ /* Add all the actions to the action group. This for-loop is a temporary fix
+ and can be removed once Glade supports adding actions and accelerators to an
+ action group. */
+ const gchar *actions[] = {
+ "game", "",
+ "open", "<ctrl>F7",
+ "save", NULL, /* NULL means use stock accelerator */
+ "quit", NULL,
+ NULL
+ };
+ const gchar **ptr;
+ for(ptr = actions; *ptr; ptr += 2)
+ gtk_action_group_add_action_with_accel(actiongroup, GTK_ACTION(load_object(ptr[0])), ptr[1]);
+
+ GtkUIManager *uimanager = gtk_ui_manager_new();
+ if( !gtk_ui_manager_add_ui_from_file(uimanager, "chimara.menus", &error) ) {
+ error_dialog(NULL, error, "Error while building interface: ");
+ return;
+ }
+
gtk_builder_connect_signals(builder, NULL);
glk = chimara_glk_new();
return;
}
+ gtk_ui_manager_insert_action_group(uimanager, actiongroup, 0);
+ GtkWidget *menubar = gtk_ui_manager_get_widget(uimanager, "/menubar");
+ GtkWidget *toolbar = gtk_ui_manager_get_widget(uimanager, "/toolbar");
+
gtk_box_pack_end(vbox, glk, TRUE, TRUE, 0);
+ gtk_box_pack_start(vbox, menubar, FALSE, FALSE, 0);
+ gtk_box_pack_start(vbox, toolbar, FALSE, FALSE, 0);
}
int
gtk_set_locale();
gtk_init(&argc, &argv);
- builder = gtk_builder_new();
- if( !gtk_builder_add_from_file(builder, "chimara.ui", &error) ) {
- error_dialog(NULL, error, "Error while building interface: ");
- return 1;
- }
-
create_window();
gtk_widget_show_all(window);