[Xfce4-commits] xfce4-settings:bluesabre/display-settings Hook up the reworked minimal dialog

2013-12-09 Thread Nick Schermer
Updating branch refs/heads/bluesabre/display-settings
 to 7f506412224f57f93020b15a9e69ffbb64f82889 (commit)
   from 6575a0c1c9726c30d0cb39f307d597a323762423 (commit)

commit 7f506412224f57f93020b15a9e69ffbb64f82889
Author: Simon Steinbeiss simon.steinbe...@elfenbeinturm.at
Date:   Thu Oct 4 12:24:11 2012 +0200

Hook up the reworked minimal dialog

 dialogs/display-settings/main.c |  288 ---
 1 file changed, 179 insertions(+), 109 deletions(-)

diff --git a/dialogs/display-settings/main.c b/dialogs/display-settings/main.c
index 0640404..c22ffea 100644
--- a/dialogs/display-settings/main.c
+++ b/dialogs/display-settings/main.c
@@ -113,7 +113,7 @@ static gboolean   bound_to_channel = FALSE;
 XfceRandr *xfce_randr = NULL;
 
 static void
-display_settings_minimal_extend_left_toggled (GtkToggleButton *button,
+display_settings_minimal_only_display1_toggled (GtkToggleButton *button,
   GtkBuilder *builder);
   
 static void
@@ -123,7 +123,10 @@ display_settings_minimal_mirror_displays_toggled 
(GtkToggleButton *button,
 static void
 display_settings_minimal_extend_right_toggled (GtkToggleButton *button,
   GtkBuilder *builder);
-
+  
+static void
+display_settings_minimal_only_display2_toggled (GtkToggleButton *button,
+  GtkBuilder *builder);
 
 
 static guint
@@ -1363,134 +1366,193 @@ display_settings_dialog_new (GtkBuilder *builder)
 }
 
 static void
-display_settings_minimal_extend_left_toggled (GtkToggleButton *button,
+display_settings_minimal_only_display1_toggled (GtkToggleButton *button,
   GtkBuilder *builder)
 {
-GObject *mirror_displays;
-GObject *extend_right;
-
-gint selected_x, selected_y;
-XfceRRMode   *current_mode;
+GObject *mirror_displays, *extend_right, *only_display2;
 
 mirror_displays = gtk_builder_get_object(builder, mirror);
 extend_right = gtk_builder_get_object(builder, extend_right);
-
+only_display2 = gtk_builder_get_object(builder, display2);
+
+/* Lock everything in the dialog to prevent bad things from happening */
 g_object_disconnect (mirror_displays, any_signal::toggled,
  display_settings_minimal_mirror_displays_toggled,
  builder, NULL);
- 
 g_object_disconnect (extend_right, any_signal::toggled,
  display_settings_minimal_extend_right_toggled,
  builder, NULL);
+g_object_disconnect (only_display2, any_signal::toggled,
+ display_settings_minimal_only_display2_toggled,
+ builder, NULL);
  
 gtk_widget_set_sensitive( GTK_WIDGET(mirror_displays), FALSE );
 gtk_widget_set_sensitive( GTK_WIDGET(extend_right), FALSE );
-
-/* Since this signal will only be called when a toggle button is 
activated. */
+gtk_widget_set_sensitive( GTK_WIDGET(only_display2), FALSE );
+
 gtk_toggle_button_set_active (button, TRUE);
 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(mirror_displays), FALSE);
 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(extend_right), FALSE);
+gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(only_display2), FALSE);
 
-/* Change active output to secondary display. */
-xfce_randr-active_output = 1;
-
-current_mode = xfce_randr_find_mode_by_id (xfce_randr, 
xfce_randr-active_output, XFCE_RANDR_MODE (xfce_randr));
-
-/* Change active output to primary display. */
-xfce_randr-active_output = 0;
+if (!xfce_randr)
+return;
+
+if (xfce_randr-noutput = 1)
+return;
+
+if (gtk_toggle_button_get_active (button))
+{
+   /* Put Display1 in its preferred mode and deactivate Display2 */
+XFCE_RANDR_MODE (xfce_randr) = xfce_randr_preferred_mode (xfce_randr, 
0);
+xfce_randr-active_output = 1;
+XFCE_RANDR_MODE (xfce_randr) = None;
+/* Apply the changes */
+xfce_randr_save_output (xfce_randr, Default, display_channel,0);
+xfce_randr_save_output (xfce_randr, Default, display_channel,1);
+xfce_randr_apply (xfce_randr, Default, display_channel);
+}
 
