]> git.0d.be Git - empathy.git/commitdiff
Move Compact List and Sort Contacts from Preferences to View menu
authorGabriel Millaire <millaire.gabriel@gmail.com>
Fri, 19 Jun 2009 20:11:14 +0000 (16:11 -0400)
committerGabriel Millaire <millaire.gabriel@gmail.com>
Fri, 10 Jul 2009 15:31:27 +0000 (11:31 -0400)
src/empathy-main-window.c
src/empathy-preferences.c
src/empathy-preferences.ui

index ce9022de3ad2ac2870b669327d0d8ee0cfc8f287..e9c98c701bceda888f22ac81d98a1634f84e6efe 100644 (file)
@@ -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);
 
index c6545ead0ffe0a6f5c063c6e5c5d7234b70e033c..3bfd7a69d0636abae7bf397c340efb936f12a82f 100644 (file)
@@ -50,15 +50,11 @@ typedef struct {
 
        GtkWidget *notebook;
 
-       GtkWidget *checkbutton_show_avatars;
-       GtkWidget *checkbutton_compact_contact_list;
        GtkWidget *checkbutton_show_smileys;
        GtkWidget *checkbutton_show_contacts_in_rooms;
        GtkWidget *combobox_chat_theme;
        GtkWidget *checkbutton_separate_chat_windows;
        GtkWidget *checkbutton_autoconnect;
-       GtkWidget *radiobutton_contact_list_sort_by_name;
-       GtkWidget *radiobutton_contact_list_sort_by_state;
 
        GtkWidget *checkbutton_sounds_enabled;
        GtkWidget *checkbutton_sounds_disabled_away;
@@ -99,11 +95,6 @@ static void     preferences_languages_cell_toggled_cb    (GtkCellRendererToggle
                                                          EmpathyPreferences      *preferences);
 static void     preferences_widget_sync_bool             (const gchar            *key,
                                                          GtkWidget              *widget);
-static void     preferences_widget_sync_string           (const gchar            *key,
-                                                         GtkWidget              *widget);
-static void     preferences_notify_string_cb             (EmpathyConf             *conf,
-                                                         const gchar            *key,
-                                                         gpointer                user_data);
 static void     preferences_notify_bool_cb               (EmpathyConf             *conf,
                                                          const gchar            *key,
                                                          gpointer                user_data);
@@ -113,16 +104,11 @@ static void     preferences_notify_sensitivity_cb        (EmpathyConf
 static void     preferences_hookup_toggle_button         (EmpathyPreferences      *preferences,
                                                          const gchar            *key,
                                                          GtkWidget              *widget);
-static void     preferences_hookup_radio_button          (EmpathyPreferences      *preferences,
-                                                         const gchar            *key,
-                                                         GtkWidget              *widget);
 static void     preferences_hookup_sensitivity           (EmpathyPreferences      *preferences,
                                                          const gchar            *key,
                                                          GtkWidget              *widget);
 static void     preferences_toggle_button_toggled_cb     (GtkWidget              *button,
                                                          gpointer                user_data);
-static void     preferences_radio_button_toggled_cb      (GtkWidget              *button,
-                                                         gpointer                user_data);
 static void     preferences_destroy_cb                   (GtkWidget              *widget,
                                                          EmpathyPreferences      *preferences);
 static void     preferences_response_cb                  (GtkWidget              *widget,
@@ -174,25 +160,9 @@ preferences_add_id (EmpathyPreferences *preferences, guint id)
                                                  GUINT_TO_POINTER (id));
 }
 
-static void
-preferences_compact_contact_list_changed_cb (EmpathyConf *conf,
-                                            const gchar *key,
-                                            gpointer     user_data)
-{
-       EmpathyPreferences *preferences = user_data;
-       gboolean            value;
-
-       if (empathy_conf_get_bool (empathy_conf_get (), key, &value)) {
-               gtk_widget_set_sensitive (preferences->checkbutton_show_avatars,
-                                         !value);
-       }
-}
-
 static void
 preferences_setup_widgets (EmpathyPreferences *preferences)
 {
-       guint id;
-
        preferences_hookup_toggle_button (preferences,
                                          EMPATHY_PREFS_NOTIFICATIONS_ENABLED,
                                          preferences->checkbutton_notifications_enabled);
@@ -240,14 +210,6 @@ preferences_setup_widgets (EmpathyPreferences *preferences)
                                          EMPATHY_PREFS_UI_SEPARATE_CHAT_WINDOWS,
                                          preferences->checkbutton_separate_chat_windows);
 
-       preferences_hookup_toggle_button (preferences,
-                                         EMPATHY_PREFS_UI_SHOW_AVATARS,
-                                         preferences->checkbutton_show_avatars);
-
-       preferences_hookup_toggle_button (preferences,
-                                         EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST,
-                                         preferences->checkbutton_compact_contact_list);
-
        preferences_hookup_toggle_button (preferences,
                                          EMPATHY_PREFS_CHAT_SHOW_SMILEYS,
                                          preferences->checkbutton_show_smileys);
@@ -256,10 +218,6 @@ preferences_setup_widgets (EmpathyPreferences *preferences)
                                          EMPATHY_PREFS_CHAT_SHOW_CONTACTS_IN_ROOMS,
                                          preferences->checkbutton_show_contacts_in_rooms);
 
