aboutsummaryrefslogtreecommitdiffstats
path: root/shell/e-shell-settings-dialog.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@src.gnome.org>2008-08-09 07:12:59 +0800
committerMatthew Barnes <mbarnes@src.gnome.org>2008-08-09 07:12:59 +0800
commit278c1fa77ba74f70a8d55e6d679f73372034fb14 (patch)
treebaff39d35a883b802328488a8ab037ff2585e2db /shell/e-shell-settings-dialog.c
parent7903e73970cbf89f4a49c5f7083b205b8670d0be (diff)
downloadgsoc2013-evolution-278c1fa77ba74f70a8d55e6d679f73372034fb14.tar
gsoc2013-evolution-278c1fa77ba74f70a8d55e6d679f73372034fb14.tar.gz
gsoc2013-evolution-278c1fa77ba74f70a8d55e6d679f73372034fb14.tar.bz2
gsoc2013-evolution-278c1fa77ba74f70a8d55e6d679f73372034fb14.tar.lz
gsoc2013-evolution-278c1fa77ba74f70a8d55e6d679f73372034fb14.tar.xz
gsoc2013-evolution-278c1fa77ba74f70a8d55e6d679f73372034fb14.tar.zst
gsoc2013-evolution-278c1fa77ba74f70a8d55e6d679f73372034fb14.zip
Work through more compilation errors.
Rewrite EMultiConfigDialog to not use ETable. svn path=/branches/kill-bonobo/; revision=35942
Diffstat (limited to 'shell/e-shell-settings-dialog.c')
-rw-r--r--shell/e-shell-settings-dialog.c190
1 files changed, 71 insertions, 119 deletions
diff --git a/shell/e-shell-settings-dialog.c b/shell/e-shell-settings-dialog.c
index 27c4fde6df..a2e470c909 100644
--- a/shell/e-shell-settings-dialog.c
+++ b/shell/e-shell-settings-dialog.c
@@ -30,7 +30,6 @@
#include "e-shell-settings-dialog.h"
#include "e-corba-config-page.h"
-#include <e-util/e-icon-factory.h>
#include <bonobo/bonobo-widget.h>
#include <bonobo/bonobo-exception.h>
@@ -40,48 +39,21 @@
#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;
};
-G_DEFINE_TYPE (EShellSettingsDialog, e_shell_settings_dialog, E_TYPE_MULTI_CONFIG_DIALOG)
-
-
-/* FIXME ugly hack to work around that sizing of invisible widgets is broken
- with Bonobo. */
+static gpointer parent_class;
-static void
-set_dialog_size (EShellSettingsDialog *dialog)
-{
- PangoLayout *layout;
- PangoContext *context;
- PangoFontMetrics *metrics;
- int width, height;
-
- layout = gtk_widget_create_pango_layout (GTK_WIDGET (dialog), "M");
- context = pango_layout_get_context (layout);
- metrics = pango_context_get_metrics (context,
- gtk_widget_get_style (GTK_WIDGET (dialog))->font_desc,
- pango_context_get_language (context));
-
- pango_layout_get_pixel_size (layout, &width, NULL);
-
- width *= 60;
- height = PANGO_PIXELS (pango_font_metrics_get_ascent (metrics)
- + pango_font_metrics_get_descent (metrics)) * 30;
-
- gtk_window_set_default_size((GtkWindow *)dialog, width, height);
- g_object_unref (layout);
- pango_font_metrics_unref (metrics);
-}
-
-
/* Page handling. */
struct _Page {
- char *title;
- char *description;
- GdkPixbuf *icon;
+ char *caption;
+ char *icon_name;
Bonobo_ActivationProperty *type;
int priority;
EConfigPage *page_widget;
@@ -89,22 +61,17 @@ struct _Page {
typedef struct _Page Page;
static Page *
-page_new (const char *title,
- const char *description,
- GdkPixbuf *icon,
+page_new (const char *caption,
+ const char *icon_name,
Bonobo_ActivationProperty *type,
int priority,
EConfigPage *page_widget)
{
Page *page;
- if (icon != NULL)
- g_object_ref (icon);
-
page = g_new (Page, 1);
- page->title = g_strdup (title);
- page->description = g_strdup (description);
- page->icon = icon;
+ page->caption = g_strdup (caption);
+ page->icon_name = g_strdup (icon_name);;
page->type = type;
page->priority = priority;
page->page_widget = page_widget;
@@ -115,35 +82,25 @@ page_new (const char *title,
static void
page_free (Page *page)
{
- g_free (page->title);
- g_free (page->description);
-
- if (page->icon != NULL)
- g_object_unref (page->icon);
-
+ g_free (page->caption);
+ g_free (page->icon_name);
g_free (page);
}
-static int
-compare_page_func (const void *a,
- const void *b)
+static gint
+compare_page_func (const Page *a,
+ const Page *b)
{
- const Page *page_a;
- const Page *page_b;
+ if (a->priority == b->priority)
+ return strcmp (a->caption, b->caption);
- 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;
+ return a->priority - b->priority;
}
static GList *
sort_page_list (GList *list)
{
- return g_list_sort (list, compare_page_func);
+ return g_list_sort (list, (GCompareFunc) compare_page_func);
}
static void
@@ -179,34 +136,21 @@ load_pages (EShellSettingsDialog *dialog)
for (i = 0; i < control_list->_length; i ++) {
CORBA_Object corba_object;
Bonobo_ServerInfo *info;
- const char *title;
- const char *description;
- const char *icon_path;
+ const char *caption;
+ const char *icon_name;
const char *priority_string;
Bonobo_ActivationProperty *type;
int priority;
- GdkPixbuf *icon;
CORBA_exception_init (&ev);
info = & control_list->_buffer[i];
- title = bonobo_server_info_prop_lookup (info, "evolution2:config_item:title", languages);
- description = bonobo_server_info_prop_lookup (info, "evolution2:config_item:description", languages);
- icon_path = bonobo_server_info_prop_lookup (info, "evolution2:config_item:icon_name", NULL);
+ 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 (icon_path == NULL) {
- icon = NULL;
- } else {
- if (g_path_is_absolute (icon_path)) {
- icon = gdk_pixbuf_new_from_file (icon_path, NULL);
- } else {
- icon = e_icon_factory_get_icon (icon_path, E_ICON_SIZE_DIALOG);
- }
- }
-
if (type != NULL && type->v._d != Bonobo_ACTIVATION_P_STRINGV)
type = NULL;
if (priority_string == NULL)
@@ -219,7 +163,7 @@ load_pages (EShellSettingsDialog *dialog)
if (! BONOBO_EX (&ev)) {
Page *page;
- page = page_new (title, description, icon, type, priority,
+ 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);
@@ -229,9 +173,6 @@ load_pages (EShellSettingsDialog *dialog)
g_free (bonobo_ex_text);
}
- if (icon != NULL)
- g_object_unref (icon);
-
CORBA_exception_free (&ev);
}
g_slist_free(languages);
@@ -243,9 +184,8 @@ load_pages (EShellSettingsDialog *dialog)
page = (Page *) p->data;
e_multi_config_dialog_add_page (E_MULTI_CONFIG_DIALOG (dialog),
- page->title,
- page->description,
- page->icon,
+ page->caption,
+ page->icon_name,
page->page_widget);
if (page->type != NULL) {
@@ -266,74 +206,88 @@ load_pages (EShellSettingsDialog *dialog)
CORBA_free (control_list);
}
-
-/* GtkObject methods. */
-
static void
-impl_finalize (GObject *object)
+shell_settings_dialog_finalize (GObject *object)
{
- EShellSettingsDialog *dialog;
EShellSettingsDialogPrivate *priv;
- dialog = E_SHELL_SETTINGS_DIALOG (object);
- priv = dialog->priv;
+ priv = E_SHELL_SETTINGS_DIALOG_GET_PRIVATE (object);
g_hash_table_destroy (priv->types);
- g_free (priv);
-
- (* G_OBJECT_CLASS (e_shell_settings_dialog_parent_class)->finalize) (object);
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
-
static void
-e_shell_settings_dialog_class_init (EShellSettingsDialogClass *klass)
+shell_settings_dialog_class_init (EShellSettingsDialogClass *class)
{
GObjectClass *object_class;
- object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = impl_finalize;
+ 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
-e_shell_settings_dialog_init (EShellSettingsDialog *dialog)
+shell_settings_dialog_init (EShellSettingsDialog *dialog)
{
- EShellSettingsDialogPrivate *priv;
+ dialog->priv = E_SHELL_SETTINGS_DIALOG_GET_PRIVATE (dialog);
- priv = g_new (EShellSettingsDialogPrivate, 1);
- priv->types = g_hash_table_new_full (
+ dialog->priv->types = g_hash_table_new_full (
g_str_hash, g_str_equal,
(GDestroyNotify) g_free,
(GDestroyNotify) NULL);
- dialog->priv = priv;
-
load_pages (dialog);
- set_dialog_size (dialog);
gtk_window_set_title (GTK_WINDOW (dialog), _("Evolution Preferences"));
gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
}
-
-GtkWidget *
-e_shell_settings_dialog_new (void)
+GType
+e_shell_settings_dialog_get_type (void)
{
- EShellSettingsDialog *new;
+ 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);
+ }
- new = g_object_new (e_shell_settings_dialog_get_type (), NULL);
+ return type;
+}
- return GTK_WIDGET (new);
+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 char *type)
+e_shell_settings_dialog_show_type (EShellSettingsDialog *dialog,
+ const gchar *type)
{
EShellSettingsDialogPrivate *priv;
gpointer key, value;
int page;
- g_return_if_fail (dialog != NULL);
g_return_if_fail (E_IS_SHELL_SETTINGS_DIALOG (dialog));
g_return_if_fail (type != NULL);
@@ -350,9 +304,7 @@ e_shell_settings_dialog_show_type (EShellSettingsDialog *dialog, const char *typ
} else
value = NULL;
}
- page = GPOINTER_TO_INT (value);
+ page = GPOINTER_TO_INT (value);
e_multi_config_dialog_show_page (E_MULTI_CONFIG_DIALOG (dialog), page);
}
-
-