-/* Move the secondary to where the primary is... */
-selected_x = XFCE_RANDR_POS_X (xfce_randr);
-selected_y = XFCE_RANDR_POS_Y (xfce_randr);
-xfce_randr-active_output = 1;
-XFCE_RANDR_POS_X (xfce_randr) = selected_x;
-XFCE_RANDR_POS_Y (xfce_randr) = selected_y;
+gtk_widget_set_sensitive( GTK_WIDGET(mirror_displays), TRUE );
+gtk_widget_set_sensitive( GTK_WIDGET(extend_right), TRUE );
+gtk_widget_set_sensitive( GTK_WIDGET(only_display2), TRUE );
+
+/* Reconnect the signals 

[Xfce4-commits] xfce4-settings:bluesabre/display-settings Hook up the reworked minimal dialog

2012-10-04 Thread Simon Steinbeiss
Updating branch refs/heads/bluesabre/display-settings
 to 81894832f619b5bae3f9199a045ae4f9e2934f96 (commit)
   from 18f5b2b24eff4818353eb0577e8c4b5695d0ddd1 (commit)

commit 81894832f619b5bae3f9199a045ae4f9e2934f96
Author: Simon Steinbeiss simon.steinbe...@elfenbeinturm.at
Date:   Thu Oct 4 12:24:11 2012 +0200

Hook up the reworked minimal dialog

 dialogs/display-settings/main.c |  288 ---
 1 files changed, 179 insertions(+), 109 deletions(-)

diff --git a/dialogs/display-settings/main.c b/dialogs/display-settings/main.c
index 0640404..c22ffea 100644
--- a/dialogs/display-settings/main.c
+++ b/dialogs/display-settings/main.c
@@ -113,7 +113,7 @@ static gboolean   bound_to_channel = FALSE;
 XfceRandr *xfce_randr = NULL;
 
 static void
-display_settings_minimal_extend_left_toggled (GtkToggleButton *button,
+display_settings_minimal_only_display1_toggled (GtkToggleButton *button,
   GtkBuilder *builder);
   
 static void
@@ -123,7 +123,10 @@ display_settings_minimal_mirror_displays_toggled 
(GtkToggleButton *button,
 static void
 display_settings_minimal_extend_right_toggled (GtkToggleButton *button,
   GtkBuilder *builder);
-
+  
+static void
+display_settings_minimal_only_display2_toggled (GtkToggleButton *button,
+  GtkBuilder *builder);
 
 
 static guint
@@ -1363,134 +1366,193 @@ display_settings_dialog_new (GtkBuilder *builder)
 }
 
 static void
-display_settings_minimal_extend_left_toggled (GtkToggleButton *button,
+display_settings_minimal_only_display1_toggled (GtkToggleButton *button,
   GtkBuilder *builder)
 {
-GObject *mirror_displays;
-GObject *extend_right;
-
-gint selected_x, selected_y;
-XfceRRMode   *current_mode;
+GObject *mirror_displays, *extend_right, *only_display2;
 
 mirror_displays = gtk_builder_get_object(builder, mirror);
 extend_right = gtk_builder_get_object(builder, extend_right);
-
+only_display2 = gtk_builder_get_object(builder, display2);
+
+/* Lock everything in the dialog to prevent bad things from happening */
 g_object_disconnect (mirror_displays, any_signal::toggled,
  display_settings_minimal_mirror_displays_toggled,
  builder, NULL);
- 
 g_object_disconnect (extend_right, any_signal::toggled,
  display_settings_minimal_extend_right_toggled,
  builder, NULL);
+g_object_disconnect (only_display2, any_signal::toggled,
+ display_settings_minimal_only_display2_toggled,
+ builder, NULL);
  
 gtk_widget_set_sensitive( GTK_WIDGET(mirror_displays), FALSE );
 gtk_widget_set_sensitive( GTK_WIDGET(extend_right), FALSE );
-
-/* Since this signal will only be called when a toggle button is 
activated. */
+gtk_widget_set_sensitive( GTK_WIDGET(only_display2), FALSE );
+
 gtk_toggle_button_set_active (button, TRUE);
 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(mirror_displays), FALSE);
 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(extend_right), FALSE);
+gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(only_display2), FALSE);
 
-/* Change active output to secondary display. */
-xfce_randr-active_output = 1;
-
-current_mode = xfce_randr_find_mode_by_id (xfce_randr, 
xfce_randr-active_output, XFCE_RANDR_MODE (xfce_randr));
-
-/* Change active output to primary display. */
-xfce_randr-active_output = 0;
+if (!xfce_randr)
+return;
+
+if (xfce_randr-noutput = 1)
+return;
+
+if (gtk_toggle_button_get_active (button))
+{
+   /* Put Display1 in its preferred mode and deactivate Display2 */
+XFCE_RANDR_MODE (xfce_randr) = xfce_randr_preferred_mode (xfce_randr, 
0);
+xfce_randr-active_output = 1;
+XFCE_RANDR_MODE (xfce_randr) = None;
+/* Apply the changes */
+xfce_randr_save_output (xfce_randr, Default, display_channel,0);
+xfce_randr_save_output (xfce_randr, Default, display_channel,1);
+xfce_randr_apply (xfce_randr, Default, display_channel);
+}
 
-/* Move the secondary to where the primary is... */
-selected_x = XFCE_RANDR_POS_X (xfce_randr);
-selected_y = XFCE_RANDR_POS_Y (xfce_randr);
-xfce_randr-active_output = 1;
-XFCE_RANDR_POS_X (xfce_randr) = selected_x;
-XFCE_RANDR_POS_Y (xfce_randr) = selected_y;
+gtk_widget_set_sensitive( GTK_WIDGET(mirror_displays), TRUE );
+gtk_widget_set_sensitive( GTK_WIDGET(extend_right), TRUE );
+gtk_widget_set_sensitive( GTK_WIDGET(only_display2), TRUE );
+
+/* Reconnect the