aboutsummaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
Diffstat (limited to 'shell')
-rw-r--r--shell/ChangeLog10
-rw-r--r--shell/e-shell-settings-dialog.c111
2 files changed, 114 insertions, 7 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog
index 4e2e94ac8b..ced37c0b2d 100644
--- a/shell/ChangeLog
+++ b/shell/ChangeLog
@@ -1,3 +1,13 @@
+2002-03-29 Ettore Perazzoli <ettore@ximian.com>
+
+ * e-shell-settings-dialog.c: Add type "Page".
+ (page_new): New helper function.
+ (page_free): New helper function.
+ (compare_page_func): Callback for sorting a GList of pages.
+ (sort_page_list): New helper function.
+ (load_pages): Create the pages, sort them, add them sorted. Now
+ we have a priority field that overrides alphabetical sorting.
+
2002-03-26 Ettore Perazzoli <ettore@ximian.com>
* e-component-info.c: New.
diff --git a/shell/e-shell-settings-dialog.c b/shell/e-shell-settings-dialog.c
index 76cf594ea4..31896cb073 100644
--- a/shell/e-shell-settings-dialog.c
+++ b/shell/e-shell-settings-dialog.c
@@ -44,12 +44,81 @@
static EMultiConfigDialogClass *parent_class = NULL;
+/* Page handling. */
+
+struct _Page {
+ char *title;
+ char *description;
+ GdkPixbuf *icon;
+ int priority;
+ EConfigPage *page_widget;
+};
+typedef struct _Page Page;
+
+static Page *
+page_new (const char *title,
+ const char *description,
+ GdkPixbuf *icon,
+ int priority,
+ EConfigPage *page_widget)
+{
+ Page *page;
+
+ if (icon != NULL)
+ gdk_pixbuf_ref (icon);
+
+ page = g_new (Page, 1);
+ page->title = g_strdup (title);
+ page->description = g_strdup (description);
+ page->icon = icon;
+ page->priority = priority;
+ page->page_widget = page_widget;
+
+ return page;
+}
+
+static void
+page_free (Page *page)
+{
+ g_free (page->title);
+ g_free (page->description);
+
+ if (page->icon != NULL)
+ gdk_pixbuf_unref (page->icon);
+
+ g_free (page);
+}
+
+static int
+compare_page_func (const void *a,
+ const void *b)
+{
+ const Page *page_a;
+ const Page *page_b;
+
+ page_a = (const Page *) a;
+ page_b = (const Page *) b;
+
+ if (page_a->priority == page_b->priority)
+ return strcmp (page_a->title, page_b->title);
+
+ return page_a->priority - page_b->priority;
+}
+
+static GList *
+sort_page_list (GList *list)
+{
+ return g_list_sort (list, compare_page_func);
+}
+
static void
load_pages (EShellSettingsDialog *dialog)
{
OAF_ServerInfoList *control_list;
CORBA_Environment ev;
GSList *language_list;
+ GList *page_list;
+ GList *p;
int i;
CORBA_exception_init (&ev);
@@ -63,19 +132,23 @@ load_pages (EShellSettingsDialog *dialog)
language_list = e_get_language_list ();
+ page_list = NULL;
for (i = 0; i < control_list->_length; i ++) {
CORBA_Object corba_object;
OAF_ServerInfo *info;
const char *title;
const char *description;
const char *icon_path;
+ const char *priority_string;
+ int priority;
GdkPixbuf *icon;
info = & control_list->_buffer[i];
- title = oaf_server_info_prop_lookup (info, "evolution:config_item:title", language_list);
- description = oaf_server_info_prop_lookup (info, "evolution:config_item:description", language_list);
- icon_path = oaf_server_info_prop_lookup (info, "evolution:config_item:icon_name", NULL);
+ title = oaf_server_info_prop_lookup (info, "evolution:config_item:title", language_list);
+ description = oaf_server_info_prop_lookup (info, "evolution:config_item:description", language_list);
+ icon_path = oaf_server_info_prop_lookup (info, "evolution:config_item:icon_name", NULL);
+ priority_string = oaf_server_info_prop_lookup (info, "evolution:config_item:priority", NULL);
if (icon_path == NULL) {
icon = NULL;
@@ -91,11 +164,20 @@ load_pages (EShellSettingsDialog *dialog)
}
}
+ if (priority_string == NULL)
+ priority = 0xffff;
+ else
+ priority = atoi (priority_string);
+
corba_object = oaf_activate_from_id ((char *) info->iid, 0, NULL, &ev);
+
if (! BONOBO_EX (&ev)) {
- e_multi_config_dialog_add_page (E_MULTI_CONFIG_DIALOG (dialog),
- title, description, icon,
- E_CONFIG_PAGE (e_corba_config_page_new_from_objref (corba_object)));
+ Page *page;
+
+ page = page_new (title, description, icon, priority,
+ E_CONFIG_PAGE (e_corba_config_page_new_from_objref (corba_object)));
+
+ page_list = g_list_prepend (page_list, page);
} else {
g_warning ("Cannot activate %s -- %s", info->iid, BONOBO_EX_ID (&ev));
}
@@ -104,9 +186,24 @@ load_pages (EShellSettingsDialog *dialog)
gdk_pixbuf_unref (icon);
}
- CORBA_free (control_list);
+ page_list = sort_page_list (page_list);
+ for (p = page_list; p != NULL; p = p->next) {
+ Page *page;
+
+ page = (Page *) p->data;
+
+ e_multi_config_dialog_add_page (E_MULTI_CONFIG_DIALOG (dialog),
+ page->title,
+ page->description,
+ page->icon,
+ page->page_widget);
+ page_free (page);
+ }
+
+ g_list_free (page_list);
e_free_language_list (language_list);
+ CORBA_free (control_list);
CORBA_exception_free (&ev);
}