diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2009-11-26 02:35:58 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2009-11-26 02:37:13 +0800 |
commit | 20efbd7c8bc742d580bc0779b05c1af96787deee (patch) | |
tree | 6ffe0f715fd6fa60f33c8e5ff1c7420abff87009 | |
parent | 7a086cbcd0592e4c133c5761c65fa291b6d05d04 (diff) | |
download | gsoc2013-evolution-20efbd7c8bc742d580bc0779b05c1af96787deee.tar.gz gsoc2013-evolution-20efbd7c8bc742d580bc0779b05c1af96787deee.tar.zst gsoc2013-evolution-20efbd7c8bc742d580bc0779b05c1af96787deee.zip |
Add a --geometry command-line option.
Applies the user's window geometry string to the first main window.
Suggested in bug #529565.
-rw-r--r-- | doc/reference/shell/tmpl/e-shell-window.sgml | 6 | ||||
-rw-r--r-- | doc/reference/shell/tmpl/e-shell.sgml | 5 | ||||
-rw-r--r-- | doc/reference/shell/tmpl/e-util.sgml | 13 | ||||
-rw-r--r-- | doc/reference/shell/tmpl/eshell-unused.sgml | 12 | ||||
-rw-r--r-- | shell/e-shell-window-private.c | 27 | ||||
-rw-r--r-- | shell/e-shell-window-private.h | 2 | ||||
-rw-r--r-- | shell/e-shell-window.c | 39 | ||||
-rw-r--r-- | shell/e-shell-window.h | 3 | ||||
-rw-r--r-- | shell/e-shell.c | 47 | ||||
-rw-r--r-- | shell/main.c | 4 |
10 files changed, 136 insertions, 22 deletions
diff --git a/doc/reference/shell/tmpl/e-shell-window.sgml b/doc/reference/shell/tmpl/e-shell-window.sgml index 9571632bae..0020ae1eb8 100644 --- a/doc/reference/shell/tmpl/e-shell-window.sgml +++ b/doc/reference/shell/tmpl/e-shell-window.sgml @@ -28,6 +28,11 @@ EShellWindow </para> +<!-- ##### ARG EShellWindow:geometry ##### --> +<para> + +</para> + <!-- ##### ARG EShellWindow:safe-mode ##### --> <para> @@ -50,6 +55,7 @@ EShellWindow @shell: @safe_mode: +@geometry: @Returns: diff --git a/doc/reference/shell/tmpl/e-shell.sgml b/doc/reference/shell/tmpl/e-shell.sgml index 80c68cb11d..c2697cc65a 100644 --- a/doc/reference/shell/tmpl/e-shell.sgml +++ b/doc/reference/shell/tmpl/e-shell.sgml @@ -94,6 +94,11 @@ EShell @eshell: the object which received the signal. +<!-- ##### ARG EShell:geometry ##### --> +<para> + +</para> + <!-- ##### ARG EShell:network-available ##### --> <para> diff --git a/doc/reference/shell/tmpl/e-util.sgml b/doc/reference/shell/tmpl/e-util.sgml index 7f1a282fef..b94e7e8b41 100644 --- a/doc/reference/shell/tmpl/e-util.sgml +++ b/doc/reference/shell/tmpl/e-util.sgml @@ -317,19 +317,6 @@ Miscellaneous Utility Functions @Returns: -<!-- ##### FUNCTION e_util_read_file ##### --> -<para> - -</para> - -@filename: -@filename_is_uri: -@buffer: -@read: -@error: -@Returns: - - <!-- ##### FUNCTION e_util_get_category_filter_options ##### --> <para> diff --git a/doc/reference/shell/tmpl/eshell-unused.sgml b/doc/reference/shell/tmpl/eshell-unused.sgml index 0928b8d717..f8c2fbcec9 100644 --- a/doc/reference/shell/tmpl/eshell-unused.sgml +++ b/doc/reference/shell/tmpl/eshell-unused.sgml @@ -2266,6 +2266,18 @@ intelligent @filename: @Returns: +<!-- ##### FUNCTION e_util_read_file ##### --> +<para> + +</para> + +@filename: +@filename_is_uri: +@buffer: +@read: +@error: +@Returns: + <!-- ##### FUNCTION e_util_uri_to_filename ##### --> <para> diff --git a/shell/e-shell-window-private.c b/shell/e-shell-window-private.c index 4025a934f3..e3d685411f 100644 --- a/shell/e-shell-window-private.c +++ b/shell/e-shell-window-private.c @@ -334,14 +334,17 @@ e_shell_window_private_constructed (EShellWindow *shell_window) GtkAction *action; GtkActionGroup *action_group; GtkUIManager *ui_manager; + GtkWindow *window; GObject *object; const gchar *key; const gchar *id; + window = GTK_WINDOW (shell_window); + shell = e_shell_window_get_shell (shell_window); shell_settings = e_shell_get_shell_settings (shell); - e_shell_watch_window (shell, GTK_WINDOW (shell_window)); + e_shell_watch_window (shell, window); /* Create the switcher actions before we set the initial * shell view, because the shell view relies on them for @@ -408,10 +411,6 @@ e_shell_window_private_constructed (EShellWindow *shell_window) bridge = gconf_bridge_get (); - key = "/apps/evolution/shell/view_defaults/window"; - gconf_bridge_bind_window ( - bridge, key, GTK_WINDOW (shell_window), TRUE, TRUE); - object = G_OBJECT (shell_window); key = "/apps/evolution/shell/view_defaults/component_id"; gconf_bridge_bind_property (bridge, key, object, "active-view"); @@ -436,6 +435,22 @@ e_shell_window_private_constructed (EShellWindow *shell_window) key = "/apps/evolution/shell/view_defaults/toolbar_visible"; gconf_bridge_bind_property (bridge, key, object, "active"); + /* Configure the initial size and position of the window by way + * of either a user-supplied geometry string or the last recorded + * values. Note that if a geometry string is applied, the window + * size and position are -not- recorded. */ + if (priv->geometry != NULL) { + if (!gtk_window_parse_geometry (window, priv->geometry)) + g_printerr ( + "Failed to parse geometry '%s'\n", + priv->geometry); + g_free (priv->geometry); + priv->geometry = NULL; + } else { + key = "/apps/evolution/shell/view_defaults/window"; + gconf_bridge_bind_window (bridge, key, window, TRUE, TRUE); + } + shell_window_init_switcher_style (shell_window); id = "org.gnome.evolution.shell"; @@ -495,6 +510,8 @@ e_shell_window_private_finalize (EShellWindow *shell_window) EShellWindowPrivate *priv = shell_window->priv; g_hash_table_destroy (priv->loaded_views); + + g_free (priv->geometry); } void diff --git a/shell/e-shell-window-private.h b/shell/e-shell-window-private.h index c4f2e195d2..4570aba02f 100644 --- a/shell/e-shell-window-private.h +++ b/shell/e-shell-window-private.h @@ -98,6 +98,8 @@ struct _EShellWindowPrivate { /* Shell signal handlers. */ GArray *signal_handler_ids; + gchar *geometry; + guint destroyed : 1; /* XXX Do we still need this? */ guint safe_mode : 1; }; diff --git a/shell/e-shell-window.c b/shell/e-shell-window.c index a6ac5706e2..737d9dc4a4 100644 --- a/shell/e-shell-window.c +++ b/shell/e-shell-window.c @@ -29,6 +29,7 @@ enum { PROP_0, PROP_ACTIVE_VIEW, + PROP_GEOMETRY, PROP_SAFE_MODE, PROP_SHELL, PROP_UI_MANAGER @@ -142,6 +143,15 @@ shell_window_update_close_action_cb (EShellWindow *shell_window) } static void +shell_window_set_geometry (EShellWindow *shell_window, + const gchar *geometry) +{ + g_return_if_fail (shell_window->priv->geometry == NULL); + + shell_window->priv->geometry = g_strdup (geometry); +} + +static void shell_window_set_shell (EShellWindow *shell_window, EShell *shell) { @@ -189,6 +199,12 @@ shell_window_set_property (GObject *object, g_value_get_string (value)); return; + case PROP_GEOMETRY: + shell_window_set_geometry ( + E_SHELL_WINDOW (object), + g_value_get_string (value)); + return; + case PROP_SAFE_MODE: e_shell_window_set_safe_mode ( E_SHELL_WINDOW (object), @@ -295,6 +311,22 @@ shell_window_class_init (EShellWindowClass *class) G_PARAM_READWRITE)); /** + * EShellWindow:geometry + * + * User-specified initial window geometry string. + **/ + g_object_class_install_property ( + object_class, + PROP_GEOMETRY, + g_param_spec_string ( + "geometry", + _("Geometry"), + _("Initial window geometry string"), + NULL, + G_PARAM_WRITABLE | + G_PARAM_CONSTRUCT_ONLY)); + + /** * EShellWindow:safe-mode * * Whether the shell window is in safe mode. @@ -380,6 +412,7 @@ e_shell_window_get_type (void) * e_shell_window_new: * @shell: an #EShell * @safe_mode: whether to initialize the window to "safe mode" + * @geometry: initial window geometry string, or %NULL * * Returns a new #EShellWindow. * @@ -397,11 +430,13 @@ e_shell_window_get_type (void) **/ GtkWidget * e_shell_window_new (EShell *shell, - gboolean safe_mode) + gboolean safe_mode, + const gchar *geometry) { return g_object_new ( E_TYPE_SHELL_WINDOW, - "shell", shell, "safe-mode", safe_mode, NULL); + "shell", shell, "geometry", geometry, + "safe-mode", safe_mode, NULL); } /** diff --git a/shell/e-shell-window.h b/shell/e-shell-window.h index b867490afb..c9ba9280b0 100644 --- a/shell/e-shell-window.h +++ b/shell/e-shell-window.h @@ -75,7 +75,8 @@ struct _EShellWindowClass { GType e_shell_window_get_type (void); GtkWidget * e_shell_window_new (EShell *shell, - gboolean safe_mode); + gboolean safe_mode, + const gchar *geometry); EShell * e_shell_window_get_shell (EShellWindow *shell_window); struct _EShellView * e_shell_window_get_shell_view (EShellWindow *shell_window, diff --git a/shell/e-shell.c b/shell/e-shell.c index 6224021ff9..1e5fecfe67 100644 --- a/shell/e-shell.c +++ b/shell/e-shell.c @@ -51,6 +51,8 @@ struct _EShellPrivate { gpointer preparing_for_line_change; /* weak pointer */ gpointer preparing_for_quit; /* weak pointer */ + gchar *geometry; + guint auto_reconnect : 1; guint network_available : 1; guint online : 1; @@ -60,6 +62,7 @@ struct _EShellPrivate { enum { PROP_0, + PROP_GEOMETRY, PROP_NETWORK_AVAILABLE, PROP_ONLINE, PROP_SHELL_SETTINGS @@ -459,12 +462,27 @@ shell_sm_quit_cb (EShell *shell, } static void +shell_set_geometry (EShell *shell, + const gchar *geometry) +{ + g_return_if_fail (shell->priv->geometry == NULL); + + shell->priv->geometry = g_strdup (geometry); +} + +static void shell_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { switch (property_id) { + case PROP_GEOMETRY: + shell_set_geometry ( + E_SHELL (object), + g_value_get_string (value)); + return; + case PROP_NETWORK_AVAILABLE: e_shell_set_network_available ( E_SHELL (object), @@ -560,6 +578,8 @@ shell_finalize (GObject *object) if (!unique_app_is_running (UNIQUE_APP (object))) e_file_lock_destroy (); + g_free (priv->geometry); + /* Chain up to parent's finalize() method. */ G_OBJECT_CLASS (parent_class)->finalize (object); } @@ -693,6 +713,23 @@ shell_class_init (EShellClass *class) unique_app_class->message_received = shell_message_received; /** + * EShell:geometry + * + * User-specified initial window geometry string to apply + * to the first #EShellWindow created. + **/ + g_object_class_install_property ( + object_class, + PROP_GEOMETRY, + g_param_spec_string ( + "geometry", + _("Geometry"), + _("Initial window geometry string"), + NULL, + G_PARAM_WRITABLE | + G_PARAM_CONSTRUCT_ONLY)); + + /** * EShell:network-available * * Whether the network is available. @@ -1221,7 +1258,15 @@ e_shell_create_shell_window (EShell *shell, } } - shell_window = e_shell_window_new (shell, shell->priv->safe_mode); + shell_window = e_shell_window_new ( + shell, + shell->priv->safe_mode, + shell->priv->geometry); + + /* Clear the first-time-only options. */ + shell->priv->safe_mode = FALSE; + g_free (shell->priv->geometry); + shell->priv->geometry = NULL; gtk_widget_show (shell_window); diff --git a/shell/main.c b/shell/main.c index ab82c2eded..e96620ab24 100644 --- a/shell/main.c +++ b/shell/main.c @@ -89,6 +89,7 @@ static gboolean disable_preview = FALSE; static gboolean import_uris = FALSE; static gboolean idle_cb (gchar **uris); +static gchar *geometry = NULL; static gchar *requested_view = NULL; static gchar *evolution_debug_log = NULL; static gchar **remaining_args; @@ -309,6 +310,8 @@ setup_segv_redirect (void) static GOptionEntry entries[] = { { "component", 'c', 0, G_OPTION_ARG_STRING, &requested_view, N_("Start Evolution activating the specified component"), NULL }, + { "geometry", 'g', 0, G_OPTION_ARG_STRING, &geometry, + N_("Apply the given geometry to the main window"), "GEOMETRY" }, { "offline", '\0', 0, G_OPTION_ARG_NONE, &start_offline, N_("Start in offline mode"), NULL }, { "online", '\0', 0, G_OPTION_ARG_NONE, &start_online, @@ -451,6 +454,7 @@ create_default_shell (void) shell = g_object_new ( E_TYPE_SHELL, "name", "org.gnome.Evolution", + "geometry", geometry, "online", online, NULL); |