[totem] Remove brightness, contrast, etc. GSettings machinery from BaconVideoWidget



commit b846fd43d94a17cedd06f6aa596dce22876cb015
Author: Philip Withnall <philip tecnocode co uk>
Date:   Wed Dec 15 21:55:25 2010 +0000

    Remove brightness, contrast, etc. GSettings machinery from BaconVideoWidget
    
    It doesn't belong in BaconVideoWidget, it belongs in totem-preferences.c.
    And that's where it now is. Closes: bgo#637317

 data/totem.ui                             |    4 --
 src/backend/bacon-video-widget-gst-0.10.c |   34 +-------------
 src/totem-preferences.c                   |   71 +++++++----------------------
 3 files changed, 19 insertions(+), 90 deletions(-)
---
diff --git a/data/totem.ui b/data/totem.ui
index ae01588..60965b2 100644
--- a/data/totem.ui
+++ b/data/totem.ui
@@ -1737,7 +1737,6 @@
 			      <property name="update_policy">GTK_UPDATE_CONTINUOUS</property>
 			      <property name="inverted">False</property>
 			      <property name="adjustment">tpw_bright_adjustment</property>
-			      <signal name="value-changed" handler="brightness_changed"/>
 			    </object>
 			    <packing>
 			      <property name="left_attach">1</property>
@@ -1758,7 +1757,6 @@
 			      <property name="update_policy">GTK_UPDATE_CONTINUOUS</property>
 			      <property name="inverted">False</property>
 			      <property name="adjustment">tpw_contrast_adjustment</property>
-			      <signal name="value-changed" handler="contrast_changed"/>
 			    </object>
 			    <packing>
 			      <property name="left_attach">1</property>
@@ -1838,7 +1836,6 @@
 			      <property name="update_policy">GTK_UPDATE_CONTINUOUS</property>
 			      <property name="inverted">False</property>
 			      <property name="adjustment">tpw_saturation_adjustment</property>
-			      <signal name="value-changed" handler="saturation_changed"/>
 			    </object>
 			    <packing>
 			      <property name="left_attach">1</property>
@@ -1860,7 +1857,6 @@
 			      <property name="update_policy">GTK_UPDATE_CONTINUOUS</property>
 			      <property name="inverted">False</property>
 			      <property name="adjustment">tpw_hue_adjustment</property>
-			      <signal name="value-changed" handler="hue_changed"/>
 			    </object>
 			    <packing>
 			      <property name="left_attach">1</property>
diff --git a/src/backend/bacon-video-widget-gst-0.10.c b/src/backend/bacon-video-widget-gst-0.10.c
index 45443f8..134e4c2 100644
--- a/src/backend/bacon-video-widget-gst-0.10.c
+++ b/src/backend/bacon-video-widget-gst-0.10.c
@@ -5424,12 +5424,7 @@ bacon_video_widget_get_video_property (BaconVideoWidget *bvw,
       }
     }
 
-  /* value wasn't found, get from GSettings */
-  if (ret == 0)
-    ret = g_settings_get_int (bvw->priv->settings, video_props_str[type]);
-
-  GST_DEBUG ("nothing found for type %d, returning value %d from GSettings key %s",
-      type, ret, video_props_str[type]);
+  GST_DEBUG ("nothing found for type %d, returning value %d", type, ret);
 
 done:
 
@@ -5533,10 +5528,7 @@ bacon_video_widget_set_video_property (BaconVideoWidget *bvw,
   /* Notify of the property change */
   g_object_notify (G_OBJECT (bvw), video_props_str[type]);
 
-  /* save in GSettings */
-  g_settings_set_int (bvw->priv->settings, video_props_str[type], value);
-
-  GST_DEBUG ("setting value %d on GSettings key %s", value, video_props_str[type]);
+  GST_DEBUG ("setting value %d", value);
 }
 
 /**
@@ -6551,22 +6543,6 @@ find_colorbalance_element (GstElement *element, GValue * ret, GstElement **cb)
   }
 }
 
-static void
-bvw_update_brightness_and_contrast_from_gsettings (BaconVideoWidget * bvw)
-{
-  guint i;
-
-  g_return_if_fail (g_thread_self() == gui_thread);
-
-  /* Setup brightness and contrast */
-  GST_LOG ("updating brightness and contrast from GSettings settings");
-  for (i = 0; i < G_N_ELEMENTS (video_props_str); i++) {
-    gint value = g_settings_get_int (bvw->priv->settings, video_props_str[i]);
-    if (value > 0)
-      bacon_video_widget_set_video_property (bvw, i, value);
-  }
-}
-
 static gboolean
 bvw_update_interfaces_delayed (BaconVideoWidget *bvw)
 {
@@ -6683,12 +6659,6 @@ bvw_update_interface_implementations (BaconVideoWidget *bvw)
     bvw->priv->balance = NULL;
   }
 
-  /* Setup brightness and contrast from configured values (do it delayed if
-   * we're within a streaming thread, otherwise GSettings/orbit/whatever may
-   * iterate or otherwise mess with the default main context and cause all
-   * kinds of nasty issues) */
-  bvw_update_brightness_and_contrast_from_gsettings (bvw);
-
   if (old_xoverlay)
     gst_object_unref (GST_OBJECT (old_xoverlay));
 
