SF.net SVN: geany: [1017] trunk

ntrel at users.sourceforge.net ntrel at xxxxx
Wed Nov 22 16:07:18 UTC 2006


Revision: 1017
          http://svn.sourceforge.net/geany/?rev=1017&view=rev
Author:   ntrel
Date:     2006-11-22 08:07:18 -0800 (Wed, 22 Nov 2006)

Log Message:
-----------
Ensure tab DnD is enabled when tabs are added; use
notebook_remove_page() instead of gtk_notebook_remove_page().
Unified notebook_[en|dis]able_dnd_for_dropping_files() in
tab_count_changed().

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/document.c
    trunk/src/notebook.c
    trunk/src/notebook.h

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2006-11-21 19:20:21 UTC (rev 1016)
+++ trunk/ChangeLog	2006-11-22 16:07:18 UTC (rev 1017)
@@ -1,3 +1,12 @@
+2006-11-22  Nick Treleaven  <nick.treleaven at btinternet.com>
+
+ * src/notebook.c, src/notebook.h, src/document.c:
+   Ensure tab DnD is enabled when tabs are added; use
+   notebook_remove_page() instead of gtk_notebook_remove_page().
+   Unified notebook_[en|dis]able_dnd_for_dropping_files() in
+   tab_count_changed().
+
+
 2006-11-21  Enrico Tröger  <enrico.troeger at uvena.de>
 
  * src/callbacks.c, src/callbacks.h, src/document.c, src/main.c,

Modified: trunk/src/document.c
===================================================================
--- trunk/src/document.c	2006-11-21 19:20:21 UTC (rev 1016)
+++ trunk/src/document.c	2006-11-22 16:07:18 UTC (rev 1017)
@@ -259,14 +259,8 @@
 	gint tabnum;
 	gint cur_pages = gtk_notebook_get_n_pages(GTK_NOTEBOOK(app->notebook));
 
-	if (cur_pages == 0)
+	if (cur_pages == 1)
 	{
-		// 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);
@@ -364,7 +358,7 @@
 		{
 			return FALSE;
 		}
-		gtk_notebook_remove_page(GTK_NOTEBOOK(app->notebook), page_num);
+		notebook_remove_page(page_num);
 		treeviews_openfiles_remove(doc_list[idx].iter);
 		if (GTK_IS_WIDGET(doc_list[idx].tag_tree))
 		{
@@ -387,10 +381,6 @@
 		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);

Modified: trunk/src/notebook.c
===================================================================
--- trunk/src/notebook.c	2006-11-21 19:20:21 UTC (rev 1016)
+++ trunk/src/notebook.c	2006-11-22 16:07:18 UTC (rev 1017)
@@ -271,6 +271,27 @@
 }
 
 
+// call this whenever the number of tabs in app->notebook changes.
+static void tab_count_changed()
+{
+	if (gtk_notebook_get_n_pages(GTK_NOTEBOOK(app->notebook)) == 0)
+	{
+		/* Enables DnD for dropping files into the empty notebook widget */
+		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);
+	}
+	else
+	{
+		/* 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) */
+		gtk_drag_dest_set(app->notebook, GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP,
+			drag_targets, G_N_ELEMENTS(drag_targets), GDK_ACTION_MOVE);
+	}
+}
+
+
 /* Returns index of notebook page, or -1 on error */
 gint notebook_new_tab(gint doc_idx, gchar *title, GtkWidget *page)
 {
@@ -308,6 +329,8 @@
 		tabnum = gtk_notebook_insert_page_menu(GTK_NOTEBOOK(app->notebook),
 			GTK_WIDGET(page), hbox, this->tabmenu_label, 0);
 
+	tab_count_changed();
+
 	// signal for clicking the tab-close button
 	g_signal_connect(G_OBJECT(but), "clicked",
 		G_CALLBACK(notebook_tab_close_clicked_cb), page);
@@ -332,26 +355,14 @@
 }
 
 
-/* Enables DnD for dropping files into the empty notebook widget */
-void notebook_enable_dnd_for_dropping_files()
+// Always use this instead of gtk_notebook_remove_page().
+void notebook_remove_page(gint page_num)
 {
-	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);
-
+	gtk_notebook_remove_page(GTK_NOTEBOOK(app->notebook), page_num);
+	tab_count_changed();
 }
 
 
-/* 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,
@@ -373,3 +384,4 @@
 	gtk_drag_finish(drag_context, success, FALSE, time);
 }
 
+

Modified: trunk/src/notebook.h
===================================================================
--- trunk/src/notebook.h	2006-11-21 19:20:21 UTC (rev 1016)
+++ trunk/src/notebook.h	2006-11-22 16:07:18 UTC (rev 1017)
@@ -29,12 +29,7 @@
 /* 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();
+// Always use this instead of gtk_notebook_remove_page().
+void notebook_remove_page(gint page_num);
 
-/* 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.



More information about the Commits mailing list