-       preferences_hookup_radio_button (preferences,
-                                        EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM,
-                                        preferences->radiobutton_contact_list_sort_by_name);
-
        preferences_hookup_toggle_button (preferences,
                                          EMPATHY_PREFS_AUTOCONNECT,
                                          preferences->checkbutton_autoconnect);
@@ -295,17 +253,6 @@ preferences_setup_widgets (EmpathyPreferences *preferences)
        preferences_hookup_sensitivity (preferences,
                                        EMPATHY_PREFS_LOCATION_PUBLISH,
                                        preferences->checkbutton_location_reduce_accuracy);
-
-       id = empathy_conf_notify_add (empathy_conf_get (),
-                                     EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST,
-                                     preferences_compact_contact_list_changed_cb,
-                                     preferences);
-       if (id) {
-               preferences_add_id (preferences, id);
-       }
-       preferences_compact_contact_list_changed_cb (empathy_conf_get (),
-                                                    EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST,
-                                                    preferences);
 }
 
 static void
@@ -659,6 +606,7 @@ preferences_widget_sync_bool (const gchar *key, GtkWidget *widget)
        }
 }
 
+#if 0
 static void
 preferences_widget_sync_string (const gchar *key, GtkWidget *widget)
 {
@@ -701,7 +649,7 @@ preferences_notify_string_cb (EmpathyConf  *conf,
 {
        preferences_widget_sync_string (key, user_data);
 }
-
+#endif
 
 static void
 preferences_notify_bool_cb (EmpathyConf  *conf,
@@ -849,6 +797,7 @@ preferences_hookup_toggle_button (EmpathyPreferences *preferences,
        }
 }
 
+#if 0
 static void
 preferences_hookup_radio_button (EmpathyPreferences *preferences,
                                 const gchar       *key,
@@ -878,6 +827,7 @@ preferences_hookup_radio_button (EmpathyPreferences *preferences,
                preferences_add_id (preferences, id);
        }
 }
+#endif
 
 static void
 preferences_hookup_sensitivity (EmpathyPreferences *preferences,
@@ -913,6 +863,7 @@ preferences_toggle_button_toggled_cb (GtkWidget *button,
                               gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)));
 }
 
+#if 0
 static void
 preferences_radio_button_toggled_cb (GtkWidget *button,
                                     gpointer   user_data)
@@ -952,6 +903,76 @@ preferences_radio_button_toggled_cb (GtkWidget *button,
 
        empathy_conf_set_string (empathy_conf_get (), key, value);
 }
