changeset 915:378c862a2381

[gaim-migrate @ 925] bmiller is damn cool. he did everything i asked for, the next day even. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Fri, 15 Sep 2000 18:24:32 +0000
parents 215fe9039ae1
children e208822ed014
files src/buddy_chat.c src/conversation.c src/dialogs.c src/gaim.h src/gaimrc.c src/prefs.c src/util.c
diffstat 7 files changed, 216 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/src/buddy_chat.c	Fri Sep 15 16:51:31 2000 +0000
+++ b/src/buddy_chat.c	Fri Sep 15 18:24:32 2000 +0000
@@ -520,7 +520,7 @@
 	GtkWidget *hpaned;
 	GtkWidget *toolbar;
 
-	gboolean dispstyle;
+	int dispstyle;
 	
 	win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
 	b->window = win;
@@ -532,7 +532,7 @@
 	gtk_window_set_policy(GTK_WINDOW(win), TRUE, TRUE, TRUE);
 	gtk_widget_realize(win);
 
-	dispstyle = (display_options & OPT_DISP_CHAT_SHOW_TEXT) ? TRUE : FALSE;
+	dispstyle = set_dispstyle(1);
 
 	close = picture_button2(win, _("Close"), cancel_xpm, dispstyle);
 	
@@ -763,13 +763,13 @@
 
 }
 
