Mercurial > pidgin.yaz
changeset 4157:9c31ddae80a1
[gaim-migrate @ 4385]
I'm commiting this so Robot101 will leave me alone.
Here's some session management stuff. Happy Gnome People.
committer: Tailor Script <tailor@pidgin.im>
author | Rob Flynn <gaim@robflynn.com> |
---|---|
date | Tue, 31 Dec 2002 05:22:56 +0000 |
parents | d833bacc054f |
children | a638bc9454a6 |
files | configure.ac configure.in plugins/docklet/docklet.c src/Makefile.am src/about.c src/aim.c src/buddy.c src/ui.h |
diffstat | 8 files changed, 131 insertions(+), 58 deletions(-) [+] |
line wrap: on
line diff
--- a/configure.ac Tue Dec 31 02:53:41 2002 +0000 +++ b/configure.ac Tue Dec 31 05:22:56 2002 +0000 @@ -122,6 +122,7 @@ AC_ARG_ENABLE(gtkspell, [ --disable-gtkspell compile without GtkSpell automatic spell checking],,enable_gtkspell=yes) AC_ARG_ENABLE(debug, [ --enable-debug compile with debugging support],,enable_debug=no) AC_ARG_ENABLE(screensaver, [ --disable-screensaver compile without X screensaver extension],,enable_xss=yes) +AC_ARG_ENABLE(sm, [ --disable-sm compile without X session management support],,enable_sm=yes) AC_ARG_WITH(krb4, [ --with-krb4=PREFIX Compile Zephyr plugin with Kerberos 4 support],kerberos="$withval",kerberos="no") if test "$enable_debug" = yes ; then @@ -141,9 +142,10 @@ AC_PATH_PROG(gaimpath, gaim) CFLAGS="$CFLAGS $GTK_CFLAGS -DGTK_ENABLE_BROKEN" +AC_PATH_X + dnl Check for XScreenSaver if test "x$enable_xss" = "xyes" ; then - AC_PATH_X old_LIBS="$LIBS" LIBS="$LIBS $GTK_LIBS -L$x_libraries" XSS_LIBS="no" @@ -168,6 +170,23 @@ AC_SUBST(XSS_LIBS) +dnl Check for X session management libs +if test "x$enable_sm" = "xyes"; then + enable_sm=no + AC_CHECK_LIB(SM, SmcSaveYourselfDone, found_sm_lib=true, , [-L$x_libraries -lICE]) + if test "$found_sm_lib" = "true"; then + AC_CHECK_HEADERS(X11/SM/SMlib.h, SM_LIBS="-L$x_libraries -lSM -lICE" enable_sm=yes) + fi +else + SM_LIBS="" + enable_sm=no +fi +AC_SUBST(SM_LIBS) +if test "$enable_sm" = "yes"; then + AC_DEFINE(USE_SM, 1, [Define if we're using X Session Management.]) +fi + + AC_DEFUN(GC_TM_GMTOFF, [AC_REQUIRE([AC_STRUCT_TM])dnl AC_CACHE_CHECK([for tm_gmtoff in struct tm], ac_cv_struct_tm_gmtoff, @@ -410,6 +429,7 @@ echo Build with GtkSpell............: $enable_gtkspell echo echo Use XScreenSaver Extension.... : $enable_xss +echo Use X Session Management...... : $enable_sm echo echo Build with ESD................ : $enable_esd echo Build with NAS................ : $enable_nas
--- a/configure.in Tue Dec 31 02:53:41 2002 +0000 +++ b/configure.in Tue Dec 31 05:22:56 2002 +0000 @@ -142,9 +142,10 @@ AC_PATH_PROG(gaimpath, gaim) CFLAGS="$CFLAGS $GTK_CFLAGS -DGTK_ENABLE_BROKEN" +AC_PATH_X + dnl Check for XScreenSaver if test "x$enable_xss" = "xyes" ; then - AC_PATH_X old_LIBS="$LIBS" LIBS="$LIBS $GTK_LIBS -L$x_libraries" XSS_LIBS="no" @@ -168,6 +169,24 @@ fi AC_SUBST(XSS_LIBS) + +dnl Check for X session management libs +if test "x$enable_sm" = "xyes"; then + enable_sm=no + AC_CHECK_LIB(SM, SmcSaveYourselfDone, found_sm_lib=true, , [-L$x_libraries -lICE]) + if test "$found_sm_lib" = "true"; then + AC_CHECK_HEADERS(X11/SM/SMlib.h, SM_LIBS="-L$x_libraries -lSM -lICE" enable_sm=yes) + fi +else + SM_LIBS="" + enable_sm=no +fi +AC_SUBST(SM_LIBS) +if test "$enable_sm" = "yes"; then + AC_DEFINE(USE_SM, 1, [Define if we're using X Session Management.]) +fi + + AC_DEFUN(GC_TM_GMTOFF, [AC_REQUIRE([AC_STRUCT_TM])dnl AC_CACHE_CHECK([for tm_gmtoff in struct tm], ac_cv_struct_tm_gmtoff,
--- a/plugins/docklet/docklet.c Tue Dec 31 02:53:41 2002 +0000 +++ b/plugins/docklet/docklet.c Tue Dec 31 05:22:56 2002 +0000 @@ -39,17 +39,18 @@ /* types */ enum docklet_status { + offline, + offline_connecting, online, + online_connecting, + online_pending, away, - away_pending, - unread_pending, - connecting, - offline + away_pending }; /* functions */ static gboolean docklet_create(); -static void docklet_update_status(); +static gboolean docklet_update_status(); void gaim_plugin_remove(); /* globals */ @@ -88,12 +89,13 @@ menu = gtk_menu_new(); - if (status == offline) { - entry = gtk_menu_item_new_with_label(_("Auto-login")); - g_signal_connect(G_OBJECT(entry), "activate", G_CALLBACK(auto_login), NULL); - gtk_menu_append(GTK_MENU(menu), entry); - } else { - if (status == online) { + switch (status) { + case offline: + case offline_connecting: + break; + case online: + case online_connecting: + case online_pending: { GtkWidget *docklet_awaymenu; GSList *awy = NULL; struct away_message *a = NULL; @@ -111,8 +113,8 @@ awy = g_slist_next(awy); } - entry = gtk_separator_menu_item_new(); - gtk_menu_append(GTK_MENU(docklet_awaymenu), entry); + if (away_messages) + gaim_separator(docklet_awaymenu); entry = gtk_menu_item_new_with_label(_("New...")); g_signal_connect(G_OBJECT(entry), "activate", G_CALLBACK(create_away_mess), NULL); @@ -121,43 +123,43 @@ entry = gtk_menu_item_new_with_label(_("Away")); gtk_menu_item_set_submenu(GTK_MENU_ITEM(entry), docklet_awaymenu); gtk_menu_append(GTK_MENU(menu), entry); - } else { + } break; + case away: + case away_pending: entry = gtk_menu_item_new_with_label(_("Back")); g_signal_connect(G_OBJECT(entry), "activate", G_CALLBACK(do_im_back), NULL); gtk_menu_append(GTK_MENU(menu), entry); - } - - entry = gtk_menu_item_new_with_label(_("Signoff")); - g_signal_connect(G_OBJECT(entry), "activate", G_CALLBACK(signoff_all), NULL); - gtk_menu_append(GTK_MENU(menu), entry); + break; } - entry = gtk_separator_menu_item_new(); - gtk_menu_append(GTK_MENU(menu), entry); + switch (status) { + case offline: + case offline_connecting: + entry = gtk_menu_item_new_with_label(_("Auto-login")); + g_signal_connect(G_OBJECT(entry), "activate", G_CALLBACK(auto_login), NULL); + gtk_menu_append(GTK_MENU(menu), entry); + break; + default: + entry = gtk_menu_item_new_with_label(_("Signoff")); + g_signal_connect(G_OBJECT(entry), "activate", G_CALLBACK(signoff_all), NULL); + gtk_menu_append(GTK_MENU(menu), entry); + break; + } + + gaim_separator(menu); entry = gtk_check_menu_item_new_with_label(_("Mute Sounds")); gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(entry), mute_sounds); g_signal_connect(G_OBJECT(entry), "toggled", G_CALLBACK(docklet_toggle_mute), NULL); gtk_menu_append(GTK_MENU(menu), entry); - entry = gtk_menu_item_new_with_label(_("Accounts")); - g_signal_connect(G_OBJECT(entry), "activate", G_CALLBACK(account_editor), NULL); - gtk_menu_append(GTK_MENU(menu), entry); - - entry = gtk_image_menu_item_new_from_stock(GTK_STOCK_PREFERENCES, NULL); - g_signal_connect(G_OBJECT(entry), "activate", G_CALLBACK(show_prefs), NULL); - gtk_menu_append(GTK_MENU(menu), entry); + gaim_new_item_from_pixbuf(menu, _("Accounts..."), "accounts-menu.png", G_CALLBACK(account_editor), NULL, 0, 0, 0); + gaim_new_item_from_stock(menu, _("Preferences..."), GTK_STOCK_PREFERENCES, G_CALLBACK(show_prefs), NULL, 0, 0, 0); - entry = gtk_separator_menu_item_new(); - gtk_menu_append(GTK_MENU(menu), entry); + gaim_separator(menu); - entry = gtk_menu_item_new_with_label(_("About")); - g_signal_connect(G_OBJECT(entry), "activate", G_CALLBACK(show_about), NULL); - gtk_menu_append(GTK_MENU(menu), entry); - - entry = gtk_image_menu_item_new_from_stock(GTK_STOCK_QUIT, NULL); - g_signal_connect(G_OBJECT(entry), "activate", G_CALLBACK(do_quit), NULL); - gtk_menu_append(GTK_MENU(menu), entry); + gaim_new_item_from_pixbuf(menu, _("About Gaim..."), "about_menu.png", G_CALLBACK(show_about), NULL, 0, 0, 0); + gaim_new_item_from_stock(menu, _("Quit"), GTK_STOCK_QUIT, G_CALLBACK(do_quit), NULL, 0, 0, 0); gtk_widget_show_all(menu); gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, event->button, event->time); @@ -189,23 +191,25 @@ GdkPixbuf *unscaled; switch (status) { + case offline: + filename = g_build_filename(DATADIR, "pixmaps", "gaim", "offline.png", NULL); + break; + case offline_connecting: + case online_connecting: + filename = g_build_filename(DATADIR, "pixmaps", "gaim", "connect.png", NULL); + break; case online: filename = g_build_filename(DATADIR, "pixmaps", "gaim", "online.png", NULL); break; + case online_pending: + filename = g_build_filename(DATADIR, "pixmaps", "gaim", "msgunread.png", NULL); + break; case away: filename = g_build_filename(DATADIR, "pixmaps", "gaim", "away.png", NULL); break; case away_pending: filename = g_build_filename(DATADIR, "pixmaps", "gaim", "msgpend.png", NULL); break; - case unread_pending: - filename = g_build_filename(DATADIR, "pixmaps", "gaim", "msgunread.png", NULL); - break; - case connecting: - filename = g_build_filename(DATADIR, "pixmaps", "gaim", "connect.png", NULL); - break; - case offline: - filename = g_build_filename(DATADIR, "pixmaps", "gaim", "offline.png", NULL); } unscaled = gdk_pixbuf_new_from_file(filename, NULL); @@ -226,14 +230,14 @@ g_free(filename); } -static void docklet_update_status() { +static gboolean docklet_update_status() { enum docklet_status oldstatus; oldstatus = status; if (connections) { if (unread_message_queue) { - status = unread_pending; + status = online_pending; } else if (awaymessage) { if (message_queue) { status = away_pending; @@ -241,13 +245,13 @@ status = away; } } else if (connecting_count) { - status = connecting; + status = online_connecting; } else { status = online; } } else { if (connecting_count) { - status = connecting; + status = offline_connecting; } else { status = offline; } @@ -256,6 +260,8 @@ if (status != oldstatus) { docklet_update_icon(); } + + return FALSE; /* for when we're called by the glib idle handler */ } static void docklet_embedded(GtkWidget *widget, void *data) { @@ -314,7 +320,10 @@ } static void gaim_signoff(struct gaim_connection *gc, void *data) { - docklet_update_status(); + /* do this when idle so that if the prpl was connecting + and was cancelled, we register that connecting_count + has returned to 0 */ + g_idle_add(docklet_update_status, NULL); } static void gaim_connecting(struct aim_user *user, void *data) {
--- a/src/Makefile.am Tue Dec 31 02:53:41 2002 +0000 +++ b/src/Makefile.am Tue Dec 31 05:22:56 2002 +0000 @@ -24,6 +24,7 @@ proxy.c \ prpl.c \ server.c \ + session.c \ socket.c \ sound.c \ util.c @@ -37,7 +38,7 @@ CFLAGS += $(PERL_CFLAGS) $(GTKSPELL_CFLAGS) CFLAGS += -DLOCALEDIR=\"$(datadir)/locale\" -DLIBDIR=\"$(libdir)/gaim/\" $(DEBUG_CFLAGS) -DDATADIR=\"$(datadir)\" -LIBS = @LIBS@ $(GTK_LIBS) $(SOUND_LIBS) $(STATIC_LINK_LIBS) $(PERL_LIBS) $(XSS_LIBS) $(INTLLIBS) $(DEBUG_LIBS) $(GTKSPELL_LIBS) +LIBS = @LIBS@ $(GTK_LIBS) $(SOUND_LIBS) $(STATIC_LINK_LIBS) $(PERL_LIBS) $(XSS_LIBS) $(SM_LIBS) $(INTLLIBS) $(DEBUG_LIBS) $(GTKSPELL_LIBS) EXTRA_DIST = convo.h \ core.h \
--- a/src/about.c Tue Dec 31 02:53:41 2002 +0000 +++ b/src/about.c Tue Dec 31 05:22:56 2002 +0000 @@ -188,5 +188,5 @@ /* Let's give'em something to talk about -- woah woah woah */ gtk_widget_show(about); - gtk_window_present(about); + gtk_window_present(GTK_WINDOW(about)); }
--- a/src/aim.c Tue Dec 31 02:53:41 2002 +0000 +++ b/src/aim.c Tue Dec 31 05:22:56 2002 +0000 @@ -125,6 +125,11 @@ perl_end(); #endif +#ifdef USE_SM + /* unplug */ + session_end(); +#endif + /* and end it all... */ gtk_main_quit(); } @@ -552,6 +557,7 @@ { int opt_acct = 0, opt_help = 0, opt_version = 0, opt_login = 0, opt_nologin = 0, dologin_ret = -1; char *opt_user_arg = NULL, *opt_login_arg = NULL; + char *opt_session_arg = NULL; #if HAVE_SIGNAL_H int sig_indx; /* for setting up signal catching */ sigset_t sigset; @@ -570,6 +576,7 @@ {"file", required_argument, NULL, 'f'}, {"debug", no_argument, NULL, 'd'}, {"version", no_argument, NULL, 'v'}, + {"session", required_argument, NULL, 's'}, {0, 0, 0, 0} }; @@ -703,7 +710,7 @@ opterr = 1; while ((opt = getopt_long(argc, argv, #ifndef _WIN32 - "adhu:f:vn", + "adhu:f:vns:", #else "adghu:f:vn", #endif @@ -722,6 +729,9 @@ case 'f': opt_rcfile_arg = g_strdup(optarg); break; + case 's': /* use existing session ID */ + opt_session_arg = g_strdup(optarg); + break; case 'v': /* version */ opt_version = 1; break; @@ -806,6 +816,14 @@ ui_main(); #endif +#ifdef USE_SM + session_init(argv[0], opt_session_arg); +#endif + if (opt_session_arg != NULL) { + g_free(opt_session_arg); + opt_session_arg = NULL; + }; + /* set the default username */ if (opt_user_arg != NULL) { set_first_user(opt_user_arg);
--- a/src/buddy.c Tue Dec 31 02:53:41 2002 +0000 +++ b/src/buddy.c Tue Dec 31 05:22:56 2002 +0000 @@ -2487,8 +2487,8 @@ y != blist_pos.y || event->width != blist_pos.width || event->height != blist_pos.height) { - blist_pos.x = x > 0 ? x : 0; - blist_pos.y = y > 0 ? y : 0; + blist_pos.x = x; + blist_pos.y = y; blist_pos.width = event->width; blist_pos.height = event->height; save_prefs();
--- a/src/ui.h Tue Dec 31 02:53:41 2002 +0000 +++ b/src/ui.h Tue Dec 31 05:22:56 2002 +0000 @@ -315,6 +315,9 @@ /* Globals in prpl.c */ extern GtkWidget *protomenu; +/* Globals in session.c */ +extern gboolean session_managed; + /* Globals in sound.c */ extern gboolean mute_sounds; @@ -506,7 +509,6 @@ extern void apply_color_dlg(GtkWidget *, gpointer); extern void destroy_colorsel(GtkWidget *, gpointer); - /* Functions in prpl.c */ extern void register_dialog(); @@ -514,6 +516,10 @@ /* server.c is in desperate need need of a split */ extern int find_queue_total_by_name(char *); +/* Functions in session.c */ +extern void session_init(gchar *, gchar *); +extern void session_end(); + /* Functions in sound.c */ extern void play_sound(int); extern void play_file(char *);