diff --git a/src/totem-preferences.c b/src/totem-preferences.c
index c58e62b..d43fe2c 100644
--- a/src/totem-preferences.c
+++ b/src/totem-preferences.c
@@ -48,10 +48,6 @@
 G_MODULE_EXPORT void checkbutton2_toggled_cb (GtkToggleButton *togglebutton, Totem *totem);
 G_MODULE_EXPORT void audio_screensaver_button_toggled_cb (GtkToggleButton *togglebutton, Totem *totem);
 G_MODULE_EXPORT void visual_menu_changed (GtkComboBox *combobox, Totem *totem);
-G_MODULE_EXPORT void brightness_changed (GtkRange *range, Totem *totem);
-G_MODULE_EXPORT void contrast_changed (GtkRange *range, Totem *totem);
-G_MODULE_EXPORT void saturation_changed (GtkRange *range, Totem *totem);
-G_MODULE_EXPORT void hue_changed (GtkRange *range, Totem *totem);
 G_MODULE_EXPORT void tpw_color_reset_clicked_cb (GtkButton *button, Totem *totem);
 G_MODULE_EXPORT void audio_out_menu_changed (GtkComboBox *combobox, Totem *totem);
 G_MODULE_EXPORT void font_set_cb (GtkFontButton * fb, Totem * totem);
@@ -192,46 +188,6 @@ visual_menu_changed (GtkComboBox *combobox, Totem *totem)
 }
 
 void
-brightness_changed (GtkRange *range, Totem *totem)
-{
-	gdouble i;
-
-	i = gtk_range_get_value (range);
-	bacon_video_widget_set_video_property (totem->bvw,
-			BVW_VIDEO_BRIGHTNESS, (int) i);
-}
-
-void
-contrast_changed (GtkRange *range, Totem *totem)
-{
-	gdouble i;
-
-	i = gtk_range_get_value (range);
-	bacon_video_widget_set_video_property (totem->bvw,
-			BVW_VIDEO_CONTRAST, (int) i);
-}
-
-void
-saturation_changed (GtkRange *range, Totem *totem)
-{
-	gdouble i;
-
-	i = gtk_range_get_value (range);
-	bacon_video_widget_set_video_property (totem->bvw,
-			BVW_VIDEO_SATURATION, (int) i);
-}
-
-void
-hue_changed (GtkRange *range, Totem *totem)
-{
-	gdouble i;
-
-	i = gtk_range_get_value (range);
-	bacon_video_widget_set_video_property (totem->bvw,
-			BVW_VIDEO_HUE, (int) i);
-}
-
-void
 tpw_color_reset_clicked_cb (GtkButton *button, Totem *totem)
 {
 	guint i;
@@ -352,11 +308,13 @@ totem_setup_preferences (Totem *totem)
 		const char *name;
 		BvwVideoProperty prop;
 		const char *label;
+		const gchar *key;
+		const gchar *adjustment;
 	} props[4] = {
-		{ "tpw_contrast_scale", BVW_VIDEO_CONTRAST, "tpw_contrast_label" },
-		{ "tpw_saturation_scale", BVW_VIDEO_SATURATION, "tpw_saturation_label" },
-		{ "tpw_bright_scale", BVW_VIDEO_BRIGHTNESS, "tpw_brightness_label" },
-		{ "tpw_hue_scale", BVW_VIDEO_HUE, "tpw_hue_label" }
+		{ "tpw_contrast_scale", BVW_VIDEO_CONTRAST, "tpw_contrast_label", "contrast", "tpw_contrast_adjustment" },
+		{ "tpw_saturation_scale", BVW_VIDEO_SATURATION, "tpw_saturation_label", "saturation", "tpw_saturation_adjustment" },
+		{ "tpw_bright_scale", BVW_VIDEO_BRIGHTNESS, "tpw_brightness_label", "brightness", "tpw_bright_adjustment" },
+		{ "tpw_hue_scale", BVW_VIDEO_HUE, "tpw_hue_label", "hue", "tpw_hue_adjustment" }
 	};
 
 	g_return_if_fail (totem->settings != NULL);
@@ -486,12 +444,16 @@ totem_setup_preferences (Totem *totem)
 	hidden = 0;
 	for (i = 0; i < G_N_ELEMENTS (props); i++) {
 		int prop_value;
-		item = gtk_builder_get_object (totem->xml, props[i].name);
-		prop_value = bacon_video_widget_get_video_property (totem->bvw,
-							       props[i].prop);
-		if (prop_value >= 0)
-			gtk_range_set_value (GTK_RANGE (item), (gdouble) prop_value);
-		else {
+
+		item = gtk_builder_get_object (totem->xml, props[i].adjustment);
+		g_settings_bind (totem->settings, props[i].key, item, "value", G_SETTINGS_BIND_DEFAULT);
+		g_settings_bind (totem->settings, props[i].key, bvw, props[i].key,
+		                 G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET | G_SETTINGS_BIND_NO_SENSITIVITY);
+
+		prop_value = bacon_video_widget_get_video_property (totem->bvw, props[i].prop);
+		if (prop_value < 0) {
+			/* The property's unsupported, so hide the widget and its label */
+			item = gtk_builder_get_object (totem->xml, props[i].name);
 			gtk_range_set_value (GTK_RANGE (item), (gdouble) 65535/2);
 			gtk_widget_hide (GTK_WIDGET (item));
 			item = gtk_builder_get_object (totem->xml, props[i].label);
@@ -500,6 +462,7 @@ totem_setup_preferences (Totem *totem)
 		}
 	}
 
+	/* If all the properties have been hidden, hide their section box */
 	if (hidden == G_N_ELEMENTS (props)) {
 		item = gtk_builder_get_object (totem->xml, "tpw_bright_contr_vbox");
 		gtk_widget_hide (GTK_WIDGET (item));



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]