aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@src.gnome.org>2008-08-09 10:24:46 +0800
committerMatthew Barnes <mbarnes@src.gnome.org>2008-08-09 10:24:46 +0800
commit558de407c4afe0d3d42a6a67687f78d31404ade8 (patch)
tree8524d1d0ac4f5a1edfd52ee1b8cdba5d6e32e5f4
parent9388bae198d928960303feb90b2924086a8ad076 (diff)
downloadgsoc2013-evolution-558de407c4afe0d3d42a6a67687f78d31404ade8.tar
gsoc2013-evolution-558de407c4afe0d3d42a6a67687f78d31404ade8.tar.gz
gsoc2013-evolution-558de407c4afe0d3d42a6a67687f78d31404ade8.tar.bz2
gsoc2013-evolution-558de407c4afe0d3d42a6a67687f78d31404ade8.tar.lz
gsoc2013-evolution-558de407c4afe0d3d42a6a67687f78d31404ade8.tar.xz
gsoc2013-evolution-558de407c4afe0d3d42a6a67687f78d31404ade8.tar.zst
gsoc2013-evolution-558de407c4afe0d3d42a6a67687f78d31404ade8.zip
Kill EShellSettingsDialog.
Rename EMultiConfigDialog to EPreferencesWindow and improve the API. svn path=/branches/kill-bonobo/; revision=35944
-rw-r--r--shell/Makefile.am2
-rw-r--r--shell/e-shell-settings-dialog.c310
-rw-r--r--shell/e-shell-settings-dialog.h69
-rw-r--r--widgets/misc/Makefile.am14
-rw-r--r--widgets/misc/e-preferences-window.c (renamed from widgets/misc/e-multi-config-dialog.c)196
-rw-r--r--widgets/misc/e-preferences-window.h (renamed from widgets/misc/e-multi-config-dialog.h)67
-rw-r--r--widgets/misc/test-preferences-window.c (renamed from widgets/misc/test-multi-config-dialog.c)42
7 files changed, 149 insertions, 551 deletions
diff --git a/shell/Makefile.am b/shell/Makefile.am
index 8e001a57ba..6b4d225164 100644
--- a/shell/Makefile.am
+++ b/shell/Makefile.am
@@ -138,8 +138,6 @@ evolution_SOURCES = \
e-shell-importer.h \
e-shell-registry.c \
e-shell-registry.h \
- e-shell-settings-dialog.c \
- e-shell-settings-dialog.h \
e-shell-window-private.c \
e-shell-window-private.h \
e-sidebar.c \
diff --git a/shell/e-shell-settings-dialog.c b/shell/e-shell-settings-dialog.c
deleted file mode 100644
index a2e470c909..0000000000
--- a/shell/e-shell-settings-dialog.c
+++ /dev/null
@@ -1,310 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* e-shell-settings-dialog.c
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- * Author: Ettore Perazzoli <ettore@ximian.com>
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <glib/gi18n.h>
-
-#include "e-shell-settings-dialog.h"
-
-#include "e-corba-config-page.h"
-
-#include <bonobo/bonobo-widget.h>
-#include <bonobo/bonobo-exception.h>
-
-#include <bonobo-activation/bonobo-activation.h>
-
-#include <stdlib.h>
-#include <string.h>
-
-#define E_SHELL_SETTINGS_DIALOG_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_SHELL_SETTINGS_DIALOG, EShellSettingsDialogPrivate))
-
-struct _EShellSettingsDialogPrivate {
- GHashTable *types;
-};
-
-static gpointer parent_class;
-
-/* Page handling. */
-
-struct _Page {
- char *caption;
- char *icon_name;
- Bonobo_ActivationProperty *type;
- int priority;
- EConfigPage *page_widget;
-};
-typedef struct _Page Page;
-
-static Page *
-page_new (const char *caption,
- const char *icon_name,
- Bonobo_ActivationProperty *type,
- int priority,
- EConfigPage *page_widget)
-{
- Page *page;
-
- page = g_new (Page, 1);
- page->caption = g_strdup (caption);
- page->icon_name = g_strdup (icon_name);;
- page->type = type;
- page->priority = priority;
- page->page_widget = page_widget;
-
- return page;
-}
-
-static void
-page_free (Page *page)
-{
- g_free (page->caption);
- g_free (page->icon_name);
- g_free (page);
-}
-
-static gint
-compare_page_func (const Page *a,
- const Page *b)
-{
- if (a->priority == b->priority)
- return strcmp (a->caption, b->caption);
-
- return a->priority - b->priority;
-}
-
-static GList *
-sort_page_list (GList *list)
-{
- return g_list_sort (list, (GCompareFunc) compare_page_func);
-}
-
-static void
-load_pages (EShellSettingsDialog *dialog)
-{
- EShellSettingsDialogPrivate *priv;
- Bonobo_ServerInfoList *control_list;
- const gchar * const *language_names;
- CORBA_Environment ev;
- GSList *languages = NULL;
- GList *page_list;
- GList *p;
- int i, j;
-
- priv = dialog->priv;
-
- CORBA_exception_init (&ev);
-
- control_list = bonobo_activation_query ("repo_ids.has('IDL:GNOME/Evolution/ConfigControl:" BASE_VERSION "')", NULL, &ev);
- if (ev._major != CORBA_NO_EXCEPTION || control_list == NULL) {
- g_warning ("Cannot load configuration pages -- %s", BONOBO_EX_REPOID (&ev));
- CORBA_exception_free (&ev);
- return;
- }
-
- CORBA_exception_free (&ev);
-
- language_names = g_get_language_names ();
- while (*language_names != NULL)
- languages = g_slist_append (languages, (gpointer)(*language_names++));
-
- page_list = NULL;
- for (i = 0; i < control_list->_length; i ++) {
- CORBA_Object corba_object;
- Bonobo_ServerInfo *info;
- const char *caption;
- const char *icon_name;
- const char *priority_string;
- Bonobo_ActivationProperty *type;
- int priority;
-
- CORBA_exception_init (&ev);
-
- info = & control_list->_buffer[i];
-
- caption = bonobo_server_info_prop_lookup (info, "evolution2:config_item:title", languages);
- icon_name = bonobo_server_info_prop_lookup (info, "evolution2:config_item:icon_name", NULL);
- type = bonobo_server_info_prop_find (info, "evolution2:config_item:type");
- priority_string = bonobo_server_info_prop_lookup (info, "evolution2:config_item:priority", NULL);
-
- if (type != NULL && type->v._d != Bonobo_ACTIVATION_P_STRINGV)
- type = NULL;
- if (priority_string == NULL)
- priority = 0xffff;
- else
- priority = atoi (priority_string);
-
- corba_object = bonobo_activation_activate_from_id ((char *) info->iid, 0, NULL, &ev);
-
- if (! BONOBO_EX (&ev)) {
- Page *page;
-
- page = page_new (caption, icon_name, type, priority,
- E_CONFIG_PAGE (e_corba_config_page_new_from_objref (corba_object)));
-
- page_list = g_list_prepend (page_list, page);
- } else {
- char *bonobo_ex_text = bonobo_exception_get_text (&ev);
- g_warning ("Cannot activate %s -- %s", info->iid, bonobo_ex_text);
- g_free (bonobo_ex_text);
- }
-
- CORBA_exception_free (&ev);
- }
- g_slist_free(languages);
-
- page_list = sort_page_list (page_list);
- for (p = page_list, i = 0; p != NULL; p = p->next, i++) {
- Page *page;
-
- page = (Page *) p->data;
-
- e_multi_config_dialog_add_page (E_MULTI_CONFIG_DIALOG (dialog),
- page->caption,
- page->icon_name,
- page->page_widget);
-
- if (page->type != NULL) {
- Bonobo_StringList list = page->type->v._u.value_stringv;
-
- for (j = 0; j < list._length; j++) {
- if (g_hash_table_lookup (priv->types, list._buffer[j]) == NULL)
- g_hash_table_insert (priv->types, g_strdup (list._buffer[j]),
- GINT_TO_POINTER (i));
- }
- }
-
-
- page_free (page);
- }
-
- g_list_free (page_list);
- CORBA_free (control_list);
-}
-
-static void
-shell_settings_dialog_finalize (GObject *object)
-{
- EShellSettingsDialogPrivate *priv;
-
- priv = E_SHELL_SETTINGS_DIALOG_GET_PRIVATE (object);
-
- g_hash_table_destroy (priv->types);
-
- /* Chain up to parent's finalize() method. */
- G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-static void
-shell_settings_dialog_class_init (EShellSettingsDialogClass *class)
-{
- GObjectClass *object_class;
-
- parent_class = g_type_class_peek_parent (class);
- g_type_class_add_private (class, sizeof (EShellSettingsDialogPrivate));
-
- object_class = G_OBJECT_CLASS (class);
- object_class->finalize = shell_settings_dialog_finalize;
-}
-
-static void
-shell_settings_dialog_init (EShellSettingsDialog *dialog)
-{
- dialog->priv = E_SHELL_SETTINGS_DIALOG_GET_PRIVATE (dialog);
-
- dialog->priv->types = g_hash_table_new_full (
- g_str_hash, g_str_equal,
- (GDestroyNotify) g_free,
- (GDestroyNotify) NULL);
-
- load_pages (dialog);
-
- gtk_window_set_title (GTK_WINDOW (dialog), _("Evolution Preferences"));
- gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
-}
-
-GType
-e_shell_settings_dialog_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0)) {
- const GTypeInfo type_info = {
- sizeof (EShellSettingsDialogClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) shell_settings_dialog_class_init,
- (GClassFinalizeFunc) NULL,
- NULL, /* class_data */
- sizeof (EShellSettingsDialog),
- 0, /* n_preallocs */
- (GInstanceInitFunc) shell_settings_dialog_init,
- NULL /* value_table */
- };
-
- type = g_type_register_static (
- E_TYPE_MULTI_CONFIG_DIALOG, "EShellSettingsDialog",
- &type_info, 0);
- }
-
- return type;
-}
-
-GtkWidget *
-e_shell_settings_dialog_new (void)
-{
- return g_object_new (E_TYPE_SHELL_SETTINGS_DIALOG, NULL);
-}
-
-void
-e_shell_settings_dialog_show_type (EShellSettingsDialog *dialog,
- const gchar *type)
-{
- EShellSettingsDialogPrivate *priv;
- gpointer key, value;
- int page;
-
- g_return_if_fail (E_IS_SHELL_SETTINGS_DIALOG (dialog));
- g_return_if_fail (type != NULL);
-
- priv = dialog->priv;
-
- if (!g_hash_table_lookup_extended (priv->types, type, &key, &value)) {
- char *slash, *supertype;
-
- slash = strchr (type, '/');
- if (slash) {
- supertype = g_strndup (type, slash - type);
- value = g_hash_table_lookup (priv->types, type);
- g_free (supertype);
- } else
- value = NULL;
- }
-
- page = GPOINTER_TO_INT (value);
- e_multi_config_dialog_show_page (E_MULTI_CONFIG_DIALOG (dialog), page);
-}
diff --git a/shell/e-shell-settings-dialog.h b/shell/e-shell-settings-dialog.h
deleted file mode 100644
index bf81a61682..0000000000
--- a/shell/e-shell-settings-dialog.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* e-shell-settings-dialog.h
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * 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
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef E_SHELL_SETTINGS_DIALOG_H
-#define E_SHELL_SETTINGS_DIALOG_H
-
-#include "e-multi-config-dialog.h"
-
-G_BEGIN_DECLS
-
-/* Standard GObject macros */
-#define E_TYPE_SHELL_SETTINGS_DIALOG \
- (e_shell_settings_dialog_get_type ())
-#define E_SHELL_SETTINGS_DIALOG(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_SHELL_SETTINGS_DIALOG, EShellSettingsDialog))
-#define E_SHELL_SETTINGS_DIALOG_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_SHELL_SETTINGS_DIALOG, EShellSettingsDialogClass))
-#define E_IS_SHELL_SETTINGS_DIALOG(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_SHELL_SETTINGS_DIALOG))
-#define E_IS_SHELL_SETTINGS_DIALOG_CLASS(cls) \
- (G_TYPE_CHECK_CLASS_TYPE \
- ((cls), E_TYPE_SHELL_SETTINGS_DIALOG))
-#define E_SHELL_SETTINGS_DIALOG_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), E_TYPE_SHELL_SETTINGS_DIALOG, EShellSettingsDialogClass))
-
-typedef struct _EShellSettingsDialog EShellSettingsDialog;
-typedef struct _EShellSettingsDialogClass EShellSettingsDialogClass;
-typedef struct _EShellSettingsDialogPrivate EShellSettingsDialogPrivate;
-
-struct _EShellSettingsDialog {
- EMultiConfigDialog parent;
- EShellSettingsDialogPrivate *priv;
-};
-
-struct _EShellSettingsDialogClass {
- EMultiConfigDialogClass parent_class;
-};
-
-GType e_shell_settings_dialog_get_type(void);
-GtkWidget * e_shell_settings_dialog_new (void);
-void e_shell_settings_dialog_show_type
- (EShellSettingsDialog *dialog,
- const gchar *type);
-
-G_END_DECLS
-
-#endif /* E_SHELL_SETTINGS_DIALOG_H */
diff --git a/widgets/misc/Makefile.am b/widgets/misc/Makefile.am
index 95acd8b929..c7258e14a5 100644
--- a/widgets/misc/Makefile.am
+++ b/widgets/misc/Makefile.am
@@ -56,7 +56,7 @@ widgetsinclude_HEADERS = \
e-image-chooser.h \
e-info-label.h \
e-map.h \
- e-multi-config-dialog.h \
+ e-preferences-window.h \
e-online-button.h \
e-search-bar.h \
e-task-bar.h \
@@ -104,7 +104,7 @@ libemiscwidgets_la_SOURCES = \
e-image-chooser.c \
e-info-label.c \
e-map.c \
- e-multi-config-dialog.c \
+ e-preferences-window.c \
e-online-button.c \
e-search-bar.c \
e-task-bar.c \
@@ -158,7 +158,7 @@ noinst_PROGRAMS = \
test-calendar \
test-dateedit \
test-dropdown-button \
- test-multi-config-dialog \
+ test-preferences-window \
test-info-label
# test-calendar
@@ -191,12 +191,12 @@ test_dropdown_button_LDADD = \
$(top_builddir)/e-util/libeutil.la \
$(E_WIDGETS_LIBS)
-# test-multi-config-dialog
+# test-preferences-window
-test_multi_config_dialog_SOURCES = \
- test-multi-config-dialog.c
+test_preferences_window_SOURCES = \
+ test-preferences-window.c
-test_multi_config_dialog_LDADD = \
+test_preferences_window_LDADD = \
libemiscwidgets.la \
$(top_builddir)/e-util/libeutil.la \
$(E_WIDGETS_LIBS)
diff --git a/widgets/misc/e-multi-config-dialog.c b/widgets/misc/e-preferences-window.c
index bb9c0e6f79..1f2d38345f 100644
--- a/widgets/misc/e-multi-config-dialog.c
+++ b/widgets/misc/e-preferences-window.c
@@ -1,5 +1,5 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* e-multi-config-dialog.c
+/* e-preferences-window.c
*
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
*
@@ -18,46 +18,33 @@
* Boston, MA 02110-1301, USA.
*/
-#include "e-multi-config-dialog.h"
+#include "e-preferences-window.h"
#include <libgnome/gnome-help.h>
#define SWITCH_PAGE_INTERVAL 250
-#define E_MULTI_CONFIG_DIALOG_GET_PRIVATE(obj) \
+#define E_PREFERENCES_WINDOW_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_MULTI_CONFIG_DIALOG, EMultiConfigDialogPrivate))
+ ((obj), E_TYPE_PREFERENCES_WINDOW, EPreferencesWindowPrivate))
-struct _EMultiConfigDialogPrivate {
+struct _EPreferencesWindowPrivate {
GtkWidget *icon_view;
GtkWidget *notebook;
- guint timeout_id;
+ GHashTable *index;
};
enum {
COLUMN_TEXT, /* G_TYPE_STRING */
- COLUMN_PIXBUF /* GDK_TYPE_PIXBUF */
+ COLUMN_PIXBUF, /* GDK_TYPE_PIXBUF */
+ COLUMN_PAGE, /* G_TYPE_INT */
+ COLUMN_SORT /* G_TYPE_INT */
};
static gpointer parent_class;
-static GtkWidget *
-create_page_container (GtkWidget *widget)
-{
- GtkWidget *vbox;
-
- vbox = gtk_vbox_new (FALSE, 0);
-
- gtk_box_pack_start (GTK_BOX (vbox), widget, TRUE, TRUE, 0);
-
- gtk_widget_show (widget);
- gtk_widget_show (vbox);
-
- return vbox;
-}
-
static GdkPixbuf *
-multi_config_dialog_load_pixbuf (const gchar *icon_name)
+preferences_window_load_pixbuf (const gchar *icon_name)
{
GtkIconTheme *icon_theme;
GtkIconInfo *icon_info;
@@ -91,50 +78,40 @@ multi_config_dialog_load_pixbuf (const gchar *icon_name)
return pixbuf;
}
-static gboolean
-multi_config_dialog_timeout_cb (EMultiConfigDialog *dialog)
+static void
+preferences_window_selection_changed_cb (EPreferencesWindow *dialog)
{
GtkIconView *icon_view;
GtkNotebook *notebook;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
GList *list;
+ gint page;
icon_view = GTK_ICON_VIEW (dialog->priv->icon_view);
- notebook = GTK_NOTEBOOK (dialog->priv->notebook);
-
list = gtk_icon_view_get_selected_items (icon_view);
+ if (list == NULL)
+ return;
- if (list != NULL) {
- GtkTreePath *path = list->data;
- gint page;
+ model = gtk_icon_view_get_model (icon_view);
+ gtk_tree_model_get_iter (model, &iter, list->data);
+ gtk_tree_model_get (model, &iter, COLUMN_PAGE, &page, -1);
- page = gtk_tree_path_get_indices (path)[0];
- gtk_notebook_set_current_page (notebook, page);
- }
+ notebook = GTK_NOTEBOOK (dialog->priv->notebook);
+ gtk_notebook_set_current_page (notebook, page);
g_list_foreach (list, (GFunc) gtk_tree_path_free, NULL);
g_list_free (list);
- dialog->priv->timeout_id = 0;
gtk_widget_grab_focus (GTK_WIDGET (icon_view));
-
- return FALSE;
}
static void
-multi_config_dialog_selection_changed_cb (EMultiConfigDialog *dialog)
+preferences_window_dispose (GObject *object)
{
- if (dialog->priv->timeout_id == 0)
- dialog->priv->timeout_id = g_timeout_add (
- SWITCH_PAGE_INTERVAL, (GSourceFunc)
- multi_config_dialog_timeout_cb, dialog);
-}
+ EPreferencesWindowPrivate *priv;
-static void
-multi_config_dialog_dispose (GObject *object)
-{
- EMultiConfigDialogPrivate *priv;
-
- priv = E_MULTI_CONFIG_DIALOG_GET_PRIVATE (object);
+ priv = E_PREFERENCES_WINDOW_GET_PRIVATE (object);
if (priv->icon_view != NULL) {
g_object_unref (priv->icon_view);
@@ -146,26 +123,27 @@ multi_config_dialog_dispose (GObject *object)
priv->notebook = NULL;
}
+ g_hash_table_remove_all (priv->index);
+
/* Chain up to parent's dispose() method. */
G_OBJECT_CLASS (parent_class)->dispose (object);
}
static void
-multi_config_dialog_finalize (GObject *object)
+preferences_window_finalize (GObject *object)
{
- EMultiConfigDialogPrivate *priv;
+ EPreferencesWindowPrivate *priv;
- priv = E_MULTI_CONFIG_DIALOG_GET_PRIVATE (object);
+ priv = E_PREFERENCES_WINDOW_GET_PRIVATE (object);
- if (priv->timeout_id != 0)
- g_source_remove (priv->timeout_id);
+ g_hash_table_destroy (priv->index);
/* Chain up to parent's finalize() method. */
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
-multi_config_dialog_map (GtkWidget *widget)
+preferences_window_map (GtkWidget *widget)
{
GtkDialog *dialog;
@@ -181,8 +159,8 @@ multi_config_dialog_map (GtkWidget *widget)
}
static void
-multi_config_dialog_response (GtkDialog *dialog,
- gint response_id)
+preferences_window_response (GtkDialog *dialog,
+ gint response_id)
{
GError *error = NULL;
@@ -204,42 +182,51 @@ multi_config_dialog_response (GtkDialog *dialog,
}
static void
-multi_config_dialog_class_init (EMultiConfigDialogClass *class)
+preferences_window_class_init (EPreferencesWindowClass *class)
{
GObjectClass *object_class;
GtkWidgetClass *widget_class;
GtkDialogClass *dialog_class;
parent_class = g_type_class_peek_parent (class);
- g_type_class_add_private (class, sizeof (EMultiConfigDialogPrivate));
+ g_type_class_add_private (class, sizeof (EPreferencesWindowPrivate));
object_class = G_OBJECT_CLASS (class);
- object_class->dispose = multi_config_dialog_dispose;
- object_class->finalize = multi_config_dialog_finalize;
+ object_class->dispose = preferences_window_dispose;
+ object_class->finalize = preferences_window_finalize;
widget_class = GTK_WIDGET_CLASS (class);
- widget_class->map = multi_config_dialog_map;
+ widget_class->map = preferences_window_map;
dialog_class = GTK_DIALOG_CLASS (class);
- dialog_class->response = multi_config_dialog_response;
+ dialog_class->response = preferences_window_response;
}
static void
-multi_config_dialog_init (EMultiConfigDialog *dialog)
+preferences_window_init (EPreferencesWindow *dialog)
{
GtkListStore *store;
GtkWidget *container;
GtkWidget *hbox;
GtkWidget *widget;
+ GHashTable *index;
- dialog->priv = E_MULTI_CONFIG_DIALOG_GET_PRIVATE (dialog);
+ index = g_hash_table_new_full (
+ g_str_hash, g_str_equal,
+ (GDestroyNotify) g_free,
+ (GDestroyNotify) gtk_tree_row_reference_free);
+
+ dialog->priv = E_PREFERENCES_WINDOW_GET_PRIVATE (dialog);
+ dialog->priv->index = index;
+
+ store = gtk_list_store_new (
+ 4, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_INT, G_TYPE_INT);
+ gtk_tree_sortable_set_sort_column_id (
+ GTK_TREE_SORTABLE (store), COLUMN_SORT, GTK_SORT_ASCENDING);
gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
gtk_window_set_resizable (GTK_WINDOW (dialog), TRUE);
- /* XXX Remove this once we kill Bonobo. */
- gtk_widget_realize (GTK_WIDGET (dialog));
-
container = GTK_DIALOG (dialog)->vbox;
hbox = gtk_hbox_new (FALSE, 12);
@@ -257,14 +244,13 @@ multi_config_dialog_init (EMultiConfigDialog *dialog)
container = widget;
- store = gtk_list_store_new (2, G_TYPE_STRING, GDK_TYPE_PIXBUF);
widget = gtk_icon_view_new_with_model (GTK_TREE_MODEL (store));
gtk_icon_view_set_columns (GTK_ICON_VIEW (widget), 1);
gtk_icon_view_set_text_column (GTK_ICON_VIEW (widget), COLUMN_TEXT);
gtk_icon_view_set_pixbuf_column (GTK_ICON_VIEW (widget), COLUMN_PIXBUF);
g_signal_connect_swapped (
widget, "selection-changed",
- G_CALLBACK (multi_config_dialog_selection_changed_cb), dialog);
+ G_CALLBACK (preferences_window_selection_changed_cb), dialog);
gtk_container_add (GTK_CONTAINER (container), widget);
dialog->priv->icon_view = g_object_ref (widget);
gtk_widget_show (widget);
@@ -288,96 +274,104 @@ multi_config_dialog_init (EMultiConfigDialog *dialog)
}
GType
-e_multi_config_dialog_get_type (void)
+e_preferences_window_get_type (void)
{
static GType type = 0;
if (G_UNLIKELY (type == 0)) {
const GTypeInfo type_info = {
- sizeof (EMultiConfigDialogClass),
+ sizeof (EPreferencesWindowClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
- (GClassInitFunc) multi_config_dialog_class_init,
+ (GClassInitFunc) preferences_window_class_init,
(GClassFinalizeFunc) NULL,
NULL, /* class_data */
- sizeof (EMultiConfigDialog),
+ sizeof (EPreferencesWindow),
0, /* n_preallocs */
- (GInstanceInitFunc) multi_config_dialog_init,
+ (GInstanceInitFunc) preferences_window_init,
NULL /* value_table */
};
type = g_type_register_static (
- GTK_TYPE_DIALOG, "EMultiConfigDialog", &type_info, 0);
+ GTK_TYPE_DIALOG, "EPreferencesWindow", &type_info, 0);
}
return type;
}
GtkWidget *
-e_multi_config_dialog_new (void)
+e_preferences_window_new (void)
{
- return g_object_new (e_multi_config_dialog_get_type (), NULL);
+ return g_object_new (E_TYPE_PREFERENCES_WINDOW, NULL);
}
void
-e_multi_config_dialog_add_page (EMultiConfigDialog *dialog,
- const gchar *caption,
- const gchar *icon_name,
- EConfigPage *page_widget)
+e_preferences_window_add_page (EPreferencesWindow *dialog,
+ const gchar *page_name,
+ const gchar *icon_name,
+ const gchar *caption,
+ gint sort_order,
+ GtkWidget *widget)
{
+ GtkTreeRowReference *reference;
GtkIconView *icon_view;
GtkNotebook *notebook;
GtkTreeModel *model;
+ GtkTreePath *path;
+ GHashTable *index;
GdkPixbuf *pixbuf;
GtkTreeIter iter;
+ gint page;
g_return_if_fail (E_IS_MULTI_CONFIG_DIALOG (dialog));
- g_return_if_fail (caption != NULL);
+ g_return_if_fail (page_name != NULL);
g_return_if_fail (icon_name != NULL);
- g_return_if_fail (E_IS_CONFIG_PAGE (page_widget));
+ g_return_if_fail (caption != NULL);
+ g_return_if_fail (GTK_IS_WIDGET (widget));
icon_view = GTK_ICON_VIEW (dialog->priv->icon_view);
notebook = GTK_NOTEBOOK (dialog->priv->notebook);
+ page = gtk_notebook_get_n_pages (notebook);
model = gtk_icon_view_get_model (icon_view);
- pixbuf = multi_config_dialog_load_pixbuf (icon_name);
+ pixbuf = preferences_window_load_pixbuf (icon_name);
gtk_list_store_append (GTK_LIST_STORE (model), &iter);
gtk_list_store_set (
GTK_LIST_STORE (model), &iter,
- COLUMN_TEXT, caption, COLUMN_PIXBUF, pixbuf, -1);
+ COLUMN_TEXT, caption, COLUMN_PIXBUF, pixbuf,
+ COLUMN_PAGE, page, COLUMN_SORT, sort_order, -1);
- if (gtk_tree_model_iter_n_children (model, NULL) == 1) {
- GtkTreePath *path;
+ index = dialog->priv->index;
+ path = gtk_tree_model_get_path (model, &iter);
+ reference = gtk_tree_row_reference_new (model, path);
+ g_hash_table_insert (index, g_strdup (page_name), reference);
+ gtk_tree_path_free (path);
- path = gtk_tree_path_new_first ();
- gtk_icon_view_select_path (icon_view, path);
- gtk_tree_path_free (path);
- }
+ gtk_notebook_append_page (notebook, widget, NULL);
- gtk_notebook_append_page (
- notebook, create_page_container (
- GTK_WIDGET (page_widget)), NULL);
+ if (page == 0)
+ e_preferences_window_show_page (dialog, page_name);
}
void
-e_multi_config_dialog_show_page (EMultiConfigDialog *dialog,
- gint page)
+e_preferences_window_show_page (EPreferencesWindow *dialog,
+ const gchar *page_name)
{
+ GtkTreeRowReference *reference;
GtkIconView *icon_view;
- GtkNotebook *notebook;
GtkTreePath *path;
g_return_if_fail (E_IS_MULTI_CONFIG_DIALOG (dialog));
+ g_return_if_fail (page_name != NULL);
icon_view = GTK_ICON_VIEW (dialog->priv->icon_view);
- notebook = GTK_NOTEBOOK (dialog->priv->notebook);
+ reference = g_hash_table_lookup (dialog->priv->index, page_name);
+ g_return_if_fail (reference != NULL);
- path = gtk_tree_path_new_from_indices (page, -1);
+ path = gtk_tree_row_reference_get_path (reference);
gtk_icon_view_select_path (icon_view, path);
gtk_icon_view_scroll_to_path (icon_view, path, FALSE, 0.0, 0.0);
gtk_tree_path_free (path);
-
- gtk_notebook_set_current_page (notebook, page);
}
diff --git a/widgets/misc/e-multi-config-dialog.h b/widgets/misc/e-preferences-window.h
index f636f0d37d..133bf8cdb3 100644
--- a/widgets/misc/e-multi-config-dialog.h
+++ b/widgets/misc/e-preferences-window.h
@@ -1,5 +1,5 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* e-multi-config-dialog.h
+/* e-preferences-window.h
*
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
*
@@ -18,61 +18,56 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef E_MULTI_CONFIG_DIALOG_H
-#define E_MULTI_CONFIG_DIALOG_H
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "e-config-page.h"
+#ifndef E_PREFERENCES_WINDOW_H
+#define E_PREFERENCES_WINDOW_H
#include <gtk/gtk.h>
-G_BEGIN_DECLS
-
/* Standard GObject macros */
-#define E_TYPE_MULTI_CONFIG_DIALOG \
- (e_multi_config_dialog_get_type ())
-#define E_MULTI_CONFIG_DIALOG(obj) \
+#define E_TYPE_PREFERENCES_WINDOW \
+ (e_preferences_window_get_type ())
+#define E_PREFERENCES_WINDOW(obj) \
(G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), E_TYPE_MULTI_CONFIG_DIALOG, EMultiConfigDialog))
-#define E_MULTI_CONFIG_DIALOG_CLASS(cls) \
+ ((obj), E_TYPE_PREFERENCES_WINDOW, EPreferencesWindow))
+#define E_PREFERENCES_WINDOW_CLASS(cls) \
(G_TYPE_CHECK_CLASS_CAST \
- ((cls), E_TYPE_MULTI_CONFIG_DIALOG, EMultiConfigDialogClass))
+ ((cls), E_TYPE_PREFERENCES_WINDOW, EPreferencesWindowClass))
#define E_IS_MULTI_CONFIG_DIALOG(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), E_TYPE_MULTI_CONFIG_DIALOG))
+ ((obj), E_TYPE_PREFERENCES_WINDOW))
#define E_IS_MULTI_CONFIG_DIALOG_CLASS(cls) \
(G_TYPE_CHECK_CLASS_TYPE \
- ((obj), E_TYPE_MULTI_CONFIG_DIALOG))
-#define E_MULTI_CONFIG_DIALOG_GET_CLASS(obj) \
+ ((obj), E_TYPE_PREFERENCES_WINDOW))
+#define E_PREFERENCES_WINDOW_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_TYPE \
- ((obj), E_TYPE_MULTI_CONFIG_DIALOG, EMultiConfigDialogClass))
+ ((obj), E_TYPE_PREFERENCES_WINDOW, EPreferencesWindowClass))
-typedef struct _EMultiConfigDialog EMultiConfigDialog;
-typedef struct _EMultiConfigDialogClass EMultiConfigDialogClass;
-typedef struct _EMultiConfigDialogPrivate EMultiConfigDialogPrivate;
+G_BEGIN_DECLS
-struct _EMultiConfigDialog {
+typedef struct _EPreferencesWindow EPreferencesWindow;
+typedef struct _EPreferencesWindowClass EPreferencesWindowClass;
+typedef struct _EPreferencesWindowPrivate EPreferencesWindowPrivate;
+
+struct _EPreferencesWindow {
GtkDialog parent;
- EMultiConfigDialogPrivate *priv;
+ EPreferencesWindowPrivate *priv;
};
-struct _EMultiConfigDialogClass {
+struct _EPreferencesWindowClass {
GtkDialogClass parent_class;
};
-GType e_multi_config_dialog_get_type (void);
-GtkWidget * e_multi_config_dialog_new (void);
-
-void e_multi_config_dialog_add_page (EMultiConfigDialog *dialog,
- const gchar *caption,
+GType e_preferences_window_get_type (void);
+GtkWidget * e_preferences_window_new (void);
+void e_preferences_window_add_page (EPreferencesWindow *window,
+ const gchar *page_name,
const gchar *icon_name,
- EConfigPage *page);
-void e_multi_config_dialog_show_page (EMultiConfigDialog *dialog,
- gint page);
+ const gchar *caption,
+ gint sort_order,
+ GtkWidget *widget);
+void e_preferences_window_show_page (EPreferencesWindow *window,
+ const gchar *page_name);
G_END_DECLS
-#endif /* E_MULTI_CONFIG_DIALOG_H */
+#endif /* E_PREFERENCES_WINDOW_H */
diff --git a/widgets/misc/test-multi-config-dialog.c b/widgets/misc/test-preferences-window.c
index b9439722e9..ddc99ff3ba 100644
--- a/widgets/misc/test-multi-config-dialog.c
+++ b/widgets/misc/test-preferences-window.c
@@ -1,5 +1,5 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-/* test-multi-config-dialog.c
+/* test-preferences-window.c
*
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
*
@@ -16,47 +16,38 @@
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
- *
- * Authors:
- * Ettore Perazzoli <ettore@ximian.com>
*/
-#include "e-multi-config-dialog.c"
+#include "e-preferences-window.c"
#include <gtk/gtk.h>
#include <libgnomeui/gnome-app.h>
#include <libgnomeui/gnome-ui-init.h>
-
#define NUM_PAGES 10
-
static void
-add_pages (EMultiConfigDialog *multi_config_dialog)
+add_pages (EPreferencesWindow *preferences_window)
{
int i;
for (i = 0; i < NUM_PAGES; i ++) {
GtkWidget *widget;
- GtkWidget *page;
- char *string;
- char *title;
+ char *caption;
+ char *page_name;
- string = g_strdup_printf ("This is page %d", i);
- title = g_strdup_printf ("Title of page %d", i);
+ caption = g_strdup_printf ("Title of page %d", i);
+ page_name = g_strdup_printf ("page-%d", i);
- widget = gtk_label_new (string);
+ widget = gtk_label_new (caption);
gtk_widget_show (widget);
- page = e_config_page_new ();
- gtk_container_add (GTK_CONTAINER (page), widget);
-
- e_multi_config_dialog_add_page (
- multi_config_dialog, title, "gtk-properties",
- E_CONFIG_PAGE (page));
+ e_preferences_window_add_page (
+ preferences_window, page_name,
+ "gtk-properties", caption, i, widget);
- g_free (string);
- g_free (title);
+ g_free (caption);
+ g_free (page_name);
}
}
@@ -70,23 +61,22 @@ delete_event_callback (GtkWidget *widget,
return TRUE;
}
-
int
main (int argc, char **argv)
{
GtkWidget *dialog;
gnome_program_init (
- "test-multi-config-dialog", "0.0", LIBGNOMEUI_MODULE,
+ "test-preferences-window", "0.0", LIBGNOMEUI_MODULE,
argc, argv, GNOME_PARAM_NONE);
- dialog = e_multi_config_dialog_new ();
+ dialog = e_preferences_window_new ();
gtk_window_set_default_size (GTK_WINDOW (dialog), 400, 300);
g_signal_connect((dialog), "delete_event",
G_CALLBACK (delete_event_callback), NULL);
- add_pages (E_MULTI_CONFIG_DIALOG (dialog));
+ add_pages (E_PREFERENCES_WINDOW (dialog));
gtk_widget_show (dialog);