changeset 608:e33dfed611c9

[gaim-migrate @ 618] removed modality from the remaining im-window dialogs, and kept -Wall nice and clean while i was at it! :) committer: Tailor Script <tailor@pidgin.im>
author Todd Kulesza <fflewddur>
date Fri, 04 Aug 2000 21:56:18 +0000
parents 01a9c6998719
children 1301715fc119
files src/buddy.c src/conversation.c src/convo.h src/dialogs.c src/gaim.h
diffstat 5 files changed, 112 insertions(+), 105 deletions(-) [+]
line wrap: on
line diff
--- a/src/buddy.c	Fri Aug 04 17:45:43 2000 +0000
+++ b/src/buddy.c	Fri Aug 04 21:56:18 2000 +0000
@@ -1344,7 +1344,7 @@
 	}
 	else
 	{
-		show_log_dialog(name);
+		show_log_dialog(c);
 		if (c) {
 			set_state_lock(1);
 			gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(c->log_button), TRUE);
--- a/src/conversation.c	Fri Aug 04 17:45:43 2000 +0000
+++ b/src/conversation.c	Fri Aug 04 21:56:18 2000 +0000
@@ -258,7 +258,11 @@
 		gtk_widget_destroy(cnv->font_dialog);
 	if (cnv->smiley_dialog)
 		gtk_widget_destroy(cnv->smiley_dialog);
-        g_free(cnv);
+	if (cnv->link_dialog)
+		gtk_widget_destroy(cnv->link_dialog);
+	if (cnv->log_dialog)
+		gtk_widget_destroy(cnv->log_dialog);
+	g_free(cnv);
 }
 
 void update_log_convs()
@@ -338,15 +342,16 @@
 /*  Callbacks                                                             */
 /*------------------------------------------------------------------------*/
 
-void toggle_loggle(GtkWidget *w, struct conversation *p)
+void toggle_loggle(GtkWidget *loggle, struct conversation *c)
 {
         if (state_lock)
                 return;
-        
-        if (find_log_info(p->name))
-                rm_log(find_log_info(p->name));
-        else 
-		show_log_dialog(p->name);
+        if (find_log_info(c->name))
+                rm_log(find_log_info(c->name));
+        else if (GTK_TOGGLE_BUTTON(loggle)->active)
+			show_log_dialog(c);
+		else
+			cancel_log(NULL, c);
 }
 
 void insert_smiley(GtkWidget *smiley, struct conversation *c)
@@ -826,7 +831,7 @@
 	else
 		advance_past(c->entry, "<FONT FACE>", "</FONT>");
 }
-
+/*
 void do_link(GtkWidget *linky, GtkWidget *entry)
 {
 	if (state_lock)
@@ -836,6 +841,18 @@
 	else
 		advance_past(entry, "<A HREF>", "</A>"	);
 }
+*/
+void toggle_link(GtkWidget *linky, struct conversation *c)
+{
+	if (state_lock)
+		return;
+	if (GTK_TOGGLE_BUTTON(linky)->active)
+		show_add_link(linky, c);
+	else if (c->link_dialog)
+		cancel_link(linky, c);
+	else
+		advance_past(c->entry, "<A HREF>", "</A>");
+}
 
 void do_strike(GtkWidget *strike, GtkWidget *entry)
 {
@@ -1330,7 +1347,7 @@
 	gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
 	link = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar),
                                             GTK_TOOLBAR_CHILD_TOGGLEBUTTON,                                                 NULL, _("Link"), _("Insert Link"),
-                                            _("Link"), link_p, GTK_SIGNAL_FUNC(do_link), entry);                 
+                                            _("Link"), link_p, GTK_SIGNAL_FUNC(toggle_link), c);                 
 	palette = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar),
 					    GTK_TOOLBAR_CHILD_TOGGLEBUTTON,
 					    NULL, _("Color"), _("Text Color"),
@@ -1384,6 +1401,7 @@
         c->log_button = wood;
 	c->palette = palette;
 	c->link = link;  
