empathy r2021 - in trunk: data libempathy-gtk src



Author: xclaesse
Date: Tue Jan  6 16:45:47 2009
New Revision: 2021
URL: http://svn.gnome.org/viewvc/empathy?rev=2021&view=rev

Log:
Create an UI for sound configuration.

Modified:
   trunk/data/empathy.schemas.in
   trunk/libempathy-gtk/empathy-conf.h
   trunk/src/empathy-preferences.c
   trunk/src/empathy-preferences.glade

Modified: trunk/data/empathy.schemas.in
==============================================================================
--- trunk/data/empathy.schemas.in	(original)
+++ trunk/data/empathy.schemas.in	Tue Jan  6 16:45:47 2009
@@ -89,43 +89,129 @@
     </schema>
 
     <schema>
-      <key>/schemas/apps/empathy/notifications/play_sounds</key>
-      <applyto>/apps/empathy/notifications/play_sounds</applyto>
+      <key>/schemas/apps/empathy/sounds/sounds_enabled</key>
+      <applyto>/apps/empathy/sounds/sounds_enabled</applyto>
       <owner>empathy</owner>
       <type>bool</type>
       <default>true</default>
       <locale name="C">
          <short>Use notification sounds</short>
          <long>
-         Whether or not to play a sound when messages arrive.
+         Whether or not to play a sound to notify for events.
          </long>
       </locale>
     </schema>
 
     <schema>
-      <key>/schemas/apps/empathy/notifications/sound_when_away</key>
-      <applyto>/apps/empathy/notifications/sound_when_away</applyto>
+      <key>/schemas/apps/empathy/sounds/sounds_disabled_away</key>
+      <applyto>/apps/empathy/sounds/sounds_disabled_away</applyto>
+      <owner>empathy</owner>
+      <type>bool</type>
+      <default>true</default>
+      <locale name="C">
+         <short>Disable sounds when away</short>
+         <long>
+         Whether or not to play a sound notifications when away or busy.
+         </long>
+      </locale>
+    </schema>
+
+    <schema>
+      <key>/schemas/apps/empathy/sounds/sounds_incoming_message</key>
+      <applyto>/apps/empathy/sounds/sounds_incoming_message</applyto>
+      <owner>empathy</owner>
+      <type>bool</type>
+      <default>true</default>
+      <locale name="C">
+         <short>Play a sound for incoming messages</short>
+         <long>
+         Whether or not to play a sound to notify for incoming messages.
+         </long>
+      </locale>
+    </schema>
+
+    <schema>
+      <key>/schemas/apps/empathy/sounds/sounds_outgoing_message</key>
+      <applyto>/apps/empathy/sounds/sounds_outgoing_message</applyto>
       <owner>empathy</owner>
       <type>bool</type>
       <default>false</default>
       <locale name="C">
-         <short>Enable sound when away</short>
+         <short>Play a sound for outgoing messages</short>
+         <long>
+         Whether or not to play a sound to notify for outgoing messages.
+         </long>
+      </locale>
+    </schema>
+
+    <schema>
+      <key>/schemas/apps/empathy/sounds/sounds_new_conversation</key>
+      <applyto>/apps/empathy/sounds/sounds_new_conversation</applyto>
+      <owner>empathy</owner>
+      <type>bool</type>
+      <default>true</default>
+      <locale name="C">
+         <short>Play a sound for new conversations</short>
          <long>
-         Whether or not to play sounds when away.
+         Whether or not to play a sound to notify for new conversations.
          </long>
       </locale>
     </schema>
 
     <schema>
-      <key>/schemas/apps/empathy/notifications/sound_when_busy</key>
-      <applyto>/apps/empathy/notifications/sound_when_busy</applyto>
+      <key>/schemas/apps/empathy/sounds/sounds_contact_login</key>
+      <applyto>/apps/empathy/sounds/sounds_contact_login/applyto>
       <owner>empathy</owner>
       <type>bool</type>
       <default>true</default>
       <locale name="C">
