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
This commit is contained in:
parent
0a27307c98
commit
9cff8504ea
@ -1,3 +1,12 @@
|
||||
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>
|
||||
|
||||
* 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)
|
||||
gint tabnum;
|
||||
gint cur_pages = gtk_notebook_get_n_pages(GTK_NOTEBOOK(app->notebook));
|
||||
|
||||
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)
|
||||
if (cur_pages == 1)
|
||||
{
|
||||
gint idx = document_get_cur_idx();
|
||||
// remove the empty document and open a new one
|
||||
@ -364,7 +358,7 @@ gboolean document_remove(guint page_num)
|
||||
{
|
||||
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 @@ gboolean document_remove(guint page_num)
|
||||
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);
|
||||
|
@ -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 */
|
||||
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),
|
||||
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,23 +355,11 @@ notebook_tab_close_clicked_cb(GtkButton *button, gpointer user_data)
|
||||
}
|
||||
|
||||
|
||||
/* 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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* 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);
|
||||
gtk_notebook_remove_page(GTK_NOTEBOOK(app->notebook), page_num);
|
||||
tab_count_changed();
|
||||
}
|
||||
|
||||
|
||||
@ -373,3 +384,4 @@ on_window_drag_data_received(GtkWidget *widget, GdkDragContext *drag_context,
|
||||
gtk_drag_finish(drag_context, success, FALSE, time);
|
||||
}
|
||||
|
||||
|
||||
|
@ -29,12 +29,7 @@ void notebook_init();
|
||||
/* 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();
|
||||
// Always use this instead of gtk_notebook_remove_page().
|
||||
void notebook_remove_page(gint page_num);
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user