changeset 18:99d91a6c2fbf

[gaim-migrate @ 27] Yet another patch by Eric. Someone needs to stop this boy :) committer: Tailor Script <tailor@pidgin.im>
author Rob Flynn <gaim@robflynn.com>
date Thu, 23 Mar 2000 18:40:39 +0000
parents e5cc6e691bff
children 2cb360d65c98
files src/away.c src/buddy.c src/gnome_applet_mgr.c src/gnome_applet_mgr.h src/prefs.c
diffstat 5 files changed, 96 insertions(+), 43 deletions(-) [+]
line wrap: on
line diff
--- a/src/away.c	Thu Mar 23 12:44:52 2000 +0000
+++ b/src/away.c	Thu Mar 23 18:40:39 2000 +0000
@@ -37,25 +37,18 @@
 GtkWidget *awaymenu;
 struct away_message *awaymessage = NULL;
 
-#ifndef USE_APPLET
 static void destroy_im_away()
 {
 	if (imaway)
 		gtk_widget_destroy(imaway);
 	imaway=NULL;
 }
-#endif /* USE_APPLET */
 
 void do_im_back(GtkWidget *w, GtkWidget *x)
 {
 #ifdef USE_APPLET
+  if(!blist) applet_widget_unregister_callback(APPLET_WIDGET(applet),"buddy");
   applet_widget_unregister_callback(APPLET_WIDGET(applet),"away");
-  if(!blist) applet_widget_unregister_callback(APPLET_WIDGET(applet),"buddy");
-  applet_widget_register_callback(APPLET_WIDGET(applet),
-                "away",
-                _("Away Message"),
-                show_away_mess,
-                NULL);
 	if(!blist) {
 	        applet_widget_register_callback(APPLET_WIDGET(applet),
         	        "buddy",
@@ -63,6 +56,7 @@
       		        (AppletCallbackFunc)make_buddy,
                 	NULL);
 	}
+  insert_applet_away();
 #endif /* USE_APPLET */
 	if (imaway) {
 		gtk_widget_destroy(imaway);
@@ -75,21 +69,6 @@
 
 void do_away_message(GtkWidget *w, struct away_message *a)
 {
-#ifdef USE_APPLET
-        applet_widget_unregister_callback(APPLET_WIDGET(applet),"away");
-        if(!blist) applet_widget_unregister_callback(APPLET_WIDGET(applet),"buddy");
-        applet_widget_register_callback(APPLET_WIDGET(applet),
-                                        "away",
-                                        _("Back"),
-                                        (AppletCallbackFunc) do_im_back,
-                                        NULL);
-        if(!blist) applet_widget_register_callback(APPLET_WIDGET(applet),
-                                                   "buddy",
-                                                   _("Buddy List"),
-                                                   (AppletCallbackFunc)make_buddy,
-                                                   NULL);
-#else
-
 	GtkWidget *back;
 	GtkWidget *awaytext;
         GtkWidget *vscrollbar;
@@ -101,6 +80,21 @@
         GList *cnv = conversations;
         struct conversation *c;
 
+#ifdef USE_APPLET
+        if(!blist) applet_widget_unregister_callback(APPLET_WIDGET(applet),"buddy");
+	remove_applet_away();
+        if(!blist) applet_widget_register_callback(APPLET_WIDGET(applet),
+                                                   "buddy",
+                                                   _("Buddy List"),
+                                                   (AppletCallbackFunc)make_buddy,
+                                                   NULL);
+        applet_widget_register_callback(APPLET_WIDGET(applet),
+                                        "away",
+                                        _("Back"),
+                                        (AppletCallbackFunc) do_im_back,
+                                        NULL);
+#endif
+
 	if (!imaway) {
 		imaway = gtk_window_new(GTK_WINDOW_DIALOG);
 		gtk_widget_realize(imaway);
@@ -165,11 +159,18 @@
         serv_set_away(buf2);
         // g_free(buf2);
 	gtk_widget_show(imaway);
-#endif /* USE_APPLET */
 }
 
 void rem_away_mess(GtkWidget *w, struct away_message *a)
 {
+#ifdef USE_APPLET
+	char *awayname;
+	awayname = malloc(sizeof *awayname * (6 + strlen(a->name)));
+	awayname[0] = '\0';
+	strcat(awayname, "away/");
+	strcat(awayname, a->name);
+	applet_widget_unregister_callback(APPLET_WIDGET(applet), awayname);
+#endif
         away_messages = g_list_remove(away_messages, a);
         g_free(a);
         do_away_menu();
@@ -188,6 +189,17 @@
         GList *awy = away_messages;
         struct away_message *a;
 
+#ifdef USE_APPLET
+	remove_applet_away();
+	if (imaway)
+		applet_widget_register_callback(APPLET_WIDGET(applet),
+			"away",
+			_("Back"),
+			(AppletCallbackFunc)do_im_back,
+			NULL);
+	else
+		insert_applet_away();
+#endif
 
 	if (pd != NULL) {
                 gtk_list_clear_items(GTK_LIST(pd->away_list), 0, -1);
--- a/src/buddy.c	Thu Mar 23 12:44:52 2000 +0000
+++ b/src/buddy.c	Thu Mar 23 18:40:39 2000 +0000
@@ -318,7 +318,7 @@
 #ifdef USE_APPLET
         set_applet_draw_closed();
         applet_widget_unregister_callback(APPLET_WIDGET(applet),"signoff");
-	applet_widget_unregister_callback(APPLET_WIDGET(applet),"away");
+	remove_applet_away();
 	applet_widget_unregister_callback(APPLET_WIDGET(applet),"buddy");
         applet_widget_register_callback(APPLET_WIDGET(applet),
                 "signon",
--- a/src/gnome_applet_mgr.c	Thu Mar 23 12:44:52 2000 +0000
+++ b/src/gnome_applet_mgr.c	Thu Mar 23 18:40:39 2000 +0000
@@ -249,11 +249,7 @@
                 _("Signoff"),
                 signoff,
                 NULL);
-	applet_widget_register_callback(APPLET_WIDGET(applet),
-		"away",
-		_("Away Message"),
-		show_away_mess,
-		NULL);
+	insert_applet_away();
         applet_widget_register_callback(APPLET_WIDGET(applet),
                 "buddy",
                 _("Buddy List"),
@@ -261,6 +257,59 @@
                 NULL);
 }
 
+void insert_applet_away() {
+	GList *awy = away_messages;
+	struct away_message *a;
+	char  *awayname;
+
+	applet_widget_register_callback_dir(APPLET_WIDGET(applet),
+		"away",
+		_("Away"));
+	applet_widget_register_callback(APPLET_WIDGET(applet),
+		"away/new",
+		_("New Away Message"),
+		(AppletCallbackFunc)create_away_mess,
+		NULL);
+
+	while(awy) {
+		a = (struct away_message *)awy->data;
+
+		awayname = malloc(sizeof *awayname * (6 + strlen(a->name)));
+		awayname[0] = '\0';
+		strcat(awayname, "away/");
+		strcat(awayname, a->name);
+		applet_widget_register_callback(APPLET_WIDGET(applet),
+			awayname,
+			a->name,
+			(AppletCallbackFunc)do_away_message,
+			a);
+
+		awy = awy->next;
+	}
+}
+
+void remove_applet_away() {
+	GList *awy = away_messages;
+	struct away_message *a;
+	char  *awayname;
+
+	applet_widget_unregister_callback(APPLET_WIDGET(applet), "away/new");
+
+	while (awy) {
+		a = (struct away_message *)awy->data;
+
+		awayname = malloc(sizeof *awayname * (5 + strlen(a->name)));
+		awayname[0] = '\0';
+		strcat(awayname, "away/");
+		strcat(awayname, a->name);
+		applet_widget_unregister_callback(APPLET_WIDGET(applet), awayname);
+
+		awy = awy->next;
+	}
+	applet_widget_unregister_callback_dir(APPLET_WIDGET(applet), "away");
+	applet_widget_unregister_callback(APPLET_WIDGET(applet), "away");
+}
+
 /***************************************************************
 **
 ** function applet_show_about
@@ -411,15 +460,6 @@
      applet_draw_open = FALSE;
 }
 
-/**************************************************
-**
-**  Dummy function to fix compiles for gnome
-**  Feel free to implement an away message
-**
-***************************************************/ 
-void show_away_mess( AppletWidget *widget, gpointer data ) {
-}
-
 void AppletClicked( GtkWidget *sender, gpointer data ){
         
 	if( applet_draw_open ){
--- a/src/gnome_applet_mgr.h	Thu Mar 23 12:44:52 2000 +0000
+++ b/src/gnome_applet_mgr.h	Thu Mar 23 18:40:39 2000 +0000
@@ -88,7 +88,8 @@
 
 void set_applet_draw_closed();								/* indicates that the code has closed the window that is controled by clicking on the applet */
 
-void show_away_mess( AppletWidget *widget, gpointer data );
+void insert_applet_away();
+void remove_applet_away();
 
 
 
--- a/src/prefs.c	Thu Mar 23 12:44:52 2000 +0000
+++ b/src/prefs.c	Thu Mar 23 18:40:39 2000 +0000
@@ -103,7 +103,7 @@
 {
         display_options = display_options ^ (int)option;
 
-	update_button_pix();
+	if (blist) update_button_pix();
 
 	save_prefs();
 }
@@ -138,7 +138,7 @@
 		update_num_groups();
 	if (data == &showidle || data == &showpix)
 		update_show_idlepix();
-	if (data == &button_pix)
+	if (data == &button_pix && blist)
                 update_button_pix();
         if (data == &transparent)
                 update_transparency();
@@ -1006,7 +1006,7 @@
 
 void debug_print(char *chars)
 {
-	if(general_options & OPT_GEN_DEBUG)
+	if(general_options & OPT_GEN_DEBUG && dw)
             gtk_text_insert(GTK_TEXT(dw->entry),NULL, NULL, NULL, chars, strlen(chars));
 #ifdef DEBUG
         printf("%s\n", chars);