forked from AuroraMiddleware/gtk
gtk-demo: Add folders to the clipboard demo
This is handy for testing a case where folder dnd does not work with the file transfer portal. See #5348
This commit is contained in:
parent
af8ad1efe8
commit
ea3c58f0ec
@ -248,6 +248,38 @@ open_file_cb (GtkWidget *button)
|
|||||||
file_chooser_response, button);
|
file_chooser_response, button);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
folder_chooser_response (GObject *source,
|
||||||
|
GAsyncResult *result,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GtkFileDialog *dialog = GTK_FILE_DIALOG (source);
|
||||||
|
GtkButton *button = GTK_BUTTON (user_data);
|
||||||
|
GFile *file;
|
||||||
|
|
||||||
|
file = gtk_file_dialog_select_folder_finish (dialog, result, NULL);
|
||||||
|
if (file)
|
||||||
|
{
|
||||||
|
file_button_set_file (button, file);
|
||||||
|
g_object_unref (file);
|
||||||
|
|
||||||
|
update_copy_button_sensitivity (gtk_widget_get_ancestor (GTK_WIDGET (button), GTK_TYPE_STACK));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
open_folder_cb (GtkWidget *button)
|
||||||
|
{
|
||||||
|
GtkFileDialog *dialog;
|
||||||
|
|
||||||
|
dialog = gtk_file_dialog_new ();
|
||||||
|
|
||||||
|
gtk_file_dialog_select_folder (dialog,
|
||||||
|
GTK_WINDOW (gtk_widget_get_ancestor (button, GTK_TYPE_WINDOW)),
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
folder_chooser_response, button);
|
||||||
|
}
|
||||||
static void
|
static void
|
||||||
update_paste_button_sensitivity (GdkClipboard *clipboard,
|
update_paste_button_sensitivity (GdkClipboard *clipboard,
|
||||||
GtkWidget *paste_button)
|
GtkWidget *paste_button)
|
||||||
@ -346,6 +378,7 @@ do_clipboard (GtkWidget *do_widget)
|
|||||||
gtk_builder_cscope_add_callback (scope, source_changed_cb);
|
gtk_builder_cscope_add_callback (scope, source_changed_cb);
|
||||||
gtk_builder_cscope_add_callback (scope, text_changed_cb);
|
gtk_builder_cscope_add_callback (scope, text_changed_cb);
|
||||||
gtk_builder_cscope_add_callback (scope, open_file_cb);
|
gtk_builder_cscope_add_callback (scope, open_file_cb);
|
||||||
|
gtk_builder_cscope_add_callback (scope, open_folder_cb);
|
||||||
gtk_builder_cscope_add_callback (scope, on_drop);
|
gtk_builder_cscope_add_callback (scope, on_drop);
|
||||||
gtk_builder_cscope_add_callback (scope, drag_prepare);
|
gtk_builder_cscope_add_callback (scope, drag_prepare);
|
||||||
builder = gtk_builder_new ();
|
builder = gtk_builder_new ();
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
<item>Color</item>
|
<item>Color</item>
|
||||||
<item>Image</item>
|
<item>Image</item>
|
||||||
<item>File</item>
|
<item>File</item>
|
||||||
|
<item>Folder</item>
|
||||||
</items>
|
</items>
|
||||||
</object>
|
</object>
|
||||||
</property>
|
</property>
|
||||||
@ -166,6 +167,30 @@
|
|||||||
</property>
|
</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkStackPage">
|
||||||
|
<property name="name">Folder</property>
|
||||||
|
<property name="child">
|
||||||
|
<object class="GtkButton" id="source_folder">
|
||||||
|
<child>
|
||||||
|
<object class="GtkDragSource">
|
||||||
|
<property name="propagation-phase">capture</property>
|
||||||
|
<signal name="prepare" handler="drag_prepare"/>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<property name="valign">center</property>
|
||||||
|
<property name="child">
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="label">—</property>
|
||||||
|
<property name="xalign">0</property>
|
||||||
|
<property name="ellipsize">start</property>
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
|
<signal name="clicked" handler="open_folder_cb"/>
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
|
Loading…
Reference in New Issue
Block a user