+	c->wood = wood;
 	c->font = font;
 	c->smiley = smiley;
 
@@ -1546,6 +1564,8 @@
 	c->font_dialog = NULL;
 	c->color_dialog = NULL;	
 	c->smiley_dialog = NULL;
+	c->link_dialog = NULL;
+	c->log_dialog = NULL;
 	
 	gtk_container_add(GTK_CONTAINER(win), paned);
         gtk_container_border_width(GTK_CONTAINER(win), 10);
--- a/src/convo.h	Fri Aug 04 17:45:43 2000 +0000
+++ b/src/convo.h	Fri Aug 04 21:56:18 2000 +0000
@@ -50,7 +50,7 @@
 extern void do_normal(GtkWidget *, GtkWidget *);
 extern void do_big(GtkWidget *, GtkWidget *);
 extern void toggle_font(GtkWidget *, struct conversation *);
-extern void do_link(GtkWidget *, GtkWidget *);
+extern void toggle_link(GtkWidget *, struct conversation *);
 extern void toggle_color(GtkWidget *, struct conversation *);
 extern void toggle_loggle(GtkWidget *, struct conversation *);
 extern void insert_smiley(GtkWidget *, struct conversation *);
--- a/src/dialogs.c	Fri Aug 04 17:45:43 2000 +0000
+++ b/src/dialogs.c	Fri Aug 04 21:56:18 2000 +0000
@@ -71,7 +71,7 @@
 
 static GtkWidget *imdialog = NULL; /*I only want ONE of these :) */
 static GList *dialogwindows = NULL;
-static GtkWidget *linkdialog, *exportdialog, *importdialog, *logdialog;
+static GtkWidget *exportdialog, *importdialog;
 
 struct create_away {
         GtkWidget *window;
@@ -299,6 +299,13 @@
 		set_state_lock(0);
 		c->smiley_dialog = NULL;
 	}
+	else if (!g_strcasecmp(object_data, "log dialog"))
+	{
+		set_state_lock(1);
+		gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(c->wood), FALSE);
+		set_state_lock(0);
+		c->log_dialog = NULL;
+	}
 	
 	return FALSE;
 }
@@ -321,18 +328,6 @@
 	if (dest == importdialog)
 		importdialog = NULL;
 
-	if (dest == logdialog)
-		logdialog = NULL;
-
-/*	if (GTK_COLOR_SELECTION_DIALOG(dest))
-		color_dialog = NULL;*/
-
-	if (dest == linkdialog)
-		linkdialog = NULL;
-	
-/*	if (dest == fontdialog)
-		fontdialog = NULL;*/
-
         dialogwindows = g_list_remove(dialogwindows, dest);
         gtk_widget_destroy(dest);
 
@@ -359,16 +354,6 @@
                 imdialog = NULL;
         }
         
-	if (linkdialog) {
-		destroy_dialog(NULL, linkdialog);
-		linkdialog = NULL;
-	}
-/* is this needed? */
-/*	if (colordialog) {
-		destroy_dialog(NULL, colordialog);
-		colordialog = NULL;
-	}*/
-
         if (exportdialog) {
                 destroy_dialog(NULL, exportdialog);
                 exportdialog = NULL;
@@ -378,16 +363,6 @@
                 destroy_dialog(NULL, importdialog);
                 importdialog = NULL;
         }
-	
-	if (logdialog) {
-		destroy_dialog(NULL, logdialog);
-		logdialog = NULL;
-	}
-/* is this needed? */
-/*	if (fontdialog) {
-		destroy_dialog(NULL, fontdialog);
-		fontdialog = NULL;
-	}*/
 }
 
 static void do_warn(GtkWidget *widget, struct warning *w)
@@ -1849,20 +1824,31 @@
 
 
 /*------------------------------------------------------------------------*/
-/*  Function Called To Add A Log                                          */
+/*  Functions Called To Add A Log                                          */
 /*------------------------------------------------------------------------*/
 
