aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@src.gnome.org>2008-08-30 12:42:02 +0800
committerMatthew Barnes <mbarnes@src.gnome.org>2008-08-30 12:42:02 +0800
commit3843185df1e71e14e4f2e5d34aca34724090b496 (patch)
tree78c0b9336c798f106d25fceca4fd8a6be5f11301
parente0c501b7018f12d37b10e32923f95b7a01c7982c (diff)
downloadgsoc2013-evolution-3843185df1e71e14e4f2e5d34aca34724090b496.tar
gsoc2013-evolution-3843185df1e71e14e4f2e5d34aca34724090b496.tar.gz
gsoc2013-evolution-3843185df1e71e14e4f2e5d34aca34724090b496.tar.bz2
gsoc2013-evolution-3843185df1e71e14e4f2e5d34aca34724090b496.tar.lz
gsoc2013-evolution-3843185df1e71e14e4f2e5d34aca34724090b496.tar.xz
gsoc2013-evolution-3843185df1e71e14e4f2e5d34aca34724090b496.tar.zst
gsoc2013-evolution-3843185df1e71e14e4f2e5d34aca34724090b496.zip
Preferences window awesomeness.
svn path=/branches/kill-bonobo/; revision=36215
-rw-r--r--addressbook/gui/component/e-book-shell-view.c5
-rw-r--r--shell/e-shell-view.c17
-rw-r--r--shell/e-shell-view.h3
-rw-r--r--shell/e-shell-window-actions.c6
-rw-r--r--shell/test/e-test-shell-view.c14
-rw-r--r--widgets/misc/e-preferences-window.c143
-rw-r--r--widgets/misc/e-preferences-window.h8
7 files changed, 107 insertions, 89 deletions
diff --git a/addressbook/gui/component/e-book-shell-view.c b/addressbook/gui/component/e-book-shell-view.c
index 13098ab84a..1a5c38940d 100644
--- a/addressbook/gui/component/e-book-shell-view.c
+++ b/addressbook/gui/component/e-book-shell-view.c
@@ -268,15 +268,16 @@ book_shell_view_get_status_widget (EShellView *shell_view)
}
static void
-book_shell_view_changed (EShellView *shell_view,
- gboolean visible)
+book_shell_view_changed (EShellView *shell_view)
{
EBookShellViewPrivate *priv;
GtkActionGroup *action_group;
+ gboolean visible;
priv = E_BOOK_SHELL_VIEW_GET_PRIVATE (shell_view);
action_group = priv->contact_actions;
+ visible = e_shell_view_is_selected (shell_view);
gtk_action_group_set_visible (action_group, visible);
}
diff --git a/shell/e-shell-view.c b/shell/e-shell-view.c
index 02d53e0696..dec7a5bd96 100644
--- a/shell/e-shell-view.c
+++ b/shell/e-shell-view.c
@@ -302,9 +302,8 @@ shell_view_class_init (EShellViewClass *class)
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (EShellViewClass, changed),
NULL, NULL,
- g_cclosure_marshal_VOID__BOOLEAN,
- G_TYPE_NONE, 1,
- G_TYPE_BOOLEAN);
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
}
static void
@@ -531,17 +530,7 @@ e_shell_view_get_status_widget (EShellView *shell_view)
void
e_shell_view_changed (EShellView *shell_view)
{
- EShellWindow *shell_window;
- EShellView *current_view;
- const gchar *view_name;
- gboolean visible;
-
g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
- shell_window = e_shell_view_get_window (shell_view);
- view_name = e_shell_window_get_current_view (shell_window);
- current_view = e_shell_window_get_view (shell_window, view_name);
- visible = (current_view == shell_view);
-
- g_signal_emit (shell_view, signals[CHANGED], 0, visible);
+ g_signal_emit (shell_view, signals[CHANGED], 0);
}
diff --git a/shell/e-shell-view.h b/shell/e-shell-view.h
index b474c0aa36..90aa35c450 100644
--- a/shell/e-shell-view.h
+++ b/shell/e-shell-view.h
@@ -71,8 +71,7 @@ struct _EShellViewClass {
/* Signals */
- void (*changed) (EShellView *shell_view,
- gboolean visible);
+ void (*changed) (EShellView *shell_view);
};
GType e_shell_view_get_type (void);
diff --git a/shell/e-shell-window-actions.c b/shell/e-shell-window-actions.c
index 61f95576cd..a43333c5b1 100644
--- a/shell/e-shell-window-actions.c
+++ b/shell/e-shell-window-actions.c
@@ -734,6 +734,12 @@ action_preferences_cb (GtkAction *action,
GtkWidget *preferences_window;
preferences_window = e_shell_get_preferences_window ();
+ gtk_window_set_transient_for (
+ GTK_WINDOW (preferences_window),
+ GTK_WINDOW (shell_window));
+ gtk_window_set_position (
+ GTK_WINDOW (preferences_window),
+ GTK_WIN_POS_CENTER_ON_PARENT);
gtk_window_present (GTK_WINDOW (preferences_window));
/* FIXME Switch to a page appropriate for the current view. */
diff --git a/shell/test/e-test-shell-view.c b/shell/test/e-test-shell-view.c
index e2514ec236..db008fafea 100644
--- a/shell/test/e-test-shell-view.c
+++ b/shell/test/e-test-shell-view.c
@@ -90,21 +90,29 @@ test_shell_view_get_status_widget (EShellView *shell_view)
}
static void
-test_shell_view_changed (EShellView *shell_view,
- gboolean visible)
+test_shell_view_changed (EShellView *shell_view)
{
- g_debug ("%s (visible=%d)", G_STRFUNC, visible);
+ gboolean is_selected;
+ const gchar *selected;
+
+ is_selected = e_shell_view_is_selected (shell_view);
+ selected = is_selected ? "selected" : "not selected";
+ g_debug ("%s (%s)", G_STRFUNC, selected);
}
static void
test_shell_view_class_init (ETestShellViewClass *class,
GTypeModule *type_module)
{
+ GObjectClass *object_class;
EShellViewClass *shell_view_class;
parent_class = g_type_class_peek_parent (class);
g_type_class_add_private (class, sizeof (ETestShellViewPrivate));
+ object_class = G_OBJECT_CLASS (class);
+ object_class->dispose = test_shell_view_dispose;
+
shell_view_class = E_SHELL_VIEW_CLASS (class);
shell_view_class->label = "Test";
shell_view_class->icon_name = "face-monkey";
diff --git a/widgets/misc/e-preferences-window.c b/widgets/misc/e-preferences-window.c
index 988d065d76..c18d975c1d 100644
--- a/widgets/misc/e-preferences-window.c
+++ b/widgets/misc/e-preferences-window.c
@@ -20,6 +20,7 @@
#include "e-preferences-window.h"
+#include <glib/gi18n.h>
#include <e-util/e-util.h>
#define SWITCH_PAGE_INTERVAL 250
@@ -79,7 +80,13 @@ preferences_window_load_pixbuf (const gchar *icon_name)
}
static void
-preferences_window_selection_changed_cb (EPreferencesWindow *dialog)
+preferences_window_help_clicked_cb (GtkWindow *window)
+{
+ e_display_help (window, "config-prefs");
+}
+
+static void
+preferences_window_selection_changed_cb (EPreferencesWindow *window)
{
GtkIconView *icon_view;
GtkNotebook *notebook;
@@ -88,7 +95,7 @@ preferences_window_selection_changed_cb (EPreferencesWindow *dialog)
GList *list;
gint page;
- icon_view = GTK_ICON_VIEW (dialog->priv->icon_view);
+ icon_view = GTK_ICON_VIEW (window->priv->icon_view);
list = gtk_icon_view_get_selected_items (icon_view);
if (list == NULL)
return;
@@ -97,7 +104,7 @@ preferences_window_selection_changed_cb (EPreferencesWindow *dialog)
gtk_tree_model_get_iter (model, &iter, list->data);
gtk_tree_model_get (model, &iter, COLUMN_PAGE, &page, -1);
- notebook = GTK_NOTEBOOK (dialog->priv->notebook);
+ notebook = GTK_NOTEBOOK (window->priv->notebook);
gtk_notebook_set_current_page (notebook, page);
g_list_foreach (list, (GFunc) gtk_tree_path_free, NULL);
@@ -143,35 +150,16 @@ preferences_window_finalize (GObject *object)
}
static void
-preferences_window_map (GtkWidget *widget)
+preferences_window_show (GtkWidget *widget)
{
- GtkDialog *dialog;
+ EPreferencesWindowPrivate *priv;
- /* Chain up to parent's map() method. */
- GTK_WIDGET_CLASS (parent_class)->map (widget);
+ priv = E_PREFERENCES_WINDOW_GET_PRIVATE (widget);
- /* Override those stubborn style properties. */
- dialog = GTK_DIALOG (widget);
- gtk_box_set_spacing (GTK_BOX (dialog->vbox), 12);
- gtk_container_set_border_width (GTK_CONTAINER (widget), 12);
- gtk_container_set_border_width (GTK_CONTAINER (dialog->vbox), 0);
- gtk_container_set_border_width (GTK_CONTAINER (dialog->action_area), 0);
-}
+ gtk_widget_grab_focus (priv->icon_view);
-static void
-preferences_window_response (GtkDialog *dialog,
- gint response_id)
-{
- switch (response_id) {
- case GTK_RESPONSE_HELP:
- e_display_help (GTK_WINDOW (dialog), "config-prefs");
- break;
-
- case GTK_RESPONSE_CLOSE:
- default:
- gtk_widget_destroy (GTK_WIDGET (dialog));
- break;
- }
+ /* Chain up to parent's show() method. */
+ GTK_WIDGET_CLASS (parent_class)->show (widget);
}
static void
@@ -179,7 +167,6 @@ 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 (EPreferencesWindowPrivate));
@@ -189,42 +176,53 @@ preferences_window_class_init (EPreferencesWindowClass *class)
object_class->finalize = preferences_window_finalize;
widget_class = GTK_WIDGET_CLASS (class);
- widget_class->map = preferences_window_map;
-
- dialog_class = GTK_DIALOG_CLASS (class);
- dialog_class->response = preferences_window_response;
+ widget_class->show = preferences_window_show;
}
static void
-preferences_window_init (EPreferencesWindow *dialog)
+preferences_window_init (EPreferencesWindow *window)
{
GtkListStore *store;
GtkWidget *container;
GtkWidget *hbox;
+ GtkWidget *vbox;
GtkWidget *widget;
GHashTable *index;
+ const gchar *title;
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;
+ window->priv = E_PREFERENCES_WINDOW_GET_PRIVATE (window);
+ window->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);
+ title = _("Evolution Preferences");
+ gtk_window_set_title (GTK_WINDOW (window), title);
+ gtk_window_set_resizable (GTK_WINDOW (window), TRUE);
+ gtk_container_set_border_width (GTK_CONTAINER (window), 12);
+
+ g_signal_connect (
+ window, "delete-event",
+ G_CALLBACK (gtk_widget_hide_on_delete), NULL);
- container = GTK_DIALOG (dialog)->vbox;
+ widget = gtk_vbox_new (FALSE, 12);
+ gtk_container_add (GTK_CONTAINER (window), widget);
+ gtk_widget_show (widget);
- hbox = gtk_hbox_new (FALSE, 12);
- gtk_container_add (GTK_CONTAINER (container), hbox);
- gtk_widget_show (hbox);
+ vbox = widget;
+
+ widget = gtk_hbox_new (FALSE, 12);
+ gtk_box_pack_start (GTK_BOX (vbox), widget, TRUE, TRUE, 0);
+ gtk_widget_show (widget);
+
+ hbox = widget;
widget = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (
@@ -243,9 +241,9 @@ preferences_window_init (EPreferencesWindow *dialog)
gtk_icon_view_set_pixbuf_column (GTK_ICON_VIEW (widget), COLUMN_PIXBUF);
g_signal_connect_swapped (
widget, "selection-changed",
- G_CALLBACK (preferences_window_selection_changed_cb), dialog);
+ G_CALLBACK (preferences_window_selection_changed_cb), window);
gtk_container_add (GTK_CONTAINER (container), widget);
- dialog->priv->icon_view = g_object_ref (widget);
+ window->priv->icon_view = g_object_ref (widget);
gtk_widget_show (widget);
g_object_unref (store);
@@ -253,17 +251,34 @@ preferences_window_init (EPreferencesWindow *dialog)
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (widget), FALSE);
gtk_notebook_set_show_border (GTK_NOTEBOOK (widget), FALSE);
gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);
- dialog->priv->notebook = g_object_ref (widget);
+ window->priv->notebook = g_object_ref (widget);
gtk_widget_show (widget);
- gtk_dialog_add_buttons (
- GTK_DIALOG (dialog),
- GTK_STOCK_HELP, GTK_RESPONSE_HELP,
- GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
- NULL);
+ widget = gtk_hbutton_box_new ();
+ gtk_button_box_set_layout (
+ GTK_BUTTON_BOX (widget), GTK_BUTTONBOX_END);
+ gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
+ gtk_widget_show (widget);
+
+ container = widget;
- gtk_dialog_set_default_response (
- GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
+ widget = gtk_button_new_from_stock (GTK_STOCK_HELP);
+ g_signal_connect_swapped (
+ widget, "clicked",
+ G_CALLBACK (preferences_window_help_clicked_cb), window);
+ gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
+ gtk_button_box_set_child_secondary (
+ GTK_BUTTON_BOX (container), widget, TRUE);
+ gtk_widget_show (widget);
+
+ widget = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
+ g_signal_connect_swapped (
+ widget, "clicked",
+ G_CALLBACK (gtk_widget_hide), window);
+ GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_DEFAULT);
+ gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
+ gtk_widget_grab_default (widget);
+ gtk_widget_show (widget);
}
GType
@@ -286,7 +301,7 @@ e_preferences_window_get_type (void)
};
type = g_type_register_static (
- GTK_TYPE_DIALOG, "EPreferencesWindow", &type_info, 0);
+ GTK_TYPE_WINDOW, "EPreferencesWindow", &type_info, 0);
}
return type;
@@ -299,7 +314,7 @@ e_preferences_window_new (void)
}
void
-e_preferences_window_add_page (EPreferencesWindow *dialog,
+e_preferences_window_add_page (EPreferencesWindow *window,
const gchar *page_name,
const gchar *icon_name,
const gchar *caption,
@@ -316,14 +331,14 @@ e_preferences_window_add_page (EPreferencesWindow *dialog,
GtkTreeIter iter;
gint page;
- g_return_if_fail (E_IS_MULTI_CONFIG_DIALOG (dialog));
+ g_return_if_fail (E_IS_PREFERENCES_WINDOW (window));
g_return_if_fail (page_name != NULL);
g_return_if_fail (icon_name != NULL);
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);
+ icon_view = GTK_ICON_VIEW (window->priv->icon_view);
+ notebook = GTK_NOTEBOOK (window->priv->notebook);
page = gtk_notebook_get_n_pages (notebook);
model = gtk_icon_view_get_model (icon_view);
@@ -336,7 +351,7 @@ e_preferences_window_add_page (EPreferencesWindow *dialog,
COLUMN_TEXT, caption, COLUMN_PIXBUF, pixbuf,
COLUMN_PAGE, page, COLUMN_SORT, sort_order, -1);
- index = dialog->priv->index;
+ index = window->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);
@@ -345,24 +360,24 @@ e_preferences_window_add_page (EPreferencesWindow *dialog,
gtk_notebook_append_page (notebook, widget, NULL);
if (page == 0)
- e_preferences_window_show_page (dialog, page_name);
+ e_preferences_window_show_page (window, page_name);
- gtk_widget_queue_resize (GTK_WIDGET (dialog));
+ gtk_widget_queue_resize (GTK_WIDGET (window));
}
void
-e_preferences_window_show_page (EPreferencesWindow *dialog,
+e_preferences_window_show_page (EPreferencesWindow *window,
const gchar *page_name)
{
GtkTreeRowReference *reference;
GtkIconView *icon_view;
GtkTreePath *path;
- g_return_if_fail (E_IS_MULTI_CONFIG_DIALOG (dialog));
+ g_return_if_fail (E_IS_PREFERENCES_WINDOW (window));
g_return_if_fail (page_name != NULL);
- icon_view = GTK_ICON_VIEW (dialog->priv->icon_view);
- reference = g_hash_table_lookup (dialog->priv->index, page_name);
+ icon_view = GTK_ICON_VIEW (window->priv->icon_view);
+ reference = g_hash_table_lookup (window->priv->index, page_name);
g_return_if_fail (reference != NULL);
path = gtk_tree_row_reference_get_path (reference);
diff --git a/widgets/misc/e-preferences-window.h b/widgets/misc/e-preferences-window.h
index 379d41a977..2a1ec921c8 100644
--- a/widgets/misc/e-preferences-window.h
+++ b/widgets/misc/e-preferences-window.h
@@ -32,10 +32,10 @@
#define E_PREFERENCES_WINDOW_CLASS(cls) \
(G_TYPE_CHECK_CLASS_CAST \
((cls), E_TYPE_PREFERENCES_WINDOW, EPreferencesWindowClass))
-#define E_IS_MULTI_CONFIG_DIALOG(obj) \
+#define E_IS_PREFERENCES_WINDOW(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE \
((obj), E_TYPE_PREFERENCES_WINDOW))
-#define E_IS_MULTI_CONFIG_DIALOG_CLASS(cls) \
+#define E_IS_PREFERENCES_WINDOW_CLASS(cls) \
(G_TYPE_CHECK_CLASS_TYPE \
((obj), E_TYPE_PREFERENCES_WINDOW))
#define E_PREFERENCES_WINDOW_GET_CLASS(obj) \
@@ -49,12 +49,12 @@ typedef struct _EPreferencesWindowClass EPreferencesWindowClass;
typedef struct _EPreferencesWindowPrivate EPreferencesWindowPrivate;
struct _EPreferencesWindow {
- GtkDialog parent;
+ GtkWindow parent;
EPreferencesWindowPrivate *priv;
};
struct _EPreferencesWindowClass {
- GtkDialogClass parent_class;
+ GtkWindowClass parent_class;
};
GType e_preferences_window_get_type (void);