From 99f9996b499c1b0e82e4297f264f3e5844b02877 Mon Sep 17 00:00:00 2001 From: "P. F. Chimento" Date: Tue, 21 Jun 2011 17:43:07 +0200 Subject: [PATCH] Implement empty browser window --- player/app.c | 4 +++- player/app.h | 2 +- player/browser.c | 34 ++++++++++++++++++++++++++++++++-- player/browser.h | 2 +- player/main.c | 5 ++--- 5 files changed, 39 insertions(+), 8 deletions(-) diff --git a/player/app.c b/player/app.c index 988c083..a9cf674 100644 --- a/player/app.c +++ b/player/app.c @@ -11,6 +11,7 @@ #include #include #include "app.h" +#include "browser.h" #include "error.h" #include "preferences.h" #include "player.h" @@ -140,8 +141,9 @@ chimara_app_get(void) if(G_UNLIKELY(theapp == NULL)) { theapp = CHIMARA_APP(g_object_new(CHIMARA_TYPE_APP, NULL)); - /* Create preferences window */ + /* Create one-per-application windows */ theapp->prefswindow = chimara_prefs_new(); + theapp->browser_window = chimara_browser_new(); } return theapp; diff --git a/player/app.h b/player/app.h index d15f2a9..6a22cc0 100644 --- a/player/app.h +++ b/player/app.h @@ -17,7 +17,7 @@ typedef struct _ChimaraApp { GObject parent_instance; /* Public pointers */ - // library browser window? + GtkWidget *browser_window; GtkWidget *aboutwindow; GtkWidget *prefswindow; /* Public settings */ diff --git a/player/browser.c b/player/browser.c index 8dfadf4..e4b3e74 100644 --- a/player/browser.c +++ b/player/browser.c @@ -1,6 +1,9 @@ #include +#include #include #include "browser.h" +#include "app.h" +#include "error.h" typedef struct _ChimaraBrowserPrivate { int dummy; @@ -38,12 +41,39 @@ chimara_browser_class_init(ChimaraBrowserClass *klass) static void chimara_browser_init(ChimaraBrowser *self) { + ChimaraApp *theapp = chimara_app_get(); + GError *error = NULL; + + /* Set own properties */ + g_object_set(self, + "title", _("Chimara"), + NULL); + + GtkUIManager *uimanager = gtk_ui_manager_new(); + 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 */ + } + + gtk_ui_manager_insert_action_group(uimanager, chimara_app_get_action_group(theapp), 0); + GtkWidget *menubar = gtk_ui_manager_get_widget(uimanager, "/browser_menu"); + gtk_container_add(GTK_CONTAINER(self), menubar); } /* PUBLIC FUNCTIONS */ -ChimaraBrowser * +GtkWidget * chimara_browser_new(void) { - return CHIMARA_BROWSER(g_object_new(CHIMARA_TYPE_BROWSER, NULL)); + return GTK_WIDGET(g_object_new(CHIMARA_TYPE_BROWSER, + "type", GTK_WINDOW_TOPLEVEL, + NULL)); } diff --git a/player/browser.h b/player/browser.h index 991267c..588b405 100644 --- a/player/browser.h +++ b/player/browser.h @@ -24,7 +24,7 @@ typedef struct _ChimaraBrowserClass { } ChimaraBrowserClass; GType chimara_browser_get_type(void) G_GNUC_CONST; -ChimaraBrowser *chimara_browser_new(void); +GtkWidget *chimara_browser_new(void); G_END_DECLS diff --git a/player/main.c b/player/main.c index 85ed57c..20ee329 100644 --- a/player/main.c +++ b/player/main.c @@ -62,9 +62,6 @@ main(int argc, char *argv[]) ChimaraApp *theapp = chimara_app_get(); - GtkWidget *window = chimara_player_new(); - gtk_widget_show_all(window); - //if(argc == 3) { // g_object_set(glk, "graphics-file", argv[2], NULL); //} @@ -75,6 +72,8 @@ main(int argc, char *argv[]) // } //} + gtk_widget_show_all(theapp->browser_window); + gdk_threads_enter(); gtk_main(); gdk_threads_leave(); -- 2.30.2