[evolution/webkit-composer-rebased: 77/105] Move EActionComboBox from widgets/misc to widgets/editor
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/webkit-composer-rebased: 77/105] Move EActionComboBox from widgets/misc to widgets/editor
- Date: Thu, 13 Dec 2012 17:19:00 +0000 (UTC)
commit 69335d8c0ff711a0f31a1915d0753468b83bef58
Author: Dan VrÃtil <dvratil redhat com>
Date: Tue Sep 11 10:16:47 2012 +0200
Move EActionComboBox from widgets/misc to widgets/editor
e-util/e-editor-actions.c | 1 -
e-util/test-editor.c | 21 ++-
modules/mail/e-mail-shell-backend.c | 3 +-
shell/e-shell-searchbar.c | 321 ++++------------------------------
4 files changed, 54 insertions(+), 292 deletions(-)
---
diff --git a/e-util/e-editor-actions.c b/e-util/e-editor-actions.c
index 8121c59..99c5ea3 100644
--- a/e-util/e-editor-actions.c
+++ b/e-util/e-editor-actions.c
@@ -1985,5 +1985,4 @@ editor_actions_init (EEditor *editor)
editor->priv->selection, "underline",
ACTION (UNDERLINE), "active",
G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
-
}
diff --git a/e-util/test-editor.c b/e-util/test-editor.c
index febfee4..5e4136c 100644
--- a/e-util/test-editor.c
+++ b/e-util/test-editor.c
@@ -128,7 +128,7 @@ save_dialog (EEditor *editor)
static void
view_source_dialog (EEditor *editor,
const gchar *title,
- const gchar *content_type,
+ gboolean plain_text,
gboolean show_source)
{
GtkWidget *dialog;
@@ -160,9 +160,16 @@ view_source_dialog (EEditor *editor,
gtk_container_set_border_width (GTK_CONTAINER (scrolled_window), 6);
gtk_window_set_default_size (GTK_WINDOW (dialog), 400, 300);
- html = e_editor_widget_get_text_html (
- e_editor_get_editor_widget (editor));
- if (show_source) {
+
+ if (plain_text) {
+ html = e_editor_widget_get_text_plain (
+ e_editor_get_editor_widget (editor));
+ } else {
+ html = e_editor_widget_get_text_html (
+ e_editor_get_editor_widget (editor));
+ }
+
+ if (show_source || plain_text) {
GtkTextBuffer *buffer;
@@ -248,21 +255,21 @@ static void
action_view_html_output (GtkAction *action,
EEditor *editor)
{
- view_source_dialog (editor, _("HTML Output"), "text/html", FALSE);
+ view_source_dialog (editor, _("HTML Output"), FALSE, FALSE);
}
static void
action_view_html_source (GtkAction *action,
EEditor *editor)
{
- view_source_dialog (editor, _("HTML Source"), "text/html", TRUE);
+ view_source_dialog (editor, _("HTML Source"), FALSE, TRUE);
}
static void
action_view_plain_source (GtkAction *action,
EEditor *editor)
{
- view_source_dialog (editor, _("Plain Source"), "text/plain", FALSE);
+ view_source_dialog (editor, _("Plain Source"), TRUE, FALSE);
}
static void
diff --git a/modules/mail/e-mail-shell-backend.c b/modules/mail/e-mail-shell-backend.c
index 9a745a6..bdf1655 100644
--- a/modules/mail/e-mail-shell-backend.c
+++ b/modules/mail/e-mail-shell-backend.c
@@ -388,9 +388,10 @@ mail_shell_backend_window_added_cb (GtkApplication *application,
shell_settings = e_shell_get_shell_settings (shell);
/* Express mode does not honor this setting. */
- if (!e_shell_get_express_mode (shell))
+ if (!e_shell_get_express_mode (shell)) {
active = e_shell_settings_get_boolean (
shell_settings, "composer-format-html");
+ }
e_editor_widget_set_mode (
editor_widget,
diff --git a/shell/e-shell-searchbar.c b/shell/e-shell-searchbar.c
index b5d490d..d717b64 100644
--- a/shell/e-shell-searchbar.c
+++ b/shell/e-shell-searchbar.c
@@ -40,9 +40,6 @@
(G_TYPE_INSTANCE_GET_PRIVATE \
((obj), E_TYPE_SHELL_SEARCHBAR, EShellSearchbarPrivate))
-/* spacing between "groups" on the search bar */
-#define COLUMN_SPACING 24
-
#define SEARCH_OPTION_ADVANCED (-1)
/* Default "state key file" group: [Search Bar] */
@@ -59,17 +56,12 @@ struct _EShellSearchbarPrivate {
GtkRadioAction *search_option;
EFilterRule *search_rule;
- GtkCssProvider *css_provider;
/* Child Widgets (not referenced) */
GtkWidget *filter_combo_box;
GtkWidget *search_entry;
GtkWidget *scope_combo_box;
- /* Child widget containers (referenced) */
- GSList *child_containers;
- guint resize_idle_id;
-
/* State Key File */
gchar *state_group;
@@ -100,7 +92,7 @@ enum {
G_DEFINE_TYPE_WITH_CODE (
EShellSearchbar,
e_shell_searchbar,
- GTK_TYPE_GRID,
+ GTK_TYPE_BOX,
G_IMPLEMENT_INTERFACE (
E_TYPE_EXTENSIBLE, NULL))
@@ -251,27 +243,17 @@ shell_searchbar_update_search_widgets (EShellSearchbar *searchbar)
(e_shell_view_get_search_rule (shell_view) != NULL);
if (sensitive) {
- GtkStyleContext *style;
- GdkRGBA bg, fg;
- gchar *css;
-
- style = gtk_widget_get_style_context (widget);
- gtk_style_context_get_background_color (style, GTK_STATE_FLAG_SELECTED, &bg);
- gtk_style_context_get_color (style, GTK_STATE_FLAG_SELECTED, &fg);
-
- css = g_strdup_printf ("GtkEntry#searchbar_searchentry_active { "
- " background:none; "
- " background-color:#%06x; "
- " color:#%06x; "
- "}",
- e_rgba_to_value (&bg),
- e_rgba_to_value (&fg));
- gtk_css_provider_load_from_data (searchbar->priv->css_provider, css, -1, NULL);
- g_free (css);
-
- gtk_widget_set_name (widget, "searchbar_searchentry_active");
+ GtkStyle *style;
+ const GdkColor *color;
+
+ style = gtk_widget_get_style (widget);
+ color = &style->mid[GTK_STATE_SELECTED];
+
+ gtk_widget_modify_bg (widget, GTK_STATE_NORMAL, color);
+ gtk_widget_modify_text (widget, GTK_STATE_NORMAL, NULL);
} else {
- gtk_widget_set_name (widget, "searchbar_searchentry");
+ /* Text color will be updated when we move the focus. */
+ gtk_widget_modify_bg (widget, GTK_STATE_NORMAL, NULL);
}
action = E_SHELL_WINDOW_ACTION_SEARCH_CLEAR (shell_window);
@@ -476,127 +458,6 @@ shell_searchbar_option_changed_cb (GtkRadioAction *action,
e_shell_searchbar_set_search_text (searchbar, NULL);
}
-static gboolean
-shell_searchbar_resize_idle_cb (gpointer user_data)
-{
- GtkWidget *widget;
- EShellSearchbar *searchbar;
- GSList *iter, *widths = NULL, *witer;
- gint row, column, roww, maxw, child_left, child_top, allocated_width;
- gboolean needs_reposition = FALSE;
-
- widget = user_data;
- searchbar = E_SHELL_SEARCHBAR (widget);
- allocated_width = gtk_widget_get_allocated_width (widget);
-
- row = 0;
- column = 0;
- roww = 0;
- maxw = 0;
-
- for (iter = searchbar->priv->child_containers; iter != NULL; iter = iter->next) {
- GtkWidget *child = iter->data;
- gint minw = -1;
-
- if (!gtk_widget_get_visible (child))
- minw = 0;
- else
- gtk_widget_get_preferred_width (child, &minw, NULL);
-
- widths = g_slist_append (widths, GINT_TO_POINTER (minw));
-
- if (roww && minw) {
- roww += COLUMN_SPACING;
- column++;
- }
-
- roww += minw;
-
- if (minw > maxw)
- maxw = minw;
-
- if (roww > allocated_width) {
- row++;
- roww = minw;
- column = 0;
- }
-
- gtk_container_child_get (
- GTK_CONTAINER (widget), child,
- "left-attach", &child_left,
- "top-attach", &child_top,
- NULL);
-
- needs_reposition = needs_reposition || child_left != column || child_top != row;
-
- if (column == 0 && row > 0 && roww < maxw) {
- /* columns has same width, thus use the wider widget for calculations*/
- roww = maxw;
- }
- }
-
- if (needs_reposition) {
- row = 0;
- column = 0;
- roww = 0;
-
- for (iter = searchbar->priv->child_containers; iter; iter = iter->next) {
- gtk_container_remove (GTK_CONTAINER (widget), iter->data);
- }
-
- for (witer = widths, iter = searchbar->priv->child_containers; witer && iter; witer = witer->next, iter = iter->next) {
- GtkWidget *child = iter->data;
- gint w = GPOINTER_TO_INT (witer->data);
-
- if (roww && w) {
- roww += COLUMN_SPACING;
- column++;
- }
-
- roww += w;
-
- if (roww > allocated_width) {
- row++;
- roww = w;
- column = 0;
- }
-
- gtk_grid_attach (GTK_GRID (widget), child, column, row, 1, 1);
-
- if (column == 0 && row > 0 && roww < maxw)
- roww = maxw;
- }
- }
-
- g_slist_free (widths);
-
- searchbar->priv->resize_idle_id = 0;
- g_object_unref (searchbar);
-
- return FALSE;
-}
-
-static gboolean
-shell_searchbar_entry_focus_in_cb (GtkWidget *entry,
- GdkEvent *event,
- EShellSearchbar *searchbar)
-{
- /* to not change background when user changes search entry content */
- gtk_widget_set_name (entry, "searchbar_searchentry");
-
- return FALSE;
-}
-
-static gboolean
-shell_searchbar_entry_focus_out_cb (GtkWidget *entry,
- GdkEvent *event,
- EShellSearchbar *searchbar)
-{
- shell_searchbar_update_search_widgets (searchbar);
-
- return FALSE;
-}
-
static void
shell_searchbar_set_shell_view (EShellSearchbar *searchbar,
EShellView *shell_view)
@@ -771,16 +632,6 @@ shell_searchbar_dispose (GObject *object)
priv = E_SHELL_SEARCHBAR_GET_PRIVATE (object);
- if (priv->resize_idle_id) {
- g_source_remove (priv->resize_idle_id);
- priv->resize_idle_id = 0;
- }
-
- if (priv->child_containers) {
- g_slist_free_full (priv->child_containers, g_object_unref);
- priv->child_containers = NULL;
- }
-
if (priv->shell_view != NULL) {
g_object_remove_weak_pointer (
G_OBJECT (priv->shell_view), &priv->shell_view);
@@ -800,11 +651,6 @@ shell_searchbar_dispose (GObject *object)
priv->state_group = NULL;
}
- if (priv->css_provider) {
- g_object_unref (priv->css_provider);
- priv->css_provider = NULL;
- }
-
/* Chain up to parent's dispose() method. */
G_OBJECT_CLASS (e_shell_searchbar_parent_class)->dispose (object);
}
@@ -849,10 +695,7 @@ shell_searchbar_constructed (GObject *object)
shell_view, (GClosureNotify) NULL,
G_CONNECT_AFTER | G_CONNECT_SWAPPED);
- searchbar->priv->css_provider = gtk_css_provider_new ();
widget = searchbar->priv->search_entry;
- gtk_style_context_add_provider (gtk_widget_get_style_context (widget),
- GTK_STYLE_PROVIDER (searchbar->priv->css_provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
action = E_SHELL_WINDOW_ACTION_SEARCH_CLEAR (shell_window);
@@ -903,46 +746,6 @@ shell_searchbar_map (GtkWidget *widget)
}
static void
-shell_searchbar_size_allocate (GtkWidget *widget,
- GdkRectangle *allocation)
-{
- EShellSearchbar *searchbar;
-
- GTK_WIDGET_CLASS (e_shell_searchbar_parent_class)->size_allocate (widget, allocation);
-
- searchbar = E_SHELL_SEARCHBAR (widget);
-
- if (!searchbar->priv->resize_idle_id)
- searchbar->priv->resize_idle_id = g_idle_add (shell_searchbar_resize_idle_cb, g_object_ref (searchbar));
-}
-
-static void
-shell_searchbar_get_preferred_width (GtkWidget *widget,
- gint *minimum_width,
- gint *natural_width)
-{
- GList *children, *iter;
- gint max_minimum = 0, max_natural = 0;
-
- children = gtk_container_get_children (GTK_CONTAINER (widget));
- for (iter = children; iter != NULL; iter = iter->next) {
- GtkWidget *child = iter->data;
- gint minimum = 0, natural = 0;
-
- if (gtk_widget_get_visible (child)) {
- gtk_widget_get_preferred_width (child, &minimum, &natural);
- if (minimum > max_minimum)
- max_minimum = minimum;
- if (natural > max_natural)
- max_natural = natural;
- }
- }
-
- *minimum_width = max_minimum + COLUMN_SPACING;
- *natural_width = max_natural + COLUMN_SPACING;
-}
-
-static void
e_shell_searchbar_class_init (EShellSearchbarClass *class)
{
GObjectClass *object_class;
@@ -958,8 +761,6 @@ e_shell_searchbar_class_init (EShellSearchbarClass *class)
widget_class = GTK_WIDGET_CLASS (class);
widget_class->map = shell_searchbar_map;
- widget_class->size_allocate = shell_searchbar_size_allocate;
- widget_class->get_preferred_width = shell_searchbar_get_preferred_width;
g_object_class_install_property (
object_class,
@@ -1102,44 +903,34 @@ e_shell_searchbar_class_init (EShellSearchbarClass *class)
static void
e_shell_searchbar_init (EShellSearchbar *searchbar)
{
- GtkGrid *grid;
+ GtkBox *box;
GtkLabel *label;
GtkWidget *widget;
searchbar->priv = E_SHELL_SEARCHBAR_GET_PRIVATE (searchbar);
- searchbar->priv->child_containers = NULL;
- gtk_grid_set_column_spacing (GTK_GRID (searchbar), COLUMN_SPACING);
- gtk_grid_set_row_spacing (GTK_GRID (searchbar), 4);
+ gtk_box_set_spacing (GTK_BOX (searchbar), 24);
/* Filter Combo Widgets */
- grid = GTK_GRID (searchbar);
+ box = GTK_BOX (searchbar);
- widget = gtk_grid_new ();
- g_object_set (
- G_OBJECT (widget),
- "orientation", GTK_ORIENTATION_HORIZONTAL,
- "column-spacing", 3,
- "valign", GTK_ALIGN_CENTER,
- NULL);
- gtk_grid_attach (grid, widget, 0, 0, 1, 1);
- searchbar->priv->child_containers = g_slist_append (
- searchbar->priv->child_containers, g_object_ref (widget));
+ widget = gtk_hbox_new (FALSE, 3);
+ gtk_box_pack_start (box, widget, FALSE, FALSE, 0);
g_object_bind_property (
searchbar, "filter-visible",
widget, "visible",
G_BINDING_SYNC_CREATE);
- grid = GTK_GRID (widget);
+ box = GTK_BOX (widget);
/* Translators: The "Show:" label precedes a combo box that
* allows the user to filter the current view. Examples of
* items that appear in the combo box are "Unread Messages",
* "Important Messages", or "Active Appointments". */
widget = gtk_label_new_with_mnemonic (_("Sho_w:"));
- gtk_grid_attach (grid, widget, 0, 0, 1, 1);
+ gtk_box_pack_start (box, widget, FALSE, FALSE, 0);
gtk_widget_show (widget);
g_object_bind_property (
@@ -1151,38 +942,28 @@ e_shell_searchbar_init (EShellSearchbar *searchbar)
widget = e_action_combo_box_new ();
gtk_label_set_mnemonic_widget (label, widget);
- gtk_grid_attach (grid, widget, 1, 0, 1, 1);
+ gtk_box_pack_start (box, widget, FALSE, FALSE, 0);
searchbar->priv->filter_combo_box = widget;
gtk_widget_show (widget);
/* Search Entry Widgets */
- grid = GTK_GRID (searchbar);
-
- widget = gtk_grid_new ();
- g_object_set (
- G_OBJECT (widget),
- "orientation", GTK_ORIENTATION_HORIZONTAL,
- "column-spacing", 3,
- "valign", GTK_ALIGN_CENTER,
- "halign", GTK_ALIGN_FILL,
- "hexpand", TRUE,
- NULL);
- gtk_grid_attach (grid, widget, 1, 0, 1, 1);
- searchbar->priv->child_containers = g_slist_append (
- searchbar->priv->child_containers, g_object_ref (widget));
+ box = GTK_BOX (searchbar);
+
+ widget = gtk_hbox_new (FALSE, 3);
+ gtk_box_pack_start (box, widget, TRUE, TRUE, 0);
g_object_bind_property (
searchbar, "search-visible",
widget, "visible",
G_BINDING_SYNC_CREATE);
- grid = GTK_GRID (widget);
+ box = GTK_BOX (widget);
/* Translators: This is part of the quick search interface.
* example: Search: [_______________] in [ Current Folder ] */
widget = gtk_label_new_with_mnemonic (_("Sear_ch:"));
- gtk_grid_attach (grid, widget, 0, 0, 1, 1);
+ gtk_box_pack_start (box, widget, FALSE, FALSE, 0);
gtk_widget_show (widget);
g_object_bind_property (
@@ -1194,12 +975,7 @@ e_shell_searchbar_init (EShellSearchbar *searchbar)
widget = gtk_entry_new ();
gtk_label_set_mnemonic_widget (label, widget);
- g_object_set (
- G_OBJECT (widget),
- "halign", GTK_ALIGN_FILL,
- "hexpand", TRUE,
- NULL);
- gtk_grid_attach (grid, widget, 1, 0, 1, 1);
+ gtk_box_pack_start (box, widget, TRUE, TRUE, 0);
searchbar->priv->search_entry = widget;
gtk_widget_show (widget);
@@ -1233,49 +1009,31 @@ e_shell_searchbar_init (EShellSearchbar *searchbar)
G_CALLBACK (shell_searchbar_entry_key_press_cb),
searchbar);
- g_signal_connect (
- widget, "focus-in-event",
- G_CALLBACK (shell_searchbar_entry_focus_in_cb),
- searchbar);
-
- g_signal_connect (
- widget, "focus-out-event",
- G_CALLBACK (shell_searchbar_entry_focus_out_cb),
- searchbar);
-
/* Scope Combo Widgets */
- grid = GTK_GRID (searchbar);
+ box = GTK_BOX (searchbar);
- widget = gtk_grid_new ();
- g_object_set (
- G_OBJECT (widget),
- "orientation", GTK_ORIENTATION_HORIZONTAL,
- "column-spacing", 3,
- "valign", GTK_ALIGN_CENTER,
- NULL);
- gtk_grid_attach (grid, widget, 2, 0, 1, 1);
- searchbar->priv->child_containers = g_slist_append (
- searchbar->priv->child_containers, g_object_ref (widget));
+ widget = gtk_hbox_new (FALSE, 3);
+ gtk_box_pack_start (box, widget, FALSE, FALSE, 0);
g_object_bind_property (
searchbar, "scope-visible",
widget, "visible",
G_BINDING_SYNC_CREATE);
- grid = GTK_GRID (widget);
+ box = GTK_BOX (widget);
/* Translators: This is part of the quick search interface.
* example: Search: [_______________] in [ Current Folder ] */
widget = gtk_label_new_with_mnemonic (_("i_n"));
- gtk_grid_attach (grid, widget, 0, 0, 1, 1);
+ gtk_box_pack_start (box, widget, FALSE, FALSE, 0);
gtk_widget_show (widget);
label = GTK_LABEL (widget);
widget = e_action_combo_box_new ();
gtk_label_set_mnemonic_widget (label, widget);
- gtk_grid_attach (grid, widget, 1, 0, 1, 1);
+ gtk_box_pack_start (box, widget, FALSE, FALSE, 0);
searchbar->priv->scope_combo_box = widget;
gtk_widget_show (widget);
@@ -1303,10 +1061,7 @@ e_shell_searchbar_new (EShellView *shell_view)
g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
return g_object_new (
- E_TYPE_SHELL_SEARCHBAR,
- "shell-view", shell_view,
- "orientation", GTK_ORIENTATION_HORIZONTAL,
- NULL);
+ E_TYPE_SHELL_SEARCHBAR, "shell-view", shell_view, NULL);
}
/**
@@ -1339,7 +1094,7 @@ e_shell_searchbar_set_express_mode (EShellSearchbar *searchbar,
{
g_return_if_fail (E_IS_SHELL_SEARCHBAR (searchbar));
- if (searchbar->priv->express_mode == express_mode)
+ if ((searchbar->priv->express_mode ? 1 : 0) == (express_mode ? 1 : 0))
return;
searchbar->priv->express_mode = express_mode;
@@ -1379,7 +1134,7 @@ e_shell_searchbar_set_labels_visible (EShellSearchbar *searchbar,
{
g_return_if_fail (E_IS_SHELL_SEARCHBAR (searchbar));
- if (searchbar->priv->labels_visible == labels_visible)
+ if ((searchbar->priv->labels_visible ? 1 : 0) == (labels_visible ? 1 : 0))
return;
searchbar->priv->labels_visible = labels_visible;
@@ -1405,7 +1160,7 @@ e_shell_searchbar_set_filter_visible (EShellSearchbar *searchbar,
{
g_return_if_fail (E_IS_SHELL_SEARCHBAR (searchbar));
- if (searchbar->priv->filter_visible == filter_visible)
+ if ((searchbar->priv->filter_visible ? 1 : 0) == (filter_visible ? 1 : 0))
return;
searchbar->priv->filter_visible = filter_visible;
@@ -1535,7 +1290,7 @@ e_shell_searchbar_set_search_visible (EShellSearchbar *searchbar,
{
g_return_if_fail (E_IS_SHELL_SEARCHBAR (searchbar));
- if (searchbar->priv->search_visible == search_visible)
+ if ((searchbar->priv->search_visible ? 1 : 0) == (search_visible ? 1 : 0))
return;
searchbar->priv->search_visible = search_visible;
@@ -1579,7 +1334,7 @@ e_shell_searchbar_set_scope_visible (EShellSearchbar *searchbar,
{
g_return_if_fail (E_IS_SHELL_SEARCHBAR (searchbar));
- if (searchbar->priv->scope_visible == scope_visible)
+ if ((searchbar->priv->scope_visible ? 1 : 0) == (scope_visible ? 1 : 0))
return;
searchbar->priv->scope_visible = scope_visible;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]