changeset 1398:f6b0cf1f4c3b

[gaim-migrate @ 1408] yay, right-click menus in chat committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Tue, 09 Jan 2001 10:03:48 +0000
parents d2799e0672ee
children 51620cc6ec4b
files src/buddy_chat.c src/conversation.c
diffstat 2 files changed, 66 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/buddy_chat.c	Tue Jan 09 09:37:01 2001 +0000
+++ b/src/buddy_chat.c	Tue Jan 09 10:03:48 2001 +0000
@@ -433,6 +433,67 @@
 	}
 }
 
+static void chat_press_im(GtkObject *obj, struct conversation *b)
+{
+	struct conversation *c;
+
+	c = find_conversation(gtk_object_get_user_data(obj));
+
+	if (c != NULL)
+		gdk_window_show(c->window->window);
+	else {
+		c = new_conversation(gtk_object_get_user_data(obj));
+		c->gc = b->gc;
+		gtk_option_menu_set_history(GTK_OPTION_MENU(c->menu), g_slist_index(connections, b->gc));
+		update_buttons_by_protocol(c);
+	}
+}
+
+static void chat_press_ign(GtkWidget *obj, struct conversation *b)
+{
+	gtk_list_select_child(GTK_LIST(b->list), gtk_object_get_user_data(GTK_OBJECT(obj)));
+	ignore_callback(obj, b);
+}
+
+static void chat_press_info(GtkObject *obj, struct conversation *b)
+{
+	(*b->gc->prpl->get_info)(b->gc, gtk_object_get_user_data(obj));
+}
+
+static gint right_click_chat(GtkObject *obj, GdkEventButton *event, struct conversation *b)
+{
+	if (event->button == 3 && event->type == GDK_BUTTON_PRESS) {
+		GtkWidget *menu;
+		GtkWidget *button;
+
+		menu = gtk_menu_new();
+
+		button = gtk_menu_item_new_with_label(_("IM"));
+		gtk_signal_connect(GTK_OBJECT(button), "activate", GTK_SIGNAL_FUNC(chat_press_im), b);
+		gtk_object_set_user_data(GTK_OBJECT(button), gtk_object_get_user_data(obj));
+		gtk_menu_append(GTK_MENU(menu), button);
+		gtk_widget_show(button);
+
+		button = gtk_menu_item_new_with_label(_("Ignore"));
+		gtk_signal_connect(GTK_OBJECT(button), "activate", GTK_SIGNAL_FUNC(chat_press_ign), b);
+		gtk_object_set_user_data(GTK_OBJECT(button), obj);
+		gtk_menu_append(GTK_MENU(menu), button);
+		gtk_widget_show(button);
+
+		if (b->gc->prpl->get_info) {
+			button = gtk_menu_item_new_with_label(_("Info"));
+			gtk_signal_connect(GTK_OBJECT(button), "activate",
+					   GTK_SIGNAL_FUNC(chat_press_info), b);
+			gtk_object_set_user_data(GTK_OBJECT(button), gtk_object_get_user_data(obj));
+			gtk_menu_append(GTK_MENU(menu), button);
+			gtk_widget_show(button);
+		}
+
+		gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, event->button, event->time);
+		return TRUE;
+	}
+	return TRUE;
+}
 
 void add_chat_buddy(struct conversation *b, char *buddy)
 {
@@ -460,6 +521,8 @@
 		list_item = gtk_list_item_new_with_label(name);
 
 	gtk_object_set_user_data(GTK_OBJECT(list_item), name);
+	gtk_signal_connect(GTK_OBJECT(list_item), "button_press_event",
+			   GTK_SIGNAL_FUNC(right_click_chat), b);
 	gtk_list_insert_items(GTK_LIST(b->list), g_list_append(NULL, list_item), pos);
 	gtk_widget_show(list_item);
 
--- a/src/conversation.c	Tue Jan 09 09:37:01 2001 +0000
+++ b/src/conversation.c	Tue Jan 09 10:03:48 2001 +0000
@@ -1753,7 +1753,7 @@
 	
 	if (c->gc->prpl->set_info == NULL && c->info)
 		gtk_widget_set_sensitive(c->info, FALSE);
-	else
+	else if (c->info)
 		gtk_widget_set_sensitive(c->info, TRUE);
 
 	if (c->gc->prpl->send_im == NULL && c->send)
@@ -1763,12 +1763,12 @@
 
 	if (c->gc->prpl->warn == NULL && c->warn)
 		gtk_widget_set_sensitive(c->warn, FALSE);
-	else
+	else if (c->warn)
 		gtk_widget_set_sensitive(c->warn, TRUE);
 
 	if (c->gc->prpl->add_permit == NULL && c->block)
 		gtk_widget_set_sensitive(c->block, FALSE);
-	else
+	else if (c->block)
 		gtk_widget_set_sensitive(c->block, TRUE);
 
 	if (c->add)