-void do_log(GtkWidget *w, char *name)
+void cancel_log(GtkWidget *widget, struct conversation *c)
+{	
+	if (c->wood)
+	{
+		set_state_lock(1);
+		gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(c->wood), FALSE);
+		set_state_lock(0);
+	}
+	dialogwindows = g_list_remove(dialogwindows, c->log_dialog);
+	gtk_widget_destroy(c->log_dialog);
+	c->log_dialog = NULL;	
+}
+
+void do_log(GtkWidget *w, struct conversation *c)
 {
         struct log_conversation *l;
-	struct conversation *c;
         char buf[128];
 
-	c = find_conversation(name);
-        if (!find_log_info(name)) {
+        if (!find_log_info(c->name)) {
                 l = (struct log_conversation *)g_new0(struct log_conversation, 1);
-                strcpy(l->name, name);
-                strcpy(l->filename, gtk_file_selection_get_filename(GTK_FILE_SELECTION(logdialog)));
+                strcpy(l->name, c->name);
+                strcpy(l->filename, gtk_file_selection_get_filename(GTK_FILE_SELECTION(c->log_dialog)));
                 log_conversations = g_list_append(log_conversations, l);
 
                 if (c != NULL)
@@ -1873,11 +1859,10 @@
         }
 
         save_prefs();
-
-        destroy_dialog(NULL, logdialog);
-        logdialog = NULL;
+        cancel_log(NULL, c);
 } 
 
+/*
 static void cancel_log(GtkWidget *w, char *name)
 {
 	
@@ -1891,32 +1876,29 @@
         }
 	destroy_dialog(NULL, logdialog);
 }
-
-void show_log_dialog(char *bname)
+*/
+
+void show_log_dialog(struct conversation *c)
 {
 	char *buf = g_malloc(BUF_LEN);
-        struct conversation *c = find_conversation(bname);
-
 	
-	if (!logdialog) {
-		logdialog = gtk_file_selection_new(_("Gaim - Log Conversation"));
+	if (!c->log_dialog) {
+		c->log_dialog = gtk_file_selection_new(_("Gaim - Log Conversation"));
+		
+		gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(c->log_dialog));	
 		
-		gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(logdialog));	
-
-                gtk_object_set_user_data(GTK_OBJECT(logdialog), c);
-		
-		g_snprintf(buf, BUF_LEN - 1, "%s/%s.log", getenv("HOME"), bname);
-		
-		gtk_file_selection_set_filename(GTK_FILE_SELECTION(logdialog), buf);
-		gtk_signal_connect(GTK_OBJECT(logdialog), "delete_event", GTK_SIGNAL_FUNC(cancel_log), c);
-		gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(logdialog)->ok_button), "clicked", GTK_SIGNAL_FUNC(do_log), bname);
-		gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(logdialog)->cancel_button), "clicked", GTK_SIGNAL_FUNC(cancel_log), bname);
+		g_snprintf(buf, BUF_LEN - 1, "%s/%s.log", getenv("HOME"), c->name);
+		gtk_object_set_user_data(GTK_OBJECT(c->log_dialog), "log dialog");
+		gtk_file_selection_set_filename(GTK_FILE_SELECTION(c->log_dialog), buf);
+		gtk_signal_connect(GTK_OBJECT(c->log_dialog), "delete_event", GTK_SIGNAL_FUNC(delete_event_dialog), c);
+		gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(c->log_dialog)->ok_button), "clicked", GTK_SIGNAL_FUNC(do_log), c);
+		gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(c->log_dialog)->cancel_button), "clicked", GTK_SIGNAL_FUNC(cancel_log), c);
 	}
 
 	g_free(buf);
 
-	gtk_widget_show(logdialog);
-	gdk_window_raise(logdialog->window);
+	gtk_widget_show(c->log_dialog);
+	gdk_window_raise(c->log_dialog->window);
 }
 
 /*------------------------------------------------------*/
@@ -2185,14 +2167,15 @@
 /* Link Dialog                                          */
 /*------------------------------------------------------*/
 
