diff options
author | Sandeep V Honde <sandeep.honde@wipro.com> | 2002-03-19 12:24:55 +0000 |
---|---|---|
committer | Mikael Hallendal <hallski@src.gnome.org> | 2002-03-19 12:24:55 +0000 |
commit | a4e4cb5269eaea139da8c4a3c664bb0ae95a9af0 (patch) | |
tree | a5216469de8e025fd401a8cd104dbd5dbddfb6a4 | |
parent | 40fc8c81e7fd35373044cd32bb9beb9bc09f8f84 (diff) | |
download | yelp-a4e4cb5269eaea139da8c4a3c664bb0ae95a9af0.tar.gz |
- Session management support for multiple windows added.
2002-03-08 Sandeep V Honde <sandeep.honde@wipro.com>
* src/yelp-main.c:
- Session management support for multiple
windows added.
(yelp_save_session) :modified.
(yelp_restore_session) :added/impl.
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | src/yelp-main.c | 106 |
2 files changed, 107 insertions, 7 deletions
@@ -1,3 +1,11 @@ +2002-03-08 Sandeep V Honde <sandeep.honde@wipro.com> + + * src/yelp-main.c: + - Session management support for multiple + windows added. + (yelp_save_session) :modified. + (yelp_restore_session) :added/impl. + 2002-03-04 Mikael Hallendal <micke@codefactory.se> * configure.in: bumped version to 0.3.99 diff --git a/src/yelp-main.c b/src/yelp-main.c index a1467355..b2e58854 100644 --- a/src/yelp-main.c +++ b/src/yelp-main.c @@ -43,6 +43,22 @@ #define YELP_FACTORY_OAFIID "OAFIID:GNOME_Yelp_Factory" +poptContext poptCon; +gint next_opt; + +/*structure defining command line option.*/ + +struct poptOption options[] = { + { + "url", + 'u', + POPT_ARG_STRING, + NULL, + 1, + NULL, + NULL, + }}; + static BonoboObject * yelp_base_factory (BonoboGenericFactory *factory, const gchar *iid, gpointer closure); @@ -59,6 +75,8 @@ static int yelp_save_session (GnomeClient *client, static gint yelp_client_die (GnomeClient *client, gpointer cdata); +static gboolean yelp_restore_session (void); + static BonoboObject * yelp_base_factory (BonoboGenericFactory *factory, @@ -163,20 +181,75 @@ yelp_save_session (GnomeClient *client, gint fast, gpointer cdata) { + + GNOME_Yelp_WindowList *list; + CORBA_Environment ev; + CORBA_Object yelp_base; + gchar **argv; + gint i=1; + gint temp; + + CORBA_exception_init (&ev); - gchar *argv[]= { NULL }; + yelp_base = yelp_main_activate_base (); + + list = GNOME_Yelp_getWindows (yelp_base, &ev); + + bonobo_object_release_unref (yelp_base, NULL); - argv[0] = (gchar*) cdata; - gnome_client_set_clone_command (client, 1, argv); - gnome_client_set_restart_command (client, 1, argv); - return TRUE; + temp = list->_length; + + temp = temp + 1; + + argv = g_malloc0 (sizeof (gchar *) * temp); + + argv[0] = (gchar*) cdata; + + /* Get the URI of each window */ + + for (i=0 ;i < list->_length; i++) { + argv[i+1] = g_strconcat ("--url=", list->_buffer[i], NULL); + } + + gnome_client_set_clone_command (client, temp, argv); + gnome_client_set_restart_command (client, temp, argv); + + g_free (argv); + + return TRUE; } static gint yelp_client_die (GnomeClient *client, gpointer cdata) { - exit (0); + bonobo_main_quit (); +} + +static gboolean +yelp_restore_session (void) +{ + CORBA_Object yelp_base; + + yelp_base = yelp_main_activate_base (); + + if (!yelp_base) { + g_error ("Couldn't activate YelpBase"); + } + + /*Get the argument of commandline option*/ + + while( (next_opt = poptGetNextOpt (poptCon)) > 0) { + if ( next_opt == 1) { + gchar *url = (gchar *) poptGetOptArg (poptCon); + yelp_main_open_new_window (yelp_base, url); + if (url) { + g_free (url); + } + } + } + + return TRUE; } int @@ -186,6 +259,7 @@ main (int argc, char **argv) CORBA_Object factory; gchar *url = NULL; GnomeClient *client; + gboolean flag = FALSE; bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); @@ -205,6 +279,10 @@ main (int argc, char **argv) NULL); gnome_vfs_init (); + + /*Commandline parsing is done here*/ + + poptCon = poptGetContext (PACKAGE, argc, (const gchar **) argv, options, 0); client = gnome_master_client (); g_signal_connect (client, "save_yourself", @@ -216,6 +294,12 @@ main (int argc, char **argv) Bonobo_ACTIVATION_FLAG_EXISTING_ONLY, NULL, NULL); + /*Check for previous session to restore.*/ + + if(gnome_client_get_flags (client) & GNOME_CLIENT_RESTORED) { + flag = TRUE; + } + if (!factory) { BonoboGenericFactory *factory; /* Not started, start now */ @@ -225,7 +309,15 @@ main (int argc, char **argv) NULL); bonobo_running_context_auto_exit_unref (BONOBO_OBJECT (factory)); - g_idle_add ((GSourceFunc) yelp_main_idle_start, url); + + /*Depending on the flag, restore the session*/ + + if (flag) { + g_idle_add ((GSourceFunc) yelp_restore_session, NULL); + } else { + g_idle_add ((GSourceFunc) yelp_main_idle_start, url); + } + bonobo_main (); } else { yelp_main_start (url); |