Mercurial > pidgin
changeset 3554:cf00549c53d7
[gaim-migrate @ 3644]
A long annoying patch by one Robert McQueen.
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Thu, 26 Sep 2002 15:23:33 +0000 |
parents | 57a233c032eb |
children | 5b3a3c6efbec |
files | ChangeLog plugins/SIGNALS plugins/docklet/docklet.c src/browser.c src/buddy.c src/conversation.c src/dialogs.c src/gaim.h src/multi.c src/ui.h |
diffstat | 10 files changed, 105 insertions(+), 103 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Thu Sep 26 14:26:11 2002 +0000 +++ b/ChangeLog Thu Sep 26 15:23:33 2002 +0000 @@ -71,8 +71,8 @@ * i18n fixes (Thanks Matt Wilson) * Removed Ctrl-C binding for color * Docklet plugin--replaces the old GNOME applet. You'll need the - Panel Notification Area applet for GNOME 2, or the patch from - RedHat for KDE 3. (Thanks Robert McQueen) + Panel Notification Area applet for GNOME 2, or the kicker for + KDE 3.1. (Thanks Robert McQueen, Ari Pollak, Patrick Aussems) * Plugins dialog and perl script menu merged into preferences. version 0.59 (06/24/2002):
--- a/plugins/SIGNALS Thu Sep 26 14:26:11 2002 +0000 +++ b/plugins/SIGNALS Thu Sep 26 15:23:33 2002 +0000 @@ -346,14 +346,14 @@ 'c' is he conversation being closed. -event_connecting +event_connecting: struct aim_user *u This is called when Gaim attempts to bring a user on-line. The - boolean u->connecting is set to true, and a global counter + boolean u->connecting is set to true, and connecting_count incremented. The attempt can end with event_signon or event_signoff being called, depending upon whether the attempt was a sucess or a failure. In both cases, u->connecting is set to false and the counter decremented. - 'u' is the account being connected + 'u' is the account being connected.
--- a/plugins/docklet/docklet.c Thu Sep 26 14:26:11 2002 +0000 +++ b/plugins/docklet/docklet.c Thu Sep 26 15:23:33 2002 +0000 @@ -26,13 +26,12 @@ - handle and update tooltips to show your current accounts - dernyi's account status menu in the right click - store icons in gtk2 stock icon thing (needs doing for the whole prog) - - pop up notices when GNOME2's system-tray-applet supports it, with a - prefs dialog to choose what to alert for */ + - optional pop up notices when GNOME2's system-tray-applet supports it + - support blinking the icon when messages are pending */ /* includes */ #define GAIM_PLUGINS #include <gtk/gtk.h> -#include <fcntl.h> #include "gaim.h" #include "eggtrayicon.h" @@ -48,35 +47,28 @@ /* functions */ static void docklet_create(); +static void docklet_update_status(); /* globals */ +static GtkWidget *configwin; static EggTrayIcon *docklet = NULL; static GtkWidget *icon; static enum docklet_status status; -static GtkWidget *configwin = NULL; -static void docklet_embedded(GtkWidget *widget, void *data) { - debug_printf("Docklet: embedded\n"); - docklet_add(); +static void docklet_toggle_mute(GtkWidget *toggle, void *data) { + mute_sounds = GTK_CHECK_MENU_ITEM(toggle)->active; } -static void docklet_destroyed(GtkWidget *widget, void *data) { - debug_printf("Docklet: destroyed\n"); - docklet_remove(); - docklet_create(); +static void docklet_toggle_queue(GtkWidget *widget, void *data) { + away_options ^= OPT_AWAY_QUEUE_UNREAD; + save_prefs(); } - - -static void docklet_mute(GtkWidget *toggle, void *data) { - mute_sounds = GTK_CHECK_MENU_ITEM(toggle)->active; - if (mute_sounds) { - debug_printf("Docklet: sounds muted\n"); - } else { - debug_printf("Docklet: sounds unmuted\n"); - } + +static void docklet_flush_queue() { + purge_away_queue(unread_message_queue); + unread_message_queue = NULL; } - static void docklet_menu(GdkEventButton *event) { static GtkWidget *menu = NULL; GtkWidget *entry; @@ -89,7 +81,7 @@ if (status == offline) { entry = gtk_menu_item_new_with_label(_("Auto-login")); - g_signal_connect(GTK_WIDGET(entry), "activate", G_CALLBACK(auto_login), NULL); + g_signal_connect(G_OBJECT(entry), "activate", G_CALLBACK(auto_login), NULL); gtk_menu_append(GTK_MENU(menu), entry); } else { if (status == online) { @@ -104,7 +96,7 @@ a = (struct away_message *)awy->data; entry = gtk_menu_item_new_with_label(a->name); - g_signal_connect(GTK_WIDGET(entry), "activate", G_CALLBACK(do_away_message), a); + g_signal_connect(G_OBJECT(entry), "activate", G_CALLBACK(do_away_message), a); gtk_menu_append(GTK_MENU(docklet_awaymenu), entry); awy = g_slist_next(awy); @@ -114,7 +106,7 @@ gtk_menu_append(GTK_MENU(docklet_awaymenu), entry); entry = gtk_menu_item_new_with_label(_("New...")); - g_signal_connect(GTK_WIDGET(entry), "activate", G_CALLBACK(create_away_mess), NULL); + g_signal_connect(G_OBJECT(entry), "activate", G_CALLBACK(create_away_mess), NULL); gtk_menu_append(GTK_MENU(docklet_awaymenu), entry); entry = gtk_menu_item_new_with_label(_("Away")); @@ -122,12 +114,12 @@ gtk_menu_append(GTK_MENU(menu), entry); } else { entry = gtk_menu_item_new_with_label(_("Back")); - g_signal_connect(GTK_WIDGET(entry), "activate", G_CALLBACK(do_im_back), NULL); + g_signal_connect(G_OBJECT(entry), "activate", G_CALLBACK(do_im_back), NULL); gtk_menu_append(GTK_MENU(menu), entry); } entry = gtk_menu_item_new_with_label(_("Signoff")); - g_signal_connect(GTK_WIDGET(entry), "activate", G_CALLBACK(signoff_all), NULL); + g_signal_connect(G_OBJECT(entry), "activate", G_CALLBACK(signoff_all), NULL); gtk_menu_append(GTK_MENU(menu), entry); } @@ -136,26 +128,26 @@ entry = gtk_check_menu_item_new_with_label(_("Mute Sounds")); gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(entry), mute_sounds); - g_signal_connect(GTK_WIDGET(entry), "toggled", G_CALLBACK(docklet_mute), NULL); + g_signal_connect(G_OBJECT(entry), "toggled", G_CALLBACK(docklet_toggle_mute), NULL); gtk_menu_append(GTK_MENU(menu), entry); entry = gtk_menu_item_new_with_label(_("Accounts")); - g_signal_connect(GTK_WIDGET(entry), "activate", G_CALLBACK(account_editor), NULL); + g_signal_connect(G_OBJECT(entry), "activate", G_CALLBACK(account_editor), NULL); gtk_menu_append(GTK_MENU(menu), entry); entry = gtk_image_menu_item_new_from_stock(GTK_STOCK_PREFERENCES, NULL); - g_signal_connect(GTK_WIDGET(entry), "activate", G_CALLBACK(show_prefs), NULL); + g_signal_connect(G_OBJECT(entry), "activate", G_CALLBACK(show_prefs), NULL); gtk_menu_append(GTK_MENU(menu), entry); entry = gtk_separator_menu_item_new(); gtk_menu_append(GTK_MENU(menu), entry); entry = gtk_menu_item_new_with_label(_("About")); - g_signal_connect(GTK_WIDGET(entry), "activate", G_CALLBACK(show_about), NULL); + g_signal_connect(G_OBJECT(entry), "activate", G_CALLBACK(show_about), NULL); gtk_menu_append(GTK_MENU(menu), entry); entry = gtk_image_menu_item_new_from_stock(GTK_STOCK_QUIT, NULL); - g_signal_connect(GTK_WIDGET(entry), "activate", G_CALLBACK(do_quit), NULL); + g_signal_connect(G_OBJECT(entry), "activate", G_CALLBACK(do_quit), NULL); gtk_menu_append(GTK_MENU(menu), entry); gtk_widget_show_all(menu); @@ -166,12 +158,12 @@ switch (event->button) { case 1: if (unread_message_queue) { - purge_away_queue(unread_message_queue); - unread_message_queue=NULL; + docklet_flush_queue(); docklet_update_status(); } - else + else { docklet_toggle(); + } break; case 2: break; @@ -238,6 +230,8 @@ } else { status = away; } + } else if (connecting_count) { + status = connecting; } else { status = online; } @@ -254,28 +248,47 @@ } } +static void docklet_embedded(GtkWidget *widget, void *data) { + debug_printf("Docklet: embedded\n"); + docklet_add(); +} + +static void docklet_destroyed(GtkWidget *widget, void *data) { + debug_printf("Docklet: destroyed\n"); + docklet_flush_queue(); + docklet_remove(); + docklet_create(); +} + static void docklet_create() { GtkWidget *box; - /* is this necessary/wise? */ - if (docklet) { - g_signal_handlers_disconnect_by_func(GTK_WIDGET(docklet), G_CALLBACK(docklet_destroyed), NULL); - gtk_widget_destroy(GTK_WIDGET(docklet)); - debug_printf("Docklet: freed\n"); + if (docklet) { + /* if this is being called when a docklet exists, it's because that + docklet is in the process of being destroyed. all we need to do + is tell gobject we're not interested in it any more, and throw + the pointer away. Alan Cox said so. */ + + /* Ooooh, look at me! I'm Robot101! I know Alan Cox! I talk to him + all the time! I'm sooooo special! --Sean Egan */ + g_object_unref(G_OBJECT(docklet)); + docklet = NULL; } docklet = egg_tray_icon_new("Gaim"); box = gtk_event_box_new(); icon = gtk_image_new(); - g_signal_connect(GTK_WIDGET(docklet), "embedded", G_CALLBACK(docklet_embedded), NULL); - g_signal_connect(GTK_WIDGET(docklet), "destroy", G_CALLBACK(docklet_destroyed), NULL); - g_signal_connect(box, "button-press-event", G_CALLBACK(docklet_clicked), NULL); + g_signal_connect(G_OBJECT(docklet), "embedded", G_CALLBACK(docklet_embedded), NULL); + g_signal_connect(G_OBJECT(docklet), "destroy", G_CALLBACK(docklet_destroyed), NULL); + g_signal_connect(G_OBJECT(box), "button-press-event", G_CALLBACK(docklet_clicked), NULL); gtk_container_add(GTK_CONTAINER(box), icon); gtk_container_add(GTK_CONTAINER(docklet), box); gtk_widget_show_all(GTK_WIDGET(docklet)); + /* ref the docklet before we bandy it about the place */ + g_object_ref(G_OBJECT(docklet)); docklet_update_status(); docklet_update_icon(); @@ -338,19 +351,34 @@ return NULL; } -static void toggle_queue (GtkWidget *w, void *null) { - away_options ^= OPT_AWAY_QUEUE_UNREAD; - save_prefs(); +void gaim_plugin_remove() { + if (GTK_WIDGET_VISIBLE(docklet)) { + docklet_remove(); + } + + docklet_flush_queue(); + + g_object_unref(G_OBJECT(docklet)); + g_signal_handlers_disconnect_by_func(G_OBJECT(docklet), G_CALLBACK(docklet_destroyed), NULL); + gtk_widget_destroy(GTK_WIDGET(docklet)); + + debug_printf("Docklet: removed\n"); } - + +static void config_close() { + configwin = NULL; +} + void gaim_plugin_config() { /* This is the sorriest dialog ever written ever */ /* It's a good thing I plan on rewriting it later tonight */ GtkWidget *button; GtkWidget *vbox; - if (configwin) return; + if (configwin) + return; GAIM_DIALOG(configwin); + g_signal_connect(G_OBJECT(configwin), "destroy", GTK_SIGNAL_FUNC(config_close), NULL); vbox = gtk_vbox_new(0, 6); gtk_container_add(GTK_CONTAINER(configwin), vbox); @@ -358,23 +386,11 @@ button = gtk_check_button_new_with_mnemonic("_Hide new messages until docklet is clicked"); gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), away_options & OPT_AWAY_QUEUE_UNREAD); - gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(toggle_queue), NULL); + g_signal_connect(G_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(docklet_toggle_queue), NULL); gtk_box_pack_end(GTK_BOX(vbox), button, 0, 0, 0); gtk_widget_show_all(configwin); } - - -void gaim_plugin_remove() { - if (GTK_WIDGET_VISIBLE(docklet)) { - docklet_remove(); - } - - g_signal_handlers_disconnect_by_func(GTK_WIDGET(docklet), G_CALLBACK(docklet_destroyed), NULL); - gtk_widget_destroy(GTK_WIDGET(docklet)); - - debug_printf("Docklet: removed\n"); -} struct gaim_plugin_description desc; struct gaim_plugin_description *gaim_plugin_desc() {
--- a/src/browser.c Thu Sep 26 14:26:11 2002 +0000 +++ b/src/browser.c Thu Sep 26 15:23:33 2002 +0000 @@ -490,7 +490,7 @@ mozilla_remote_init_atoms(); window = mozilla_remote_find_window(); - if (window && (((GdkWindowPrivate *) window)->destroyed == FALSE)) { + if (window && (GDK_WINDOW_OBJECT(window)->destroyed == FALSE)) { XSelectInput(gdk_display, GDK_WINDOW_XWINDOW(window), (PropertyChangeMask | StructureNotifyMask)); @@ -528,7 +528,7 @@ mozilla_remote_init_atoms(); window = mozilla_remote_find_window(); - if (window && (((GdkWindowPrivate *) window)->destroyed == FALSE)) { + if (window && (GDK_WINDOW_OBJECT(window)->destroyed == FALSE)) { XSelectInput(gdk_display, GDK_WINDOW_XWINDOW(window), (PropertyChangeMask | StructureNotifyMask));
--- a/src/buddy.c Thu Sep 26 14:26:11 2002 +0000 +++ b/src/buddy.c Thu Sep 26 15:23:33 2002 +0000 @@ -1999,7 +1999,7 @@ buddy list/login window--depending on which is active */ if (connections) { if (GTK_WIDGET_VISIBLE(blist)) { - if (DOCKLET_WINDOW_ICONIFIED(blist)) { + if (GAIM_WINDOW_ICONIFIED(blist)) { unhide_buddy_list(); } else { hide_buddy_list(); @@ -2009,7 +2009,7 @@ } } else { if (GTK_WIDGET_VISIBLE(mainwindow)) { - if (DOCKLET_WINDOW_ICONIFIED(mainwindow)) { + if (GAIM_WINDOW_ICONIFIED(mainwindow)) { gtk_window_present(GTK_WINDOW(mainwindow)); } else { gtk_widget_hide(mainwindow); @@ -2458,6 +2458,13 @@ } } +static void change_state_blist_window(GtkWidget *w, GdkEventWindowState *event, void *dummy) { + if (event->new_window_state & GDK_WINDOW_STATE_ICONIFIED && + docklet_count) { + gtk_widget_hide(blist); + } +} + /******************************************************************* * * Helper funs for making the menu @@ -2493,8 +2500,7 @@ gtk_widget_add_accelerator(menuitem, "activate", accel, str[0], GDK_MOD1_MASK, GTK_ACCEL_LOCKED); - gtk_widget_lock_accelerators(menuitem); - + return menuitem; } @@ -2544,7 +2550,6 @@ if (accel_key) { gtk_widget_add_accelerator(menuitem, "activate", accel, accel_key, accel_mods, GTK_ACCEL_LOCKED); - gtk_widget_lock_accelerators(menuitem); } return menuitem; @@ -2656,7 +2661,7 @@ gtk_window_set_policy(GTK_WINDOW(blist), TRUE, TRUE, TRUE); accel = gtk_accel_group_new(); - gtk_accel_group_attach(accel, G_OBJECT(blist)); + gtk_window_add_accel_group(G_OBJECT(blist), accel); menubar = gtk_menu_bar_new(); @@ -2867,6 +2872,8 @@ gtk_signal_connect(GTK_OBJECT(blist), "configure_event", GTK_SIGNAL_FUNC(configure_blist_window), NULL); + gtk_signal_connect(GTK_OBJECT(blist), "window_state_event", GTK_SIGNAL_FUNC(change_state_blist_window), + NULL);
--- a/src/conversation.c Thu Sep 26 14:26:11 2002 +0000 +++ b/src/conversation.c Thu Sep 26 15:23:33 2002 +0000 @@ -2118,7 +2118,7 @@ GtkWidget *win; GtkWidget *entry; - toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_ICONS); + toolbar = gtk_toolbar_new(); win = c->window; entry = c->entry;
--- a/src/dialogs.c Thu Sep 26 14:26:11 2002 +0000 +++ b/src/dialogs.c Thu Sep 26 15:23:33 2002 +0000 @@ -3692,7 +3692,7 @@ /* pack buttons */ if (c->gc->prpl->smiley_list == NULL) { - smiley_box = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_ICONS); + smiley_box = gtk_toolbar_new(); gtk_box_pack_start(GTK_BOX(vbox), smiley_box, TRUE, TRUE, 0); toolbar_add_smiley(c, smiley_box, angel_xpm, win, "O:-)"); @@ -3700,7 +3700,7 @@ toolbar_add_smiley(c, smiley_box, burp_xpm, win, ":-!"); toolbar_add_smiley(c, smiley_box, crossedlips_xpm, win, ":-X"); - smiley_box = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_ICONS); + smiley_box = gtk_toolbar_new(); gtk_box_pack_start(GTK_BOX(vbox), smiley_box, TRUE, TRUE, 0); toolbar_add_smiley(c, smiley_box, cry_xpm, win, ":'("); @@ -3708,7 +3708,7 @@ toolbar_add_smiley(c, smiley_box, kiss_xpm, win, ":-*"); toolbar_add_smiley(c, smiley_box, moneymouth_xpm, win, ":-$"); - smiley_box = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_ICONS); + smiley_box = gtk_toolbar_new(); gtk_box_pack_start(GTK_BOX(vbox), smiley_box, TRUE, TRUE, 0); toolbar_add_smiley(c, smiley_box, sad_xpm, win, ":-("); @@ -3716,7 +3716,7 @@ toolbar_add_smiley(c, smiley_box, smile_xpm, win, ":-)"); toolbar_add_smiley(c, smiley_box, smile8_xpm, win, "8-)"); - smiley_box = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_ICONS); + smiley_box = gtk_toolbar_new(); gtk_box_pack_start(GTK_BOX(vbox), smiley_box, TRUE, TRUE, 0); toolbar_add_smiley(c, smiley_box, think_xpm, win, ":-/"); @@ -3740,7 +3740,7 @@ smilies = c->gc->prpl->smiley_list(); - smiley_box = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_ICONS); + smiley_box = gtk_toolbar_new(); gtk_box_pack_start(GTK_BOX(vbox), smiley_box, TRUE, TRUE, 0); while (smilies) { @@ -3750,7 +3750,7 @@ if (smile->show) { if ((!(smiley_count % ((int)(sqrt(total_count))))) && (smiley_count > 0)) { - smiley_box = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_ICONS); + smiley_box = gtk_toolbar_new(); gtk_box_pack_start(GTK_BOX(vbox), smiley_box, TRUE, TRUE, 0); }
--- a/src/gaim.h Thu Sep 26 14:26:11 2002 +0000 +++ b/src/gaim.h Thu Sep 26 15:23:33 2002 +0000 @@ -353,7 +353,6 @@ extern void do_pounce(struct gaim_connection *, char *, int); void create_prpl_icon(GtkWidget *widget, struct gaim_connection *gc, GdkPixmap **pixmap, GdkBitmap **mask); -void docklet_toggle(); /* Functions in buddy_chat.c */ extern void show_new_buddy_chat(struct conversation *);
--- a/src/multi.c Thu Sep 26 14:26:11 2002 +0000 +++ b/src/multi.c Thu Sep 26 15:23:33 2002 +0000 @@ -1112,7 +1112,7 @@ gtk_widget_destroy(meter_win->window); g_free (meter_win); meter_win = NULL; - } + } } void account_online(struct gaim_connection *gc) @@ -1131,22 +1131,6 @@ if (mainwindow) gtk_widget_hide(mainwindow); -/* fixme: docklet - if (blist_options & OPT_BLIST_APP_BUDDY_SHOW) { - show_buddy_list(); - refresh_buddy_window(); - createOnlinePopup(); - applet_buddy_show = TRUE; - } else if (!blist) { - show_buddy_list(); - build_edit_tree(); - gtk_widget_hide(blist); - applet_buddy_show = FALSE; - } else { - build_edit_tree(); - } - set_user_state(online); */ - show_buddy_list(); refresh_buddy_window();
--- a/src/ui.h Thu Sep 26 14:26:11 2002 +0000 +++ b/src/ui.h Thu Sep 26 15:23:33 2002 +0000 @@ -31,12 +31,8 @@ #define GAIM_DIALOG(x) x = gtk_window_new(GTK_WINDOW_TOPLEVEL); \ gtk_window_set_type_hint(GTK_WINDOW(x), GDK_WINDOW_TYPE_HINT_DIALOG) -#define GdkWindowPrivate GdkWindowObject -#define gtk_toolbar_new(x,y) gtk_toolbar_new() -#define gtk_accel_group_attach(x, y) _gtk_accel_group_attach(x, y) -#define gtk_widget_lock_accelerators(x) -#define DOCKLET_WINDOW_ICONIFIED(x) (gdk_window_get_state(GTK_WIDGET(x)->window) & GDK_WINDOW_STATE_ICONIFIED) +#define GAIM_WINDOW_ICONIFIED(x) (gdk_window_get_state(GTK_WIDGET(x)->window) & GDK_WINDOW_STATE_ICONIFIED) #define DEFAULT_FONT_FACE "Helvetica"