Sat, 21 Jan 2006 00:46:36 +0000
[gaim-migrate @ 15326]
GtkTreeView::indent_expanders is a boolean value not an integer, so change
gaimrc to match. Also fix how changing settings works, all settings should be
instant-apply-on-change for gtk > 2.4, and will either work better or worse
than they did before with gtk < 2.4 (I'm not sure and don't have anywhere to
test.)
| 4134 | 1 | /* |
|
6409
ea9ba622db3f
[gaim-migrate @ 6915]
Herman Bloggs <herman@bluedigits.com>
parents:
6063
diff
changeset
|
2 | * gaim - WinGaim Options Plugin |
| 4134 | 3 | * |
| 11003 | 4 | * Gaim is the legal property of its developers, whose names are too numerous |
| 5 | * to list here. Please refer to the COPYRIGHT file distributed with this | |
| 6 | * source distribution. | |
|
6409
ea9ba622db3f
[gaim-migrate @ 6915]
Herman Bloggs <herman@bluedigits.com>
parents:
6063
diff
changeset
|
7 | * |
| 11003 | 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by | |
| 10 | * the Free Software Foundation; either version 2 of the License, or | |
| 4134 | 11 | * (at your option) any later version. |
| 12 | * | |
| 11003 | 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | * GNU General Public License for more details. | |
| 4134 | 17 | * |
| 11003 | 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software | |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 4134 | 21 | * |
| 22 | */ | |
|
11709
da6e9cd5f6d9
[gaim-migrate @ 14000]
Casey Harkins <charkins@pidgin.im>
parents:
11601
diff
changeset
|
23 | #include <gtk/gtk.h> |
|
6409
ea9ba622db3f
[gaim-migrate @ 6915]
Herman Bloggs <herman@bluedigits.com>
parents:
6063
diff
changeset
|
24 | #include <gdk/gdkwin32.h> |
|
5912
32619a71edd2
[gaim-migrate @ 6344]
Herman Bloggs <herman@bluedigits.com>
parents:
5854
diff
changeset
|
25 | |
|
32619a71edd2
[gaim-migrate @ 6344]
Herman Bloggs <herman@bluedigits.com>
parents:
5854
diff
changeset
|
26 | #include "internal.h" |
|
32619a71edd2
[gaim-migrate @ 6344]
Herman Bloggs <herman@bluedigits.com>
parents:
5854
diff
changeset
|
27 | |
|
6494
21e66a116e2a
[gaim-migrate @ 7009]
Herman Bloggs <herman@bluedigits.com>
parents:
6436
diff
changeset
|
28 | #include "core.h" |
| 11003 | 29 | #include "debug.h" |
|
5912
32619a71edd2
[gaim-migrate @ 6344]
Herman Bloggs <herman@bluedigits.com>
parents:
5854
diff
changeset
|
30 | #include "prefs.h" |
| 8760 | 31 | #include "signals.h" |
| 9954 | 32 | #include "version.h" |
|
5912
32619a71edd2
[gaim-migrate @ 6344]
Herman Bloggs <herman@bluedigits.com>
parents:
5854
diff
changeset
|
33 | |
| 11003 | 34 | #include "gtkappbar.h" |
| 35 | #include "gtkblist.h" | |
| 36 | #include "gtkconv.h" | |
|
5224
8cb89f5b912a
[gaim-migrate @ 5594]
Herman Bloggs <herman@bluedigits.com>
parents:
4606
diff
changeset
|
37 | #include "gtkplugin.h" |
| 11003 | 38 | #include "gtkprefs.h" |
|
5912
32619a71edd2
[gaim-migrate @ 6344]
Herman Bloggs <herman@bluedigits.com>
parents:
5854
diff
changeset
|
39 | #include "gtkutils.h" |
| 4134 | 40 | |
| 41 | /* | |
| 42 | * MACROS & DEFINES | |
| 43 | */ | |
| 5854 | 44 | #define WINPREFS_PLUGIN_ID "gtk-win-prefs" |
| 4134 | 45 | |
| 46 | /* | |
| 47 | * LOCALS | |
| 48 | */ | |
| 11003 | 49 | static const char *PREF_DBLIST_DOCKABLE = "/plugins/gtk/win32/winprefs/dblist_dockable"; |
| 50 | static const char *PREF_DBLIST_DOCKED = "/plugins/gtk/win32/winprefs/dblist_docked"; | |
| 51 | static const char *PREF_DBLIST_HEIGHT = "/plugins/gtk/win32/winprefs/dblist_height"; | |
| 52 | static const char *PREF_DBLIST_SIDE = "/plugins/gtk/win32/winprefs/dblist_side"; | |
| 53 | static const char *PREF_BLIST_ON_TOP = "/plugins/gtk/win32/winprefs/blist_on_top"; | |
| 54 | static const char *PREF_IM_BLINK = "/plugins/gtk/win32/winprefs/im_blink"; | |
| 55 | /* Deprecated */ | |
| 56 | static const char *PREF_DBLIST_ON_TOP = "/plugins/gtk/win32/winprefs/dblist_on_top"; | |
|
6436
f2bf79a9db81
[gaim-migrate @ 6944]
Herman Bloggs <herman@bluedigits.com>
parents:
6409
diff
changeset
|
57 | |
| 11003 | 58 | static GaimPlugin *handle = NULL; |
|
6409
ea9ba622db3f
[gaim-migrate @ 6915]
Herman Bloggs <herman@bluedigits.com>
parents:
6063
diff
changeset
|
59 | static GtkAppBar *blist_ab = NULL; |
|
ea9ba622db3f
[gaim-migrate @ 6915]
Herman Bloggs <herman@bluedigits.com>
parents:
6063
diff
changeset
|
60 | static GtkWidget *blist = NULL; |
| 4134 | 61 | |
| 11003 | 62 | /* flash info */ |
| 63 | ||
| 64 | struct _WGAIM_FLASH_INFO { | |
| 65 | guint t_handle; | |
| 66 | guint sig_handler; | |
| 67 | }; | |
| 68 | ||
| 69 | enum { | |
| 70 | BLIST_TOP_NEVER = 0, | |
| 71 | BLIST_TOP_ALWAYS, | |
| 72 | BLIST_TOP_DOCKED, | |
| 73 | }; | |
| 74 | ||
| 75 | typedef struct _WGAIM_FLASH_INFO WGAIM_FLASH_INFO; | |
| 76 | ||
| 77 | typedef BOOL (CALLBACK* LPFNFLASHWINDOWEX)(PFLASHWINFO); | |
| 78 | ||
| 79 | static LPFNFLASHWINDOWEX MyFlashWindowEx = NULL; | |
| 4134 | 80 | |
| 81 | /* | |
| 82 | * CODE | |
| 83 | */ | |
| 84 | ||
|
6409
ea9ba622db3f
[gaim-migrate @ 6915]
Herman Bloggs <herman@bluedigits.com>
parents:
6063
diff
changeset
|
85 | /* BLIST DOCKING */ |
|
ea9ba622db3f
[gaim-migrate @ 6915]
Herman Bloggs <herman@bluedigits.com>
parents:
6063
diff
changeset
|
86 | |
|
ea9ba622db3f
[gaim-migrate @ 6915]
Herman Bloggs <herman@bluedigits.com>
parents:
6063
diff
changeset
|
87 | static void blist_save_state() { |
| 11003 | 88 | if(blist_ab) { |
| 89 | if(gaim_prefs_get_bool(PREF_DBLIST_DOCKABLE) && blist_ab->docked) { | |
| 90 | gaim_prefs_set_int(PREF_DBLIST_HEIGHT, blist_ab->undocked_height); | |
| 91 | gaim_prefs_set_int(PREF_DBLIST_SIDE, blist_ab->side); | |
| 92 | gaim_prefs_set_bool(PREF_DBLIST_DOCKED, blist_ab->docked); | |
| 93 | } else | |
| 94 | gaim_prefs_set_bool(PREF_DBLIST_DOCKED, FALSE); | |
| 95 | } | |
|
6436
f2bf79a9db81
[gaim-migrate @ 6944]
Herman Bloggs <herman@bluedigits.com>
parents:
6409
diff
changeset
|
96 | } |
|
f2bf79a9db81
[gaim-migrate @ 6944]
Herman Bloggs <herman@bluedigits.com>
parents:
6409
diff
changeset
|
97 | |
|
f2bf79a9db81
[gaim-migrate @ 6944]
Herman Bloggs <herman@bluedigits.com>
parents:
6409
diff
changeset
|
98 | static void blist_set_ontop(gboolean val) { |
| 11003 | 99 | if (!blist) |
| 100 | return; | |
| 101 | ||
| 102 | if (val == TRUE) | |
| 103 | SetWindowPos(GDK_WINDOW_HWND(blist->window), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); | |
| 104 | else | |
| 105 | SetWindowPos(GDK_WINDOW_HWND(blist->window), HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); | |
| 106 | ||
|
6436
f2bf79a9db81
[gaim-migrate @ 6944]
Herman Bloggs <herman@bluedigits.com>
parents:
6409
diff
changeset
|
107 | } |
|
f2bf79a9db81
[gaim-migrate @ 6944]
Herman Bloggs <herman@bluedigits.com>
parents:
6409
diff
changeset
|
108 | |
|
f2bf79a9db81
[gaim-migrate @ 6944]
Herman Bloggs <herman@bluedigits.com>
parents:
6409
diff
changeset
|
109 | static void blist_dock_cb(gboolean val) { |
| 11003 | 110 | if (val == TRUE) { |
| 111 | gaim_debug_info(WINPREFS_PLUGIN_ID, "Blist Docking..\n"); | |
| 112 | if (gaim_prefs_get_int(PREF_BLIST_ON_TOP) != BLIST_TOP_NEVER) | |
| 113 | blist_set_ontop(TRUE); | |
| 114 | } else { | |
| 115 | gaim_debug_info(WINPREFS_PLUGIN_ID, "Blist Undocking..\n"); | |
| 116 | if (gaim_prefs_get_int(PREF_BLIST_ON_TOP) == BLIST_TOP_ALWAYS) | |
| 117 | blist_set_ontop(TRUE); | |
| 118 | else | |
| 119 | blist_set_ontop(FALSE); | |
| 120 | } | |
|
6409
ea9ba622db3f
[gaim-migrate @ 6915]
Herman Bloggs <herman@bluedigits.com>
parents:
6063
diff
changeset
|
121 | } |
|
ea9ba622db3f
[gaim-migrate @ 6915]
Herman Bloggs <herman@bluedigits.com>
parents:
6063
diff
changeset
|
122 | |
|
ea9ba622db3f
[gaim-migrate @ 6915]
Herman Bloggs <herman@bluedigits.com>
parents:
6063
diff
changeset
|
123 | static void blist_set_dockable(gboolean val) { |
| 11003 | 124 | if (val == TRUE) { |
| 125 | if (blist_ab == NULL && blist != NULL) { | |
| 126 | blist_ab = gtk_appbar_add(blist); | |
| 127 | gtk_appbar_add_dock_cb(blist_ab, blist_dock_cb); | |
| 128 | } | |
| 129 | } else { | |
| 130 | if (blist_ab != NULL) { | |
| 131 | gtk_appbar_remove(blist_ab); | |
| 132 | blist_ab = NULL; | |
| 133 | } | |
| 134 | ||
| 135 | if (gaim_prefs_get_int(PREF_BLIST_ON_TOP) == BLIST_TOP_ALWAYS) | |
| 136 | blist_set_ontop(TRUE); | |
| 137 | else | |
| 138 | blist_set_ontop(FALSE); | |
| 139 | } | |
|
6409
ea9ba622db3f
[gaim-migrate @ 6915]
Herman Bloggs <herman@bluedigits.com>
parents:
6063
diff
changeset
|
140 | } |
|
ea9ba622db3f
[gaim-migrate @ 6915]
Herman Bloggs <herman@bluedigits.com>
parents:
6063
diff
changeset
|
141 | |
|
6436
f2bf79a9db81
[gaim-migrate @ 6944]
Herman Bloggs <herman@bluedigits.com>
parents:
6409
diff
changeset
|
142 | /* PLUGIN CALLBACKS */ |
|
f2bf79a9db81
[gaim-migrate @ 6944]
Herman Bloggs <herman@bluedigits.com>
parents:
6409
diff
changeset
|
143 | |
|
f2bf79a9db81
[gaim-migrate @ 6944]
Herman Bloggs <herman@bluedigits.com>
parents:
6409
diff
changeset
|
144 | /* We need this because the blist destroy cb won't be called before the |
|
f2bf79a9db81
[gaim-migrate @ 6944]
Herman Bloggs <herman@bluedigits.com>
parents:
6409
diff
changeset
|
145 | plugin is unloaded, when quitting */ |
|
6409
ea9ba622db3f
[gaim-migrate @ 6915]
Herman Bloggs <herman@bluedigits.com>
parents:
6063
diff
changeset
|
146 | static void gaim_quit_cb() { |
| 11003 | 147 | gaim_debug_info(WINPREFS_PLUGIN_ID, "gaim_quit_cb: removing appbar\n"); |
| 148 | blist_save_state(); | |
| 149 | blist_set_dockable(FALSE); | |
|
6409
ea9ba622db3f
[gaim-migrate @ 6915]
Herman Bloggs <herman@bluedigits.com>
parents:
6063
diff
changeset
|
150 | } |
|
ea9ba622db3f
[gaim-migrate @ 6915]
Herman Bloggs <herman@bluedigits.com>
parents:
6063
diff
changeset
|
151 | |
|
10530
8dc238880e48
[gaim-migrate @ 11856]
Daniel Atallah <datallah@pidgin.im>
parents:
9954
diff
changeset
|
152 | static void blist_create_cb(GaimBuddyList *gaim_blist, void *data) { |
|
8dc238880e48
[gaim-migrate @ 11856]
Daniel Atallah <datallah@pidgin.im>
parents:
9954
diff
changeset
|
153 | gaim_debug_info(WINPREFS_PLUGIN_ID, "buddy list created\n"); |
|
6436
f2bf79a9db81
[gaim-migrate @ 6944]
Herman Bloggs <herman@bluedigits.com>
parents:
6409
diff
changeset
|
154 | |
|
10530
8dc238880e48
[gaim-migrate @ 11856]
Daniel Atallah <datallah@pidgin.im>
parents:
9954
diff
changeset
|
155 | blist = GAIM_GTK_BLIST(gaim_blist)->window; |
|
6436
f2bf79a9db81
[gaim-migrate @ 6944]
Herman Bloggs <herman@bluedigits.com>
parents:
6409
diff
changeset
|
156 | |
| 11003 | 157 | if (gaim_prefs_get_bool(PREF_DBLIST_DOCKABLE)) { |
| 158 | blist_set_dockable(TRUE); | |
| 159 | if (gaim_prefs_get_bool(PREF_DBLIST_DOCKED)) { | |
| 160 | blist_ab->undocked_height = gaim_prefs_get_int(PREF_DBLIST_HEIGHT); | |
| 161 | gtk_appbar_dock(blist_ab, | |
| 162 | gaim_prefs_get_int(PREF_DBLIST_SIDE)); | |
| 163 | if (gaim_prefs_get_int(PREF_BLIST_ON_TOP) == BLIST_TOP_DOCKED) | |
| 164 | blist_set_ontop(TRUE); | |
| 165 | } | |
| 166 | } | |
| 167 | ||
| 168 | if (gaim_prefs_get_int(PREF_BLIST_ON_TOP) == BLIST_TOP_ALWAYS) | |
| 169 | blist_set_ontop(TRUE); | |
| 170 | ||
|
6409
ea9ba622db3f
[gaim-migrate @ 6915]
Herman Bloggs <herman@bluedigits.com>
parents:
6063
diff
changeset
|
171 | } |
|
ea9ba622db3f
[gaim-migrate @ 6915]
Herman Bloggs <herman@bluedigits.com>
parents:
6063
diff
changeset
|
172 | |
|
ea9ba622db3f
[gaim-migrate @ 6915]
Herman Bloggs <herman@bluedigits.com>
parents:
6063
diff
changeset
|
173 | /* AUTOSTART */ |
|
ea9ba622db3f
[gaim-migrate @ 6915]
Herman Bloggs <herman@bluedigits.com>
parents:
6063
diff
changeset
|
174 | |
| 4134 | 175 | static int open_run_key(PHKEY phKey, REGSAM samDesired) { |
| 11003 | 176 | /* First try current user key (for WinNT & Win2k +), fall back to local machine */ |
| 177 | if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_CURRENT_USER, | |
| 178 | "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", | |
| 179 | 0, samDesired, phKey)); | |
| 180 | else if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, | |
| 181 | "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", | |
| 182 | 0, samDesired, phKey)); | |
| 4134 | 183 | else { |
| 8760 | 184 | gaim_debug_error(WINPREFS_PLUGIN_ID, "open_run_key: Could not open key for writing value\n"); |
| 4134 | 185 | return 0; |
| 186 | } | |
| 187 | return 1; | |
| 188 | } | |
| 189 | ||
|
6409
ea9ba622db3f
[gaim-migrate @ 6915]
Herman Bloggs <herman@bluedigits.com>
parents:
6063
diff
changeset
|
190 | /* WIN PREFS GENERAL */ |
| 4134 | 191 | |
| 11003 | 192 | static void |
| 193 | winprefs_set_autostart(GtkWidget *w) | |
| 194 | { | |
| 195 | HKEY hKey; | |
| 196 | ||
| 197 | if (!open_run_key(&hKey, KEY_SET_VALUE)) | |
| 198 | return; | |
| 199 | if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w))) { | |
| 200 | char buffer[1024]; | |
| 201 | DWORD size; | |
| 202 | ||
| 203 | if ((size = GetModuleFileName(wgaim_hinstance(), | |
| 204 | (LPBYTE)buffer, sizeof(buffer)))==0) { | |
| 205 | gaim_debug_error(WINPREFS_PLUGIN_ID, "GetModuleFileName Error.. Could not set Gaim autostart.\n"); | |
| 206 | RegCloseKey(hKey); | |
| 207 | return; | |
| 208 | } | |
| 209 | ||
| 210 | /* Now set value of new key */ | |
| 211 | if (ERROR_SUCCESS != RegSetValueEx(hKey, "Gaim", 0, REG_SZ, buffer, size)) | |
| 212 | gaim_debug_error(WINPREFS_PLUGIN_ID, "Could not set registry key value\n"); | |
| 213 | } else { | |
| 214 | if (ERROR_SUCCESS != RegDeleteValue(hKey, "Gaim")) | |
| 215 | gaim_debug_error(WINPREFS_PLUGIN_ID, "Could not delete registry key value\n"); | |
| 216 | } | |
| 217 | RegCloseKey(hKey); | |
| 218 | } | |
| 4134 | 219 | |
| 11003 | 220 | static void |
| 221 | winprefs_set_blist_dockable (const char *pref, GaimPrefType type, | |
|
12816
5f93e09fa9a6
[gaim-migrate @ 15164]
Mark Doliner <markdoliner@pidgin.im>
parents:
12537
diff
changeset
|
222 | gconstpointer value, gpointer user_data) |
| 11003 | 223 | { |
| 224 | blist_set_dockable(GPOINTER_TO_INT(value)); | |
| 225 | } | |
| 226 | ||
| 227 | static void | |
| 228 | winprefs_set_blist_ontop (const char *pref, GaimPrefType type, | |
|
12816
5f93e09fa9a6
[gaim-migrate @ 15164]
Mark Doliner <markdoliner@pidgin.im>
parents:
12537
diff
changeset
|
229 | gconstpointer value, gpointer user_data) |
| 11003 | 230 | { |
| 231 | gint setting = gaim_prefs_get_int(PREF_BLIST_ON_TOP); | |
| 232 | if ((setting == BLIST_TOP_DOCKED && blist_ab && blist_ab->docked) | |
| 233 | || setting == BLIST_TOP_ALWAYS) | |
| 234 | blist_set_ontop(TRUE); | |
| 235 | else | |
| 236 | blist_set_ontop(FALSE); | |
| 237 | } | |
| 238 | ||
| 239 | static void load_winver_specific_procs (void) { | |
| 240 | /* Used for Win98+ and WinNT5+ */ | |
| 241 | MyFlashWindowEx = (LPFNFLASHWINDOWEX)wgaim_find_and_loadproc("user32.dll", "FlashWindowEx" ); | |
| 242 | } | |
| 243 | ||
| 244 | /* Window flasher */ | |
| 245 | static gboolean flash_window_cb (gpointer data) { | |
| 246 | FlashWindow((HWND)data, TRUE); | |
| 247 | return TRUE; | |
| 4134 | 248 | } |
| 249 | ||
| 11003 | 250 | static int |
| 251 | halt_flash_filter (GtkWidget *widget, GdkEventFocus *event, gpointer data) | |
| 252 | { | |
|
11601
cf72b616ceb3
[gaim-migrate @ 13872]
Daniel Atallah <datallah@pidgin.im>
parents:
11590
diff
changeset
|
253 | if (MyFlashWindowEx) { |
| 11003 | 254 | HWND hWnd = data; |
| 255 | FLASHWINFO info; | |
| 256 | ||
| 257 | if (!IsWindow(hWnd)) | |
| 258 | return 0; | |
| 259 | ||
| 260 | memset(&info, 0, sizeof(FLASHWINFO)); | |
| 261 | info.cbSize = sizeof(FLASHWINFO); | |
| 262 | info.hwnd = hWnd; | |
| 263 | info.dwFlags = FLASHW_STOP; | |
| 264 | info.dwTimeout = 0; | |
| 265 | MyFlashWindowEx(&info); | |
| 266 | ||
| 267 | } else { | |
| 268 | WGAIM_FLASH_INFO *finfo = data; | |
| 269 | /* Stop flashing and remove filter */ | |
| 270 | gaim_debug(GAIM_DEBUG_INFO, "wgaim", "Removing timeout\n"); | |
| 271 | gaim_timeout_remove(finfo->t_handle); | |
| 272 | gaim_debug(GAIM_DEBUG_INFO, "wgaim", "Disconnecting signal handler\n"); | |
| 273 | g_signal_handler_disconnect(G_OBJECT(widget),finfo->sig_handler); | |
| 274 | gaim_debug(GAIM_DEBUG_INFO, "wgaim", "done\n"); | |
| 275 | g_free(finfo); | |
| 276 | } | |
| 277 | return 0; | |
|
6409
ea9ba622db3f
[gaim-migrate @ 6915]
Herman Bloggs <herman@bluedigits.com>
parents:
6063
diff
changeset
|
278 | } |
|
ea9ba622db3f
[gaim-migrate @ 6915]
Herman Bloggs <herman@bluedigits.com>
parents:
6063
diff
changeset
|
279 | |
| 11003 | 280 | /* FlashWindowEx is only supported by Win98+ and WinNT5+. If it's |
| 281 | not supported we do it our own way */ | |
| 282 | static void | |
| 12913 | 283 | wgaim_conv_im_blink (GaimAccount *account, char *sender, char *buffer, |
| 284 | GaimConversation *conv, int flags, void * data) | |
| 11003 | 285 | { |
|
11590
5bc4443c5407
[gaim-migrate @ 13860]
Daniel Atallah <datallah@pidgin.im>
parents:
11440
diff
changeset
|
286 | GaimGtkWindow *win; |
|
11440
b9f3c9c82b13
[gaim-migrate @ 13677]
Daniel Atallah <datallah@pidgin.im>
parents:
11338
diff
changeset
|
287 | GtkWidget *window; |
| 11003 | 288 | if (gaim_prefs_get_bool(PREF_IM_BLINK) == FALSE) |
| 289 | return; | |
| 290 | ||
| 291 | if (conv == NULL) { | |
| 292 | gaim_debug_info("winprefs", "gar!\n"); | |
| 293 | return; | |
| 294 | } | |
|
11590
5bc4443c5407
[gaim-migrate @ 13860]
Daniel Atallah <datallah@pidgin.im>
parents:
11440
diff
changeset
|
295 | win = gaim_gtkconv_get_window(GAIM_GTK_CONVERSATION(conv)); |
| 11003 | 296 | if (win == NULL) { |
| 297 | gaim_debug_info("winprefs", "gar2!\n"); | |
| 298 | return; | |
| 299 | } | |
|
11590
5bc4443c5407
[gaim-migrate @ 13860]
Daniel Atallah <datallah@pidgin.im>
parents:
11440
diff
changeset
|
300 | window = win->window; |
|
6436
f2bf79a9db81
[gaim-migrate @ 6944]
Herman Bloggs <herman@bluedigits.com>
parents:
6409
diff
changeset
|
301 | |
| 11003 | 302 | if (MyFlashWindowEx) { |
| 303 | FLASHWINFO info; | |
| 304 | if (GetForegroundWindow() == GDK_WINDOW_HWND(window->window)) | |
| 305 | return; | |
| 306 | ||
| 307 | memset(&info, 0, sizeof(FLASHWINFO)); | |
| 308 | info.cbSize = sizeof(FLASHWINFO); | |
| 309 | info.hwnd = GDK_WINDOW_HWND(window->window); | |
|
12537
2d8fe5746c5d
[gaim-migrate @ 14850]
Daniel Atallah <datallah@pidgin.im>
parents:
11957
diff
changeset
|
310 | info.dwFlags = FLASHW_ALL | FLASHW_TIMER; |
| 11003 | 311 | info.dwTimeout = 0; |
| 312 | MyFlashWindowEx(&info); | |
| 313 | /* Stop flashing when window receives focus */ | |
| 314 | g_signal_connect(G_OBJECT(window), "focus-in-event", | |
| 315 | G_CALLBACK(halt_flash_filter), info.hwnd); | |
| 316 | } else { | |
| 317 | WGAIM_FLASH_INFO *finfo = g_new0(WGAIM_FLASH_INFO, 1); | |
| 318 | ||
| 319 | /* Start Flashing window */ | |
| 320 | finfo->t_handle = gaim_timeout_add(1000, flash_window_cb, | |
| 321 | GDK_WINDOW_HWND(window->window)); | |
| 322 | finfo->sig_handler = g_signal_connect(G_OBJECT(window), | |
| 323 | "focus-in-event", | |
| 324 | G_CALLBACK(halt_flash_filter), finfo); | |
| 325 | } | |
|
6436
f2bf79a9db81
[gaim-migrate @ 6944]
Herman Bloggs <herman@bluedigits.com>
parents:
6409
diff
changeset
|
326 | } |
|
f2bf79a9db81
[gaim-migrate @ 6944]
Herman Bloggs <herman@bluedigits.com>
parents:
6409
diff
changeset
|
327 | |
|
6409
ea9ba622db3f
[gaim-migrate @ 6915]
Herman Bloggs <herman@bluedigits.com>
parents:
6063
diff
changeset
|
328 | |
| 4134 | 329 | /* |
| 330 | * EXPORTED FUNCTIONS | |
| 331 | */ | |
|
6409
ea9ba622db3f
[gaim-migrate @ 6915]
Herman Bloggs <herman@bluedigits.com>
parents:
6063
diff
changeset
|
332 | |
|
ea9ba622db3f
[gaim-migrate @ 6915]
Herman Bloggs <herman@bluedigits.com>
parents:
6063
diff
changeset
|
333 | gboolean plugin_load(GaimPlugin *plugin) { |
| 11003 | 334 | /* Find out how to go blinky */ |
| 335 | load_winver_specific_procs(); | |
|
6409
ea9ba622db3f
[gaim-migrate @ 6915]
Herman Bloggs <herman@bluedigits.com>
parents:
6063
diff
changeset
|
336 | |
| 11003 | 337 | handle = plugin; |
| 338 | ||
| 339 | /* blist docking init */ | |
|
10530
8dc238880e48
[gaim-migrate @ 11856]
Daniel Atallah <datallah@pidgin.im>
parents:
9954
diff
changeset
|
340 | if (gaim_get_blist() && GAIM_GTK_BLIST(gaim_get_blist()) && GAIM_GTK_BLIST(gaim_get_blist())->window) { |
|
8dc238880e48
[gaim-migrate @ 11856]
Daniel Atallah <datallah@pidgin.im>
parents:
9954
diff
changeset
|
341 | blist_create_cb(gaim_get_blist(), NULL); |
|
8dc238880e48
[gaim-migrate @ 11856]
Daniel Atallah <datallah@pidgin.im>
parents:
9954
diff
changeset
|
342 | } |
|
6409
ea9ba622db3f
[gaim-migrate @ 6915]
Herman Bloggs <herman@bluedigits.com>
parents:
6063
diff
changeset
|
343 | |
| 11003 | 344 | /* This really shouldn't happen anymore generally, but if for some strange |
| 345 | reason, the blist is recreated, we need to set it up again. */ | |
| 346 | gaim_signal_connect(gaim_gtk_blist_get_handle(), "gtkblist-created", plugin, GAIM_CALLBACK(blist_create_cb), NULL); | |
| 347 | ||
| 348 | gaim_signal_connect(gaim_conversations_get_handle(), "received-im-msg", plugin, GAIM_CALLBACK(wgaim_conv_im_blink), NULL); | |
|
6436
f2bf79a9db81
[gaim-migrate @ 6944]
Herman Bloggs <herman@bluedigits.com>
parents:
6409
diff
changeset
|
349 | |
| 11003 | 350 | gaim_signal_connect((void*)gaim_get_core(), "quitting", plugin, GAIM_CALLBACK(gaim_quit_cb), NULL); |
|
6409
ea9ba622db3f
[gaim-migrate @ 6915]
Herman Bloggs <herman@bluedigits.com>
parents:
6063
diff
changeset
|
351 | |
| 11003 | 352 | gaim_prefs_connect_callback(handle, PREF_BLIST_ON_TOP, |
| 353 | winprefs_set_blist_ontop, NULL); | |
| 354 | gaim_prefs_connect_callback(handle, PREF_DBLIST_DOCKABLE, | |
| 355 | winprefs_set_blist_dockable, NULL); | |
| 356 | ||
| 357 | return TRUE; | |
|
6409
ea9ba622db3f
[gaim-migrate @ 6915]
Herman Bloggs <herman@bluedigits.com>
parents:
6063
diff
changeset
|
358 | } |
|
ea9ba622db3f
[gaim-migrate @ 6915]
Herman Bloggs <herman@bluedigits.com>
parents:
6063
diff
changeset
|
359 | |
|
ea9ba622db3f
[gaim-migrate @ 6915]
Herman Bloggs <herman@bluedigits.com>
parents:
6063
diff
changeset
|
360 | gboolean plugin_unload(GaimPlugin *plugin) { |
| 11003 | 361 | blist_set_dockable(FALSE); |
| 362 | blist_set_ontop(FALSE); | |
| 11033 | 363 | |
| 11003 | 364 | return TRUE; |
|
6409
ea9ba622db3f
[gaim-migrate @ 6915]
Herman Bloggs <herman@bluedigits.com>
parents:
6063
diff
changeset
|
365 | } |
|
ea9ba622db3f
[gaim-migrate @ 6915]
Herman Bloggs <herman@bluedigits.com>
parents:
6063
diff
changeset
|
366 | |
|
5224
8cb89f5b912a
[gaim-migrate @ 5594]
Herman Bloggs <herman@bluedigits.com>
parents:
4606
diff
changeset
|
367 | static GtkWidget* get_config_frame(GaimPlugin *plugin) { |
| 4134 | 368 | GtkWidget *ret; |
| 11003 | 369 | GtkWidget *vbox; |
| 4134 | 370 | GtkWidget *button; |
| 11003 | 371 | char* gtk_version = NULL; |
| 372 | HKEY hKey = HKEY_CURRENT_USER; | |
| 4134 | 373 | |
| 374 | ret = gtk_vbox_new(FALSE, 18); | |
| 375 | gtk_container_set_border_width (GTK_CONTAINER (ret), 12); | |
| 376 | ||
|
11601
cf72b616ceb3
[gaim-migrate @ 13872]
Daniel Atallah <datallah@pidgin.im>
parents:
11590
diff
changeset
|
377 | gtk_version = g_strdup_printf("GTK+ %u.%u.%u\nGlib %u.%u.%u", |
|
cf72b616ceb3
[gaim-migrate @ 13872]
Daniel Atallah <datallah@pidgin.im>
parents:
11590
diff
changeset
|
378 | gtk_major_version, gtk_minor_version, gtk_micro_version, |
|
cf72b616ceb3
[gaim-migrate @ 13872]
Daniel Atallah <datallah@pidgin.im>
parents:
11590
diff
changeset
|
379 | glib_major_version, glib_minor_version, glib_micro_version); |
|
6436
f2bf79a9db81
[gaim-migrate @ 6944]
Herman Bloggs <herman@bluedigits.com>
parents:
6409
diff
changeset
|
380 | |
| 11003 | 381 | /* Display Installed GTK+ Runtime Version */ |
| 382 | if(gtk_version) { | |
| 383 | GtkWidget *label; | |
| 384 | vbox = gaim_gtk_make_frame(ret, _("GTK+ Runtime Version")); | |
| 385 | label = gtk_label_new(gtk_version); | |
| 386 | gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
| 387 | gtk_widget_show(label); | |
| 388 | g_free(gtk_version); | |
| 389 | } | |
|
6409
ea9ba622db3f
[gaim-migrate @ 6915]
Herman Bloggs <herman@bluedigits.com>
parents:
6063
diff
changeset
|
390 | |
| 11003 | 391 | /* Autostart */ |
|
6436
f2bf79a9db81
[gaim-migrate @ 6944]
Herman Bloggs <herman@bluedigits.com>
parents:
6409
diff
changeset
|
392 | vbox = gaim_gtk_make_frame (ret, _("Startup")); |
| 11003 | 393 | button = gtk_check_button_new_with_mnemonic(_("_Start Gaim on Windows startup")); |
| 394 | gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0); | |
| 4134 | 395 | if(open_run_key(&hKey, KEY_QUERY_VALUE)) { |
| 396 | if(ERROR_SUCCESS == RegQueryValueEx(hKey, "Gaim", 0, NULL, NULL, NULL)) { | |
| 397 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE); | |
| 398 | } | |
| 399 | } | |
| 11003 | 400 | g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(winprefs_set_autostart), NULL); |
| 401 | gtk_widget_show(button); | |
| 4134 | 402 | |
| 11003 | 403 | /* Buddy List */ |
| 404 | vbox = gaim_gtk_make_frame (ret, _("Buddy List")); | |
| 405 | gaim_gtk_prefs_checkbox(_("_Dockable Buddy List"), | |
| 406 | PREF_DBLIST_DOCKABLE, vbox); | |
|
6436
f2bf79a9db81
[gaim-migrate @ 6944]
Herman Bloggs <herman@bluedigits.com>
parents:
6409
diff
changeset
|
407 | |
| 11003 | 408 | /* Blist On Top */ |
| 409 | gaim_gtk_prefs_dropdown(vbox, _("_Keep Buddy List window on top:"), | |
| 410 | GAIM_PREF_INT, PREF_BLIST_ON_TOP, | |
| 411 | _("Never"), BLIST_TOP_NEVER, | |
| 412 | _("Always"), BLIST_TOP_ALWAYS, | |
| 413 | /* XXX: Did this ever work? */ | |
| 414 | _("Only when docked"), BLIST_TOP_DOCKED, | |
| 415 | NULL); | |
|
6436
f2bf79a9db81
[gaim-migrate @ 6944]
Herman Bloggs <herman@bluedigits.com>
parents:
6409
diff
changeset
|
416 | |
| 11003 | 417 | /* Conversations */ |
|
6436
f2bf79a9db81
[gaim-migrate @ 6944]
Herman Bloggs <herman@bluedigits.com>
parents:
6409
diff
changeset
|
418 | vbox = gaim_gtk_make_frame (ret, _("Conversations")); |
| 11003 | 419 | gaim_gtk_prefs_checkbox(_("_Flash window when messages are received"), |
| 420 | PREF_IM_BLINK, vbox); | |
|
6436
f2bf79a9db81
[gaim-migrate @ 6944]
Herman Bloggs <herman@bluedigits.com>
parents:
6409
diff
changeset
|
421 | |
| 4134 | 422 | gtk_widget_show_all(ret); |
| 423 | return ret; | |
| 424 | } | |
|
5224
8cb89f5b912a
[gaim-migrate @ 5594]
Herman Bloggs <herman@bluedigits.com>
parents:
4606
diff
changeset
|
425 | |
|
8cb89f5b912a
[gaim-migrate @ 5594]
Herman Bloggs <herman@bluedigits.com>
parents:
4606
diff
changeset
|
426 | static GaimGtkPluginUiInfo ui_info = |
|
8cb89f5b912a
[gaim-migrate @ 5594]
Herman Bloggs <herman@bluedigits.com>
parents:
4606
diff
changeset
|
427 | { |
|
8cb89f5b912a
[gaim-migrate @ 5594]
Herman Bloggs <herman@bluedigits.com>
parents:
4606
diff
changeset
|
428 | get_config_frame |
|
8cb89f5b912a
[gaim-migrate @ 5594]
Herman Bloggs <herman@bluedigits.com>
parents:
4606
diff
changeset
|
429 | }; |
|
8cb89f5b912a
[gaim-migrate @ 5594]
Herman Bloggs <herman@bluedigits.com>
parents:
4606
diff
changeset
|
430 | |
|
8cb89f5b912a
[gaim-migrate @ 5594]
Herman Bloggs <herman@bluedigits.com>
parents:
4606
diff
changeset
|
431 | static GaimPluginInfo info = |
|
8cb89f5b912a
[gaim-migrate @ 5594]
Herman Bloggs <herman@bluedigits.com>
parents:
4606
diff
changeset
|
432 | { |
| 9954 | 433 | GAIM_PLUGIN_MAGIC, |
| 434 | GAIM_MAJOR_VERSION, | |
| 435 | GAIM_MINOR_VERSION, | |
|
5224
8cb89f5b912a
[gaim-migrate @ 5594]
Herman Bloggs <herman@bluedigits.com>
parents:
4606
diff
changeset
|
436 | GAIM_PLUGIN_STANDARD, |
|
8cb89f5b912a
[gaim-migrate @ 5594]
Herman Bloggs <herman@bluedigits.com>
parents:
4606
diff
changeset
|
437 | GAIM_GTK_PLUGIN_TYPE, |
|
8cb89f5b912a
[gaim-migrate @ 5594]
Herman Bloggs <herman@bluedigits.com>
parents:
4606
diff
changeset
|
438 | 0, |
|
8cb89f5b912a
[gaim-migrate @ 5594]
Herman Bloggs <herman@bluedigits.com>
parents:
4606
diff
changeset
|
439 | NULL, |
|
8cb89f5b912a
[gaim-migrate @ 5594]
Herman Bloggs <herman@bluedigits.com>
parents:
4606
diff
changeset
|
440 | GAIM_PRIORITY_DEFAULT, |
|
8cb89f5b912a
[gaim-migrate @ 5594]
Herman Bloggs <herman@bluedigits.com>
parents:
4606
diff
changeset
|
441 | WINPREFS_PLUGIN_ID, |
|
8cb89f5b912a
[gaim-migrate @ 5594]
Herman Bloggs <herman@bluedigits.com>
parents:
4606
diff
changeset
|
442 | N_("WinGaim Options"), |
|
8cb89f5b912a
[gaim-migrate @ 5594]
Herman Bloggs <herman@bluedigits.com>
parents:
4606
diff
changeset
|
443 | VERSION, |
|
8cb89f5b912a
[gaim-migrate @ 5594]
Herman Bloggs <herman@bluedigits.com>
parents:
4606
diff
changeset
|
444 | N_("Options specific to Windows Gaim."), |
| 11003 | 445 | N_("Provides options specific to Windows Gaim, such as buddy list docking and conversation flashing."), |
|
5224
8cb89f5b912a
[gaim-migrate @ 5594]
Herman Bloggs <herman@bluedigits.com>
parents:
4606
diff
changeset
|
446 | "Herman Bloggs <hermanator12002@yahoo.com>", |
|
6409
ea9ba622db3f
[gaim-migrate @ 6915]
Herman Bloggs <herman@bluedigits.com>
parents:
6063
diff
changeset
|
447 | GAIM_WEBSITE, |
|
ea9ba622db3f
[gaim-migrate @ 6915]
Herman Bloggs <herman@bluedigits.com>
parents:
6063
diff
changeset
|
448 | plugin_load, |
|
ea9ba622db3f
[gaim-migrate @ 6915]
Herman Bloggs <herman@bluedigits.com>
parents:
6063
diff
changeset
|
449 | plugin_unload, |
|
5224
8cb89f5b912a
[gaim-migrate @ 5594]
Herman Bloggs <herman@bluedigits.com>
parents:
4606
diff
changeset
|
450 | NULL, |
|
8cb89f5b912a
[gaim-migrate @ 5594]
Herman Bloggs <herman@bluedigits.com>
parents:
4606
diff
changeset
|
451 | &ui_info, |
| 8993 | 452 | NULL, |
| 453 | NULL, | |
|
5224
8cb89f5b912a
[gaim-migrate @ 5594]
Herman Bloggs <herman@bluedigits.com>
parents:
4606
diff
changeset
|
454 | NULL |
|
8cb89f5b912a
[gaim-migrate @ 5594]
Herman Bloggs <herman@bluedigits.com>
parents:
4606
diff
changeset
|
455 | }; |
|
8cb89f5b912a
[gaim-migrate @ 5594]
Herman Bloggs <herman@bluedigits.com>
parents:
4606
diff
changeset
|
456 | |
|
8cb89f5b912a
[gaim-migrate @ 5594]
Herman Bloggs <herman@bluedigits.com>
parents:
4606
diff
changeset
|
457 | static void |
|
5798
d60e39f7fa1d
[gaim-migrate @ 6223]
Christian Hammond <chipx86@chipx86.com>
parents:
5795
diff
changeset
|
458 | init_plugin(GaimPlugin *plugin) |
|
5224
8cb89f5b912a
[gaim-migrate @ 5594]
Herman Bloggs <herman@bluedigits.com>
parents:
4606
diff
changeset
|
459 | { |
| 11003 | 460 | gaim_prefs_add_none("/plugins/gtk"); |
|
6409
ea9ba622db3f
[gaim-migrate @ 6915]
Herman Bloggs <herman@bluedigits.com>
parents:
6063
diff
changeset
|
461 | gaim_prefs_add_none("/plugins/gtk/win32"); |
|
ea9ba622db3f
[gaim-migrate @ 6915]
Herman Bloggs <herman@bluedigits.com>
parents:
6063
diff
changeset
|
462 | gaim_prefs_add_none("/plugins/gtk/win32/winprefs"); |
| 11003 | 463 | gaim_prefs_add_bool(PREF_DBLIST_DOCKABLE, FALSE); |
| 464 | gaim_prefs_add_bool(PREF_DBLIST_DOCKED, FALSE); | |
| 465 | gaim_prefs_add_int(PREF_DBLIST_HEIGHT, 0); | |
| 466 | gaim_prefs_add_int(PREF_DBLIST_SIDE, 0); | |
| 467 | gaim_prefs_add_bool(PREF_IM_BLINK, TRUE); | |
| 468 | ||
| 469 | /* Convert old preferences */ | |
| 470 | if (gaim_prefs_exists(PREF_DBLIST_ON_TOP)) { | |
| 471 | gint blist_top = BLIST_TOP_NEVER; | |
| 472 | if (gaim_prefs_get_bool(PREF_BLIST_ON_TOP)) | |
| 473 | blist_top = BLIST_TOP_ALWAYS; | |
| 474 | else if (gaim_prefs_get_bool(PREF_DBLIST_ON_TOP)) | |
| 475 | blist_top = BLIST_TOP_DOCKED; | |
| 476 | gaim_prefs_remove(PREF_BLIST_ON_TOP); | |
| 477 | gaim_prefs_remove(PREF_DBLIST_ON_TOP); | |
| 478 | gaim_prefs_add_int(PREF_BLIST_ON_TOP, blist_top); | |
| 479 | } else | |
| 480 | gaim_prefs_add_int(PREF_BLIST_ON_TOP, BLIST_TOP_NEVER); | |
|
5224
8cb89f5b912a
[gaim-migrate @ 5594]
Herman Bloggs <herman@bluedigits.com>
parents:
4606
diff
changeset
|
481 | } |
|
8cb89f5b912a
[gaim-migrate @ 5594]
Herman Bloggs <herman@bluedigits.com>
parents:
4606
diff
changeset
|
482 | |
| 6063 | 483 | GAIM_INIT_PLUGIN(winprefs, init_plugin, info) |