# HG changeset patch # User Christian Hammond # Date 1054974955 0 # Node ID 0efc365eed6dfcc4902d99c7b7cba1248aa8df26 # Parent 5e93fc46d1afd67b40416746f3084abd99d88ae8 [gaim-migrate @ 6220] Win32 pref updates. Thanks SimGuy! committer: Tailor Script diff -r 5e93fc46d1af -r 0efc365eed6d plugins/win32/winprefs/winprefs.c --- a/plugins/win32/winprefs/winprefs.c Sat Jun 07 07:57:24 2003 +0000 +++ b/plugins/win32/winprefs/winprefs.c Sat Jun 07 08:35:55 2003 +0000 @@ -23,6 +23,7 @@ #include #include "gaim.h" #include "gtkplugin.h" +#include "prefs.h" #include "win32dep.h" /* @@ -31,13 +32,10 @@ #define WINPREFS_PLUGIN_ID "gaim-winprefs" #define WINPREFS_VERSION 1 -/* Plugin options */ -#define OPT_WGAIM_AUTOSTART 0x00000001 - /* * LOCALS */ -guint winprefs_options=0; +static const char *OPT_WINPREFS_AUTOSTART="/plugins/gtk/win32/winprefs/auto_start"; /* * PROTOS @@ -47,73 +45,45 @@ * CODE */ -static GtkWidget *wgaim_button(const char *text, guint *options, int option, GtkWidget *page) { - GtkWidget *button; +static GtkWidget *wgaim_button(const char *text, const char *pref, GtkWidget *page) { + GtkWidget *button; button = gtk_check_button_new_with_mnemonic(text); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), (*options & option)); - gtk_box_pack_start(GTK_BOX(page), button, FALSE, FALSE, 0); - g_object_set_data(G_OBJECT(button), "options", options); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), gaim_prefs_get_bool(pref)); + gtk_box_pack_start(GTK_BOX(page), button, FALSE, FALSE, 0); gtk_widget_show(button); - return button; -} - -static void write_options(FILE *f) { - fprintf(f, "options {\n"); - fprintf(f, "\twinprefs_options { %u }\n", winprefs_options); - fprintf(f, "}\n"); -} - -static void save_winprefs_prefs() { - FILE *f; - char buf[1024]; - - if (gaim_home_dir()) { - g_snprintf(buf, sizeof(buf), "%s" G_DIR_SEPARATOR_S ".gaim" G_DIR_SEPARATOR_S "winprefsrc", gaim_home_dir()); - } - else - return; - - if ((f = fopen(buf, "w"))) { - fprintf(f, "# winprefsrc v%d\n", WINPREFS_VERSION); - write_options(f); - fclose(f); - } - else - debug_printf("Error opening wintransrc\n"); + return button; } static int open_run_key(PHKEY phKey, REGSAM samDesired) { - /* First try current user key (for WinNT & Win2k +), fall back to local machine */ - if(ERROR_SUCCESS == RegOpenKeyEx(HKEY_CURRENT_USER, + /* First try current user key (for WinNT & Win2k +), fall back to local machine */ + if(ERROR_SUCCESS == RegOpenKeyEx(HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", 0, samDesired, phKey)); else if(ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", 0, samDesired, phKey)); else { - debug_printf("open_run_key: Could not open key for writing value\n"); + gaim_debug(3, WINPREFS_PLUGIN_ID, "open_run_key: Could not open key for writing value\n"); return 0; } return 1; } -static void set_winprefs_option(GtkWidget *w, int option) { - winprefs_options ^= option; - save_winprefs_prefs(); - - if(option == OPT_WGAIM_AUTOSTART) { +static void set_winprefs_option(GtkWidget *w, const char *key) { + gaim_prefs_set_bool(key, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w))); + if(key == OPT_WINPREFS_AUTOSTART) { HKEY hKey; if(!open_run_key(&hKey, KEY_SET_VALUE)) return; - if(winprefs_options & OPT_WGAIM_AUTOSTART) { + if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w))) { char buffer[1024]; DWORD size; if((size = GetModuleFileName(wgaim_hinstance(), (LPBYTE)buffer, sizeof(buffer)))==0) { - debug_printf("GetModuleFileName Error.. Could not set Gaim autostart.\n"); + gaim_debug(3, WINPREFS_PLUGIN_ID, "GetModuleFileName Error.. Could not set Gaim autostart.\n"); RegCloseKey(hKey); return; } @@ -124,11 +94,11 @@ REG_SZ, buffer, size)) - debug_printf("Could not set registry key value\n"); + gaim_debug(3, WINPREFS_PLUGIN_ID, "Could not set registry key value\n"); } else { if(ERROR_SUCCESS != RegDeleteValue(hKey, "Gaim")) - debug_printf("Could not delete registry key value\n"); + gaim_debug(3, WINPREFS_PLUGIN_ID, "Could not delete registry key value\n"); } RegCloseKey(hKey); } @@ -148,20 +118,28 @@ /* IM Convo trans options */ vbox = gaim_gtk_make_frame (ret, _("Startup")); - button = wgaim_button(_("_Start Gaim on Windows startup"), &winprefs_options, OPT_WGAIM_AUTOSTART, vbox); + button = wgaim_button(_("_Start Gaim on Windows startup"), OPT_WINPREFS_AUTOSTART, vbox); /* Set initial value */ if(open_run_key(&hKey, KEY_QUERY_VALUE)) { if(ERROR_SUCCESS == RegQueryValueEx(hKey, "Gaim", 0, NULL, NULL, NULL)) { - winprefs_options ^= OPT_WGAIM_AUTOSTART; gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE); } } - gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(set_winprefs_option), (int *)OPT_WGAIM_AUTOSTART); + gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(set_winprefs_option), (void *)OPT_WINPREFS_AUTOSTART); gtk_widget_show_all(ret); return ret; } +static gboolean plugin_load(GaimPlugin *plugin) +{ + gaim_prefs_add_none("/plugins/gtk/win32"); + gaim_prefs_add_none("/plugins/gtk/win32/winprefs"); + gaim_prefs_add_bool("/plugins/gtk/win32/winprefs/auto_start", FALSE); + + return TRUE; +} + static GaimGtkPluginUiInfo ui_info = { get_config_frame @@ -182,7 +160,7 @@ N_("Options specific to Windows Gaim."), "Herman Bloggs ", WEBSITE, - NULL, + plugin_load, NULL, NULL, &ui_info, diff -r 5e93fc46d1af -r 0efc365eed6d src/win32/systray.c --- a/src/win32/systray.c Sat Jun 07 07:57:24 2003 +0000 +++ b/src/win32/systray.c Sat Jun 07 08:35:55 2003 +0000 @@ -146,7 +146,7 @@ /* in both connected and disconnected case delete away message menu */ if(systray_away_menu) { if(!DeleteMenu(systray_menu, (UINT)systray_away_menu, MF_BYCOMMAND)) - debug_printf("Error using DeleteMenu\n"); + gaim_debug(GAIM_DEBUG_ERROR, "wgaim_systray", "Error using DeleteMenu\n"); } @@ -160,8 +160,8 @@ pos = GetMenuItemPosition(systray_menu, SYSTRAY_CMND_MENU_EXIT) - 1; if(!InsertMenu(systray_menu, pos, MF_BYPOSITION | MF_STRING, SYSTRAY_CMND_SIGNOFF, locenc)) - debug_printf("InsertMenu failed: %s\n", GetLastError()); - debug_printf("Inserted Menu with ID: %d\n", SYSTRAY_CMND_SIGNOFF); + gaim_debug(GAIM_DEBUG_ERROR, "wgaim_systray", "InsertMenu failed: %s\n", GetLastError()); + gaim_debug(GAIM_DEBUG_INFO, "wgaim_systray", "Inserted Menu with ID: %d\n", SYSTRAY_CMND_SIGNOFF); g_free(locenc); } locenc = g_locale_from_utf8(_("Set Away Message"), -1, NULL, NULL, NULL); @@ -192,7 +192,7 @@ pos = GetMenuItemPosition(systray_menu, SYSTRAY_CMND_MENU_EXIT) - 1; if(!InsertMenu(systray_menu, pos, MF_BYPOSITION | MF_STRING, SYSTRAY_CMND_SIGNON, locenc)) - debug_printf("InsertMenu failed: %s\n", GetLastError()); + gaim_debug(GAIM_DEBUG_ERROR, "wgaim_systray", "InsertMenu failed: %s\n", GetLastError()); g_free(locenc); } EnableMenuItem(systray_menu, SYSTRAY_CMND_AUTOLOGIN, MF_ENABLED); @@ -232,53 +232,53 @@ switch(msg) { case WM_CREATE: - debug_printf("WM_CREATE\n"); + gaim_debug(GAIM_DEBUG_INFO, "wgaim_systray", "WM_CREATE\n"); taskbarRestartMsg = RegisterWindowMessage("TaskbarCreated"); break; case WM_TIMER: - debug_printf("WM_TIMER\n"); + gaim_debug(GAIM_DEBUG_INFO, "wgaim_systray", "WM_TIMER\n"); break; case WM_DESTROY: - debug_printf("WM_DESTROY\n"); + gaim_debug(GAIM_DEBUG_INFO, "wgaim_systray", "WM_DESTROY\n"); break; case WM_COMMAND: - debug_printf("WM_COMMAND\n"); + gaim_debug(GAIM_DEBUG_INFO, "wgaim_systray", "WM_COMMAND\n"); switch(LOWORD(wparam)) { case SYSTRAY_CMND_MENU_EXIT: do_quit(); break; case SYSTRAY_CMND_SIGNON: - debug_printf("signon\n"); + gaim_debug(GAIM_DEBUG_INFO, "wgaim_systray", "signon\n"); show_login(); break; case SYSTRAY_CMND_SIGNOFF: - debug_printf("signoff\n"); + gaim_debug(GAIM_DEBUG_INFO, "wgaim_systray", "signoff\n"); gaim_connections_disconnect_all(); break; case SYSTRAY_CMND_AUTOLOGIN: - debug_printf("autologin\n"); - /*auto_login();*/ + gaim_debug(GAIM_DEBUG_INFO, "wgaim_systray", "autologin\n"); + gaim_accounts_auto_login(GAIM_GTK_UI); break; case SYSTRAY_CMND_PREFS: - debug_printf("Prefs\n"); + gaim_debug(GAIM_DEBUG_INFO, "wgaim_systray", "Prefs\n"); gaim_gtk_prefs_show(); break; case SYSTRAY_CMND_BACK: - debug_printf("I'm back\n"); + gaim_debug(GAIM_DEBUG_INFO, "wgaim_systray", "I'm back\n"); do_im_back(NULL, NULL); break; case SYSTRAY_CMND_SET_AWY_NEW: - debug_printf("New away item\n"); + gaim_debug(GAIM_DEBUG_INFO, "wgaim_systray", "New away item\n"); create_away_mess(NULL, NULL); break; default: /* SYSTRAY_CMND_SET_AWY */ if((LOWORD(wparam) >= SYSTRAY_CMND_SET_AWY) && (LOWORD(wparam) <= (SYSTRAY_CMND_SET_AWY + MAX_AWY_MESSAGES))) { - debug_printf("Set away message\n"); + gaim_debug(GAIM_DEBUG_INFO, "wgaim_systray", "Set away message\n"); systray_set_away(LOWORD(wparam)-SYSTRAY_CMND_SET_AWY); } } @@ -289,7 +289,7 @@ /* Double Click */ /* Either hide or show current window (login or buddy) */ gaim_gtk_blist_docklet_toggle(); - debug_printf("Systray got double click\n"); + gaim_debug(GAIM_DEBUG_INFO, "wgaim_systray", "Systray got double click\n"); } if( lparam == WM_RBUTTONUP ) { /* Right Click */ @@ -353,20 +353,20 @@ if((systray_menu = CreatePopupMenu())) { if(!AppendMenu(systray_menu, MF_STRING, SYSTRAY_CMND_PREFS, (locenc=g_locale_from_utf8(_("Preferences"), -1, NULL, NULL, NULL)))) - debug_printf("AppendMenu error: %ld\n", GetLastError()); + gaim_debug(GAIM_DEBUG_ERROR, "wgaim_systray", "AppendMenu error: %ld\n", GetLastError()); g_free(locenc); if(!AppendMenu(systray_menu, MF_STRING, SYSTRAY_CMND_AUTOLOGIN, (locenc=g_locale_from_utf8(_("Auto-login"), -1, NULL, NULL, NULL)))) - debug_printf("AppendMenu error: %ld\n", GetLastError()); + gaim_debug(GAIM_DEBUG_ERROR, "wgaim_systray", "AppendMenu error: %ld\n", GetLastError()); g_free(locenc); if(!AppendMenu(systray_menu, MF_SEPARATOR, 0, 0)) - debug_printf("AppendMenu error: %ld\n", GetLastError()); + gaim_debug(GAIM_DEBUG_ERROR, "wgaim_systray", "AppendMenu error: %ld\n", GetLastError()); if(!AppendMenu(systray_menu, MF_STRING, SYSTRAY_CMND_MENU_EXIT, (locenc=g_locale_from_utf8(_("Exit"), -1, NULL, NULL, NULL)))) - debug_printf("AppendMenu error: %ld\n", GetLastError()); + gaim_debug(GAIM_DEBUG_ERROR, "wgaim_systray", "AppendMenu error: %ld\n", GetLastError()); g_free(locenc); } else - debug_printf("CreatePopupMenu error: %ld\n", GetLastError()); + gaim_debug(GAIM_DEBUG_ERROR, "wgaim_systray", "CreatePopupMenu error: %ld\n", GetLastError()); } static void systray_init_icon(HWND hWnd, HICON icon) { @@ -423,23 +423,17 @@ if(gaim_connections_get_all()) { if(awaymessage) { st_state = SYSTRAY_STATE_AWAY; -#if 0 } else if(gaim_connections_get_connecting()) { st_state = SYSTRAY_STATE_ONLINE_CONNECTING; -#endif } else { st_state = SYSTRAY_STATE_ONLINE; } } else { -#if 0 if(gaim_connections_get_connecting()) { st_state = SYSTRAY_STATE_OFFLINE_CONNECTING; } else { -#endif st_state = SYSTRAY_STATE_OFFLINE; -#if 0 } -#endif } if(st_state != old_state) { systray_update_icon();