[ekiga] Use tooltips for Detect devices button and code simplification



commit 8cf17ddf9ee0c148e26eb6ae9e04c511f37be7ff
Author: Eugen Dedu <Eugen Dedu pu-pm univ-fcomte fr>
Date:   Mon Jan 10 22:01:51 2011 +0100

    Use tooltips for Detect devices button and code simplification

 src/gui/preferences.cpp |   50 +++++++++++++++++-----------------------------
 1 files changed, 19 insertions(+), 31 deletions(-)
---
diff --git a/src/gui/preferences.cpp b/src/gui/preferences.cpp
index 2185829..3643b55 100644
--- a/src/gui/preferences.cpp
+++ b/src/gui/preferences.cpp
@@ -33,7 +33,7 @@
  *   copyright            : (C) 2000-2006 by Damien Sandras
  *   description          : This file contains all the functions needed to
  *                          create the preferences window and all its callbacks
- *   Additional code      : Miguel Rodríguez Pérez  <miguelrp gmail com> 
+ *   Additional code      : Miguel Rodríguez Pérez  <miguelrp gmail com>
  */
 
 
@@ -91,33 +91,31 @@ static void gm_pw_destroy (gpointer prefs_window);
 /* DESCRIPTION  : /
  * BEHAVIOR     : Returns a pointer to the private GmPrerencesWindow structure
  *                used by the preferences window GMObject.
- * PRE          : The given GtkWidget pointer must be a preferences window 
+ * PRE          : The given GtkWidget pointer must be a preferences window
  * 		  GMObject.
  */
 static GmPreferencesWindow *gm_pw_get_pw (GtkWidget *preferences_window);
 
 
-/* DESCRIPTION  :  / 
- * BEHAVIOR     :  Builds the sound events list of the preferences window. 
+/* DESCRIPTION  :  /
+ * BEHAVIOR     :  Builds the sound events list of the preferences window.
  * PRE          :  /
  */
-static void gm_prefs_window_sound_events_list_build (GtkWidget *prefs_window); 
+static void gm_prefs_window_sound_events_list_build (GtkWidget *prefs_window);
 
 
 /* DESCRIPTION  : /
  * BEHAVIOR     : Adds an update button connected to the given callback to
  * 		  the given GtkBox.
- * PRE          : A valid pointer to the preferences window GMObject, and to the
- * 		  container widget where to attach the button, followed by
- * 		  a stock ID, a label, the callback, a tooltip and the 
- * 		  alignment.
+ * PRE          : A valid pointer to the container widget where to attach
+ *        the button, followed by a stock ID, a label, the callback, a
+ *        tooltip and the alignment.
  */
-static GtkWidget *gm_pw_add_update_button (GtkWidget *prefs_window,
-					   GtkWidget *box,
+static void gm_pw_add_update_button (GtkWidget *box,
 					   const char *stock_id,
 					   const char *label,
 					   GCallback func,
-					   gchar *tooltip,
+					   const gchar *tooltip,
 					   gfloat valign,
 					   gpointer data);
 
@@ -403,32 +401,24 @@ gm_prefs_window_sound_events_list_build (GtkWidget *prefs_window)
 }
 
 
-static GtkWidget *
-gm_pw_add_update_button (G_GNUC_UNUSED GtkWidget *prefs_window,
-                         GtkWidget *box,
+static void
+gm_pw_add_update_button (GtkWidget *box,
                          const char *stock_id,
-                         const char *label_,
+                         const char *label,
                          GCallback func,
-                         G_GNUC_UNUSED gchar *tooltip,
+                         const gchar *tooltip,
                          gfloat valign,
                          gpointer data)
 {
   GtkWidget* alignment = NULL;
   GtkWidget* image = NULL;
   GtkWidget* button = NULL;
-  GtkWidget* hbox = NULL;
-  GtkWidget* label = NULL;
 
   /* Update Button */
+  button = gtk_button_new_with_mnemonic (label);
   image = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_BUTTON);
-  button = gtk_button_new ();
-  label = gtk_label_new_with_mnemonic (label_);
-  hbox = gtk_hbox_new (FALSE, 0);
-
-  gtk_box_pack_start(GTK_BOX (hbox), image, TRUE, TRUE, 0);
-  gtk_box_pack_start(GTK_BOX (hbox), label, TRUE, TRUE, 0);
-
-  gtk_container_add (GTK_CONTAINER (button), hbox);
+  gtk_button_set_image ((GTK_BUTTON) button, image);
+  gtk_widget_set_tooltip_text (button, tooltip);
 
   alignment = gtk_alignment_new (1, valign, 0, 0);
   gtk_container_add (GTK_CONTAINER (alignment), button);
@@ -439,8 +429,6 @@ gm_pw_add_update_button (G_GNUC_UNUSED GtkWidget *prefs_window,
   g_signal_connect (button, "clicked",
                     G_CALLBACK (func),
                     (gpointer) data);
-
-  return button;
 }
 
 
@@ -771,7 +759,7 @@ gm_pw_init_audio_devices_page (GtkWidget *prefs_window,
   g_free (array);
 
   /* That button will refresh the device list */
-  gm_pw_add_update_button (prefs_window, container, GTK_STOCK_REFRESH, _("_Detect devices"), G_CALLBACK (refresh_devices_list_cb), _("Click here to refresh the device list"), 1, prefs_window);
+  gm_pw_add_update_button (container, GTK_STOCK_REFRESH, _("_Detect devices"), G_CALLBACK (refresh_devices_list_cb), _("Click here to refresh the device list"), 1, prefs_window);
 }
 
 
@@ -920,7 +908,7 @@ gm_pw_init_video_devices_page (GtkWidget *prefs_window,
   gnome_prefs_int_option_menu_new (subsection, _("Format:"), video_format, VIDEO_DEVICES_KEY "format", _("Select the format for video cameras (does not apply to most USB cameras)"), 2);
 
   /* That button will refresh the device list */
-  gm_pw_add_update_button (prefs_window, container, GTK_STOCK_REFRESH, _("_Detect devices"), G_CALLBACK (refresh_devices_list_cb), _("Click here to refresh the device list"), 1, prefs_window);
+  gm_pw_add_update_button (container, GTK_STOCK_REFRESH, _("_Detect devices"), G_CALLBACK (refresh_devices_list_cb), _("Click here to refresh the device list"), 1, prefs_window);
 
   for (i=0; i< NB_VIDEO_SIZES; i++)
     g_free (video_size[i]);



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