SF.net SVN: geany: [1004] trunk
eht16 at users.sourceforge.net
eht16 at xxxxx
Wed Nov 15 23:12:14 UTC 2006
Revision: 1004
http://svn.sourceforge.net/geany/?rev=1004&view=rev
Author: eht16
Date: 2006-11-15 15:12:13 -0800 (Wed, 15 Nov 2006)
Log Message:
-----------
Enabled drag and drop for the whole main window to be able to drop files even if no tabs are open.
Moved code for getting the file list to document_open_file_list().
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/callbacks.c
trunk/src/callbacks.h
trunk/src/document.c
trunk/src/document.h
trunk/src/main.c
trunk/src/sci_cb.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2006-11-15 18:21:46 UTC (rev 1003)
+++ trunk/ChangeLog 2006-11-15 23:12:13 UTC (rev 1004)
@@ -3,6 +3,11 @@
* src/vte.c: Don't unload the VTE module on exit to avoid crashes on
some systems.
* src/main.c: Fixed small memory leak.
+ * src/callbacks.c, src/callbacks.h, src/document.c, src/document.h,
+ src/main.c, src/sci_cb.c:
+ Enabled drag and drop for the whole main window to be able to drop
+ files even if no tabs are open.
+ Moved code for getting the file list to document_open_file_list().
2006-11-15 Frank Lanitz <frank at frank.uvena.de>
Modified: trunk/src/callbacks.c
===================================================================
--- trunk/src/callbacks.c 2006-11-15 18:21:46 UTC (rev 1003)
+++ trunk/src/callbacks.c 2006-11-15 23:12:13 UTC (rev 1004)
@@ -2068,3 +2068,25 @@
}
+void
+on_window_drag_data_received
+ (GtkWidget *widget, GdkDragContext *drag_context,
+ gint x, gint y, GtkSelectionData *data, guint info,
+ guint time, gpointer user_data)
+{
+ gboolean success = FALSE;
+
+ if (data->length > 0 && data->format == 8)
+ {
+ if (drag_context->action == GDK_ACTION_ASK)
+ {
+ drag_context->action = GDK_ACTION_COPY;
+ }
+
+ document_open_file_list(data->data, data->length);
+
+ success = TRUE;
+ }
+ gtk_drag_finish(drag_context, success, FALSE, time);
+}
+
Modified: trunk/src/callbacks.h
===================================================================
--- trunk/src/callbacks.h 2006-11-15 18:21:46 UTC (rev 1003)
+++ trunk/src/callbacks.h 2006-11-15 23:12:13 UTC (rev 1004)
@@ -551,3 +551,9 @@
on_menu_toggle_line_commentation1_activate
(GtkMenuItem *menuitem,
gpointer user_data);
+
+void
+on_window_drag_data_received
+ (GtkWidget *widget, GdkDragContext *drag_context,
+ gint x, gint y, GtkSelectionData *data, guint info,
+ guint time, gpointer user_data);
Modified: trunk/src/document.c
===================================================================
--- trunk/src/document.c 2006-11-15 18:21:46 UTC (rev 1003)
+++ trunk/src/document.c 2006-11-15 23:12:13 UTC (rev 1004)
@@ -648,9 +648,9 @@
if (app->main_window_realized)
dialogs_show_msgbox(GTK_MESSAGE_WARNING, warn_msg, utf8_filename);
-
+
msgwin_status_add(warn_msg, utf8_filename);
-
+
// set the file to read-only mode because saving it is probably dangerous
readonly = TRUE;
}
@@ -763,6 +763,40 @@
}
+/* Takes a new line separated list of filename URIs and opens each file.
+ * length is the length of the string or -1 if it should be detected */
+void document_open_file_list(const gchar *data, gsize length)
+{
+ gint i;
+ gchar *filename;
+ gchar **list;
+
+ if (data == NULL) return;
+
+ if (length == -1)
+ length = strlen(data);
+
+ switch (utils_get_line_endings((gchar*) data, length))
+ {
+ case SC_EOL_CR: list = g_strsplit(data, "\r", 0); break;
+ case SC_EOL_CRLF: list = g_strsplit(data, "\r\n", 0); break;
+ case SC_EOL_LF: list = g_strsplit(data, "\n", 0); break;
+ default: list = g_strsplit(data, "\n", 0);
+ }
+
+ for (i = 0; ; i++)
+ {
+ if (list[i] == NULL) break;
+ filename = g_filename_from_uri(list[i], NULL, NULL);
+ if (filename == NULL) continue;
+ document_open_file(-1, filename, 0, FALSE, NULL, NULL);
+ g_free(filename);
+ }
+
+ g_strfreev(list);
+}
+
+
gint document_reload_file(gint idx, const gchar *forced_enc)
{
gint pos = 0;
Modified: trunk/src/document.h
===================================================================
--- trunk/src/document.h 2006-11-15 18:21:46 UTC (rev 1003)
+++ trunk/src/document.h 2006-11-15 23:12:13 UTC (rev 1004)
@@ -130,6 +130,12 @@
*/
int document_open_file(gint, const gchar*, gint, gboolean, filetype*, const gchar*);
+
+/* Takes a new line separated list of filename URIs and opens each file.
+ * length is the length of the string or -1 if it should be detected */
+void document_open_file_list(const gchar *data, gsize length);
+
+
int document_reload_file(gint idx, const gchar *forced_enc);
Modified: trunk/src/main.c
===================================================================
--- trunk/src/main.c 2006-11-15 18:21:46 UTC (rev 1003)
+++ trunk/src/main.c 2006-11-15 23:12:13 UTC (rev 1004)
@@ -554,6 +554,21 @@
g_signal_connect(G_OBJECT(app->window), "key-press-event", G_CALLBACK(on_window_key_press_event), NULL);
g_signal_connect(G_OBJECT(app->toolbar), "button-press-event", G_CALLBACK(toolbar_popup_menu), NULL);
+ /* enable DnD files somewhere in the main window */
+ {
+ GtkTargetEntry targets[] = {
+ { "STRING", 0, 0 },
+ { "UTF8_STRING", 0, 0 },
+ { "text/plain", 0, 0 },
+ { "text/uri-list", 0, 0 }
+ };
+ gtk_drag_dest_set(app->window, GTK_DEST_DEFAULT_ALL, targets,
+ G_N_ELEMENTS(targets),
+ GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK | GDK_ACTION_ASK);
+ g_signal_connect(G_OBJECT(app->window), "drag-data-received",
+ G_CALLBACK(on_window_drag_data_received), NULL);
+ }
+
treeviews_prepare_openfiles();
treeviews_create_taglist_popup_menu();
treeviews_create_openfiles_popup_menu();
Modified: trunk/src/sci_cb.c
===================================================================
--- trunk/src/sci_cb.c 2006-11-15 18:21:46 UTC (rev 1003)
+++ trunk/src/sci_cb.c 2006-11-15 23:12:13 UTC (rev 1004)
@@ -269,30 +269,11 @@
#endif
case SCN_URIDROPPED:
{
- if (nt->text != NULL && strlen(nt->text) > 0)
+ if (nt->text != NULL)
{
- gint i;
- gchar *filename;
- gchar **list;
-
- switch (utils_get_line_endings((gchar*) nt->text, strlen(nt->text)))
- {
- case SC_EOL_CR: list = g_strsplit(nt->text, "\r", 0); break;
- case SC_EOL_CRLF: list = g_strsplit(nt->text, "\r\n", 0); break;
- case SC_EOL_LF: list = g_strsplit(nt->text, "\n", 0); break;
- default: list = g_strsplit(nt->text, "\n", 0);
- }
-
- for (i = 0; ; i++)
- {
- if (list[i] == NULL) break;
- filename = g_filename_from_uri(list[i], NULL, NULL);
- if (filename == NULL) continue;
- document_open_file(-1, filename, 0, FALSE, NULL, NULL);
- g_free(filename);
- }
-
- g_strfreev(list);
+ gsize len = strlen(nt->text);
+ if (len > 0)
+ document_open_file_list(nt->text, len);
}
break;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Commits
mailing list