]> git.0d.be Git - empathy.git/commitdiff
Use the new enum everywhere
authorEmilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>
Wed, 3 Aug 2011 15:49:10 +0000 (16:49 +0100)
committerEmilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>
Thu, 4 Aug 2011 09:10:20 +0000 (10:10 +0100)
And use strings for the --show-preferences argument.

src/empathy-call-window.c
src/empathy-main-window.c
src/empathy-main-window.h
src/empathy-preferences.c
src/empathy-preferences.h
src/empathy.c

index 52c68b441464b3e5ddba7ad0438b677cefb82bd7..215bb5c4d6df44563694f9196dff88b1b530af5b 100644 (file)
@@ -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
index 3d09e5255e5969fc667a0be1bdd25db2f686cd7a..3ecb939a4cfe95f3da9848b2e6464db73ac17b17 100644 (file)
@@ -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
index 4392e73e9c6f7642ef68a2ede2834e9890554673..cb0ae3cf07ef4e6703e7343b39b23ad57a38e7b7 100644 (file)
@@ -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
 
index dd3aaee135cfaa34efade36cb0e3a52533c093b3..4b3e0766f4c7b249e3efedada5040d076a75ae66 100644 (file)
@@ -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));
 }
index 707c5e81da35977322d327069d538b7c978183fd..daaaecc0b4449dc917aa80a26c0bf2ccfd214581 100644 (file)
@@ -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__ */
-
-
index 66b38778858afb22416e636ce3e3ad59487fc51a..3506319fa318e407b97e8cc481484d4ae71b5efa 100644 (file)
@@ -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;
 }