changeset 15425:c9497aad9fc4

Warmenhoved patch #1397916: "Turns Block button in conv menu into Unblock after blocking" from Glauber de Oliveira Costa (glommer). You know the drill.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sat, 27 Jan 2007 17:46:52 +0000
parents acc8a838ad94
children 7865f302c5fb a415922e2882
files pidgin/gaimstock.c pidgin/gaimstock.h pidgin/gtkconv.c pidgin/gtkconvwin.h pidgin/gtkprivacy.c
diffstat 5 files changed, 45 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/gaimstock.c	Sat Jan 27 16:40:21 2007 +0000
+++ b/pidgin/gaimstock.c	Sat Jan 27 17:46:52 2007 +0000
@@ -46,6 +46,7 @@
 #endif
 	{ GAIM_STOCK_BGCOLOR,         "buttons", "change-bgcolor-small.png" },
 	{ GAIM_STOCK_BLOCK,           NULL,      GTK_STOCK_STOP             },
+	{ GAIM_STOCK_UNBLOCK,         NULL,      GTK_STOCK_STOP /* XXX: */  },
 	{ GAIM_STOCK_CHAT,            NULL,      GTK_STOCK_JUMP_TO          },
 	{ GAIM_STOCK_CLEAR,           NULL,      GTK_STOCK_CLEAR            },
 	{ GAIM_STOCK_CLOSE_TABS,      NULL,      GTK_STOCK_CLOSE            },
--- a/pidgin/gaimstock.h	Sat Jan 27 16:40:21 2007 +0000
+++ b/pidgin/gaimstock.h	Sat Jan 27 17:46:52 2007 +0000
@@ -38,6 +38,7 @@
 #define GAIM_STOCK_AWAY            "gaim-away"
 #define GAIM_STOCK_BGCOLOR         "gaim-bgcolor"
 #define GAIM_STOCK_BLOCK           "gaim-block"
+#define GAIM_STOCK_UNBLOCK         "gaim-unblock"
 #define GAIM_STOCK_CHAT            "gaim-chat"
 #define GAIM_STOCK_CLEAR           "gaim-clear"
 #define GAIM_STOCK_CLOSE_TABS      "gaim-close-tab"
--- a/pidgin/gtkconv.c	Sat Jan 27 16:40:21 2007 +0000
+++ b/pidgin/gtkconv.c	Sat Jan 27 17:46:52 2007 +0000
@@ -712,6 +712,20 @@
 }
 
 static void
+unblock_cb(GtkWidget *widget, GaimGtkConversation *gtkconv)
+{
+	GaimConversation *conv = gtkconv->active_conv;
+	GaimAccount *account;
+
+	account = gaim_conversation_get_account(conv);
+
+	if (account != NULL && gaim_account_is_connected(account))
+		gaim_gtk_request_add_permit(account, gaim_conversation_get_name(conv));
+
+	gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry);
+}
+
+static void
 do_invite(GtkWidget *w, int resp, InviteBuddyInfo *info)
 {
 	const char *buddy, *message;
@@ -1297,6 +1311,17 @@
 }
 
 static void
+menu_unblock_cb(gpointer data, guint action, GtkWidget *widget)
+{
+	GaimGtkWindow *win = data;
+	GaimConversation *conv;
+
+	conv = gaim_gtk_conv_window_get_active_conversation(win);
+
+	unblock_cb(NULL, GAIM_GTK_CONVERSATION(conv));
+}
+
+static void
 menu_add_remove_cb(gpointer data, guint action, GtkWidget *widget)
 {
 	GaimGtkWindow *win = data;
@@ -2735,6 +2760,8 @@
 			"<StockItem>", GAIM_STOCK_EDIT },
 	{ N_("/Conversation/_Block..."), NULL, menu_block_cb, 0,
 			"<StockItem>", GAIM_STOCK_BLOCK },
+	{ N_("/Conversation/_Unblock..."), NULL, menu_unblock_cb, 0,
+			"<StockItem>", GAIM_STOCK_UNBLOCK },
 	{ N_("/Conversation/_Add..."), NULL, menu_add_remove_cb, 0,
 			"<StockItem>", GTK_STOCK_ADD },
 	{ N_("/Conversation/_Remove..."), NULL, menu_add_remove_cb, 0,
@@ -2951,6 +2978,10 @@
 		gtk_item_factory_get_widget(win->menu.item_factory,
 		                            N_("/Conversation/Block..."));
 
+	win->menu.unblock = 
+		gtk_item_factory_get_widget(win->menu.item_factory,
+					    N_("/Conversation/Unblock..."));
+	
 	win->menu.add =
 		gtk_item_factory_get_widget(win->menu.item_factory,
 		                            N_("/Conversation/Add..."));
@@ -5627,7 +5658,13 @@
 		gtk_widget_show(win->menu.get_info);
 		gtk_widget_hide(win->menu.invite);
 		gtk_widget_show(win->menu.alias);
-		gtk_widget_show(win->menu.block);
+ 		if (gaim_privacy_check(account, gaim_conversation_get_name(conv))) {
+ 			gtk_widget_hide(win->menu.unblock);
+ 			gtk_widget_show(win->menu.block);
+ 		} else {
+ 			gtk_widget_hide(win->menu.block);
+ 			gtk_widget_show(win->menu.unblock);
+ 		}
 
 		if ((account == NULL) || gaim_find_buddy(account, gaim_conversation_get_name(conv)) == NULL) {
 			gtk_widget_show(win->menu.add);
@@ -6574,10 +6611,9 @@
 	GaimConversation *conv;
 
 	gtkconv = get_gtkconv_with_contact(gaim_buddy_get_contact(buddy));
-	if (gtkconv)
-	{
+	if (gtkconv) {
 		conv = gtkconv->active_conv;
-		gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_TAB_ICON);
+		gaim_gtkconv_update_fields(conv, GAIM_GTKCONV_TAB_ICON | GAIM_GTKCONV_MENU);
 	}
 }
 
--- a/pidgin/gtkconvwin.h	Sat Jan 27 16:40:21 2007 +0000
+++ b/pidgin/gtkconvwin.h	Sat Jan 27 17:46:52 2007 +0000
@@ -56,6 +56,7 @@
 
 		GtkWidget *alias;
 		GtkWidget *block;
+		GtkWidget *unblock;
 		GtkWidget *add;
 		GtkWidget *remove;
 
--- a/pidgin/gtkprivacy.c	Sat Jan 27 16:40:21 2007 +0000
+++ b/pidgin/gtkprivacy.c	Sat Jan 27 17:46:52 2007 +0000
@@ -529,9 +529,9 @@
 confirm_permit_block_cb(GaimGtkPrivacyRequestData *data, int option)
 {
 	if (data->block)
-		gaim_privacy_deny_add(data->account, data->name, FALSE);
+		gaim_privacy_deny(data->account, data->name, FALSE, FALSE);
 	else
-		gaim_privacy_permit_add(data->account, data->name, FALSE);
+		gaim_privacy_allow(data->account, data->name, FALSE, FALSE);
 
 	destroy_request_data(data);
 }