aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@src.gnome.org>2008-08-27 09:54:22 +0800
committerMatthew Barnes <mbarnes@src.gnome.org>2008-08-27 09:54:22 +0800
commit244ab98402af2d384fe63c46fd15541f1c9f79bf (patch)
tree5fcc178bc3f0fa7d147cd0a82604c8e0a9ced7de
parentcf3b01017162cbba568ee4317eee2efe5f6fdc10 (diff)
downloadgsoc2013-evolution-244ab98402af2d384fe63c46fd15541f1c9f79bf.tar.gz
gsoc2013-evolution-244ab98402af2d384fe63c46fd15541f1c9f79bf.tar.zst
gsoc2013-evolution-244ab98402af2d384fe63c46fd15541f1c9f79bf.zip
Progress update:
- Get the test module to demonstrate populating the shell window (particularly, the various notebooks) with some stupid widgets. svn path=/branches/kill-bonobo/; revision=36094
-rw-r--r--shell/e-shell-view.c48
-rw-r--r--shell/e-shell-view.h1
-rw-r--r--shell/e-shell-window.c78
-rw-r--r--shell/test/e-test-shell-view.c90
4 files changed, 198 insertions, 19 deletions
diff --git a/shell/e-shell-view.c b/shell/e-shell-view.c
index 5da8af55ff..af2e9eeb0a 100644
--- a/shell/e-shell-view.c
+++ b/shell/e-shell-view.c
@@ -32,11 +32,13 @@
struct _EShellViewPrivate {
gchar *title;
+ gint page_num;
gpointer window; /* weak pointer */
};
enum {
PROP_0,
+ PROP_PAGE_NUM,
PROP_TITLE,
PROP_WINDOW
};
@@ -44,6 +46,13 @@ enum {
static gpointer parent_class;
static void
+shell_view_set_page_num (EShellView *shell_view,
+ gint page_num)
+{
+ shell_view->priv->page_num = page_num;
+}
+
+static void
shell_view_set_window (EShellView *shell_view,
GtkWidget *window)
{
@@ -62,6 +71,12 @@ shell_view_set_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
+ case PROP_PAGE_NUM:
+ shell_view_set_page_num (
+ E_SHELL_VIEW (object),
+ g_value_get_int (value));
+ return;
+
case PROP_TITLE:
e_shell_view_set_title (
E_SHELL_VIEW (object),
@@ -85,6 +100,12 @@ shell_view_get_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
+ case PROP_PAGE_NUM:
+ g_value_set_int (
+ value, e_shell_view_get_page_num (
+ E_SHELL_VIEW (object)));
+ return;
+
case PROP_TITLE:
g_value_set_string (
value, e_shell_view_get_title (
@@ -147,6 +168,19 @@ shell_view_class_init (EShellViewClass *class)
g_object_class_install_property (
object_class,
+ PROP_PAGE_NUM,
+ g_param_spec_int (
+ "page-num",
+ _("Page Number"),
+ _("The notebook page number of the shell view"),
+ -1,
+ G_MAXINT,
+ -1,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property (
+ object_class,
PROP_TITLE,
g_param_spec_string (
"title",
@@ -265,6 +299,14 @@ e_shell_view_is_selected (EShellView *shell_view)
return (strcmp (curr_view_name, this_view_name) == 0);
}
+gint
+e_shell_view_get_page_num (EShellView *shell_view)
+{
+ g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), -1);
+
+ return shell_view->priv->page_num;
+}
+
GtkWidget *
e_shell_view_get_content_widget (EShellView *shell_view)
{
@@ -272,7 +314,7 @@ e_shell_view_get_content_widget (EShellView *shell_view)
g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
- class = E_SHELL_VIEW_CLASS (shell_view);
+ class = E_SHELL_VIEW_GET_CLASS (shell_view);
g_return_val_if_fail (class->get_content_widget != NULL, NULL);
return class->get_content_widget (shell_view);
@@ -285,7 +327,7 @@ e_shell_view_get_sidebar_widget (EShellView *shell_view)
g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
- class = E_SHELL_VIEW_CLASS (shell_view);
+ class = E_SHELL_VIEW_GET_CLASS (shell_view);
g_return_val_if_fail (class->get_sidebar_widget != NULL, NULL);
return class->get_sidebar_widget (shell_view);
@@ -298,7 +340,7 @@ e_shell_view_get_status_widget (EShellView *shell_view)
g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
- class = E_SHELL_VIEW_CLASS (shell_view);
+ class = E_SHELL_VIEW_GET_CLASS (shell_view);
g_return_val_if_fail (class->get_status_widget != NULL, NULL);
return class->get_status_widget (shell_view);
diff --git a/shell/e-shell-view.h b/shell/e-shell-view.h
index ed123773fe..0c98e32eb4 100644
--- a/shell/e-shell-view.h
+++ b/shell/e-shell-view.h
@@ -77,6 +77,7 @@ void e_shell_view_set_title (EShellView *shell_view,
const gchar *title);
EShellWindow * e_shell_view_get_window (EShellView *shell_view);
gboolean e_shell_view_is_selected (EShellView *shell_view);
+gint e_shell_view_get_page_num (EShellView *shell_view);
GtkWidget * e_shell_view_get_content_widget (EShellView *shell_view);
GtkWidget * e_shell_view_get_sidebar_widget (EShellView *shell_view);
GtkWidget * e_shell_view_get_status_widget (EShellView *shell_view);
diff --git a/shell/e-shell-window.c b/shell/e-shell-window.c
index ed1e731922..063b0ff8e8 100644
--- a/shell/e-shell-window.c
+++ b/shell/e-shell-window.c
@@ -41,6 +41,47 @@ enum {
static gpointer parent_class;
+static EShellView *
+shell_window_new_view (EShellWindow *shell_window,
+ GType shell_view_type,
+ const gchar *title)
+{
+ GHashTable *loaded_views;
+ EShellView *shell_view;
+ GtkNotebook *notebook;
+ GtkWidget *widget;
+ const gchar *name;
+ gint page_num;
+
+ /* Determine the page number for the new shell view. */
+ notebook = GTK_NOTEBOOK (shell_window->priv->content_notebook);
+ page_num = gtk_notebook_get_n_pages (notebook);
+
+ shell_view = g_object_new (
+ shell_view_type, "page-num", page_num,
+ "title", title, "window", shell_window, NULL);
+
+ name = e_shell_view_get_name (shell_view);
+ loaded_views = shell_window->priv->loaded_views;
+ g_hash_table_insert (loaded_views, g_strdup (name), shell_view);
+
+ /* Add pages to the various shell window notebooks. */
+
+ notebook = GTK_NOTEBOOK (shell_window->priv->content_notebook);
+ widget = e_shell_view_get_content_widget (shell_view);
+ gtk_notebook_append_page (notebook, widget, NULL);
+
+ notebook = GTK_NOTEBOOK (shell_window->priv->sidebar_notebook);
+ widget = e_shell_view_get_sidebar_widget (shell_view);
+ gtk_notebook_append_page (notebook, widget, NULL);
+
+ notebook = GTK_NOTEBOOK (shell_window->priv->status_notebook);
+ widget = e_shell_view_get_status_widget (shell_view);
+ gtk_notebook_append_page (notebook, widget, NULL);
+
+ return shell_view;
+}
+
static void
shell_window_online_mode_notify_cb (EShell *shell,
GParamSpec *pspec,
@@ -286,14 +327,11 @@ e_shell_window_get_view (EShellWindow *shell_window,
continue;
}
- if (strcmp (view_name, class->type_module->name) == 0) {
- shell_view = g_object_new (
- shell_view_type, "title", class->label,
- "window", shell_window, NULL);
- g_hash_table_insert (
- loaded_views,
- g_strdup (view_name), shell_view);
- }
+ g_debug ("Comparing %s to %s (%s)", view_name, class->type_module->name, g_type_name (shell_view_type));
+
+ if (strcmp (view_name, class->type_module->name) == 0)
+ shell_view = shell_window_new_view (
+ shell_window, shell_view_type, class->label);
g_type_class_unref (class);
}
@@ -404,17 +442,37 @@ void
e_shell_window_set_current_view (EShellWindow *shell_window,
const gchar *name_or_alias)
{
+ GtkNotebook *notebook;
+ EShellView *shell_view;
const gchar *current_view;
+ gint page_num;
g_return_if_fail (E_IS_SHELL_WINDOW (shell_window));
- if (name_or_alias != NULL)
+ current_view = name_or_alias;
+
+ if (current_view != NULL)
current_view =
- e_shell_registry_get_canonical_name (name_or_alias);
+ e_shell_registry_get_canonical_name (current_view);
if (current_view == NULL)
current_view = shell_window->priv->default_view;
+ g_return_if_fail (current_view != NULL);
+
+ shell_view = e_shell_window_get_view (shell_window, current_view);
+ page_num = e_shell_view_get_page_num (shell_view);
+ g_return_if_fail (page_num >= 0);
+
+ notebook = GTK_NOTEBOOK (shell_window->priv->content_notebook);
+ gtk_notebook_set_current_page (notebook, page_num);
+
+ notebook = GTK_NOTEBOOK (shell_window->priv->sidebar_notebook);
+ gtk_notebook_set_current_page (notebook, page_num);
+
+ notebook = GTK_NOTEBOOK (shell_window->priv->status_notebook);
+ gtk_notebook_set_current_page (notebook, page_num);
+
shell_window->priv->current_view = current_view;
g_object_notify (G_OBJECT (shell_window), "current-view");
diff --git a/shell/test/e-test-shell-view.c b/shell/test/e-test-shell-view.c
index adba6ae3b8..05d19c13f1 100644
--- a/shell/test/e-test-shell-view.c
+++ b/shell/test/e-test-shell-view.c
@@ -20,20 +20,76 @@
#include "e-test-shell-view.h"
-#include <glib/gi18n.h>
-
#define E_TEST_SHELL_VIEW_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE \
((obj), E_TYPE_TEST_SHELL_VIEW, ETestShellViewPrivate))
struct _ETestShellViewPrivate {
- gint dummy_value;
+ GtkWidget *content_widget;
+ GtkWidget *sidebar_widget;
+ GtkWidget *status_widget;
};
GType e_test_shell_view_type = 0;
static gpointer parent_class;
static void
+test_shell_view_dispose (GObject *object)
+{
+ ETestShellViewPrivate *priv;
+
+ priv = E_TEST_SHELL_VIEW_GET_PRIVATE (object);
+
+ if (priv->content_widget != NULL) {
+ g_object_unref (priv->content_widget);
+ priv->content_widget = NULL;
+ }
+
+ if (priv->sidebar_widget != NULL) {
+ g_object_unref (priv->sidebar_widget);
+ priv->sidebar_widget = NULL;
+ }
+
+ if (priv->status_widget != NULL) {
+ g_object_unref (priv->status_widget);
+ priv->status_widget = NULL;
+ }
+
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (parent_class)->dispose (object);
+}
+
+static GtkWidget *
+test_shell_view_get_content_widget (EShellView *shell_view)
+{
+ ETestShellViewPrivate *priv;
+
+ priv = E_TEST_SHELL_VIEW_GET_PRIVATE (shell_view);
+
+ return priv->content_widget;
+}
+
+static GtkWidget *
+test_shell_view_get_sidebar_widget (EShellView *shell_view)
+{
+ ETestShellViewPrivate *priv;
+
+ priv = E_TEST_SHELL_VIEW_GET_PRIVATE (shell_view);
+
+ return priv->sidebar_widget;
+}
+
+static GtkWidget *
+test_shell_view_get_status_widget (EShellView *shell_view)
+{
+ ETestShellViewPrivate *priv;
+
+ priv = E_TEST_SHELL_VIEW_GET_PRIVATE (shell_view);
+
+ return priv->status_widget;
+}
+
+static void
test_shell_view_class_init (ETestShellViewClass *class,
GTypeModule *type_module)
{
@@ -43,15 +99,37 @@ test_shell_view_class_init (ETestShellViewClass *class,
g_type_class_add_private (class, sizeof (ETestShellViewPrivate));
shell_view_class = E_SHELL_VIEW_CLASS (class);
- shell_view_class->label = N_("Test");
+ shell_view_class->label = "Test";
shell_view_class->icon_name = "face-monkey";
shell_view_class->type_module = type_module;
+
+ shell_view_class->get_content_widget =
+ test_shell_view_get_content_widget;
+ shell_view_class->get_sidebar_widget =
+ test_shell_view_get_sidebar_widget;
+ shell_view_class->get_status_widget =
+ test_shell_view_get_status_widget;
}
static void
-test_shell_view_init (ETestShellView *view)
+test_shell_view_init (ETestShellView *test_shell_view)
{
- view->priv = E_TEST_SHELL_VIEW_GET_PRIVATE (view);
+ GtkWidget *widget;
+
+ test_shell_view->priv =
+ E_TEST_SHELL_VIEW_GET_PRIVATE (test_shell_view);
+
+ widget = gtk_label_new ("Content Widget");
+ test_shell_view->priv->content_widget = g_object_ref_sink (widget);
+ gtk_widget_show (widget);
+
+ widget = gtk_label_new ("Sidebar Widget");
+ test_shell_view->priv->sidebar_widget = g_object_ref_sink (widget);
+ gtk_widget_show (widget);
+
+ widget = gtk_label_new ("Status Widget");
+ test_shell_view->priv->status_widget = g_object_ref_sink (widget);
+ gtk_widget_show (widget);
}
GType