[Goodies-commits] r3648 - ristretto/trunk/src

Stephan Arts stephan at xfce.org
Tue Nov 27 23:14:02 CET 2007


Author: stephan
Date: 2007-11-27 22:14:02 +0000 (Tue, 27 Nov 2007)
New Revision: 3648

Modified:
   ristretto/trunk/src/main.c
   ristretto/trunk/src/main_window.c
   ristretto/trunk/src/main_window.h
   ristretto/trunk/src/picture_viewer.c
   ristretto/trunk/src/picture_viewer.h
Log:
Allow bg-color to be overridden (non gtk-style, bug #3691)



Modified: ristretto/trunk/src/main.c
===================================================================
--- ristretto/trunk/src/main.c	2007-11-27 18:32:54 UTC (rev 3647)
+++ ristretto/trunk/src/main.c	2007-11-27 22:14:02 UTC (rev 3648)
@@ -52,7 +52,7 @@
 
 int main(int argc, char **argv)
 {
-
+    GdkColor *bg_color = NULL;
     GError *cli_error = NULL;
     gchar *path_dir = NULL;
     gint n;
@@ -95,6 +95,12 @@
     gint slideshow_timeout = xfce_rc_read_int_entry(xfce_rc, "SlideShowTimeout", 5000);
     gint max_cache = xfce_rc_read_int_entry(xfce_rc, "MaxImagesCacheSize", 1);
     gboolean preload_during_slideshow = xfce_rc_read_bool_entry (xfce_rc, "PreloadDuringSlideShow", FALSE);
+    gboolean override_bg_color = xfce_rc_read_bool_entry (xfce_rc, "OverrideBgColor", FALSE);
+    if (override_bg_color)
+    {
+        bg_color = g_new0(GdkColor, 1);
+        bg_color->pixel = xfce_rc_read_int_entry(xfce_rc, "BgColor", 0);
+    }
     
     GtkWidget *window = rstto_main_window_new();
     gtk_widget_ref(window);
@@ -224,7 +230,12 @@
         rstto_main_window_set_thumbnail_viewer_orientation(RSTTO_MAIN_WINDOW(window), GTK_ORIENTATION_HORIZONTAL);
     }
 
+    if (bg_color)
+    {
+        rstto_main_window_set_pv_bg_color(RSTTO_MAIN_WINDOW(window), bg_color);
+    }
 
+
     gtk_window_set_default_size(GTK_WINDOW(window), window_width, window_height);
     gtk_widget_show_all(window);
 
@@ -232,9 +243,21 @@
     rstto_main_window_set_show_toolbar(RSTTO_MAIN_WINDOW(window), show_toolbar);
 
     gtk_main();
+
+    bg_color = rstto_main_window_get_pv_bg_color(RSTTO_MAIN_WINDOW(window));
+
     xfce_rc_write_bool_entry(xfce_rc, "ShowToolBar", rstto_main_window_get_show_toolbar(RSTTO_MAIN_WINDOW(window)));
     xfce_rc_write_bool_entry(xfce_rc, "PreloadDuringSlideShow", navigator->preload);
     xfce_rc_write_bool_entry(xfce_rc, "ShowThumbnailViewer", rstto_main_window_get_show_thumbnail_viewer(RSTTO_MAIN_WINDOW(window)));
+    if (bg_color)
+    {
+        xfce_rc_write_bool_entry(xfce_rc, "OverrideBgColor", TRUE);
+        xfce_rc_write_int_entry(xfce_rc, "BgColor", bg_color->pixel);
+    }
+    else
+    {
+        xfce_rc_write_bool_entry(xfce_rc, "OverrideBgColor", FALSE);
+    }
     switch (rstto_main_window_get_thumbnail_viewer_orientation(RSTTO_MAIN_WINDOW(window)))
     {
         case GTK_ORIENTATION_VERTICAL:

Modified: ristretto/trunk/src/main_window.c
===================================================================
--- ristretto/trunk/src/main_window.c	2007-11-27 18:32:54 UTC (rev 3647)
+++ ristretto/trunk/src/main_window.c	2007-11-27 22:14:02 UTC (rev 3648)
@@ -51,11 +51,12 @@
     } containers;
 
     struct {
-        GtkOrientation thumbnail_viewer_orientation;
-        gboolean       thumbnail_viewer_visibility;
-        gboolean       toolbar_visibility;
-        gint           max_cache_size;
-        gdouble        slideshow_timeout;
+        GtkOrientation  thumbnail_viewer_orientation;
+        gboolean        thumbnail_viewer_visibility;
+        gboolean        toolbar_visibility;
+        gint            max_cache_size;
+        gdouble         slideshow_timeout;
+        const GdkColor *bg_color;
     } settings;
 
     struct {
@@ -1103,15 +1104,16 @@
             gtk_widget_hide(window->priv->toolbar.bar);
             gtk_widget_hide(window->priv->statusbar);
             GdkColor *color = g_new0(GdkColor, 1);
-            color->pixel = 0;
 
             rstto_picture_viewer_set_bg_color(RSTTO_PICTURE_VIEWER(window->priv->picture_viewer), color);
+
+            gdk_color_free(color);
         }
         else
         {
             gtk_widget_show(window->priv->menus.menu);
             gtk_widget_show(window->priv->statusbar);
-            rstto_picture_viewer_set_bg_color(RSTTO_PICTURE_VIEWER(window->priv->picture_viewer), NULL);
+            rstto_picture_viewer_set_bg_color(RSTTO_PICTURE_VIEWER(window->priv->picture_viewer), window->priv->settings.bg_color);
 
             if (window->priv->settings.toolbar_visibility == TRUE)
             {
@@ -1144,6 +1146,15 @@
 static void
 cb_rstto_main_window_preferences(GtkWidget *widget, RsttoMainWindow *window)
 {
+    GdkColor  *color = NULL;
+    if (rstto_picture_viewer_get_bg_color(RSTTO_PICTURE_VIEWER(window->priv->picture_viewer)))
+    {
+        color = gdk_color_copy(rstto_picture_viewer_get_bg_color(RSTTO_PICTURE_VIEWER(window->priv->picture_viewer)));
+    }
+    else
+    {
+        color = g_new0(GdkColor, 1);
+    }
     GtkWidget *slideshow_main_vbox;
     GtkWidget *slideshow_main_lbl;
     GtkWidget *display_main_vbox;
@@ -1176,7 +1187,7 @@
     GtkWidget *bg_color_frame = xfce_create_framebox_with_content (_("Background Color"), bg_color_vbox);
 
     GtkWidget *bg_color_override_check = gtk_check_button_new_with_mnemonic(_("_Override Background Color"));
-    GtkWidget *bg_color_button = gtk_color_button_new();
+    GtkWidget *bg_color_button = gtk_color_button_new_with_color(color);
 
     gtk_box_pack_start(GTK_BOX(bg_color_vbox), bg_color_override_check, FALSE, TRUE, 0);
     gtk_box_pack_start(GTK_BOX(bg_color_vbox), bg_color_button, FALSE, FALSE, 0);
@@ -1229,6 +1240,16 @@
         case GTK_RESPONSE_OK:
             rstto_main_window_set_slideshow_timeout(window, gtk_range_get_value(GTK_RANGE(slideshow_hscale)) * 1000);
             window->priv->navigator->preload = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(preload_check));
+            if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(bg_color_override_check)) == TRUE)
+            {
+                gtk_color_button_get_color(GTK_COLOR_BUTTON(bg_color_button), color);
+                rstto_main_window_set_pv_bg_color(window, color);
+                gdk_color_free(color);
+            }
+            else
+            {
+                rstto_main_window_set_pv_bg_color(window, NULL);
+            }
         default:
             break;
     }
