Revision: 1015 http://svn.sourceforge.net/geany/?rev=1015&view=rev Author: eht16 Date: 2006-11-21 10:39:23 -0800 (Tue, 21 Nov 2006)
Log Message: ----------- Removed DnD handler for the main window (not very useful). Fixed broken tab reordering by only enabling DnD for dropping files when there are no open file tabs, otherwise disable it and enable DnD for moving file tabs. Dropping files into Geany when file tabs are open still works because then it is handled by the Scintilla widget.
Modified Paths: -------------- trunk/ChangeLog trunk/src/callbacks.c trunk/src/callbacks.h trunk/src/document.c trunk/src/main.c trunk/src/notebook.c trunk/src/notebook.h
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2006-11-19 21:53:40 UTC (rev 1014) +++ trunk/ChangeLog 2006-11-21 18:39:23 UTC (rev 1015) @@ -1,3 +1,15 @@ +2006-11-21 Enrico Tröger enrico.troeger@uvena.de + + * src/callbacks.c, src/callbacks.h, src/document.c, src/main.c, + src/notebook.c, src/notebook.h: + Removed DnD handler for the main window (not very useful). + Fixed broken tab reordering by only enabling DnD for dropping files + when there are no open file tabs, otherwise disable it and enable + DnD for moving file tabs. Dropping files into Geany when file tabs + are open still works because then it is handled by the Scintilla + widget. + + 2006-11-18 Nick Treleaven nick.treleaven@btinternet.com
* src/sciwrappers.c, src/sciwrappers.h:
Modified: trunk/src/callbacks.c =================================================================== --- trunk/src/callbacks.c 2006-11-19 21:53:40 UTC (rev 1014) +++ trunk/src/callbacks.c 2006-11-21 18:39:23 UTC (rev 1015) @@ -2067,26 +2067,3 @@ } }
- -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((const gchar *)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-19 21:53:40 UTC (rev 1014) +++ trunk/src/callbacks.h 2006-11-21 18:39:23 UTC (rev 1015) @@ -551,9 +551,3 @@ 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-19 21:53:40 UTC (rev 1014) +++ trunk/src/document.c 2006-11-21 18:39:23 UTC (rev 1015) @@ -257,9 +257,16 @@ gint new_idx; document *this; gint tabnum; + gint cur_pages = gtk_notebook_get_n_pages(GTK_NOTEBOOK(app->notebook));
- if (gtk_notebook_get_n_pages(GTK_NOTEBOOK(app->notebook)) == 1) + if (cur_pages == 0) { + // now we get the first file tab so enable moving of file tabs and + // disable Dnd for dropping files + notebook_disable_dnd_for_dropping_files(); + } + else if (cur_pages == 1) + { gint idx = document_get_cur_idx(); // remove the empty document and open a new one if (doc_list[idx].file_name == NULL && ! doc_list[idx].changed) document_remove(0); @@ -380,6 +387,10 @@ document_undo_clear(idx); if (gtk_notebook_get_n_pages(GTK_NOTEBOOK(app->notebook)) == 0) { + // no more open file tabs so disable moving of file tabs and + // enable Dnd for dropping files + notebook_enable_dnd_for_dropping_files(); + ui_update_tag_list(-1, FALSE); //on_notebook1_switch_page(GTK_NOTEBOOK(app->notebook), NULL, 0, NULL); ui_set_window_title(-1); @@ -1007,7 +1018,7 @@ if (flags & SCFIND_REGEXP) search_backwards = FALSE;
first_visible_line = sci_get_first_visible_line(doc_list[idx].sci); - + selection_start = sci_get_selection_start(doc_list[idx].sci); selection_end = sci_get_selection_end(doc_list[idx].sci); if ((selection_end - selection_start) > 0)
Modified: trunk/src/main.c =================================================================== --- trunk/src/main.c 2006-11-19 21:53:40 UTC (rev 1014) +++ trunk/src/main.c 2006-11-21 18:39:23 UTC (rev 1015) @@ -554,26 +554,6 @@ 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); - gtk_drag_dest_set(app->notebook, 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); - g_signal_connect(G_OBJECT(app->notebook), "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/notebook.c =================================================================== --- trunk/src/notebook.c 2006-11-19 21:53:40 UTC (rev 1014) +++ trunk/src/notebook.c 2006-11-21 18:39:23 UTC (rev 1015) @@ -34,7 +34,14 @@ {GEANY_DND_NOTEBOOK_TAB_TYPE, GTK_TARGET_SAME_APP | GTK_TARGET_SAME_WIDGET, 0} };
+static GtkTargetEntry files_drop_targets[] = { + { "STRING", 0, 0 }, + { "UTF8_STRING", 0, 0 }, + { "text/plain", 0, 0 }, + { "text/uri-list", 0, 0 } +};
+ static gboolean notebook_drag_motion_cb(GtkWidget *widget, GdkDragContext *dc, gint x, gint y, guint time, gpointer user_data); @@ -49,6 +56,11 @@ gpointer user_data); #endif
+static void +on_window_drag_data_received(GtkWidget *widget, GdkDragContext *drag_context, + gint x, gint y, GtkSelectionData *data, guint info, + guint time, gpointer user_data); + static gint notebook_find_tab_num_at_pos(GtkNotebook *notebook, gint x, gint y);
@@ -74,6 +86,9 @@ g_signal_connect_after(G_OBJECT(app->notebook), "button-release-event", G_CALLBACK(focus_sci), NULL);
+ g_signal_connect(G_OBJECT(app->notebook), "drag-data-received", + G_CALLBACK(on_window_drag_data_received), NULL); + setup_tab_dnd(); }
@@ -315,3 +330,46 @@ GTK_WIDGET(user_data)); document_remove(cur_page); } + + +/* Enables DnD for dropping files into the empty notebook widget */ +void notebook_enable_dnd_for_dropping_files() +{ + gtk_drag_dest_set(app->notebook, GTK_DEST_DEFAULT_ALL, + files_drop_targets, G_N_ELEMENTS(files_drop_targets), + GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK | GDK_ACTION_ASK); + +} + + +/* Disables DnD for dropping files into the notebook widget and enables the DnD for moving file + * tabs. Files can still be dropped into the notebook widget because it will be handled by the + * active Scintilla Widget (only dropping to the tab bar is not possible but it should be ok) */ +void notebook_disable_dnd_for_dropping_files() +{ + gtk_drag_dest_set(app->notebook, GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP, + drag_targets, G_N_ELEMENTS(drag_targets), GDK_ACTION_MOVE); +} + + +static void +on_window_drag_data_received(GtkWidget *widget, GdkDragContext *drag_context, + gint x, gint y, GtkSelectionData *data, guint target_type, + 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((const gchar *)data->data, data->length); + + success = TRUE; + } + gtk_drag_finish(drag_context, success, FALSE, time); +} +
Modified: trunk/src/notebook.h =================================================================== --- trunk/src/notebook.h 2006-11-19 21:53:40 UTC (rev 1014) +++ trunk/src/notebook.h 2006-11-21 18:39:23 UTC (rev 1015) @@ -29,4 +29,12 @@ /* Returns index of notebook page, or -1 on error */ gint notebook_new_tab(gint doc_idx, gchar *title, GtkWidget *page);
+/* Enables DnD for dropping files into the empty notebook widget */ +void notebook_enable_dnd_for_dropping_files(); + +/* Disables DnD for dropping files into the notebook widget and enables the DnD for moving file + * tabs. Files can still be dropped into the notebook widget because it will be handled by the + * active Scintilla Widget (only dropping to the tab bar is not possible but it should be ok) */ +void notebook_disable_dnd_for_dropping_files(); + #endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.