aboutsummaryrefslogtreecommitdiffstats
path: root/shell/e-shell-view.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@src.gnome.org>2008-07-17 03:37:02 +0800
committerMatthew Barnes <mbarnes@src.gnome.org>2008-07-17 03:37:02 +0800
commit03a3e6f84638c62c7848eee4d6f71cc4b1a7c1b8 (patch)
tree39d9a26ea8438f161ca413b197cf62a070b21385 /shell/e-shell-view.c
parentac0c655f3f2a8e47b0cca877aabae66421c58187 (diff)
downloadgsoc2013-evolution-03a3e6f84638c62c7848eee4d6f71cc4b1a7c1b8.tar.gz
gsoc2013-evolution-03a3e6f84638c62c7848eee4d6f71cc4b1a7c1b8.tar.zst
gsoc2013-evolution-03a3e6f84638c62c7848eee4d6f71cc4b1a7c1b8.zip
Disable all components and plugins. Begin rewriting the shell.
svn path=/branches/kill-bonobo/; revision=35748
Diffstat (limited to 'shell/e-shell-view.c')
-rw-r--r--shell/e-shell-view.c262
1 files changed, 191 insertions, 71 deletions
diff --git a/shell/e-shell-view.c b/shell/e-shell-view.c
index ebcc9c03fe..ef921a2ebf 100644
--- a/shell/e-shell-view.c
+++ b/shell/e-shell-view.c
@@ -3,8 +3,6 @@
*
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
*
- * Author(s): Michael Zucchi <notzed@ximian.com>
- *
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public
* License as published by the Free Software Foundation.
@@ -18,130 +16,252 @@
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
- *
- * Helper class for evolution shells to setup a view
*/
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "e-shell-view.h"
-#include <gtk/gtk.h>
#include <glib/gi18n.h>
-#include "e-shell-view.h"
#include "e-shell-window.h"
-#include "e-util/e-icon-factory.h"
-static BonoboObjectClass *parent_class = NULL;
+#define E_SHELL_VIEW_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_SHELL_VIEW, EShellViewPrivate))
struct _EShellViewPrivate {
- int dummy;
+ gchar *title;
+ gpointer window; /* weak pointer */
+};
+
+enum {
+ PROP_0,
+ PROP_TITLE,
+ PROP_WINDOW
};
+static gpointer parent_class;
+
static void
-impl_ShellView_setTitle(PortableServer_Servant _servant, const CORBA_char *id, const CORBA_char * title, CORBA_Environment * ev)
+shell_view_set_window (EShellView *shell_view,
+ GtkWindow *window)
{
- EShellView *esw = (EShellView *)bonobo_object_from_servant(_servant);
- /* To translators: This is the window title and %s is the
- component name. Most translators will want to keep it as is. */
- char *tmp = g_strdup_printf(_("%s - Evolution"), title);
+ g_return_if_fail (GTK_IS_WINDOW (window));
+
+ shell_view->priv->window = window;
- e_shell_window_set_title(esw->window, id, tmp);
- g_free(tmp);
+ g_object_add_weak_pointer (
+ G_OBJECT (window), &shell_view->priv->window);
}
static void
-impl_ShellView_setComponent(PortableServer_Servant _servant, const CORBA_char *id, CORBA_Environment * ev)
+shell_view_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- EShellView *esw = (EShellView *)bonobo_object_from_servant(_servant);
-
- e_shell_window_switch_to_component(esw->window, id);
+ switch (property_id) {
+ case PROP_TITLE:
+ e_shell_view_set_title (
+ E_SHELL_VIEW (object),
+ g_value_get_string (value));
+ return;
+
+ case PROP_WINDOW:
+ shell_view_set_window (
+ E_SHELL_VIEW (object),
+ g_value_get_object (value));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
-struct change_icon_struct {
- const char *component_name;
- GdkPixbuf *icon;
-};
+static void
+shell_view_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_TITLE:
+ g_value_set_string (
+ value, e_shell_view_get_title (
+ E_SHELL_VIEW (object)));
+ return;
+
+ case PROP_WINDOW:
+ g_value_set_object (
+ value, e_shell_view_get_window (
+ E_SHELL_VIEW (object)));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
-static gboolean
-change_button_icon_func (EShell *shell, EShellWindow *window, gpointer user_data)
+static void
+shell_view_dispose (GObject *object)
{
- struct change_icon_struct *cis = (struct change_icon_struct*)user_data;
+ EShellViewPrivate *priv;
- g_return_val_if_fail (window != NULL, FALSE);
- g_return_val_if_fail (cis != NULL, FALSE);
+ priv = E_SHELL_VIEW_GET_PRIVATE (object);
- e_shell_window_change_component_button_icon (window, cis->component_name, cis->icon);
+ if (priv->window != NULL) {
+ g_object_remove_weak_pointer (
+ G_OBJECT (priv->window), &priv->window);
+ priv->window = NULL;
+ }
- return TRUE;
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (parent_class)->dispose (object);
}
static void
-impl_ShellView_setButtonIcon (PortableServer_Servant _servant, const CORBA_char *id, const CORBA_char * iconName, CORBA_Environment * ev)
+shell_view_finalize (GObject *object)
{
- EShellView *esw = (EShellView *)bonobo_object_from_servant(_servant);
- EShell *shell = e_shell_window_peek_shell (esw->window);
-
- struct change_icon_struct cis;
- cis.component_name = id;
- cis.icon = NULL;
+ EShellViewPrivate *priv;
- if (iconName)
- cis.icon = e_icon_factory_get_icon (iconName, E_ICON_SIZE_BUTTON);
+ priv = E_SHELL_VIEW_GET_PRIVATE (object);
- e_shell_foreach_shell_window (shell, change_button_icon_func, &cis);
+ g_free (priv->title);
- if (cis.icon)
- g_object_unref (cis.icon);
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
-impl_dispose (GObject *object)
+shell_view_class_init (EShellViewClass *class)
{
- /*EShellView *esv = (EShellView *)object;*/
+ GObjectClass *object_class;
- ((GObjectClass *)parent_class)->dispose(object);
+ parent_class = g_type_class_peek_parent (class);
+ g_type_class_add_private (class, sizeof (EShellViewPrivate));
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->set_property = shell_view_set_property;
+ object_class->get_property = shell_view_get_property;
+ object_class->dispose = shell_view_dispose;
+ object_class->finalize = shell_view_finalize;
+
+ g_object_class_install_property (
+ object_class,
+ PROP_TITLE,
+ g_param_spec_string (
+ "title",
+ _("Title"),
+ _("The title of the shell view"),
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_WINDOW,
+ g_param_spec_object (
+ "window",
+ _("Window"),
+ _("The window to which the shell view belongs"),
+ GTK_TYPE_WINDOW,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
}
static void
-impl_finalise (GObject *object)
+shell_view_init (EShellView *shell_view)
{
- ((GObjectClass *)parent_class)->finalize(object);
+ shell_view->priv = E_SHELL_VIEW_GET_PRIVATE (shell_view);
}
-static void
-e_shell_view_class_init (EShellViewClass *klass)
+GType
+e_shell_view_get_type (void)
{
- GObjectClass *object_class;
- POA_GNOME_Evolution_ShellView__epv *epv;
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0)) {
+ const GTypeInfo type_info = {
+ sizeof (EShellViewClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) shell_view_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL, /* class_data */
+ sizeof (EShellView),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) shell_view_init,
+ NULL /* value_table */
+ };
+
+ type = g_type_register_static (
+ G_TYPE_OBJECT, "EShellView",
+ &type_info, G_TYPE_FLAG_ABSTRACT);
+ }
+
+ return type;
+}
- parent_class = g_type_class_ref(bonobo_object_get_type());
+const gchar *
+e_shell_view_get_title (EShellView *shell_view)
+{
+ g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
+
+ return shell_view->priv->title;
+}
+
+void
+e_shell_view_set_title (EShellView *shell_view,
+ const gchar *title)
+{
+ g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
- object_class = G_OBJECT_CLASS (klass);
- object_class->dispose = impl_dispose;
- object_class->finalize = impl_finalise;
+ g_free (shell_view->priv->title);
+ shell_view->priv->title = g_strdup (title);
- epv = & klass->epv;
- epv->setTitle = impl_ShellView_setTitle;
- epv->setComponent = impl_ShellView_setComponent;
- epv->setButtonIcon = impl_ShellView_setButtonIcon;
+ g_object_notify (G_OBJECT (shell_view), "title");
}
-static void
-e_shell_view_init (EShellView *shell)
+GtkWindow *
+e_shell_view_get_window (EShellView *shell_view)
+{
+ g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
+
+ return shell_view->priv->window;
+}
+
+GtkWidget *
+e_shell_view_get_content_widget (EShellView *shell_view)
{
+ EShellViewClass *class;
+
+ g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
+
+ class = E_SHELL_VIEW_CLASS (shell_view);
+ g_return_val_if_fail (class->get_content_widget != NULL, NULL);
+
+ return class->get_content_widget (shell_view);
}
-EShellView *e_shell_view_new(struct _EShellWindow *window)
+GtkWidget *
+e_shell_view_get_sidebar_widget (EShellView *shell_view)
{
- EShellView *new = g_object_new (e_shell_view_get_type (), NULL);
+ EShellViewClass *class;
+
+ g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
- /* TODO: listen to destroy? */
- new->window = window;
+ class = E_SHELL_VIEW_CLASS (shell_view);
+ g_return_val_if_fail (class->get_sidebar_widget != NULL, NULL);
- return new;
+ return class->get_sidebar_widget (shell_view);
}
-BONOBO_TYPE_FUNC_FULL (EShellView, GNOME_Evolution_ShellView, bonobo_object_get_type(), e_shell_view)
+GtkWidget *
+e_shell_view_get_status_widget (EShellView *shell_view)
+{
+ EShellViewClass *class;
+
+ g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
+ class = E_SHELL_VIEW_CLASS (shell_view);
+ g_return_val_if_fail (class->get_status_widget != NULL, NULL);
+
+ return class->get_status_widget (shell_view);
+}