Mercurial > pidgin.yaz
changeset 6436:759a81390b36
[gaim-migrate @ 6944]
Blist on top option moved here. Added option to always make
docked windows on top. Installed GTK+ Version is now displayed here. Option
to turn off Conversation Window flashing.
committer: Tailor Script <tailor@pidgin.im>
author | Herman Bloggs <hermanator12002@yahoo.com> |
---|---|
date | Tue, 12 Aug 2003 01:30:08 +0000 |
parents | 53a613fed06d |
children | ae4c3abbaac1 |
files | plugins/win32/winprefs/gtkappbar.c plugins/win32/winprefs/gtkappbar.h plugins/win32/winprefs/winprefs.c |
diffstat | 3 files changed, 189 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/win32/winprefs/gtkappbar.c Tue Aug 12 01:26:23 2003 +0000 +++ b/plugins/win32/winprefs/gtkappbar.c Tue Aug 12 01:30:08 2003 +0000 @@ -152,6 +152,16 @@ SHAppBarMessage(ABM_SETPOS, &abd); } +static void gtk_appbar_dispatch_dock_cbs(GtkAppBar *ab, gboolean val) { + GList *lst = ab->dock_cbs; + + while(lst) { + GtkAppBarDockCB dock_cb = lst->data; + dock_cb(val); + lst = lst->next; + } +} + static GdkFilterReturn wnd_moving(GtkAppBar *ab, GdkXEvent *xevent) { MSG *msg = (MSG*)xevent; POINT cp; @@ -243,9 +253,11 @@ gtk_appbar_setpos(ab, msg->hwnd); ab->docking = FALSE; ab->docked = TRUE; + gtk_appbar_dispatch_dock_cbs(ab, TRUE); } else if(!ab->docked) { gtk_appbar_unregister(ab, msg->hwnd); + gtk_appbar_dispatch_dock_cbs(ab, FALSE); } return GDK_FILTER_CONTINUE; @@ -416,6 +428,12 @@ ab->docked = TRUE; } +void gtk_appbar_add_dock_cb(GtkAppBar *ab, GtkAppBarDockCB dock_cb) { + if(!ab) + return; + ab->dock_cbs = g_list_append(ab->dock_cbs, dock_cb); +} + GtkAppBar *gtk_appbar_add(GtkWidget *win) { GtkAppBar *ab;
--- a/plugins/win32/winprefs/gtkappbar.h Tue Aug 12 01:26:23 2003 +0000 +++ b/plugins/win32/winprefs/gtkappbar.h Tue Aug 12 01:30:08 2003 +0000 @@ -33,10 +33,14 @@ gboolean docked; gboolean docking; gboolean registered; + GList *dock_cbs; } GtkAppBar; +typedef void (*GtkAppBarDockCB)(gboolean); + GtkAppBar *gtk_appbar_add(GtkWidget *win); void gtk_appbar_remove(GtkAppBar *ab); void gtk_appbar_dock(GtkAppBar *ab, UINT side); +void gtk_appbar_add_dock_cb(GtkAppBar *ab, GtkAppBarDockCB dock_cb); #endif /* _GTKAPPBAR_H_ */
--- a/plugins/win32/winprefs/winprefs.c Tue Aug 12 01:26:23 2003 +0000 +++ b/plugins/win32/winprefs/winprefs.c Tue Aug 12 01:30:08 2003 +0000 @@ -50,6 +50,10 @@ static const char *OPT_WINPREFS_DBLIST_DOCKED = "/plugins/gtk/win32/winprefs/dblist_docked"; static const char *OPT_WINPREFS_DBLIST_HEIGHT = "/plugins/gtk/win32/winprefs/dblist_height"; static const char *OPT_WINPREFS_DBLIST_SIDE = "/plugins/gtk/win32/winprefs/dblist_side"; +static const char *OPT_WINPREFS_DBLIST_ON_TOP = "/plugins/gtk/win32/winprefs/dblist_on_top"; +static const char *OPT_WINPREFS_BLIST_ON_TOP = "/plugins/gtk/win32/winprefs/blist_on_top"; +static const char *OPT_WINPREFS_IM_BLINK = "/plugins/gtk/win32/winprefs/im_blink"; + static GaimPlugin *plugin_id = NULL; static GtkAppBar *blist_ab = NULL; static GtkWidget *blist = NULL; @@ -76,34 +80,74 @@ /* BLIST DOCKING */ static void blist_save_state() { - if(blist_ab && gaim_prefs_get_bool(OPT_WINPREFS_DBLIST_DOCKABLE)) { - if(blist_ab->docked) { + if(blist_ab) { + if(gaim_prefs_get_bool(OPT_WINPREFS_DBLIST_DOCKABLE) && blist_ab->docked) { gaim_prefs_set_int(OPT_WINPREFS_DBLIST_HEIGHT, blist_ab->undocked_height); gaim_prefs_set_int(OPT_WINPREFS_DBLIST_SIDE, blist_ab->side); + gaim_prefs_set_bool(OPT_WINPREFS_DBLIST_DOCKED, blist_ab->docked); } - gaim_prefs_set_bool(OPT_WINPREFS_DBLIST_DOCKED, blist_ab->docked); + else + gaim_prefs_set_bool(OPT_WINPREFS_DBLIST_DOCKED, FALSE); } +} + +static void blist_set_ontop(gboolean val) { + if(!blist) + return; + if(val) + SetWindowPos(GDK_WINDOW_HWND(blist->window), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); else - gaim_prefs_set_bool(OPT_WINPREFS_DBLIST_DOCKED, FALSE); + SetWindowPos(GDK_WINDOW_HWND(blist->window), HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); +} + +static void blist_dock_cb(gboolean val) { + if(val) { + gaim_debug(GAIM_DEBUG_INFO, "winprefs", "Blist Docking..\n"); + if(gaim_prefs_get_bool(OPT_WINPREFS_DBLIST_ON_TOP)) + blist_set_ontop(TRUE); + } + else { + gaim_debug(GAIM_DEBUG_INFO, "winprefs", "Blist Undocking..\n"); + if(gaim_prefs_get_bool(OPT_WINPREFS_DBLIST_ON_TOP) && + !gaim_prefs_get_bool(OPT_WINPREFS_BLIST_ON_TOP)) + blist_set_ontop(FALSE); + } } static void blist_set_dockable(gboolean val) { if(val) { - if(!blist_ab && blist) + if(!blist_ab && blist) { blist_ab = gtk_appbar_add(blist); + gtk_appbar_add_dock_cb(blist_ab, blist_dock_cb); + } } else { + if(gaim_prefs_get_bool(OPT_WINPREFS_DBLIST_ON_TOP) && + !gaim_prefs_get_bool(OPT_WINPREFS_BLIST_ON_TOP)) + blist_set_ontop(FALSE); gtk_appbar_remove(blist_ab); blist_ab = NULL; } } +/* PLUGIN CALLBACKS */ + +/* We need this because the blist destroy cb won't be called before the + plugin is unloaded, when quitting */ static void gaim_quit_cb() { gaim_debug(GAIM_DEBUG_INFO, WINPREFS_PLUGIN_ID, "gaim_quit_cb: removing appbar\n"); blist_save_state(); blist_set_dockable(FALSE); } +/* Needed when the last account is signed off.. and we get the login window */ +static void blist_destroy_cb() { + gaim_debug(GAIM_DEBUG_INFO, "winprefs", "blist_destroy_cb\n"); + blist_save_state(); + blist_set_dockable(FALSE); + gaim_signal_connect(plugin_id, event_signon, blist_create_cb, NULL); +} + static gboolean blist_create_cb_remove(gpointer data) { gaim_signal_disconnect(plugin_id, event_signon, blist_create_cb); return FALSE; @@ -113,20 +157,26 @@ gaim_debug(GAIM_DEBUG_INFO, WINPREFS_PLUGIN_ID, "event_signon\n"); blist = GAIM_GTK_BLIST(gaim_get_blist())->window; + g_signal_connect(blist, "destroy", blist_destroy_cb, NULL); + if(gaim_prefs_get_bool(OPT_WINPREFS_DBLIST_DOCKABLE)) { blist_set_dockable(TRUE); if(gaim_prefs_get_bool(OPT_WINPREFS_DBLIST_DOCKED)) { blist_ab->undocked_height = gaim_prefs_get_int(OPT_WINPREFS_DBLIST_HEIGHT); gtk_appbar_dock(blist_ab, gaim_prefs_get_int(OPT_WINPREFS_DBLIST_SIDE)); + if(gaim_prefs_get_bool(OPT_WINPREFS_DBLIST_ON_TOP)) + blist_set_ontop(TRUE); } } + if(gaim_prefs_get_bool(OPT_WINPREFS_BLIST_ON_TOP)) { + blist_set_ontop(TRUE); + } /* removing here will cause a crash when going to next cb in the gaim signal cb loop.. so process delayed. */ g_idle_add(blist_create_cb_remove, NULL); } - /* AUTOSTART */ static int open_run_key(PHKEY phKey, REGSAM samDesired) { @@ -178,11 +228,48 @@ RegCloseKey(hKey); } -static void winprefs_set_blist_dockable(GtkWidget *w) { +static void winprefs_set_blist_dockable(GtkWidget *w, GtkWidget *w1) { gaim_prefs_set_bool(OPT_WINPREFS_DBLIST_DOCKABLE, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w))); - gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w)) ? blist_set_dockable(TRUE) : blist_set_dockable(FALSE); + if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w))) { + blist_set_dockable(TRUE); + gtk_widget_set_sensitive(w1, TRUE); + } + else { + blist_set_dockable(FALSE); + gtk_widget_set_sensitive(w1, FALSE); + } } +static void winprefs_set_blist_ontop(GtkWidget *w) { + gaim_prefs_set_bool(OPT_WINPREFS_BLIST_ON_TOP, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w))); + + if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w))) { + blist_set_ontop(TRUE); + } + else { + if(!(gaim_prefs_get_bool(OPT_WINPREFS_DBLIST_DOCKABLE) && + gaim_prefs_get_bool(OPT_WINPREFS_DBLIST_ON_TOP) && + (blist_ab && blist_ab->docked))) + blist_set_ontop(FALSE); + } +} + +static void winprefs_set_dblist_ontop(GtkWidget *w) { + gaim_prefs_set_bool(OPT_WINPREFS_DBLIST_ON_TOP, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w))); + if(blist && blist_ab) { + if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w))) { + if(blist_ab->docked) + blist_set_ontop(TRUE); + } + else if(!gaim_prefs_get_bool(OPT_WINPREFS_BLIST_ON_TOP)) + blist_set_ontop(FALSE); + } +} + +static void winprefs_set_im_blink(GtkWidget *w) { + gaim_prefs_set_bool(OPT_WINPREFS_IM_BLINK, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w))); + wgaim_im_blink_state(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w))); +} /* * EXPORTED FUNCTIONS @@ -192,14 +279,21 @@ plugin_id = plugin; /* blist docking init */ - if(!blist && gaim_get_blist() && GAIM_GTK_BLIST(gaim_get_blist())) { + if(gaim_get_blist() && GAIM_GTK_BLIST(gaim_get_blist())) { blist = GAIM_GTK_BLIST(gaim_get_blist())->window; + /* Set Dockable */ if(gaim_prefs_get_bool(OPT_WINPREFS_DBLIST_DOCKABLE)) blist_set_dockable(TRUE); + /* Set On top */ + if(gaim_prefs_get_bool(OPT_WINPREFS_BLIST_ON_TOP)) + blist_set_ontop(TRUE); + g_signal_connect(blist, "destroy", blist_destroy_cb, NULL); } else gaim_signal_connect(plugin, event_signon, blist_create_cb, NULL); + wgaim_im_blink_state(gaim_prefs_get_bool(OPT_WINPREFS_IM_BLINK)); + gaim_signal_connect(plugin, event_quit, gaim_quit_cb, NULL); return TRUE; @@ -207,21 +301,57 @@ gboolean plugin_unload(GaimPlugin *plugin) { blist_set_dockable(FALSE); + wgaim_im_blink_state(TRUE); return TRUE; } static GtkWidget* get_config_frame(GaimPlugin *plugin) { GtkWidget *ret; GtkWidget *button; + GtkWidget *dbutton; GtkWidget *vbox; - HKEY hKey; + char* gtk_version = NULL; + HKEY hKey = HKEY_CURRENT_USER; ret = gtk_vbox_new(FALSE, 18); gtk_container_set_border_width (GTK_CONTAINER (ret), 12); - vbox = gaim_gtk_make_frame (ret, _("Startup")); + while(hKey) { + char version[25]; + DWORD vlen = 25; + if(wgaim_read_reg_string(hKey, "SOFTWARE\\GTK\\2.0", "Version", (LPBYTE)&version, &vlen)) { + char revision[25]; + DWORD rlen = 25; + gboolean gotrev = FALSE; + if(wgaim_read_reg_string(hKey, "SOFTWARE\\GTK\\2.0", "Revision", (LPBYTE)&revision, &rlen)) { + revision[0] = g_ascii_toupper(revision[0]); + revision[1] = '\0'; + gotrev = TRUE; + } + gtk_version = g_strdup_printf("%s%s%s", + version, + gotrev?" Revision ":"", + gotrev?revision:""); + hKey = 0; + } + if(hKey == HKEY_CURRENT_USER) + hKey = HKEY_LOCAL_MACHINE; + else if(hKey == HKEY_LOCAL_MACHINE) + hKey = 0; + } + + /* Display Installed GTK+ Runtime Version */ + if(gtk_version) { + GtkWidget *label; + vbox = gaim_gtk_make_frame(ret, _("GTK+ Runtime Version")); + label = gtk_label_new(gtk_version); + gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); + gtk_widget_show(label); + g_free(gtk_version); + } /* Autostart */ + vbox = gaim_gtk_make_frame (ret, _("Startup")); button = wgaim_button(_("_Start Gaim on Windows startup"), vbox); if(open_run_key(&hKey, KEY_QUERY_VALUE)) { if(ERROR_SUCCESS == RegQueryValueEx(hKey, "Gaim", 0, NULL, NULL, NULL)) { @@ -230,11 +360,32 @@ } gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(winprefs_set_autostart), NULL); - /* Dockable Blist */ + /* Buddy List */ + vbox = gaim_gtk_make_frame (ret, _("Buddy List")); button = wgaim_button(_("_Dockable Buddy List"), vbox); - gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(winprefs_set_blist_dockable), NULL); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), gaim_prefs_get_bool(OPT_WINPREFS_DBLIST_DOCKABLE)); + /* Docked Blist On Top */ + dbutton = wgaim_button(_("Docked _Buddy List is always on top"), vbox); + gtk_signal_connect(GTK_OBJECT(dbutton), "clicked", GTK_SIGNAL_FUNC(winprefs_set_dblist_ontop), NULL); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dbutton), gaim_prefs_get_bool(OPT_WINPREFS_DBLIST_ON_TOP)); + if(!gaim_prefs_get_bool(OPT_WINPREFS_DBLIST_DOCKABLE)) + gtk_widget_set_sensitive(GTK_WIDGET(dbutton), FALSE); + + /* Connect cb for Dockable option.. passing dblist on top button */ + gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(winprefs_set_blist_dockable), dbutton); + + /* Blist On Top */ + button = wgaim_button(_("_Keep Buddy List window on top"), vbox); + gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(winprefs_set_blist_ontop), NULL); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), gaim_prefs_get_bool(OPT_WINPREFS_BLIST_ON_TOP)); + + /* Conversations */ + vbox = gaim_gtk_make_frame (ret, _("Conversations")); + button = wgaim_button(_("_Flash Window when messages are received"), vbox); + gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(winprefs_set_im_blink), NULL); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), gaim_prefs_get_bool(OPT_WINPREFS_IM_BLINK)); + gtk_widget_show_all(ret); return ret; } @@ -275,6 +426,9 @@ gaim_prefs_add_bool(OPT_WINPREFS_DBLIST_DOCKED, FALSE); gaim_prefs_add_int(OPT_WINPREFS_DBLIST_HEIGHT, 0); gaim_prefs_add_int(OPT_WINPREFS_DBLIST_SIDE, 0); + gaim_prefs_add_bool(OPT_WINPREFS_DBLIST_ON_TOP, FALSE); + gaim_prefs_add_bool(OPT_WINPREFS_BLIST_ON_TOP, FALSE); + gaim_prefs_add_bool(OPT_WINPREFS_IM_BLINK, TRUE); } GAIM_INIT_PLUGIN(winprefs, init_plugin, info)