From: fliep Date: Sun, 2 May 2010 19:59:53 +0000 (+0000) Subject: Implemented dynamic title bar in player X-Git-Tag: v0.9~207 X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=422727d2d79580db18947a004ca6759b745e871e;p=projects%2Fchimara%2Fchimara.git Implemented dynamic title bar in player --- 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