aboutsummaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
Diffstat (limited to 'shell')
-rw-r--r--shell/Makefile.am2
-rw-r--r--shell/e-shell-settings.c201
-rw-r--r--shell/e-shell-settings.h82
-rw-r--r--shell/e-shell-view.c43
-rw-r--r--shell/e-shell-view.h4
-rw-r--r--shell/e-shell.c34
-rw-r--r--shell/e-shell.h2
7 files changed, 367 insertions, 1 deletions
diff --git a/shell/Makefile.am b/shell/Makefile.am
index 7b54607d10..79ed87c880 100644
--- a/shell/Makefile.am
+++ b/shell/Makefile.am
@@ -62,6 +62,7 @@ eshellinclude_HEADERS = \
e-shell-common.h \
e-shell-content.h \
e-shell-module.h \
+ e-shell-settings.h \
e-shell-sidebar.h \
e-shell-switcher.h \
e-shell-taskbar.h \
@@ -74,6 +75,7 @@ libeshell_la_SOURCES = \
$(IDL_GENERATED) \
e-shell-content.c \
e-shell-module.c \
+ e-shell-settings.c \
e-shell-sidebar.c \
e-shell-switcher.c \
e-shell-taskbar.c \
diff --git a/shell/e-shell-settings.c b/shell/e-shell-settings.c
new file mode 100644
index 0000000000..d0c678baa9
--- /dev/null
+++ b/shell/e-shell-settings.c
@@ -0,0 +1,201 @@
+/*
+ * e-shell-settings.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#include "e-shell-settings.h"
+
+#include "e-util/gconf-bridge.h"
+
+#define E_SHELL_SETTINGS_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_SHELL_SETTINGS, EShellSettingsPrivate))
+
+struct _EShellSettingsPrivate {
+ GArray *value_array;
+};
+
+static GList *instances;
+static guint property_count;
+static gpointer parent_class;
+
+static void
+shell_settings_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ EShellSettingsPrivate *priv;
+ GValue *dest_value;
+
+ priv = E_SHELL_SETTINGS_GET_PRIVATE (object);
+
+ dest_value = &g_array_index (
+ priv->value_array, GValue, property_id - 1);
+
+ g_value_copy (value, dest_value);
+ g_object_notify (object, pspec->name);
+}
+
+static void
+shell_settings_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ EShellSettingsPrivate *priv;
+ GValue *src_value;
+
+ priv = E_SHELL_SETTINGS_GET_PRIVATE (object);
+
+ src_value = &g_array_index (
+ priv->value_array, GValue, property_id - 1);
+
+ g_value_copy (src_value, value);
+}
+
+static void
+shell_settings_finalize (GObject *object)
+{
+ EShellSettingsPrivate *priv;
+ guint ii;
+
+ priv = E_SHELL_SETTINGS_GET_PRIVATE (object);
+
+ for (ii = 0; ii < priv->value_array->len; ii++)
+ g_value_unset (&g_array_index (priv->value_array, GValue, ii));
+
+ g_array_free (priv->value_array, TRUE);
+
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static void
+shell_settings_class_init (EShellSettingsClass *class)
+{
+ GObjectClass *object_class;
+
+ parent_class = g_type_class_peek_parent (class);
+ g_type_class_add_private (class, sizeof (EShellSettingsPrivate));
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->set_property = shell_settings_set_property;
+ object_class->get_property = shell_settings_get_property;
+ object_class->finalize = shell_settings_finalize;
+}
+
+static void
+shell_settings_init (EShellSettings *shell_settings,
+ GObjectClass *object_class)
+{
+ GArray *value_array;
+
+ instances = g_list_prepend (instances, shell_settings);
+
+ value_array = g_array_new (FALSE, TRUE, sizeof (GValue));
+ g_array_set_size (value_array, property_count);
+
+ shell_settings->priv = E_SHELL_SETTINGS_GET_PRIVATE (shell_settings);
+ shell_settings->priv->value_array = value_array;
+}
+
+GType
+e_shell_settings_get_type (void)
+{
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0)) {
+ const GTypeInfo type_info = {
+ sizeof (EShellSettingsClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) shell_settings_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL, /* class_data */
+ sizeof (EShellSettings),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) shell_settings_init,
+ NULL /* value_table */
+ };
+
+ type = g_type_register_static (
+ G_TYPE_OBJECT, "EShellSettings", &type_info, 0);
+ }
+
+ return type;
+}
+
+void
+e_shell_settings_install_property (GParamSpec *pspec)
+{
+ static GObjectClass *class = NULL;
+ GList *iter, *next;
+
+ g_return_if_fail (G_IS_PARAM_SPEC (pspec));
+
+ if (G_UNLIKELY (class == NULL))
+ class = g_type_class_ref (E_TYPE_SHELL_SETTINGS);
+
+ if (g_object_class_find_property (class, pspec->name) != NULL) {
+ g_warning (
+ "Settings property \"%s\" already exists",
+ pspec->name);
+ return;
+ }
+
+ for (iter = instances; iter != NULL; iter = iter->next)
+ g_object_freeze_notify (iter->data);
+
+ g_object_class_install_property (class, ++property_count, pspec);
+
+ for (iter = instances; iter != NULL; iter = iter->next) {
+ EShellSettings *shell_settings = iter->data;
+ GArray *value_array;
+ GValue *value;
+
+ value_array = shell_settings->priv->value_array;
+ g_array_set_size (value_array, property_count);
+
+ value = &g_array_index (
+ value_array, GValue, property_count - 1);
+ g_value_init (value, G_PARAM_SPEC_VALUE_TYPE (pspec));
+ g_param_value_set_default (pspec, value);
+ g_object_notify (G_OBJECT (shell_settings), pspec->name);
+ }
+
+ for (iter = instances; iter != NULL; iter = next) {
+ next = iter->next;
+ g_object_thaw_notify (iter->data);
+ }
+}
+
+void
+e_shell_settings_bind_to_gconf (EShellSettings *shell_settings,
+ const gchar *property_name,
+ const gchar *gconf_key)
+{
+ g_return_if_fail (E_IS_SHELL_SETTINGS (shell_settings));
+ g_return_if_fail (property_name != NULL);
+ g_return_if_fail (gconf_key != NULL);
+
+ gconf_bridge_bind_property (
+ gconf_bridge_get (), gconf_key,
+ G_OBJECT (shell_settings), property_name);
+}
diff --git a/shell/e-shell-settings.h b/shell/e-shell-settings.h
new file mode 100644
index 0000000000..b01d7fe327
--- /dev/null
+++ b/shell/e-shell-settings.h
@@ -0,0 +1,82 @@
+/*
+ * e-shell-settings.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+/**
+ * SECTION: e-shell-settings
+ * @short_description: settings management
+ * @include: shell/e-shell-settings.h
+ **/
+
+#ifndef E_SHELL_SETTINGS_H
+#define E_SHELL_SETTINGS_H
+
+#include <shell/e-shell-common.h>
+
+/* Standard GObject macros */
+#define E_TYPE_SHELL_SETTINGS \
+ (e_shell_settings_get_type ())
+#define E_SHELL_SETTINGS(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_SHELL_SETTINGS, EShellSettings))
+#define E_SHELL_SETTINGS_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_SHELL_SETTINGS, EShellSettingsClass))
+#define E_IS_SHELL_SETTINGS(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_SHELL_SETTINGS))
+#define E_IS_SHELL_SETTINGS_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_SHELL_SETTINGS))
+#define E_SHELL_SETTINGS_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_SHELL_SETTINGS, EShellSettingsClass))
+
+G_BEGIN_DECLS
+
+typedef struct _EShellSettings EShellSettings;
+typedef struct _EShellSettingsClass EShellSettingsClass;
+typedef struct _EShellSettingsPrivate EShellSettingsPrivate;
+
+/**
+ * EShellSettings:
+ *
+ * Contains only private data that should be read and manipulated using the
+ * functions below.
+ **/
+struct _EShellSettings {
+ GObject parent;
+ EShellSettingsPrivate *priv;
+};
+
+struct _EShellSettingsClass {
+ GObjectClass parent_class;
+};
+
+GType e_shell_settings_get_type (void);
+void e_shell_settings_install_property
+ (GParamSpec *pspec);
+void e_shell_settings_bind_to_gconf (EShellSettings *shell_settings,
+ const gchar *property_name,
+ const gchar *gconf_key);
+
+G_END_DECLS
+
+#endif /* E_SHELL_SETTINGS_H */
diff --git a/shell/e-shell-view.c b/shell/e-shell-view.c
index 3ab67b6ab0..9c5ff2b8bb 100644
--- a/shell/e-shell-view.c
+++ b/shell/e-shell-view.c
@@ -111,6 +111,17 @@ shell_view_init_view_collection (EShellViewClass *shell_view_class)
}
static void
+shell_view_update_view_id (EShellView *shell_view,
+ GalViewInstance *view_instance)
+{
+ gchar *view_id;
+
+ view_id = gal_view_instance_get_current_view_id (view_instance);
+ e_shell_view_set_view_id (shell_view, view_id);
+ g_free (view_id);
+}
+
+static void
shell_view_emit_toggled (EShellView *shell_view)
{
g_signal_emit (shell_view, signals[TOGGLED], 0);
@@ -967,3 +978,35 @@ e_shell_view_show_popup_menu (EShellView *shell_view,
GTK_MENU (menu), NULL, NULL, NULL, NULL,
0, gtk_get_current_event_time ());
}
+
+/**
+ * e_shell_view_new_view_instance:
+ * @shell_view: an #EShellView
+ * @instance_id: a name for the #GalViewInstance
+ *
+ * Creates a new #GalViewInstance and configures it to keep
+ * @shell_view<!-- -->'s #EShellView:view-id property up-to-date.
+ *
+ * Returns: a new #GalViewInstance
+ **/
+GalViewInstance *
+e_shell_view_new_view_instance (EShellView *shell_view,
+ const gchar *instance_id)
+{
+ EShellViewClass *shell_view_class;
+ GalViewCollection *view_collection;
+ GalViewInstance *view_instance;
+
+ g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
+
+ shell_view_class = E_SHELL_VIEW_GET_CLASS (shell_view);
+
+ view_collection = shell_view_class->view_collection;
+ view_instance = gal_view_instance_new (view_collection, instance_id);
+
+ g_signal_connect_swapped (
+ view_instance, "changed",
+ G_CALLBACK (shell_view_update_view_id), shell_view);
+
+ return view_instance;
+}
diff --git a/shell/e-shell-view.h b/shell/e-shell-view.h
index 1b1fffd87d..3159b5a71b 100644
--- a/shell/e-shell-view.h
+++ b/shell/e-shell-view.h
@@ -36,6 +36,7 @@
#include <shell/e-shell-window.h>
#include <widgets/menus/gal-view-collection.h>
+#include <widgets/menus/gal-view-instance.h>
/* Standard GObject macros */
#define E_TYPE_SHELL_VIEW \
@@ -174,6 +175,9 @@ void e_shell_view_update_actions (EShellView *shell_view);
void e_shell_view_show_popup_menu (EShellView *shell_view,
const gchar *widget_path,
GdkEventButton *event);
+GalViewInstance *
+ e_shell_view_new_view_instance (EShellView *shell_view,
+ const gchar *instance_id);
G_END_DECLS
diff --git a/shell/e-shell.c b/shell/e-shell.c
index d6884b0a69..1840571767 100644
--- a/shell/e-shell.c
+++ b/shell/e-shell.c
@@ -37,6 +37,7 @@
struct _EShellPrivate {
GList *active_windows;
+ EShellSettings *settings;
EShellLineStatus line_status;
/* Shell Modules */
@@ -50,7 +51,8 @@ struct _EShellPrivate {
enum {
PROP_0,
- PROP_ONLINE_MODE
+ PROP_ONLINE_MODE,
+ PROP_SETTINGS
};
enum {
@@ -261,6 +263,12 @@ shell_get_property (GObject *object,
value, e_shell_get_online_mode (
E_SHELL (object)));
return;
+
+ case PROP_SETTINGS:
+ g_value_set_object (
+ value, e_shell_get_settings (
+ E_SHELL (object)));
+ return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -273,6 +281,11 @@ shell_dispose (GObject *object)
priv = E_SHELL_GET_PRIVATE (object);
+ if (priv->settings != NULL) {
+ g_object_unref (priv->settings);
+ priv->settings = NULL;
+ }
+
g_list_foreach (
priv->loaded_modules,
(GFunc) g_type_module_unuse, NULL);
@@ -358,6 +371,16 @@ shell_class_init (EShellClass *class)
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
+ g_object_class_install_property (
+ object_class,
+ PROP_SETTINGS,
+ g_param_spec_object (
+ "settings",
+ _("Settings"),
+ _("Application settings"),
+ E_TYPE_SHELL_SETTINGS,
+ G_PARAM_READABLE));
+
signals[EVENT] = g_signal_new (
"event",
G_OBJECT_CLASS_TYPE (object_class),
@@ -415,6 +438,7 @@ shell_init (EShell *shell)
modules_by_name = g_hash_table_new (g_str_hash, g_str_equal);
modules_by_scheme = g_hash_table_new (g_str_hash, g_str_equal);
+ shell->priv->settings = g_object_new (E_TYPE_SHELL_SETTINGS, NULL);
shell->priv->modules_by_name = modules_by_name;
shell->priv->modules_by_scheme = modules_by_scheme;
shell->priv->safe_mode = e_file_lock_exists ();
@@ -517,6 +541,14 @@ e_shell_get_module_by_scheme (EShell *shell,
return g_hash_table_lookup (hash_table, scheme);
}
+EShellSettings *
+e_shell_get_settings (EShell *shell)
+{
+ g_return_val_if_fail (E_IS_SHELL (shell), NULL);
+
+ return shell->priv->settings;
+}
+
GtkWidget *
e_shell_create_window (EShell *shell)
{
diff --git a/shell/e-shell.h b/shell/e-shell.h
index 2c942097c5..79ff9c1783 100644
--- a/shell/e-shell.h
+++ b/shell/e-shell.h
@@ -30,6 +30,7 @@
#include <shell/e-shell-common.h>
#include <shell/e-shell-module.h>
+#include <shell/e-shell-settings.h>
/* Standard GObject macros */
#define E_TYPE_SHELL \
@@ -89,6 +90,7 @@ EShellModule * e_shell_get_module_by_name (EShell *shell,
const gchar *name);
EShellModule * e_shell_get_module_by_scheme (EShell *shell,
const gchar *scheme);
+EShellSettings *e_shell_get_settings (EShell *shell);
GtkWidget * e_shell_create_window (EShell *shell);
GtkWidget * e_shell_get_focused_window (EShell *shell);
gboolean e_shell_handle_uri (EShell *shell,