Mercurial > pidgin.yaz
changeset 4026:a997156437b6
[gaim-migrate @ 4230]
Win prefs page w/ transparency option added
committer: Tailor Script <tailor@pidgin.im>
author | Herman Bloggs <hermanator12002@yahoo.com> |
---|---|
date | Sun, 01 Dec 2002 03:08:27 +0000 |
parents | 0d8b71d0d8f8 |
children | 764b41bb1905 |
files | src/Makefile.mingw src/conversation.c src/gaimrc.c src/prefs.c src/win32/mingw_plus/winuser_extra.h src/win32/win32dep.c src/win32/win32dep.h |
diffstat | 7 files changed, 180 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/src/Makefile.mingw Sun Dec 01 03:04:09 2002 +0000 +++ b/src/Makefile.mingw Sun Dec 01 03:08:27 2002 +0000 @@ -103,7 +103,8 @@ win32/win32dep.c \ win32/MinimizeToTray.c \ win32/libc_interface.c \ - win32/systray.c + win32/systray.c \ + win32/winprefs.c RC_SRC = win32/gaimrc.rc
--- a/src/conversation.c Sun Dec 01 03:04:09 2002 +0000 +++ b/src/conversation.c Sun Dec 01 03:08:27 2002 +0000 @@ -49,7 +49,7 @@ #include "prpl.h" #ifdef _WIN32 -#include <process.h> /* fog getpid() */ +#include <process.h> /* for getpid() */ #include <io.h> #include "win32dep.h" #endif @@ -2783,6 +2783,17 @@ menubar = build_conv_menubar(c); gtk_box_pack_start(GTK_BOX(testidea), menubar, FALSE, TRUE, 0); gtk_box_pack_start(GTK_BOX(testidea), convo_notebook, TRUE, TRUE, 0); +#ifdef _WIN32 + /* Windows transparency slider */ + if ((wgaim_options & OPT_WGAIM_IMTRANS) && + (wgaim_options & OPT_WGAIM_SHOW_IMTRANS)) { + gtk_box_pack_start(GTK_BOX(testidea), + wgaim_wintrans_slider(win), + FALSE, FALSE, 0); + } else if(wgaim_options & OPT_WGAIM_IMTRANS) { + wgaim_set_wintrans(win, wgaim_get_imalpha()); + } +#endif gtk_widget_show(testidea); gtk_widget_show(convo_notebook); convo_menubar = menubar; @@ -2790,7 +2801,6 @@ gtk_container_add(GTK_CONTAINER(win), testidea); gtk_signal_connect(GTK_OBJECT(convo_notebook), "switch-page", GTK_SIGNAL_FUNC(convo_switch), NULL); - } else win = c->window = all_convos; @@ -2811,7 +2821,8 @@ gtk_box_pack_start(GTK_BOX(tabby), c->close, FALSE, FALSE, 0); gtk_widget_show_all(tabby); gtk_notebook_insert_page(GTK_NOTEBOOK(convo_notebook), cont, tabby, - g_list_index(conversations, c)); + g_list_index(conversations, c)); + gtk_widget_show(cont); } else { cont = win = gtk_window_new(GTK_WINDOW_TOPLEVEL); @@ -2917,6 +2928,23 @@ gtk_box_pack_start(GTK_BOX(vbox2), bbox, FALSE, FALSE, 0); gtk_widget_show(bbox); +#ifdef _WIN32 + /* Windows transparency slider */ + if ((wgaim_options & OPT_WGAIM_IMTRANS) && + (wgaim_options & OPT_WGAIM_SHOW_IMTRANS) && + !(im_options & OPT_IM_ONE_WINDOW)) { + GtkWidget *wsep = gtk_hseparator_new(); + gtk_box_pack_start(GTK_BOX(vbox2), wsep, FALSE, FALSE, 0); + gtk_widget_show(wsep); + gtk_box_pack_start(GTK_BOX(vbox2), + wgaim_wintrans_slider(c->window), + FALSE, FALSE, 0); + } else if((wgaim_options & OPT_WGAIM_IMTRANS) && + !(im_options & OPT_IM_ONE_WINDOW)) { + wgaim_set_wintrans(win, wgaim_get_imalpha()); + } +#endif + /* I'm leaving this here just incase we want to bring this back. I'd rather not have the close * button any more. If we do, though, it needs to be on the left side. I might bring it back and put * it on that side. */
--- a/src/gaimrc.c Sun Dec 01 03:04:09 2002 +0000 +++ b/src/gaimrc.c Sun Dec 01 03:08:27 2002 +0000 @@ -57,6 +57,9 @@ guint sound_options; guint away_options; guint away_resend; +#ifdef _WIN32 +guint wgaim_options; +#endif int report_idle; int web_browser; @@ -170,8 +173,9 @@ return 6; } else if (!strcmp(tag, "proxy")) { return 7; + } else if (!strcmp(tag, "wgaim")) { + return 8; } - return -1; } @@ -765,6 +769,10 @@ } else if (!strcmp(p->option, "away_options")) { away_options = atoi(p->value[0]); away_resend = atoi(p->value[1]); +#ifdef _WIN32 + } else if(!strcmp(p->option, "wgaim_options")) { + wgaim_options = atoi(p->value[0]); +#endif } else if (!strcmp(p->option, "font_face")) { g_snprintf(fontface, sizeof(fontface), "%s", p->value[0]); } else if (!strcmp(p->option, "font_size")) { @@ -873,7 +881,9 @@ fprintf(f, "\tfont_options { %u }\n", font_options); fprintf(f, "\tsound_options { %u }\n", sound_options); fprintf(f, "\taway_options { %u } { %u }\n", away_options, away_resend); - +#ifdef _WIN32 + fprintf(f, "\twgaim_options { %u }\n", wgaim_options); +#endif fprintf(f, "\tfont_face { %s }\n", fontface); fprintf(f, "\tfont_size { %d }\n", fontsize); fprintf(f, "\tforeground { %d } { %d } { %d }\n", fgcolor.red, fgcolor.green, fgcolor.blue); @@ -1120,6 +1130,37 @@ fprintf(f, "}\n"); } +#ifdef _WIN32 +static void gaimrc_read_wgaim(FILE *f) +{ + char buf[2048]; + struct parse parse_buffer; + struct parse *p; + + buf[0] = 0; + + while (buf[0] != '}') { + if (buf[0] == '#') + continue; + + if (!fgets(buf, sizeof(buf), f)) + return; + + p = parse_line(buf, &parse_buffer); + + if (!strcmp(p->option, "imalpha")) { + wgaim_set_imalpha(atoi(p->value[0])); + } + } +} + +static void gaimrc_write_wgaim(FILE *f) +{ + fprintf(f, "wgaim {\n"); + fprintf(f, "\timalpha { %d }\n", wgaim_get_imalpha()); + fprintf(f, "}\n"); +} +#endif static void set_defaults() { @@ -1165,6 +1206,10 @@ away_options = OPT_AWAY_BACK_ON_IM; +#ifdef _WIN32 + wgaim_options = 0; +#endif + for (i = 0; i < NUM_SOUNDS; i++) sound_file[i] = NULL; font_options = 0; @@ -1259,6 +1304,11 @@ case 7: gaimrc_read_proxy(f); break; +#ifdef _WIN32 + case 8: + gaimrc_read_wgaim(f); + break; +#endif default: /* NOOP */ break; @@ -1300,6 +1350,9 @@ gaimrc_write_plugins(f); #endif gaimrc_write_proxy(f); +#ifdef _WIN32 + gaimrc_write_wgaim(f); +#endif fclose(f); chmod(buf, S_IRUSR | S_IWUSR);
--- a/src/prefs.c Sun Dec 01 03:04:09 2002 +0000 +++ b/src/prefs.c Sun Dec 01 03:08:27 2002 +0000 @@ -39,6 +39,10 @@ #include "prpl.h" #include "proxy.h" +#ifdef _WIN32 +#include "win32dep.h" +#endif + char fontface[128]; GtkWidget *tree_v = NULL; @@ -59,7 +63,7 @@ GtkCTreeNode *general_node = NULL; GtkCTreeNode *deny_node = NULL; GtkWidget *prefs_proxy_frame = NULL; -static GtkWidget *gaim_button(const char *, guint *, int, GtkWidget *); +GtkWidget *gaim_button(const char *, guint *, int, GtkWidget *); GtkWidget *gaim_labeled_spin_button(GtkWidget *, const gchar *, int*, int, int, GtkSizeGroup *); static GtkWidget *gaim_dropdown(GtkWidget *, const gchar *, int *, int, ...); static GtkWidget *show_color_pref(GtkWidget *, gboolean); @@ -1394,6 +1398,9 @@ prefs_notebook_add_page(_("Sound Events"), NULL, sound_events_page(), &c, &p, notebook_page++); prefs_notebook_add_page(_("Away / Idle"), NULL, away_page(), &p, NULL, notebook_page++); prefs_notebook_add_page(_("Away Messages"), NULL, away_message_page(), &c, &p, notebook_page++); +#ifdef _WIN32 + prefs_notebook_add_page(_("Windows Only"), NULL, wgaim_winprefs_page(), &p, NULL, notebook_page++); +#endif #if USE_PLUGINS prefs_notebook_add_page(_("Plugins"), NULL, plugin_page(), &plugin_iter, NULL, notebook_page++); while (l) { @@ -1741,6 +1748,14 @@ save_prefs(); } +#ifdef _WIN32 +static void set_wgaim_option(GtkWidget *w, int option) +{ + wgaim_options ^= option; + save_prefs(); +} +#endif + GtkWidget *gaim_button(const char *text, guint *options, int option, GtkWidget *page) { GtkWidget *button; @@ -1749,7 +1764,7 @@ gtk_box_pack_start(GTK_BOX(page), button, FALSE, FALSE, 0); gtk_object_set_user_data(GTK_OBJECT(button), options); - if (options == &misc_options) + if (options == &misc_options) gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(set_misc_option), (int *)option); if (options == &logging_options) @@ -1773,10 +1788,11 @@ if (options == &sound_options) gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(set_sound_option), (int *)option); - if (options == &away_options) - gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(set_away_option), +#ifdef _WIN32 + if (options == &wgaim_options) + gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(set_wgaim_option), (int *)option); - +#endif gtk_widget_show(button); return button;
--- a/src/win32/mingw_plus/winuser_extra.h Sun Dec 01 03:04:09 2002 +0000 +++ b/src/win32/mingw_plus/winuser_extra.h Sun Dec 01 03:08:27 2002 +0000 @@ -27,4 +27,13 @@ DWORD dwTimeout; } FLASHWINFO, *PFLASHWINFO; +/* These defines aren't found in the current version of mingw */ +#ifndef LWA_ALPHA +#define LWA_ALPHA 0x00000002 +#endif + +#ifndef WS_EX_LAYERED +#define WS_EX_LAYERED 0x00080000 +#endif + #endif /* _WINUSER_EXTRA_H_ */
--- a/src/win32/win32dep.c Sun Dec 01 03:04:09 2002 +0000 +++ b/src/win32/win32dep.c Sun Dec 01 03:08:27 2002 +0000 @@ -40,7 +40,7 @@ static char lib_dir[MAXPATHLEN]; static char locale_dir[MAXPATHLEN]; static int bhide_icon; - +static int imalpha = 255; /* * GLOBALS @@ -52,7 +52,8 @@ * PROTOS */ BOOL (*MyFlashWindowEx)(PFLASHWINFO pfwi)=NULL; - +BOOL (*MySetLayeredWindowAttributes)(HWND hwnd, COLORREF crKey, BYTE bAlpha, DWORD dwFlags)=NULL; +void wgaim_set_wintrans(GtkWidget *window, int trans); /* * STATIC CODE @@ -104,12 +105,17 @@ } } - -void load_winver_specific_procs(void) { +static void load_winver_specific_procs(void) { /* Used for Win98+ and WinNT5+ */ MyFlashWindowEx = (void*)find_and_loadproc("user32.dll", "FlashWindowEx" ); + /* Used for Win2k+ */ + MySetLayeredWindowAttributes = (void*)find_and_loadproc("user32.dll", "SetLayeredWindowAttributes" ); } +/* Transparency slider callbacks */ +static void change_im_alpha(GtkWidget *w, gpointer data) { + wgaim_set_wintrans(GTK_WIDGET(data), gtk_range_get_value(GTK_RANGE(w))); +} /* * PUBLIC CODE @@ -181,6 +187,52 @@ } } +/* Set window transparency level */ +void wgaim_set_wintrans(GtkWidget *window, int trans) { + if(MySetLayeredWindowAttributes) { + HWND hWnd = GDK_WINDOW_HWND(window->window); + SetWindowLong(hWnd,GWL_EXSTYLE,GetWindowLong(hWnd,GWL_EXSTYLE) | WS_EX_LAYERED); + MySetLayeredWindowAttributes(hWnd,0,trans,LWA_ALPHA); + } +} + +void wgaim_set_imalpha(int val) { + imalpha = val; +} + +int wgaim_get_imalpha(int val) { + return imalpha; +} + +int wgaim_has_transparency() { + return MySetLayeredWindowAttributes ? TRUE : FALSE; +} + +GtkWidget *wgaim_wintrans_slider(GtkWidget *win) { + GtkWidget *hbox; + GtkWidget *label, *slider; + + hbox = gtk_hbox_new(FALSE, 5); + + label = gtk_label_new(_("Opacity:")); + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); + + slider = gtk_hscale_new_with_range(50,255,1); + gtk_range_set_value(GTK_RANGE(slider), imalpha); + gtk_widget_set_usize(GTK_WIDGET(slider), 200, -1); + + /* On slider val change, update window's transparency level */ + gtk_signal_connect(GTK_OBJECT(slider), "value-changed", GTK_SIGNAL_FUNC(change_im_alpha), win); + gtk_box_pack_start(GTK_BOX(hbox), slider, FALSE, TRUE, 5); + + /* Set the initial transparency level */ + wgaim_set_wintrans(win, imalpha); + + gtk_widget_show_all(hbox); + + return hbox; +} + /* Windows Initializations */ void wgaim_init(void) {
--- a/src/win32/win32dep.h Sun Dec 01 03:04:09 2002 +0000 +++ b/src/win32/win32dep.h Sun Dec 01 03:08:27 2002 +0000 @@ -10,6 +10,7 @@ #include "winerror.h" #include "libc_interface.h" #include "systray.h" +#include "winprefs.h" /* * PROTOS @@ -21,6 +22,11 @@ /* Misc */ HINSTANCE wgaim_hinstance(void); extern void wgaim_im_blink(GtkWidget*); +extern GtkWidget *wgaim_wintrans_slider(GtkWidget*); +extern void wgaim_set_wintrans(GtkWidget*, int); +extern void wgaim_set_imalpha(int); +extern int wgaim_get_imalpha(); +extern int wgaim_has_transparency(); /* Determine Gaim paths */ extern char* wgaim_install_dir(void);