changeset 234:985635758c33

[gaim-migrate @ 244] More patches from fflew. This adds a font selector to the conversation window, among other things. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Tue, 16 May 2000 20:48:47 +0000
parents b8c5efaef154
children 633ec753fb1d
files src/conversation.c src/dialogs.c src/gaim.h src/prefs.c src/proxy.c
diffstat 5 files changed, 163 insertions(+), 49 deletions(-) [+]
line wrap: on
line diff
--- a/src/conversation.c	Mon May 15 17:43:04 2000 +0000
+++ b/src/conversation.c	Tue May 16 20:48:47 2000 +0000
@@ -37,7 +37,7 @@
 #include "pixmaps/small.xpm"
 #include "pixmaps/normal.xpm"
 #include "pixmaps/big.xpm"
-/* #include "pixmaps/fontface.xpm" */
+#include "pixmaps/fontface.xpm"
 #include "pixmaps/speaker.xpm"
 /* #include "pixmaps/aimicon2.xpm" */
 #include "pixmaps/wood.xpm"
@@ -54,7 +54,6 @@
 
 void check_everything(GtkWidget *entry);
 gboolean user_keypress_callback(GtkWidget *entry, GdkEventKey *event,  struct conversation *c);
-void set_font_face(GtkWidget *widget, struct conversation *c);
 
 /*------------------------------------------------------------------------*/
 /*  Helpers                                                               */
@@ -74,6 +73,18 @@
         state_lock = i;
 }
 
+void toggle_sensitive(GtkWidget *widget, GtkWidget *to_toggle)
+{
+	gboolean sensitivity = GTK_WIDGET_IS_SENSITIVE(GTK_WIDGET(to_toggle));
+	
+	if (sensitivity == TRUE)
+		gtk_widget_set_sensitive(GTK_WIDGET(to_toggle), FALSE);
+	else
+		gtk_widget_set_sensitive(GTK_WIDGET(to_toggle), TRUE);
+		
+	return;
+}
+
 struct conversation *new_conversation(char *name)
 {
         struct conversation *c;
@@ -209,6 +220,9 @@
                 if (c->strike)
                         gtk_widget_set_sensitive(c->strike, ((font_options & OPT_FONT_STRIKE)) ? FALSE : TRUE);
 
+                if (c->font)
+                        gtk_widget_set_sensitive(c->font, ((font_options & OPT_FONT_FACE)) ? TRUE : FALSE);
+		
 		cnv = cnv->next;
 	}
 }
@@ -264,13 +278,20 @@
 	if (!(font_options & OPT_FONT_FACE))
 		return;
 
-	if (fontface)
+	if (c->current_fontface && strcmp(c->current_fontface, "(null)"))
 	{
-		pre_fontface = g_strconcat("<FONT FACE=\"", fontface, "\">", '\0');
+		pre_fontface = g_strconcat("<FONT FACE=\"", c->current_fontface, "\">", '\0');
 		alloc++;
 	}
 	else
 		pre_fontface = "<FONT FACE=\"Helvetica\">";
+	
+	if (!strcmp(pre_fontface, "<FONT FACE=\"\">"))
+	{
+		g_free(pre_fontface);
+		alloc--;
+		pre_fontface = "<FONT FACE=\"Helvetica\">";
+	}
 		
 	surround(c->entry, pre_fontface, "</FONT>");
 	gtk_widget_grab_focus(c->entry);
@@ -613,6 +634,13 @@
 		advance_past(entry, "<FONT COLOR>", "</FONT>" );
 }
 
+static void toggle_font(GtkWidget *font, GtkWidget *entry)
+{
+	show_font_dialog(entry, font);
+	
+	return;
+}
+
 static void do_link(GtkWidget *linky, GtkWidget *entry)
 {
 	if (state_lock)
@@ -887,9 +915,9 @@
 	GtkWidget *vbox2;
 	GtkWidget *paned;
         GtkWidget *add;
-        GdkPixmap *strike_i, *small_i, *normal_i, *big_i, *bold_i, *italic_i, *underline_i, *speaker_i, *wood_i, *palette_i, *link_i;
-        GtkWidget *strike_p, *small_p, *normal_p, *big_p, *bold_p, *italic_p, *underline_p, *speaker_p, *wood_p, *palette_p, *link_p;
-        GtkWidget *strike, *small, *normal, *big, *bold, *italic, *underline, *speaker, *wood, *palette, *link;
+        GdkPixmap *strike_i, *small_i, *normal_i, *big_i, *bold_i, *italic_i, *underline_i, *speaker_i, *wood_i, *palette_i, *link_i, *font_i;
+        GtkWidget *strike_p, *small_p, *normal_p, *big_p, *bold_p, *italic_p, *underline_p, *speaker_p, *wood_p, *palette_p, *link_p, *font_p;
+        GtkWidget *strike, *small, *normal, *big, *bold, *italic, *underline, *speaker, *wood, *palette, *link, *font;
         GdkBitmap *mask;
 	
 	win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
@@ -979,7 +1007,10 @@
              &win->style->white, big_xpm );
 	big_p = gtk_pixmap_new(big_i, mask);
 	gtk_widget_show(big_p);
