2 * callbacks.c - this file is part of Geany, a fast and lightweight IDE
4 * Copyright 2005-2012 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
5 * Copyright 2006-2012 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
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.
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.
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.
23 * Callbacks used by Glade. These are mainly in response to menu item and button events in the
24 * main window. Callbacks not used by Glade should go elsewhere.
31 #include "callbacks.h"
37 #include "documentprivate.h"
38 #include "encodings.h"
39 #include "filetypes.h"
40 #include "geanyobject.h"
41 #include "highlighting.h"
42 #include "keybindings.h"
46 #include "msgwindow.h"
49 #include "pluginutils.h"
52 #include "sciwrappers.h"
59 #include "templates.h"
66 #include "gtkcompat.h"
71 #include <gdk/gdkkeysyms.h>
72 #include <glib/gstdio.h>
76 /* prototypes of Glade-only callback to let the compiler know they really are meant to be exported */
77 G_MODULE_EXPORT gboolean
on_window_delete_event(GtkWidget
*widget
, GdkEvent
*event
, gpointer gdata
);
78 G_MODULE_EXPORT
void on_info1_activate(GtkMenuItem
*menuitem
, gpointer user_data
);
79 G_MODULE_EXPORT
void on_change_font1_activate(GtkMenuItem
*menuitem
, gpointer user_data
);
80 G_MODULE_EXPORT
void on_crlf_activate(GtkCheckMenuItem
*menuitem
, gpointer user_data
);
81 G_MODULE_EXPORT
void on_lf_activate(GtkCheckMenuItem
*menuitem
, gpointer user_data
);
82 G_MODULE_EXPORT
void on_cr_activate(GtkCheckMenuItem
*menuitem
, gpointer user_data
);
83 G_MODULE_EXPORT
void on_hide_toolbar1_activate(GtkMenuItem
*menuitem
, gpointer user_data
);
84 G_MODULE_EXPORT
void on_show_toolbar1_toggled(GtkCheckMenuItem
*checkmenuitem
, gpointer user_data
);
85 G_MODULE_EXPORT
void on_fullscreen1_toggled(GtkCheckMenuItem
*checkmenuitem
, gpointer user_data
);
86 G_MODULE_EXPORT
void on_markers_margin1_toggled(GtkCheckMenuItem
*checkmenuitem
, gpointer user_data
);
87 G_MODULE_EXPORT
void on_show_messages_window1_toggled(GtkCheckMenuItem
*checkmenuitem
, gpointer user_data
);
88 G_MODULE_EXPORT
void on_menu_color_schemes_activate(GtkImageMenuItem
*imagemenuitem
, gpointer user_data
);
89 G_MODULE_EXPORT
void on_count_words1_activate(GtkMenuItem
*menuitem
, gpointer user_data
);
90 G_MODULE_EXPORT
void on_edit1_activate(GtkMenuItem
*menuitem
, gpointer user_data
);
91 G_MODULE_EXPORT
void on_website1_activate(GtkMenuItem
*menuitem
, gpointer user_data
);
92 G_MODULE_EXPORT
void on_help_menu_item_donate_activate(GtkMenuItem
*item
, gpointer user_data
);
93 G_MODULE_EXPORT
void on_help_menu_item_wiki_activate(GtkMenuItem
*item
, gpointer user_data
);
94 G_MODULE_EXPORT
void on_help_menu_item_bug_report_activate(GtkMenuItem
*item
, gpointer user_data
);
95 G_MODULE_EXPORT
void on_comments_function_activate(GtkMenuItem
*menuitem
, gpointer user_data
);
96 G_MODULE_EXPORT
void on_comments_multiline_activate(GtkMenuItem
*menuitem
, gpointer user_data
);
97 G_MODULE_EXPORT
void on_comments_changelog_activate(GtkMenuItem
*menuitem
, gpointer user_data
);
98 G_MODULE_EXPORT
void on_comments_gpl_activate(GtkMenuItem
*menuitem
, gpointer user_data
);
99 G_MODULE_EXPORT
void on_comments_fileheader_activate(GtkMenuItem
*menuitem
, gpointer user_data
);
100 G_MODULE_EXPORT
void on_set_file_readonly1_toggled(GtkCheckMenuItem
*checkmenuitem
, gpointer user_data
);
101 G_MODULE_EXPORT
void on_tv_notebook_switch_page(GtkNotebook
*notebook
, gpointer page
, guint page_num
, gpointer user_data
);
102 G_MODULE_EXPORT
void on_help_shortcuts1_activate(GtkMenuItem
*menuitem
, gpointer user_data
);
103 G_MODULE_EXPORT
void on_file_properties_activate(GtkMenuItem
*menuitem
, gpointer user_data
);
104 G_MODULE_EXPORT
void on_show_line_numbers1_toggled(GtkCheckMenuItem
*checkmenuitem
, gpointer user_data
);
105 G_MODULE_EXPORT
void on_use_auto_indentation1_toggled(GtkCheckMenuItem
*checkmenuitem
, gpointer user_data
);
106 G_MODULE_EXPORT
void on_menu_fold_all1_activate(GtkMenuItem
*menuitem
, gpointer user_data
);
107 G_MODULE_EXPORT
void on_menu_unfold_all1_activate(GtkMenuItem
*menuitem
, gpointer user_data
);
108 G_MODULE_EXPORT
void on_notebook1_switch_page_after(GtkNotebook
*notebook
, gpointer page
, guint page_num
, gpointer user_data
);
109 G_MODULE_EXPORT
void on_menu_write_unicode_bom1_toggled(GtkCheckMenuItem
*checkmenuitem
, gpointer user_data
);
110 G_MODULE_EXPORT
void on_menu_comments_multiline_activate(GtkMenuItem
*menuitem
, gpointer user_data
);
111 G_MODULE_EXPORT
void on_menu_comments_gpl_activate(GtkMenuItem
*menuitem
, gpointer user_data
);
112 G_MODULE_EXPORT
void on_menu_comments_bsd_activate(GtkMenuItem
*menuitem
, gpointer user_data
);
113 G_MODULE_EXPORT
void on_comments_bsd_activate(GtkMenuItem
*menuitem
, gpointer user_data
);
114 G_MODULE_EXPORT
void on_menu_project1_activate(GtkMenuItem
*menuitem
, gpointer user_data
);
115 G_MODULE_EXPORT
void on_load_tags1_activate(GtkMenuItem
*menuitem
, gpointer user_data
);
116 G_MODULE_EXPORT
void on_file1_activate(GtkMenuItem
*menuitem
, gpointer user_data
);
117 G_MODULE_EXPORT
void on_tv_notebook_switch_page_after(GtkNotebook
*notebook
, gpointer page
, guint page_num
, gpointer user_data
);
118 G_MODULE_EXPORT
void on_tabs1_activate(GtkCheckMenuItem
*menuitem
, gpointer user_data
);
119 G_MODULE_EXPORT
void on_spaces1_activate(GtkCheckMenuItem
*menuitem
, gpointer user_data
);
120 G_MODULE_EXPORT
void on_strip_trailing_spaces1_activate(GtkMenuItem
*menuitem
, gpointer user_data
);
121 G_MODULE_EXPORT
void on_page_setup1_activate(GtkMenuItem
*menuitem
, gpointer user_data
);
122 G_MODULE_EXPORT
void on_search1_activate(GtkMenuItem
*menuitem
, gpointer user_data
);
123 G_MODULE_EXPORT
void on_menu_reload_configuration1_activate(GtkMenuItem
*menuitem
, gpointer user_data
);
124 G_MODULE_EXPORT
void on_tabs_and_spaces1_activate(GtkCheckMenuItem
*menuitem
, gpointer user_data
);
125 G_MODULE_EXPORT
void on_debug_messages1_activate(GtkMenuItem
*menuitem
, gpointer user_data
);
126 G_MODULE_EXPORT
void on_menu_show_white_space1_toggled(GtkCheckMenuItem
*checkmenuitem
, gpointer user_data
);
127 G_MODULE_EXPORT
void on_menu_show_line_endings1_toggled(GtkCheckMenuItem
*checkmenuitem
, gpointer user_data
);
128 G_MODULE_EXPORT
void on_menu_show_indentation_guides1_toggled(GtkCheckMenuItem
*checkmenuitem
, gpointer user_data
);
129 G_MODULE_EXPORT gboolean
on_window_state_event(GtkWidget
*widget
, GdkEventWindowState
*event
, gpointer user_data
);
130 G_MODULE_EXPORT
void on_customize_toolbar1_activate(GtkMenuItem
*menuitem
, gpointer user_data
);
131 G_MODULE_EXPORT
void on_button_customize_toolbar_clicked(GtkButton
*button
, gpointer user_data
);
132 G_MODULE_EXPORT
void on_cut_current_lines1_activate(GtkMenuItem
*menuitem
, gpointer user_data
);
133 G_MODULE_EXPORT
void on_copy_current_lines1_activate(GtkMenuItem
*menuitem
, gpointer user_data
);
134 G_MODULE_EXPORT
void on_delete_current_lines1_activate(GtkMenuItem
*menuitem
, gpointer user_data
);
135 G_MODULE_EXPORT
void on_duplicate_line_or_selection1_activate(GtkMenuItem
*menuitem
, gpointer user_data
);
136 G_MODULE_EXPORT
void on_select_current_lines1_activate(GtkMenuItem
*menuitem
, gpointer user_data
);
137 G_MODULE_EXPORT
void on_select_current_paragraph1_activate(GtkMenuItem
*menuitem
, gpointer user_data
);
138 G_MODULE_EXPORT
void on_insert_alternative_white_space1_activate(GtkMenuItem
*menuitem
, gpointer user_data
);
139 G_MODULE_EXPORT
void on_go_to_next_marker1_activate(GtkMenuItem
*menuitem
, gpointer user_data
);
140 G_MODULE_EXPORT
void on_go_to_previous_marker1_activate(GtkMenuItem
*menuitem
, gpointer user_data
);
141 G_MODULE_EXPORT
void on_reflow_lines_block1_activate(GtkMenuItem
*menuitem
, gpointer user_data
);
142 G_MODULE_EXPORT
void on_smart_line_indent1_activate(GtkMenuItem
*menuitem
, gpointer user_data
);
143 G_MODULE_EXPORT
void on_move_lines_up1_activate(GtkMenuItem
*menuitem
, gpointer user_data
);
144 G_MODULE_EXPORT
void on_move_lines_down1_activate(GtkMenuItem
*menuitem
, gpointer user_data
);
145 G_MODULE_EXPORT
void on_goto_tag_definition1(GtkMenuItem
*menuitem
, gpointer user_data
);
146 G_MODULE_EXPORT
void on_goto_tag_declaration1(GtkMenuItem
*menuitem
, gpointer user_data
);
147 G_MODULE_EXPORT
void on_indent_width_activate(GtkMenuItem
*menuitem
, gpointer user_data
);
148 G_MODULE_EXPORT
void on_reset_indentation1_activate(GtkMenuItem
*menuitem
, gpointer user_data
);
149 G_MODULE_EXPORT
void on_mark_all1_activate(GtkMenuItem
*menuitem
, gpointer user_data
);
150 G_MODULE_EXPORT
void on_detect_type_from_file_activate(GtkMenuItem
*menuitem
, gpointer user_data
);
151 G_MODULE_EXPORT
void on_detect_width_from_file_activate(GtkMenuItem
*menuitem
, gpointer user_data
);
154 /* flag to indicate that an insert callback was triggered from the file menu,
155 * so we need to store the current cursor position in editor_info.click_pos. */
156 static gboolean insert_callback_from_menu
= FALSE
;
158 /* represents the state at switching a notebook page(in the left treeviews widget), to not emit
159 * the selection-changed signal from tv.tree_openfiles */
160 /*static gboolean switch_tv_notebook_page = FALSE; */
163 static gboolean
check_no_unsaved(void)
167 for (i
= 0; i
< documents_array
->len
; i
++)
169 if (documents
[i
]->is_valid
&& documents
[i
]->changed
)
174 return TRUE
; /* no unsaved edits */
178 /* set editor_info.click_pos to the current cursor position if insert_callback_from_menu is TRUE
179 * to prevent invalid cursor positions which can cause segfaults */
180 static void verify_click_pos(GeanyDocument
*doc
)
182 if (insert_callback_from_menu
)
184 editor_info
.click_pos
= sci_get_current_position(doc
->editor
->sci
);
185 insert_callback_from_menu
= FALSE
;
190 /* should only be called from on_window_delete_event */
191 static void quit_app(void)
193 configuration_save();
195 if (app
->project
!= NULL
)
196 project_close(FALSE
); /* save project session files */
198 document_close_all();
200 main_status
.quitting
= TRUE
;
206 /* wrapper function to abort exit process if cancel button is pressed */
207 G_MODULE_EXPORT gboolean
on_window_delete_event(GtkWidget
*widget
, GdkEvent
*event
, gpointer gdata
)
209 main_status
.quitting
= TRUE
;
211 if (! check_no_unsaved())
213 if (document_account_for_unsaved())
220 if (! prefs
.confirm_exit
||
221 dialogs_show_question_full(NULL
, GTK_STOCK_QUIT
, GTK_STOCK_CANCEL
, NULL
,
222 _("Do you really want to quit?")))
228 main_status
.quitting
= FALSE
;
237 G_MODULE_EXPORT
void on_new1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
239 document_new_file(NULL
, NULL
, NULL
);
243 G_MODULE_EXPORT
void on_save1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
245 gint cur_page
= gtk_notebook_get_current_page(GTK_NOTEBOOK(main_widgets
.notebook
));
246 GeanyDocument
*doc
= document_get_current();
248 if (doc
!= NULL
&& cur_page
>= 0)
250 document_save_file(doc
, ui_prefs
.allow_always_save
);
255 G_MODULE_EXPORT
void on_save_as1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
257 dialogs_show_save_as();
261 G_MODULE_EXPORT
void on_save_all1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
263 guint i
, max
= (guint
) gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_widgets
.notebook
));
264 GeanyDocument
*doc
, *cur_doc
= document_get_current();
267 /* iterate over documents in tabs order */
268 for (i
= 0; i
< max
; i
++)
270 doc
= document_get_from_page(i
);
274 if (document_save_file(doc
, FALSE
))
280 ui_set_statusbar(FALSE
, ngettext("%d file saved.", "%d files saved.", count
), count
);
281 /* saving may have changed window title, sidebar for another doc, so update */
282 sidebar_update_tag_list(cur_doc
, TRUE
);
283 ui_set_window_title(cur_doc
);
287 G_MODULE_EXPORT
void on_close_all1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
289 document_close_all();
293 G_MODULE_EXPORT
void on_close1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
295 GeanyDocument
*doc
= document_get_current();
302 G_MODULE_EXPORT
void on_quit1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
304 on_window_delete_event(NULL
, NULL
, NULL
);
308 G_MODULE_EXPORT
void on_file1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
310 gtk_widget_set_sensitive(ui_widgets
.recent_files_menuitem
,
311 g_queue_get_length(ui_prefs
.recent_queue
) > 0);
312 /* hide Page setup when GTK printing is not used */
313 ui_widget_show_hide(ui_widgets
.print_page_setup
, printing_prefs
.use_gtk_printing
);
317 /* edit actions, c&p & co, from menu bar and from popup menu */
318 G_MODULE_EXPORT
void on_edit1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
321 GeanyDocument
*doc
= document_get_current();
323 ui_update_menu_copy_items(doc
);
324 ui_update_insert_include_item(doc
, 1);
326 item
= ui_lookup_widget(main_widgets
.window
, "plugin_preferences1");
328 gtk_widget_hide(item
);
330 gtk_widget_set_sensitive(item
, plugins_have_preferences());
335 G_MODULE_EXPORT
void on_undo1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
337 GeanyDocument
*doc
= document_get_current();
339 g_return_if_fail(doc
!= NULL
);
341 if (document_can_undo(doc
))
343 sci_cancel(doc
->editor
->sci
);
349 G_MODULE_EXPORT
void on_redo1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
351 GeanyDocument
*doc
= document_get_current();
353 g_return_if_fail(doc
!= NULL
);
355 if (document_can_redo(doc
))
357 sci_cancel(doc
->editor
->sci
);
363 G_MODULE_EXPORT
void on_cut1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
365 GeanyDocument
*doc
= document_get_current();
366 GtkWidget
*focusw
= gtk_window_get_focus(GTK_WINDOW(main_widgets
.window
));
368 if (GTK_IS_EDITABLE(focusw
))
369 gtk_editable_cut_clipboard(GTK_EDITABLE(focusw
));
371 if (IS_SCINTILLA(focusw
) && doc
!= NULL
)
372 sci_cut(doc
->editor
->sci
);
374 if (GTK_IS_TEXT_VIEW(focusw
))
376 GtkTextBuffer
*buffer
= gtk_text_view_get_buffer(
377 GTK_TEXT_VIEW(focusw
));
378 gtk_text_buffer_cut_clipboard(buffer
, gtk_clipboard_get(GDK_NONE
), TRUE
);
383 G_MODULE_EXPORT
void on_copy1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
385 GeanyDocument
*doc
= document_get_current();
386 GtkWidget
*focusw
= gtk_window_get_focus(GTK_WINDOW(main_widgets
.window
));
388 if (GTK_IS_EDITABLE(focusw
))
389 gtk_editable_copy_clipboard(GTK_EDITABLE(focusw
));
391 if (IS_SCINTILLA(focusw
) && doc
!= NULL
)
392 sci_copy(doc
->editor
->sci
);
394 if (GTK_IS_TEXT_VIEW(focusw
))
396 GtkTextBuffer
*buffer
= gtk_text_view_get_buffer(
397 GTK_TEXT_VIEW(focusw
));
398 gtk_text_buffer_copy_clipboard(buffer
, gtk_clipboard_get(GDK_NONE
));
403 G_MODULE_EXPORT
void on_paste1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
405 GeanyDocument
*doc
= document_get_current();
406 GtkWidget
*focusw
= gtk_window_get_focus(GTK_WINDOW(main_widgets
.window
));
408 if (GTK_IS_EDITABLE(focusw
))
409 gtk_editable_paste_clipboard(GTK_EDITABLE(focusw
));
411 if (IS_SCINTILLA(focusw
) && doc
!= NULL
)
413 sci_paste(doc
->editor
->sci
);
416 if (GTK_IS_TEXT_VIEW(focusw
))
418 GtkTextBuffer
*buffer
= gtk_text_view_get_buffer(
419 GTK_TEXT_VIEW(focusw
));
420 gtk_text_buffer_paste_clipboard(buffer
, gtk_clipboard_get(GDK_NONE
), NULL
,
426 G_MODULE_EXPORT
void on_delete1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
428 GeanyDocument
*doc
= document_get_current();
429 GtkWidget
*focusw
= gtk_window_get_focus(GTK_WINDOW(main_widgets
.window
));
431 if (GTK_IS_EDITABLE(focusw
))
432 gtk_editable_delete_selection(GTK_EDITABLE(focusw
));
434 if (IS_SCINTILLA(focusw
) && doc
!= NULL
&& sci_has_selection(doc
->editor
->sci
))
435 sci_clear(doc
->editor
->sci
);
437 if (GTK_IS_TEXT_VIEW(focusw
))
439 GtkTextBuffer
*buffer
= gtk_text_view_get_buffer(
440 GTK_TEXT_VIEW(focusw
));
441 gtk_text_buffer_delete_selection(buffer
, TRUE
, TRUE
);
446 G_MODULE_EXPORT
void on_preferences1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
452 /* about menu item */
453 G_MODULE_EXPORT
void on_info1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
460 G_MODULE_EXPORT
void on_open1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
462 dialogs_show_open_file();
467 G_MODULE_EXPORT
void on_toolbutton_reload_clicked(GtkAction
*action
, gpointer user_data
)
469 GeanyDocument
*doc
= document_get_current();
471 g_return_if_fail(doc
!= NULL
);
473 document_reload_prompt(doc
, NULL
);
477 G_MODULE_EXPORT
void on_change_font1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
479 dialogs_show_open_font();
483 /* store text, clear search flags so we can use Search->Find Next/Previous */
484 static void setup_find(const gchar
*text
, gboolean backwards
)
486 SETPTR(search_data
.text
, g_strdup(text
));
487 SETPTR(search_data
.original_text
, g_strdup(text
));
488 search_data
.flags
= 0;
489 search_data
.backwards
= backwards
;
490 search_data
.search_bar
= TRUE
;
494 static void do_toolbar_search(const gchar
*text
, gboolean incremental
, gboolean backwards
)
496 GeanyDocument
*doc
= document_get_current();
499 setup_find(text
, backwards
);
500 result
= document_search_bar_find(doc
, search_data
.text
, 0, incremental
, backwards
);
501 if (search_data
.search_bar
)
502 ui_set_search_entry_background(toolbar_get_widget_child_by_name("SearchEntry"), result
);
507 void on_toolbar_search_entry_changed(GtkAction
*action
, const gchar
*text
, gpointer user_data
)
509 do_toolbar_search(text
, TRUE
, FALSE
);
514 void on_toolbar_search_entry_activate(GtkAction
*action
, const gchar
*text
, gpointer user_data
)
516 do_toolbar_search(text
, FALSE
, GPOINTER_TO_INT(user_data
));
521 void on_toolbutton_search_clicked(GtkAction
*action
, gpointer user_data
)
523 GeanyDocument
*doc
= document_get_current();
525 GtkWidget
*entry
= toolbar_get_widget_child_by_name("SearchEntry");
529 const gchar
*text
= gtk_entry_get_text(GTK_ENTRY(entry
));
531 setup_find(text
, FALSE
);
532 result
= document_search_bar_find(doc
, search_data
.text
, 0, FALSE
, FALSE
);
533 if (search_data
.search_bar
)
534 ui_set_search_entry_background(entry
, result
);
537 on_find1_activate(NULL
, NULL
);
541 /* hides toolbar from toolbar popup menu */
542 G_MODULE_EXPORT
void on_hide_toolbar1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
544 GtkWidget
*tool_item
= ui_lookup_widget(GTK_WIDGET(main_widgets
.window
), "menu_show_toolbar1");
545 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(tool_item
), FALSE
);
549 /* zoom in from menu bar and popup menu */
550 G_MODULE_EXPORT
void on_zoom_in1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
552 GeanyDocument
*doc
= document_get_current();
553 static gint done
= 1;
555 g_return_if_fail(doc
!= NULL
);
558 sci_set_line_numbers(doc
->editor
->sci
, editor_prefs
.show_linenumber_margin
,
559 (sci_get_zoom(doc
->editor
->sci
) / 2));
560 sci_zoom_in(doc
->editor
->sci
);
564 /* zoom out from menu bar and popup menu */
565 G_MODULE_EXPORT
void on_zoom_out1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
567 GeanyDocument
*doc
= document_get_current();
569 g_return_if_fail(doc
!= NULL
);
571 if (sci_get_zoom(doc
->editor
->sci
) == 0)
572 sci_set_line_numbers(doc
->editor
->sci
, editor_prefs
.show_linenumber_margin
, 0);
573 sci_zoom_out(doc
->editor
->sci
);
577 G_MODULE_EXPORT
void on_normal_size1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
579 GeanyDocument
*doc
= document_get_current();
581 g_return_if_fail(doc
!= NULL
);
583 sci_zoom_off(doc
->editor
->sci
);
584 sci_set_line_numbers(doc
->editor
->sci
, editor_prefs
.show_linenumber_margin
, 0);
588 static gboolean
delayed_check_disk_status(gpointer data
)
590 document_check_disk_status(data
, FALSE
);
595 /* Changes window-title after switching tabs and lots of other things.
596 * note: using 'after' makes Scintilla redraw before the UI, appearing more responsive */
597 G_MODULE_EXPORT
void on_notebook1_switch_page_after(GtkNotebook
*notebook
, gpointer page
,
598 guint page_num
, gpointer user_data
)
602 if (G_UNLIKELY(main_status
.opening_session_files
|| main_status
.closing_all
))
605 if (page_num
== (guint
) -1 && page
!= NULL
)
606 doc
= document_find_by_sci(SCINTILLA(page
));
608 doc
= document_get_from_page(page_num
);
612 sidebar_select_openfiles_item(doc
);
613 ui_save_buttons_toggle(doc
->changed
);
614 ui_set_window_title(doc
);
615 ui_update_statusbar(doc
, -1);
616 ui_update_popup_reundo_items(doc
);
617 ui_document_show_hide(doc
); /* update the document menu */
618 build_menu_update(doc
);
619 sidebar_update_tag_list(doc
, FALSE
);
620 document_highlight_tags(doc
);
622 /* We delay the check to avoid weird fast, unintended switching of notebook pages when
623 * the 'file has changed' dialog is shown while the switch event is not yet completely
624 * finished. So, we check after the switch has been performed to be safe. */
625 g_idle_add(delayed_check_disk_status
, doc
);
628 vte_cwd((doc
->real_path
!= NULL
) ? doc
->real_path
: doc
->file_name
, FALSE
);
631 g_signal_emit_by_name(geany_object
, "document-activate", doc
);
636 G_MODULE_EXPORT
void on_tv_notebook_switch_page(GtkNotebook
*notebook
, gpointer page
,
637 guint page_num
, gpointer user_data
)
639 /* suppress selection changed signal when switching to the open files list */
640 ignore_callback
= TRUE
;
644 G_MODULE_EXPORT
void on_tv_notebook_switch_page_after(GtkNotebook
*notebook
, gpointer page
,
645 guint page_num
, gpointer user_data
)
647 ignore_callback
= FALSE
;
651 static void convert_eol(gint mode
)
653 GeanyDocument
*doc
= document_get_current();
655 g_return_if_fail(doc
!= NULL
);
657 sci_convert_eols(doc
->editor
->sci
, mode
);
658 sci_set_eol_mode(doc
->editor
->sci
, mode
);
659 ui_update_statusbar(doc
, -1);
663 G_MODULE_EXPORT
void on_crlf_activate(GtkCheckMenuItem
*menuitem
, gpointer user_data
)
665 if (ignore_callback
|| ! gtk_check_menu_item_get_active(menuitem
))
668 convert_eol(SC_EOL_CRLF
);
672 G_MODULE_EXPORT
void on_lf_activate(GtkCheckMenuItem
*menuitem
, gpointer user_data
)
674 if (ignore_callback
|| ! gtk_check_menu_item_get_active(menuitem
))
677 convert_eol(SC_EOL_LF
);
681 G_MODULE_EXPORT
void on_cr_activate(GtkCheckMenuItem
*menuitem
, gpointer user_data
)
683 if (ignore_callback
|| ! gtk_check_menu_item_get_active(menuitem
))
686 convert_eol(SC_EOL_CR
);
690 G_MODULE_EXPORT
void on_replace_tabs_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
692 GeanyDocument
*doc
= document_get_current();
694 g_return_if_fail(doc
!= NULL
);
696 editor_replace_tabs(doc
->editor
);
700 gboolean
toolbar_popup_menu(GtkWidget
*widget
, GdkEventButton
*event
, gpointer user_data
)
702 if (event
->button
== 3)
704 gtk_menu_popup(GTK_MENU(ui_widgets
.toolbar_menu
), NULL
, NULL
, NULL
, NULL
, event
->button
, event
->time
);
711 G_MODULE_EXPORT
void on_toggle_case1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
713 GeanyDocument
*doc
= document_get_current();
714 ScintillaObject
*sci
;
716 gboolean keep_sel
= TRUE
;
718 g_return_if_fail(doc
!= NULL
);
720 sci
= doc
->editor
->sci
;
721 if (! sci_has_selection(sci
))
723 keybindings_send_command(GEANY_KEY_GROUP_SELECT
, GEANY_KEYS_SELECT_WORD
);
727 /* either we already had a selection or we created one for current word */
728 if (sci_has_selection(sci
))
730 gchar
*result
= NULL
;
731 gint cmd
= SCI_LOWERCASE
;
732 gboolean rectsel
= (gboolean
) scintilla_send_message(sci
, SCI_SELECTIONISRECTANGLE
, 0, 0);
734 text
= sci_get_selection_contents(sci
);
736 if (utils_str_has_upper(text
))
741 result
= g_utf8_strdown(text
, -1);
748 result
= g_utf8_strup(text
, -1);
753 sci_replace_sel(sci
, result
);
756 sci_set_selection_start(sci
, sci_get_current_position(sci
) - strlen(text
));
759 sci_send_command(sci
, cmd
);
767 G_MODULE_EXPORT
void on_show_toolbar1_toggled(GtkCheckMenuItem
*checkmenuitem
, gpointer user_data
)
769 if (ignore_callback
) return;
771 toolbar_prefs
.visible
= (toolbar_prefs
.visible
) ? FALSE
: TRUE
;;
772 ui_widget_show_hide(GTK_WIDGET(main_widgets
.toolbar
), toolbar_prefs
.visible
);
776 G_MODULE_EXPORT
void on_fullscreen1_toggled(GtkCheckMenuItem
*checkmenuitem
, gpointer user_data
)
781 ui_prefs
.fullscreen
= (ui_prefs
.fullscreen
) ? FALSE
: TRUE
;
786 G_MODULE_EXPORT
void on_show_messages_window1_toggled(GtkCheckMenuItem
*checkmenuitem
, gpointer user_data
)
791 ui_prefs
.msgwindow_visible
= (ui_prefs
.msgwindow_visible
) ? FALSE
: TRUE
;
792 msgwin_show_hide(ui_prefs
.msgwindow_visible
);
796 G_MODULE_EXPORT
void on_menu_color_schemes_activate(GtkImageMenuItem
*imagemenuitem
, gpointer user_data
)
798 highlighting_show_color_scheme_dialog();
802 G_MODULE_EXPORT
void on_markers_margin1_toggled(GtkCheckMenuItem
*checkmenuitem
, gpointer user_data
)
807 editor_prefs
.show_markers_margin
= ! editor_prefs
.show_markers_margin
;
808 ui_toggle_editor_features(GEANY_EDITOR_SHOW_MARKERS_MARGIN
);
812 G_MODULE_EXPORT
void on_show_line_numbers1_toggled(GtkCheckMenuItem
*checkmenuitem
, gpointer user_data
)
817 editor_prefs
.show_linenumber_margin
= ! editor_prefs
.show_linenumber_margin
;
818 ui_toggle_editor_features(GEANY_EDITOR_SHOW_LINE_NUMBERS
);
822 G_MODULE_EXPORT
void on_menu_show_white_space1_toggled(GtkCheckMenuItem
*checkmenuitem
, gpointer user_data
)
827 editor_prefs
.show_white_space
= ! editor_prefs
.show_white_space
;
828 ui_toggle_editor_features(GEANY_EDITOR_SHOW_WHITE_SPACE
);
832 G_MODULE_EXPORT
void on_menu_show_line_endings1_toggled(GtkCheckMenuItem
*checkmenuitem
, gpointer user_data
)
837 editor_prefs
.show_line_endings
= ! editor_prefs
.show_line_endings
;
838 ui_toggle_editor_features(GEANY_EDITOR_SHOW_LINE_ENDINGS
);
842 G_MODULE_EXPORT
void on_menu_show_indentation_guides1_toggled(GtkCheckMenuItem
*checkmenuitem
, gpointer user_data
)
847 editor_prefs
.show_indent_guide
= ! editor_prefs
.show_indent_guide
;
848 ui_toggle_editor_features(GEANY_EDITOR_SHOW_INDENTATION_GUIDES
);
852 G_MODULE_EXPORT
void on_line_wrapping1_toggled(GtkCheckMenuItem
*checkmenuitem
, gpointer user_data
)
854 if (! ignore_callback
)
856 GeanyDocument
*doc
= document_get_current();
857 g_return_if_fail(doc
!= NULL
);
859 editor_set_line_wrapping(doc
->editor
, ! doc
->editor
->line_wrapping
);
864 G_MODULE_EXPORT
void on_set_file_readonly1_toggled(GtkCheckMenuItem
*checkmenuitem
, gpointer user_data
)
866 if (! ignore_callback
)
868 GeanyDocument
*doc
= document_get_current();
869 g_return_if_fail(doc
!= NULL
);
871 doc
->readonly
= ! doc
->readonly
;
872 sci_set_readonly(doc
->editor
->sci
, doc
->readonly
);
873 ui_update_tab_status(doc
);
874 ui_update_statusbar(doc
, -1);
879 G_MODULE_EXPORT
void on_use_auto_indentation1_toggled(GtkCheckMenuItem
*checkmenuitem
, gpointer user_data
)
881 if (! ignore_callback
)
883 GeanyDocument
*doc
= document_get_current();
884 g_return_if_fail(doc
!= NULL
);
886 doc
->editor
->auto_indent
= ! doc
->editor
->auto_indent
;
891 static void find_usage(gboolean in_session
)
895 GeanyDocument
*doc
= document_get_current();
897 g_return_if_fail(doc
!= NULL
);
899 if (sci_has_selection(doc
->editor
->sci
))
900 { /* take selected text if there is a selection */
901 search_text
= sci_get_selection_contents(doc
->editor
->sci
);
902 flags
= SCFIND_MATCHCASE
;
906 editor_find_current_word_sciwc(doc
->editor
, -1,
907 editor_info
.current_word
, GEANY_MAX_WORD_LENGTH
);
908 search_text
= g_strdup(editor_info
.current_word
);
909 flags
= SCFIND_MATCHCASE
| SCFIND_WHOLEWORD
;
912 search_find_usage(search_text
, search_text
, flags
, in_session
);
917 G_MODULE_EXPORT
void on_find_document_usage1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
923 G_MODULE_EXPORT
void on_find_usage1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
929 static void goto_tag(gboolean definition
)
931 GeanyDocument
*doc
= document_get_current();
933 g_return_if_fail(doc
!= NULL
);
935 /* update cursor pos for navigating back afterwards */
936 if (!sci_has_selection(doc
->editor
->sci
))
937 sci_set_current_position(doc
->editor
->sci
, editor_info
.click_pos
, FALSE
);
939 /* use the keybinding callback as it checks for selections as well as current word */
941 keybindings_send_command(GEANY_KEY_GROUP_GOTO
, GEANY_KEYS_GOTO_TAGDEFINITION
);
943 keybindings_send_command(GEANY_KEY_GROUP_GOTO
, GEANY_KEYS_GOTO_TAGDECLARATION
);
947 G_MODULE_EXPORT
void on_goto_tag_definition1(GtkMenuItem
*menuitem
, gpointer user_data
)
953 G_MODULE_EXPORT
void on_goto_tag_declaration1(GtkMenuItem
*menuitem
, gpointer user_data
)
959 G_MODULE_EXPORT
void on_count_words1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
965 G_MODULE_EXPORT
void on_show_color_chooser1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
968 GeanyDocument
*doc
= document_get_current();
971 g_return_if_fail(doc
!= NULL
);
973 pos
= sci_get_current_position(doc
->editor
->sci
);
974 editor_find_current_word(doc
->editor
, pos
, colour
, sizeof colour
, GEANY_WORDCHARS
"#");
975 tools_color_chooser(colour
);
979 void on_toolbutton_compile_clicked(GtkAction
*action
, gpointer user_data
)
981 keybindings_send_command(GEANY_KEY_GROUP_BUILD
, GEANY_KEYS_BUILD_COMPILE
);
985 G_MODULE_EXPORT
void on_find1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
987 search_show_find_dialog();
991 G_MODULE_EXPORT
void on_find_next1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
993 search_find_again(FALSE
);
997 G_MODULE_EXPORT
void on_find_previous1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
999 if (search_data
.flags
& SCFIND_REGEXP
)
1000 /* Can't reverse search order for a regex (find next ignores search backwards) */
1003 search_find_again(TRUE
);
1007 G_MODULE_EXPORT
void on_find_nextsel1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1009 search_find_selection(document_get_current(), FALSE
);
1013 G_MODULE_EXPORT
void on_find_prevsel1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1015 search_find_selection(document_get_current(), TRUE
);
1019 G_MODULE_EXPORT
void on_replace1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1021 search_show_replace_dialog();
1025 G_MODULE_EXPORT
void on_find_in_files1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1027 search_show_find_in_files_dialog(NULL
);
1031 static void get_line_and_offset_from_text(const gchar
*text
, gint
*line_no
, gint
*offset
)
1033 if (*text
== '+' || *text
== '-')
1035 *line_no
= atoi(text
+ 1);
1036 *offset
= (*text
== '+') ? 1 : -1;
1040 *line_no
= atoi(text
) - 1;
1046 G_MODULE_EXPORT
void on_go_to_line_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1048 static gchar value
[16] = "";
1051 result
= dialogs_show_input_goto_line(
1052 _("Go to Line"), GTK_WINDOW(main_widgets
.window
),
1053 _("Enter the line you want to go to:"), value
);
1056 GeanyDocument
*doc
= document_get_current();
1060 g_return_if_fail(doc
!= NULL
);
1062 get_line_and_offset_from_text(result
, &line_no
, &offset
);
1063 if (! editor_goto_line(doc
->editor
, line_no
, offset
))
1065 /* remember value for future calls */
1066 g_snprintf(value
, sizeof(value
), "%s", result
);
1073 void on_toolbutton_goto_entry_activate(GtkAction
*action
, const gchar
*text
, gpointer user_data
)
1075 GeanyDocument
*doc
= document_get_current();
1079 g_return_if_fail(doc
!= NULL
);
1081 get_line_and_offset_from_text(text
, &line_no
, &offset
);
1082 if (! editor_goto_line(doc
->editor
, line_no
, offset
))
1085 keybindings_send_command(GEANY_KEY_GROUP_FOCUS
, GEANY_KEYS_FOCUS_EDITOR
);
1089 void on_toolbutton_goto_clicked(GtkAction
*action
, gpointer user_data
)
1091 GtkWidget
*entry
= toolbar_get_widget_child_by_name("GotoEntry");
1095 const gchar
*text
= gtk_entry_get_text(GTK_ENTRY(entry
));
1097 on_toolbutton_goto_entry_activate(NULL
, text
, NULL
);
1100 on_go_to_line_activate(NULL
, NULL
);
1104 G_MODULE_EXPORT
void on_help1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1108 uri
= utils_get_help_url(NULL
);
1109 utils_open_browser(uri
);
1114 G_MODULE_EXPORT
void on_help_shortcuts1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1116 keybindings_show_shortcuts();
1120 G_MODULE_EXPORT
void on_website1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1122 utils_open_browser(GEANY_HOMEPAGE
);
1126 G_MODULE_EXPORT
void on_help_menu_item_donate_activate(GtkMenuItem
*item
, gpointer user_data
)
1128 utils_open_browser(GEANY_DONATE
);
1132 G_MODULE_EXPORT
void on_help_menu_item_wiki_activate(GtkMenuItem
*item
, gpointer user_data
)
1134 utils_open_browser(GEANY_WIKI
);
1138 G_MODULE_EXPORT
void on_help_menu_item_bug_report_activate(GtkMenuItem
*item
, gpointer user_data
)
1140 utils_open_browser(GEANY_BUG_REPORT
);
1144 G_MODULE_EXPORT
void on_comments_function_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1146 GeanyDocument
*doc
= document_get_current();
1148 const gchar
*cur_tag
= NULL
;
1149 gint line
= -1, pos
= 0;
1151 if (doc
== NULL
|| doc
->file_type
== NULL
)
1153 ui_set_statusbar(FALSE
,
1154 _("Please set the filetype for the current file before using this function."));
1158 /* symbols_get_current_function returns -1 on failure, so sci_get_position_from_line
1159 * returns the current position, so it should be safe */
1160 line
= symbols_get_current_function(doc
, &cur_tag
);
1161 pos
= sci_get_position_from_line(doc
->editor
->sci
, line
);
1163 text
= templates_get_template_function(doc
, cur_tag
);
1165 sci_start_undo_action(doc
->editor
->sci
);
1166 sci_insert_text(doc
->editor
->sci
, pos
, text
);
1167 sci_end_undo_action(doc
->editor
->sci
);
1172 G_MODULE_EXPORT
void on_comments_multiline_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1174 GeanyDocument
*doc
= document_get_current();
1176 if (doc
== NULL
|| doc
->file_type
== NULL
)
1178 ui_set_statusbar(FALSE
,
1179 _("Please set the filetype for the current file before using this function."));
1183 verify_click_pos(doc
); /* make sure that the click_pos is valid */
1185 if (doc
->file_type
->comment_open
|| doc
->file_type
->comment_single
)
1186 editor_insert_multiline_comment(doc
->editor
);
1192 G_MODULE_EXPORT
void on_comments_gpl_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1194 GeanyDocument
*doc
= document_get_current();
1197 g_return_if_fail(doc
!= NULL
);
1199 text
= templates_get_template_licence(doc
, GEANY_TEMPLATE_GPL
);
1201 verify_click_pos(doc
); /* make sure that the click_pos is valid */
1203 sci_start_undo_action(doc
->editor
->sci
);
1204 sci_insert_text(doc
->editor
->sci
, editor_info
.click_pos
, text
);
1205 sci_end_undo_action(doc
->editor
->sci
);
1210 G_MODULE_EXPORT
void on_comments_bsd_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1212 GeanyDocument
*doc
= document_get_current();
1215 g_return_if_fail(doc
!= NULL
);
1217 text
= templates_get_template_licence(doc
, GEANY_TEMPLATE_BSD
);
1219 verify_click_pos(doc
); /* make sure that the click_pos is valid */
1221 sci_start_undo_action(doc
->editor
->sci
);
1222 sci_insert_text(doc
->editor
->sci
, editor_info
.click_pos
, text
);
1223 sci_end_undo_action(doc
->editor
->sci
);
1229 G_MODULE_EXPORT
void on_comments_changelog_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1231 GeanyDocument
*doc
= document_get_current();
1234 g_return_if_fail(doc
!= NULL
);
1236 text
= templates_get_template_changelog(doc
);
1237 sci_start_undo_action(doc
->editor
->sci
);
1238 sci_insert_text(doc
->editor
->sci
, 0, text
);
1239 /* sets the cursor to the right position to type the changelog text,
1240 * the template has 21 chars + length of name and email */
1241 sci_goto_pos(doc
->editor
->sci
, 21 + strlen(template_prefs
.developer
) + strlen(template_prefs
.mail
), TRUE
);
1242 sci_end_undo_action(doc
->editor
->sci
);
1248 G_MODULE_EXPORT
void on_comments_fileheader_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1250 GeanyDocument
*doc
= document_get_current();
1255 g_return_if_fail(doc
!= NULL
);
1257 ft
= doc
->file_type
;
1258 fname
= doc
->file_name
;
1259 text
= templates_get_template_fileheader(FILETYPE_ID(ft
), fname
);
1261 sci_start_undo_action(doc
->editor
->sci
);
1262 sci_insert_text(doc
->editor
->sci
, 0, text
);
1263 sci_goto_pos(doc
->editor
->sci
, 0, FALSE
);
1264 sci_end_undo_action(doc
->editor
->sci
);
1269 void on_insert_date_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1271 GeanyDocument
*doc
= document_get_current();
1272 const gchar
*format
= NULL
;
1275 g_return_if_fail(doc
!= NULL
);
1277 /* set default value */
1278 if (utils_str_equal("", ui_prefs
.custom_date_format
))
1280 g_free(ui_prefs
.custom_date_format
);
1281 ui_prefs
.custom_date_format
= g_strdup("%d.%m.%Y");
1284 if (utils_str_equal(_("dd.mm.yyyy"), (gchar
*) user_data
))
1285 format
= "%d.%m.%Y";
1286 else if (utils_str_equal(_("mm.dd.yyyy"), (gchar
*) user_data
))
1287 format
= "%m.%d.%Y";
1288 else if (utils_str_equal(_("yyyy/mm/dd"), (gchar
*) user_data
))
1289 format
= "%Y/%m/%d";
1290 else if (utils_str_equal(_("dd.mm.yyyy hh:mm:ss"), (gchar
*) user_data
))
1291 format
= "%d.%m.%Y %H:%M:%S";
1292 else if (utils_str_equal(_("mm.dd.yyyy hh:mm:ss"), (gchar
*) user_data
))
1293 format
= "%m.%d.%Y %H:%M:%S";
1294 else if (utils_str_equal(_("yyyy/mm/dd hh:mm:ss"), (gchar
*) user_data
))
1295 format
= "%Y/%m/%d %H:%M:%S";
1296 else if (utils_str_equal(_("_Use Custom Date Format"), (gchar
*) user_data
))
1297 format
= ui_prefs
.custom_date_format
;
1300 gchar
*str
= dialogs_show_input(_("Custom Date Format"), GTK_WINDOW(main_widgets
.window
),
1301 _("Enter here a custom date and time format. "
1302 "You can use any conversion specifiers which can be used with the ANSI C strftime function."),
1303 ui_prefs
.custom_date_format
);
1305 SETPTR(ui_prefs
.custom_date_format
, str
);
1309 time_str
= utils_get_date_time(format
, NULL
);
1310 if (time_str
!= NULL
)
1312 verify_click_pos(doc
); /* make sure that the click_pos is valid */
1314 sci_start_undo_action(doc
->editor
->sci
);
1315 sci_insert_text(doc
->editor
->sci
, editor_info
.click_pos
, time_str
);
1316 sci_goto_pos(doc
->editor
->sci
, editor_info
.click_pos
+ strlen(time_str
), FALSE
);
1317 sci_end_undo_action(doc
->editor
->sci
);
1323 ui_set_statusbar(TRUE
,
1324 _("Date format string could not be converted (possibly too long)."));
1329 void on_insert_include_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1331 GeanyDocument
*doc
= document_get_current();
1335 g_return_if_fail(doc
!= NULL
);
1336 g_return_if_fail(user_data
!= NULL
);
1338 verify_click_pos(doc
); /* make sure that the click_pos is valid */
1340 if (utils_str_equal(user_data
, "blank"))
1342 text
= g_strdup("#include \"\"\n");
1343 pos
= editor_info
.click_pos
+ 10;
1347 text
= g_strconcat("#include <", user_data
, ">\n", NULL
);
1350 sci_start_undo_action(doc
->editor
->sci
);
1351 sci_insert_text(doc
->editor
->sci
, editor_info
.click_pos
, text
);
1352 sci_end_undo_action(doc
->editor
->sci
);
1355 sci_goto_pos(doc
->editor
->sci
, pos
, FALSE
);
1359 G_MODULE_EXPORT
void on_file_properties_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1361 GeanyDocument
*doc
= document_get_current();
1362 g_return_if_fail(doc
!= NULL
);
1364 dialogs_show_file_properties(doc
);
1368 G_MODULE_EXPORT
void on_menu_fold_all1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1370 GeanyDocument
*doc
= document_get_current();
1371 g_return_if_fail(doc
!= NULL
);
1373 editor_fold_all(doc
->editor
);
1377 G_MODULE_EXPORT
void on_menu_unfold_all1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1379 GeanyDocument
*doc
= document_get_current();
1380 g_return_if_fail(doc
!= NULL
);
1382 editor_unfold_all(doc
->editor
);
1386 void on_toolbutton_run_clicked(GtkAction
*action
, gpointer user_data
)
1388 keybindings_send_command(GEANY_KEY_GROUP_BUILD
, GEANY_KEYS_BUILD_RUN
);
1392 G_MODULE_EXPORT
void on_menu_remove_indicators1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1394 GeanyDocument
*doc
= document_get_current();
1395 g_return_if_fail(doc
!= NULL
);
1397 editor_indicator_clear(doc
->editor
, GEANY_INDICATOR_ERROR
);
1401 G_MODULE_EXPORT
void on_print1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1403 GeanyDocument
*doc
= document_get_current();
1404 g_return_if_fail(doc
!= NULL
);
1406 printing_print_doc(doc
);
1410 G_MODULE_EXPORT
void on_menu_select_all1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1412 GeanyDocument
*doc
= document_get_current();
1413 g_return_if_fail(doc
!= NULL
);
1415 sci_select_all(doc
->editor
->sci
);
1419 G_MODULE_EXPORT
void on_menu_show_sidebar1_toggled(GtkCheckMenuItem
*checkmenuitem
, gpointer user_data
)
1421 if (ignore_callback
)
1424 ui_prefs
.sidebar_visible
= ! ui_prefs
.sidebar_visible
;
1426 /* show built-in tabs if no tabs visible */
1427 if (ui_prefs
.sidebar_visible
&&
1428 ! interface_prefs
.sidebar_openfiles_visible
&& ! interface_prefs
.sidebar_symbol_visible
&&
1429 gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_widgets
.sidebar_notebook
)) <= 2)
1431 interface_prefs
.sidebar_openfiles_visible
= TRUE
;
1432 interface_prefs
.sidebar_symbol_visible
= TRUE
;
1435 /* if window has input focus, set it back to the editor before toggling off */
1436 if (! ui_prefs
.sidebar_visible
&&
1437 gtk_container_get_focus_child(GTK_CONTAINER(main_widgets
.sidebar_notebook
)) != NULL
)
1439 keybindings_send_command(GEANY_KEY_GROUP_FOCUS
, GEANY_KEYS_FOCUS_EDITOR
);
1442 ui_sidebar_show_hide();
1446 G_MODULE_EXPORT
void on_menu_write_unicode_bom1_toggled(GtkCheckMenuItem
*checkmenuitem
, gpointer user_data
)
1448 if (! ignore_callback
)
1450 GeanyDocument
*doc
= document_get_current();
1452 g_return_if_fail(doc
!= NULL
);
1459 document_undo_add(doc
, UNDO_BOM
, GINT_TO_POINTER(doc
->has_bom
));
1461 doc
->has_bom
= ! doc
->has_bom
;
1463 ui_update_statusbar(doc
, -1);
1468 G_MODULE_EXPORT
void on_menu_comment_line1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1470 GeanyDocument
*doc
= document_get_current();
1471 g_return_if_fail(doc
!= NULL
);
1473 editor_do_comment(doc
->editor
, -1, FALSE
, FALSE
, TRUE
);
1477 G_MODULE_EXPORT
void on_menu_uncomment_line1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1479 GeanyDocument
*doc
= document_get_current();
1480 g_return_if_fail(doc
!= NULL
);
1482 editor_do_uncomment(doc
->editor
, -1, FALSE
);
1486 G_MODULE_EXPORT
void on_menu_toggle_line_commentation1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1488 GeanyDocument
*doc
= document_get_current();
1489 g_return_if_fail(doc
!= NULL
);
1491 editor_do_comment_toggle(doc
->editor
);
1495 G_MODULE_EXPORT
void on_menu_increase_indent1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1497 GeanyDocument
*doc
= document_get_current();
1498 g_return_if_fail(doc
!= NULL
);
1500 editor_indent(doc
->editor
, TRUE
);
1504 G_MODULE_EXPORT
void on_menu_decrease_indent1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1506 GeanyDocument
*doc
= document_get_current();
1507 g_return_if_fail(doc
!= NULL
);
1509 editor_indent(doc
->editor
, FALSE
);
1513 G_MODULE_EXPORT
void on_next_message1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1515 if (! ui_tree_view_find_next(GTK_TREE_VIEW(msgwindow
.tree_msg
),
1516 msgwin_goto_messages_file_line
))
1517 ui_set_statusbar(FALSE
, _("No more message items."));
1521 G_MODULE_EXPORT
void on_previous_message1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1523 if (! ui_tree_view_find_previous(GTK_TREE_VIEW(msgwindow
.tree_msg
),
1524 msgwin_goto_messages_file_line
))
1525 ui_set_statusbar(FALSE
, _("No more message items."));
1529 G_MODULE_EXPORT
void on_menu_comments_multiline_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1531 insert_callback_from_menu
= TRUE
;
1532 on_comments_multiline_activate(menuitem
, user_data
);
1536 G_MODULE_EXPORT
void on_menu_comments_gpl_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1538 insert_callback_from_menu
= TRUE
;
1539 on_comments_gpl_activate(menuitem
, user_data
);
1543 G_MODULE_EXPORT
void on_menu_comments_bsd_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1545 insert_callback_from_menu
= TRUE
;
1546 on_comments_bsd_activate(menuitem
, user_data
);
1550 void on_menu_insert_include_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1552 insert_callback_from_menu
= TRUE
;
1553 on_insert_include_activate(menuitem
, user_data
);
1557 void on_menu_insert_date_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1559 insert_callback_from_menu
= TRUE
;
1560 on_insert_date_activate(menuitem
, user_data
);
1564 G_MODULE_EXPORT
void on_project_new1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1570 G_MODULE_EXPORT
void on_project_open1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1576 G_MODULE_EXPORT
void on_project_close1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1578 project_close(TRUE
);
1582 G_MODULE_EXPORT
void on_project_properties1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1584 project_properties();
1588 G_MODULE_EXPORT
void on_menu_project1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1590 static GtkWidget
*item_close
= NULL
;
1591 static GtkWidget
*item_properties
= NULL
;
1593 if (item_close
== NULL
)
1595 item_close
= ui_lookup_widget(main_widgets
.window
, "project_close1");
1596 item_properties
= ui_lookup_widget(main_widgets
.window
, "project_properties1");
1599 gtk_widget_set_sensitive(item_close
, (app
->project
!= NULL
));
1600 gtk_widget_set_sensitive(item_properties
, (app
->project
!= NULL
));
1601 gtk_widget_set_sensitive(ui_widgets
.recent_projects_menuitem
,
1602 g_queue_get_length(ui_prefs
.recent_projects_queue
) > 0);
1606 G_MODULE_EXPORT
void on_menu_open_selected_file1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1608 GeanyDocument
*doc
= document_get_current();
1613 wc
= GEANY_WORDCHARS
"./-" "\\";
1615 wc
= GEANY_WORDCHARS
"./-";
1618 g_return_if_fail(doc
!= NULL
);
1620 sel
= editor_get_default_selection(doc
->editor
, TRUE
, wc
);
1621 SETPTR(sel
, utils_get_locale_from_utf8(sel
));
1625 gchar
*filename
= NULL
;
1627 if (g_path_is_absolute(sel
))
1628 filename
= g_strdup(sel
);
1630 { /* relative filename, add the path of the current file */
1633 path
= utils_get_current_file_dir_utf8();
1634 SETPTR(path
, utils_get_locale_from_utf8(path
));
1636 path
= g_get_current_dir();
1638 filename
= g_build_path(G_DIR_SEPARATOR_S
, path
, sel
, NULL
);
1640 if (! g_file_test(filename
, G_FILE_TEST_EXISTS
) &&
1641 app
->project
!= NULL
&& !EMPTY(app
->project
->base_path
))
1643 /* try the project's base path */
1644 SETPTR(path
, project_get_base_path());
1645 SETPTR(path
, utils_get_locale_from_utf8(path
));
1646 SETPTR(filename
, g_build_path(G_DIR_SEPARATOR_S
, path
, sel
, NULL
));
1650 if (! g_file_test(filename
, G_FILE_TEST_EXISTS
))
1651 SETPTR(filename
, g_build_path(G_DIR_SEPARATOR_S
, "/usr/local/include", sel
, NULL
));
1653 if (! g_file_test(filename
, G_FILE_TEST_EXISTS
))
1654 SETPTR(filename
, g_build_path(G_DIR_SEPARATOR_S
, "/usr/include", sel
, NULL
));
1658 if (g_file_test(filename
, G_FILE_TEST_EXISTS
))
1659 document_open_file(filename
, FALSE
, NULL
, NULL
);
1662 SETPTR(sel
, utils_get_utf8_from_locale(sel
));
1663 ui_set_statusbar(TRUE
, _("Could not open file %s (File not found)"), sel
);
1672 G_MODULE_EXPORT
void on_remove_markers1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1674 GeanyDocument
*doc
= document_get_current();
1675 g_return_if_fail(doc
!= NULL
);
1677 sci_marker_delete_all(doc
->editor
->sci
, 0); /* delete the yellow tag marker */
1678 sci_marker_delete_all(doc
->editor
->sci
, 1); /* delete user markers */
1679 editor_indicator_clear(doc
->editor
, GEANY_INDICATOR_SEARCH
);
1683 G_MODULE_EXPORT
void on_load_tags1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1685 symbols_show_load_tags_dialog();
1689 G_MODULE_EXPORT
void on_context_action1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1691 gchar
*word
, *command
;
1692 GError
*error
= NULL
;
1693 GeanyDocument
*doc
= document_get_current();
1695 g_return_if_fail(doc
!= NULL
);
1697 if (sci_has_selection(doc
->editor
->sci
))
1698 { /* take selected text if there is a selection */
1699 word
= sci_get_selection_contents(doc
->editor
->sci
);
1703 word
= g_strdup(editor_info
.current_word
);
1706 /* use the filetype specific command if available, fallback to global command otherwise */
1707 if (doc
->file_type
!= NULL
&&
1708 !EMPTY(doc
->file_type
->context_action_cmd
))
1710 command
= g_strdup(doc
->file_type
->context_action_cmd
);
1714 command
= g_strdup(tool_prefs
.context_action_cmd
);
1717 /* substitute the wildcard %s and run the command if it is non empty */
1718 if (G_LIKELY(!EMPTY(command
)))
1720 utils_str_replace_all(&command
, "%s", word
);
1722 if (! g_spawn_command_line_async(command
, &error
))
1724 ui_set_statusbar(TRUE
, "Context action command failed: %s", error
->message
);
1725 g_error_free(error
);
1733 G_MODULE_EXPORT
void on_menu_toggle_all_additional_widgets1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1735 static gint hide_all
= -1;
1736 GtkCheckMenuItem
*msgw
= GTK_CHECK_MENU_ITEM(
1737 ui_lookup_widget(main_widgets
.window
, "menu_show_messages_window1"));
1738 GtkCheckMenuItem
*toolbari
= GTK_CHECK_MENU_ITEM(
1739 ui_lookup_widget(main_widgets
.window
, "menu_show_toolbar1"));
1741 /* get the initial state (necessary if Geany was closed with hide_all = TRUE) */
1742 if (G_UNLIKELY(hide_all
== -1))
1744 if (! gtk_check_menu_item_get_active(msgw
) &&
1745 ! interface_prefs
.show_notebook_tabs
&&
1746 ! gtk_check_menu_item_get_active(toolbari
))
1754 hide_all
= ! hide_all
; /* toggle */
1758 if (gtk_check_menu_item_get_active(msgw
))
1759 gtk_check_menu_item_set_active(msgw
, ! gtk_check_menu_item_get_active(msgw
));
1761 interface_prefs
.show_notebook_tabs
= FALSE
;
1762 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(main_widgets
.notebook
), interface_prefs
.show_notebook_tabs
);
1764 ui_statusbar_showhide(FALSE
);
1766 if (gtk_check_menu_item_get_active(toolbari
))
1767 gtk_check_menu_item_set_active(toolbari
, ! gtk_check_menu_item_get_active(toolbari
));
1772 if (! gtk_check_menu_item_get_active(msgw
))
1773 gtk_check_menu_item_set_active(msgw
, ! gtk_check_menu_item_get_active(msgw
));
1775 interface_prefs
.show_notebook_tabs
= TRUE
;
1776 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(main_widgets
.notebook
), interface_prefs
.show_notebook_tabs
);
1778 ui_statusbar_showhide(TRUE
);
1780 if (! gtk_check_menu_item_get_active(toolbari
))
1781 gtk_check_menu_item_set_active(toolbari
, ! gtk_check_menu_item_get_active(toolbari
));
1786 void on_toolbutton_forward_activate(GtkAction
*menuitem
, gpointer user_data
)
1788 navqueue_go_forward();
1792 void on_toolbutton_back_activate(GtkAction
*menuitem
, gpointer user_data
)
1798 gboolean
on_motion_event(GtkWidget
*widget
, GdkEventMotion
*event
, gpointer user_data
)
1800 if (prefs
.auto_focus
&& ! gtk_widget_has_focus(widget
))
1801 gtk_widget_grab_focus(widget
);
1807 static void set_indent_type(GtkCheckMenuItem
*menuitem
, GeanyIndentType type
)
1811 if (ignore_callback
|| ! gtk_check_menu_item_get_active(menuitem
))
1814 doc
= document_get_current();
1815 g_return_if_fail(doc
!= NULL
);
1817 editor_set_indent(doc
->editor
, type
, doc
->editor
->indent_width
);
1818 ui_update_statusbar(doc
, -1);
1822 G_MODULE_EXPORT
void on_tabs1_activate(GtkCheckMenuItem
*menuitem
, gpointer user_data
)
1824 set_indent_type(menuitem
, GEANY_INDENT_TYPE_TABS
);
1828 G_MODULE_EXPORT
void on_spaces1_activate(GtkCheckMenuItem
*menuitem
, gpointer user_data
)
1830 set_indent_type(menuitem
, GEANY_INDENT_TYPE_SPACES
);
1834 G_MODULE_EXPORT
void on_tabs_and_spaces1_activate(GtkCheckMenuItem
*menuitem
, gpointer user_data
)
1836 set_indent_type(menuitem
, GEANY_INDENT_TYPE_BOTH
);
1840 G_MODULE_EXPORT
void on_strip_trailing_spaces1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1844 if (ignore_callback
)
1847 doc
= document_get_current();
1848 g_return_if_fail(doc
!= NULL
);
1850 editor_strip_trailing_spaces(doc
->editor
);
1854 G_MODULE_EXPORT
void on_page_setup1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1856 printing_page_setup_gtk();
1860 G_MODULE_EXPORT gboolean
on_escape_key_press_event(GtkWidget
*widget
, GdkEventKey
*event
, gpointer user_data
)
1862 guint state
= event
->state
& gtk_accelerator_get_default_mod_mask();
1864 /* make pressing escape in the sidebar and toolbar focus the editor */
1865 if (event
->keyval
== GDK_Escape
&& state
== 0)
1867 keybindings_send_command(GEANY_KEY_GROUP_FOCUS
, GEANY_KEYS_FOCUS_EDITOR
);
1874 G_MODULE_EXPORT
void on_line_breaking1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1878 if (ignore_callback
)
1881 doc
= document_get_current();
1882 g_return_if_fail(doc
!= NULL
);
1884 doc
->editor
->line_breaking
= !doc
->editor
->line_breaking
;
1888 G_MODULE_EXPORT
void on_replace_spaces_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1890 GeanyDocument
*doc
= document_get_current();
1892 g_return_if_fail(doc
!= NULL
);
1894 editor_replace_spaces(doc
->editor
);
1898 G_MODULE_EXPORT
void on_search1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1900 GtkWidget
*next_message
= ui_lookup_widget(main_widgets
.window
, "next_message1");
1901 GtkWidget
*previous_message
= ui_lookup_widget(main_widgets
.window
, "previous_message1");
1902 gboolean have_messages
;
1904 /* enable commands if the messages window has any items */
1905 have_messages
= gtk_tree_model_iter_n_children(GTK_TREE_MODEL(msgwindow
.store_msg
),
1908 gtk_widget_set_sensitive(next_message
, have_messages
);
1909 gtk_widget_set_sensitive(previous_message
, have_messages
);
1913 /* simple implementation (vs. close all which doesn't close documents if cancelled),
1914 * if user_data is set, it is the GeanyDocument to keep */
1915 G_MODULE_EXPORT
void on_close_other_documents1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1918 GeanyDocument
*cur_doc
= user_data
;
1920 if (cur_doc
== NULL
)
1921 cur_doc
= document_get_current();
1923 for (i
= 0; i
< documents_array
->len
; i
++)
1925 GeanyDocument
*doc
= documents
[i
];
1927 if (doc
== cur_doc
|| ! doc
->is_valid
)
1930 if (! document_close(doc
))
1936 G_MODULE_EXPORT
void on_menu_reload_configuration1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1938 main_reload_configuration();
1942 G_MODULE_EXPORT
void on_debug_messages1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1944 log_show_debug_messages_dialog();
1948 G_MODULE_EXPORT
void on_send_selection_to_vte1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1951 if (vte_info
.have_vte
)
1952 vte_send_selection_to_vte();
1957 G_MODULE_EXPORT gboolean
on_window_state_event(GtkWidget
*widget
, GdkEventWindowState
*event
, gpointer user_data
)
1960 if (event
->changed_mask
& GDK_WINDOW_STATE_FULLSCREEN
)
1962 static GtkWidget
*menuitem
= NULL
;
1964 if (menuitem
== NULL
)
1965 menuitem
= ui_lookup_widget(widget
, "menu_fullscreen1");
1967 ignore_callback
= TRUE
;
1969 ui_prefs
.fullscreen
= (event
->new_window_state
& GDK_WINDOW_STATE_FULLSCREEN
) ? TRUE
: FALSE
;
1970 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem
), ui_prefs
.fullscreen
);
1972 ignore_callback
= FALSE
;
1978 static void show_notebook_page(const gchar
*notebook_name
, const gchar
*page_name
)
1981 GtkNotebook
*notebook
;
1983 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, page_name
);
1984 notebook
= GTK_NOTEBOOK(ui_lookup_widget(ui_widgets
.prefs_dialog
, notebook_name
));
1986 if (notebook
!= NULL
&& widget
!= NULL
)
1987 gtk_notebook_set_current_page(notebook
, gtk_notebook_page_num(notebook
, widget
));
1991 G_MODULE_EXPORT
void on_customize_toolbar1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1993 prefs_show_dialog();
1995 /* select the Interface page */
1996 show_notebook_page("notebook2", "notebook6");
1997 /* select the Toolbar subpage */
1998 show_notebook_page("notebook6", "vbox15");
2002 G_MODULE_EXPORT
void on_button_customize_toolbar_clicked(GtkButton
*button
, gpointer user_data
)
2004 toolbar_configure(GTK_WINDOW(ui_widgets
.prefs_dialog
));
2008 G_MODULE_EXPORT
void on_cut_current_lines1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
2010 keybindings_send_command(GEANY_KEY_GROUP_CLIPBOARD
, GEANY_KEYS_CLIPBOARD_CUTLINE
);
2014 G_MODULE_EXPORT
void on_copy_current_lines1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
2016 keybindings_send_command(GEANY_KEY_GROUP_CLIPBOARD
, GEANY_KEYS_CLIPBOARD_COPYLINE
);
2020 G_MODULE_EXPORT
void on_delete_current_lines1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
2022 keybindings_send_command(GEANY_KEY_GROUP_EDITOR
, GEANY_KEYS_EDITOR_DELETELINE
);
2026 G_MODULE_EXPORT
void on_duplicate_line_or_selection1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
2028 keybindings_send_command(GEANY_KEY_GROUP_EDITOR
, GEANY_KEYS_EDITOR_DUPLICATELINE
);
2032 G_MODULE_EXPORT
void on_select_current_lines1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
2034 keybindings_send_command(GEANY_KEY_GROUP_SELECT
, GEANY_KEYS_SELECT_LINE
);
2038 G_MODULE_EXPORT
void on_select_current_paragraph1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
2040 keybindings_send_command(GEANY_KEY_GROUP_SELECT
, GEANY_KEYS_SELECT_PARAGRAPH
);
2044 G_MODULE_EXPORT
void on_insert_alternative_white_space1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
2046 keybindings_send_command(GEANY_KEY_GROUP_INSERT
, GEANY_KEYS_INSERT_ALTWHITESPACE
);
2050 G_MODULE_EXPORT
void on_go_to_next_marker1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
2052 keybindings_send_command(GEANY_KEY_GROUP_GOTO
, GEANY_KEYS_GOTO_NEXTMARKER
);
2056 G_MODULE_EXPORT
void on_go_to_previous_marker1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
2058 keybindings_send_command(GEANY_KEY_GROUP_GOTO
, GEANY_KEYS_GOTO_PREVIOUSMARKER
);
2062 G_MODULE_EXPORT
void on_reflow_lines_block1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
2064 keybindings_send_command(GEANY_KEY_GROUP_FORMAT
, GEANY_KEYS_FORMAT_REFLOWPARAGRAPH
);
2068 G_MODULE_EXPORT
void on_move_lines_up1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
2070 keybindings_send_command(GEANY_KEY_GROUP_EDITOR
, GEANY_KEYS_EDITOR_MOVELINEUP
);
2074 G_MODULE_EXPORT
void on_move_lines_down1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
2076 keybindings_send_command(GEANY_KEY_GROUP_EDITOR
, GEANY_KEYS_EDITOR_MOVELINEDOWN
);
2080 G_MODULE_EXPORT
void on_smart_line_indent1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
2082 keybindings_send_command(GEANY_KEY_GROUP_FORMAT
, GEANY_KEYS_FORMAT_AUTOINDENT
);
2086 G_MODULE_EXPORT
void on_plugin_preferences1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
2089 plugin_show_configure(NULL
);
2094 G_MODULE_EXPORT
void on_indent_width_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
2100 if (ignore_callback
)
2103 label
= ui_menu_item_get_text(menuitem
);
2104 width
= atoi(label
);
2107 doc
= document_get_current();
2108 if (doc
!= NULL
&& width
> 0)
2109 editor_set_indent_width(doc
->editor
, width
);
2113 G_MODULE_EXPORT
void on_reset_indentation1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
2118 document_apply_indent_settings(documents
[i
]);
2120 ui_update_statusbar(NULL
, -1);
2121 ui_document_show_hide(NULL
);
2125 G_MODULE_EXPORT
void on_mark_all1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
2127 keybindings_send_command(GEANY_KEY_GROUP_SEARCH
, GEANY_KEYS_SEARCH_MARKALL
);
2131 G_MODULE_EXPORT
void on_detect_type_from_file_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
2133 GeanyDocument
*doc
= document_get_current();
2134 GeanyIndentType type
;
2136 if (doc
!= NULL
&& document_detect_indent_type(doc
, &type
))
2138 editor_set_indent_type(doc
->editor
, type
);
2139 ui_document_show_hide(doc
);
2144 G_MODULE_EXPORT
void on_detect_width_from_file_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
2146 GeanyDocument
*doc
= document_get_current();
2149 if (doc
!= NULL
&& document_detect_indent_width(doc
, &width
))
2151 editor_set_indent_width(doc
->editor
, width
);
2152 ui_document_show_hide(doc
);