diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2013-06-24 06:47:34 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2013-06-24 07:32:40 +0800 |
commit | d2bf13d734424b12f3a92791624aa637b11c8500 (patch) | |
tree | 032675c74bd67ff8867cfed81ee6a5531683a308 | |
parent | d9126cd9470657460f623d55bb558a6868700c7e (diff) | |
download | gsoc2013-evolution-d2bf13d734424b12f3a92791624aa637b11c8500.tar gsoc2013-evolution-d2bf13d734424b12f3a92791624aa637b11c8500.tar.gz gsoc2013-evolution-d2bf13d734424b12f3a92791624aa637b11c8500.tar.bz2 gsoc2013-evolution-d2bf13d734424b12f3a92791624aa637b11c8500.tar.lz gsoc2013-evolution-d2bf13d734424b12f3a92791624aa637b11c8500.tar.xz gsoc2013-evolution-d2bf13d734424b12f3a92791624aa637b11c8500.tar.zst gsoc2013-evolution-d2bf13d734424b12f3a92791624aa637b11c8500.zip |
EUrlEntry: Replace button with clickable inline icon.
Replace the big, bulky "open URL" button with a clickable icon directly
in the text entry field. This saves precious vertical space, especially
in the contact editor.
Also remove e_url_entry_get_entry() since EUrlEntry now IS a GtkEntry.
-rw-r--r-- | addressbook/gui/contact-editor/e-contact-editor.c | 16 | ||||
-rw-r--r-- | calendar/gui/dialogs/task-page.c | 15 | ||||
-rw-r--r-- | doc/reference/evolution-util/evolution-util-sections.txt | 1 | ||||
-rw-r--r-- | e-util/e-url-entry.c | 90 | ||||
-rw-r--r-- | e-util/e-url-entry.h | 5 |
5 files changed, 42 insertions, 85 deletions
diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c index a72d783095..8f7bc9e929 100644 --- a/addressbook/gui/contact-editor/e-contact-editor.c +++ b/addressbook/gui/contact-editor/e-contact-editor.c @@ -2549,8 +2549,7 @@ init_simple_field (EContactEditor *editor, gtk_text_view_get_buffer (GTK_TEXT_VIEW (widget))); } else if (E_IS_URL_ENTRY (widget)) { - changed_object = G_OBJECT ( - e_url_entry_get_entry (E_URL_ENTRY (widget))); + changed_object = G_OBJECT (widget); g_signal_connect_swapped ( changed_object, "activate", G_CALLBACK (entry_activated), editor); @@ -2607,9 +2606,9 @@ fill_in_simple_field (EContactEditor *editor, g_free (text); } else if (E_IS_URL_ENTRY (widget)) { - GtkWidget *entry = e_url_entry_get_entry (E_URL_ENTRY (widget)); - gchar *text = e_contact_get (contact, field_id); - gtk_entry_set_text (GTK_ENTRY (entry), STRING_MAKE_NON_NULL (text)); + gchar *text = e_contact_get (contact, field_id); + gtk_entry_set_text ( + GTK_ENTRY (widget), STRING_MAKE_NON_NULL (text)); g_free (text); } else if (E_IS_DATE_EDIT (widget)) { @@ -2737,8 +2736,7 @@ extract_simple_field (EContactEditor *editor, g_free (text); } else if (E_IS_URL_ENTRY (widget)) { - GtkWidget *entry = e_url_entry_get_entry (E_URL_ENTRY (widget)); - const gchar *text = gtk_entry_get_text (GTK_ENTRY (entry)); + const gchar *text = gtk_entry_get_text (GTK_ENTRY (widget)); e_contact_set (contact, field_id, (gchar *) text); } else if (E_IS_DATE_EDIT (widget)) { @@ -2854,10 +2852,6 @@ sensitize_simple_field (GtkWidget *widget, gtk_editable_set_editable (GTK_EDITABLE (widget), enabled); else if (GTK_IS_TEXT_VIEW (widget)) gtk_text_view_set_editable (GTK_TEXT_VIEW (widget), enabled); - else if (E_IS_URL_ENTRY (widget)) { - GtkWidget *entry = e_url_entry_get_entry (E_URL_ENTRY (widget)); - gtk_editable_set_editable (GTK_EDITABLE (entry), enabled); - } else if (E_IS_DATE_EDIT (widget)) e_date_edit_set_editable (E_DATE_EDIT (widget), enabled); else diff --git a/calendar/gui/dialogs/task-page.c b/calendar/gui/dialogs/task-page.c index fcc00fae5d..7971bfbe2c 100644 --- a/calendar/gui/dialogs/task-page.c +++ b/calendar/gui/dialogs/task-page.c @@ -268,7 +268,6 @@ clear_widgets (TaskPage *tpage) { TaskPagePrivate *priv = tpage->priv; CompEditor *editor; - GtkWidget *entry; editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (tpage)); @@ -292,8 +291,7 @@ clear_widgets (TaskPage *tpage) e_dialog_combo_box_set (priv->priority_combo, PRIORITY_UNDEFINED, priority_map); gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->percent_complete), 0); - entry = e_url_entry_get_entry (E_URL_ENTRY (priv->web_page_entry)); - gtk_entry_set_text (GTK_ENTRY (entry), ""); + gtk_entry_set_text (GTK_ENTRY (priv->web_page_entry), ""); } static gboolean @@ -349,7 +347,6 @@ sensitize_widgets (TaskPage *tpage) ECalClient *client; GtkActionGroup *action_group; GtkAction *action; - GtkWidget *entry; gboolean read_only, sens = TRUE, sensitize; editor = comp_editor_page_get_editor (COMP_EDITOR_PAGE (tpage)); @@ -400,8 +397,8 @@ sensitize_widgets (TaskPage *tpage) gtk_widget_set_sensitive (priv->percent_complete, !read_only); gtk_widget_set_sensitive (priv->classification_combo, !read_only); - entry = e_url_entry_get_entry (E_URL_ENTRY (priv->web_page_entry)); - gtk_editable_set_editable (GTK_EDITABLE (entry), !read_only); + gtk_editable_set_editable ( + GTK_EDITABLE (priv->web_page_entry), !read_only); gtk_widget_set_sensitive (priv->organizer, !read_only); gtk_widget_set_sensitive (priv->add, (!read_only && sens)); @@ -918,7 +915,7 @@ task_page_fill_widgets (CompEditorPage *page, /* URL */ e_cal_component_get_url (comp, &url); - gtk_entry_set_text (GTK_ENTRY (e_url_entry_get_entry (E_URL_ENTRY (priv->web_page_entry))), url ? url : ""); + gtk_entry_set_text (GTK_ENTRY (priv->web_page_entry), url ? url : ""); sensitize_widgets (tpage); @@ -1218,7 +1215,7 @@ task_page_fill_component (CompEditorPage *page, } /* URL. */ - text = gtk_entry_get_text (GTK_ENTRY (e_url_entry_get_entry (E_URL_ENTRY (priv->web_page_entry)))); + text = gtk_entry_get_text (GTK_ENTRY (priv->web_page_entry)); e_cal_component_set_url (comp, text); return TRUE; @@ -2554,7 +2551,7 @@ init_widgets (TaskPage *tpage) /* URL */ g_signal_connect_swapped ( - e_url_entry_get_entry (E_URL_ENTRY (priv->web_page_entry)), "changed", + priv->web_page_entry, "changed", G_CALLBACK (comp_editor_page_changed), tpage); action = comp_editor_get_action (editor, "view-time-zone"); diff --git a/doc/reference/evolution-util/evolution-util-sections.txt b/doc/reference/evolution-util/evolution-util-sections.txt index e657387d3f..77f380f03e 100644 --- a/doc/reference/evolution-util/evolution-util-sections.txt +++ b/doc/reference/evolution-util/evolution-util-sections.txt @@ -4364,7 +4364,6 @@ e_xml_get_translated_utf8_string_prop_by_name <TITLE>EUrlEntry</TITLE> EUrlEntry e_url_entry_new -e_url_entry_get_entry <SUBSECTION Standard> E_URL_ENTRY E_IS_URL_ENTRY diff --git a/e-util/e-url-entry.c b/e-util/e-url-entry.c index 231ac19dfe..5b90f4a14f 100644 --- a/e-util/e-url-entry.c +++ b/e-util/e-url-entry.c @@ -31,15 +31,12 @@ (G_TYPE_INSTANCE_GET_PRIVATE \ ((obj), E_TYPE_URL_ENTRY, EUrlEntryPrivate)) -struct _EUrlEntryPrivate { - GtkWidget *entry; - GtkWidget *button; -}; +#define ICON_POSITION GTK_ENTRY_ICON_SECONDARY G_DEFINE_TYPE ( EUrlEntry, e_url_entry, - GTK_TYPE_HBOX) + GTK_TYPE_ENTRY) static gboolean url_entry_text_to_sensitive (GBinding *binding, @@ -58,75 +55,54 @@ url_entry_text_to_sensitive (GBinding *binding, } static void -url_entry_button_clicked_cb (GtkButton *button, - EUrlEntry *url_entry) +url_entry_icon_release_cb (GtkEntry *entry, + GtkEntryIconPosition icon_position, + GdkEvent *event) { - const gchar *text; gpointer toplevel; - toplevel = gtk_widget_get_toplevel (GTK_WIDGET (url_entry)); + toplevel = gtk_widget_get_toplevel (GTK_WIDGET (entry)); toplevel = gtk_widget_is_toplevel (toplevel) ? toplevel : NULL; - text = gtk_entry_get_text (GTK_ENTRY (url_entry->priv->entry)); - - e_show_uri (toplevel, text); -} + if (icon_position == ICON_POSITION) { + const gchar *text; -static gboolean -url_entry_mnemonic_activate (GtkWidget *widget, - gboolean group_cycling) -{ - GtkWidget *entry; + text = gtk_entry_get_text (entry); + g_return_if_fail (text != NULL); - entry = e_url_entry_get_entry (E_URL_ENTRY (widget)); - - return gtk_widget_mnemonic_activate (entry, group_cycling); + e_show_uri (toplevel, text); + } } static void e_url_entry_class_init (EUrlEntryClass *class) { - GtkWidgetClass *widget_class; - - g_type_class_add_private (class, sizeof (EUrlEntryPrivate)); - - widget_class = GTK_WIDGET_CLASS (class); - widget_class->mnemonic_activate = url_entry_mnemonic_activate; } static void e_url_entry_init (EUrlEntry *url_entry) { - GtkWidget *widget; - - url_entry->priv = E_URL_ENTRY_GET_PRIVATE (url_entry); - - widget = gtk_entry_new (); - gtk_entry_set_placeholder_text ( - GTK_ENTRY (widget), _("Enter a URL here")); - gtk_box_pack_start (GTK_BOX (url_entry), widget, TRUE, TRUE, 0); - url_entry->priv->entry = widget; /* do not reference */ - gtk_widget_show (widget); - - widget = gtk_button_new (); - gtk_container_add ( - GTK_CONTAINER (widget), - gtk_image_new_from_stock ( - GTK_STOCK_JUMP_TO, - GTK_ICON_SIZE_BUTTON)); - gtk_widget_set_tooltip_text ( - widget, _("Click here to open the URL")); - gtk_box_pack_start (GTK_BOX (url_entry), widget, FALSE, FALSE, 0); - url_entry->priv->button = widget; /* do not reference */ - gtk_widget_show_all (widget); + GtkEntry *entry; + + entry = GTK_ENTRY (url_entry); + gtk_entry_set_icon_from_stock ( + entry, ICON_POSITION, GTK_STOCK_JUMP_TO); + + gtk_entry_set_icon_tooltip_text ( + entry, ICON_POSITION, _("Click here to open the URL")); + + gtk_entry_set_placeholder_text (entry, _("Enter a URL here")); + + /* XXX GtkEntryClass has no "icon_release" method pointer to + * override, so instead we have to connect to the signal. */ g_signal_connect ( - widget, "clicked", - G_CALLBACK (url_entry_button_clicked_cb), url_entry); + url_entry, "icon-release", + G_CALLBACK (url_entry_icon_release_cb), NULL); g_object_bind_property_full ( - url_entry->priv->entry, "text", - url_entry->priv->button, "sensitive", + url_entry, "text", + url_entry, "secondary-icon-sensitive", G_BINDING_SYNC_CREATE, url_entry_text_to_sensitive, (GBindingTransformFunc) NULL, @@ -139,11 +115,3 @@ e_url_entry_new (void) return g_object_new (E_TYPE_URL_ENTRY, NULL); } -GtkWidget * -e_url_entry_get_entry (EUrlEntry *url_entry) -{ - g_return_val_if_fail (E_IS_URL_ENTRY (url_entry), NULL); - - return url_entry->priv->entry; -} - diff --git a/e-util/e-url-entry.h b/e-util/e-url-entry.h index 6751f07755..50136ec110 100644 --- a/e-util/e-url-entry.h +++ b/e-util/e-url-entry.h @@ -51,17 +51,16 @@ typedef struct _EUrlEntryClass EUrlEntryClass; typedef struct _EUrlEntryPrivate EUrlEntryPrivate; struct _EUrlEntry { - GtkBox parent; + GtkEntry parent; EUrlEntryPrivate *priv; }; struct _EUrlEntryClass { - GtkBoxClass parent_class; + GtkEntryClass parent_class; }; GType e_url_entry_get_type (void) G_GNUC_CONST; GtkWidget * e_url_entry_new (void); -GtkWidget * e_url_entry_get_entry (EUrlEntry *url_entry); G_END_DECLS |