[empathy] Use the new enum everywhere



commit 2e7a0efc837d4b38290dffbd04a1c9d70df64db2
Author: Emilio Pozuelo Monfort <emilio pozuelo collabora co uk>
Date:   Wed Aug 3 16:49:10 2011 +0100

    Use the new enum everywhere
    
    And use strings for the --show-preferences argument.

 src/empathy-call-window.c |    4 +++-
 src/empathy-main-window.c |    6 +++---
 src/empathy-main-window.h |    2 +-
 src/empathy-preferences.c |   31 +++++++++++++++++++++++++++----
 src/empathy-preferences.h |   12 +++++++++---
 src/empathy.c             |   10 +++++-----
 6 files changed, 48 insertions(+), 17 deletions(-)
---
diff --git a/src/empathy-call-window.c b/src/empathy-call-window.c
index 52c68b4..215bb5c 100644
--- a/src/empathy-call-window.c
+++ b/src/empathy-call-window.c
@@ -63,6 +63,7 @@
 #include "empathy-audio-sink.h"
 #include "empathy-video-src.h"
 #include "empathy-mic-menu.h"
+#include "empathy-preferences.h"
 
 #define CONTENT_HBOX_BORDER_WIDTH 6
 #define CONTENT_HBOX_SPACING 3
@@ -734,7 +735,8 @@ static void
 empathy_call_window_settings_cb (GtkAction *action,
     EmpathyCallWindow *self)
 {
-  empathy_launch_program (BIN_DIR, "empathy", "-p 3");
+  empathy_launch_program (BIN_DIR, "empathy",
+      "-p " EMPATHY_PREFERENCES_STR_TAB_CALLS);
 }
 
 static void
diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c
index 3d09e52..3ecb939 100644
--- a/src/empathy-main-window.c
+++ b/src/empathy-main-window.c
@@ -1877,7 +1877,7 @@ main_window_edit_blocked_contacts_cb (GtkAction         *action,
 
 void
 empathy_main_window_show_preferences (EmpathyMainWindow *window,
-    gint tab)
+    const gchar *tab)
 {
 	EmpathyMainWindowPriv *priv = GET_PRIV (window);
 
@@ -1891,7 +1891,7 @@ empathy_main_window_show_preferences (EmpathyMainWindow *window,
 		gtk_window_present (GTK_WINDOW (priv->preferences));
 	}
 
-	if (tab != -1)
+	if (tab != NULL)
 		empathy_preferences_show_tab (
 			EMPATHY_PREFERENCES (priv->preferences), tab);
 }
@@ -1900,7 +1900,7 @@ static void
 main_window_edit_preferences_cb (GtkAction         *action,
 				 EmpathyMainWindow *window)
 {
-	empathy_main_window_show_preferences (window, -1);
+	empathy_main_window_show_preferences (window, NULL);
 }
 
 static void
diff --git a/src/empathy-main-window.h b/src/empathy-main-window.h
index 4392e73..cb0ae3c 100644
--- a/src/empathy-main-window.h
+++ b/src/empathy-main-window.h
@@ -54,7 +54,7 @@ GType empathy_main_window_get_type (void);
 GtkWidget *empathy_main_window_dup (void);
 
 void empathy_main_window_show_preferences (EmpathyMainWindow *window,
-    gint tab);
+    const gchar *tab);
 
 G_END_DECLS
 
diff --git a/src/empathy-preferences.c b/src/empathy-preferences.c
index dd3aaee..4b3e076 100644
--- a/src/empathy-preferences.c
+++ b/src/empathy-preferences.c
@@ -1226,11 +1226,11 @@ empathy_preferences_init (EmpathyPreferences *preferences)
 	preferences_sound_load (preferences);
 
 	if (empathy_spell_supported ()) {
-		page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (priv->notebook), 5);
+		page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (priv->notebook), EMPATHY_PREFERENCES_TAB_SPELL);
 		gtk_widget_show (page);
 	}
 
-	page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (priv->notebook), 4);
+	page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (priv->notebook), EMPATHY_PREFERENCES_TAB_LOCATION);
 #ifdef HAVE_GEOCLUE
 	gtk_widget_show (page);
 #else
@@ -1238,6 +1238,28 @@ empathy_preferences_init (EmpathyPreferences *preferences)
 #endif
 }
 
