Kaydet (Commit) 9cff8504 authored tarafından Nick Treleaven's avatar Nick Treleaven

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().


git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@1017 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst 0a27307c
2006-11-22 Nick Treleaven <nick.treleaven@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@uvena.de> 2006-11-21 Enrico Tröger <enrico.troeger@uvena.de>
* src/callbacks.c, src/callbacks.h, src/document.c, src/main.c, * src/callbacks.c, src/callbacks.h, src/document.c, src/main.c,
......
...@@ -259,13 +259,7 @@ static gint document_create_new_sci(const gchar *filename) ...@@ -259,13 +259,7 @@ static gint document_create_new_sci(const gchar *filename)
gint tabnum; gint tabnum;
gint cur_pages = gtk_notebook_get_n_pages(GTK_NOTEBOOK(app->notebook)); 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(); gint idx = document_get_cur_idx();
// remove the empty document and open a new one // remove the empty document and open a new one
...@@ -364,7 +358,7 @@ gboolean document_remove(guint page_num) ...@@ -364,7 +358,7 @@ gboolean document_remove(guint page_num)
{ {
return FALSE; return FALSE;
} }
gtk_notebook_remove_page(GTK_NOTEBOOK(app->notebook), page_num); notebook_remove_page(page_num);
treeviews_openfiles_remove(doc_list[idx].iter); treeviews_openfiles_remove(doc_list[idx].iter);
if (GTK_IS_WIDGET(doc_list[idx].tag_tree)) if (GTK_IS_WIDGET(doc_list[idx].tag_tree))
{ {
...@@ -387,10 +381,6 @@ gboolean document_remove(guint page_num) ...@@ -387,10 +381,6 @@ gboolean document_remove(guint page_num)
document_undo_clear(idx); document_undo_clear(idx);
if (gtk_notebook_get_n_pages(GTK_NOTEBOOK(app->notebook)) == 0) 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); ui_update_tag_list(-1, FALSE);
//on_notebook1_switch_page(GTK_NOTEBOOK(app->notebook), NULL, 0, NULL); //on_notebook1_switch_page(GTK_NOTEBOOK(app->notebook), NULL, 0, NULL);
ui_set_window_title(-1); ui_set_window_title(-1);
......
...@@ -271,6 +271,27 @@ notebook_find_tab_num_at_pos(GtkNotebook *notebook, gint x, gint y) ...@@ -271,6 +271,27 @@ notebook_find_tab_num_at_pos(GtkNotebook *notebook, gint x, gint y)
} }
// 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 */ /* Returns index of notebook page, or -1 on error */
gint notebook_new_tab(gint doc_idx, gchar *title, GtkWidget *page) gint notebook_new_tab(gint doc_idx, gchar *title, GtkWidget *page)
{ {
...@@ -308,6 +329,8 @@ gint notebook_new_tab(gint doc_idx, gchar *title, GtkWidget *page) ...@@ -308,6 +329,8 @@ gint notebook_new_tab(gint doc_idx, gchar *title, GtkWidget *page)
tabnum = gtk_notebook_insert_page_menu(GTK_NOTEBOOK(app->notebook), tabnum = gtk_notebook_insert_page_menu(GTK_NOTEBOOK(app->notebook),
GTK_WIDGET(page), hbox, this->tabmenu_label, 0); GTK_WIDGET(page), hbox, this->tabmenu_label, 0);
tab_count_changed();
// signal for clicking the tab-close button // signal for clicking the tab-close button
g_signal_connect(G_OBJECT(but), "clicked", g_signal_connect(G_OBJECT(but), "clicked",
G_CALLBACK(notebook_tab_close_clicked_cb), page); G_CALLBACK(notebook_tab_close_clicked_cb), page);
...@@ -332,23 +355,11 @@ notebook_tab_close_clicked_cb(GtkButton *button, gpointer user_data) ...@@ -332,23 +355,11 @@ notebook_tab_close_clicked_cb(GtkButton *button, gpointer user_data)
} }
/* Enables DnD for dropping files into the empty notebook widget */ // Always use this instead of gtk_notebook_remove_page().
void notebook_enable_dnd_for_dropping_files() 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);
}
/* 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, gtk_notebook_remove_page(GTK_NOTEBOOK(app->notebook), page_num);
drag_targets, G_N_ELEMENTS(drag_targets), GDK_ACTION_MOVE); tab_count_changed();
} }
...@@ -373,3 +384,4 @@ on_window_drag_data_received(GtkWidget *widget, GdkDragContext *drag_context, ...@@ -373,3 +384,4 @@ on_window_drag_data_received(GtkWidget *widget, GdkDragContext *drag_context,
gtk_drag_finish(drag_context, success, FALSE, time); gtk_drag_finish(drag_context, success, FALSE, time);
} }
...@@ -29,12 +29,7 @@ void notebook_init(); ...@@ -29,12 +29,7 @@ void notebook_init();
/* Returns index of notebook page, or -1 on error */ /* Returns index of notebook page, or -1 on error */
gint notebook_new_tab(gint doc_idx, gchar *title, GtkWidget *page); gint notebook_new_tab(gint doc_idx, gchar *title, GtkWidget *page);
/* Enables DnD for dropping files into the empty notebook widget */ // Always use this instead of gtk_notebook_remove_page().
void notebook_enable_dnd_for_dropping_files(); 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 #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment