aboutsummaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2009-11-26 02:35:58 +0800
committerMatthew Barnes <mbarnes@redhat.com>2009-11-26 02:37:13 +0800
commit20efbd7c8bc742d580bc0779b05c1af96787deee (patch)
tree6ffe0f715fd6fa60f33c8e5ff1c7420abff87009 /shell
parent7a086cbcd0592e4c133c5761c65fa291b6d05d04 (diff)
downloadgsoc2013-evolution-20efbd7c8bc742d580bc0779b05c1af96787deee.tar
gsoc2013-evolution-20efbd7c8bc742d580bc0779b05c1af96787deee.tar.gz
gsoc2013-evolution-20efbd7c8bc742d580bc0779b05c1af96787deee.tar.bz2
gsoc2013-evolution-20efbd7c8bc742d580bc0779b05c1af96787deee.tar.lz
gsoc2013-evolution-20efbd7c8bc742d580bc0779b05c1af96787deee.tar.xz
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.
Diffstat (limited to 'shell')
-rw-r--r--shell/e-shell-window-private.c27
-rw-r--r--shell/e-shell-window-private.h2
-rw-r--r--shell/e-shell-window.c39
-rw-r--r--shell/e-shell-window.h3
-rw-r--r--shell/e-shell.c47
-rw-r--r--shell/main.c4
6 files changed, 113 insertions, 9 deletions
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);