-         <short>Enable sound when busy</short>
+         <short>Play a sound when a contact logs in</short>
+         <long>
+         Whether or not to play a sound to notify for contacts logging in the
+         network.
+         </long>
+      </locale>
+    </schema>
+    
+    <schema>
+      <key>/schemas/apps/empathy/sounds/sounds_contact_logout</key>
+      <applyto>/apps/empathy/sounds/sounds_contact_logout/applyto>
+      <owner>empathy</owner>
+      <type>bool</type>
+      <default>true</default>
+      <locale name="C">
+         <short>Play a sound when a contact logs out</short>
+         <long>
+         Whether or not to play a sound to notify for contacts logging off the
+         network.
+         </long>
+      </locale>
+    </schema>
+
+    <schema>
+      <key>/schemas/apps/empathy/sounds/sounds_service_login</key>
+      <applyto>/apps/empathy/sounds/sounds_service_login/applyto>
+      <owner>empathy</owner>
+      <type>bool</type>
+      <default>false</default>
+      <locale name="C">
+         <short>Play a sound when we log in</short>
+         <long>
+         Whether or not to play a sound when logging in a network.
+         </long>
+      </locale>
+    </schema>
+    
+    <schema>
+      <key>/schemas/apps/empathy/sounds/sounds_service_logout</key>
+      <applyto>/apps/empathy/sounds/sounds_service_logout/applyto>
+      <owner>empathy</owner>
+      <type>bool</type>
+      <default>false</default>
+      <locale name="C">
+         <short>Play a sound when we log out</short>
          <long>
-         Whether or not to play sounds when busy.
+         Whether or not to play a sound when logging off a network.
          </long>
       </locale>
     </schema>

Modified: trunk/libempathy-gtk/empathy-conf.h
==============================================================================
--- trunk/libempathy-gtk/empathy-conf.h	(original)
+++ trunk/libempathy-gtk/empathy-conf.h	Tue Jan  6 16:45:47 2009
@@ -45,9 +45,15 @@
 };
 
 #define EMPATHY_PREFS_PATH "/apps/empathy"
-#define EMPATHY_PREFS_SOUNDS_FOR_MESSAGES          EMPATHY_PREFS_PATH "/notifications/sounds_for_messages"
-#define EMPATHY_PREFS_SOUNDS_WHEN_AWAY             EMPATHY_PREFS_PATH "/notifications/sounds_when_away"
-#define EMPATHY_PREFS_SOUNDS_WHEN_BUSY             EMPATHY_PREFS_PATH "/notifications/sounds_when_busy"
+#define EMPATHY_PREFS_SOUNDS_ENABLED               EMPATHY_PREFS_PATH "/sounds/sounds_enabled"
+#define EMPATHY_PREFS_SOUNDS_DISABLED_AWAY         EMPATHY_PREFS_PATH "/sounds/sounds_disabled_away"
+#define EMPATHY_PREFS_SOUNDS_INCOMING_MESSAGE      EMPATHY_PREFS_PATH "/sounds/sounds_incoming_message"
+#define EMPATHY_PREFS_SOUNDS_OUTGOING_MESSAGE      EMPATHY_PREFS_PATH "/sounds/sounds_outgoing_message"
+#define EMPATHY_PREFS_SOUNDS_NEW_CONVERSATION      EMPATHY_PREFS_PATH "/sounds/sounds_new_conversation"
+#define EMPATHY_PREFS_SOUNDS_SERVICE_LOGIN         EMPATHY_PREFS_PATH "/sounds/sounds_service_login"
+#define EMPATHY_PREFS_SOUNDS_SERVICE_LOGOUT        EMPATHY_PREFS_PATH "/sounds/sounds_service_logout"
+#define EMPATHY_PREFS_SOUNDS_CONTACT_LOGIN         EMPATHY_PREFS_PATH "/sounds/sounds_contact_login"
+#define EMPATHY_PREFS_SOUNDS_CONTACT_LOGOUT        EMPATHY_PREFS_PATH "/sounds/sounds_contact_logout"
 #define EMPATHY_PREFS_POPUPS_WHEN_AVAILABLE        EMPATHY_PREFS_PATH "/notifications/popups_when_available"
 #define EMPATHY_PREFS_CHAT_SHOW_SMILEYS            EMPATHY_PREFS_PATH "/conversation/graphical_smileys"
 #define EMPATHY_PREFS_CHAT_THEME                   EMPATHY_PREFS_PATH "/conversation/theme"

