X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=player%2Fmain.c;h=8d9bb255d2a94cf38ab53d06e8507e8fc9eb4596;hb=0c230096e95470b4c96141220d5be848cb47be39;hp=9827d3193e9a57f20c0c27ed33439203ec3e1c8b;hpb=3c19422ee9cc38e710bd2f262b2b91a3d6e04ab6;p=rodin%2Fchimara.git diff --git a/player/main.c b/player/main.c index 9827d31..8d9bb25 100644 --- a/player/main.c +++ b/player/main.c @@ -44,11 +44,15 @@ #include #include -/* Global pointers to widgets */ -GtkBuilder *builder = NULL; -GtkUIManager *uimanager = NULL; -GtkWidget *window = NULL; -GtkWidget *glk = NULL; +/* Static global pointers to widgets */ +static GtkBuilder *builder = NULL; +static GtkUIManager *uimanager = NULL; +static GtkWidget *window = NULL; +static GtkWidget *glk = NULL; + +/* Global global pointers */ +GtkWidget *aboutwindow = NULL; +GtkWidget *prefswindow = NULL; static GObject * load_object(const gchar *name) @@ -67,12 +71,22 @@ create_window(void) GError *error = NULL; builder = gtk_builder_new(); - if( !gtk_builder_add_from_file(builder, PACKAGE_SRC_DIR "/chimara.ui", &error) ) { - error_dialog(NULL, error, "Error while building interface: "); - return; + if( !gtk_builder_add_from_file(builder, PACKAGE_DATA_DIR "/chimara.ui", &error) ) { +#ifdef DEBUG + g_error_free(error); + error = NULL; + if( !gtk_builder_add_from_file(builder, PACKAGE_SRC_DIR "/chimara.ui", &error) ) { +#endif /* DEBUG */ + error_dialog(NULL, error, "Error while building interface: "); + return; +#ifdef DEBUG + } +#endif /* DEBUG */ } window = GTK_WIDGET(load_object("chimara")); + aboutwindow = GTK_WIDGET(load_object("aboutwindow")); + prefswindow = GTK_WIDGET(load_object("prefswindow")); GtkActionGroup *actiongroup = GTK_ACTION_GROUP(load_object("actiongroup")); /* Add all the actions to the action group. This for-loop is a temporary fix @@ -91,7 +105,6 @@ create_window(void) "restart", "", "quit", "", "edit", "", - "cut", NULL, "copy", NULL, "paste", NULL, "preferences", "", @@ -102,11 +115,29 @@ create_window(void) 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]); + GtkRecentFilter *filter = gtk_recent_filter_new(); + /* TODO: Use mimetypes and construct the filter dynamically depending on + what plugins are installed */ + const gchar *patterns[] = { + "*.z[1-8]", "*.[zg]lb", "*.[zg]blorb", "*.ulx", "*.blb", "*.blorb", NULL + }; + for(ptr = patterns; *ptr; ptr++) + gtk_recent_filter_add_pattern(filter, *ptr); + GtkRecentChooser *recent = GTK_RECENT_CHOOSER(load_object("recent")); + gtk_recent_chooser_add_filter(recent, filter); uimanager = gtk_ui_manager_new(); - if( !gtk_ui_manager_add_ui_from_file(uimanager, PACKAGE_SRC_DIR "/chimara.menus", &error) ) { - error_dialog(NULL, error, "Error while building interface: "); - return; + if( !gtk_ui_manager_add_ui_from_file(uimanager, PACKAGE_DATA_DIR "/chimara.menus", &error) ) { +#ifdef DEBUG + g_error_free(error); + error = NULL; + if( !gtk_ui_manager_add_ui_from_file(uimanager, PACKAGE_SRC_DIR "/chimara.menus", &error) ) { +#endif /* DEBUG */ + error_dialog(NULL, error, "Error while building interface: "); + return; +#ifdef DEBUG + } +#endif /* DEBUG */ } glk = chimara_if_new();