-
+	font_i = gdk_pixmap_create_from_xpm_d ( win->window, &mask,
+			&win->style->white, fontface_xpm );
+	font_p = gtk_pixmap_new(font_i, mask);
+	gtk_widget_show(font_p);
 
 	bold = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar),
 	                                  GTK_TOOLBAR_CHILD_TOGGLEBUTTON, NULL,
@@ -1001,6 +1032,11 @@
 	small = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), "Small", "Decrease font size", "Small", small_p, GTK_SIGNAL_FUNC(do_small), entry);
 	normal = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), "Normal", "Normal font size", "Normal", normal_p, GTK_SIGNAL_FUNC(do_normal), entry);
 	big = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), "Big", "Increase font size", "Big", big_p, GTK_SIGNAL_FUNC(do_big), entry);
+	font = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), "Font", "Select Font", "Font", font_p, GTK_SIGNAL_FUNC(toggle_font), entry);
+	gtk_object_set_user_data(GTK_OBJECT(font), c);
+	if (!(font_options & OPT_FONT_FACE))
+		gtk_widget_set_sensitive(GTK_WIDGET(font), FALSE);
+	
 	gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
 	link = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar),
                                             GTK_TOOLBAR_CHILD_TOGGLEBUTTON,                                                 NULL, "Link", "Insert Link",
@@ -1019,7 +1055,7 @@
 					    "Sound", speaker_p, GTK_SIGNAL_FUNC(set_option), &c->makesound);
 	c->makesound=0;
 	gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(speaker), TRUE);
-
+	
         state_lock = 1;
 	if (find_log_info(c->name))
 		gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(wood), TRUE);
@@ -1038,6 +1074,7 @@
 	c->palette = palette;
 	c->link = link;  
         c->add_button = add;
+    c->font = font;
 
         gtk_widget_set_sensitive(c->log_button, ((general_options & OPT_GEN_LOG_ALL)) ? FALSE : TRUE);
         
@@ -1136,7 +1173,10 @@
 	gtk_signal_connect(GTK_OBJECT(win), "delete_event", GTK_SIGNAL_FUNC(delete_event_convo), c);
 	gtk_signal_connect(GTK_OBJECT(entry), "insert-text", GTK_SIGNAL_FUNC(check_spelling), entry);
 	gtk_signal_connect(GTK_OBJECT(entry), "key_press_event", GTK_SIGNAL_FUNC(entry_key_pressed), entry);
-
+	
+	c->current_fontface = g_strdup(fontface);
+	c->current_fontname = g_strdup(fontname);
+	
 	set_font_face(NULL, c);
 	
 	gtk_widget_show(win);
--- a/src/dialogs.c	Mon May 15 17:43:04 2000 +0000
+++ b/src/dialogs.c	Tue May 16 20:48:47 2000 +0000
@@ -284,6 +284,9 @@
 
 	if (dest == linkdialog)
 		linkdialog = NULL;
+	
+	if (dest == fontdialog)
+		fontdialog = NULL;
 
         dialogwindows = g_list_remove(dialogwindows, dest);
         gtk_widget_destroy(dest);
@@ -334,6 +337,10 @@
 		logdialog = NULL;
 	}
 
+	if (fontdialog) {
+		destroy_dialog(NULL, fontdialog);
+		fontdialog = NULL;
+	}
 }
 
 static void do_warn(GtkWidget *widget, struct warning *w)
@@ -1943,15 +1950,8 @@
 /*  Font Selection Dialog                                                 */
 /*------------------------------------------------------------------------*/
 
