Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 793 lines (629 sloc) 21.569 kb
14e6966 @ntrel Added currently disabled drag reordering of notebook tabs
ntrel authored
1 /*
2 * notebook.c - this file is part of Geany, a fast and lightweight IDE
3 *
1c2c455 @b4n Update copyright information
b4n authored
4 * Copyright 2006-2012 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
5 * Copyright 2006-2012 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
14e6966 @ntrel Added currently disabled drag reordering of notebook tabs
ntrel authored
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
d80bc7c @b4n Update FSF address
b4n authored
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
14e6966 @ntrel Added currently disabled drag reordering of notebook tabs
ntrel authored
20 */
21
806dd5b @ntrel Add descriptions for all .c source files below the file header.
ntrel authored
22 /*
23 * Notebook tab Drag 'n' Drop reordering and tab management.
24 */
25
14e6966 @ntrel Added currently disabled drag reordering of notebook tabs
ntrel authored
26 #include "geany.h"
ddbb253 @techee Move MRU tab handing from keybindings.c to notebook.c because this is wh...
techee authored
27
28 #include <gdk/gdkkeysyms.h>
29
14e6966 @ntrel Added currently disabled drag reordering of notebook tabs
ntrel authored
30 #include "notebook.h"
efe6588 @ntrel Enable drag reordering of tabs for GTK+2.8, and a temporary workaround f...
ntrel authored
31 #include "document.h"
4837030 @ntrel Fix compilation.
ntrel authored
32 #include "editor.h"
37e0d1f @ntrel Move GeanyDocument GUI elements and saved_encoding to private
ntrel authored
33 #include "documentprivate.h"
a63fc1e @ntrel Moved UI related utils from utils.c to ui_utils.c
ntrel authored
34 #include "ui_utils.h"
caec1ec @ntrel Rename treeviews.[hc] -> sidebar.[hc].
ntrel authored
35 #include "sidebar.h"
1edaaa3 @ntrel Show read-only notebook tabs in green.
ntrel authored
36 #include "support.h"
416e1b0 @eht16 Enable close tab on middle-clicking a notebook tab label.
eht16 authored
37 #include "callbacks.h"
3b9840d @ntrel Show current document in bold in tab popup menu.
ntrel authored
38 #include "utils.h"
cf30b64 @ntrel Make Ctrl-click on any notebook tab switch to the last used
ntrel authored
39 #include "keybindings.h"
ddbb253 @techee Move MRU tab handing from keybindings.c to notebook.c because this is wh...
techee authored
40 #include "main.h"
14e6966 @ntrel Added currently disabled drag reordering of notebook tabs
ntrel authored
41
42 #define GEANY_DND_NOTEBOOK_TAB_TYPE "geany_dnd_notebook_tab"
43
2e31c57 @eht16 Compile notebook_motion_notify_event_cb() only with GTK 2.6.
eht16 authored
44 static const GtkTargetEntry drag_targets[] =
14e6966 @ntrel Added currently disabled drag reordering of notebook tabs
ntrel authored
45 {
46 {GEANY_DND_NOTEBOOK_TAB_TYPE, GTK_TARGET_SAME_APP | GTK_TARGET_SAME_WIDGET, 0}
47 };
48
4306f90 @eht16 Removed DnD handler for the main window (not very useful).
eht16 authored
49 static GtkTargetEntry files_drop_targets[] = {
50 { "STRING", 0, 0 },
51 { "UTF8_STRING", 0, 0 },
52 { "text/plain", 0, 0 },
53 { "text/uri-list", 0, 0 }
54 };
55
ddbb253 @techee Move MRU tab handing from keybindings.c to notebook.c because this is wh...
techee authored
56 static const gsize MAX_MRU_DOCS = 20;
57 static GQueue *mru_docs = NULL;
58 static guint mru_pos = 0;
59
60 static gboolean switch_in_progress = FALSE;
61 static GtkWidget *switch_dialog = NULL;
62 static GtkWidget *switch_dialog_label = NULL;
63
14e6966 @ntrel Added currently disabled drag reordering of notebook tabs
ntrel authored
64
0a4e1ff @ntrel Use native tab DnD reordering on GTK+ 2.10; closes #1519650
ntrel authored
65 static void
66 notebook_page_reordered_cb(GtkNotebook *notebook, GtkWidget *child, guint page_num,
ddb4ad5 @b4n Fix some whitespace style errors
b4n authored
67 gpointer user_data);
0a4e1ff @ntrel Use native tab DnD reordering on GTK+ 2.10; closes #1519650
ntrel authored
68
4306f90 @eht16 Removed DnD handler for the main window (not very useful).
eht16 authored
69 static void
70 on_window_drag_data_received(GtkWidget *widget, GdkDragContext *drag_context,
ddb4ad5 @b4n Fix some whitespace style errors
b4n authored
71 gint x, gint y, GtkSelectionData *data, guint target_type,
72 guint event_time, gpointer user_data);
4306f90 @eht16 Removed DnD handler for the main window (not very useful).
eht16 authored
73
93a9a2b @ntrel Fix close tab button bug introduced in last commit
ntrel authored
74 static void
75 notebook_tab_close_clicked_cb(GtkButton *button, gpointer user_data);
76
85f7312 @eht16 Apply patch from Daniel Richard G. to fix to fix several compiler warnin...
eht16 authored
77 static void setup_tab_dnd(void);
0a4e1ff @ntrel Use native tab DnD reordering on GTK+ 2.10; closes #1519650
ntrel authored
78
efe6588 @ntrel Enable drag reordering of tabs for GTK+2.8, and a temporary workaround f...
ntrel authored
79
ddbb253 @techee Move MRU tab handing from keybindings.c to notebook.c because this is wh...
techee authored
80 static void update_mru_docs_head(GeanyDocument *doc)
81 {
82 if (doc)
83 {
84 g_queue_remove(mru_docs, doc);
85 g_queue_push_head(mru_docs, doc);
86
87 if (g_queue_get_length(mru_docs) > MAX_MRU_DOCS)
88 g_queue_pop_tail(mru_docs);
89 }
90 }
91
92
93 /* before the tab changes, add the current document to the MRU list */
94 static void on_notebook_switch_page(GtkNotebook *notebook,
95 GtkNotebookPage *page, guint page_num, gpointer user_data)
96 {
97 GeanyDocument *new;
98
99 new = document_get_from_page(page_num);
100
101 /* insert the very first document (when adding the second document
102 * and switching to it) */
103 if (g_queue_get_length(mru_docs) == 0 && gtk_notebook_get_n_pages(notebook) == 2)
104 update_mru_docs_head(document_get_current());
105
106 if (!switch_in_progress)
107 update_mru_docs_head(new);
108 }
109
110
111 static void on_document_close(GObject *obj, GeanyDocument *doc)
112 {
113 if (! main_status.quitting)
114 {
115 g_queue_remove(mru_docs, doc);
116 /* this prevents the pop up window from showing when there's a single
117 * document */
118 if (gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_widgets.notebook)) == 2)
119 g_queue_clear(mru_docs);
120 }
121 }
122
123
124 static GtkWidget *ui_minimal_dialog_new(GtkWindow *parent, const gchar *title)
125 {
126 GtkWidget *dialog;
127
128 dialog = gtk_window_new(GTK_WINDOW_POPUP);
129
130 if (parent)
131 {
132 gtk_window_set_transient_for(GTK_WINDOW(dialog), parent);
133 gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE);
134 }
135 gtk_window_set_title(GTK_WINDOW(dialog), title);
136 gtk_window_set_type_hint(GTK_WINDOW(dialog), GDK_WINDOW_TYPE_HINT_DIALOG);
137 gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER_ON_PARENT);
138
139 gtk_widget_set_name(dialog, "GeanyDialog");
140 return dialog;
141 }
142
143
144 static gboolean is_modifier_key(guint keyval)
145 {
146 switch (keyval)
147 {
148 case GDK_Shift_L:
149 case GDK_Shift_R:
150 case GDK_Control_L:
151 case GDK_Control_R:
152 case GDK_Meta_L:
153 case GDK_Meta_R:
154 case GDK_Alt_L:
155 case GDK_Alt_R:
156 case GDK_Super_L:
157 case GDK_Super_R:
158 case GDK_Hyper_L:
159 case GDK_Hyper_R:
160 return TRUE;
161 default:
162 return FALSE;
163 }
164 }
165
166
167 static gboolean on_key_release_event(GtkWidget *widget, GdkEventKey *ev, gpointer user_data)
168 {
169 /* user may have rebound keybinding to a different modifier than Ctrl, so check all */
170 if (switch_in_progress && is_modifier_key(ev->keyval))
171 {
5cc8a96 @techee Do not show document change notification dialog when MRU switch is in pr...
techee authored
172 GeanyDocument *doc;
173
ddbb253 @techee Move MRU tab handing from keybindings.c to notebook.c because this is wh...
techee authored
174 switch_in_progress = FALSE;
175
176 if (switch_dialog)
177 {
178 gtk_widget_destroy(switch_dialog);
179 switch_dialog = NULL;
180 }
181
5cc8a96 @techee Do not show document change notification dialog when MRU switch is in pr...
techee authored
182 doc = document_get_current();
183 update_mru_docs_head(doc);
ddbb253 @techee Move MRU tab handing from keybindings.c to notebook.c because this is wh...
techee authored
184 mru_pos = 0;
5cc8a96 @techee Do not show document change notification dialog when MRU switch is in pr...
techee authored
185 document_check_disk_status(doc, TRUE);
ddbb253 @techee Move MRU tab handing from keybindings.c to notebook.c because this is wh...
techee authored
186 }
187 return FALSE;
188 }
189
190
191 static GtkWidget *create_switch_dialog(void)
192 {
193 GtkWidget *dialog, *widget, *vbox;
194
195 dialog = ui_minimal_dialog_new(GTK_WINDOW(main_widgets.window), _("Switch to Document"));
196 gtk_window_set_decorated(GTK_WINDOW(dialog), FALSE);
197 gtk_window_set_default_size(GTK_WINDOW(dialog), 200, -1);
198
199 vbox = gtk_vbox_new(FALSE, 6);
200 gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);
201 gtk_container_add(GTK_CONTAINER(dialog), vbox);
202
203 widget = gtk_image_new_from_stock(GTK_STOCK_JUMP_TO, GTK_ICON_SIZE_BUTTON);
204 gtk_container_add(GTK_CONTAINER(vbox), widget);
205
206 widget = gtk_label_new(NULL);
207 gtk_label_set_justify(GTK_LABEL(widget), GTK_JUSTIFY_CENTER);
208 gtk_container_add(GTK_CONTAINER(vbox), widget);
209 switch_dialog_label = widget;
210
211 g_signal_connect(dialog, "key-release-event", G_CALLBACK(on_key_release_event), NULL);
212 return dialog;
213 }
214
215
216 static void update_filename_label(void)
217 {
218 guint i;
d79268b @b4n Fix a theoretically possible use of an uninitialized value
b4n authored
219 gchar *msg = NULL;
ddbb253 @techee Move MRU tab handing from keybindings.c to notebook.c because this is wh...
techee authored
220 guint queue_length;
221 GeanyDocument *doc;
222
223 if (!switch_dialog)
224 {
225 switch_dialog = create_switch_dialog();
226 gtk_widget_show_all(switch_dialog);
227 }
228
229 queue_length = g_queue_get_length(mru_docs);
230 for (i = mru_pos; (i <= mru_pos + 3) && (doc = g_queue_peek_nth(mru_docs, i % queue_length)); i++)
231 {
232 gchar *basename;
233
234 basename = g_path_get_basename(DOC_FILENAME(doc));
235 if (i == mru_pos)
236 msg = g_markup_printf_escaped ("<b>%s</b>", basename);
237 else if (i % queue_length == mru_pos) /* && i != mru_pos */
238 {
239 /* We have wrapped around and got to the starting document again */
240 g_free(basename);
241 break;
242 }
243 else
244 {
b287553 @ntrel Use 'SETPTR' instead of 'setptr'
ntrel authored
245 SETPTR(basename, g_markup_printf_escaped ("\n%s", basename));
246 SETPTR(msg, g_strconcat(msg, basename, NULL));
ddbb253 @techee Move MRU tab handing from keybindings.c to notebook.c because this is wh...
techee authored
247 }
248 g_free(basename);
249 }
250 gtk_label_set_markup(GTK_LABEL(switch_dialog_label), msg);
251 g_free(msg);
252 }
253
254
255 static gboolean on_switch_timeout(G_GNUC_UNUSED gpointer data)
256 {
257 if (!switch_in_progress || switch_dialog)
258 {
259 return FALSE;
260 }
261
262 update_filename_label();
263 return FALSE;
264 }
265
266
267 void notebook_switch_tablastused(void)
268 {
269 GeanyDocument *last_doc;
270 gboolean switch_start = !switch_in_progress;
271
272 mru_pos += 1;
273 last_doc = g_queue_peek_nth(mru_docs, mru_pos);
274
275 if (! DOC_VALID(last_doc))
276 {
277 utils_beep();
278 mru_pos = 0;
279 last_doc = g_queue_peek_nth(mru_docs, mru_pos);
280 }
281 if (! DOC_VALID(last_doc))
282 return;
283
284 switch_in_progress = TRUE;
285 document_show_tab(last_doc);
286
287 /* if there's a modifier key, we can switch back in MRU order each time unless
288 * the key is released */
289 if (switch_start)
290 g_timeout_add(600, on_switch_timeout, NULL);
291 else
292 update_filename_label();
293 }
294
295
5cc8a96 @techee Do not show document change notification dialog when MRU switch is in pr...
techee authored
296 gboolean notebook_switch_in_progress(void)
297 {
298 return switch_in_progress;
299 }
300
301
961b040 @eht16 Fix signature of focus_sci().
eht16 authored
302 static gboolean focus_sci(GtkWidget *widget, GdkEventButton *event, gpointer user_data)
5ac6b83 @ntrel Focus the current document after clicking on a tab.
ntrel authored
303 {
d3439f8 @eht16 Use document pointer instead of an index to the documents array everywhe...
eht16 authored
304 GeanyDocument *doc = document_get_current();
5ac6b83 @ntrel Focus the current document after clicking on a tab.
ntrel authored
305
a95a59a @eht16 Remove all G_LIKELY macros inside g_return_if_fail() statements as this ...
eht16 authored
306 if (doc != NULL && event->button == 1)
961b040 @eht16 Fix signature of focus_sci().
eht16 authored
307 gtk_widget_grab_focus(GTK_WIDGET(doc->editor->sci));
5ac6b83 @ntrel Focus the current document after clicking on a tab.
ntrel authored
308
961b040 @eht16 Fix signature of focus_sci().
eht16 authored
309 return FALSE;
310 }
311
312
080c93b @eht16 Ignore the scroll arrows when checking for a double click in the noteboo...
eht16 authored
313 static gboolean gtk_notebook_show_arrows(GtkNotebook *notebook)
314 {
315 return notebook->scrollable;
316 #if 0
317 /* To get this working we would need to define at least the first two fields of
318 * GtkNotebookPage since it is a private field. The better way would be to
319 * subclass GtkNotebook.
320 struct _FakeGtkNotebookPage
321 {
322 GtkWidget *child;
323 GtkWidget *tab_label;
324 };
325 */
326 gboolean show_arrow = FALSE;
327 GList *children;
328
329 if (! notebook->scrollable)
330 return FALSE;
331
332 children = notebook->children;
333 while (children)
334 {
335 struct _FakeGtkNotebookPage *page = children->data;
336
337 if (page->tab_label && ! gtk_widget_get_child_visible(page->tab_label))
338 show_arrow = TRUE;
339
340 children = children->next;
341 }
342 return show_arrow;
343 #endif
344 }
345
346
961b040 @eht16 Fix signature of focus_sci().
eht16 authored
347 static gboolean is_position_on_tab_bar(GtkNotebook *notebook, GdkEventButton *event)
348 {
349 GtkWidget *page;
350 GtkWidget *tab;
080c93b @eht16 Ignore the scroll arrows when checking for a double click in the noteboo...
eht16 authored
351 GtkWidget *nb;
961b040 @eht16 Fix signature of focus_sci().
eht16 authored
352 GtkPositionType tab_pos;
080c93b @eht16 Ignore the scroll arrows when checking for a double click in the noteboo...
eht16 authored
353 gint scroll_arrow_hlength, scroll_arrow_vlength;
354 gdouble x, y;
961b040 @eht16 Fix signature of focus_sci().
eht16 authored
355
080c93b @eht16 Ignore the scroll arrows when checking for a double click in the noteboo...
eht16 authored
356 page = gtk_notebook_get_nth_page(notebook, 0);
a95a59a @eht16 Remove all G_LIKELY macros inside g_return_if_fail() statements as this ...
eht16 authored
357 g_return_val_if_fail(page != NULL, FALSE);
961b040 @eht16 Fix signature of focus_sci().
eht16 authored
358
080c93b @eht16 Ignore the scroll arrows when checking for a double click in the noteboo...
eht16 authored
359 tab = gtk_notebook_get_tab_label(notebook, page);
a95a59a @eht16 Remove all G_LIKELY macros inside g_return_if_fail() statements as this ...
eht16 authored
360 g_return_val_if_fail(tab != NULL, FALSE);
961b040 @eht16 Fix signature of focus_sci().
eht16 authored
361
080c93b @eht16 Ignore the scroll arrows when checking for a double click in the noteboo...
eht16 authored
362 tab_pos = gtk_notebook_get_tab_pos(notebook);
363 nb = GTK_WIDGET(notebook);
364
365 gtk_widget_style_get(GTK_WIDGET(notebook), "scroll-arrow-hlength", &scroll_arrow_hlength,
366 "scroll-arrow-vlength", &scroll_arrow_vlength, NULL);
367
368 if (! gdk_event_get_coords((GdkEvent*) event, &x, &y))
369 {
370 x = event->x;
371 y = event->y;
372 }
961b040 @eht16 Fix signature of focus_sci().
eht16 authored
373
374 switch (tab_pos)
375 {
376 case GTK_POS_TOP:
377 case GTK_POS_BOTTOM:
378 {
379 if (event->y >= 0 && event->y <= tab->allocation.height)
080c93b @eht16 Ignore the scroll arrows when checking for a double click in the noteboo...
eht16 authored
380 {
381 if (! gtk_notebook_show_arrows(notebook) || (
382 x > scroll_arrow_hlength &&
383 x < nb->allocation.width - scroll_arrow_hlength))
384 return TRUE;
385 }
386 break;
961b040 @eht16 Fix signature of focus_sci().
eht16 authored
387 }
388 case GTK_POS_LEFT:
389 case GTK_POS_RIGHT:
390 {
391 if (event->x >= 0 && event->x <= tab->allocation.width)
080c93b @eht16 Ignore the scroll arrows when checking for a double click in the noteboo...
eht16 authored
392 {
393 if (! gtk_notebook_show_arrows(notebook) || (
394 y > scroll_arrow_vlength &&
395 y < nb->allocation.height - scroll_arrow_vlength))
396 return TRUE;
397 }
961b040 @eht16 Fix signature of focus_sci().
eht16 authored
398 }
399 }
400
401 return FALSE;
402 }
403
404
93b0278 @eht16 Disable the default tab bar menu for the main notebook widget and use a ...
eht16 authored
405 static void tab_bar_menu_activate_cb(GtkMenuItem *menuitem, gpointer data)
406 {
407 GeanyDocument *doc = data;
408
409 if (! DOC_VALID(doc))
410 return;
411
1563c62 @ntrel Add document_show_tab().
ntrel authored
412 document_show_tab(doc);
93b0278 @eht16 Disable the default tab bar menu for the main notebook widget and use a ...
eht16 authored
413 }
414
415
31a4d06 @ntrel Add 'Open in New Window' command in the notebook tab menu (based on
ntrel authored
416 static void on_open_in_new_window_activate(GtkMenuItem *menuitem, gpointer user_data)
417 {
418 gchar *geany_path;
419 GeanyDocument *doc = user_data;
420
421 g_return_if_fail(doc->is_valid);
422
423 geany_path = g_find_program_in_path("geany");
424
425 if (geany_path)
426 {
427 gchar *doc_path = utils_get_locale_from_utf8(doc->file_name);
428 gchar *argv[] = {geany_path, "-i", doc_path, NULL};
429 GError *err = NULL;
430
431 if (!utils_spawn_async(NULL, argv, NULL, 0, NULL, NULL, NULL, &err))
432 {
433 g_printerr("Unable to open new window: %s", err->message);
434 g_error_free(err);
435 }
436 g_free(doc_path);
437 g_free(geany_path);
438 }
439 else
440 g_printerr("Unable to find 'geany'");
441 }
442
443
cfa334d @eht16 Fix using the current document on 'Close Other Documents' from the GtkNo...
eht16 authored
444 static void show_tab_bar_popup_menu(GdkEventButton *event, GtkWidget *page)
93b0278 @eht16 Disable the default tab bar menu for the main notebook widget and use a ...
eht16 authored
445 {
39cdcac @ntrel Make Split Window 'Show current document' button have a drop-down menu
ntrel authored
446 GtkWidget *menu_item;
93b0278 @eht16 Disable the default tab bar menu for the main notebook widget and use a ...
eht16 authored
447 static GtkWidget *menu = NULL;
31a4d06 @ntrel Add 'Open in New Window' command in the notebook tab menu (based on
ntrel authored
448 GeanyDocument *doc = NULL;
cfa334d @eht16 Fix using the current document on 'Close Other Documents' from the GtkNo...
eht16 authored
449 gint page_num;
39cdcac @ntrel Make Split Window 'Show current document' button have a drop-down menu
ntrel authored
450
451 if (menu == NULL)
93b0278 @eht16 Disable the default tab bar menu for the main notebook widget and use a ...
eht16 authored
452 menu = gtk_menu_new();
453
454 /* clear the old menu items */
455 gtk_container_foreach(GTK_CONTAINER(menu), (GtkCallback) gtk_widget_destroy, NULL);
456
39cdcac @ntrel Make Split Window 'Show current document' button have a drop-down menu
ntrel authored
457 ui_menu_add_document_items(GTK_MENU(menu), document_get_current(),
458 G_CALLBACK(tab_bar_menu_activate_cb));
93b0278 @eht16 Disable the default tab bar menu for the main notebook widget and use a ...
eht16 authored
459
460 menu_item = gtk_separator_menu_item_new();
461 gtk_widget_show(menu_item);
462 gtk_container_add(GTK_CONTAINER(menu), menu_item);
463
cfa334d @eht16 Fix using the current document on 'Close Other Documents' from the GtkNo...
eht16 authored
464 if (page != NULL)
465 {
466 page_num = gtk_notebook_page_num(GTK_NOTEBOOK(main_widgets.notebook), page);
467 doc = document_get_from_page(page_num);
468 }
469
31a4d06 @ntrel Add 'Open in New Window' command in the notebook tab menu (based on
ntrel authored
470 menu_item = ui_image_menu_item_new(GTK_STOCK_OPEN, "Open in New _Window");
471 gtk_widget_show(menu_item);
472 gtk_container_add(GTK_CONTAINER(menu), menu_item);
473 g_signal_connect(menu_item, "activate",
474 G_CALLBACK(on_open_in_new_window_activate), doc);
475 /* disable if not on disk */
cfa334d @eht16 Fix using the current document on 'Close Other Documents' from the GtkNo...
eht16 authored
476 if (doc == NULL || !doc->real_path)
31a4d06 @ntrel Add 'Open in New Window' command in the notebook tab menu (based on
ntrel authored
477 gtk_widget_set_sensitive(menu_item, FALSE);
478
479 menu_item = gtk_separator_menu_item_new();
480 gtk_widget_show(menu_item);
481 gtk_container_add(GTK_CONTAINER(menu), menu_item);
482
39606dd @eht16 Add Close menu item to the notebook tab menu
eht16 authored
483 menu_item = gtk_image_menu_item_new_from_stock(GTK_STOCK_CLOSE, NULL);
484 gtk_widget_show(menu_item);
485 gtk_container_add(GTK_CONTAINER(menu), menu_item);
486 g_signal_connect(menu_item, "activate", G_CALLBACK(notebook_tab_close_clicked_cb), page);
487 gtk_widget_set_sensitive(GTK_WIDGET(menu_item), (page != NULL));
488
d2a93f3 @ntrel Add stock close buttons to notebook tab popup menu.
ntrel authored
489 menu_item = ui_image_menu_item_new(GTK_STOCK_CLOSE, _("Close Ot_her Documents"));
93b0278 @eht16 Disable the default tab bar menu for the main notebook widget and use a ...
eht16 authored
490 gtk_widget_show(menu_item);
491 gtk_container_add(GTK_CONTAINER(menu), menu_item);
cfa334d @eht16 Fix using the current document on 'Close Other Documents' from the GtkNo...
eht16 authored
492 g_signal_connect(menu_item, "activate", G_CALLBACK(on_close_other_documents1_activate), page);
493 gtk_widget_set_sensitive(GTK_WIDGET(menu_item), (page != NULL));
93b0278 @eht16 Disable the default tab bar menu for the main notebook widget and use a ...
eht16 authored
494
d2a93f3 @ntrel Add stock close buttons to notebook tab popup menu.
ntrel authored
495 menu_item = ui_image_menu_item_new(GTK_STOCK_CLOSE, _("C_lose All"));
93b0278 @eht16 Disable the default tab bar menu for the main notebook widget and use a ...
eht16 authored
496 gtk_widget_show(menu_item);
497 gtk_container_add(GTK_CONTAINER(menu), menu_item);
498 g_signal_connect(menu_item, "activate", G_CALLBACK(on_close_all1_activate), NULL);
499
39cdcac @ntrel Make Split Window 'Show current document' button have a drop-down menu
ntrel authored
500 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, event->button, event->time);
93b0278 @eht16 Disable the default tab bar menu for the main notebook widget and use a ...
eht16 authored
501 }
502
503
961b040 @eht16 Fix signature of focus_sci().
eht16 authored
504 static gboolean notebook_tab_bar_click_cb(GtkWidget *widget, GdkEventButton *event,
505 gpointer user_data)
506 {
507 if (event->type == GDK_2BUTTON_PRESS)
508 {
509 /* accessing ::event_window is a little hacky but we need to make sure the click
510 * was in the tab bar and not inside the child */
511 if (event->window != GTK_NOTEBOOK(main_widgets.notebook)->event_window)
512 return FALSE;
513
080c93b @eht16 Ignore the scroll arrows when checking for a double click in the noteboo...
eht16 authored
514 if (is_position_on_tab_bar(GTK_NOTEBOOK(widget), event))
515 {
516 document_new_file(NULL, NULL, NULL);
517 return TRUE;
518 }
961b040 @eht16 Fix signature of focus_sci().
eht16 authored
519 }
cfa334d @eht16 Fix using the current document on 'Close Other Documents' from the GtkNo...
eht16 authored
520 /* right-click is also handled here if it happened on the notebook tab bar but not
521 * on a tab directly */
93b0278 @eht16 Disable the default tab bar menu for the main notebook widget and use a ...
eht16 authored
522 else if (event->button == 3)
523 {
cfa334d @eht16 Fix using the current document on 'Close Other Documents' from the GtkNo...
eht16 authored
524 show_tab_bar_popup_menu(event, NULL);
525 return TRUE;
93b0278 @eht16 Disable the default tab bar menu for the main notebook widget and use a ...
eht16 authored
526 }
961b040 @eht16 Fix signature of focus_sci().
eht16 authored
527 return FALSE;
5ac6b83 @ntrel Focus the current document after clicking on a tab.
ntrel authored
528 }
529
530
14e6966 @ntrel Added currently disabled drag reordering of notebook tabs
ntrel authored
531 void notebook_init()
532 {
74fd731 @eht16 Another attempt to handle tab close button size properly (based on code ...
eht16 authored
533 /* Individual style for the tab close buttons */
534 gtk_rc_parse_string(
535 "style \"geany-close-tab-button-style\" {\n"
536 " GtkWidget::focus-padding = 0\n"
537 " GtkWidget::focus-line-width = 0\n"
538 " xthickness = 0\n"
539 " ythickness = 0\n"
540 "}\n"
541 "widget \"*.geany-close-tab-button\" style \"geany-close-tab-button-style\""
542 );
543
961b040 @eht16 Fix signature of focus_sci().
eht16 authored
544 g_signal_connect_after(main_widgets.notebook, "button-press-event",
545 G_CALLBACK(notebook_tab_bar_click_cb), NULL);
546
8d67117 @eht16 Rename "delete_event" to "delete-event".
eht16 authored
547 g_signal_connect(main_widgets.notebook, "drag-data-received",
4306f90 @eht16 Removed DnD handler for the main window (not very useful).
eht16 authored
548 G_CALLBACK(on_window_drag_data_received), NULL);
549
ddbb253 @techee Move MRU tab handing from keybindings.c to notebook.c because this is wh...
techee authored
550 mru_docs = g_queue_new();
551 g_signal_connect(main_widgets.notebook, "switch-page",
552 G_CALLBACK(on_notebook_switch_page), NULL);
553 g_signal_connect(geany_object, "document-close",
554 G_CALLBACK(on_document_close), NULL);
555
556 /* in case the switch dialog misses an event while drawing the dialog */
557 g_signal_connect(main_widgets.window, "key-release-event", G_CALLBACK(on_key_release_event), NULL);
558
0a4e1ff @ntrel Use native tab DnD reordering on GTK+ 2.10; closes #1519650
ntrel authored
559 setup_tab_dnd();
560 }
561
562
ddbb253 @techee Move MRU tab handing from keybindings.c to notebook.c because this is wh...
techee authored
563 void notebook_free(void)
564 {
565 g_queue_free(mru_docs);
566 }
567
568
0a4e1ff @ntrel Use native tab DnD reordering on GTK+ 2.10; closes #1519650
ntrel authored
569 static void setup_tab_dnd()
570 {
398efbd @ntrel Note: this commit breaks the plugin API.
ntrel authored
571 GtkWidget *notebook = main_widgets.notebook;
14e6966 @ntrel Added currently disabled drag reordering of notebook tabs
ntrel authored
572
6bf947c @b4n Remove pre-GTK 2.10 tab DnD support
b4n authored
573 g_signal_connect(notebook, "page-reordered", G_CALLBACK(notebook_page_reordered_cb), NULL);
efe6588 @ntrel Enable drag reordering of tabs for GTK+2.8, and a temporary workaround f...
ntrel authored
574 }
575
576
0a4e1ff @ntrel Use native tab DnD reordering on GTK+ 2.10; closes #1519650
ntrel authored
577 static void
578 notebook_page_reordered_cb(GtkNotebook *notebook, GtkWidget *child, guint page_num,
579 gpointer user_data)
580 {
638af6c @ntrel Don't recreate the open files items when DnD reordering tabs, now
ntrel authored
581 /* Not necessary to update open files treeview if it's sorted.
582 * Note: if enabled, it's best to move the item instead of recreating all items. */
caec1ec @ntrel Rename treeviews.[hc] -> sidebar.[hc].
ntrel authored
583 /*sidebar_openfiles_update_all();*/
0a4e1ff @ntrel Use native tab DnD reordering on GTK+ 2.10; closes #1519650
ntrel authored
584 }
585
586
398efbd @ntrel Note: this commit breaks the plugin API.
ntrel authored
587 /* call this after the number of tabs in main_widgets.notebook changes. */
85f7312 @eht16 Apply patch from Daniel Richard G. to fix to fix several compiler warnin...
eht16 authored
588 static void tab_count_changed(void)
9cff850 @ntrel Ensure tab DnD is enabled when tabs are added; use
ntrel authored
589 {
398efbd @ntrel Note: this commit breaks the plugin API.
ntrel authored
590 switch (gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_widgets.notebook)))
9cff850 @ntrel Ensure tab DnD is enabled when tabs are added; use
ntrel authored
591 {
6bb48f0 @ntrel Make tab_count_changed() slightly more efficient.
ntrel authored
592 case 0:
9cff850 @ntrel Ensure tab DnD is enabled when tabs are added; use
ntrel authored
593 /* Enables DnD for dropping files into the empty notebook widget */
398efbd @ntrel Note: this commit breaks the plugin API.
ntrel authored
594 gtk_drag_dest_set(main_widgets.notebook, GTK_DEST_DEFAULT_ALL,
9cff850 @ntrel Ensure tab DnD is enabled when tabs are added; use
ntrel authored
595 files_drop_targets, G_N_ELEMENTS(files_drop_targets),
596 GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK | GDK_ACTION_ASK);
6bb48f0 @ntrel Make tab_count_changed() slightly more efficient.
ntrel authored
597 break;
598
599 case 1:
9cff850 @ntrel Ensure tab DnD is enabled when tabs are added; use
ntrel authored
600 /* Disables DnD for dropping files into the notebook widget and enables the DnD for moving file
601 * tabs. Files can still be dropped into the notebook widget because it will be handled by the
602 * active Scintilla Widget (only dropping to the tab bar is not possible but it should be ok) */
398efbd @ntrel Note: this commit breaks the plugin API.
ntrel authored
603 gtk_drag_dest_set(main_widgets.notebook, GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP,
9cff850 @ntrel Ensure tab DnD is enabled when tabs are added; use
ntrel authored
604 drag_targets, G_N_ELEMENTS(drag_targets), GDK_ACTION_MOVE);
6bb48f0 @ntrel Make tab_count_changed() slightly more efficient.
ntrel authored
605 break;
9cff850 @ntrel Ensure tab DnD is enabled when tabs are added; use
ntrel authored
606 }
607 }
608
961b040 @eht16 Fix signature of focus_sci().
eht16 authored
609
1fc1a3d @ntrel Make middle-clicking to close tabs and double-clicking to toggle
ntrel authored
610 static gboolean notebook_tab_click(GtkWidget *widget, GdkEventButton *event, gpointer data)
416e1b0 @eht16 Enable close tab on middle-clicking a notebook tab label.
eht16 authored
611 {
d84a498 @eht16 Fix Ctrl-Click on notebook tab if Numpad is active.
eht16 authored
612 guint state;
613
b7bfb27 @eht16 Replace all C++-style comments with usual C-like multi-line comments.
eht16 authored
614 /* toggle additional widgets on double click */
416e1b0 @eht16 Enable close tab on middle-clicking a notebook tab label.
eht16 authored
615 if (event->type == GDK_2BUTTON_PRESS)
961b040 @eht16 Fix signature of focus_sci().
eht16 authored
616 {
89fce6d @ntrel Add an interface pref for whether to hide additional widgets when
ntrel authored
617 if (interface_prefs.notebook_double_click_hides_widgets)
618 on_menu_toggle_all_additional_widgets1_activate(NULL, NULL);
619
961b040 @eht16 Fix signature of focus_sci().
eht16 authored
620 return TRUE; /* stop other handlers like notebook_tab_bar_click_cb() */
621 }
b7bfb27 @eht16 Replace all C++-style comments with usual C-like multi-line comments.
eht16 authored
622 /* close tab on middle click */
416e1b0 @eht16 Enable close tab on middle-clicking a notebook tab label.
eht16 authored
623 if (event->button == 2)
961b040 @eht16 Fix signature of focus_sci().
eht16 authored
624 {
d3439f8 @eht16 Use document pointer instead of an index to the documents array everywhe...
eht16 authored
625 document_remove_page(gtk_notebook_page_num(GTK_NOTEBOOK(main_widgets.notebook),
4936861 @eht16 Oops, compile fix.
eht16 authored
626 GTK_WIDGET(data)));
961b040 @eht16 Fix signature of focus_sci().
eht16 authored
627 return TRUE; /* stop other handlers like notebook_tab_bar_click_cb() */
628 }
cf30b64 @ntrel Make Ctrl-click on any notebook tab switch to the last used
ntrel authored
629 /* switch last used tab on ctrl-click */
d84a498 @eht16 Fix Ctrl-Click on notebook tab if Numpad is active.
eht16 authored
630 state = event->state & gtk_accelerator_get_default_mod_mask();
631 if (event->button == 1 && state == GDK_CONTROL_MASK)
cf30b64 @ntrel Make Ctrl-click on any notebook tab switch to the last used
ntrel authored
632 {
633 keybindings_send_command(GEANY_KEY_GROUP_NOTEBOOK,
634 GEANY_KEYS_NOTEBOOK_SWITCHTABLASTUSED);
635 return TRUE;
636 }
cfa334d @eht16 Fix using the current document on 'Close Other Documents' from the GtkNo...
eht16 authored
637 /* right-click is first handled here if it happened on a notebook tab */
638 if (event->button == 3)
639 {
640 show_tab_bar_popup_menu(event, data);
641 return TRUE;
642 }
643
416e1b0 @eht16 Enable close tab on middle-clicking a notebook tab label.
eht16 authored
644 return FALSE;
645 }
646
9cff850 @ntrel Ensure tab DnD is enabled when tabs are added; use
ntrel authored
647
68ac190 @eht16 Handle "style-set" events to reset the tab close button icon size when n...
eht16 authored
648 static void notebook_tab_close_button_style_set(GtkWidget *btn, GtkRcStyle *prev_style,
649 gpointer data)
650 {
651 gint w, h;
652
653 gtk_icon_size_lookup_for_settings(gtk_widget_get_settings(btn), GTK_ICON_SIZE_MENU, &w, &h);
654 gtk_widget_set_size_request(btn, w + 2, h + 2);
655 }
656
657
1edaaa3 @ntrel Show read-only notebook tabs in green.
ntrel authored
658 /* Returns page number of notebook page, or -1 on error */
d3439f8 @eht16 Use document pointer instead of an index to the documents array everywhe...
eht16 authored
659 gint notebook_new_tab(GeanyDocument *this)
efe6588 @ntrel Enable drag reordering of tabs for GTK+2.8, and a temporary workaround f...
ntrel authored
660 {
416e1b0 @eht16 Enable close tab on middle-clicking a notebook tab label.
eht16 authored
661 GtkWidget *hbox, *ebox;
efe6588 @ntrel Enable drag reordering of tabs for GTK+2.8, and a temporary workaround f...
ntrel authored
662 gint tabnum;
1edaaa3 @ntrel Show read-only notebook tabs in green.
ntrel authored
663 GtkWidget *page;
fdd451f @eht16 Add preference to add new document tabs beside the current one (patch by...
eht16 authored
664 gint cur_page;
efe6588 @ntrel Enable drag reordering of tabs for GTK+2.8, and a temporary workaround f...
ntrel authored
665
a95a59a @eht16 Remove all G_LIKELY macros inside g_return_if_fail() statements as this ...
eht16 authored
666 g_return_val_if_fail(this != NULL, -1);
efe6588 @ntrel Enable drag reordering of tabs for GTK+2.8, and a temporary workaround f...
ntrel authored
667
7db4bfe @ntrel Rename GeanyEditor::scintilla to GeanyEditor::sci.
ntrel authored
668 page = GTK_WIDGET(this->editor->sci);
1edaaa3 @ntrel Show read-only notebook tabs in green.
ntrel authored
669
ac52e42 @eht16 Show the full filename of a document as tooltip on the tab labels.
eht16 authored
670 this->priv->tab_label = gtk_label_new(NULL);
efe6588 @ntrel Enable drag reordering of tabs for GTK+2.8, and a temporary workaround f...
ntrel authored
671
1fc1a3d @ntrel Make middle-clicking to close tabs and double-clicking to toggle
ntrel authored
672 /* get button press events for the tab label and the space between it and
673 * the close button, if any */
416e1b0 @eht16 Enable close tab on middle-clicking a notebook tab label.
eht16 authored
674 ebox = gtk_event_box_new();
675 GTK_WIDGET_SET_FLAGS(ebox, GTK_NO_WINDOW);
1fc1a3d @ntrel Make middle-clicking to close tabs and double-clicking to toggle
ntrel authored
676 g_signal_connect(ebox, "button-press-event", G_CALLBACK(notebook_tab_click), page);
1256ab2 @ntrel Fix focusing the editor after clicking on a notebook tab.
ntrel authored
677 /* focus the current document after clicking on a tab */
678 g_signal_connect_after(ebox, "button-release-event",
679 G_CALLBACK(focus_sci), NULL);
416e1b0 @eht16 Enable close tab on middle-clicking a notebook tab label.
eht16 authored
680
b8043b3 @ntrel Use stock close image for notebook tab close buttons.
ntrel authored
681 hbox = gtk_hbox_new(FALSE, 2);
1fc1a3d @ntrel Make middle-clicking to close tabs and double-clicking to toggle
ntrel authored
682 gtk_box_pack_start(GTK_BOX(hbox), this->priv->tab_label, FALSE, FALSE, 0);
683 gtk_container_add(GTK_CONTAINER(ebox), hbox);
efe6588 @ntrel Enable drag reordering of tabs for GTK+2.8, and a temporary workaround f...
ntrel authored
684
3a12da9 @ntrel Note: this commit breaks the plugin API (but is necessary so that in
ntrel authored
685 if (file_prefs.show_tab_cross)
edc0cea @eht16 Add version to plugin info fields and two other fields for future use.
eht16 authored
686 {
b8043b3 @ntrel Use stock close image for notebook tab close buttons.
ntrel authored
687 GtkWidget *image, *btn, *align;
688
689 btn = gtk_button_new();
690 gtk_button_set_relief(GTK_BUTTON(btn), GTK_RELIEF_NONE);
691 gtk_button_set_focus_on_click(GTK_BUTTON(btn), FALSE);
74fd731 @eht16 Another attempt to handle tab close button size properly (based on code ...
eht16 authored
692 gtk_widget_set_name(btn, "geany-close-tab-button");
f6c3430 @ntrel Attempt to fix problem with tab close button size.
ntrel authored
693
b8043b3 @ntrel Use stock close image for notebook tab close buttons.
ntrel authored
694 image = gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU);
74fd731 @eht16 Another attempt to handle tab close button size properly (based on code ...
eht16 authored
695 gtk_container_add(GTK_CONTAINER(btn), image);
696
e9b5ef8 @ntrel Align notebook tab close buttons centred vertically - thanks to
ntrel authored
697 align = gtk_alignment_new(1.0, 0.5, 0.0, 0.0);
b8043b3 @ntrel Use stock close image for notebook tab close buttons.
ntrel authored
698 gtk_container_add(GTK_CONTAINER(align), btn);
edc0cea @eht16 Add version to plugin info fields and two other fields for future use.
eht16 authored
699 gtk_box_pack_start(GTK_BOX(hbox), align, TRUE, TRUE, 0);
700
8d67117 @eht16 Rename "delete_event" to "delete-event".
eht16 authored
701 g_signal_connect(btn, "clicked", G_CALLBACK(notebook_tab_close_clicked_cb), page);
1fc1a3d @ntrel Make middle-clicking to close tabs and double-clicking to toggle
ntrel authored
702 /* button overrides event box, so make middle click on button also close tab */
703 g_signal_connect(btn, "button-press-event", G_CALLBACK(notebook_tab_click), page);
68ac190 @eht16 Handle "style-set" events to reset the tab close button icon size when n...
eht16 authored
704 /* handle style modification to keep button small as possible even when theme change */
705 g_signal_connect(btn, "style-set", G_CALLBACK(notebook_tab_close_button_style_set), NULL);
edc0cea @eht16 Add version to plugin info fields and two other fields for future use.
eht16 authored
706 }
efe6588 @ntrel Enable drag reordering of tabs for GTK+2.8, and a temporary workaround f...
ntrel authored
707
1fc1a3d @ntrel Make middle-clicking to close tabs and double-clicking to toggle
ntrel authored
708 gtk_widget_show_all(ebox);
efe6588 @ntrel Enable drag reordering of tabs for GTK+2.8, and a temporary workaround f...
ntrel authored
709
ac52e42 @eht16 Show the full filename of a document as tooltip on the tab labels.
eht16 authored
710 document_update_tab_label(this);
711
fdd451f @eht16 Add preference to add new document tabs beside the current one (patch by...
eht16 authored
712 if (file_prefs.tab_order_beside)
713 cur_page = gtk_notebook_get_current_page(GTK_NOTEBOOK(main_widgets.notebook));
714 else
715 cur_page = file_prefs.tab_order_ltr ? -2 /* hack: -2 + 1 = -1, last page */ : 0;
3a12da9 @ntrel Note: this commit breaks the plugin API (but is necessary so that in
ntrel authored
716 if (file_prefs.tab_order_ltr)
fdd451f @eht16 Add preference to add new document tabs beside the current one (patch by...
eht16 authored
717 tabnum = gtk_notebook_insert_page_menu(GTK_NOTEBOOK(main_widgets.notebook), page,
718 ebox, NULL, cur_page + 1);
efe6588 @ntrel Enable drag reordering of tabs for GTK+2.8, and a temporary workaround f...
ntrel authored
719 else
398efbd @ntrel Note: this commit breaks the plugin API.
ntrel authored
720 tabnum = gtk_notebook_insert_page_menu(GTK_NOTEBOOK(main_widgets.notebook), page,
fdd451f @eht16 Add preference to add new document tabs beside the current one (patch by...
eht16 authored
721 ebox, NULL, cur_page);
efe6588 @ntrel Enable drag reordering of tabs for GTK+2.8, and a temporary workaround f...
ntrel authored
722
9cff850 @ntrel Ensure tab DnD is enabled when tabs are added; use
ntrel authored
723 tab_count_changed();
724
6bf947c @b4n Remove pre-GTK 2.10 tab DnD support
b4n authored
725 /* enable tab DnD */
726 gtk_notebook_set_tab_reorderable(GTK_NOTEBOOK(main_widgets.notebook), page, TRUE);
727
efe6588 @ntrel Enable drag reordering of tabs for GTK+2.8, and a temporary workaround f...
ntrel authored
728 return tabnum;
729 }
730
93a9a2b @ntrel Fix close tab button bug introduced in last commit
ntrel authored
731
732 static void
733 notebook_tab_close_clicked_cb(GtkButton *button, gpointer user_data)
734 {
398efbd @ntrel Note: this commit breaks the plugin API.
ntrel authored
735 gint cur_page = gtk_notebook_page_num(GTK_NOTEBOOK(main_widgets.notebook),
93a9a2b @ntrel Fix close tab button bug introduced in last commit
ntrel authored
736 GTK_WIDGET(user_data));
be0d9e8 @ntrel Note: this breaks the plugin API.
ntrel authored
737
d3439f8 @eht16 Use document pointer instead of an index to the documents array everywhe...
eht16 authored
738 document_remove_page(cur_page);
93a9a2b @ntrel Fix close tab button bug introduced in last commit
ntrel authored
739 }
4306f90 @eht16 Removed DnD handler for the main window (not very useful).
eht16 authored
740
741
4a62d1d @ntrel When closing a tab when using left-to-right tabs, focus the next
ntrel authored
742 /* Always use this instead of gtk_notebook_remove_page(). */
9cff850 @ntrel Ensure tab DnD is enabled when tabs are added; use
ntrel authored
743 void notebook_remove_page(gint page_num)
4306f90 @eht16 Removed DnD handler for the main window (not very useful).
eht16 authored
744 {
624c11c @techee Do not change notebook tab in document-close callback
techee authored
745 gint page = gtk_notebook_get_current_page(GTK_NOTEBOOK(main_widgets.notebook));
746
747 if (page_num == page)
748 {
fa70c16 @b4n Fix page switching after closing the first page in RTL non-MRU mode (oop...
b4n authored
749 if (file_prefs.tab_order_ltr)
750 page += 1;
751 else if (page > 0) /* never go negative, it would select the last page */
752 page -= 1;
624c11c @techee Do not change notebook tab in document-close callback
techee authored
753
754 if (file_prefs.tab_close_switch_to_mru)
755 {
756 GeanyDocument *last_doc;
757
758 last_doc = g_queue_peek_nth(mru_docs, 0);
759 if (DOC_VALID(last_doc))
760 page = document_get_notebook_page(last_doc);
761 }
762
763 gtk_notebook_set_current_page(GTK_NOTEBOOK(main_widgets.notebook), page);
764 }
765
766 /* now remove the page (so we don't temporarily switch to the previous page) */
398efbd @ntrel Note: this commit breaks the plugin API.
ntrel authored
767 gtk_notebook_remove_page(GTK_NOTEBOOK(main_widgets.notebook), page_num);
5bb5ff5 @ntrel When closing tabs that were opened left-to-right, don't temporarily
ntrel authored
768
769 tab_count_changed();
4306f90 @eht16 Removed DnD handler for the main window (not very useful).
eht16 authored
770 }
771
772
773 static void
774 on_window_drag_data_received(GtkWidget *widget, GdkDragContext *drag_context,
ddb4ad5 @b4n Fix some whitespace style errors
b4n authored
775 gint x, gint y, GtkSelectionData *data, guint target_type,
776 guint event_time, gpointer user_data)
4306f90 @eht16 Removed DnD handler for the main window (not very useful).
eht16 authored
777 {
778 gboolean success = FALSE;
779
780 if (data->length > 0 && data->format == 8)
781 {
782 if (drag_context->action == GDK_ACTION_ASK)
783 {
784 drag_context->action = GDK_ACTION_COPY;
785 }
786
787 document_open_file_list((const gchar *)data->data, data->length);
788
789 success = TRUE;
790 }
90b01da @eht16 Fixed several compiler warnings (mainly shadowing local variables and un...
eht16 authored
791 gtk_drag_finish(drag_context, success, FALSE, event_time);
4306f90 @eht16 Removed DnD handler for the main window (not very useful).
eht16 authored
792 }
Something went wrong with that request. Please try again.