-void cancel_link(GtkWidget *widget, struct linkdlg *b)
+void cancel_link(GtkWidget *widget, struct conversation *c)
 {
-	if (b->toggle) {
+	if (c->link) {
 		set_state_lock(1);
-		gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->toggle), FALSE);
+		gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(c->link), FALSE);
 		set_state_lock(0);
 	}	
-	destroy_dialog(NULL, b->window);
+	destroy_dialog(NULL, c->link_dialog);
+	c->link_dialog = NULL;
 }
 
 void do_add_link(GtkWidget *widget, struct linkdlg *b)
@@ -2213,7 +2196,7 @@
 }
 
 
-void show_add_link(GtkWidget *entry, GtkWidget *link)
+void show_add_link(GtkWidget *linky, struct conversation *c)
 {
 	GtkWidget *vbox;
 	GtkWidget *bbox;
@@ -2222,14 +2205,14 @@
 	GtkWidget *frame;
 	GtkWidget *fbox;
 
-	if (!linkdialog) {
+	if (!c->link_dialog) {
 		struct linkdlg *b = g_new0(struct linkdlg, 1);
-		linkdialog = gtk_window_new(GTK_WINDOW_DIALOG);
-		dialogwindows = g_list_prepend(dialogwindows, linkdialog);
-
-		gtk_widget_set_usize(linkdialog, 270, 165);
-		gtk_window_set_policy(GTK_WINDOW(linkdialog), FALSE, FALSE, TRUE);
-		gtk_widget_show(linkdialog);
+		c->link_dialog = gtk_window_new(GTK_WINDOW_DIALOG);
+		dialogwindows = g_list_prepend(dialogwindows, c->link_dialog);
+
+		gtk_widget_set_usize(c->link_dialog, 270, 165);
+		gtk_window_set_policy(GTK_WINDOW(c->link_dialog), FALSE, FALSE, TRUE);
+		gtk_widget_show(c->link_dialog);
 
 		vbox = gtk_vbox_new(FALSE, 10);
 		bbox = gtk_hbox_new(TRUE, 10);
@@ -2238,8 +2221,8 @@
 
 		/* Build OK Button */
 
-		b->ok = picture_button(linkdialog, _("OK"), ok_xpm);
-		b->cancel = picture_button(linkdialog, _("Cancel"), cancel_xpm);
+		b->ok = picture_button(c->link_dialog, _("OK"), ok_xpm);
+		b->cancel = picture_button(c->link_dialog, _("Cancel"), cancel_xpm);
 
 		gtk_box_pack_start(GTK_BOX(bbox), b->ok, FALSE, FALSE, 10);
 		gtk_box_pack_end(GTK_BOX(bbox), b->cancel, FALSE, FALSE, 10);
@@ -2274,27 +2257,27 @@
 		gtk_box_pack_start(GTK_BOX(fbox), bbox, TRUE, TRUE, 5);
 		gtk_widget_show(vbox);
 
-		gtk_signal_connect(GTK_OBJECT(linkdialog), "destroy",
-				   GTK_SIGNAL_FUNC(cancel_link), b);
+		gtk_signal_connect(GTK_OBJECT(c->link_dialog), "destroy",
+				   GTK_SIGNAL_FUNC(cancel_link), c);
 		gtk_signal_connect(GTK_OBJECT(b->cancel), "clicked",
-				   GTK_SIGNAL_FUNC(cancel_link), b);
+				   GTK_SIGNAL_FUNC(cancel_link), c);
 		gtk_signal_connect(GTK_OBJECT(b->ok), "clicked",
 				   GTK_SIGNAL_FUNC(do_add_link), b);
 
-		gtk_container_add(GTK_CONTAINER(linkdialog  ), fbox);
-		gtk_container_border_width(GTK_CONTAINER(linkdialog  ), 10);
-		gtk_window_set_title(GTK_WINDOW(linkdialog  ), _("GAIM - Add URL"));
-		gtk_window_set_focus(GTK_WINDOW(linkdialog  ), b->url);
-		b->window = linkdialog;
-		b->toggle = link;
-                b->entry = entry;
-                gtk_widget_realize(linkdialog);
-		aol_icon(linkdialog->window);
+		gtk_container_add(GTK_CONTAINER(c->link_dialog  ), fbox);
+		gtk_container_border_width(GTK_CONTAINER(c->link_dialog  ), 10);
+		gtk_window_set_title(GTK_WINDOW(c->link_dialog  ), _("GAIM - Add URL"));
+		gtk_window_set_focus(GTK_WINDOW(c->link_dialog  ), b->url);
+		b->window = c->link_dialog;
+		b->toggle = linky;
+        b->entry = c->entry;
+                gtk_widget_realize(c->link_dialog);
+		aol_icon(c->link_dialog->window);
 
 	}
 
-	gtk_widget_show(linkdialog);
-	gdk_window_raise(linkdialog->window);
+	gtk_widget_show(c->link_dialog);
+	gdk_window_raise(c->link_dialog->window);
 }
 
 
