[gtk+] file chooser: Set default widget in create folder popover
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] file chooser: Set default widget in create folder popover
- Date: Sun, 3 May 2015 00:34:51 +0000 (UTC)
commit adb58b2c84eb542f7971bd6f248e35c1e09bdcda
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Apr 17 00:14:28 2015 -0400
file chooser: Set default widget in create folder popover
This is using the new default widget functionality for
popovers to make Enter in the entry activate the Create
button.
https://bugzilla.gnome.org/show_bug.cgi?id=747664
gtk/gtkfilechooserwidget.c | 3 +++
gtk/gtkplacessidebar.c | 3 +++
gtk/ui/gtkfilechooserwidget.ui | 2 ++
3 files changed, 8 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c
index b90f3a5..eaaaf9b 100644
--- a/gtk/gtkfilechooserwidget.c
+++ b/gtk/gtkfilechooserwidget.c
@@ -82,6 +82,7 @@
#include "gtkmain.h"
#include "gtkscrollable.h"
#include "gtkadjustment.h"
+#include "gtkpopover.h"
#include <cairo-gobject.h>
#include <errno.h>
@@ -7588,6 +7589,8 @@ post_process_ui (GtkFileChooserWidget *impl)
* that priv->icon_size be already setup.
*/
set_icon_cell_renderer_fixed_size (impl);
+
+ gtk_popover_set_default_widget (GTK_POPOVER (impl->priv->new_folder_popover),
impl->priv->new_folder_create_button);
}
static void
diff --git a/gtk/gtkplacessidebar.c b/gtk/gtkplacessidebar.c
index 01a5c39..a5bc74b 100644
--- a/gtk/gtkplacessidebar.c
+++ b/gtk/gtkplacessidebar.c
@@ -2650,6 +2650,7 @@ create_rename_popover (GtkPlacesSidebar *sidebar)
"column-spacing", 6,
NULL);
entry = gtk_entry_new ();
+ gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
g_signal_connect (entry, "changed", G_CALLBACK (rename_entry_changed), sidebar);
str = g_strdup_printf ("<b>%s</b>", _("Name"));
label = gtk_label_new (str);
@@ -2658,6 +2659,7 @@ create_rename_popover (GtkPlacesSidebar *sidebar)
gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);
g_free (str);
button = gtk_button_new_with_mnemonic (_("_Rename"));
+ gtk_widget_set_can_default (button, TRUE);
gtk_style_context_add_class (gtk_widget_get_style_context (button), "suggested-action");
g_signal_connect (button, "clicked", G_CALLBACK (do_rename), sidebar);
error = gtk_label_new ("");
@@ -2667,6 +2669,7 @@ create_rename_popover (GtkPlacesSidebar *sidebar)
gtk_grid_attach (GTK_GRID (grid), button,1, 1, 1, 1);
gtk_grid_attach (GTK_GRID (grid), error, 0, 2, 2, 1);
gtk_widget_show_all (grid);
+ gtk_popover_set_default_widget (GTK_POPOVER (popover), button);
sidebar->rename_popover = popover;
sidebar->rename_entry = entry;
diff --git a/gtk/ui/gtkfilechooserwidget.ui b/gtk/ui/gtkfilechooserwidget.ui
index e935d07..cdecc73 100644
--- a/gtk/ui/gtkfilechooserwidget.ui
+++ b/gtk/ui/gtkfilechooserwidget.ui
@@ -388,6 +388,7 @@
<object class="GtkEntry" id="new_folder_name_entry">
<property name="visible">True</property>
<property name="width-chars">25</property>
+ <property name="activates_default">True</property>
<signal name="changed" handler="new_folder_name_changed"/>
</object>
<packing>
@@ -401,6 +402,7 @@
<property name="sensitive">False</property>
<property name="label" translatable="yes">_Create</property>
<property name="use_underline">True</property>
+ <property name="can_default">True</property>
<signal name="clicked" handler="new_folder_create_clicked"/>
<style>
<class name="suggested-action"/>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]