aboutsummaryrefslogtreecommitdiffstats
path: root/shell/e-shell.c
diff options
context:
space:
mode:
Diffstat (limited to 'shell/e-shell.c')
-rw-r--r--shell/e-shell.c179
1 files changed, 158 insertions, 21 deletions
diff --git a/shell/e-shell.c b/shell/e-shell.c
index 459ebdc64a..7f291745e3 100644
--- a/shell/e-shell.c
+++ b/shell/e-shell.c
@@ -19,6 +19,12 @@
*
*/
+/**
+ * SECTION: e-shell
+ * @short_description: the backbone of Evolution
+ * @include: shell/e-shell.h
+ **/
+
#include "e-shell.h"
#include <glib/gi18n.h>
@@ -46,7 +52,7 @@ struct _EShellPrivate {
GtkWidget *preferences_window;
/* Shell Backends */
- GList *loaded_backends;
+ GList *loaded_backends; /* not referenced */
GHashTable *backends_by_name;
GHashTable *backends_by_scheme;
@@ -62,11 +68,15 @@ struct _EShellPrivate {
guint quit_cancelled : 1;
guint safe_mode : 1;
guint express_mode : 1;
+ guint meego_mode : 1;
+ guint small_screen_mode : 1;
};
enum {
PROP_0,
PROP_EXPRESS_MODE,
+ PROP_MEEGO_MODE,
+ PROP_SMALL_SCREEN_MODE,
PROP_GEOMETRY,
PROP_MODULE_DIRECTORY,
PROP_NETWORK_AVAILABLE,
@@ -401,23 +411,14 @@ shell_split_and_insert_items (GHashTable *hash_table,
}
static void
-shell_add_backend (GType type,
- EShell *shell)
+shell_process_backend (EShellBackend *shell_backend,
+ EShell *shell)
{
EShellBackendClass *class;
- EShellBackend *shell_backend;
GHashTable *backends_by_name;
GHashTable *backends_by_scheme;
const gchar *string;
- shell_backend = g_object_new (type, "shell", shell, NULL);
-
- shell->priv->loaded_backends = g_list_insert_sorted (
- shell->priv->loaded_backends, shell_backend,
- (GCompareFunc) e_shell_backend_compare);
-
- /* Bookkeeping */
-
class = E_SHELL_BACKEND_GET_CLASS (shell_backend);
backends_by_name = shell->priv->backends_by_name;
backends_by_scheme = shell->priv->backends_by_scheme;
@@ -474,6 +475,18 @@ shell_set_express_mode (EShell *shell,
}
static void
+shell_set_meego_mode (EShell *shell, gboolean is_meego)
+{
+ shell->priv->meego_mode = is_meego;
+}
+
+static void
+shell_set_small_screen_mode (EShell *shell, gboolean small_screen)
+{
+ shell->priv->small_screen_mode = small_screen;
+}
+
+static void
shell_set_geometry (EShell *shell,
const gchar *geometry)
{
@@ -504,6 +517,18 @@ shell_set_property (GObject *object,
g_value_get_boolean (value));
return;
+ case PROP_MEEGO_MODE:
+ shell_set_meego_mode (
+ E_SHELL (object),
+ g_value_get_boolean (value));
+ return;
+
+ case PROP_SMALL_SCREEN_MODE:
+ shell_set_small_screen_mode (
+ E_SHELL (object),
+ g_value_get_boolean (value));
+ return;
+
case PROP_GEOMETRY:
shell_set_geometry (
E_SHELL (object),
@@ -545,6 +570,18 @@ shell_get_property (GObject *object,
E_SHELL (object)));
return;
+ case PROP_MEEGO_MODE:
+ g_value_set_boolean (
+ value, e_shell_get_meego_mode (
+ E_SHELL (object)));
+ return;
+
+ case PROP_SMALL_SCREEN_MODE:
+ g_value_set_boolean (
+ value, e_shell_get_small_screen_mode (
+ E_SHELL (object)));
+ return;
+
case PROP_MODULE_DIRECTORY:
g_value_set_string (
value, e_shell_get_module_directory (
@@ -595,10 +632,6 @@ shell_dispose (GObject *object)
priv->preferences_window = NULL;
}
- g_list_foreach (priv->loaded_backends, (GFunc) g_object_unref, NULL);
- g_list_free (priv->loaded_backends);
- priv->loaded_backends = NULL;
-
if (priv->preparing_for_line_change != NULL) {
g_object_remove_weak_pointer (
G_OBJECT (priv->preparing_for_line_change),
@@ -623,6 +656,8 @@ shell_finalize (GObject *object)
if (!unique_app_is_running (UNIQUE_APP (object)))
e_file_lock_destroy ();
+ g_list_free (priv->loaded_backends);
+
g_free (priv->geometry);
g_free (priv->module_directory);
@@ -634,6 +669,7 @@ static void
shell_constructed (GObject *object)
{
EShellPrivate *priv;
+ GList *list;
priv = E_SHELL_GET_PRIVATE (object);
@@ -653,11 +689,13 @@ shell_constructed (GObject *object)
shell_load_modules (E_SHELL (object));
- e_type_traverse (
- E_TYPE_SHELL_BACKEND, (ETypeFunc)
- shell_add_backend, object);
-
- e_extensible_load_extensions (E_EXTENSIBLE (object));
+ /* Process shell backends. */
+ list = g_list_sort (
+ e_extensible_list_extensions (
+ E_EXTENSIBLE (object), E_TYPE_SHELL_BACKEND),
+ (GCompareFunc) e_shell_backend_compare);
+ g_list_foreach (list, (GFunc) shell_process_backend, object);
+ priv->loaded_backends = list;
}
static UniqueResponse
@@ -791,6 +829,40 @@ e_shell_class_init (EShellClass *class)
G_PARAM_CONSTRUCT_ONLY));
/**
+ * EShell:meego
+ *
+ * Are we running under meego - if so, adapt ourselves
+ * to fit in well with their theming.
+ **/
+ g_object_class_install_property (
+ object_class,
+ PROP_MEEGO_MODE,
+ g_param_spec_boolean (
+ "meego-mode",
+ "Meego Mode",
+ "Whether meego mode is enabled",
+ FALSE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+
+ /**
+ * EShell:small-screen
+ *
+ * Are we running with a small (1024x600) screen - if so, start
+ * throwing the babies overboard to fit onto that screen size.
+ **/
+ g_object_class_install_property (
+ object_class,
+ PROP_SMALL_SCREEN_MODE,
+ g_param_spec_boolean (
+ "small-screen-mode",
+ "Small Screen Mode",
+ "Whether we run on a rather small screen",
+ FALSE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+
+ /**
* EShell:geometry
*
* User-specified initial window geometry string to apply
@@ -1582,6 +1654,38 @@ e_shell_get_express_mode (EShell *shell)
}
/**
+ * e_shell_get_meego_mode:
+ * @shell: an #EShell
+ *
+ * Returns %TRUE if Evolution is in MeeGo mode.
+ *
+ * Returns: %TRUE if Evolution is in MeeGo mode
+ **/
+gboolean
+e_shell_get_meego_mode (EShell *shell)
+{
+ g_return_val_if_fail (E_IS_SHELL (shell), FALSE);
+
+ return shell->priv->meego_mode;
+}
+
+/**
+ * e_shell_get_small_screen_mode:
+ * @shell: an #EShell
+ *
+ * Returns %TRUE if Evolution is in small (netbook) screen mode.
+ *
+ * Returns: %TRUE if Evolution is in small screen mode
+ **/
+gboolean
+e_shell_get_small_screen_mode (EShell *shell)
+{
+ g_return_val_if_fail (E_IS_SHELL (shell), FALSE);
+
+ return shell->priv->small_screen_mode;
+}
+
+/**
* e_shell_get_module_directory:
* @shell: an #EShell
*
@@ -1799,3 +1903,36 @@ e_shell_cancel_quit (EShell *shell)
g_signal_stop_emission (shell, signals[QUIT_REQUESTED], 0);
}
+
+/**
+ * e_shell_adapt_window_size:
+ * @shell: an #EShell
+ * @window: a #GtkWindow to adapt to full-screen
+ *
+ * This is used to adapt to window's size to be optimal for
+ * the platform. The shell settings are used to determine if
+ * a window should be set to full screen etc.
+ *
+ * This method is best called when the widget is realized on
+ * a given screen.
+ **/
+void
+e_shell_adapt_window_size (EShell *shell,
+ GtkWindow *window)
+{
+ gint monitor;
+ GdkScreen *scr;
+ GdkRectangle rect;
+
+ if (!e_shell_get_meego_mode (shell) &&
+ !e_shell_get_small_screen_mode (shell))
+ return;
+
+ scr = gdk_screen_get_default ();
+ monitor = gdk_screen_get_monitor_at_window (scr, GTK_WIDGET (window)->window);
+ gdk_screen_get_monitor_geometry (scr, monitor, &rect);
+
+ gtk_window_set_default_size (window, rect.width, rect.height);
+ gtk_window_set_decorated (window, FALSE);
+ gtk_window_maximize (window);
+}