Skip to content

Commit

Permalink
[gtk] Location entry in GtkFileChooserWidget should notify the choose…
Browse files Browse the repository at this point in the history
…r when it's been activated.

Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=3398
  • Loading branch information
bratsche committed Jan 31, 2014
1 parent 116a621 commit e2cb5ed
Show file tree
Hide file tree
Showing 2 changed files with 123 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/gtk+.py
Expand Up @@ -89,6 +89,7 @@ def __init__ (self):
# 'patches/gtk/0072-let-global-keyboard-shortcuts-pass-through.patch',
'patches/gtk/0073-disable-combobox-scrolling.patch',
'patches/gtk/0074-fix-NULL-pointer-in-clipboard.patch',
'patches/gtk/0075-filechooserwidget-location-entry-activation.patch',

# Bug 702841 - GdkQuartz does not distinguish Eisu, Kana and Space keys on Japanese keyrboard
# https://bugzilla.gnome.org/show_bug.cgi?id=702841
Expand Down
@@ -0,0 +1,122 @@
diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c
index f94f4d6..eeb501b 100644
--- a/gtk/gtkfilechooserdefault.c
+++ b/gtk/gtkfilechooserdefault.c
@@ -4409,17 +4409,26 @@ file_pane_create (GtkFileChooserDefault *impl,
}

static void
+on_folder_loaded (GtkFileChooserEntry *entry, GtkFileChooserDefault *chooser)
+{
+ gtk_file_chooser_default_should_respond (GTK_FILE_CHOOSER_EMBED (chooser));
+ g_signal_emit_by_name (chooser, "response-requested");
+}
+
+static void
location_entry_create (GtkFileChooserDefault *impl)
{
if (!impl->location_entry)
- impl->location_entry = _gtk_file_chooser_entry_new (TRUE);
+ {
+ impl->location_entry = _gtk_file_chooser_entry_new (TRUE);
+ g_signal_connect (impl->location_entry, "xam-load-folder", G_CALLBACK (on_folder_loaded), impl);
+ }

_gtk_file_chooser_entry_set_file_system (GTK_FILE_CHOOSER_ENTRY (impl->location_entry),
impl->file_system);
_gtk_file_chooser_entry_set_local_only (GTK_FILE_CHOOSER_ENTRY (impl->location_entry), impl->local_only);
_gtk_file_chooser_entry_set_action (GTK_FILE_CHOOSER_ENTRY (impl->location_entry), impl->action);
gtk_entry_set_width_chars (GTK_ENTRY (impl->location_entry), 45);
- gtk_entry_set_activates_default (GTK_ENTRY (impl->location_entry), TRUE);
}

/* Creates the widgets specific to Save mode */
diff --git a/gtk/gtkfilechooserdialog.c b/gtk/gtkfilechooserdialog.c
index c06fe3f..a0548a6 100644
--- a/gtk/gtkfilechooserdialog.c
+++ b/gtk/gtkfilechooserdialog.c
@@ -254,7 +254,7 @@ file_chooser_widget_response_requested (GtkWidget *widget,

g_list_free (children);
}
-
+
static GObject*
gtk_file_chooser_dialog_constructor (GType type,
guint n_construct_properties,
diff --git a/gtk/gtkfilechooserentry.c b/gtk/gtkfilechooserentry.c
index 3caa7b8..44cf665 100644
--- a/gtk/gtkfilechooserentry.c
+++ b/gtk/gtkfilechooserentry.c
@@ -28,6 +28,7 @@
#include "gtkfilechooserentry.h"
#include "gtklabel.h"
#include "gtkmain.h"
+#include "gtkmarshalers.h"
#include "gtkwindow.h"
#include "gtkintl.h"
#include "gtkalias.h"
@@ -45,6 +46,11 @@ struct _GtkFileChooserEntryClass
GtkEntryClass parent_class;
};

+enum {
+ XAM_LOAD_FOLDER,
+ LAST_SIGNAL
+};
+
/* Action to take when the current folder finishes loading (for explicit or automatic completion) */
typedef enum {
LOAD_COMPLETE_NOTHING,
@@ -168,6 +174,8 @@ static void pop_up_completion_feedback (GtkFileChooserEntry *chooser_entry,

static GtkEditableClass *parent_editable_iface;

+static guint signals[LAST_SIGNAL] = { 0 };
+
G_DEFINE_TYPE_WITH_CODE (GtkFileChooserEntry, _gtk_file_chooser_entry, GTK_TYPE_ENTRY,
G_IMPLEMENT_INTERFACE (GTK_TYPE_EDITABLE,
gtk_file_chooser_entry_iface_init))
@@ -188,6 +196,14 @@ _gtk_file_chooser_entry_class_init (GtkFileChooserEntryClass *class)
widget_class->focus_out_event = gtk_file_chooser_entry_focus_out_event;

entry_class->activate = gtk_file_chooser_entry_activate;
+
+ signals[XAM_LOAD_FOLDER] = g_signal_new (I_("xam-load-folder"),
+ G_OBJECT_CLASS_TYPE (gobject_class),
+ G_SIGNAL_RUN_LAST,
+ NULL,
+ NULL, NULL,
+ _gtk_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
}

static void
@@ -1301,6 +1317,7 @@ gtk_file_chooser_entry_activate (GtkEntry *entry)
GtkFileChooserEntry *chooser_entry = GTK_FILE_CHOOSER_ENTRY (entry);

commit_completion_and_refresh (chooser_entry);
+ g_signal_emit (chooser_entry, signals[XAM_LOAD_FOLDER], 0);
GTK_ENTRY_CLASS (_gtk_file_chooser_entry_parent_class)->activate (entry);
}

diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c
index d69d854..3ad8a19 100644
--- a/gtk/gtkfilechooserwidget.c
+++ b/gtk/gtkfilechooserwidget.c
@@ -24,6 +24,7 @@
#include "gtkfilechooserwidget.h"
#include "gtkfilechooserdefault.h"
#include "gtkfilechooserutils.h"
+#include "gtkmarshalers.h"
#include "gtktypebuiltins.h"
#include "gtkfilechooserembed.h"
#include "gtkintl.h"
@@ -101,7 +102,6 @@ gtk_file_chooser_widget_constructor (GType type,
gtk_widget_push_composite_child ();

priv->impl = _gtk_file_chooser_default_new ();
-
gtk_box_pack_start (GTK_BOX (object), priv->impl, TRUE, TRUE, 0);
gtk_widget_show (priv->impl);

0 comments on commit e2cb5ed

Please sign in to comment.