annotate plugins/win32/winprefs/winprefs.c @ 5749:6d6ae91c5de7

[gaim-migrate @ 6174] updates for api changes committer: Tailor Script <tailor@pidgin.im>
author Herman Bloggs <hermanator12002@yahoo.com>
date Wed, 04 Jun 2003 16:47:21 +0000
parents 5160333a80df
children 0efc365eed6d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4134
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
1 /*
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
2 * winprefs.c
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
3 *
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
4 * copyright (c) 1998-2002, Herman Bloggs <hermanator12002@yahoo.com>
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
5 *
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
6 * this program is free software; you can redistribute it and/or modify
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
7 * it under the terms of the gnu general public license as published by
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
8 * the free software foundation; either version 2 of the license, or
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
9 * (at your option) any later version.
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
10 *
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
11 * this program is distributed in the hope that it will be useful,
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
12 * but without any warranty; without even the implied warranty of
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
13 * merchantability or fitness for a particular purpose. see the
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
14 * gnu general public license for more details.
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
15 *
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
16 * you should have received a copy of the gnu general public license
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
17 * along with this program; if not, write to the free software
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
18 * foundation, inc., 59 temple place, suite 330, boston, ma 02111-1307 usa
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
19 *
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
20 */
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
21 #include <windows.h>
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
22 #include <winreg.h>
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
23 #include <winerror.h>
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
24 #include "gaim.h"
5224
5160333a80df [gaim-migrate @ 5594]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4606
diff changeset
25 #include "gtkplugin.h"
4134
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
26 #include "win32dep.h"
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
27
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
28 /*
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
29 * MACROS & DEFINES
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
30 */
5224
5160333a80df [gaim-migrate @ 5594]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4606
diff changeset
31 #define WINPREFS_PLUGIN_ID "gaim-winprefs"
5160333a80df [gaim-migrate @ 5594]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4606
diff changeset
32 #define WINPREFS_VERSION 1
4134
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
33
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
34 /* Plugin options */
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
35 #define OPT_WGAIM_AUTOSTART 0x00000001
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
36
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
37 /*
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
38 * LOCALS
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
39 */
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
40 guint winprefs_options=0;
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
41
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
42 /*
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
43 * PROTOS
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
44 */
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
45
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
46 /*
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
47 * CODE
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
48 */
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
49
5749
6d6ae91c5de7 [gaim-migrate @ 6174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5224
diff changeset
50 static GtkWidget *wgaim_button(const char *text, guint *options, int option, GtkWidget *page) {
6d6ae91c5de7 [gaim-migrate @ 6174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5224
diff changeset
51 GtkWidget *button;
6d6ae91c5de7 [gaim-migrate @ 6174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5224
diff changeset
52 button = gtk_check_button_new_with_mnemonic(text);
6d6ae91c5de7 [gaim-migrate @ 6174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5224
diff changeset
53 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), (*options & option));
6d6ae91c5de7 [gaim-migrate @ 6174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5224
diff changeset
54 gtk_box_pack_start(GTK_BOX(page), button, FALSE, FALSE, 0);
6d6ae91c5de7 [gaim-migrate @ 6174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5224
diff changeset
55 g_object_set_data(G_OBJECT(button), "options", options);
6d6ae91c5de7 [gaim-migrate @ 6174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5224
diff changeset
56 gtk_widget_show(button);
6d6ae91c5de7 [gaim-migrate @ 6174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5224
diff changeset
57 return button;
6d6ae91c5de7 [gaim-migrate @ 6174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5224
diff changeset
58 }
6d6ae91c5de7 [gaim-migrate @ 6174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5224
diff changeset
59
4134
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
60 static void write_options(FILE *f) {
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
61 fprintf(f, "options {\n");
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
62 fprintf(f, "\twinprefs_options { %u }\n", winprefs_options);
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
63 fprintf(f, "}\n");
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
64 }
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
65
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
66 static void save_winprefs_prefs() {
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
67 FILE *f;
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
68 char buf[1024];
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
69
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
70 if (gaim_home_dir()) {
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
71 g_snprintf(buf, sizeof(buf), "%s" G_DIR_SEPARATOR_S ".gaim" G_DIR_SEPARATOR_S "winprefsrc", gaim_home_dir());
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
72 }
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
73 else
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
74 return;
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
75
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
76 if ((f = fopen(buf, "w"))) {
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
77 fprintf(f, "# winprefsrc v%d\n", WINPREFS_VERSION);
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
78 write_options(f);
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
79 fclose(f);
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
80 }
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
81 else
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
82 debug_printf("Error opening wintransrc\n");
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
83 }
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
84
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
85 static int open_run_key(PHKEY phKey, REGSAM samDesired) {
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
86 /* First try current user key (for WinNT & Win2k +), fall back to local machine */
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
87 if(ERROR_SUCCESS == RegOpenKeyEx(HKEY_CURRENT_USER,
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
88 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
89 0, samDesired, phKey));
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
90 else if(ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE,
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
91 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
92 0, samDesired, phKey));
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
93 else {
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
94 debug_printf("open_run_key: Could not open key for writing value\n");
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
95 return 0;
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
96 }
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
97 return 1;
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
98 }
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
99
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
100 static void set_winprefs_option(GtkWidget *w, int option) {
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
101 winprefs_options ^= option;
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
102 save_winprefs_prefs();
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
103
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
104 if(option == OPT_WGAIM_AUTOSTART) {
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
105 HKEY hKey;
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
106
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
107 if(!open_run_key(&hKey, KEY_SET_VALUE))
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
108 return;
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
109 if(winprefs_options & OPT_WGAIM_AUTOSTART) {
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
110 char buffer[1024];
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
111 DWORD size;
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
112
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
113 if((size = GetModuleFileName(wgaim_hinstance(),
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
114 (LPBYTE)buffer,
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
115 sizeof(buffer)))==0) {
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
116 debug_printf("GetModuleFileName Error.. Could not set Gaim autostart.\n");
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
117 RegCloseKey(hKey);
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
118 return;
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
119 }
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
120 /* Now set value of new key */
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
121 if(ERROR_SUCCESS != RegSetValueEx(hKey,
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
122 "Gaim",
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
123 0,
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
124 REG_SZ,
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
125 buffer,
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
126 size))
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
127 debug_printf("Could not set registry key value\n");
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
128 }
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
129 else {
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
130 if(ERROR_SUCCESS != RegDeleteValue(hKey, "Gaim"))
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
131 debug_printf("Could not delete registry key value\n");
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
132 }
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
133 RegCloseKey(hKey);
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
134 }
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
135 }
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
136
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
137 /*
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
138 * EXPORTED FUNCTIONS
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
139 */
5224
5160333a80df [gaim-migrate @ 5594]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4606
diff changeset
140 static GtkWidget* get_config_frame(GaimPlugin *plugin) {
4134
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
141 GtkWidget *ret;
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
142 GtkWidget *button;
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
143 GtkWidget *vbox;
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
144 HKEY hKey;
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
145
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
146 ret = gtk_vbox_new(FALSE, 18);
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
147 gtk_container_set_border_width (GTK_CONTAINER (ret), 12);
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
148
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
149 /* IM Convo trans options */
5749
6d6ae91c5de7 [gaim-migrate @ 6174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5224
diff changeset
150 vbox = gaim_gtk_make_frame (ret, _("Startup"));
6d6ae91c5de7 [gaim-migrate @ 6174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5224
diff changeset
151 button = wgaim_button(_("_Start Gaim on Windows startup"), &winprefs_options, OPT_WGAIM_AUTOSTART, vbox);
4134
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
152 /* Set initial value */
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
153 if(open_run_key(&hKey, KEY_QUERY_VALUE)) {
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
154 if(ERROR_SUCCESS == RegQueryValueEx(hKey, "Gaim", 0, NULL, NULL, NULL)) {
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
155 winprefs_options ^= OPT_WGAIM_AUTOSTART;
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
156 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
157 }
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
158 }
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
159 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(set_winprefs_option), (int *)OPT_WGAIM_AUTOSTART);
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
160
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
161 gtk_widget_show_all(ret);
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
162 return ret;
c0f4c664e3ba [gaim-migrate @ 4352]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff changeset
163 }
5224
5160333a80df [gaim-migrate @ 5594]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4606
diff changeset
164
5160333a80df [gaim-migrate @ 5594]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4606
diff changeset
165 static GaimGtkPluginUiInfo ui_info =
5160333a80df [gaim-migrate @ 5594]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4606
diff changeset
166 {
5160333a80df [gaim-migrate @ 5594]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4606
diff changeset
167 get_config_frame
5160333a80df [gaim-migrate @ 5594]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4606
diff changeset
168 };
5160333a80df [gaim-migrate @ 5594]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4606
diff changeset
169
5160333a80df [gaim-migrate @ 5594]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4606
diff changeset
170 static GaimPluginInfo info =
5160333a80df [gaim-migrate @ 5594]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4606
diff changeset
171 {
5160333a80df [gaim-migrate @ 5594]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4606
diff changeset
172 2,
5160333a80df [gaim-migrate @ 5594]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4606
diff changeset
173 GAIM_PLUGIN_STANDARD,
5160333a80df [gaim-migrate @ 5594]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4606
diff changeset
174 GAIM_GTK_PLUGIN_TYPE,
5160333a80df [gaim-migrate @ 5594]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4606
diff changeset
175 0,
5160333a80df [gaim-migrate @ 5594]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4606
diff changeset
176 NULL,
5160333a80df [gaim-migrate @ 5594]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4606
diff changeset
177 GAIM_PRIORITY_DEFAULT,
5160333a80df [gaim-migrate @ 5594]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4606
diff changeset
178 WINPREFS_PLUGIN_ID,
5160333a80df [gaim-migrate @ 5594]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4606
diff changeset
179 N_("WinGaim Options"),
5160333a80df [gaim-migrate @ 5594]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4606
diff changeset
180 VERSION,
5160333a80df [gaim-migrate @ 5594]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4606
diff changeset
181 N_("Options specific to Windows Gaim."),
5160333a80df [gaim-migrate @ 5594]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4606
diff changeset
182 N_("Options specific to Windows Gaim."),
5160333a80df [gaim-migrate @ 5594]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4606
diff changeset
183 "Herman Bloggs <hermanator12002@yahoo.com>",
5160333a80df [gaim-migrate @ 5594]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4606
diff changeset
184 WEBSITE,
5160333a80df [gaim-migrate @ 5594]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4606
diff changeset
185 NULL,
5160333a80df [gaim-migrate @ 5594]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4606
diff changeset
186 NULL,
5160333a80df [gaim-migrate @ 5594]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4606
diff changeset
187 NULL,
5160333a80df [gaim-migrate @ 5594]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4606
diff changeset
188 &ui_info,
5160333a80df [gaim-migrate @ 5594]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4606
diff changeset
189 NULL
5160333a80df [gaim-migrate @ 5594]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4606
diff changeset
190 };
5160333a80df [gaim-migrate @ 5594]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4606
diff changeset
191
5160333a80df [gaim-migrate @ 5594]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4606
diff changeset
192 static void
5160333a80df [gaim-migrate @ 5594]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4606
diff changeset
193 __init_plugin(GaimPlugin *plugin)
5160333a80df [gaim-migrate @ 5594]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4606
diff changeset
194 {
5160333a80df [gaim-migrate @ 5594]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4606
diff changeset
195 }
5160333a80df [gaim-migrate @ 5594]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4606
diff changeset
196
5160333a80df [gaim-migrate @ 5594]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4606
diff changeset
197 GAIM_INIT_PLUGIN(winprefs, __init_plugin, info);