changeset 8427:2e18099ded93

[gaim-migrate @ 9157] I'm going to start committing stuff rapidly. I've turned off rich-text cut and paste, as I have about an hour to finish everything I want finished and don't think I can fit that in. This adds the protocol-specific smileys to the toolbar, and I think that's about it. committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Thu, 11 Mar 2004 20:02:00 +0000
parents aa755705bcf5
children 018406bb4ab6
files src/gtkconv.c src/gtkimhtml.c src/gtkimhtml.h src/gtkimhtmltoolbar.c src/gtkimhtmltoolbar.h
diffstat 5 files changed, 41 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/src/gtkconv.c	Thu Mar 11 02:54:09 2004 +0000
+++ b/src/gtkconv.c	Thu Mar 11 20:02:00 2004 +0000
@@ -2341,6 +2341,7 @@
 			buttons = GTK_IMHTML_SMILEY;
 		}
 		gtk_imhtml_set_format_functions(GTK_IMHTML(gtkconv->entry), buttons);
+		gtk_imhtmltoolbar_associate_smileys (GTK_IMHTMLTOOLBAR(gtkconv->toolbar), gaim_account_get_protocol_id(gaim_conversation_get_account(conv)));
 
 #if 0
 		/* Deal with menu items */
--- a/src/gtkimhtml.c	Thu Mar 11 02:54:09 2004 +0000
+++ b/src/gtkimhtml.c	Thu Mar 11 20:02:00 2004 +0000
@@ -88,6 +88,7 @@
 	URL_CLICKED,
 	BUTTONS_UPDATE,
 	TOGGLE_FORMAT,
+	CLEAR_FORMAT,
 	LAST_SIGNAL
 };
 static guint signals [LAST_SIGNAL] = { 0 };
@@ -631,8 +632,16 @@
 					      NULL,
 					      0,
 					      g_cclosure_marshal_VOID__POINTER,
-					      G_TYPE_NONE, 1,
+					      G_TYPE_NONE, 1, 
 					      G_TYPE_INT);
+	signals[CLEAR_FORMAT] = g_signal_new("format_function_clear",
+					      G_TYPE_FROM_CLASS(gobject_class),
+					      G_SIGNAL_RUN_FIRST,
+					      G_STRUCT_OFFSET(GtkIMHtmlClass, clear_format),
+					      NULL,
+					      0,
+					      g_cclosure_marshal_VOID__POINTER,
+					     G_TYPE_NONE, 0);
 	gobject_class->finalize = gtk_imhtml_finalize;
 }
 
@@ -682,11 +691,13 @@
 			  GDK_ACTION_COPY);
 	g_signal_connect(G_OBJECT(imhtml), "drag_data_received", G_CALLBACK(gtk_imhtml_link_drag_rcv_cb), imhtml);
 
+#if 0 /* Remove buggy copy-and-paste for 0.76 */
 #if GTK_CHECK_VERSION(2,2,0)
 	g_signal_connect(G_OBJECT(imhtml), "copy-clipboard", G_CALLBACK(copy_clipboard_cb), NULL);
 	g_signal_connect(G_OBJECT(imhtml), "paste-clipboard", G_CALLBACK(paste_clipboard_cb), NULL);
 	g_signal_connect(G_OBJECT(imhtml), "button-release-event", G_CALLBACK(button_release_cb), imhtml);
 #endif
+#endif
 	gtk_widget_add_events(GTK_WIDGET(imhtml), GDK_LEAVE_NOTIFY_MASK);
 
 	imhtml->tip = NULL;
@@ -2050,6 +2061,7 @@
 {
 	GList *del;
 	GtkTextIter start, end;
+	GObject *object = g_object_ref(G_OBJECT(imhtml));
 
 	gtk_text_buffer_get_start_iter(imhtml->text_buffer, &start);
 	gtk_text_buffer_get_end_iter(imhtml->text_buffer, &end);
@@ -2081,6 +2093,9 @@
 	imhtml->edit.backcolor = NULL;
 	imhtml->edit.sizespan = NULL;
 	imhtml->edit.fontsize = 3;
+	printf("Emiting signal\n");
+	g_signal_emit(object, signals[CLEAR_FORMAT], 0);
+	g_object_unref(object);
 }
 
 void gtk_imhtml_page_up (GtkIMHtml *imhtml)