+<<<<<<< HEAD:src/empathy-preferences.c
+=======
+#endif
+
+static void
+preferences_theme_adium_update_visibility (EmpathyPreferences *preferences,
+                                          const gchar        *name)
+{
+       if (name && strcmp (name, "adium") == 0) {
+               gtk_widget_show (preferences->hbox_adium_theme);
+       } else {
+               gtk_widget_hide (preferences->hbox_adium_theme);
+               gtk_widget_hide (preferences->label_invalid_adium_theme);
+       }
+}
+
+static void
+preferences_theme_adium_update_validity (EmpathyPreferences *preferences,
+                                        const gchar        *path)
+{
+#ifdef HAVE_WEBKIT
+       if (empathy_adium_path_is_valid (path)) {
+               gtk_widget_hide (preferences->label_invalid_adium_theme);
+       } else {
+               gtk_widget_show (preferences->label_invalid_adium_theme);
+       }
+#endif
+}
+
+static void
+preferences_theme_adium_path_notify_cb (EmpathyConf *conf,
+                                       const gchar *key,
+                                       gpointer     user_data)
+{
+       EmpathyPreferences *preferences = user_data;
+       GtkFileChooser     *chooser;
+       gchar              *value;
+       const gchar        *path;
+
+       if (!empathy_conf_get_string (conf, key, &value)) {
+               return;
+       }
+
+       if (EMP_STR_EMPTY (value)) {
+               path = g_get_home_dir ();
+       } else {
+               path = value;
+       }
+
+       chooser = GTK_FILE_CHOOSER (preferences->filechooserbutton_adium_theme);
+       gtk_file_chooser_set_current_folder (chooser, path);
+       preferences_theme_adium_update_validity (preferences, path);
+       g_free (value);
+}
+
+static void
+preferences_theme_adium_file_set_cb (GtkFileChooser     *chooser,
+                                    EmpathyPreferences *preferences)
+{
+       gchar *path;
+
+       path = gtk_file_chooser_get_current_folder (chooser);
+       empathy_conf_set_string (empathy_conf_get (),
+                                EMPATHY_PREFS_CHAT_ADIUM_PATH,
+                                path);
+       preferences_theme_adium_update_validity (preferences, path);
+
+       g_free (path);
+}
+>>>>>>> Move Compact List and Sort Contacts from Preferences to View menu:src/empathy-preferences.c
 
 static void
 preferences_theme_notify_cb (EmpathyConf *conf,
@@ -1182,15 +1203,11 @@ empathy_preferences_show (GtkWindow *parent)
        gui = empathy_builder_get_file (filename,
                "preferences_dialog", &preferences->dialog,
                "notebook", &preferences->notebook,
-               "checkbutton_show_avatars", &preferences->checkbutton_show_avatars,
-               "checkbutton_compact_contact_list", &preferences->checkbutton_compact_contact_list,
                "checkbutton_show_smileys", &preferences->checkbutton_show_smileys,
                "checkbutton_show_contacts_in_rooms", &preferences->checkbutton_show_contacts_in_rooms,
                "combobox_chat_theme", &preferences->combobox_chat_theme,
                "checkbutton_separate_chat_windows", &preferences->checkbutton_separate_chat_windows,
                "checkbutton_autoconnect", &preferences->checkbutton_autoconnect,
-               "radiobutton_contact_list_sort_by_name", &preferences->radiobutton_contact_list_sort_by_name,
-               "radiobutton_contact_list_sort_by_state", &preferences->radiobutton_contact_list_sort_by_state,
                "checkbutton_notifications_enabled", &preferences->checkbutton_notifications_enabled,
                "checkbutton_notifications_disabled_away", &preferences->checkbutton_notifications_disabled_away,
                "checkbutton_notifications_focus", &preferences->checkbutton_notifications_focus,
index e4ec183bdf07a8c630a505e8c83127656daa33dc..a383607aacd84f11a36aee16236da6d068bb8740 100644 (file)
                         <child>
                           <object class="GtkVBox" id="vbox199">
                             <property name="visible">True</property>
-                            <child>
-                              <object class="GtkCheckButton" id="checkbutton_compact_contact_list">
-                                <property name="label" translatable="yes">Show co_mpact contact list</property>
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="receives_default">False</property>
-                                <property name="use_underline">True</property>
-                                <property name="draw_indicator">True</property>
-                              </object>
-                              <packing>
-                                <property name="expand">False</property>
-                                <property name="fill">False</property>
-                                <property name="position">0</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkCheckButton" id="checkbutton_show_avatars">
-                                <property name="label" translatable="yes">Show _avatars</property>
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="receives_default">False</property>
-                                <property name="tooltip_text" translatable="yes">Avatars are user chosen images shown in the contact list</property>
-                                <property name="use_underline">True</property>
-                                <property name="active">True</property>
-                                <property name="draw_indicator">True</property>
-                              </object>
-                              <packing>
-                                <property name="expand">False</property>
-                                <property name="fill">False</property>
-                                <property name="position">1</property>
-                              </packing>
-                            </child>
                             <child>
                               <object class="GtkCheckButton" id="checkbutton_show_smileys">
                                 <property name="label" translatable="yes">Show _smileys as images</property>
                     <property name="position">1</property>
                   </packing>
                 </child>
-                <child>
-                  <object class="GtkFrame" id="frame13">
-                    <property name="visible">True</property>
-                    <property name="label_xalign">0</property>
-                    <property name="shadow_type">none</property>
-                    <child>
-                      <object class="GtkAlignment" id="alignment31">
-                        <property name="visible">True</property>
-                        <property name="top_padding">6</property>
-                        <property name="left_padding">12</property>
-                        <child>
-                          <object class="GtkVBox" id="vbox217">
-                            <property name="visible">True</property>
-                            <child>
-                              <object class="GtkRadioButton" id="radiobutton_contact_list_sort_by_name">
-                                <property name="label" translatable="yes">Sort by _name</property>
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="receives_default">False</property>
-                                <property name="use_underline">True</property>
-                                <property name="draw_indicator">True</property>
-                              </object>
-                              <packing>
-                                <property name="expand">False</property>
-                                <property name="fill">False</property>
-                                <property name="position">0</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkRadioButton" id="radiobutton_contact_list_sort_by_state">
-                                <property name="label" translatable="yes">Sort by s_tate</property>
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="receives_default">False</property>
-                                <property name="use_underline">True</property>
-                                <property name="draw_indicator">True</property>
-                                <property name="group">radiobutton_contact_list_sort_by_name</property>
-                              </object>
-                              <packing>
-                                <property name="expand">False</property>
-                                <property name="fill">False</property>
-                                <property name="position">1</property>
-                              </packing>
-                            </child>
-                          </object>
-                        </child>
-                      </object>
-                    </child>
-                    <child type="label">
-                      <object class="GtkLabel" id="label644">
-                        <property name="visible">True</property>
-                        <property name="label" translatable="yes">Contact List</property>
-                        <attributes>
-                          <attribute name="weight" value="bold"/>
-                        </attributes>
-                      </object>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="position">2</property>
-                  </packing>
-                </child>
               </object>
             </child>
             <child type="tab">