[GnomeMeeting-devel-list] Dialpad alignment



This patch makes all the digits in the dialpad aligned. The current
style is not all that bad, but this looks slightly more neat.
The size of the buttons should remain the same. But if you'd prefer all
digits to be in the horizontal center of each button, the buttons would
have to become wider than now, or the alphas would have to be notably
smaller.
Alternative layouts can easilly be implemented (e.g. digit on top and
alpha at bottom) as well as controlling visibility of the alphas.
Please point out flaws in the coding. One thing I wonder is: in the
callback function the label widget that holds "digit" value is
fetched... but how to know if it's first or second child of the hbox?
Currently it's by certain the first child, but if other layout is used
then it might be the second.
/Eric
--- gnomemeeting-opal/src/main_window.cpp.orig	2005-12-16 03:33:55.000000000 +0100
+++ gnomemeeting-opal/src/main_window.cpp	2005-12-16 03:33:18.000000000 +0100
@@ -1191,6 +1191,10 @@
 {
   GmWindow *mw = NULL;
   
+  GtkSizeGroup *size_group_alpha = NULL;
+  GtkSizeGroup *size_group_digit = NULL;
+
+  GtkWidget *box = NULL;
   GtkWidget *button = NULL;
   GtkWidget *label = NULL;
   GtkWidget *table = NULL;
@@ -1216,16 +1220,34 @@
   gtk_container_set_border_width (GTK_CONTAINER (table), 4);
   
 
+  size_group_alpha = gtk_size_group_new (GTK_SIZE_GROUP_BOTH);
+  size_group_digit = gtk_size_group_new (GTK_SIZE_GROUP_BOTH);
+
   for (i = 0 ; i < 12 ; i++) {
 
+    box = gtk_hbox_new (FALSE, 0);
+
+    label = gtk_label_new (NULL);
+    text_label =
+      g_strdup_printf (" %s ",
+		       key_n [i]);
+    g_object_set (label, "xalign", 1.0, NULL);
+    gtk_label_set_markup (GTK_LABEL (label), text_label); 
+    gtk_size_group_add_widget (size_group_digit, label);
+		gtk_box_pack_start (GTK_BOX(box), label, TRUE, TRUE, 0);
+
     label = gtk_label_new (NULL);
     text_label =
-      g_strdup_printf ("%s<sub><span size=\"small\">%s</span></sub>",
-		       key_n [i], key_a [i]);
+      g_strdup_printf ("<sub><span size=\"small\">%s</span></sub> ",
+		       key_a [i]);
+    g_object_set (label, "xalign", 0.0, NULL);
     gtk_label_set_markup (GTK_LABEL (label), text_label); 
+    gtk_size_group_add_widget (size_group_alpha, label);
+		gtk_box_pack_start (GTK_BOX(box), label, FALSE, TRUE, 0);
+
     button = gtk_button_new ();
     gtk_container_set_border_width (GTK_CONTAINER (button), 0);
-    gtk_container_add (GTK_CONTAINER (button), label);
+    gtk_container_add (GTK_CONTAINER (button), box);
    
     gtk_widget_add_accelerator (button, "activate", 
 				mw->accel, key_kp [i], 
@@ -1954,7 +1976,7 @@
 
   endpoint = GnomeMeeting::Process ()->Endpoint ();
 
-  label = gtk_bin_get_child (GTK_BIN (button));
+  label = ( (GtkBoxChild*) GTK_BOX (gtk_bin_get_child (GTK_BIN (button)) )->children->data )->widget;
   button_text = gtk_label_get_text (GTK_LABEL (label));
 
   if (button_text
@@ -1969,7 +1991,7 @@
     /* Send the DTMF if there is a current call */
     if (!call_token.IsEmpty ()) {
       
-      endpoint->SendDTMF (call_token, button_text [0]);
+      endpoint->SendDTMF (call_token, button_text [1]);
       sent = TRUE;
     }
     gdk_threads_enter ();
@@ -1979,17 +2001,17 @@
      * and a button press in all cases */
     if (!sent) {
 
-      if (button_text [0] == '*')
+      if (button_text [1] == '*')
 	url += '.';
       else
-	url += button_text [0];
+	url += button_text [1];
       
       gm_main_window_append_call_url (GTK_WIDGET (data), url);
     }
     else
       gm_main_window_flash_message (GTK_WIDGET (data),
 				    _("Sent DTMF %c"), 
-				    button_text [0]);
+				    button_text [1]);
   }
 }
 

Attachment: screenshots.png
Description: PNG image



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