@@ -1794,3 +1815,24 @@
     GList *list = g_list_prepend(NULL, info->path);
     thunar_vfs_mime_handler_exec(THUNAR_VFS_MIME_HANDLER(app), NULL, list, NULL);
 }
+
+void
+rstto_main_window_set_pv_bg_color (RsttoMainWindow *window, const GdkColor *color)
+{
+    rstto_picture_viewer_set_bg_color(RSTTO_PICTURE_VIEWER(window->priv->picture_viewer), color);
+    if (color)
+    {
+        window->priv->settings.bg_color = gdk_color_copy(color);
+    }
+    else
+    {
+        window->priv->settings.bg_color = NULL;
+    }
+}
+
+const GdkColor *
+rstto_main_window_get_pv_bg_color (RsttoMainWindow *window)
+{
+    /*return rstto_picture_viewer_get_bg_color(RSTTO_PICTURE_VIEWER(window->priv->picture_viewer));*/
+    return window->priv->settings.bg_color;
+}

Modified: ristretto/trunk/src/main_window.h
===================================================================
--- ristretto/trunk/src/main_window.h	2007-11-27 18:32:54 UTC (rev 3647)
+++ ristretto/trunk/src/main_window.h	2007-11-27 22:14:02 UTC (rev 3648)
@@ -86,6 +86,10 @@
 rstto_main_window_set_slideshow_timeout (RsttoMainWindow *window, gdouble timeout);
 void
 rstto_main_window_set_max_cache_size (RsttoMainWindow *window, gint max_cache_size);
+void
+rstto_main_window_set_pv_bg_color (RsttoMainWindow *window, const GdkColor *color);
+const GdkColor *
+rstto_main_window_get_pv_bg_color (RsttoMainWindow *window);
 
 G_END_DECLS
 

Modified: ristretto/trunk/src/picture_viewer.c
===================================================================
--- ristretto/trunk/src/picture_viewer.c	2007-11-27 18:32:54 UTC (rev 3647)
+++ ristretto/trunk/src/picture_viewer.c	2007-11-27 22:14:02 UTC (rev 3648)
@@ -1056,7 +1056,7 @@
 }
 
 void
-rstto_picture_viewer_set_bg_color (RsttoPictureViewer *viewer, GdkColor *color)
+rstto_picture_viewer_set_bg_color (RsttoPictureViewer *viewer, const GdkColor *color)
 {
     if (viewer->priv->bg_color)
     {
@@ -1068,3 +1068,9 @@
         viewer->priv->bg_color = gdk_color_copy(color);
     }
 }
+
+const GdkColor *
+rstto_picture_viewer_get_bg_color (RsttoPictureViewer *viewer)
+{
+    return viewer->priv->bg_color;
+}

Modified: ristretto/trunk/src/picture_viewer.h
===================================================================
--- ristretto/trunk/src/picture_viewer.h	2007-11-27 18:32:54 UTC (rev 3647)
+++ ristretto/trunk/src/picture_viewer.h	2007-11-27 22:14:02 UTC (rev 3648)
@@ -72,7 +72,9 @@
 void       rstto_picture_viewer_set_timeout(RsttoPictureViewer *viewer, gboolean timeout);
 
 void       rstto_picture_viewer_set_menu (RsttoPictureViewer *viewer, GtkMenu *menu);
-void       rstto_picture_viewer_set_bg_color (RsttoPictureViewer *viewer, GdkColor *color);
+void       rstto_picture_viewer_set_bg_color (RsttoPictureViewer *viewer, const GdkColor *color);
+const GdkColor *
+rstto_picture_viewer_get_bg_color (RsttoPictureViewer *viewer);
 
 G_END_DECLS
 




More information about the Goodies-commits mailing list