--- osmo.old/src/gui.c +++ osmo/src/gui.c @@ -19,6 +19,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include + #include "gui.h" #include "about.h" #include "i18n.h" @@ -1339,6 +1341,50 @@ return menu_item; } +/* ---------------------------------------------------------------- */ + +/* "SignalForceVisible" is a signal handler that forces the main */ +/* GUI out of the system tray (if it's been collapsed into the */ +/* tray). Note: Two setup operations are required. Higher-level */ +/* code should set the static GUI structure pointer "MainGUI" ap- */ +/* propriately. Subsequently, higher-level code should install */ +/* "SignalForceVisible" as a signal handler for the signal SIGUSR1. */ + +static GUI *MainGUI = (GUI *) 0; + +void SignalForceVisible (int kludge) +{ + if ((MainGUI != (GUI *) 0) && + (config.enable_systray == TRUE) && + (MainGUI->no_tray == FALSE) && + (MainGUI->calendar_only == FALSE) && + !MainGUI->window_visible) + { + gui_toggle_window_visibility (MainGUI); + } +} + +/* ---------------------------------------------------------------- */ + +/* "SignalForceInvisible" is a signal handler that forces the main */ +/* GUI into the system tray (if it's been raised out of the tray). */ +/* Note: Two setup operations are required. Higher-level code */ +/* should set the static GUI structure pointer "MainGUI" appropri- */ +/* ately. Subsequently, higher-level code should install "Signal- */ +/* ForceInvisible" as a signal handler for the signal SIGUSR2. */ + +void SignalForceInvisible (int kludge) +{ + if ((MainGUI != (GUI *) 0) && + (config.enable_systray == TRUE) && + (MainGUI->no_tray == FALSE) && + (MainGUI->calendar_only == FALSE) && + MainGUI->window_visible) + { + gui_toggle_window_visibility (MainGUI); + } +} + /*------------------------------------------------------------------------------*/ void @@ -1374,6 +1420,13 @@ } #endif /* TASKS_ENABLED */ + /* See notes preceding the "Signal- */ + /* ForceVisible" and "SignalForce- */ + /* Invisible" routines */ + MainGUI = appGUI; + signal (SIGUSR1, SignalForceVisible ); + signal (SIGUSR2, SignalForceInvisible ); + #ifdef CONTACTS_ENABLED appGUI->trayicon_menu_contacts_item = create_menu_item (_("Show contacts"), gtk_image_new_from_icon_name(OSMO_STOCK_SYSTRAY_MENU_CONTACTS, GTK_ICON_SIZE_MENU)); --- osmo.old/src/main.c +++ osmo/src/main.c @@ -84,6 +84,8 @@ #ifdef HAVE_LIBWEBKIT gchar *cmd_stylesheet_file = NULL; #endif /* HAVE_LIBWEBKIT */ +gboolean cmd_minimized = FALSE; + GOptionEntry cmd_options[] = { { "calendar", 'c', 0, G_OPTION_ARG_NONE, &cmd_calendar, N_("Show small calendar window"), NULL }, { "check", 'e', 0, G_OPTION_ARG_NONE, &cmd_check_events, N_("Check for events since last run"), NULL }, @@ -95,6 +97,7 @@ #ifdef HAVE_LIBWEBKIT { "html-stylesheet", 0, 0, G_OPTION_ARG_STRING, &cmd_stylesheet_file, N_("HTML renderer stylesheet file"), "STRING" }, #endif /* HAVE_LIBWEBKIT */ + { "minimized", 'm', 0, G_OPTION_ARG_NONE, &cmd_minimized, N_("Start minimized"), NULL }, { NULL } }; @@ -301,7 +304,9 @@ gtk_window_set_default_icon_name ("osmo"); if (gui_create_window (appGUI) == TRUE) { - gtk_main (); + extern int SignalForceInvisible (int); + if (cmd_minimized) SignalForceInvisible (0); + gtk_main (); } if (appGUI->calendar_only == FALSE) {