[snappy] ui: receive drop events to load files
- From: Luis de Bethencourt <luisbg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [snappy] ui: receive drop events to load files
- Date: Mon, 11 Mar 2013 21:02:53 +0000 (UTC)
commit 592d6d3bd6a20944d90178d0d64a64c2ae0f6a39
Author: Luis de Bethencourt <luis debethencourt com>
Date: Mon Mar 11 17:02:39 2013 -0400
ui: receive drop events to load files
src/user_interface.c | 26 ++++++++++++++++++++++++++
src/user_interface.h | 8 ++++++++
2 files changed, 34 insertions(+), 0 deletions(-)
---
diff --git a/src/user_interface.c b/src/user_interface.c
index 3d3a619..75740df 100644
--- a/src/user_interface.c
+++ b/src/user_interface.c
@@ -1161,6 +1161,26 @@ interface_load_uri (UserInterface * ui, gchar * uri)
}
void
+interface_on_drop_cb (GtkWidget * widget,
+ GdkDragContext * context,
+ gint x,
+ gint y,
+ GtkSelectionData * data, guint info, guint _time, UserInterface * ui)
+{
+ char **list;
+
+ list = g_uri_list_extract_uris (gtk_selection_data_get_data (data));
+
+ engine_open_uri (ui->engine, list[0]);
+ interface_load_uri (ui, list[0]);
+ engine_play (ui->engine);
+
+ if (!CLUTTER_ACTOR_IS_VISIBLE (ui->texture)) {
+ clutter_actor_show (ui->texture);
+ }
+}
+
+void
interface_play_next_or_prev (UserInterface * ui, gboolean next)
{
GList *element;
@@ -1302,6 +1322,12 @@ interface_start (UserInterface * ui, gchar * uri)
if (!ui->fileuri) {
clutter_actor_hide (ui->texture);
}
+
+ gtk_drag_dest_set (GTK_WIDGET (ui->box), GTK_DEST_DEFAULT_ALL,
+ drop_target_table, G_N_ELEMENTS (drop_target_table),
+ GDK_ACTION_COPY | GDK_ACTION_MOVE);
+ g_signal_connect (G_OBJECT (ui->box), "drag_data_received",
+ G_CALLBACK (interface_on_drop_cb), ui);
}
gboolean
diff --git a/src/user_interface.h b/src/user_interface.h
index 75d7863..01bf844 100644
--- a/src/user_interface.h
+++ b/src/user_interface.h
@@ -129,10 +129,18 @@ struct _UserInterface
ScreenSaver *screensaver;
};
+static const GtkTargetEntry drop_target_table[] = {
+ {(gchar *) "text/uri-list", 0, 0}
+};
+
+
// Declaration of non-static functions
void interface_init (UserInterface * ui);
gboolean interface_is_it_last (UserInterface * ui);
gboolean interface_load_uri (UserInterface * ui, gchar * uri);
+void interface_on_drop_cb (GtkWidget * widget, GdkDragContext * context, gint x,
+ gint y, GtkSelectionData * data, guint info, guint _time,
+ UserInterface * ui);
void interface_play_next_or_prev (UserInterface * ui, gboolean next);
void interface_start (UserInterface * ui, gchar * uri);
gboolean interface_update_controls (UserInterface * ui);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]