log-window: factor out add_date_if_needed()
[empathy-mirror.git] / src / empathy-preferences.c
blob77ec49c264edaa52d9c336261141e108bca849a6
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3 * Copyright (C) 2003-2007 Imendio AB
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public
16 * License along with this program; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18 * Boston, MA 02110-1301 USA
20 * Authors: Mikael Hallendal <micke@imendio.com>
21 * Richard Hult <richard@imendio.com>
22 * Martyn Russell <martyn@imendio.com>
23 * Danielle Madeley <danielle.madeley@collabora.co.uk>
26 #include <config.h>
28 #include <string.h>
29 #include <stdio.h>
31 #include <gtk/gtk.h>
32 #include <glib/gi18n.h>
33 #include <telepathy-glib/dbus.h>
34 #include <telepathy-glib/util.h>
36 #include <libempathy/empathy-gsettings.h>
37 #include <libempathy/empathy-utils.h>
39 #include <libempathy-gtk/empathy-ui-utils.h>
40 #include <libempathy-gtk/empathy-theme-manager.h>
41 #include <libempathy-gtk/empathy-spell.h>
42 #include <libempathy-gtk/empathy-gtk-enum-types.h>
43 #include <libempathy-gtk/empathy-theme-adium.h>
45 #include "empathy-preferences.h"
47 #define DEBUG_FLAG EMPATHY_DEBUG_OTHER
48 #include <libempathy/empathy-debug.h>
50 G_DEFINE_TYPE (EmpathyPreferences, empathy_preferences, GTK_TYPE_DIALOG);
52 #define GET_PRIV(self) ((EmpathyPreferencesPriv *)((EmpathyPreferences *) self)->priv)
54 static const gchar * empathy_preferences_tabs[] =
56 "general",
57 "notifications",
58 "sounds",
59 "calls",
60 "location",
61 "spell",
62 "themes",
65 struct _EmpathyPreferencesPriv {
66 GtkWidget *notebook;
68 GtkWidget *checkbutton_show_smileys;
69 GtkWidget *checkbutton_show_contacts_in_rooms;
70 GtkWidget *radiobutton_chats_new_windows;
71 GtkWidget *checkbutton_events_notif_area;
72 GtkWidget *checkbutton_autoconnect;
73 GtkWidget *checkbutton_logging;
75 GtkWidget *checkbutton_sounds_enabled;
76 GtkWidget *checkbutton_sounds_disabled_away;
77 GtkWidget *treeview_sounds;
79 GtkWidget *checkbutton_notifications_enabled;
80 GtkWidget *checkbutton_notifications_disabled_away;
81 GtkWidget *checkbutton_notifications_focus;
82 GtkWidget *checkbutton_notifications_contact_signin;
83 GtkWidget *checkbutton_notifications_contact_signout;
85 GtkWidget *echo_cancellation;
87 GtkWidget *treeview_spell_checker;
89 GtkWidget *checkbutton_location_publish;
90 GtkWidget *checkbutton_location_reduce_accuracy;
91 GtkWidget *checkbutton_location_resource_network;
92 GtkWidget *checkbutton_location_resource_cell;
93 GtkWidget *checkbutton_location_resource_gps;
95 GtkWidget *vbox_chat_theme;
96 GtkWidget *combobox_chat_theme;
97 GtkWidget *combobox_chat_theme_variant;
98 GtkWidget *hbox_chat_theme_variant;
99 GtkWidget *sw_chat_theme_preview;
100 EmpathyChatView *chat_theme_preview;
101 EmpathyThemeManager *theme_manager;
103 GSettings *gsettings;
104 GSettings *gsettings_chat;
105 GSettings *gsettings_call;
106 GSettings *gsettings_loc;
107 GSettings *gsettings_notify;
108 GSettings *gsettings_sound;
109 GSettings *gsettings_ui;
110 GSettings *gsettings_logger;
113 static void preferences_setup_widgets (EmpathyPreferences *preferences);
114 static void preferences_languages_setup (EmpathyPreferences *preferences);
115 static void preferences_languages_add (EmpathyPreferences *preferences);
116 static void preferences_languages_save (EmpathyPreferences *preferences);
117 static gboolean preferences_languages_save_foreach (GtkTreeModel *model,
118 GtkTreePath *path,
119 GtkTreeIter *iter,
120 gchar **languages);
121 static void preferences_languages_load (EmpathyPreferences *preferences);
122 static gboolean preferences_languages_load_foreach (GtkTreeModel *model,
123 GtkTreePath *path,
124 GtkTreeIter *iter,
125 GList *languages);
126 static void preferences_languages_cell_toggled_cb (GtkCellRendererToggle *cell,
127 gchar *path_string,
128 EmpathyPreferences *preferences);
130 enum {
131 COL_LANG_ENABLED,
132 COL_LANG_CODE,
133 COL_LANG_NAME,
134 COL_LANG_COUNT
137 enum {
138 COL_THEME_VISIBLE_NAME,
139 COL_THEME_NAME,
140 COL_THEME_IS_ADIUM,
141 COL_THEME_ADIUM_PATH,
142 COL_THEME_ADIUM_INFO,
143 COL_THEME_COUNT
146 enum {
147 COL_VARIANT_NAME,
148 COL_VARIANT_DEFAULT,
149 COL_VARIANT_COUNT
152 enum {
153 COL_SOUND_ENABLED,
154 COL_SOUND_NAME,
155 COL_SOUND_KEY,
156 COL_SOUND_COUNT
159 typedef struct {
160 const char *name;
161 const char *key;
162 } SoundEventEntry;
164 /* TODO: add phone related sounds also? */
165 static SoundEventEntry sound_entries [] = {
166 { N_("Message received"), EMPATHY_PREFS_SOUNDS_INCOMING_MESSAGE },
167 { N_("Message sent"), EMPATHY_PREFS_SOUNDS_OUTGOING_MESSAGE },
168 { N_("New conversation"), EMPATHY_PREFS_SOUNDS_NEW_CONVERSATION },
169 { N_("Contact comes online"), EMPATHY_PREFS_SOUNDS_CONTACT_LOGIN },
170 { N_("Contact goes offline"), EMPATHY_PREFS_SOUNDS_CONTACT_LOGOUT },
171 { N_("Account connected"), EMPATHY_PREFS_SOUNDS_SERVICE_LOGIN },
172 { N_("Account disconnected"), EMPATHY_PREFS_SOUNDS_SERVICE_LOGOUT }
175 static void
176 preferences_setup_widgets (EmpathyPreferences *preferences)
178 EmpathyPreferencesPriv *priv = GET_PRIV (preferences);
180 g_settings_bind (priv->gsettings_notify,
181 EMPATHY_PREFS_NOTIFICATIONS_ENABLED,
182 priv->checkbutton_notifications_enabled,
183 "active",
184 G_SETTINGS_BIND_DEFAULT);
185 g_settings_bind (priv->gsettings_notify,
186 EMPATHY_PREFS_NOTIFICATIONS_DISABLED_AWAY,
187 priv->checkbutton_notifications_disabled_away,
188 "active",
189 G_SETTINGS_BIND_DEFAULT);
190 g_settings_bind (priv->gsettings_notify,
191 EMPATHY_PREFS_NOTIFICATIONS_FOCUS,
192 priv->checkbutton_notifications_focus,
193 "active",
194 G_SETTINGS_BIND_DEFAULT);
195 g_settings_bind (priv->gsettings_notify,
196 EMPATHY_PREFS_NOTIFICATIONS_CONTACT_SIGNIN,
197 priv->checkbutton_notifications_contact_signin,
198 "active",
199 G_SETTINGS_BIND_DEFAULT);
200 g_settings_bind (priv->gsettings_notify,
201 EMPATHY_PREFS_NOTIFICATIONS_CONTACT_SIGNOUT,
202 priv->checkbutton_notifications_contact_signout,
203 "active",
204 G_SETTINGS_BIND_DEFAULT);
206 g_settings_bind (priv->gsettings_notify,
207 EMPATHY_PREFS_NOTIFICATIONS_ENABLED,
208 priv->checkbutton_notifications_disabled_away,
209 "sensitive",
210 G_SETTINGS_BIND_GET);
211 g_settings_bind (priv->gsettings_notify,
212 EMPATHY_PREFS_NOTIFICATIONS_ENABLED,
213 priv->checkbutton_notifications_focus,
214 "sensitive",
215 G_SETTINGS_BIND_GET);
216 g_settings_bind (priv->gsettings_notify,
217 EMPATHY_PREFS_NOTIFICATIONS_ENABLED,
218 priv->checkbutton_notifications_contact_signin,
219 "sensitive",
220 G_SETTINGS_BIND_GET);
221 g_settings_bind (priv->gsettings_notify,
222 EMPATHY_PREFS_NOTIFICATIONS_ENABLED,
223 priv->checkbutton_notifications_contact_signout,
224 "sensitive",
225 G_SETTINGS_BIND_GET);
227 g_settings_bind (priv->gsettings_sound,
228 EMPATHY_PREFS_SOUNDS_ENABLED,
229 priv->checkbutton_sounds_enabled,
230 "active",
231 G_SETTINGS_BIND_DEFAULT);
232 g_settings_bind (priv->gsettings_sound,
233 EMPATHY_PREFS_SOUNDS_DISABLED_AWAY,
234 priv->checkbutton_sounds_disabled_away,
235 "active",
236 G_SETTINGS_BIND_DEFAULT);
238 g_settings_bind (priv->gsettings_sound,
239 EMPATHY_PREFS_SOUNDS_ENABLED,
240 priv->checkbutton_sounds_disabled_away,
241 "sensitive",
242 G_SETTINGS_BIND_GET);
243 g_settings_bind (priv->gsettings_sound,
244 EMPATHY_PREFS_SOUNDS_ENABLED,
245 priv->treeview_sounds,
246 "sensitive",
247 G_SETTINGS_BIND_GET);
249 g_settings_bind (priv->gsettings_ui,
250 EMPATHY_PREFS_UI_SEPARATE_CHAT_WINDOWS,
251 priv->radiobutton_chats_new_windows,
252 "active",
253 G_SETTINGS_BIND_DEFAULT);
255 g_settings_bind (priv->gsettings_ui,
256 EMPATHY_PREFS_UI_EVENTS_NOTIFY_AREA,
257 priv->checkbutton_events_notif_area,
258 "active",
259 G_SETTINGS_BIND_DEFAULT);
261 g_settings_bind (priv->gsettings_chat,
262 EMPATHY_PREFS_CHAT_SHOW_SMILEYS,
263 priv->checkbutton_show_smileys,
264 "active",
265 G_SETTINGS_BIND_DEFAULT);
266 g_settings_bind (priv->gsettings_chat,
267 EMPATHY_PREFS_CHAT_SHOW_CONTACTS_IN_ROOMS,
268 priv->checkbutton_show_contacts_in_rooms,
269 "active",
270 G_SETTINGS_BIND_DEFAULT);
272 g_settings_bind (priv->gsettings_call,
273 EMPATHY_PREFS_CALL_ECHO_CANCELLATION,
274 priv->echo_cancellation,
275 "active",
276 G_SETTINGS_BIND_DEFAULT);
278 g_settings_bind (priv->gsettings,
279 EMPATHY_PREFS_AUTOCONNECT,
280 priv->checkbutton_autoconnect,
281 "active",
282 G_SETTINGS_BIND_DEFAULT);
284 g_settings_bind (priv->gsettings_loc,
285 EMPATHY_PREFS_LOCATION_PUBLISH,
286 priv->checkbutton_location_publish,
287 "active",
288 G_SETTINGS_BIND_DEFAULT);
290 g_settings_bind (priv->gsettings_loc,
291 EMPATHY_PREFS_LOCATION_RESOURCE_NETWORK,
292 priv->checkbutton_location_resource_network,
293 "active",
294 G_SETTINGS_BIND_DEFAULT);
295 g_settings_bind (priv->gsettings_loc,
296 EMPATHY_PREFS_LOCATION_PUBLISH,
297 priv->checkbutton_location_resource_network,
298 "sensitive",
299 G_SETTINGS_BIND_GET);
301 g_settings_bind (priv->gsettings_loc,
302 EMPATHY_PREFS_LOCATION_RESOURCE_CELL,
303 priv->checkbutton_location_resource_cell,
304 "active",
305 G_SETTINGS_BIND_DEFAULT);
306 g_settings_bind (priv->gsettings_loc,
307 EMPATHY_PREFS_LOCATION_PUBLISH,
308 priv->checkbutton_location_resource_cell,
309 "sensitive",
310 G_SETTINGS_BIND_GET);
312 g_settings_bind (priv->gsettings_loc,
313 EMPATHY_PREFS_LOCATION_RESOURCE_GPS,
314 priv->checkbutton_location_resource_gps,
315 "active",
316 G_SETTINGS_BIND_DEFAULT);
317 g_settings_bind (priv->gsettings_loc,
318 EMPATHY_PREFS_LOCATION_PUBLISH,
319 priv->checkbutton_location_resource_gps,
320 "sensitive",
321 G_SETTINGS_BIND_GET);
323 g_settings_bind (priv->gsettings_loc,
324 EMPATHY_PREFS_LOCATION_REDUCE_ACCURACY,
325 priv->checkbutton_location_reduce_accuracy,
326 "active",
327 G_SETTINGS_BIND_DEFAULT);
328 g_settings_bind (priv->gsettings_loc,
329 EMPATHY_PREFS_LOCATION_PUBLISH,
330 priv->checkbutton_location_reduce_accuracy,
331 "sensitive",
332 G_SETTINGS_BIND_GET);
334 g_settings_bind (priv->gsettings_logger,
335 EMPATHY_PREFS_LOGGER_ENABLED,
336 priv->checkbutton_logging,
337 "active",
338 G_SETTINGS_BIND_DEFAULT);
341 static void
342 preferences_sound_cell_toggled_cb (GtkCellRendererToggle *toggle,
343 char *path_string,
344 EmpathyPreferences *preferences)
346 EmpathyPreferencesPriv *priv = GET_PRIV (preferences);
347 GtkTreePath *path;
348 gboolean instore;
349 GtkTreeIter iter;
350 GtkTreeView *view;
351 GtkTreeModel *model;
352 char *key;
354 view = GTK_TREE_VIEW (priv->treeview_sounds);
355 model = gtk_tree_view_get_model (view);
357 path = gtk_tree_path_new_from_string (path_string);
359 gtk_tree_model_get_iter (model, &iter, path);
360 gtk_tree_model_get (model, &iter, COL_SOUND_KEY, &key,
361 COL_SOUND_ENABLED, &instore, -1);
363 instore ^= 1;
365 gtk_list_store_set (GTK_LIST_STORE (model), &iter,
366 COL_SOUND_ENABLED, instore, -1);
368 g_settings_set_boolean (priv->gsettings_sound, key, instore);
370 g_free (key);
371 gtk_tree_path_free (path);
374 static void
375 preferences_sound_load (EmpathyPreferences *preferences)
377 EmpathyPreferencesPriv *priv = GET_PRIV (preferences);
378 guint i;
379 GtkTreeView *view;
380 GtkListStore *store;
381 GtkTreeIter iter;
382 gboolean set;
384 view = GTK_TREE_VIEW (priv->treeview_sounds);
385 store = GTK_LIST_STORE (gtk_tree_view_get_model (view));
387 for (i = 0; i < G_N_ELEMENTS (sound_entries); i++) {
388 set = g_settings_get_boolean (priv->gsettings_sound,
389 sound_entries[i].key);
391 gtk_list_store_insert_with_values (store, &iter, i,
392 COL_SOUND_NAME, gettext (sound_entries[i].name),
393 COL_SOUND_KEY, sound_entries[i].key,
394 COL_SOUND_ENABLED, set, -1);
398 static void
399 preferences_sound_setup (EmpathyPreferences *preferences)
401 EmpathyPreferencesPriv *priv = GET_PRIV (preferences);
402 GtkTreeView *view;
403 GtkListStore *store;
404 GtkCellRenderer *renderer;
405 GtkTreeViewColumn *column;
407 view = GTK_TREE_VIEW (priv->treeview_sounds);
409 store = gtk_list_store_new (COL_SOUND_COUNT,
410 G_TYPE_BOOLEAN, /* enabled */
411 G_TYPE_STRING, /* name */
412 G_TYPE_STRING); /* key */
414 gtk_tree_view_set_model (view, GTK_TREE_MODEL (store));
416 renderer = gtk_cell_renderer_toggle_new ();
417 g_signal_connect (renderer, "toggled",
418 G_CALLBACK (preferences_sound_cell_toggled_cb),
419 preferences);
421 column = gtk_tree_view_column_new ();
422 gtk_tree_view_column_pack_start (column, renderer, FALSE);
423 gtk_tree_view_column_add_attribute (column, renderer,
424 "active", COL_SOUND_ENABLED);
426 renderer = gtk_cell_renderer_text_new ();
427 gtk_tree_view_column_pack_start (column, renderer, FALSE);
428 gtk_tree_view_column_add_attribute (column, renderer,
429 "text", COL_SOUND_NAME);
431 gtk_tree_view_append_column (view, column);
433 gtk_tree_view_column_set_resizable (column, FALSE);
434 gtk_tree_view_column_set_clickable (GTK_TREE_VIEW_COLUMN (column), TRUE);
436 g_object_unref (store);
439 static void
440 preferences_languages_setup (EmpathyPreferences *preferences)
442 EmpathyPreferencesPriv *priv = GET_PRIV (preferences);
443 GtkTreeView *view;
444 GtkListStore *store;
445 GtkTreeSelection *selection;
446 GtkTreeViewColumn *column;
447 GtkCellRenderer *renderer;
448 guint col_offset;
450 view = GTK_TREE_VIEW (priv->treeview_spell_checker);
452 store = gtk_list_store_new (COL_LANG_COUNT,
453 G_TYPE_BOOLEAN, /* enabled */
454 G_TYPE_STRING, /* code */
455 G_TYPE_STRING); /* name */
457 gtk_tree_view_set_model (view, GTK_TREE_MODEL (store));
459 selection = gtk_tree_view_get_selection (view);
460 gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
462 renderer = gtk_cell_renderer_toggle_new ();
463 g_signal_connect (renderer, "toggled",
464 G_CALLBACK (preferences_languages_cell_toggled_cb),
465 preferences);
467 column = gtk_tree_view_column_new_with_attributes (NULL, renderer,
468 "active", COL_LANG_ENABLED,
469 NULL);
471 gtk_tree_view_append_column (view, column);
473 renderer = gtk_cell_renderer_text_new ();
474 col_offset = gtk_tree_view_insert_column_with_attributes (view,
475 -1, _("Language"),
476 renderer,
477 "text", COL_LANG_NAME,
478 NULL);
480 g_object_set_data (G_OBJECT (renderer),
481 "column", GINT_TO_POINTER (COL_LANG_NAME));
483 column = gtk_tree_view_get_column (view, col_offset - 1);
484 gtk_tree_view_column_set_sort_column_id (column, COL_LANG_NAME);
485 gtk_tree_view_column_set_resizable (column, FALSE);
486 gtk_tree_view_column_set_clickable (GTK_TREE_VIEW_COLUMN (column), TRUE);
488 g_object_unref (store);
491 static void
492 preferences_languages_add (EmpathyPreferences *preferences)
494 EmpathyPreferencesPriv *priv = GET_PRIV (preferences);
495 GtkTreeView *view;
496 GtkListStore *store;
497 GList *codes, *l;
499 view = GTK_TREE_VIEW (priv->treeview_spell_checker);
500 store = GTK_LIST_STORE (gtk_tree_view_get_model (view));
502 codes = empathy_spell_get_language_codes ();
504 if (!codes) {
505 gtk_widget_set_sensitive (priv->treeview_spell_checker, FALSE);
508 for (l = codes; l; l = l->next) {
509 GtkTreeIter iter;
510 const gchar *code;
511 const gchar *name;
513 code = l->data;
514 name = empathy_spell_get_language_name (code);
515 if (!name) {
516 continue;
519 gtk_list_store_append (store, &iter);
520 gtk_list_store_set (store, &iter,
521 COL_LANG_CODE, code,
522 COL_LANG_NAME, name,
523 -1);
526 empathy_spell_free_language_codes (codes);
529 static void
530 preferences_languages_save (EmpathyPreferences *preferences)
532 EmpathyPreferencesPriv *priv = GET_PRIV (preferences);
533 GtkTreeView *view;
534 GtkTreeModel *model;
536 gchar *languages = NULL;
538 view = GTK_TREE_VIEW (priv->treeview_spell_checker);
539 model = gtk_tree_view_get_model (view);
541 gtk_tree_model_foreach (model,
542 (GtkTreeModelForeachFunc) preferences_languages_save_foreach,
543 &languages);
545 /* if user selects no languages, we don't want spell check */
546 g_settings_set_boolean (priv->gsettings_chat,
547 EMPATHY_PREFS_CHAT_SPELL_CHECKER_ENABLED,
548 languages != NULL);
550 g_settings_set_string (priv->gsettings_chat,
551 EMPATHY_PREFS_CHAT_SPELL_CHECKER_LANGUAGES,
552 languages != NULL ? languages : "");
554 g_free (languages);
557 static gboolean
558 preferences_languages_save_foreach (GtkTreeModel *model,
559 GtkTreePath *path,
560 GtkTreeIter *iter,
561 gchar **languages)
563 gboolean enabled;
564 gchar *code;
566 if (!languages) {
567 return TRUE;
570 gtk_tree_model_get (model, iter, COL_LANG_ENABLED, &enabled, -1);
571 if (!enabled) {
572 return FALSE;
575 gtk_tree_model_get (model, iter, COL_LANG_CODE, &code, -1);
576 if (!code) {
577 return FALSE;
580 if (!(*languages)) {
581 *languages = g_strdup (code);
582 } else {
583 gchar *str = *languages;
584 *languages = g_strdup_printf ("%s,%s", str, code);
585 g_free (str);
588 g_free (code);
590 return FALSE;
593 static void
594 preferences_languages_load (EmpathyPreferences *preferences)
596 EmpathyPreferencesPriv *priv = GET_PRIV (preferences);
597 GtkTreeView *view;
598 GtkTreeModel *model;
599 GList *enabled_codes;
601 enabled_codes = empathy_spell_get_enabled_language_codes ();
603 g_settings_set_boolean (priv->gsettings_chat,
604 EMPATHY_PREFS_CHAT_SPELL_CHECKER_ENABLED,
605 enabled_codes != NULL);
607 if (enabled_codes == NULL)
608 return;
610 view = GTK_TREE_VIEW (priv->treeview_spell_checker);
611 model = gtk_tree_view_get_model (view);
613 gtk_tree_model_foreach (model,
614 (GtkTreeModelForeachFunc) preferences_languages_load_foreach,
615 enabled_codes);
617 g_list_free (enabled_codes);
620 static gboolean
621 preferences_languages_load_foreach (GtkTreeModel *model,
622 GtkTreePath *path,
623 GtkTreeIter *iter,
624 GList *languages)
626 gchar *code;
627 gboolean found = FALSE;
629 if (!languages) {
630 return TRUE;
633 gtk_tree_model_get (model, iter, COL_LANG_CODE, &code, -1);
634 if (!code) {
635 return FALSE;
638 if (g_list_find_custom (languages, code, (GCompareFunc) strcmp)) {
639 found = TRUE;
642 g_free (code);
643 gtk_list_store_set (GTK_LIST_STORE (model), iter, COL_LANG_ENABLED, found, -1);
644 return FALSE;
647 static void
648 preferences_languages_cell_toggled_cb (GtkCellRendererToggle *cell,
649 gchar *path_string,
650 EmpathyPreferences *preferences)
652 EmpathyPreferencesPriv *priv = GET_PRIV (preferences);
653 GtkTreeView *view;
654 GtkTreeModel *model;
655 GtkListStore *store;
656 GtkTreePath *path;
657 GtkTreeIter iter;
658 gboolean enabled;
660 view = GTK_TREE_VIEW (priv->treeview_spell_checker);
661 model = gtk_tree_view_get_model (view);
662 store = GTK_LIST_STORE (model);
664 path = gtk_tree_path_new_from_string (path_string);
666 gtk_tree_model_get_iter (model, &iter, path);
667 gtk_tree_model_get (model, &iter, COL_LANG_ENABLED, &enabled, -1);
669 enabled ^= 1;
671 gtk_list_store_set (store, &iter, COL_LANG_ENABLED, enabled, -1);
672 gtk_tree_path_free (path);
674 preferences_languages_save (preferences);
677 static void
678 preferences_preview_theme_append_message (EmpathyChatView *view,
679 EmpathyContact *sender,
680 EmpathyContact *receiver,
681 const gchar *text,
682 gboolean should_highlight)
684 EmpathyMessage *message;
686 message = g_object_new (EMPATHY_TYPE_MESSAGE,
687 "sender", sender,
688 "receiver", receiver,
689 "body", text,
690 NULL);
692 empathy_chat_view_append_message (view, message, should_highlight);
693 g_object_unref (message);
696 static void
697 preferences_preview_theme_changed_cb (EmpathyThemeManager *manager,
698 EmpathyPreferences *preferences)
700 EmpathyPreferencesPriv *priv = GET_PRIV (preferences);
701 TpDBusDaemon *dbus;
702 TpAccount *account;
703 EmpathyContact *juliet;
704 EmpathyContact *romeo;
706 DEBUG ("Theme changed, update preview widget");
708 if (priv->chat_theme_preview != NULL) {
709 gtk_widget_destroy (GTK_WIDGET (priv->chat_theme_preview));
711 priv->chat_theme_preview = empathy_theme_manager_create_view (manager);
712 gtk_container_add (GTK_CONTAINER (priv->sw_chat_theme_preview),
713 GTK_WIDGET (priv->chat_theme_preview));
714 gtk_widget_show (GTK_WIDGET (priv->chat_theme_preview));
716 /* FIXME: It is ugly to add a fake conversation like that.
717 * Would be cool if we could request a TplLogManager for a fake
718 * conversation */
719 dbus = tp_dbus_daemon_dup (NULL);
720 account = tp_account_new (dbus,
721 TP_ACCOUNT_OBJECT_PATH_BASE "cm/jabber/account", NULL);
722 juliet = g_object_new (EMPATHY_TYPE_CONTACT,
723 "account", account,
724 "id", "juliet",
725 /* translators: Contact name for the chat theme preview */
726 "alias", _("Juliet"),
727 "is-user", FALSE,
728 NULL);
729 romeo = g_object_new (EMPATHY_TYPE_CONTACT,
730 "account", account,
731 "id", "romeo",
732 /* translators: Contact name for the chat theme preview */
733 "alias", _("Romeo"),
734 "is-user", TRUE,
735 NULL);
737 preferences_preview_theme_append_message (priv->chat_theme_preview,
738 /* translators: Quote from Romeo & Julier, for chat theme preview */
739 juliet, romeo, _("O Romeo, Romeo, wherefore art thou Romeo?"),
740 TRUE /* this message mentions Romeo */);
741 preferences_preview_theme_append_message (priv->chat_theme_preview,
742 /* translators: Quote from Romeo & Julier, for chat theme preview */
743 juliet, romeo, _("Deny thy father and refuse thy name;"), FALSE);
744 preferences_preview_theme_append_message (priv->chat_theme_preview,
745 /* translators: Quote from Romeo & Julier, for chat theme preview */
746 juliet, romeo, _("Or if thou wilt not, be but sworn my love"), FALSE);
747 preferences_preview_theme_append_message (priv->chat_theme_preview,
748 /* translators: Quote from Romeo & Julier, for chat theme preview */
749 juliet, romeo, _("And I'll no longer be a Capulet."), FALSE);
750 preferences_preview_theme_append_message (priv->chat_theme_preview,
751 /* translators: Quote from Romeo & Julier, for chat theme preview */
752 romeo, juliet, _("Shall I hear more, or shall I speak at this?"), FALSE);
754 /* translators: Quote from Romeo & Julier, for chat theme preview */
755 empathy_chat_view_append_event (priv->chat_theme_preview, _("Juliet has disconnected"));
757 g_object_unref (juliet);
758 g_object_unref (romeo);
759 g_object_unref (account);
760 g_object_unref (dbus);
763 static void
764 preferences_theme_variant_changed_cb (GtkComboBox *combo,
765 EmpathyPreferences *preferences)
767 EmpathyPreferencesPriv *priv = GET_PRIV (preferences);
768 GtkTreeIter iter;
770 if (gtk_combo_box_get_active_iter (combo, &iter)) {
771 GtkTreeModel *model;
772 gchar *name;
774 model = gtk_combo_box_get_model (combo);
775 gtk_tree_model_get (model, &iter,
776 COL_VARIANT_NAME, &name,
777 -1);
779 g_settings_set_string (priv->gsettings_chat,
780 EMPATHY_PREFS_CHAT_THEME_VARIANT,
781 name);
783 g_free (name);
787 static void
788 preferences_theme_variant_notify_cb (GSettings *gsettings,
789 const gchar *key,
790 gpointer user_data)
792 EmpathyPreferences *preferences = user_data;
793 EmpathyPreferencesPriv *priv = GET_PRIV (preferences);
794 GtkComboBox *combo;
795 gchar *conf_name;
796 GtkTreeModel *model;
797 GtkTreeIter iter;
798 GtkTreeIter default_iter;
799 gboolean found_default = FALSE;
800 gboolean found = FALSE;
801 gboolean ok;
803 conf_name = g_settings_get_string (gsettings, EMPATHY_PREFS_CHAT_THEME_VARIANT);
804 combo = GTK_COMBO_BOX (priv->combobox_chat_theme_variant);
805 model = gtk_combo_box_get_model (combo);
807 for (ok = gtk_tree_model_get_iter_first (model, &iter);
808 ok && !found;
809 ok = gtk_tree_model_iter_next (model, &iter)) {
810 gchar *name;
811 gboolean is_default;
813 gtk_tree_model_get (model, &iter,
814 COL_VARIANT_NAME, &name,
815 COL_VARIANT_DEFAULT, &is_default,
816 -1);
818 if (!tp_strdiff (name, conf_name)) {
819 found = TRUE;
820 gtk_combo_box_set_active_iter (combo, &iter);
822 if (is_default) {
823 found_default = TRUE;
824 default_iter = iter;
827 g_free (name);
830 /* Fallback to the first one. */
831 if (!found) {
832 if (found_default) {
833 gtk_combo_box_set_active_iter (combo, &default_iter);
834 } else if (gtk_tree_model_get_iter_first (model, &iter)) {
835 gtk_combo_box_set_active_iter (combo, &iter);
839 g_free (conf_name);
842 /* return TRUE if we added at least one variant */
843 static gboolean
844 preferences_theme_variants_fill (EmpathyPreferences *preferences,
845 GHashTable *info)
847 EmpathyPreferencesPriv *priv = GET_PRIV (preferences);
848 GtkTreeModel *model;
849 GtkListStore *store;
850 GPtrArray *variants;
851 const gchar *default_variant;
852 guint i;
853 gboolean result = FALSE;
855 model = gtk_combo_box_get_model (GTK_COMBO_BOX (priv->combobox_chat_theme_variant));
856 store = GTK_LIST_STORE (model);
857 gtk_list_store_clear (store);
859 variants = empathy_adium_info_get_available_variants (info);
860 default_variant = empathy_adium_info_get_default_variant (info);
861 for (i = 0; i < variants->len; i++) {
862 gchar *name = g_ptr_array_index (variants, i);
864 gtk_list_store_insert_with_values (store, NULL, -1,
865 COL_VARIANT_NAME, name,
866 COL_VARIANT_DEFAULT, !tp_strdiff (name, default_variant),
867 -1);
869 result = TRUE;
872 /* Select the variant from the GSetting key */
873 preferences_theme_variant_notify_cb (priv->gsettings_chat,
874 EMPATHY_PREFS_CHAT_THEME_VARIANT,
875 preferences);
877 return result;
880 static void
881 preferences_theme_variants_setup (EmpathyPreferences *preferences)
883 EmpathyPreferencesPriv *priv = GET_PRIV (preferences);
884 GtkComboBox *combo;
885 GtkCellLayout *cell_layout;
886 GtkCellRenderer *renderer;
887 GtkListStore *store;
889 combo = GTK_COMBO_BOX (priv->combobox_chat_theme_variant);
890 cell_layout = GTK_CELL_LAYOUT (combo);
892 /* Create the model */
893 store = gtk_list_store_new (COL_VARIANT_COUNT,
894 G_TYPE_STRING, /* name */
895 G_TYPE_BOOLEAN); /* is default */
896 gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store),
897 COL_VARIANT_NAME, GTK_SORT_ASCENDING);
899 /* Add cell renderer */
900 renderer = gtk_cell_renderer_text_new ();
901 gtk_cell_layout_pack_start (cell_layout, renderer, TRUE);
902 gtk_cell_layout_set_attributes (cell_layout, renderer,
903 "text", COL_VARIANT_NAME, NULL);
905 gtk_combo_box_set_model (combo, GTK_TREE_MODEL (store));
906 g_object_unref (store);
908 g_signal_connect (combo, "changed",
909 G_CALLBACK (preferences_theme_variant_changed_cb),
910 preferences);
912 /* Track changes of the GSetting key */
913 g_signal_connect (priv->gsettings_chat,
914 "changed::" EMPATHY_PREFS_CHAT_THEME_VARIANT,
915 G_CALLBACK (preferences_theme_variant_notify_cb),
916 preferences);
919 static void
920 preferences_theme_changed_cb (GtkComboBox *combo,
921 EmpathyPreferences *preferences)
923 EmpathyPreferencesPriv *priv = GET_PRIV (preferences);
924 GtkTreeIter iter;
926 if (gtk_combo_box_get_active_iter (combo, &iter)) {
927 GtkTreeModel *model;
928 gboolean is_adium;
929 gchar *name;
930 gchar *path;
931 GHashTable *info;
933 model = gtk_combo_box_get_model (combo);
934 gtk_tree_model_get (model, &iter,
935 COL_THEME_IS_ADIUM, &is_adium,
936 COL_THEME_NAME, &name,
937 COL_THEME_ADIUM_PATH, &path,
938 COL_THEME_ADIUM_INFO, &info,
939 -1);
941 g_settings_set_string (priv->gsettings_chat,
942 EMPATHY_PREFS_CHAT_THEME,
943 name);
944 if (is_adium) {
945 gboolean variant;
947 g_settings_set_string (priv->gsettings_chat,
948 EMPATHY_PREFS_CHAT_ADIUM_PATH,
949 path);
951 variant = preferences_theme_variants_fill (preferences, info);
952 gtk_widget_set_visible (priv->hbox_chat_theme_variant, variant);
953 } else {
954 gtk_widget_hide (priv->hbox_chat_theme_variant);
956 g_free (name);
957 g_free (path);
958 tp_clear_pointer (&info, g_hash_table_unref);
962 static void
963 preferences_theme_notify_cb (GSettings *gsettings,
964 const gchar *key,
965 gpointer user_data)
967 EmpathyPreferences *preferences = user_data;
968 EmpathyPreferencesPriv *priv = GET_PRIV (preferences);
969 GtkComboBox *combo;
970 gchar *conf_name;
971 gchar *conf_path;
972 GtkTreeModel *model;
973 GtkTreeIter iter;
974 gboolean found = FALSE;
975 gboolean ok;
977 conf_name = g_settings_get_string (gsettings, EMPATHY_PREFS_CHAT_THEME);
978 conf_path = g_settings_get_string (gsettings, EMPATHY_PREFS_CHAT_ADIUM_PATH);
980 combo = GTK_COMBO_BOX (priv->combobox_chat_theme);
981 model = gtk_combo_box_get_model (combo);
982 for (ok = gtk_tree_model_get_iter_first (model, &iter);
983 ok && !found;
984 ok = gtk_tree_model_iter_next (model, &iter)) {
985 gboolean is_adium;
986 gchar *name;
987 gchar *path;
989 gtk_tree_model_get (model, &iter,
990 COL_THEME_IS_ADIUM, &is_adium,
991 COL_THEME_NAME, &name,
992 COL_THEME_ADIUM_PATH, &path,
993 -1);
995 if (!tp_strdiff (name, conf_name) &&
996 (!is_adium || !tp_strdiff (path, conf_path))) {
997 found = TRUE;
998 gtk_combo_box_set_active_iter (combo, &iter);
1001 g_free (name);
1002 g_free (path);
1005 /* Fallback to the first one. */
1006 if (!found) {
1007 if (gtk_tree_model_get_iter_first (model, &iter)) {
1008 gtk_combo_box_set_active_iter (combo, &iter);
1012 g_free (conf_name);
1013 g_free (conf_path);
1016 static void
1017 preferences_themes_setup (EmpathyPreferences *preferences)
1019 EmpathyPreferencesPriv *priv = GET_PRIV (preferences);
1020 GtkComboBox *combo;
1021 GtkCellLayout *cell_layout;
1022 GtkCellRenderer *renderer;
1023 GtkListStore *store;
1024 const gchar **themes;
1025 GList *adium_themes;
1026 gint i;
1028 preferences_theme_variants_setup (preferences);
1030 combo = GTK_COMBO_BOX (priv->combobox_chat_theme);
1031 cell_layout = GTK_CELL_LAYOUT (combo);
1033 /* Create the model */
1034 store = gtk_list_store_new (COL_THEME_COUNT,
1035 G_TYPE_STRING, /* Display name */
1036 G_TYPE_STRING, /* Theme name */
1037 G_TYPE_BOOLEAN, /* Is an Adium theme */
1038 G_TYPE_STRING, /* Adium theme path */
1039 G_TYPE_HASH_TABLE); /* Adium theme info */
1040 gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store),
1041 COL_THEME_VISIBLE_NAME, GTK_SORT_ASCENDING);
1043 /* Fill the model */
1044 themes = empathy_theme_manager_get_themes ();
1045 for (i = 0; themes[i]; i += 2) {
1046 gtk_list_store_insert_with_values (store, NULL, -1,
1047 COL_THEME_VISIBLE_NAME, _(themes[i + 1]),
1048 COL_THEME_NAME, themes[i],
1049 COL_THEME_IS_ADIUM, FALSE,
1050 -1);
1053 adium_themes = empathy_theme_manager_get_adium_themes ();
1054 while (adium_themes != NULL) {
1055 GHashTable *info;
1056 const gchar *name;
1057 const gchar *path;
1059 info = adium_themes->data;
1060 name = tp_asv_get_string (info, "CFBundleName");
1061 path = tp_asv_get_string (info, "path");
1063 if (name != NULL && path != NULL) {
1064 gtk_list_store_insert_with_values (store, NULL, -1,
1065 COL_THEME_VISIBLE_NAME, name,
1066 COL_THEME_NAME, "adium",
1067 COL_THEME_IS_ADIUM, TRUE,
1068 COL_THEME_ADIUM_PATH, path,
1069 COL_THEME_ADIUM_INFO, info,
1070 -1);
1072 g_hash_table_unref (info);
1073 adium_themes = g_list_delete_link (adium_themes, adium_themes);
1076 /* Add cell renderer */
1077 renderer = gtk_cell_renderer_text_new ();
1078 gtk_cell_layout_pack_start (cell_layout, renderer, TRUE);
1079 gtk_cell_layout_set_attributes (cell_layout, renderer,
1080 "text", COL_THEME_VISIBLE_NAME, NULL);
1082 gtk_combo_box_set_model (combo, GTK_TREE_MODEL (store));
1083 g_object_unref (store);
1085 g_signal_connect (combo, "changed",
1086 G_CALLBACK (preferences_theme_changed_cb),
1087 preferences);
1089 /* Select the theme from the GSetting key and track changes */
1090 preferences_theme_notify_cb (priv->gsettings_chat,
1091 EMPATHY_PREFS_CHAT_THEME,
1092 preferences);
1093 g_signal_connect (priv->gsettings_chat,
1094 "changed::" EMPATHY_PREFS_CHAT_THEME,
1095 G_CALLBACK (preferences_theme_notify_cb),
1096 preferences);
1098 g_signal_connect (priv->gsettings_chat,
1099 "changed::" EMPATHY_PREFS_CHAT_ADIUM_PATH,
1100 G_CALLBACK (preferences_theme_notify_cb),
1101 preferences);
1104 static void
1105 empathy_preferences_response (GtkDialog *widget,
1106 gint response)
1108 gtk_widget_destroy (GTK_WIDGET (widget));
1111 static void
1112 empathy_preferences_finalize (GObject *self)
1114 EmpathyPreferencesPriv *priv = GET_PRIV (self);
1116 g_object_unref (priv->theme_manager);
1118 g_object_unref (priv->gsettings);
1119 g_object_unref (priv->gsettings_chat);
1120 g_object_unref (priv->gsettings_call);
1121 g_object_unref (priv->gsettings_loc);
1122 g_object_unref (priv->gsettings_notify);
1123 g_object_unref (priv->gsettings_sound);
1124 g_object_unref (priv->gsettings_ui);
1125 g_object_unref (priv->gsettings_logger);
1127 G_OBJECT_CLASS (empathy_preferences_parent_class)->finalize (self);
1130 static void
1131 empathy_preferences_class_init (EmpathyPreferencesClass *klass)
1133 GtkDialogClass *dialog_class = GTK_DIALOG_CLASS (klass);
1134 GObjectClass *object_class = G_OBJECT_CLASS (klass);
1136 dialog_class->response = empathy_preferences_response;
1138 object_class->finalize = empathy_preferences_finalize;
1140 g_type_class_add_private (object_class,
1141 sizeof (EmpathyPreferencesPriv));
1144 static void
1145 empathy_preferences_init (EmpathyPreferences *preferences)
1147 EmpathyPreferencesPriv *priv;
1148 GtkBuilder *gui;
1149 gchar *filename;
1150 GtkWidget *page;
1152 priv = preferences->priv = G_TYPE_INSTANCE_GET_PRIVATE (preferences,
1153 EMPATHY_TYPE_PREFERENCES, EmpathyPreferencesPriv);
1155 gtk_dialog_add_button (GTK_DIALOG (preferences),
1156 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
1158 gtk_container_set_border_width (GTK_CONTAINER (preferences), 5);
1159 gtk_window_set_title (GTK_WINDOW (preferences), _("Preferences"));
1160 gtk_window_set_role (GTK_WINDOW (preferences), "preferences");
1161 gtk_window_set_position (GTK_WINDOW (preferences),
1162 GTK_WIN_POS_CENTER_ON_PARENT);
1163 gtk_window_set_icon_name (GTK_WINDOW (preferences), "gtk-preferences");
1165 filename = empathy_file_lookup ("empathy-preferences.ui", "src");
1166 gui = empathy_builder_get_file (filename,
1167 "notebook", &priv->notebook,
1168 "checkbutton_show_smileys", &priv->checkbutton_show_smileys,
1169 "checkbutton_show_contacts_in_rooms", &priv->checkbutton_show_contacts_in_rooms,
1170 "vbox_chat_theme", &priv->vbox_chat_theme,
1171 "combobox_chat_theme", &priv->combobox_chat_theme,
1172 "combobox_chat_theme_variant", &priv->combobox_chat_theme_variant,
1173 "hbox_chat_theme_variant", &priv->hbox_chat_theme_variant,
1174 "sw_chat_theme_preview", &priv->sw_chat_theme_preview,
1175 "radiobutton_chats_new_windows", &priv->radiobutton_chats_new_windows,
1176 "checkbutton_events_notif_area", &priv->checkbutton_events_notif_area,
1177 "checkbutton_autoconnect", &priv->checkbutton_autoconnect,
1178 "checkbutton_logging", &priv->checkbutton_logging,
1179 "checkbutton_notifications_enabled", &priv->checkbutton_notifications_enabled,
1180 "checkbutton_notifications_disabled_away", &priv->checkbutton_notifications_disabled_away,
1181 "checkbutton_notifications_focus", &priv->checkbutton_notifications_focus,
1182 "checkbutton_notifications_contact_signin", &priv->checkbutton_notifications_contact_signin,
1183 "checkbutton_notifications_contact_signout", &priv->checkbutton_notifications_contact_signout,
1184 "checkbutton_sounds_enabled", &priv->checkbutton_sounds_enabled,
1185 "checkbutton_sounds_disabled_away", &priv->checkbutton_sounds_disabled_away,
1186 "treeview_sounds", &priv->treeview_sounds,
1187 "treeview_spell_checker", &priv->treeview_spell_checker,
1188 "checkbutton_location_publish", &priv->checkbutton_location_publish,
1189 "checkbutton_location_reduce_accuracy", &priv->checkbutton_location_reduce_accuracy,
1190 "checkbutton_location_resource_network", &priv->checkbutton_location_resource_network,
1191 "checkbutton_location_resource_cell", &priv->checkbutton_location_resource_cell,
1192 "checkbutton_location_resource_gps", &priv->checkbutton_location_resource_gps,
1193 "call_echo_cancellation", &priv->echo_cancellation,
1194 NULL);
1195 g_free (filename);
1197 gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (preferences))), priv->notebook);
1198 gtk_widget_show (priv->notebook);
1200 g_object_unref (gui);
1202 priv->gsettings = g_settings_new (EMPATHY_PREFS_SCHEMA);
1203 priv->gsettings_chat = g_settings_new (EMPATHY_PREFS_CHAT_SCHEMA);
1204 priv->gsettings_call = g_settings_new (EMPATHY_PREFS_CALL_SCHEMA);
1205 priv->gsettings_loc = g_settings_new (EMPATHY_PREFS_LOCATION_SCHEMA);
1206 priv->gsettings_notify = g_settings_new (EMPATHY_PREFS_NOTIFICATIONS_SCHEMA);
1207 priv->gsettings_sound = g_settings_new (EMPATHY_PREFS_SOUNDS_SCHEMA);
1208 priv->gsettings_ui = g_settings_new (EMPATHY_PREFS_UI_SCHEMA);
1209 priv->gsettings_logger = g_settings_new (EMPATHY_PREFS_LOGGER_SCHEMA);
1211 /* Create chat theme preview, and track changes */
1212 priv->theme_manager = empathy_theme_manager_dup_singleton ();
1213 tp_g_signal_connect_object (priv->theme_manager, "theme-changed",
1214 G_CALLBACK (preferences_preview_theme_changed_cb),
1215 preferences, 0);
1216 preferences_preview_theme_changed_cb (priv->theme_manager, preferences);
1218 preferences_themes_setup (preferences);
1220 preferences_setup_widgets (preferences);
1222 preferences_languages_setup (preferences);
1223 preferences_languages_add (preferences);
1224 preferences_languages_load (preferences);
1226 preferences_sound_setup (preferences);
1227 preferences_sound_load (preferences);
1229 if (empathy_spell_supported ()) {
1230 page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (priv->notebook), EMPATHY_PREFERENCES_TAB_SPELL);
1231 gtk_widget_show (page);
1234 page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (priv->notebook), EMPATHY_PREFERENCES_TAB_LOCATION);
1235 #ifdef HAVE_GEOCLUE
1236 gtk_widget_show (page);
1237 #else
1238 gtk_widget_hide (page);
1239 #endif
1242 static EmpathyPreferencesTab
1243 empathy_preferences_tab_from_string (const gchar *str)
1245 guint i;
1247 for (i = 0; i < G_N_ELEMENTS (empathy_preferences_tabs); i++)
1249 if (!tp_strdiff (str, empathy_preferences_tabs[i]))
1250 return i;
1253 g_warn_if_reached ();
1254 return -1;
1257 const gchar *
1258 empathy_preferences_tab_to_string (EmpathyPreferencesTab tab)
1260 g_return_val_if_fail (tab < G_N_ELEMENTS (empathy_preferences_tabs), NULL);
1262 return empathy_preferences_tabs[tab];
1265 GtkWidget *
1266 empathy_preferences_new (GtkWindow *parent,
1267 gboolean shell_running)
1269 GtkWidget *self;
1270 EmpathyPreferencesPriv *priv;
1271 GtkWidget *notif_page;
1273 g_return_val_if_fail (parent == NULL || GTK_IS_WINDOW (parent), NULL);
1275 self = g_object_new (EMPATHY_TYPE_PREFERENCES, NULL);
1277 if (parent != NULL) {
1278 gtk_window_set_transient_for (GTK_WINDOW (self),
1279 parent);
1282 /* when running in Gnome Shell we must hide these options since they
1283 * are meaningless in that context:
1284 * - 'Display incoming events in the notification area' (General->Behavior)
1285 * - 'Notifications' tab
1287 priv = GET_PRIV (self);
1288 if (shell_running) {
1289 gtk_widget_hide (priv->checkbutton_events_notif_area);
1290 notif_page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (priv->notebook),
1291 EMPATHY_PREFERENCES_TAB_NOTIFICATIONS);
1292 gtk_widget_hide (notif_page);
1295 return self;
1298 void
1299 empathy_preferences_show_tab (EmpathyPreferences *self,
1300 const gchar *page)
1302 EmpathyPreferencesPriv *priv = GET_PRIV (self);
1304 gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook),
1305 empathy_preferences_tab_from_string (page));