evolution r36215 - in branches/kill-bonobo: addressbook/gui/component shell shell/test widgets/misc



Author: mbarnes
Date: Sat Aug 30 04:42:02 2008
New Revision: 36215
URL: http://svn.gnome.org/viewvc/evolution?rev=36215&view=rev

Log:
Preferences window awesomeness.


Modified:
   branches/kill-bonobo/addressbook/gui/component/e-book-shell-view.c
   branches/kill-bonobo/shell/e-shell-view.c
   branches/kill-bonobo/shell/e-shell-view.h
   branches/kill-bonobo/shell/e-shell-window-actions.c
   branches/kill-bonobo/shell/test/e-test-shell-view.c
   branches/kill-bonobo/widgets/misc/e-preferences-window.c
   branches/kill-bonobo/widgets/misc/e-preferences-window.h

Modified: branches/kill-bonobo/addressbook/gui/component/e-book-shell-view.c
==============================================================================
--- branches/kill-bonobo/addressbook/gui/component/e-book-shell-view.c	(original)
+++ branches/kill-bonobo/addressbook/gui/component/e-book-shell-view.c	Sat Aug 30 04:42:02 2008
@@ -268,15 +268,16 @@
 }
 
 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);
 }
 

Modified: branches/kill-bonobo/shell/e-shell-view.c
==============================================================================
--- branches/kill-bonobo/shell/e-shell-view.c	(original)
+++ branches/kill-bonobo/shell/e-shell-view.c	Sat Aug 30 04:42:02 2008
@@ -302,9 +302,8 @@
 		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 @@
 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);
 }

Modified: branches/kill-bonobo/shell/e-shell-view.h
==============================================================================
--- branches/kill-bonobo/shell/e-shell-view.h	(original)
+++ branches/kill-bonobo/shell/e-shell-view.h	Sat Aug 30 04:42:02 2008
@@ -71,8 +71,7 @@
 
 	/* Signals */
 
-	void		(*changed)		(EShellView *shell_view,
-						 gboolean visible);
+	void		(*changed)		(EShellView *shell_view);
 };
 
 GType		e_shell_view_get_type		(void);

Modified: branches/kill-bonobo/shell/e-shell-window-actions.c
==============================================================================
--- branches/kill-bonobo/shell/e-shell-window-actions.c	(original)
+++ branches/kill-bonobo/shell/e-shell-window-actions.c	Sat Aug 30 04:42:02 2008
@@ -734,6 +734,12 @@
 	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. */

Modified: branches/kill-bonobo/shell/test/e-test-shell-view.c
==============================================================================
--- branches/kill-bonobo/shell/test/e-test-shell-view.c	(original)
+++ branches/kill-bonobo/shell/test/e-test-shell-view.c	Sat Aug 30 04:42:02 2008
@@ -90,21 +90,29 @@
 }
 
 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";

Modified: branches/kill-bonobo/widgets/misc/e-preferences-window.c
==============================================================================
--- branches/kill-bonobo/widgets/misc/e-preferences-window.c	(original)
+++ branches/kill-bonobo/widgets/misc/e-preferences-window.c	Sat Aug 30 04:42:02 2008
@@ -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 @@
 }
 
 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 @@
 	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 @@
 	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 @@
 }
 
 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 @@
 {
 	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 @@
 	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);
+
+	widget = gtk_vbox_new (FALSE, 12);
+	gtk_container_add (GTK_CONTAINER (window), widget);
+	gtk_widget_show (widget);
+
+	vbox = widget;
 
-	container = GTK_DIALOG (dialog)->vbox;
+	widget = gtk_hbox_new (FALSE, 12);
+	gtk_box_pack_start (GTK_BOX (vbox), widget, TRUE, TRUE, 0);
+	gtk_widget_show (widget);
 
-	hbox = gtk_hbox_new (FALSE, 12);
-	gtk_container_add (GTK_CONTAINER (container), hbox);
-	gtk_widget_show (hbox);
+	hbox = widget;
 
 	widget = gtk_scrolled_window_new (NULL, NULL);
 	gtk_scrolled_window_set_policy (
@@ -243,9 +241,9 @@
 	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 @@
 	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 @@
 		};
 
 		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 @@
 }
 
 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 @@
 	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 @@
 		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 @@
 	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);

Modified: branches/kill-bonobo/widgets/misc/e-preferences-window.h
==============================================================================
--- branches/kill-bonobo/widgets/misc/e-preferences-window.h	(original)
+++ branches/kill-bonobo/widgets/misc/e-preferences-window.h	Sat Aug 30 04:42:02 2008
@@ -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 _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);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]