-static GtkWidget *change_text(GtkWidget *win, char *text, GtkWidget *button, char **xpm, int opt)
+static GtkWidget *change_text(GtkWidget *win, char *text, GtkWidget *button, char **xpm, int chat)
 {
-	gboolean dispstyle = (display_options & opt) ? TRUE : FALSE;
+	int dispstyle = set_dispstyle(chat);
 	GtkWidget *parent = button->parent;
 	gtk_widget_destroy(button);
 	button = picture_button2(win, text, xpm, dispstyle);
-	if (opt == OPT_DISP_CHAT_SHOW_TEXT)
+	if (chat == 1)
 		gtk_box_pack_start(GTK_BOX(parent), button, dispstyle, dispstyle, 5);
 	else
 		gtk_box_pack_end(GTK_BOX(parent), button, dispstyle, dispstyle, 0);
@@ -781,7 +781,7 @@
 {
 	GList *bcs = buddy_chats;
 	struct conversation *c;
-	int opt = OPT_DISP_CHAT_SHOW_TEXT;
+	int opt = 1;
 
 	while (bcs) {
 		c = (struct conversation *)bcs->data;
@@ -803,8 +803,8 @@
 	GList *bcs = conversations;
 	struct conversation *c;
 	GtkWidget *parent;
-	int opt = OPT_DISP_CONV_SHOW_TEXT;
-	gboolean dispstyle = (display_options & opt) ? TRUE : FALSE;
+	int opt = 0;
+	int dispstyle = set_dispstyle(0);
 
 	while (bcs) {
 		c = (struct conversation *)bcs->data;
--- a/src/conversation.c	Fri Sep 15 16:51:31 2000 +0000
+++ b/src/conversation.c	Fri Sep 15 18:24:32 2000 +0000
@@ -427,8 +427,11 @@
 void add_callback(GtkWidget *widget, struct conversation *c)
 {
 	if (find_buddy(c->name) != NULL) {
-		gboolean dispstyle = (display_options & OPT_DISP_CONV_SHOW_TEXT) ? TRUE : FALSE;
+		int dispstyle;
 		GtkWidget *parent = c->add->parent;
+
+		dispstyle = set_dispstyle(0);
+
 		sprintf(debug_buff,_("Removing '%s' from buddylist.\n"), c->name);
 		debug_print(debug_buff);
 		remove_buddy(find_group_by_buddy(c->name), find_buddy(c->name));
@@ -1634,15 +1637,8 @@
 	aol_icon(win->window);
         
 	c->window = win;
-       
-	if (display_options & OPT_DISP_CONV_SHOW_TEXT)
-	{
-		dispstyle = TRUE;
-	}
-	else
-	{
-		dispstyle = FALSE;
-	}
+
+	dispstyle = set_dispstyle(0);
 
 	send = picture_button2(win, _("Send"), tmp_send_xpm, dispstyle);
 	info = picture_button2(win, _("Info"), tb_search_xpm, dispstyle);
--- a/src/dialogs.c	Fri Sep 15 16:51:31 2000 +0000
+++ b/src/dialogs.c	Fri Sep 15 18:24:32 2000 +0000
@@ -777,7 +777,7 @@
         add_buddy(grp, who, NULL);
 
         if (c != NULL) {
-		gboolean dispstyle = (display_options & OPT_DISP_CONV_SHOW_TEXT) ? TRUE : FALSE;
+		int dispstyle = set_dispstyle(0);
 		GtkWidget *parent = c->add->parent;
 		gtk_widget_destroy(c->add);
 		c->add = picture_button2(c->window, _("Remove"), gnome_remove_xpm, dispstyle);
--- a/src/gaim.h	Fri Sep 15 16:51:31 2000 +0000
+++ b/src/gaim.h	Fri Sep 15 18:24:32 2000 +0000
@@ -414,7 +414,7 @@
 #define TYPE_SIGNOFF   4
 #define TYPE_KEEPALIVE 5
 
-#define REVISION "gaim:$Revision: 919 $"
+#define REVISION "gaim:$Revision: 925 $"
 #define FLAPON "FLAPON\r\n\r\n"
 
 #define ROAST "Tic/Toc"
@@ -517,11 +517,13 @@
 #define OPT_DISP_CHAT_LOGON       0x00000800
 #define OPT_DISP_IGN_WHITE        0x00001000
 #define OPT_DISP_NO_BUTTONS       0x00002000
-#define OPT_DISP_CONV_SHOW_TEXT   0x00004000 
-#define OPT_DISP_CHAT_SHOW_TEXT   0x00008000 
+#define OPT_DISP_CONV_BUTTON_TEXT 0x00004000 
+#define OPT_DISP_CHAT_BUTTON_TEXT 0x00008000 
 #define OPT_DISP_CONV_BIG_ENTRY   0x00010000
 #define OPT_DISP_CHAT_BIG_ENTRY   0x00020000
 #define OPT_DISP_NO_MT_GRP        0x00040000
+#define OPT_DISP_CONV_BUTTON_XPM  0x00080000
+#define OPT_DISP_CHAT_BUTTON_XPM  0x00100000
 
 extern int sound_options;
 #define OPT_SOUND_LOGIN          0x00000001
@@ -609,6 +611,7 @@
 extern void translate_lst (FILE *, char *);
 extern void translate_blt (FILE *, char *);
 extern char *stylize(gchar *, int);
+extern int set_dispstyle (int);
 
 /* Functions in server.c */
 /* input to serv */
--- a/src/gaimrc.c	Fri Sep 15 16:51:31 2000 +0000
+++ b/src/gaimrc.c	Fri Sep 15 18:24:32 2000 +0000
@@ -689,10 +689,12 @@
                 OPT_DISP_SHOW_BUTTON_XPM |
 		OPT_DISP_SHOW_SMILEY |
 		OPT_DISP_COOL_LOOK |
-		OPT_DISP_CONV_SHOW_TEXT |
-		OPT_DISP_CHAT_SHOW_TEXT |
 		OPT_DISP_CONV_BIG_ENTRY |
-		OPT_DISP_CHAT_BIG_ENTRY;
+		OPT_DISP_CHAT_BIG_ENTRY |
+		OPT_DISP_CONV_BUTTON_XPM | 
+		OPT_DISP_CONV_BUTTON_TEXT |
+		OPT_DISP_CHAT_BUTTON_XPM | 
+		OPT_DISP_CHAT_BUTTON_TEXT;
 
 	font_options = 0; 
         sound_options = OPT_SOUND_LOGIN | OPT_SOUND_LOGOUT | OPT_SOUND_RECV | OPT_SOUND_SEND | OPT_SOUND_SILENT_SIGNON;
--- a/src/prefs.c	Fri Sep 15 16:51:31 2000 +0000
+++ b/src/prefs.c	Fri Sep 15 18:24:32 2000 +0000
@@ -57,6 +57,7 @@
 static void prefs_build_away(GtkWidget *);
 static void prefs_build_browser(GtkWidget *);
 static gint handle_delete(GtkWidget *, GdkEvent *, void *);
+static void delete_prefs(GtkWidget *, void *);
 
 static GtkWidget *prefdialog = NULL;
 static GtkWidget *debugbutton = NULL;
@@ -693,11 +694,69 @@
 	gtk_widget_show(prefdialog);
 }
 
+static void set_buttons_opt(GtkWidget *w, int data)
+{
+	int mask;
+	if (data & 0x1) /* set the first bit if we're affecting chat buttons */
+		mask = (OPT_DISP_CHAT_BUTTON_TEXT | OPT_DISP_CHAT_BUTTON_XPM);
+	else
+		mask = (OPT_DISP_CONV_BUTTON_TEXT | OPT_DISP_CONV_BUTTON_XPM);
+	display_options &= ~(mask);
+	display_options |= (data & mask);
+
+	if (data & 0x1)
+		update_chat_button_pix();
+	else
+		update_im_button_pix();
+}
+
+static void im_buttons_menu_init(GtkWidget *omenu)
+{
+	GtkWidget *menu, *opt;
+	int index;
+
+	switch (display_options & 
+		(OPT_DISP_CONV_BUTTON_TEXT | OPT_DISP_CONV_BUTTON_XPM)) {
+	case OPT_DISP_CONV_BUTTON_TEXT:
+		index = 2;
+		break;
+	case OPT_DISP_CONV_BUTTON_XPM:
+		index = 1;
+		break;
+	default: /* both or neither */
+		index = 0;
+		break;
+	}
+
+	menu = gtk_menu_new();
+
+	opt = gtk_menu_item_new_with_label(_("Pictures and Text"));
+	gtk_signal_connect(GTK_OBJECT(opt), "activate", GTK_SIGNAL_FUNC(set_buttons_opt), (void *)(OPT_DISP_CONV_BUTTON_TEXT | OPT_DISP_CONV_BUTTON_XPM));
+	gtk_widget_show(opt);
+	gtk_menu_append(GTK_MENU(menu), opt);
+
+	opt = gtk_menu_item_new_with_label(_("Pictures Only"));
+	gtk_signal_connect(GTK_OBJECT(opt), "activate", GTK_SIGNAL_FUNC(set_buttons_opt), (void *)OPT_DISP_CONV_BUTTON_XPM);
+	gtk_widget_show(opt);
+	gtk_menu_append(GTK_MENU(menu), opt);
+
+	opt = gtk_menu_item_new_with_label(_("Text Only"));
+	gtk_signal_connect(GTK_OBJECT(opt), "activate", GTK_SIGNAL_FUNC(set_buttons_opt), (void *)OPT_DISP_CONV_BUTTON_TEXT);
+	gtk_widget_show(opt);
+	gtk_menu_append(GTK_MENU(menu), opt);
+
+	gtk_option_menu_remove_menu(GTK_OPTION_MENU(omenu));
+	gtk_option_menu_set_menu(GTK_OPTION_MENU(omenu), menu);
+	gtk_option_menu_set_history(GTK_OPTION_MENU(omenu), index);
+}
+
 static void im_page()
 {
 	GtkWidget *parent;
 	GtkWidget *box;
+	GtkWidget *hbox;
 	GtkWidget *label;
+	GtkWidget *opt;
 
 	parent = prefdialog->parent;
 	gtk_widget_destroy(prefdialog);
@@ -714,7 +773,20 @@
 	gtk_widget_show(label);
 
 	gaim_button(_("Show logins in window"), &display_options, OPT_DISP_SHOW_LOGON, box);
-	gaim_button(_("Show buttons with text"), &display_options, OPT_DISP_CONV_SHOW_TEXT, box);
+
+	hbox = gtk_hbox_new(FALSE, 0);
+	gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 5);
+	gtk_widget_show(hbox);
+
+	label = gtk_label_new(_("Show buttons as "));
+	gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
+	gtk_widget_show(label);
+
+	opt = gtk_option_menu_new();
+	gtk_box_pack_start(GTK_BOX(hbox), opt, FALSE, FALSE, 5);
+	im_buttons_menu_init(opt);
+	gtk_widget_show(opt);
+
 	gaim_button(_("Show larger entry box on new windows"), &display_options, OPT_DISP_CONV_BIG_ENTRY, box);
 	gaim_button(_("Raise windows on events"), &general_options, OPT_GEN_POPUP_WINDOWS, box);
 	gaim_button(_("Ignore new conversations when away"), &general_options, OPT_GEN_DISCARD_WHEN_AWAY, box);
@@ -723,11 +795,53 @@
 	gtk_widget_show(prefdialog);
 }
 
+static void chat_buttons_menu_init(GtkWidget *omenu)
+{
+	GtkWidget *menu, *opt;
+	int index;
+
+	switch (display_options & 
+		(OPT_DISP_CHAT_BUTTON_TEXT | OPT_DISP_CHAT_BUTTON_XPM)) {
+	case OPT_DISP_CHAT_BUTTON_TEXT:
+		index = 2;
+		break;
+	case OPT_DISP_CHAT_BUTTON_XPM:
+		index = 1;
+		break;
+	default: /* both or neither */
+		index = 0;
+		break;
+	}
+
+	menu = gtk_menu_new();
+
+	opt = gtk_menu_item_new_with_label(_("Pictures and Text"));
+	gtk_signal_connect(GTK_OBJECT(opt), "activate", GTK_SIGNAL_FUNC(set_buttons_opt), (void *)(OPT_DISP_CHAT_BUTTON_TEXT | OPT_DISP_CHAT_BUTTON_XPM | 1));
+	gtk_widget_show(opt);
+	gtk_menu_append(GTK_MENU(menu), opt);
+
+	opt = gtk_menu_item_new_with_label(_("Pictures Only"));
+	gtk_signal_connect(GTK_OBJECT(opt), "activate", GTK_SIGNAL_FUNC(set_buttons_opt), (void *)(OPT_DISP_CHAT_BUTTON_XPM | 1));
+	gtk_widget_show(opt);
+	gtk_menu_append(GTK_MENU(menu), opt);
+
+	opt = gtk_menu_item_new_with_label(_("Text Only"));
+	gtk_signal_connect(GTK_OBJECT(opt), "activate", GTK_SIGNAL_FUNC(set_buttons_opt), (void *)(OPT_DISP_CHAT_BUTTON_TEXT | 1));
+	gtk_widget_show(opt);
+	gtk_menu_append(GTK_MENU(menu), opt);
+
+	gtk_option_menu_remove_menu(GTK_OPTION_MENU(omenu));
+	gtk_option_menu_set_menu(GTK_OPTION_MENU(omenu), menu);
+	gtk_option_menu_set_history(GTK_OPTION_MENU(omenu), index);
+}
+
 static void chat_page()
 {
 	GtkWidget *parent;
 	GtkWidget *box;
+	GtkWidget *hbox;
 	GtkWidget *label;
+	GtkWidget *opt;
 
 	parent = prefdialog->parent;
 	gtk_widget_destroy(prefdialog);
@@ -744,7 +858,21 @@
 	gtk_widget_show(label);
 
 	gaim_button(_("Show people joining/leaving in window"), &display_options, OPT_DISP_CHAT_LOGON, box);
-	gaim_button(_("Show buttons with text"), &display_options, OPT_DISP_CHAT_SHOW_TEXT, box);
+
+	hbox = gtk_hbox_new(FALSE, 0);
+	gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 5);
+	gtk_widget_show(hbox);
+
+	label = gtk_label_new(_("Show buttons as "));
+	gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
+	gtk_widget_show(label);
+
+	opt = gtk_option_menu_new();
+	gtk_box_pack_start(GTK_BOX(hbox), opt, FALSE, FALSE, 5);
+	chat_buttons_menu_init(opt);
+	gtk_widget_show(opt);
+
+
 	gaim_button(_("Show larger entry box on new windows"), &display_options, OPT_DISP_CHAT_BIG_ENTRY, box);
 	gaim_button(_("Raise windows on events"), &general_options, OPT_GEN_POPUP_CHAT, box);
 
@@ -1587,6 +1715,8 @@
 	gtk_container_border_width(GTK_CONTAINER(prefs), 10);
 	gtk_window_set_title(GTK_WINDOW(prefs), _("Gaim - Preferences"));
 	gtk_widget_set_usize(prefs, 600, 550);
+	gtk_signal_connect(GTK_OBJECT(prefs), "destroy",
+			   GTK_SIGNAL_FUNC(delete_prefs), NULL);
 
 	vbox = gtk_vbox_new(FALSE, 5);
 	gtk_container_add(GTK_CONTAINER(prefs), vbox);
@@ -1723,6 +1853,16 @@
         return FALSE;
 }
 
+static void delete_prefs(GtkWidget *w, void *data)
+{
+	if (prefs) {
+		save_prefs();
+		gtk_widget_destroy(prefs);
+	}
+	prefs = NULL;
+}
+      
+
 void set_option(GtkWidget *w, int *option)
 {
 	*option = !(*option);
@@ -1764,9 +1904,6 @@
 
 	if (blist) update_button_pix();
 
-	if ((int)option == OPT_DISP_CHAT_SHOW_TEXT) update_chat_button_pix();
-	if ((int)option == OPT_DISP_CONV_SHOW_TEXT) update_im_button_pix();
-
 #ifdef USE_APPLET
 	update_pixmaps();
 #endif
--- a/src/util.c	Fri Sep 15 16:51:31 2000 +0000
+++ b/src/util.c	Fri Sep 15 18:24:32 2000 +0000
@@ -940,7 +940,7 @@
 }
 
 static GtkTooltips *tips = NULL;
-GtkWidget *picture_button2(GtkWidget *window, char *text, char **xpm, short showtext)
+GtkWidget *picture_button2(GtkWidget *window, char *text, char **xpm, short dispstyle)
 {
 	GtkWidget *button;
 	GtkWidget *button_box, *button_box_2;
@@ -960,23 +960,29 @@
 	button_box_2 = gtk_vbox_new(FALSE, 0);
 
 	gtk_box_pack_start(GTK_BOX(button_box), button_box_2, TRUE, TRUE, 0);
-	pm = gdk_pixmap_create_from_xpm_d(window->window, &mask, NULL, xpm);
-	pixmap = gtk_pixmap_new(pm, mask);
-	gtk_box_pack_start(GTK_BOX(button_box_2), pixmap, FALSE, FALSE, 0);
+	if (dispstyle == 2 || dispstyle == 0) {
+		pm = gdk_pixmap_create_from_xpm_d(window->window, &mask, NULL, xpm);
+		pixmap = gtk_pixmap_new(pm, mask);
+		gtk_box_pack_start(GTK_BOX(button_box_2), pixmap, FALSE, FALSE, 0);
 
-	if (showtext)
+		gtk_widget_show(pixmap);
+
+	}
+
+	if (dispstyle == 2 || dispstyle == 1)
 	{
 		label = gtk_label_new(text);
 		gtk_widget_show(label);
 		gtk_box_pack_end(GTK_BOX(button_box_2), label, FALSE, FALSE, 0);
 	}
 
-	gtk_widget_show(pixmap);
 	gtk_widget_show(button_box_2);
 	gtk_widget_show(button_box);
 	gtk_widget_show(button);
-	gdk_pixmap_unref(pm);
-	gdk_bitmap_unref(mask);
+	if (dispstyle == 2 || dispstyle == 0) {
+		gdk_pixmap_unref(pm);
+		gdk_bitmap_unref(mask);
+	}
 	
 	gtk_tooltips_set_tip(tips, button, text, "Gaim");	
 	return button;
@@ -1154,3 +1160,37 @@
 	
 	return buf;
 }
+
+int set_dispstyle (int chat)
+{
+	int dispstyle;
+
+	if (chat) {
+		switch (display_options & (OPT_DISP_CHAT_BUTTON_TEXT | 
+					   OPT_DISP_CHAT_BUTTON_XPM)) {
+		case OPT_DISP_CHAT_BUTTON_TEXT:
+			  dispstyle = 1;
+			  break;
+		case OPT_DISP_CHAT_BUTTON_XPM:
+			  dispstyle = 0;
+			  break;
+		default: /* both or neither */
+			  dispstyle = 2;
+			  break;
+		}
+	} else {
+		switch (display_options & (OPT_DISP_CONV_BUTTON_TEXT | 
+					   OPT_DISP_CONV_BUTTON_XPM)) {
+		case OPT_DISP_CONV_BUTTON_TEXT:
+			  dispstyle = 1;
+			  break;
+		case OPT_DISP_CONV_BUTTON_XPM:
+			  dispstyle = 0;
+			  break;
+		default: /* both or neither */
+			  dispstyle = 2;
+			  break;
+		}
+	}
+	return dispstyle;
+}