From: Philip Chimento Date: Sun, 2 May 2010 19:59:53 +0000 (+0000) Subject: Implemented dynamic title bar in player X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=4033055248595b5dfc337444097686703764c8b6;p=rodin%2Fchimara.git Implemented dynamic title bar in player git-svn-id: http://lassie.dyndns-server.com/svn/gargoyle-gtk@258 ddfedd41-794f-dd11-ae45-00112f111e67 --- diff --git a/player/main.c b/player/main.c index 182ca1e..962ca30 100644 --- a/player/main.c +++ b/player/main.c @@ -65,6 +65,26 @@ load_object(const gchar *name) return retval; } +static void +change_window_title(ChimaraGlk *glk, GParamSpec *pspec, GtkWindow *window) +{ + gchar *program_name, *story_name, *title; + g_object_get(glk, "program-name", &program_name, "story-name", &story_name, NULL); + if(!program_name) { + gtk_window_set_title(window, "Chimara"); + return; + } + else if(!story_name) + title = g_strdup_printf("%s - Chimara", program_name); + else + title = g_strdup_printf("%s - %s - Chimara", program_name, story_name); + + g_free(program_name); + g_free(story_name); + gtk_window_set_title(window, title); + g_free(title); +} + static void create_window(void) { @@ -146,7 +166,7 @@ create_window(void) #ifdef DEBUG g_error_free(error); error = NULL; - if( !chimara_glk_set_css_from_file(CHIMARA_GLK(glk), PACKAGE_SRC_DIR "/style.css", &error) ) { + if( !chimara_glk_set_css_from_file(CHIMARA_GLK(glk), PACKAGE_SRC_DIR "/macstyle.css", &error) ) { #endif /* DEBUG */ error_dialog(NULL, error, "Couldn't open CSS file: "); return; @@ -176,6 +196,8 @@ create_window(void) gtk_box_pack_start(vbox, toolbar, FALSE, FALSE, 0); gtk_builder_connect_signals(builder, glk); + g_signal_connect(glk, "notify::program-name", G_CALLBACK(change_window_title), window); + g_signal_connect(glk, "notify::story-name", G_CALLBACK(change_window_title), window); } int