Implemented dynamic title bar in player
authorfliep <fliep@ddfedd41-794f-dd11-ae45-00112f111e67>
Sun, 2 May 2010 19:59:53 +0000 (19:59 +0000)
committerfliep <fliep@ddfedd41-794f-dd11-ae45-00112f111e67>
Sun, 2 May 2010 19:59:53 +0000 (19:59 +0000)
player/main.c

index 182ca1e31c3202606de705db94b6adfdbbd89efd..962ca30e0ba3f05198a9f55d163f56a2e8646769 100644 (file)
@@ -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