X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=player%2Fmain.c;h=182ca1e31c3202606de705db94b6adfdbbd89efd;hb=7ef4ef1fecab7ae0f724e59f7de1315a96822152;hp=9827d3193e9a57f20c0c27ed33439203ec3e1c8b;hpb=3c19422ee9cc38e710bd2f262b2b91a3d6e04ab6;p=rodin%2Fchimara.git diff --git a/player/main.c b/player/main.c index 9827d31..182ca1e 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,15 +115,50 @@ 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(); g_object_set(glk, "ignore-errors", TRUE, NULL); + if( !chimara_glk_set_css_from_file(CHIMARA_GLK(glk), PACKAGE_DATA_DIR "/style.css", &error) ) { +#ifdef DEBUG + g_error_free(error); + error = NULL; + if( !chimara_glk_set_css_from_file(CHIMARA_GLK(glk), PACKAGE_SRC_DIR "/style.css", &error) ) { +#endif /* DEBUG */ + error_dialog(NULL, error, "Couldn't open CSS file: "); + return; +#ifdef DEBUG + } +#endif /* DEBUG */ + } + + /* DON'T UNCOMMENT THIS your eyes will burn + but it is a good test of programmatically altering just one style + chimara_glk_set_css_from_string(CHIMARA_GLK(glk), + "buffer.normal { font-family: 'Comic Sans MS'; }");*/ GtkBox *vbox = GTK_BOX( gtk_builder_get_object(builder, "vbox") ); if(vbox == NULL)