Modified: trunk/src/empathy-preferences.c
==============================================================================
--- trunk/src/empathy-preferences.c	(original)
+++ trunk/src/empathy-preferences.c	Tue Jan  6 16:45:47 2009
@@ -55,10 +55,9 @@
 	GtkWidget *radiobutton_contact_list_sort_by_name;
 	GtkWidget *radiobutton_contact_list_sort_by_state;
 
-	GtkWidget *checkbutton_sounds_for_messages;
-	GtkWidget *checkbutton_sounds_when_busy;
-	GtkWidget *checkbutton_sounds_when_away;
-	GtkWidget *checkbutton_popups_when_available;
+	GtkWidget *checkbutton_sounds_enabled;
+	GtkWidget *checkbutton_sounds_disabled_away;
+	GtkWidget *treeview_sounds;
 
 	GtkWidget *treeview_spell_checker;
 
@@ -137,6 +136,29 @@
 	COL_COMBO_COUNT
 };
 
+enum {
+	COL_SOUND_ENABLED,
+	COL_SOUND_NAME,
+	COL_SOUND_KEY,
+	COL_SOUND_COUNT
+};
+
+typedef struct {
+	const char *name;
+	const char *key;
+} SoundEventEntry;
+
+/* TODO: add phone related sounds also? */
+static SoundEventEntry sound_entries [] = {
+	{ N_("Message received"), EMPATHY_PREFS_SOUNDS_INCOMING_MESSAGE },
+	{ N_("Message sent"), EMPATHY_PREFS_SOUNDS_OUTGOING_MESSAGE },
+	{ N_("New conversation"), EMPATHY_PREFS_SOUNDS_NEW_CONVERSATION },
+	{ N_("Contact logs in"), EMPATHY_PREFS_SOUNDS_CONTACT_LOGIN },
+	{ N_("Contact logs out"), EMPATHY_PREFS_SOUNDS_CONTACT_LOGOUT },
+	{ N_("Logging in a network"), EMPATHY_PREFS_SOUNDS_SERVICE_LOGIN },
+	{ N_("Logging off a network"), EMPATHY_PREFS_SOUNDS_SERVICE_LOGOUT }
+};
+
 static void
 preferences_add_id (EmpathyPreferences *preferences, guint id)
 {
@@ -164,24 +186,18 @@
 	guint id;
 
 	preferences_hookup_toggle_button (preferences,
-					  EMPATHY_PREFS_SOUNDS_FOR_MESSAGES,
-					  preferences->checkbutton_sounds_for_messages);
-	preferences_hookup_toggle_button (preferences,
-					  EMPATHY_PREFS_SOUNDS_WHEN_AWAY,
-					  preferences->checkbutton_sounds_when_away);
+					  EMPATHY_PREFS_SOUNDS_ENABLED,
+					  preferences->checkbutton_sounds_enabled);
 	preferences_hookup_toggle_button (preferences,
-					  EMPATHY_PREFS_SOUNDS_WHEN_BUSY,
-					  preferences->checkbutton_sounds_when_busy);
-	preferences_hookup_toggle_button (preferences,
-					  EMPATHY_PREFS_POPUPS_WHEN_AVAILABLE,
-					  preferences->checkbutton_popups_when_available);
+					  EMPATHY_PREFS_SOUNDS_DISABLED_AWAY,
+					  preferences->checkbutton_sounds_disabled_away);
 
 	preferences_hookup_sensitivity (preferences,
-					EMPATHY_PREFS_SOUNDS_FOR_MESSAGES,
-					preferences->checkbutton_sounds_when_away);
+					EMPATHY_PREFS_SOUNDS_ENABLED,
+					preferences->checkbutton_sounds_disabled_away);
 	preferences_hookup_sensitivity (preferences,
-					EMPATHY_PREFS_SOUNDS_FOR_MESSAGES,
-					preferences->checkbutton_sounds_when_busy);
+					EMPATHY_PREFS_SOUNDS_ENABLED,
+					preferences->treeview_sounds);
 
 	preferences_hookup_toggle_button (preferences,
 					  EMPATHY_PREFS_UI_SEPARATE_CHAT_WINDOWS,
@@ -224,6 +240,102 @@
 }
 
 static void