+static EmpathyPreferencesTab
+empathy_preferences_tab_from_string (const gchar *str)
+{
+  if (!tp_strdiff (str, EMPATHY_PREFERENCES_STR_TAB_GENERAL))
+    return EMPATHY_PREFERENCES_TAB_GENERAL;
+  else if (!tp_strdiff (str, EMPATHY_PREFERENCES_STR_TAB_NOTIFICATIONS))
+    return EMPATHY_PREFERENCES_TAB_NOTIFICATIONS;
+  else if (!tp_strdiff (str, EMPATHY_PREFERENCES_STR_TAB_SOUNDS))
+    return EMPATHY_PREFERENCES_TAB_SOUNDS;
+  else if (!tp_strdiff (str, EMPATHY_PREFERENCES_STR_TAB_CALLS))
+    return EMPATHY_PREFERENCES_TAB_CALLS;
+  else if (!tp_strdiff (str, EMPATHY_PREFERENCES_STR_TAB_LOCATION))
+    return EMPATHY_PREFERENCES_TAB_LOCATION;
+  else if (!tp_strdiff (str, EMPATHY_PREFERENCES_STR_TAB_SPELL))
+    return EMPATHY_PREFERENCES_TAB_SPELL;
+  else if (!tp_strdiff (str, EMPATHY_PREFERENCES_STR_TAB_THEMES))
+    return EMPATHY_PREFERENCES_TAB_THEMES;
+
+  g_warn_if_reached ();
+  return -1;
+}
+
 GtkWidget *
 empathy_preferences_new (GtkWindow *parent)
 {
@@ -1257,9 +1279,10 @@ empathy_preferences_new (GtkWindow *parent)
 
 void
 empathy_preferences_show_tab (EmpathyPreferences *self,
-			      gint tab)
+			      const gchar *page)
 {
 	EmpathyPreferencesPriv *priv = GET_PRIV (self);
 
-	gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), tab);
+	gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook),
+				       empathy_preferences_tab_from_string (page));
 }
diff --git a/src/empathy-preferences.h b/src/empathy-preferences.h
index 707c5e8..daaaecc 100644
--- a/src/empathy-preferences.h
+++ b/src/empathy-preferences.h
@@ -61,15 +61,21 @@ typedef enum
   EMPATHY_PREFERENCES_TAB_THEMES,
 } EmpathyPreferencesTab;
 
+#define EMPATHY_PREFERENCES_STR_TAB_GENERAL "general"
+#define EMPATHY_PREFERENCES_STR_TAB_NOTIFICATIONS "notifications"
+#define EMPATHY_PREFERENCES_STR_TAB_SOUNDS "sounds"
+#define EMPATHY_PREFERENCES_STR_TAB_CALLS "calls"
+#define EMPATHY_PREFERENCES_STR_TAB_LOCATION "location"
+#define EMPATHY_PREFERENCES_STR_TAB_SPELL "spell"
+#define EMPATHY_PREFERENCES_STR_TAB_THEMES "themes"
+
 GType empathy_preferences_get_type (void);
 
 GtkWidget *empathy_preferences_new (GtkWindow *parent);
 
 void empathy_preferences_show_tab (EmpathyPreferences *self,
-    gint tab);
+    const gchar *tab);
 
 G_END_DECLS
 
 #endif /* __EMPATHY_PREFERENCES_H__ */
-
-
diff --git a/src/empathy.c b/src/empathy.c
index 66b3877..3506319 100644
--- a/src/empathy.c
+++ b/src/empathy.c
@@ -107,7 +107,7 @@ struct _EmpathyApp
   gboolean no_connect;
   gboolean start_hidden;
   gboolean show_preferences;
-  gint preferences_tab;
+  gchar *preferences_tab;
 
   gboolean activated;
 
@@ -173,6 +173,8 @@ empathy_app_finalize (GObject *object)
   void (*finalize) (GObject *) =
     G_OBJECT_CLASS (empathy_app_parent_class)->finalize;
 
+  g_free (self->preferences_tab);
+
   if (self->window != NULL)
     gtk_widget_destroy (self->window);
 
@@ -319,10 +321,8 @@ preferences_cb (const char *option_name,
 
   self->show_preferences = TRUE;
 
-  self->preferences_tab = -1;
-
-  if (value != NULL)
-    self->preferences_tab = atoi (value);
+  g_free (self->preferences_tab);
+  self->preferences_tab = g_strdup (value);
 
   return TRUE;
 }



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