--- a/src/gaim.h	Fri Aug 04 17:45:43 2000 +0000
+++ b/src/gaim.h	Fri Aug 04 21:56:18 2000 +0000
@@ -275,6 +275,7 @@
 	GtkWidget *underline;
 	GtkWidget *palette;
 	GtkWidget *link;
+	GtkWidget *wood;
 	GtkWidget *log_button;
 	GtkWidget *strike;
 	GtkWidget *font;
@@ -282,6 +283,8 @@
 	GtkWidget *color_dialog;
 	GtkWidget *font_dialog;
 	GtkWidget *smiley_dialog;
+	GtkWidget *link_dialog;
+	GtkWidget *log_dialog;
 	int makesound;
 	char current_fontface[64];
 	char current_fontname[64];
@@ -405,7 +408,7 @@
 #define TYPE_SIGNOFF   4
 #define TYPE_KEEPALIVE 5
 
-#define REVISION "gaim:$Revision: 614 $"
+#define REVISION "gaim:$Revision: 618 $"
 #define FLAPON "FLAPON\r\n\r\n"
 
 #define ROAST "Tic/Toc"
@@ -648,7 +651,7 @@
 extern void do_small(GtkWidget *, GtkWidget *);
 extern void do_normal(GtkWidget *, GtkWidget *);
 extern void do_big(GtkWidget *, GtkWidget *);
-extern void do_link(GtkWidget *, GtkWidget *);
+extern void toggle_link(GtkWidget *, struct conversation *);
 extern int invert_tags(GtkWidget *, char *, char *, int);
 extern void quiet_set(GtkWidget *, int);
 extern int count_tag(GtkWidget *, char *, char *);
@@ -762,7 +765,7 @@
 extern void show_export_dialog();
 extern void show_import_dialog();
 extern void show_new_bp();
-extern void show_log_dialog(char *);
+extern void show_log_dialog(struct conversation *);
 extern void show_find_email();
 extern void show_find_info();
 extern void g_show_info (char *);
@@ -774,7 +777,7 @@
 extern void cancel_color(GtkWidget *widget, struct conversation *c);
 extern void create_away_mess(GtkWidget *, void *);
 extern void show_ee_dialog(int);
-extern void show_add_link(GtkWidget *, GtkWidget *);
+extern void show_add_link(GtkWidget *,struct conversation *);
 extern void show_change_passwd();
 extern void do_import(GtkWidget *, void *);
 extern int bud_list_cache_exists();
@@ -782,7 +785,8 @@
 extern void close_smiley_dialog(GtkWidget *widget, struct conversation *c);
 extern void set_smiley_array(GtkWidget *widget, int smiley_type);
 extern void insert_smiley_text(GtkWidget *widget, struct conversation *c);
-
+extern void cancel_log(GtkWidget *, struct conversation *);
+extern void cancel_link(GtkWidget *, struct conversation *);
 extern void show_font_dialog(struct conversation *c, GtkWidget *font);
 extern void cancel_font(GtkWidget *widget, struct conversation *c);
 extern void apply_font(GtkWidget *widget, GtkFontSelection *fontsel);