+preferences_sound_cell_toggled_cb (GtkCellRendererToggle *toggle,
+				   char *path_string,
+				   EmpathyPreferences *preferences)
+{
+	GtkTreePath *path;
+	gboolean toggled, instore;
+	GtkTreeIter iter;
+	GtkTreeView *view;
+	GtkTreeModel *model;
+	char *key;
+
+	view = GTK_TREE_VIEW (preferences->treeview_sounds);
+	model = gtk_tree_view_get_model (view);
+
+	path = gtk_tree_path_new_from_string (path_string);
+	toggled = gtk_cell_renderer_toggle_get_active (toggle);
+
+	gtk_tree_model_get_iter (model, &iter, path);
+	gtk_tree_model_get (model, &iter, COL_SOUND_KEY, &key,
+			    COL_SOUND_ENABLED, &instore, -1);
+
+	instore ^= 1;
+
+	gtk_list_store_set (GTK_LIST_STORE (model), &iter,
+			    COL_SOUND_ENABLED, instore, -1);
+
+	empathy_conf_set_bool (empathy_conf_get (), key, instore);
+
+	gtk_tree_path_free (path);
+}
+
+static void
+preferences_sound_load (EmpathyPreferences *preferences)
+{
+	int i;
+	GtkTreeView *view;
+	GtkListStore *store;
+	GtkTreeIter iter;
+	gboolean set;
+	EmpathyConf *conf;
+
+	view = GTK_TREE_VIEW (preferences->treeview_sounds);
+	store = GTK_LIST_STORE (gtk_tree_view_get_model (view));
+	conf = empathy_conf_get ();
+
+	for (i = 0; i < G_N_ELEMENTS (sound_entries); i++) {
+		empathy_conf_get_bool (conf, sound_entries[i].key, &set);
+
+		gtk_list_store_append (store, &iter);
+		gtk_list_store_set (store, &iter, COL_SOUND_ENABLED, set,
+				    COL_SOUND_NAME, sound_entries[i].name,
+				    COL_SOUND_KEY, sound_entries[i].key, -1);
+	}
+}
+
+static void
+preferences_sound_setup (EmpathyPreferences *preferences)
+{
+	GtkTreeView *view;
+	GtkListStore *store;
+	GtkCellRenderer *renderer;
+	GtkTreeViewColumn *column;
+
+	view = GTK_TREE_VIEW (preferences->treeview_sounds);
+
+	store = gtk_list_store_new (COL_SOUND_COUNT,
+				    G_TYPE_BOOLEAN, /* enabled */
+				    G_TYPE_STRING,  /* name */
+				    G_TYPE_STRING); /* key */
+
+	gtk_tree_view_set_model (view, GTK_TREE_MODEL (store));
+
+	renderer = gtk_cell_renderer_toggle_new ();
+	g_signal_connect (renderer, "toggled",
+			  G_CALLBACK (preferences_sound_cell_toggled_cb),
+			  preferences);
+
+	column = gtk_tree_view_column_new ();
+	gtk_tree_view_column_pack_start (column, renderer, FALSE);
+	gtk_tree_view_column_add_attribute (column, renderer,
+					    "active", COL_SOUND_ENABLED);
+
+	renderer = gtk_cell_renderer_text_new ();
+	gtk_tree_view_column_pack_start (column, renderer, FALSE);
+	gtk_tree_view_column_add_attribute (column, renderer,
+					    "text", COL_SOUND_NAME);
+
+	gtk_tree_view_append_column (view, column);
+
+	gtk_tree_view_column_set_resizable (column, FALSE);
+	gtk_tree_view_column_set_clickable (GTK_TREE_VIEW_COLUMN (column), TRUE);
+
+	g_object_unref (store);
+}
+
+static void
 preferences_languages_setup (EmpathyPreferences *preferences)
 {
 	GtkTreeView       *view;
@@ -949,10 +1061,9 @@
 		"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_sounds_for_messages", &preferences->checkbutton_sounds_for_messages,
-		"checkbutton_sounds_when_busy", &preferences->checkbutton_sounds_when_busy,
-		"checkbutton_sounds_when_away", &preferences->checkbutton_sounds_when_away,
-		"checkbutton_popups_when_available", &preferences->checkbutton_popups_when_available,
+		"checkbutton_sounds_enabled", &preferences->checkbutton_sounds_enabled,
+		"checkbutton_sounds_disabled_away", &preferences->checkbutton_sounds_disabled_away,
+		"treeview_sounds", &preferences->treeview_sounds,
 		"treeview_spell_checker", &preferences->treeview_spell_checker,
 		NULL);
 	g_free (filename);
