From 29cbf3a2b4c6c2a73b04d4e369a4ffc35a5dcfb2 Mon Sep 17 00:00:00 2001 From: Gabriel Millaire Date: Wed, 10 Jun 2009 21:43:19 -0400 Subject: Work in progress : move preferences to View menu Moving Sort by name / by status and Show Avatars / Compact contact list preferences to View menu : Sort by name / Sort by status and Normal Size / Normal Without Icons / Compact Size --- src/empathy-main-window.c | 145 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 115 insertions(+), 30 deletions(-) (limited to 'src/empathy-main-window.c') diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c index c7816d7fd..ce9022de3 100644 --- a/src/empathy-main-window.c +++ b/src/empathy-main-window.c @@ -717,6 +717,36 @@ main_window_view_show_offline_cb (GtkToggleAction *action, //empathy_sound_set_enabled (TRUE); } +static void +main_window_view_sort_contacts_cb (GtkRadioAction *action, + GtkRadioAction *current, + EmpathyMainWindow *window) +{ + EmpathyContactListStoreSort value; + + value = gtk_radio_action_get_current_value (action); + + empathy_contact_list_store_set_sort_criterium (window->list_store, value); +} + +/* Matches GtkRadioAction values set in empathy-main-window.ui */ +#define CONTACT_LIST_NORMAL_SIZE 0 +#define CONTACT_LIST_NORMAL_WITHOUT_ICONS 1 +#define CONTACT_LIST_COMPACT_SIZE 2 + +static void +main_window_view_contacts_list_size_cb (GtkRadioAction *action, + GtkRadioAction *current, + EmpathyMainWindow *window) +{ + gint value; + + value = gtk_radio_action_get_current_value (action); + + empathy_contact_list_store_set_show_avatars (window->list_store, value == CONTACT_LIST_NORMAL_SIZE); + empathy_contact_list_store_set_is_compact (window->list_store, value == CONTACT_LIST_COMPACT_SIZE); +} + static void main_window_view_show_map_cb (GtkCheckMenuItem *item, EmpathyMainWindow *window) @@ -1052,9 +1082,10 @@ main_window_notify_compact_contact_list_cb (EmpathyConf *conf, } static void -main_window_notify_sort_criterium_cb (EmpathyConf *conf, - const gchar *key, - EmpathyMainWindow *window) +main_window_conf_sort_criterium (EmpathyConf *conf, + const gchar *key, + EmpathyMainWindow *window, + GtkRadioAction *action) { gchar *str = NULL; @@ -1067,11 +1098,17 @@ main_window_notify_sort_criterium_cb (EmpathyConf *conf, enum_class = G_ENUM_CLASS (g_type_class_peek (type)); enum_value = g_enum_get_value_by_nick (enum_class, str); g_free (str); - - if (enum_value) { - empathy_contact_list_store_set_sort_criterium (window->list_store, - enum_value->value); + + if (enum_value->value == EMPATHY_CONTACT_LIST_STORE_SORT_STATE) { + gtk_radio_action_set_current_value (action, 2); + } else { + gtk_radio_action_set_current_value (action, 1); } + +// if (enum_value) { +// empathy_contact_list_store_set_sort_criterium (window->list_store, +// enum_value->value); +// } } } @@ -1112,6 +1149,11 @@ empathy_main_window_show (void) EmpathyConf *conf; GtkWidget *sw; GtkToggleAction *show_offline_widget; + GtkRadioAction *sort_by_name; + GtkRadioAction *sort_by_status; + GtkRadioAction *normal_size; + GtkRadioAction *normal_without_icons; + GtkRadioAction *compact_size; GtkWidget *ebox; GtkAction *show_map_widget; GtkToolItem *item; @@ -1119,6 +1161,7 @@ empathy_main_window_show (void) gboolean show_avatars; gboolean compact_contact_list; gint x, y, w, h; + gint value = 1; gchar *filename; GSList *l; @@ -1137,6 +1180,11 @@ empathy_main_window_show (void) "errors_vbox", &window->errors_vbox, "ui_manager", &window->ui_manager, "view_show_offline", &show_offline_widget, + "view_sort_by_name", &sort_by_name, + "view_sort_by_status", &sort_by_status, + "view_normal_size", &normal_size, + "view_normal_without_icons", &normal_without_icons, + "view_compact_size", &compact_size, "view_history", &window->view_history, "view_show_map", &show_map_widget, "room_join_favorites", &window->room_join_favorites, @@ -1157,6 +1205,8 @@ empathy_main_window_show (void) "chat_add_contact", "activate", main_window_chat_add_contact_cb, "view_show_ft_manager", "activate", main_window_view_show_ft_manager, "view_show_offline", "toggled", main_window_view_show_offline_cb, + "view_sort_by_name", "changed", main_window_view_sort_contacts_cb, + "view_normal_size", "changed", main_window_view_contacts_list_size_cb, "view_show_map", "activate", main_window_view_show_map_cb, "edit", "activate", main_window_edit_cb, "edit_accounts", "activate", main_window_edit_accounts_cb, @@ -1307,35 +1357,70 @@ empathy_main_window_show (void) show_offline_widget); gtk_toggle_action_set_active (show_offline_widget, show_offline); + + /* Sort by name / by status ? */ + /* without conf */ + main_window_view_sort_contacts_cb (sort_by_name, sort_by_name, window); + + /* with conf */ +// main_window_conf_sort_criterium (conf, +// EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM, +// window, +// sort_by_name); + + + /* Contacts list size */ + /* whithout conf */ + main_window_view_contacts_list_size_cb (normal_size, normal_size, window); + + /* with conf */ +// empathy_conf_get_bool (conf, +// EMPATHY_PREFS_UI_SHOW_AVATARS, +// &show_avatars); +// empathy_conf_get_bool (conf, +// EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST, +// &compact_contact_list); +// +// if (compact_contact_list == TRUE) { +// value = CONTACT_LIST_COMPACT_SIZE; +// } else if (show_avatars == TRUE) { +// value = CONTACT_LIST_NORMAL_SIZE; +// } else { +// value = CONTACT_LIST_NORMAL_WITHOUT_ICONS; +// } +// gtk_radio_action_set_current_value (normal_size, value); + + /* Show avatars ? */ - empathy_conf_get_bool (conf, - EMPATHY_PREFS_UI_SHOW_AVATARS, - &show_avatars); - empathy_conf_notify_add (conf, - EMPATHY_PREFS_UI_SHOW_AVATARS, - (EmpathyConfNotifyFunc) main_window_notify_show_avatars_cb, - window); - empathy_contact_list_store_set_show_avatars (window->list_store, show_avatars); +// empathy_conf_get_bool (conf, +// EMPATHY_PREFS_UI_SHOW_AVATARS, +// &show_avatars); +// empathy_conf_notify_add (conf, +// EMPATHY_PREFS_UI_SHOW_AVATARS, +// (EmpathyConfNotifyFunc) main_window_notify_show_avatars_cb, +// window); +// empathy_contact_list_store_set_show_avatars (window->list_store, show_avatars); /* Is compact ? */ - empathy_conf_get_bool (conf, - EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST, - &compact_contact_list); - empathy_conf_notify_add (conf, - EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST, - (EmpathyConfNotifyFunc) main_window_notify_compact_contact_list_cb, - window); - empathy_contact_list_store_set_is_compact (window->list_store, compact_contact_list); +// empathy_conf_get_bool (conf, +// EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST, +// &compact_contact_list); +// empathy_conf_notify_add (conf, +// EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST, +// (EmpathyConfNotifyFunc) main_window_notify_compact_contact_list_cb, +// window); +// empathy_contact_list_store_set_is_compact (window->list_store, compact_contact_list); /* Sort criterium */ - empathy_conf_notify_add (conf, - EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM, - (EmpathyConfNotifyFunc) main_window_notify_sort_criterium_cb, - window); - main_window_notify_sort_criterium_cb (conf, - EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM, - window); + /* with conf */ + // empathy_conf_notify_add (conf, + // EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM, + // (EmpathyConfNotifyFunc) main_window_notify_sort_criterium_cb, + // window); +// main_window_notify_sort_criterium_cb (conf, +// EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM, +// window); main_window_update_status (window, window->account_manager); -- cgit v1.2.3 From 4fa12b80765dcb6059017a43e1c419f6bf2c9b3f Mon Sep 17 00:00:00 2001 From: Gabriel Millaire Date: Fri, 19 Jun 2009 16:11:14 -0400 Subject: Move Compact List and Sort Contacts from Preferences to View menu --- src/empathy-main-window.c | 155 ++++++++++++++++++---------------------------- 1 file changed, 60 insertions(+), 95 deletions(-) (limited to 'src/empathy-main-window.c') diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c index ce9022de3..e9c98c701 100644 --- a/src/empathy-main-window.c +++ b/src/empathy-main-window.c @@ -723,9 +723,33 @@ main_window_view_sort_contacts_cb (GtkRadioAction *action, EmpathyMainWindow *window) { EmpathyContactListStoreSort value; + const gchar *valueStr = NULL; value = gtk_radio_action_get_current_value (action); - + + GSList *group; + GType type; + GEnumClass *enum_class; + GEnumValue *enum_value; + + group = gtk_radio_action_get_group (action); + + /* Get string from index */ + type = empathy_contact_list_store_sort_get_type (); + enum_class = G_ENUM_CLASS (g_type_class_peek (type)); + enum_value = g_enum_get_value (enum_class, g_slist_index (group, current)); + + if (!enum_value) { + g_warning ("No GEnumValue for EmpathyContactListSort with GtkRadioButton index:%d", + g_slist_index (group, action)); + } else { + valueStr = enum_value->value_nick; + + empathy_conf_set_string (empathy_conf_get (), + EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM, + valueStr); + } + empathy_contact_list_store_set_sort_criterium (window->list_store, value); } @@ -742,7 +766,14 @@ main_window_view_contacts_list_size_cb (GtkRadioAction *action, gint value; value = gtk_radio_action_get_current_value (action); - + + empathy_conf_set_bool (empathy_conf_get (), + EMPATHY_PREFS_UI_SHOW_AVATARS, + value == CONTACT_LIST_NORMAL_SIZE); + empathy_conf_set_bool (empathy_conf_get (), + EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST, + value == CONTACT_LIST_COMPACT_SIZE); + empathy_contact_list_store_set_show_avatars (window->list_store, value == CONTACT_LIST_NORMAL_SIZE); empathy_contact_list_store_set_is_compact (window->list_store, value == CONTACT_LIST_COMPACT_SIZE); } @@ -1055,31 +1086,9 @@ main_window_notify_show_offline_cb (EmpathyConf *conf, } } -static void -main_window_notify_show_avatars_cb (EmpathyConf *conf, - const gchar *key, - EmpathyMainWindow *window) -{ - gboolean show_avatars; - - if (empathy_conf_get_bool (conf, key, &show_avatars)) { - empathy_contact_list_store_set_show_avatars (window->list_store, - show_avatars); - } -} - -static void -main_window_notify_compact_contact_list_cb (EmpathyConf *conf, - const gchar *key, - EmpathyMainWindow *window) -{ - gboolean compact_contact_list; - - if (empathy_conf_get_bool (conf, key, &compact_contact_list)) { - empathy_contact_list_store_set_is_compact (window->list_store, - compact_contact_list); - } -} +/* Matches GtkRadioAction values set in empathy-main-window.ui */ +#define CONTACT_LIST_SORT_BY_STATUS 0 +#define CONTACT_LIST_SORT_BY_NAME 1 static void main_window_conf_sort_criterium (EmpathyConf *conf, @@ -1098,17 +1107,12 @@ main_window_conf_sort_criterium (EmpathyConf *conf, enum_class = G_ENUM_CLASS (g_type_class_peek (type)); enum_value = g_enum_get_value_by_nick (enum_class, str); g_free (str); - + if (enum_value->value == EMPATHY_CONTACT_LIST_STORE_SORT_STATE) { - gtk_radio_action_set_current_value (action, 2); + gtk_radio_action_set_current_value (action, CONTACT_LIST_SORT_BY_STATUS); } else { - gtk_radio_action_set_current_value (action, 1); + gtk_radio_action_set_current_value (action, CONTACT_LIST_SORT_BY_NAME); } - -// if (enum_value) { -// empathy_contact_list_store_set_sort_criterium (window->list_store, -// enum_value->value); -// } } } @@ -1357,70 +1361,31 @@ empathy_main_window_show (void) show_offline_widget); gtk_toggle_action_set_active (show_offline_widget, show_offline); - + /* Sort by name / by status ? */ - /* without conf */ - main_window_view_sort_contacts_cb (sort_by_name, sort_by_name, window); - - /* with conf */ -// main_window_conf_sort_criterium (conf, -// EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM, -// window, -// sort_by_name); + main_window_conf_sort_criterium (conf, + EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM, + window, + sort_by_name); /* Contacts list size */ - /* whithout conf */ - main_window_view_contacts_list_size_cb (normal_size, normal_size, window); - - /* with conf */ -// empathy_conf_get_bool (conf, -// EMPATHY_PREFS_UI_SHOW_AVATARS, -// &show_avatars); -// empathy_conf_get_bool (conf, -// EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST, -// &compact_contact_list); -// -// if (compact_contact_list == TRUE) { -// value = CONTACT_LIST_COMPACT_SIZE; -// } else if (show_avatars == TRUE) { -// value = CONTACT_LIST_NORMAL_SIZE; -// } else { -// value = CONTACT_LIST_NORMAL_WITHOUT_ICONS; -// } -// gtk_radio_action_set_current_value (normal_size, value); - - - - /* Show avatars ? */ -// empathy_conf_get_bool (conf, -// EMPATHY_PREFS_UI_SHOW_AVATARS, -// &show_avatars); -// empathy_conf_notify_add (conf, -// EMPATHY_PREFS_UI_SHOW_AVATARS, -// (EmpathyConfNotifyFunc) main_window_notify_show_avatars_cb, -// window); -// empathy_contact_list_store_set_show_avatars (window->list_store, show_avatars); - - /* Is compact ? */ -// empathy_conf_get_bool (conf, -// EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST, -// &compact_contact_list); -// empathy_conf_notify_add (conf, -// EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST, -// (EmpathyConfNotifyFunc) main_window_notify_compact_contact_list_cb, -// window); -// empathy_contact_list_store_set_is_compact (window->list_store, compact_contact_list); - - /* Sort criterium */ - /* with conf */ - // empathy_conf_notify_add (conf, - // EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM, - // (EmpathyConfNotifyFunc) main_window_notify_sort_criterium_cb, - // window); -// main_window_notify_sort_criterium_cb (conf, -// EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM, -// window); + empathy_conf_get_bool (conf, + EMPATHY_PREFS_UI_SHOW_AVATARS, + &show_avatars); + empathy_conf_get_bool (conf, + EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST, + &compact_contact_list); + + if (compact_contact_list) { + value = CONTACT_LIST_COMPACT_SIZE; + } else if (show_avatars) { + value = CONTACT_LIST_NORMAL_SIZE; + } else { + value = CONTACT_LIST_NORMAL_WITHOUT_ICONS; + } + gtk_radio_action_set_current_value (normal_size, value); + main_window_update_status (window, window->account_manager); -- cgit v1.2.3 From 40869ce43c263c1e20f79ec342415fea749cc9a7 Mon Sep 17 00:00:00 2001 From: Gabriel Millaire Date: Fri, 19 Jun 2009 15:22:19 -0400 Subject: Added notification for confs Show avatar, Compact Size and Sort criterium Now checks for wrong string in Sort criterium --- src/empathy-main-window.c | 124 ++++++++++++++++++++++++++++------------------ 1 file changed, 77 insertions(+), 47 deletions(-) (limited to 'src/empathy-main-window.c') diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c index e9c98c701..a40e29649 100644 --- a/src/empathy-main-window.c +++ b/src/empathy-main-window.c @@ -95,6 +95,12 @@ typedef struct { GtkWidget *presence_chooser; GtkWidget *errors_vbox; + GtkRadioAction *sort_by_name; + GtkRadioAction *sort_by_status; + GtkRadioAction *normal_size; + GtkRadioAction *normal_without_icons; + GtkRadioAction *compact_size; + GtkUIManager *ui_manager; GtkAction *view_history; GtkAction *room_join_favorites; @@ -749,7 +755,6 @@ main_window_view_sort_contacts_cb (GtkRadioAction *action, EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM, valueStr); } - empathy_contact_list_store_set_sort_criterium (window->list_store, value); } @@ -768,14 +773,16 @@ main_window_view_contacts_list_size_cb (GtkRadioAction *action, value = gtk_radio_action_get_current_value (action); empathy_conf_set_bool (empathy_conf_get (), - EMPATHY_PREFS_UI_SHOW_AVATARS, - value == CONTACT_LIST_NORMAL_SIZE); + EMPATHY_PREFS_UI_SHOW_AVATARS, + value == CONTACT_LIST_NORMAL_SIZE); empathy_conf_set_bool (empathy_conf_get (), - EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST, - value == CONTACT_LIST_COMPACT_SIZE); + EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST, + value == CONTACT_LIST_COMPACT_SIZE); - empathy_contact_list_store_set_show_avatars (window->list_store, value == CONTACT_LIST_NORMAL_SIZE); - empathy_contact_list_store_set_is_compact (window->list_store, value == CONTACT_LIST_COMPACT_SIZE); + empathy_contact_list_store_set_show_avatars (window->list_store, + value == CONTACT_LIST_NORMAL_SIZE); + empathy_contact_list_store_set_is_compact (window->list_store, + value == CONTACT_LIST_COMPACT_SIZE); } static void @@ -1086,15 +1093,41 @@ main_window_notify_show_offline_cb (EmpathyConf *conf, } } +static void +main_window_notify_contact_list_size_cb (EmpathyConf *conf, + const gchar *key, + EmpathyMainWindow *window) +{ + gboolean show_avatars; + gboolean compact_contact_list; + gint value = CONTACT_LIST_NORMAL_SIZE; + + if (empathy_conf_get_bool (conf, + EMPATHY_PREFS_UI_SHOW_AVATARS, + &show_avatars) + && empathy_conf_get_bool (conf, + EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST, + &compact_contact_list)) { + if (compact_contact_list) { + value = CONTACT_LIST_COMPACT_SIZE; + } else if (show_avatars) { + value = CONTACT_LIST_NORMAL_SIZE; + } else { + value = CONTACT_LIST_NORMAL_WITHOUT_ICONS; + } + } + gtk_radio_action_set_current_value (window->normal_size, value); +} + + /* Matches GtkRadioAction values set in empathy-main-window.ui */ #define CONTACT_LIST_SORT_BY_STATUS 0 #define CONTACT_LIST_SORT_BY_NAME 1 static void -main_window_conf_sort_criterium (EmpathyConf *conf, - const gchar *key, - EmpathyMainWindow *window, - GtkRadioAction *action) +main_window_notify_sort_contact_cb (EmpathyConf *conf, + const gchar *key, + EmpathyMainWindow *window) { gchar *str = NULL; @@ -1106,13 +1139,19 @@ main_window_conf_sort_criterium (EmpathyConf *conf, type = empathy_contact_list_store_sort_get_type (); enum_class = G_ENUM_CLASS (g_type_class_peek (type)); enum_value = g_enum_get_value_by_nick (enum_class, str); - g_free (str); - if (enum_value->value == EMPATHY_CONTACT_LIST_STORE_SORT_STATE) { - gtk_radio_action_set_current_value (action, CONTACT_LIST_SORT_BY_STATUS); + if (enum_value) { + if (enum_value->value == EMPATHY_CONTACT_LIST_STORE_SORT_STATE) { + gtk_radio_action_set_current_value (window->sort_by_name, + CONTACT_LIST_SORT_BY_STATUS); + } else { + gtk_radio_action_set_current_value (window->sort_by_name, + CONTACT_LIST_SORT_BY_NAME); + } } else { - gtk_radio_action_set_current_value (action, CONTACT_LIST_SORT_BY_NAME); + g_warning ("Wrong value for sort_criterium configuration : %s", str); } + g_free (str); } } @@ -1153,19 +1192,11 @@ empathy_main_window_show (void) EmpathyConf *conf; GtkWidget *sw; GtkToggleAction *show_offline_widget; - GtkRadioAction *sort_by_name; - GtkRadioAction *sort_by_status; - GtkRadioAction *normal_size; - GtkRadioAction *normal_without_icons; - GtkRadioAction *compact_size; GtkWidget *ebox; GtkAction *show_map_widget; GtkToolItem *item; gboolean show_offline; - gboolean show_avatars; - gboolean compact_contact_list; gint x, y, w, h; - gint value = 1; gchar *filename; GSList *l; @@ -1184,11 +1215,11 @@ empathy_main_window_show (void) "errors_vbox", &window->errors_vbox, "ui_manager", &window->ui_manager, "view_show_offline", &show_offline_widget, - "view_sort_by_name", &sort_by_name, - "view_sort_by_status", &sort_by_status, - "view_normal_size", &normal_size, - "view_normal_without_icons", &normal_without_icons, - "view_compact_size", &compact_size, + "view_sort_by_name", &window->sort_by_name, + "view_sort_by_status", &window->sort_by_status, + "view_normal_size", &window->normal_size, + "view_normal_without_icons", &window->normal_without_icons, + "view_compact_size", &window->compact_size, "view_history", &window->view_history, "view_show_map", &show_map_widget, "room_join_favorites", &window->room_join_favorites, @@ -1363,29 +1394,28 @@ empathy_main_window_show (void) gtk_toggle_action_set_active (show_offline_widget, show_offline); /* Sort by name / by status ? */ - main_window_conf_sort_criterium (conf, - EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM, - window, - sort_by_name); + empathy_conf_notify_add (conf, + EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM, + (EmpathyConfNotifyFunc) main_window_notify_sort_contact_cb, + window); + main_window_notify_sort_contact_cb (conf, + EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM, + window); /* Contacts list size */ - empathy_conf_get_bool (conf, - EMPATHY_PREFS_UI_SHOW_AVATARS, - &show_avatars); - empathy_conf_get_bool (conf, - EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST, - &compact_contact_list); - - if (compact_contact_list) { - value = CONTACT_LIST_COMPACT_SIZE; - } else if (show_avatars) { - value = CONTACT_LIST_NORMAL_SIZE; - } else { - value = CONTACT_LIST_NORMAL_WITHOUT_ICONS; - } - gtk_radio_action_set_current_value (normal_size, value); + empathy_conf_notify_add (conf, + EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST, + (EmpathyConfNotifyFunc) main_window_notify_contact_list_size_cb, + window); + empathy_conf_notify_add (conf, + EMPATHY_PREFS_UI_SHOW_AVATARS, + (EmpathyConfNotifyFunc) main_window_notify_contact_list_size_cb, + window); + main_window_notify_contact_list_size_cb (conf, + EMPATHY_PREFS_UI_SHOW_AVATARS, + window); main_window_update_status (window, window->account_manager); -- cgit v1.2.3 From c74b8f99f8b3c706d18cc280c35748d8e5282660 Mon Sep 17 00:00:00 2001 From: Gabriel Millaire Date: Mon, 29 Jun 2009 22:37:23 -0400 Subject: Changed menu label and various review fixes --- src/empathy-main-window.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) (limited to 'src/empathy-main-window.c') diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c index a40e29649..2e2e93a81 100644 --- a/src/empathy-main-window.c +++ b/src/empathy-main-window.c @@ -97,8 +97,8 @@ typedef struct { GtkRadioAction *sort_by_name; GtkRadioAction *sort_by_status; + GtkRadioAction *normal_with_avatars; GtkRadioAction *normal_size; - GtkRadioAction *normal_without_icons; GtkRadioAction *compact_size; GtkUIManager *ui_manager; @@ -729,15 +729,12 @@ main_window_view_sort_contacts_cb (GtkRadioAction *action, EmpathyMainWindow *window) { EmpathyContactListStoreSort value; - const gchar *valueStr = NULL; - - value = gtk_radio_action_get_current_value (action); - GSList *group; GType type; GEnumClass *enum_class; GEnumValue *enum_value; + value = gtk_radio_action_get_current_value (action); group = gtk_radio_action_get_group (action); /* Get string from index */ @@ -749,19 +746,20 @@ main_window_view_sort_contacts_cb (GtkRadioAction *action, g_warning ("No GEnumValue for EmpathyContactListSort with GtkRadioButton index:%d", g_slist_index (group, action)); } else { - valueStr = enum_value->value_nick; + const gchar *value_str; + value_str = enum_value->value_nick; empathy_conf_set_string (empathy_conf_get (), EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM, - valueStr); + value_str); } empathy_contact_list_store_set_sort_criterium (window->list_store, value); } /* Matches GtkRadioAction values set in empathy-main-window.ui */ -#define CONTACT_LIST_NORMAL_SIZE 0 -#define CONTACT_LIST_NORMAL_WITHOUT_ICONS 1 -#define CONTACT_LIST_COMPACT_SIZE 2 +#define CONTACT_LIST_NORMAL_SIZE_WITH_AVATARS 0 +#define CONTACT_LIST_NORMAL_SIZE 1 +#define CONTACT_LIST_COMPACT_SIZE 2 static void main_window_view_contacts_list_size_cb (GtkRadioAction *action, @@ -774,13 +772,13 @@ main_window_view_contacts_list_size_cb (GtkRadioAction *action, empathy_conf_set_bool (empathy_conf_get (), EMPATHY_PREFS_UI_SHOW_AVATARS, - value == CONTACT_LIST_NORMAL_SIZE); + value == CONTACT_LIST_NORMAL_SIZE_WITH_AVATARS); empathy_conf_set_bool (empathy_conf_get (), EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST, value == CONTACT_LIST_COMPACT_SIZE); empathy_contact_list_store_set_show_avatars (window->list_store, - value == CONTACT_LIST_NORMAL_SIZE); + value == CONTACT_LIST_NORMAL_SIZE_WITH_AVATARS); empathy_contact_list_store_set_is_compact (window->list_store, value == CONTACT_LIST_COMPACT_SIZE); } @@ -1100,7 +1098,7 @@ main_window_notify_contact_list_size_cb (EmpathyConf *conf, { gboolean show_avatars; gboolean compact_contact_list; - gint value = CONTACT_LIST_NORMAL_SIZE; + gint value = CONTACT_LIST_NORMAL_SIZE_WITH_AVATARS; if (empathy_conf_get_bool (conf, EMPATHY_PREFS_UI_SHOW_AVATARS, @@ -1111,12 +1109,12 @@ main_window_notify_contact_list_size_cb (EmpathyConf *conf, if (compact_contact_list) { value = CONTACT_LIST_COMPACT_SIZE; } else if (show_avatars) { - value = CONTACT_LIST_NORMAL_SIZE; + value = CONTACT_LIST_NORMAL_SIZE_WITH_AVATARS; } else { - value = CONTACT_LIST_NORMAL_WITHOUT_ICONS; + value = CONTACT_LIST_NORMAL_SIZE; } } - gtk_radio_action_set_current_value (window->normal_size, value); + gtk_radio_action_set_current_value (window->normal_with_avatars, value); } @@ -1217,8 +1215,8 @@ empathy_main_window_show (void) "view_show_offline", &show_offline_widget, "view_sort_by_name", &window->sort_by_name, "view_sort_by_status", &window->sort_by_status, + "view_normal_size_with_avatars", &window->normal_with_avatars, "view_normal_size", &window->normal_size, - "view_normal_without_icons", &window->normal_without_icons, "view_compact_size", &window->compact_size, "view_history", &window->view_history, "view_show_map", &show_map_widget, @@ -1241,7 +1239,7 @@ empathy_main_window_show (void) "view_show_ft_manager", "activate", main_window_view_show_ft_manager, "view_show_offline", "toggled", main_window_view_show_offline_cb, "view_sort_by_name", "changed", main_window_view_sort_contacts_cb, - "view_normal_size", "changed", main_window_view_contacts_list_size_cb, + "view_normal_size_with_avatars", "changed", main_window_view_contacts_list_size_cb, "view_show_map", "activate", main_window_view_show_map_cb, "edit", "activate", main_window_edit_cb, "edit_accounts", "activate", main_window_edit_accounts_cb, -- cgit v1.2.3 From 2a5d562c839106c2edacd58cbdc003e0aead635b Mon Sep 17 00:00:00 2001 From: Gabriel Millaire Date: Fri, 10 Jul 2009 11:28:54 -0400 Subject: Regrouped similar functions, uses enum instead of define --- src/empathy-main-window.c | 118 +++++++++++++++++++++------------------------- 1 file changed, 55 insertions(+), 63 deletions(-) (limited to 'src/empathy-main-window.c') diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c index 2e2e93a81..06238b2a4 100644 --- a/src/empathy-main-window.c +++ b/src/empathy-main-window.c @@ -723,6 +723,34 @@ main_window_view_show_offline_cb (GtkToggleAction *action, //empathy_sound_set_enabled (TRUE); } +static void +main_window_notify_sort_contact_cb (EmpathyConf *conf, + const gchar *key, + EmpathyMainWindow *window) +{ + gchar *str = NULL; + + if (empathy_conf_get_string (conf, key, &str) && str) { + GType type; + GEnumClass *enum_class; + GEnumValue *enum_value; + + type = empathy_contact_list_store_sort_get_type (); + enum_class = G_ENUM_CLASS (g_type_class_peek (type)); + enum_value = g_enum_get_value_by_nick (enum_class, str); + if (enum_value) { + /* By changing the value of the GtkRadioAction, + it emits a signal that calls main_window_view_sort_contacts_cb + which updates the contacts list */ + gtk_radio_action_set_current_value (window->sort_by_name, + enum_value->value); + } else { + g_warning ("Wrong value for sort_criterium configuration : %s", str); + } + g_free (str); + } +} + static void main_window_view_sort_contacts_cb (GtkRadioAction *action, GtkRadioAction *current, @@ -743,7 +771,7 @@ main_window_view_sort_contacts_cb (GtkRadioAction *action, enum_value = g_enum_get_value (enum_class, g_slist_index (group, current)); if (!enum_value) { - g_warning ("No GEnumValue for EmpathyContactListSort with GtkRadioButton index:%d", + g_warning ("No GEnumValue for EmpathyContactListSort with GtkRadioAction index:%d", g_slist_index (group, action)); } else { const gchar *value_str; @@ -783,6 +811,32 @@ main_window_view_contacts_list_size_cb (GtkRadioAction *action, value == CONTACT_LIST_COMPACT_SIZE); } +static void +main_window_notify_contact_list_size_cb (EmpathyConf *conf, + const gchar *key, + EmpathyMainWindow *window) +{ + gboolean show_avatars; + gboolean compact_contact_list; + gint value = CONTACT_LIST_NORMAL_SIZE_WITH_AVATARS; + + if (empathy_conf_get_bool (conf, + EMPATHY_PREFS_UI_SHOW_AVATARS, + &show_avatars) + && empathy_conf_get_bool (conf, + EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST, + &compact_contact_list)) { + if (compact_contact_list) { + value = CONTACT_LIST_COMPACT_SIZE; + } else if (show_avatars) { + value = CONTACT_LIST_NORMAL_SIZE_WITH_AVATARS; + } else { + value = CONTACT_LIST_NORMAL_SIZE; + } + } + gtk_radio_action_set_current_value (window->normal_with_avatars, value); +} + static void main_window_view_show_map_cb (GtkCheckMenuItem *item, EmpathyMainWindow *window) @@ -1091,68 +1145,6 @@ main_window_notify_show_offline_cb (EmpathyConf *conf, } } -static void -main_window_notify_contact_list_size_cb (EmpathyConf *conf, - const gchar *key, - EmpathyMainWindow *window) -{ - gboolean show_avatars; - gboolean compact_contact_list; - gint value = CONTACT_LIST_NORMAL_SIZE_WITH_AVATARS; - - if (empathy_conf_get_bool (conf, - EMPATHY_PREFS_UI_SHOW_AVATARS, - &show_avatars) - && empathy_conf_get_bool (conf, - EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST, - &compact_contact_list)) { - if (compact_contact_list) { - value = CONTACT_LIST_COMPACT_SIZE; - } else if (show_avatars) { - value = CONTACT_LIST_NORMAL_SIZE_WITH_AVATARS; - } else { - value = CONTACT_LIST_NORMAL_SIZE; - } - } - gtk_radio_action_set_current_value (window->normal_with_avatars, value); -} - - -/* Matches GtkRadioAction values set in empathy-main-window.ui */ -#define CONTACT_LIST_SORT_BY_STATUS 0 -#define CONTACT_LIST_SORT_BY_NAME 1 - -static void -main_window_notify_sort_contact_cb (EmpathyConf *conf, - const gchar *key, - EmpathyMainWindow *window) -{ - gchar *str = NULL; - - if (empathy_conf_get_string (conf, key, &str) && str) { - GType type; - GEnumClass *enum_class; - GEnumValue *enum_value; - - type = empathy_contact_list_store_sort_get_type (); - enum_class = G_ENUM_CLASS (g_type_class_peek (type)); - enum_value = g_enum_get_value_by_nick (enum_class, str); - - if (enum_value) { - if (enum_value->value == EMPATHY_CONTACT_LIST_STORE_SORT_STATE) { - gtk_radio_action_set_current_value (window->sort_by_name, - CONTACT_LIST_SORT_BY_STATUS); - } else { - gtk_radio_action_set_current_value (window->sort_by_name, - CONTACT_LIST_SORT_BY_NAME); - } - } else { - g_warning ("Wrong value for sort_criterium configuration : %s", str); - } - g_free (str); - } -} - static void main_window_connection_items_setup (EmpathyMainWindow *window, GtkBuilder *gui) -- cgit v1.2.3 From 972532d4223b01ae12fcae945620615fbc9f5ccd Mon Sep 17 00:00:00 2001 From: Gabriel Millaire Date: Fri, 10 Jul 2009 12:55:43 -0400 Subject: Minor changes --- src/empathy-main-window.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/empathy-main-window.c') diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c index 06238b2a4..4b1af853d 100644 --- a/src/empathy-main-window.c +++ b/src/empathy-main-window.c @@ -774,12 +774,9 @@ main_window_view_sort_contacts_cb (GtkRadioAction *action, g_warning ("No GEnumValue for EmpathyContactListSort with GtkRadioAction index:%d", g_slist_index (group, action)); } else { - const gchar *value_str; - value_str = enum_value->value_nick; - empathy_conf_set_string (empathy_conf_get (), EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM, - value_str); + enum_value->value_nick); } empathy_contact_list_store_set_sort_criterium (window->list_store, value); } @@ -834,6 +831,9 @@ main_window_notify_contact_list_size_cb (EmpathyConf *conf, value = CONTACT_LIST_NORMAL_SIZE; } } + /* By changing the value of the GtkRadioAction, + it emits a signal that calls main_window_view_contacts_list_size_cb + which updates the contacts list */ gtk_radio_action_set_current_value (window->normal_with_avatars, value); } -- cgit v1.2.3 From ad1cc3ce5f2e21766e7cd0f05669e3510048eacb Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Mon, 13 Jul 2009 18:04:56 +0100 Subject: empathy-main-window.c: remove a trailing space --- src/empathy-main-window.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/empathy-main-window.c') diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c index 4b1af853d..0e71229c5 100644 --- a/src/empathy-main-window.c +++ b/src/empathy-main-window.c @@ -739,7 +739,7 @@ main_window_notify_sort_contact_cb (EmpathyConf *conf, enum_class = G_ENUM_CLASS (g_type_class_peek (type)); enum_value = g_enum_get_value_by_nick (enum_class, str); if (enum_value) { - /* By changing the value of the GtkRadioAction, + /* By changing the value of the GtkRadioAction, it emits a signal that calls main_window_view_sort_contacts_cb which updates the contacts list */ gtk_radio_action_set_current_value (window->sort_by_name, -- cgit v1.2.3 From e1fa17399fc137a508f195aa6976b5f32189de96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Wed, 17 Jun 2009 10:01:52 +0200 Subject: Put configuration data in XDG_CONFIG_DIRS (GNOME bug 494007) --- src/empathy-main-window.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/empathy-main-window.c') diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c index 0e71229c5..a600fd429 100644 --- a/src/empathy-main-window.c +++ b/src/empathy-main-window.c @@ -611,7 +611,7 @@ main_window_accels_load (void) { gchar *filename; - filename = g_build_filename (g_get_home_dir (), ".gnome2", PACKAGE_NAME, ACCELS_FILENAME, NULL); + filename = g_build_filename (g_get_user_config_dir (), PACKAGE_NAME, ACCELS_FILENAME, NULL); if (g_file_test (filename, G_FILE_TEST_EXISTS)) { DEBUG ("Loading from:'%s'", filename); gtk_accel_map_load (filename); @@ -626,7 +626,7 @@ main_window_accels_save (void) gchar *dir; gchar *file_with_path; - dir = g_build_filename (g_get_home_dir (), ".gnome2", PACKAGE_NAME, NULL); + dir = g_build_filename (g_get_user_config_dir (), PACKAGE_NAME, NULL); g_mkdir_with_parents (dir, S_IRUSR | S_IWUSR | S_IXUSR); file_with_path = g_build_filename (dir, ACCELS_FILENAME, NULL); g_free (dir); -- cgit v1.2.3