#include "config.h"
#include "gtkfilechooserwidget.h"
+#include "gtkfilechooserwidgetprivate.h"
#include "gtkbindings.h"
#include "gtkbutton.h"
GtkWidget *location_entry;
LocationMode location_mode;
+ GtkWidget *external_entry;
+
/* Handles */
GCancellable *file_list_drag_data_received_cancellable;
GCancellable *update_current_folder_cancellable;
}
static void
-location_entry_create (GtkFileChooserWidget *impl)
+location_entry_setup (GtkFileChooserWidget *impl)
{
GtkFileChooserWidgetPrivate *priv = impl->priv;
- if (!priv->location_entry)
- {
- priv->location_entry = _gtk_file_chooser_entry_new (TRUE);
- if (priv->action == GTK_FILE_CHOOSER_ACTION_OPEN ||
- priv->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
- gtk_entry_set_placeholder_text (GTK_ENTRY (priv->location_entry), _("Location"));
+ if (priv->action == GTK_FILE_CHOOSER_ACTION_OPEN ||
+ priv->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
+ gtk_entry_set_placeholder_text (GTK_ENTRY (priv->location_entry), _("Location"));
- g_signal_connect (priv->location_entry, "changed",
- G_CALLBACK (location_entry_changed_cb), impl);
- }
+ g_signal_connect (priv->location_entry, "changed",
+ G_CALLBACK (location_entry_changed_cb), impl);
_gtk_file_chooser_entry_set_local_only (GTK_FILE_CHOOSER_ENTRY (priv->location_entry), priv->local_only);
_gtk_file_chooser_entry_set_action (GTK_FILE_CHOOSER_ENTRY (priv->location_entry), priv->action);
gtk_entry_set_activates_default (GTK_ENTRY (priv->location_entry), TRUE);
}
+static void
+location_entry_disconnect (GtkFileChooserWidget *impl)
+{
+ GtkFileChooserWidgetPrivate *priv = impl->priv;
+
+ if (priv->location_entry)
+ g_signal_handlers_disconnect_by_func (priv->location_entry, location_entry_changed_cb, impl);
+}
+
+static void
+location_entry_create (GtkFileChooserWidget *impl)
+{
+ GtkFileChooserWidgetPrivate *priv = impl->priv;
+
+ if (!priv->location_entry)
+ {
+ priv->location_entry = _gtk_file_chooser_entry_new (TRUE);
+ location_entry_setup (impl);
+ }
+}
+
/* Creates the widgets specific to Save mode */
static void
save_widgets_create (GtkFileChooserWidget *impl)
location_switch_to_path_bar (impl);
+ if (priv->external_entry)
+ {
+ location_entry_disconnect (impl);
+ priv->location_entry = priv->external_entry;
+ location_entry_setup (impl);
+ return;
+ }
+
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
gtk_style_context_add_class (gtk_widget_get_style_context (vbox), "search-bar");
{
GtkFileChooserWidgetPrivate *priv = impl->priv;
+ if (priv->external_entry && priv->external_entry == priv->location_entry)
+ {
+ location_entry_disconnect (impl);
+ priv->location_entry = NULL;
+ }
+
if (priv->save_widgets == NULL)
return;
priv->bookmarks_manager = NULL;
}
+ if (priv->external_entry && priv->location_entry == priv->external_entry)
+ {
+ location_entry_disconnect (impl);
+ priv->external_entry = NULL;
+ }
+
G_OBJECT_CLASS (gtk_file_chooser_widget_parent_class)->dispose (object);
}
gtk_popover_set_default_widget (GTK_POPOVER (impl->priv->new_folder_popover), impl->priv->new_folder_create_button);
}
+void
+gtk_file_chooser_widget_set_save_entry (GtkFileChooserWidget *impl,
+ GtkWidget *entry)
+{
+ GtkFileChooserWidgetPrivate *priv = impl->priv;
+
+ g_return_if_fail (GTK_IS_FILE_CHOOSER_WIDGET (impl));
+ g_return_if_fail (GTK_IS_FILE_CHOOSER_ENTRY (entry));
+
+ priv->external_entry = entry;
+
+ if (priv->action == GTK_FILE_CHOOSER_ACTION_SAVE ||
+ priv->action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
+ {
+ save_widgets_destroy (impl);
+ save_widgets_create (impl);
+ }
+}
+
static void
gtk_file_chooser_widget_init (GtkFileChooserWidget *impl)
{
--- /dev/null
+/* gtkfilechooserwidgetprivate.h
+ *
+ * Copyright (C) 2015 Red Hat
+ *
+ * This file is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This file is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors: Matthias Clasen
+ */
+
+#ifndef __GTK_FILE_CHOOSER_WIDGET_PRIVATE_H__
+#define __GTK_FILE_CHOOSER_WIDGET_PRIVATE_H__
+
+#include <glib.h>
+#include "gtkfilechooserwidget.h"
+
+G_BEGIN_DECLS
+
+void
+gtk_file_chooser_widget_set_save_entry (GtkFileChooserWidget *chooser,
+ GtkWidget *entry);
+
+G_END_DECLS
+
+#endif /* __GTK_FILE_CHOOSER_WIDGET_PRIVATE_H__ */