-void cancel_font(GtkWidget *widget, GtkWidget *font)
-{
-	if (font)
-    {
-		set_state_lock(1);
-        gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(font), FALSE);
-        set_state_lock(0);
-	}
-	
+void cancel_font(GtkWidget *widget, GtkWidget *window)
+{	
 	destroy_dialog(NULL, fontdialog);
 }
 
@@ -1960,34 +1960,67 @@
 	/* this could be expanded to include font size, weight, etc.
 	   but for now only works with font face */
 	int i, j = 0, k = 0;
-
-	fontface = g_malloc(64);
-	fontname = gtk_font_selection_get_font_name(fontsel);
+    struct conversation *c = gtk_object_get_user_data(GTK_OBJECT(fontsel));
 	
-	for (i = 0; i < strlen(fontname); i++)
+	if (c)
 	{
-		if (fontname[i] == '-')
+		g_free(c->current_fontname);
+		g_free(c->current_fontface);
+		c->current_fontface = g_malloc(64);
+		c->current_fontname = gtk_font_selection_get_font_name(fontsel);
+
+		for (i = 0; i < strlen(c->current_fontname); i++)
 		{
-			if (++j > 2)
-				break;	
-		}		
-		else if (j == 2)
-			fontface[k++] = fontname[i];
+			if (c->current_fontname[i] == '-')
+			{
+				if (++j > 2)
+					break;	
+			}		
+			else if (j == 2)
+				c->current_fontface[k++] = c->current_fontname[i];
+		}
+		c->current_fontface[k] = '\0';
+
+		set_font_face(NULL, c);
 	}
