aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEmilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>2011-08-03 23:49:10 +0800
committerEmilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>2011-08-04 17:10:20 +0800
commit2e7a0efc837d4b38290dffbd04a1c9d70df64db2 (patch)
treec779badde862e83bac3fa393bafa4183c584f6ba /src
parentd801233c1f25596c429d75d03ec6282d1b3828e2 (diff)
downloadgsoc2013-empathy-2e7a0efc837d4b38290dffbd04a1c9d70df64db2.tar
gsoc2013-empathy-2e7a0efc837d4b38290dffbd04a1c9d70df64db2.tar.gz
gsoc2013-empathy-2e7a0efc837d4b38290dffbd04a1c9d70df64db2.tar.bz2
gsoc2013-empathy-2e7a0efc837d4b38290dffbd04a1c9d70df64db2.tar.lz
gsoc2013-empathy-2e7a0efc837d4b38290dffbd04a1c9d70df64db2.tar.xz
gsoc2013-empathy-2e7a0efc837d4b38290dffbd04a1c9d70df64db2.tar.zst
gsoc2013-empathy-2e7a0efc837d4b38290dffbd04a1c9d70df64db2.zip
Use the new enum everywhere
And use strings for the --show-preferences argument.
Diffstat (limited to 'src')
-rw-r--r--src/empathy-call-window.c4
-rw-r--r--src/empathy-main-window.c6
-rw-r--r--src/empathy-main-window.h2
-rw-r--r--src/empathy-preferences.c31
-rw-r--r--src/empathy-preferences.h12
-rw-r--r--src/empathy.c10
6 files changed, 48 insertions, 17 deletions
diff --git a/src/empathy-call-window.c b/src/empathy-call-window.c
index 52c68b441..215bb5c4d 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 3d09e5255..3ecb939a4 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 4392e73e9..cb0ae3cf0 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 dd3aaee13..4b3e0766f 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 707c5e81d..daaaecc0b 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 66b387788..3506319fa 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;
}