@@ -975,6 +1086,9 @@
 	preferences_languages_add (preferences);
 	preferences_languages_load (preferences);
 
+	preferences_sound_setup (preferences);
+	preferences_sound_load (preferences);
+
 	if (empathy_spell_supported ()) {
 		GtkWidget *page;
 

Modified: trunk/src/empathy-preferences.glade
==============================================================================
--- trunk/src/empathy-preferences.glade	(original)
+++ trunk/src/empathy-preferences.glade	Tue Jan  6 16:45:47 2009
@@ -243,120 +243,94 @@
             </child>
             <child>
               <widget class="GtkVBox" id="outer_vbox">
+                <property name="visible">True</property>
                 <property name="border_width">12</property>
                 <property name="spacing">18</property>
                 <child>
-                  <widget class="GtkFrame" id="frame5">
-                    <property name="label_xalign">0</property>
-                    <property name="shadow_type">GTK_SHADOW_NONE</property>
+                  <widget class="GtkVBox" id="vbox219">
+                    <property name="visible">True</property>
+                    <property name="spacing">6</property>
                     <child>
-                      <widget class="GtkAlignment" id="alignment13">
+                      <widget class="GtkCheckButton" id="checkbutton_sounds_enabled">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="label" translatable="yes">_Enable sound notifications</property>
+                        <property name="use_underline">True</property>
+                        <property name="response_id">0</property>
+                        <property name="draw_indicator">True</property>
+                      </widget>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <widget class="GtkAlignment" id="alignment32">
                         <property name="visible">True</property>
-                        <property name="top_padding">6</property>
                         <property name="left_padding">12</property>
                         <child>
-                          <widget class="GtkVBox" id="vbox106">
+                          <widget class="GtkCheckButton" id="checkbutton_sounds_disabled_away">
                             <property name="visible">True</property>
-                            <property name="spacing">6</property>
-                            <child>
-                              <widget class="GtkCheckButton" id="checkbutton_sounds_for_messages">
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="label" translatable="yes">_Play sound when messages arrive</property>
-                                <property name="use_underline">True</property>
-                                <property name="response_id">0</property>
-                                <property name="draw_indicator">True</property>
-                              </widget>
-                              <packing>
-                                <property name="expand">False</property>
-                                <property name="fill">False</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <widget class="GtkCheckButton" id="checkbutton_sounds_when_busy">
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="label" translatable="yes">Enable sounds when _busy</property>
-                                <property name="use_underline">True</property>
-                                <property name="response_id">0</property>
-                                <property name="draw_indicator">True</property>
-                              </widget>
-                              <packing>
-                                <property name="expand">False</property>
-                                <property name="fill">False</property>
-                                <property name="position">1</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <widget class="GtkCheckButton" id="checkbutton_sounds_when_away">
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="label" translatable="yes">Enable sounds when _away</property>
-                                <property name="use_underline">True</property>
-                                <property name="response_id">0</property>
-                                <property name="draw_indicator">True</property>
-                              </widget>
-                              <packing>
-                                <property name="expand">False</property>
-                                <property name="fill">False</property>
-                                <property name="position">2</property>
-                              </packing>
-                            </child>
+                            <property name="can_focus">True</property>
+                            <property name="label" translatable="yes">Disable sounds when _away or busy</property>
+                            <property name="use_underline">True</property>
+                            <property name="response_id">0</property>
+                            <property name="draw_indicator">True</property>
                           </widget>
                         </child>
                       </widget>
-                    </child>
-                    <child>
-                      <widget class="GtkLabel" id="label613">
-                        <property name="visible">True</property>
-                        <property name="label" translatable="yes" comments="To translators: Audio notifications preferences">&lt;b&gt;Audio&lt;/b&gt;</property>
-                        <property name="use_markup">True</property>
-                      </widget>
                       <packing>
-                        <property name="type">label_item</property>
+                        <property name="position">1</property>
                       </packing>
                     </child>
                   </widget>
                   <packing>
                     <property name="expand">False</property>
-                    <property name="fill">False</property>
                   </packing>
                 </child>
                 <child>
-                  <widget class="GtkFrame" id="frame6">
-                    <property name="label_xalign">0</property>
-                    <property name="shadow_type">GTK_SHADOW_NONE</property>
+                  <widget class="GtkVBox" id="vbox221">
+                    <property name="visible">True</property>
+                    <property name="spacing">6</property>
                     <child>
-                      <widget class="GtkAlignment" id="alignment14">
+                      <widget class="GtkLabel" id="label645">
+                        <property name="visible">True</property>
+                        <property name="xalign">0</property>
+                        <property name="label" translatable="yes">&lt;b&gt;Play sound for events&lt;/b&gt;</property>
+                        <property name="use_markup">True</property>
+                      </widget>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <widget class="GtkAlignment" id="alignment33">
                         <property name="visible">True</property>
-                        <property name="top_padding">6</property>
                         <property name="left_padding">12</property>
                         <child>
-                          <widget class="GtkCheckButton" id="checkbutton_popups_when_available">
+                          <widget class="GtkScrolledWindow" id="scrolledwindow19">
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
-                            <property name="label" translatable="yes">Display notifications when contacts come _online</property>
-                            <property name="use_underline">True</property>
-                            <property name="response_id">0</property>
-                            <property name="draw_indicator">True</property>
+                            <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+                            <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+                            <property name="shadow_type">GTK_SHADOW_IN</property>
+                            <child>
+                              <widget class="GtkTreeView" id="treeview_sounds">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="headers_visible">False</property>
+                              </widget>
+                            </child>
                           </widget>
                         </child>
                       </widget>
-                    </child>
-                    <child>
-                      <widget class="GtkLabel" id="label614">
-                        <property name="visible">True</property>
-                        <property name="label" translatable="yes" comments="To translators: Visual notifications preferences, like notify bubbles, etc.">&lt;b&gt;Visual&lt;/b&gt;</property>
-                        <property name="use_markup">True</property>
-                      </widget>
                       <packing>
-                        <property name="type">label_item</property>
+                        <property name="position">1</property>
                       </packing>
                     </child>
                   </widget>
                   <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">False</property>
                     <property name="position">1</property>
                   </packing>
                 </child>
@@ -368,7 +342,7 @@
             <child>
               <widget class="GtkLabel" id="label607">
                 <property name="visible">True</property>
-                <property name="label" translatable="yes">Notifications</property>
+                <property name="label" translatable="yes">Sounds</property>
               </widget>
               <packing>
                 <property name="type">tab</property>
@@ -378,6 +352,7 @@
             </child>
             <child>
               <widget class="GtkVBox" id="vbox168">
+                <property name="visible">True</property>
                 <property name="border_width">12</property>
                 <property name="spacing">18</property>
                 <child>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]