-	fontface[k] = '\0';
+	else
+	{
+		if (fontface)
+			g_free(fontface);
+		
+		fontface = g_malloc(64);
+		fontname = gtk_font_selection_get_font_name(fontsel);
 	
-	save_prefs();
+		for (i = 0; i < strlen(fontname); i++)
+		{
+			if (fontname[i] == '-')
+			{
+				if (++j > 2)
+					break;	
+			}		
+			else if (j == 2)
+				fontface[k++] = fontname[i];
+		}
+		fontface[k] = '\0';
 	
-	cancel_font(widget, NULL);	
+		save_prefs();
+	}
+	
+	cancel_font(widget, NULL);
 }
 
 void show_font_dialog(GtkWidget *widget, GtkWidget *font)
 {
 	GtkWidget *fontsel;
-
+	
 	fontdialog = gtk_font_selection_dialog_new("Select Font");
 	fontsel = GTK_FONT_SELECTION_DIALOG(fontdialog)->fontsel;
-	
+
+	if (font)
+		gtk_object_set_user_data(GTK_OBJECT(fontsel), gtk_object_get_user_data(GTK_OBJECT(font)));
+	else
+		gtk_object_set_user_data(GTK_OBJECT(fontsel), NULL);
+			
 	gtk_font_selection_dialog_set_font_name((GtkFontSelectionDialog *)fontdialog, DEFAULT_FONT_NAME);	
 	gtk_window_set_modal(GTK_WINDOW(fontdialog), TRUE);
 	gtk_signal_connect(GTK_OBJECT(fontdialog), "delete_event", GTK_SIGNAL_FUNC(cancel_font), font);
--- a/src/gaim.h	Mon May 15 17:43:04 2000 +0000
+++ b/src/gaim.h	Tue May 16 20:48:47 2000 +0000
@@ -226,12 +226,15 @@
 	GtkWidget *underline;
 	GtkWidget *palette;
 	GtkWidget *link;
-        GtkWidget *add_button;
-        GtkWidget *log_button;
+    GtkWidget *add_button;
+    GtkWidget *log_button;
 	GtkWidget *strike;
+	GtkWidget *font;
 
-        int makesound;
-        time_t sent_away;
+	char *current_fontface;
+	char *current_fontname;
+	int makesound;
+ 	time_t sent_away;
 };
 
 struct file_header {
@@ -334,7 +337,7 @@
 #define TYPE_SIGNOFF   4
 #define TYPE_KEEPALIVE 5
 
-#define REVISION "gaim:$Revision: 240 $"
+#define REVISION "gaim:$Revision: 244 $"
 #define FLAPON "FLAPON\r\n\r\n"
 
 #define ROAST "Tic/Toc"
@@ -363,10 +366,6 @@
 extern char *fontface;
 extern char *fontname;
 
-/* Globals in dialog.c */
-extern char *fontface;
-extern char *fontname;
-
 /* Globals in network.c */
 
 /* Globals in toc.c */
@@ -547,6 +546,7 @@
 extern void update_log_convs();
 extern void update_transparency();
 extern void update_font_buttons();
+extern void toggle_sensitive(GtkWidget *widget, GtkWidget *to_toggle);
 
 /* Functions in network.c */
 extern unsigned int *get_address(char *);
--- a/src/prefs.c	Mon May 15 17:43:04 2000 +0000
+++ b/src/prefs.c	Tue May 16 20:48:47 2000 +0000
@@ -334,6 +334,7 @@
 	GtkWidget *sw2;
 	GtkWidget *away_page;
 	GtkWidget *select_font;
+	GtkWidget *font_face_for_text;
 	
 	GtkWidget *list_item;
 
@@ -728,13 +729,16 @@
 	gaim_button("Italics Text", &font_options, OPT_FONT_ITALIC, fontbox);
 	gaim_button("Underlined Text", &font_options, OPT_FONT_UNDERLINE, fontbox);
 	gaim_button("Strike Text", &font_options, OPT_FONT_STRIKE, fontbox);
-	gaim_button("Font Face for Text", &font_options, OPT_FONT_FACE, fontbox);
-	
+	font_face_for_text = gaim_button("Font Face for Text", &font_options, OPT_FONT_FACE, fontbox);
+		
 	select_font = gtk_button_new_with_label("Select Font");
 	gtk_box_pack_start(GTK_BOX(fontbox), select_font, FALSE, FALSE, 0);
 	gtk_signal_connect(GTK_OBJECT(select_font), "clicked", GTK_SIGNAL_FUNC(show_font_dialog), NULL);
+	if (!(font_options & OPT_FONT_FACE))
+	    gtk_widget_set_sensitive(GTK_WIDGET(select_font), FALSE);
 	gtk_widget_show(select_font);
-
+	gtk_signal_connect(GTK_OBJECT(font_face_for_text), "clicked", GTK_SIGNAL_FUNC(toggle_sensitive), select_font);
+	
 	gtk_widget_show(appearance_page);
 	gtk_widget_show(fontbox);
 	gtk_widget_show(fontframe);
--- a/src/proxy.c	Mon May 15 17:43:04 2000 +0000
+++ b/src/proxy.c	Tue May 16 20:48:47 2000 +0000
@@ -174,9 +174,46 @@
 	        
                 return ret;
                 break;
-        case PROXY_SOCKS:
-                fprintf(stderr,"Socks proxy is not yet implemented.\n");
-                return(-1);
+        case PROXY_SOCKS: /* Socks v4 proxy (? I'm not a proxy hacker) */
+		/* this is going to be a cross between the HTTP proxy code
+		 * above and the TiK proxy code, translated from tcl->C */
+		/*
+		{
+			struct hostent *hostinfo;
+			unsigned short shortport = proxy_port;
+
+			memset(&name, 0, sizeof (name));
+			name.sin_family = AF_INET;
+			name.sin_port = htons (shortport);
+			hostinfo = gethostbyname (proxy_host);
+			if (hostinfo == NULL) {
+				fprintf (stderr, "Unknown host %s.\n", proxy_host);
+				return (-1);
+			}
+			name.sin_addr = *(struct in_addr *) hostinfo->h_addr;
+		}
+		sprintf(debug_buff,"Trying to connect ...\n");
+		debug_print(debug_buff);
+		if ((ret = connect(sockfd,(struct sockaddr *)&name,sizeof(name)))<0)
+			return(ret);
+*/
+		/* here's where it's no longer http proxy and is now tik */
+/*		{
+			char cmd[80];
+			char *inputline;
+
+			snprintf(cmd, 80, "\0x4\0x1%d%d%d%d%d", toc_port,
+					toc_server_1,
+					toc_server_2, /* the second part of the
+							 ip address: 1.this.1.1
+						      *//*
+					toc_server_3,
+					toc_server_4);
+                        if (send(sockfd,cmd,strlen(cmd),0)<0)
+                                return(-1);
+                        if (proxy_recv_line(sockfd,&inputline) < 0) {
+                                return(-1);
+                        }*/
                 break;
         default:
                 fprintf(stderr,"Unknown proxy type : %d.\n",proxy_type);