[accounts-dialog/control-center-panel: 12/15] Prevent jumping text



commit 7178e3ecb05f2452ada7ac5e24037e64d4fadc4d
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Jun 13 23:31:55 2010 -0400

    Prevent jumping text
    
    By padding the labels enough to make them match up with their
    counterparts in the button.

 src/um-editable-button.c |   20 ++++++++++++++++++++
 src/um-editable-combo.c  |   21 +++++++++++++++++++++
 2 files changed, 41 insertions(+), 0 deletions(-)
---
diff --git a/src/um-editable-button.c b/src/um-editable-button.c
index 9e376c8..59b792b 100644
--- a/src/um-editable-button.c
+++ b/src/um-editable-button.c
@@ -420,6 +420,25 @@ entry_key_press (GtkWidget        *widget,
 }
 
 static void
+update_button_padding (GtkWidget        *widget,
+                       GtkAllocation    *allocation,
+                       UmEditableButton *button)
+{
+        UmEditableButtonPrivate *priv = button->priv;
+        GtkAllocation parent_allocation;
+        gint offset;
+        gint pad;
+
+        gtk_widget_get_allocation (gtk_widget_get_parent (widget), &parent_allocation);
+
+        offset = allocation->x - parent_allocation.x;
+
+        gtk_misc_get_padding  (GTK_MISC (priv->label), &pad, NULL);
+        if (offset != pad)
+                gtk_misc_set_padding (GTK_MISC (priv->label), offset, 0);
+}
+
+static void
 um_editable_button_init (UmEditableButton *button)
 {
         UmEditableButtonPrivate *priv;
@@ -453,6 +472,7 @@ um_editable_button_init (UmEditableButton *button)
         g_signal_connect (priv->entry, "focus-out-event", G_CALLBACK (entry_focus_out), button);
         g_signal_connect (priv->entry, "key-press-event", G_CALLBACK (entry_key_press), button);
         g_signal_connect (priv->entry, "style-set", G_CALLBACK (update_entry_font), button);
+        g_signal_connect (gtk_bin_get_child (GTK_BIN (priv->button)), "size-allocate", G_CALLBACK (update_button_padding), button);
 
         gtk_container_add (GTK_CONTAINER (button), (GtkWidget*)priv->notebook);
 
diff --git a/src/um-editable-combo.c b/src/um-editable-combo.c
index 567818e..06b5d60 100644
--- a/src/um-editable-combo.c
+++ b/src/um-editable-combo.c
@@ -364,6 +364,25 @@ combo_hierarchy_changed (GtkWidget       *widget,
 }
 
 static void
+update_button_padding (GtkWidget       *widget,
+                       GtkAllocation   *allocation,
+                       UmEditableCombo *combo)
+{
+        UmEditableComboPrivate *priv = combo->priv;
+        GtkAllocation parent_allocation;
+        gint offset;
+        gint pad;
+
+        gtk_widget_get_allocation (gtk_widget_get_parent (widget), &parent_allocation);
+
+        offset = allocation->x - parent_allocation.x;
+
+        gtk_misc_get_padding  (GTK_MISC (priv->label), &pad, NULL);
+        if (offset != pad)
+                gtk_misc_set_padding (GTK_MISC (priv->label), offset, 0);
+}
+
+static void
 um_editable_combo_init (UmEditableCombo *combo)
 {
         UmEditableComboPrivate *priv;
@@ -396,6 +415,8 @@ um_editable_combo_init (UmEditableCombo *combo)
 
         g_signal_connect (priv->combo, "changed", G_CALLBACK (combo_changed), combo);
         g_signal_connect (priv->combo, "key-press-event", G_CALLBACK (combo_key_press), combo);
+        g_signal_connect (gtk_bin_get_child (GTK_BIN (priv->button)), "size-allocate", G_CALLBACK (update_button_padding), combo);
+
 
         gtk_container_add (GTK_CONTAINER (combo), (GtkWidget*)priv->notebook);
 



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