--- a/src/gtkimhtml.h	Thu Mar 11 02:54:09 2004 +0000
+++ b/src/gtkimhtml.h	Thu Mar 11 20:02:00 2004 +0000
@@ -118,6 +118,7 @@
 	void (*url_clicked)(GtkIMHtml *, const gchar *);
 	void (*buttons_update)(GtkIMHtml *, GtkIMHtmlButtons);
 	void (*toggle_format)(GtkIMHtml *, GtkIMHtmlButtons);
+	void (*clear_format)(GtkIMHtml *);
 };
 
 struct _GtkIMHtmlFontDetail {
--- a/src/gtkimhtmltoolbar.c	Thu Mar 11 02:54:09 2004 +0000
+++ b/src/gtkimhtmltoolbar.c	Thu Mar 11 20:02:00 2004 +0000
@@ -538,14 +538,10 @@
 			return;
 		}
 
-		/*
-		  if(c->account)
-		  smileys = get_proto_smileys(
-		  gaim_account_get_protocol_id(gaim_conversation_get_account(c)));
+		if (toolbar->sml)
+			smileys = get_proto_smileys(toolbar->sml);
 		  else
-		*/
-
-		smileys = get_proto_smileys(GAIM_PROTO_DEFAULT);
+			  smileys = get_proto_smileys(GAIM_PROTO_DEFAULT);
 
 		while(smileys) {
 			GtkIMHtmlSmiley *smiley = smileys->data;
@@ -644,6 +640,11 @@
 	}
 }
 
+static void reset_buttons_cb(GtkIMHtml *imhtml, GtkIMHtmlToolbar *toolbar)
+{
+	printf("yo!\n");
+}
+
 enum {
 	LAST_SIGNAL
 };
@@ -654,6 +655,8 @@
 {
 	GtkIMHtmlToolbar *toolbar = GTK_IMHTMLTOOLBAR(object);
 
+	if (toolbar->sml)
+		free(toolbar->sml);
 	gtk_object_sink(GTK_OBJECT(toolbar->tooltips));
 
 	G_OBJECT_CLASS(parent_class)->finalize (object);
@@ -847,11 +850,7 @@
 	sep = gtk_hseparator_new();
 	gtk_box_pack_start(GTK_BOX(toolbar), sep, FALSE, FALSE, 0);
 	gtk_widget_show(sep);
-
-
-//if (!gaim_prefs_get_bool("/gaim/gtk/conversations/show_formatting_toolbar"))
-//	gtk_widget_hide(vbox);
-
+	toolbar->sml = NULL;
 	gtk_widget_show_all(hbox);
 }
 
@@ -895,4 +894,13 @@
 	toolbar->imhtml = imhtml;
 	g_signal_connect(G_OBJECT(imhtml), "format_functions_update", G_CALLBACK(update_buttons_cb), toolbar);
 	g_signal_connect(G_OBJECT(imhtml), "format_function_toggle", G_CALLBACK(toggle_button_cb), toolbar);
+	g_signal_connect(G_OBJECT(imhtml), "format_function_clear", G_CALLBACK(reset_buttons_cb), toolbar);
 }
+
+void gtk_imhtmltoolbar_associate_smileys(GtkIMHtmlToolbar *toolbar, const char *proto_id)
+{
+	if (toolbar->sml)
+		g_free(toolbar->sml);
+	
+	toolbar->sml = g_strdup(proto_id);
+}
--- a/src/gtkimhtmltoolbar.h	Thu Mar 11 02:54:09 2004 +0000
+++ b/src/gtkimhtmltoolbar.h	Thu Mar 11 20:02:00 2004 +0000
@@ -69,6 +69,8 @@
 	GtkWidget *link_dialog;
 	GtkWidget *smiley_dialog;
 	GtkWidget *image_dialog;
+
+	char *sml;
 };
 
 struct _GtkIMHtmlToolbarClass {
@@ -80,6 +82,7 @@
 GtkWidget* gtk_imhtmltoolbar_new              (void);
 
 void gtk_imhtmltoolbar_attach    (GtkIMHtmlToolbar *toolbar, GtkWidget *imhtml);
+void gtk_imhtmltoolbar_associate_smileys (GtkIMHtmlToolbar *toolbar, const char *proto_id);
 
 
 #ifdef __cplusplus