pidgin: afbef523: Make it more obvious that there is a def...

nosnilmot at pidgin.im nosnilmot at pidgin.im
Fri May 23 09:15:49 EDT 2008


-----------------------------------------------------------------
Revision: afbef523e127d8e222553204fc5093e6506d1155
Ancestor: 05cdb341d2bf5165ab95cc42e52750624f0a7ad9
Author: nosnilmot at pidgin.im
Date: 2008-05-23T13:03:18
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/afbef523e127d8e222553204fc5093e6506d1155

Modified files:
        pidgin/gtkpounce.c

ChangeLog: 

Make it more obvious that there is a default buddy pounce sound, and
un-mute sounds when testing the sound, just like in preferences.
Fixes #5798

-------------- next part --------------
============================================================
--- pidgin/gtkpounce.c	ff2f34b63f822c3e191e457237abd474891aa099
+++ pidgin/gtkpounce.c	e98a23f67301eb38b1a4bbf8e767d9d5a52bd604
@@ -100,6 +100,7 @@ typedef struct
 	GtkWidget *play_sound_entry;
 	GtkWidget *play_sound_browse;
 	GtkWidget *play_sound_test;
+	GtkWidget *play_sound_reset;
 
 	GtkWidget *save_pounce;
 
@@ -166,16 +167,29 @@ pounce_test_sound(GtkWidget *w, GtkWidge
 pounce_test_sound(GtkWidget *w, GtkWidget *entry)
 {
 	const char *filename;
+	gboolean temp_mute;
 
+	temp_mute = purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/sound/mute");
+
+	if (temp_mute) purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/sound/mute", FALSE);
+
 	filename = gtk_entry_get_text(GTK_ENTRY(entry));
 
-	if (filename != NULL && *filename != '\0')
+	if (filename != NULL && *filename != '\0' && strcmp(filename, _("(default)")))
 		purple_sound_play_file(filename, NULL);
 	else
 		purple_sound_play_event(PURPLE_SOUND_POUNCE_DEFAULT, NULL);
+
+	if (temp_mute) purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/sound/mute", TRUE);
 }
 
 static void
+pounce_reset_sound(GtkWidget *w, GtkWidget *entry)
+{
+	gtk_entry_set_text(GTK_ENTRY(entry), _("(default)"));
+}
+
+static void
 add_pounce_to_treeview(GtkListStore *model, PurplePounce *pounce)
 {
 	GtkTreeIter iter;
@@ -304,7 +318,7 @@ save_pounce_cb(GtkWidget *w, PidginPounc
 		message = NULL;
 	}
 	if (*command == '\0') command = NULL;
-	if (*sound   == '\0') sound   = NULL;
+	if (*sound   == '\0' || !strcmp(sound, _("(default)"))) sound   = NULL;
 
 	/* If the pounce has already been triggered, let's pretend it is a new one */
 	if (dialog->pounce != NULL
@@ -652,7 +666,7 @@ pidgin_pounce_editor_show(PurpleAccount 
 	/* Create the "Action" frame. */
 	frame = pidgin_make_frame(vbox2, _("Action"));
 
-	table = gtk_table_new(3, 5, FALSE);
+	table = gtk_table_new(3, 6, FALSE);
 	gtk_container_add(GTK_CONTAINER(frame), table);
 	gtk_table_set_col_spacings(GTK_TABLE(table), PIDGIN_HIG_BORDER);
 	gtk_widget_show(table);
@@ -674,8 +688,11 @@ pidgin_pounce_editor_show(PurpleAccount 
 	dialog->popup_entry       = gtk_entry_new();
 	dialog->exec_cmd_browse   = gtk_button_new_with_mnemonic(_("Brows_e..."));
 	dialog->play_sound_entry  = gtk_entry_new();
+	gtk_entry_set_text(GTK_ENTRY(dialog->play_sound_entry), _("(default)"));
+	gtk_editable_set_editable(GTK_EDITABLE(dialog->play_sound_entry), FALSE);
 	dialog->play_sound_browse = gtk_button_new_with_mnemonic(_("Br_owse..."));
 	dialog->play_sound_test   = gtk_button_new_with_mnemonic(_("Pre_view"));
+	dialog->play_sound_reset  = gtk_button_new_with_mnemonic(_("Reset"));
 
 	gtk_widget_set_sensitive(send_msg_imhtml,           FALSE);
 	gtk_widget_set_sensitive(dialog->exec_cmd_entry,    FALSE);
@@ -684,6 +701,7 @@ pidgin_pounce_editor_show(PurpleAccount 
 	gtk_widget_set_sensitive(dialog->play_sound_entry,  FALSE);
 	gtk_widget_set_sensitive(dialog->play_sound_browse, FALSE);
 	gtk_widget_set_sensitive(dialog->play_sound_test,   FALSE);
+	gtk_widget_set_sensitive(dialog->play_sound_reset,  FALSE);
 
 	g_object_unref(sg);
 
@@ -698,6 +716,7 @@ pidgin_pounce_editor_show(PurpleAccount 
 	gtk_size_group_add_widget(sg, dialog->play_sound_entry);
 	gtk_size_group_add_widget(sg, dialog->play_sound_browse);
 	gtk_size_group_add_widget(sg, dialog->play_sound_test);
+	gtk_size_group_add_widget(sg, dialog->play_sound_reset);
 
 	g_object_unref(sg);
 	sg = NULL;
@@ -706,11 +725,11 @@ pidgin_pounce_editor_show(PurpleAccount 
 					 GTK_FILL, 0, 0, 0);
 	gtk_table_attach(GTK_TABLE(table), dialog->popup,            0, 1, 1, 2,
 					 GTK_FILL, 0, 0, 0);
-	gtk_table_attach(GTK_TABLE(table), dialog->popup_entry,      1, 4, 1, 2,
+	gtk_table_attach(GTK_TABLE(table), dialog->popup_entry,      1, 5, 1, 2,
 					 GTK_FILL, 0, 0, 0);
-	gtk_table_attach(GTK_TABLE(table), dialog->send_msg,         0, 4, 2, 3,
+	gtk_table_attach(GTK_TABLE(table), dialog->send_msg,         0, 5, 2, 3,
 					 GTK_FILL, 0, 0, 0);
-	gtk_table_attach(GTK_TABLE(table), send_msg_imhtml,          0, 4, 3, 4,
+	gtk_table_attach(GTK_TABLE(table), send_msg_imhtml,          0, 5, 3, 4,
 					 GTK_FILL, 0, 0, 0);
 	gtk_table_attach(GTK_TABLE(table), dialog->exec_cmd,         0, 1, 4, 5,
 					 GTK_FILL, 0, 0, 0);
@@ -726,6 +745,8 @@ pidgin_pounce_editor_show(PurpleAccount 
 					 GTK_FILL | GTK_EXPAND, 0, 0, 0);
 	gtk_table_attach(GTK_TABLE(table), dialog->play_sound_test,  3, 4, 5, 6,
 					 GTK_FILL | GTK_EXPAND, 0, 0, 0);
+	gtk_table_attach(GTK_TABLE(table), dialog->play_sound_reset, 4, 5, 5, 6,
+					 GTK_FILL | GTK_EXPAND, 0, 0, 0);
 
 	gtk_table_set_row_spacings(GTK_TABLE(table), PIDGIN_HIG_BOX_SPACE / 2);
 
@@ -741,6 +762,7 @@ pidgin_pounce_editor_show(PurpleAccount 
 	gtk_widget_show(dialog->play_sound_entry);
 	gtk_widget_show(dialog->play_sound_browse);
 	gtk_widget_show(dialog->play_sound_test);
+	gtk_widget_show(dialog->play_sound_reset);
 
 	g_signal_connect(G_OBJECT(dialog->message_recv), "clicked",
 					 G_CALLBACK(message_recv_toggle),
@@ -771,6 +793,7 @@ pidgin_pounce_editor_show(PurpleAccount 
 	g_ptr_array_add(sound_widgets,dialog->play_sound_entry);
 	g_ptr_array_add(sound_widgets,dialog->play_sound_browse);
 	g_ptr_array_add(sound_widgets,dialog->play_sound_test);
+	g_ptr_array_add(sound_widgets,dialog->play_sound_reset);
 
 	g_signal_connect(G_OBJECT(dialog->play_sound), "clicked",
 					 G_CALLBACK(pidgin_toggle_sensitive_array),
@@ -781,6 +804,9 @@ pidgin_pounce_editor_show(PurpleAccount 
 	g_signal_connect(G_OBJECT(dialog->play_sound_test), "clicked",
 					 G_CALLBACK(pounce_test_sound),
 					 dialog->play_sound_entry);
+	g_signal_connect(G_OBJECT(dialog->play_sound_reset), "clicked",
+					 G_CALLBACK(pounce_reset_sound),
+					 dialog->play_sound_entry);
 	g_object_set_data_full(G_OBJECT(dialog->window), "sound-widgets",
 				sound_widgets, (GDestroyNotify)g_ptr_array_free);
 
@@ -795,8 +821,6 @@ pidgin_pounce_editor_show(PurpleAccount 
 					 G_CALLBACK(save_pounce_cb), dialog);
 	g_signal_connect(G_OBJECT(dialog->exec_cmd_entry), "activate",
 					 G_CALLBACK(save_pounce_cb), dialog);
-	g_signal_connect(G_OBJECT(dialog->play_sound_entry), "activate",
-					 G_CALLBACK(save_pounce_cb), dialog);
 
 	/* Create the "Options" frame. */
 	frame = pidgin_make_frame(vbox2, _("Options"));
@@ -924,7 +948,7 @@ pidgin_pounce_editor_show(PurpleAccount 
 													  "play-sound",
 													  "filename")) != NULL)
 		{
-			gtk_entry_set_text(GTK_ENTRY(dialog->play_sound_entry), value);
+			gtk_entry_set_text(GTK_ENTRY(dialog->play_sound_entry), (value && *value != '\0') ? value : _("(default)"));
 		}
 	}
 	else


More information about the Commits mailing list