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
);
152 G_MODULE_EXPORT
void on_clone1_activate(GtkMenuItem
*menuitem
, gpointer user_data
);
155 /* flag to indicate that an insert callback was triggered from the file menu,
156 * so we need to store the current cursor position in editor_info.click_pos. */
157 static gboolean insert_callback_from_menu
= FALSE
;
159 /* represents the state at switching a notebook page(in the left treeviews widget), to not emit
160 * the selection-changed signal from tv.tree_openfiles */
161 /*static gboolean switch_tv_notebook_page = FALSE; */
164 static gboolean
check_no_unsaved(void)
168 for (i
= 0; i
< documents_array
->len
; i
++)
170 if (documents
[i
]->is_valid
&& documents
[i
]->changed
)
175 return TRUE
; /* no unsaved edits */
179 /* set editor_info.click_pos to the current cursor position if insert_callback_from_menu is TRUE
180 * to prevent invalid cursor positions which can cause segfaults */
181 static void verify_click_pos(GeanyDocument
*doc
)
183 if (insert_callback_from_menu
)
185 editor_info
.click_pos
= sci_get_current_position(doc
->editor
->sci
);
186 insert_callback_from_menu
= FALSE
;
191 /* should only be called from on_window_delete_event */
192 static void quit_app(void)
194 configuration_save();
196 if (app
->project
!= NULL
)
197 project_close(FALSE
); /* save project session files */
199 document_close_all();
201 main_status
.quitting
= TRUE
;
207 /* wrapper function to abort exit process if cancel button is pressed */
208 G_MODULE_EXPORT gboolean
on_window_delete_event(GtkWidget
*widget
, GdkEvent
*event
, gpointer gdata
)
210 main_status
.quitting
= TRUE
;
212 if (! check_no_unsaved())
214 if (document_account_for_unsaved())
221 if (! prefs
.confirm_exit
||
222 dialogs_show_question_full(NULL
, GTK_STOCK_QUIT
, GTK_STOCK_CANCEL
, NULL
,
223 _("Do you really want to quit?")))
229 main_status
.quitting
= FALSE
;
238 G_MODULE_EXPORT
void on_new1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
240 document_new_file(NULL
, NULL
, NULL
);
244 /* create a new file and copy file content and properties */
245 G_MODULE_EXPORT
void on_clone1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
247 GeanyDocument
*old_doc
= document_get_current();
250 document_clone(old_doc
);
254 G_MODULE_EXPORT
void on_save1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
256 gint cur_page
= gtk_notebook_get_current_page(GTK_NOTEBOOK(main_widgets
.notebook
));
257 GeanyDocument
*doc
= document_get_current();
259 if (doc
!= NULL
&& cur_page
>= 0)
261 document_save_file(doc
, ui_prefs
.allow_always_save
);
266 G_MODULE_EXPORT
void on_save_as1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
268 dialogs_show_save_as();
272 G_MODULE_EXPORT
void on_save_all1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
274 guint i
, max
= (guint
) gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_widgets
.notebook
));
275 GeanyDocument
*doc
, *cur_doc
= document_get_current();
278 /* iterate over documents in tabs order */
279 for (i
= 0; i
< max
; i
++)
281 doc
= document_get_from_page(i
);
285 if (document_save_file(doc
, FALSE
))
291 ui_set_statusbar(FALSE
, ngettext("%d file saved.", "%d files saved.", count
), count
);
292 /* saving may have changed window title, sidebar for another doc, so update */
293 sidebar_update_tag_list(cur_doc
, TRUE
);
294 ui_set_window_title(cur_doc
);
298 G_MODULE_EXPORT
void on_close_all1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
300 document_close_all();
304 G_MODULE_EXPORT
void on_close1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
306 GeanyDocument
*doc
= document_get_current();
313 G_MODULE_EXPORT
void on_quit1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
315 on_window_delete_event(NULL
, NULL
, NULL
);
319 G_MODULE_EXPORT
void on_file1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
321 gtk_widget_set_sensitive(ui_widgets
.recent_files_menuitem
,
322 g_queue_get_length(ui_prefs
.recent_queue
) > 0);
323 /* hide Page setup when GTK printing is not used */
324 ui_widget_show_hide(ui_widgets
.print_page_setup
, printing_prefs
.use_gtk_printing
);
328 /* edit actions, c&p & co, from menu bar and from popup menu */
329 G_MODULE_EXPORT
void on_edit1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
332 GeanyDocument
*doc
= document_get_current();
334 ui_update_menu_copy_items(doc
);
335 ui_update_insert_include_item(doc
, 1);
337 item
= ui_lookup_widget(main_widgets
.window
, "plugin_preferences1");
339 gtk_widget_hide(item
);
341 gtk_widget_set_sensitive(item
, plugins_have_preferences());
346 G_MODULE_EXPORT
void on_undo1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
348 GeanyDocument
*doc
= document_get_current();
350 g_return_if_fail(doc
!= NULL
);
352 if (document_can_undo(doc
))
354 sci_cancel(doc
->editor
->sci
);
360 G_MODULE_EXPORT
void on_redo1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
362 GeanyDocument
*doc
= document_get_current();
364 g_return_if_fail(doc
!= NULL
);
366 if (document_can_redo(doc
))
368 sci_cancel(doc
->editor
->sci
);
374 G_MODULE_EXPORT
void on_cut1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
376 GeanyDocument
*doc
= document_get_current();
377 GtkWidget
*focusw
= gtk_window_get_focus(GTK_WINDOW(main_widgets
.window
));
379 if (GTK_IS_EDITABLE(focusw
))
380 gtk_editable_cut_clipboard(GTK_EDITABLE(focusw
));
382 if (IS_SCINTILLA(focusw
) && doc
!= NULL
)
383 sci_cut(doc
->editor
->sci
);
385 if (GTK_IS_TEXT_VIEW(focusw
))
387 GtkTextBuffer
*buffer
= gtk_text_view_get_buffer(
388 GTK_TEXT_VIEW(focusw
));
389 gtk_text_buffer_cut_clipboard(buffer
, gtk_clipboard_get(GDK_NONE
), TRUE
);
394 G_MODULE_EXPORT
void on_copy1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
396 GeanyDocument
*doc
= document_get_current();
397 GtkWidget
*focusw
= gtk_window_get_focus(GTK_WINDOW(main_widgets
.window
));
399 if (GTK_IS_EDITABLE(focusw
))
400 gtk_editable_copy_clipboard(GTK_EDITABLE(focusw
));
402 if (IS_SCINTILLA(focusw
) && doc
!= NULL
)
403 sci_copy(doc
->editor
->sci
);
405 if (GTK_IS_TEXT_VIEW(focusw
))
407 GtkTextBuffer
*buffer
= gtk_text_view_get_buffer(
408 GTK_TEXT_VIEW(focusw
));
409 gtk_text_buffer_copy_clipboard(buffer
, gtk_clipboard_get(GDK_NONE
));
414 G_MODULE_EXPORT
void on_paste1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
416 GeanyDocument
*doc
= document_get_current();
417 GtkWidget
*focusw
= gtk_window_get_focus(GTK_WINDOW(main_widgets
.window
));
419 if (GTK_IS_EDITABLE(focusw
))
420 gtk_editable_paste_clipboard(GTK_EDITABLE(focusw
));
422 if (IS_SCINTILLA(focusw
) && doc
!= NULL
)
424 sci_paste(doc
->editor
->sci
);
427 if (GTK_IS_TEXT_VIEW(focusw
))
429 GtkTextBuffer
*buffer
= gtk_text_view_get_buffer(
430 GTK_TEXT_VIEW(focusw
));
431 gtk_text_buffer_paste_clipboard(buffer
, gtk_clipboard_get(GDK_NONE
), NULL
,
437 G_MODULE_EXPORT
void on_delete1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
439 GeanyDocument
*doc
= document_get_current();
440 GtkWidget
*focusw
= gtk_window_get_focus(GTK_WINDOW(main_widgets
.window
));
442 if (GTK_IS_EDITABLE(focusw
))
443 gtk_editable_delete_selection(GTK_EDITABLE(focusw
));
445 if (IS_SCINTILLA(focusw
) && doc
!= NULL
&& sci_has_selection(doc
->editor
->sci
))
446 sci_clear(doc
->editor
->sci
);
448 if (GTK_IS_TEXT_VIEW(focusw
))
450 GtkTextBuffer
*buffer
= gtk_text_view_get_buffer(
451 GTK_TEXT_VIEW(focusw
));
452 gtk_text_buffer_delete_selection(buffer
, TRUE
, TRUE
);
457 G_MODULE_EXPORT
void on_preferences1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
463 /* about menu item */
464 G_MODULE_EXPORT
void on_info1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
471 G_MODULE_EXPORT
void on_open1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
473 dialogs_show_open_file();
478 G_MODULE_EXPORT
void on_toolbutton_reload_clicked(GtkAction
*action
, gpointer user_data
)
480 GeanyDocument
*doc
= document_get_current();
482 g_return_if_fail(doc
!= NULL
);
484 document_reload_prompt(doc
, NULL
);
488 G_MODULE_EXPORT
void on_change_font1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
490 dialogs_show_open_font();
494 /* store text, clear search flags so we can use Search->Find Next/Previous */
495 static void setup_find(const gchar
*text
, gboolean backwards
)
497 SETPTR(search_data
.text
, g_strdup(text
));
498 SETPTR(search_data
.original_text
, g_strdup(text
));
499 search_data
.flags
= 0;
500 search_data
.backwards
= backwards
;
501 search_data
.search_bar
= TRUE
;
505 static void do_toolbar_search(const gchar
*text
, gboolean incremental
, gboolean backwards
)
507 GeanyDocument
*doc
= document_get_current();
510 setup_find(text
, backwards
);
511 result
= document_search_bar_find(doc
, search_data
.text
, 0, incremental
, backwards
);
512 if (search_data
.search_bar
)
513 ui_set_search_entry_background(toolbar_get_widget_child_by_name("SearchEntry"), result
);
518 void on_toolbar_search_entry_changed(GtkAction
*action
, const gchar
*text
, gpointer user_data
)
520 do_toolbar_search(text
, TRUE
, FALSE
);
525 void on_toolbar_search_entry_activate(GtkAction
*action
, const gchar
*text
, gpointer user_data
)
527 do_toolbar_search(text
, FALSE
, GPOINTER_TO_INT(user_data
));
532 void on_toolbutton_search_clicked(GtkAction
*action
, gpointer user_data
)
534 GeanyDocument
*doc
= document_get_current();
536 GtkWidget
*entry
= toolbar_get_widget_child_by_name("SearchEntry");
540 const gchar
*text
= gtk_entry_get_text(GTK_ENTRY(entry
));
542 setup_find(text
, FALSE
);
543 result
= document_search_bar_find(doc
, search_data
.text
, 0, FALSE
, FALSE
);
544 if (search_data
.search_bar
)
545 ui_set_search_entry_background(entry
, result
);
548 on_find1_activate(NULL
, NULL
);
552 /* hides toolbar from toolbar popup menu */
553 G_MODULE_EXPORT
void on_hide_toolbar1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
555 GtkWidget
*tool_item
= ui_lookup_widget(GTK_WIDGET(main_widgets
.window
), "menu_show_toolbar1");
556 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(tool_item
), FALSE
);
560 /* zoom in from menu bar and popup menu */
561 G_MODULE_EXPORT
void on_zoom_in1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
563 GeanyDocument
*doc
= document_get_current();
564 static gint done
= 1;
566 g_return_if_fail(doc
!= NULL
);
569 sci_set_line_numbers(doc
->editor
->sci
, editor_prefs
.show_linenumber_margin
,
570 (sci_get_zoom(doc
->editor
->sci
) / 2));
571 sci_zoom_in(doc
->editor
->sci
);
575 /* zoom out from menu bar and popup menu */
576 G_MODULE_EXPORT
void on_zoom_out1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
578 GeanyDocument
*doc
= document_get_current();
580 g_return_if_fail(doc
!= NULL
);
582 if (sci_get_zoom(doc
->editor
->sci
) == 0)
583 sci_set_line_numbers(doc
->editor
->sci
, editor_prefs
.show_linenumber_margin
, 0);
584 sci_zoom_out(doc
->editor
->sci
);
588 G_MODULE_EXPORT
void on_normal_size1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
590 GeanyDocument
*doc
= document_get_current();
592 g_return_if_fail(doc
!= NULL
);
594 sci_zoom_off(doc
->editor
->sci
);
595 sci_set_line_numbers(doc
->editor
->sci
, editor_prefs
.show_linenumber_margin
, 0);
599 static gboolean
delayed_check_disk_status(gpointer data
)
601 document_check_disk_status(data
, FALSE
);
606 /* Changes window-title after switching tabs and lots of other things.
607 * note: using 'after' makes Scintilla redraw before the UI, appearing more responsive */
608 G_MODULE_EXPORT
void on_notebook1_switch_page_after(GtkNotebook
*notebook
, gpointer page
,
609 guint page_num
, gpointer user_data
)
613 if (G_UNLIKELY(main_status
.opening_session_files
|| main_status
.closing_all
))
616 if (page_num
== (guint
) -1 && page
!= NULL
)
617 doc
= document_find_by_sci(SCINTILLA(page
));
619 doc
= document_get_from_page(page_num
);
623 sidebar_select_openfiles_item(doc
);
624 ui_save_buttons_toggle(doc
->changed
);
625 ui_set_window_title(doc
);
626 ui_update_statusbar(doc
, -1);
627 ui_update_popup_reundo_items(doc
);
628 ui_document_show_hide(doc
); /* update the document menu */
629 build_menu_update(doc
);
630 sidebar_update_tag_list(doc
, FALSE
);
631 document_highlight_tags(doc
);
633 /* We delay the check to avoid weird fast, unintended switching of notebook pages when
634 * the 'file has changed' dialog is shown while the switch event is not yet completely
635 * finished. So, we check after the switch has been performed to be safe. */
636 g_idle_add(delayed_check_disk_status
, doc
);
639 vte_cwd((doc
->real_path
!= NULL
) ? doc
->real_path
: doc
->file_name
, FALSE
);
642 g_signal_emit_by_name(geany_object
, "document-activate", doc
);
647 G_MODULE_EXPORT
void on_tv_notebook_switch_page(GtkNotebook
*notebook
, gpointer page
,
648 guint page_num
, gpointer user_data
)
650 /* suppress selection changed signal when switching to the open files list */
651 ignore_callback
= TRUE
;
655 G_MODULE_EXPORT
void on_tv_notebook_switch_page_after(GtkNotebook
*notebook
, gpointer page
,
656 guint page_num
, gpointer user_data
)
658 ignore_callback
= FALSE
;
662 static void convert_eol(gint mode
)
664 GeanyDocument
*doc
= document_get_current();
666 g_return_if_fail(doc
!= NULL
);
668 sci_convert_eols(doc
->editor
->sci
, mode
);
669 sci_set_eol_mode(doc
->editor
->sci
, mode
);
670 ui_update_statusbar(doc
, -1);
674 G_MODULE_EXPORT
void on_crlf_activate(GtkCheckMenuItem
*menuitem
, gpointer user_data
)
676 if (ignore_callback
|| ! gtk_check_menu_item_get_active(menuitem
))
679 convert_eol(SC_EOL_CRLF
);
683 G_MODULE_EXPORT
void on_lf_activate(GtkCheckMenuItem
*menuitem
, gpointer user_data
)
685 if (ignore_callback
|| ! gtk_check_menu_item_get_active(menuitem
))
688 convert_eol(SC_EOL_LF
);
692 G_MODULE_EXPORT
void on_cr_activate(GtkCheckMenuItem
*menuitem
, gpointer user_data
)
694 if (ignore_callback
|| ! gtk_check_menu_item_get_active(menuitem
))
697 convert_eol(SC_EOL_CR
);
701 G_MODULE_EXPORT
void on_replace_tabs_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
703 GeanyDocument
*doc
= document_get_current();
705 g_return_if_fail(doc
!= NULL
);
707 editor_replace_tabs(doc
->editor
);
711 gboolean
toolbar_popup_menu(GtkWidget
*widget
, GdkEventButton
*event
, gpointer user_data
)
713 if (event
->button
== 3)
715 gtk_menu_popup(GTK_MENU(ui_widgets
.toolbar_menu
), NULL
, NULL
, NULL
, NULL
, event
->button
, event
->time
);
722 G_MODULE_EXPORT
void on_toggle_case1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
724 GeanyDocument
*doc
= document_get_current();
725 ScintillaObject
*sci
;
727 gboolean keep_sel
= TRUE
;
729 g_return_if_fail(doc
!= NULL
);
731 sci
= doc
->editor
->sci
;
732 if (! sci_has_selection(sci
))
734 keybindings_send_command(GEANY_KEY_GROUP_SELECT
, GEANY_KEYS_SELECT_WORD
);
738 /* either we already had a selection or we created one for current word */
739 if (sci_has_selection(sci
))
741 gchar
*result
= NULL
;
742 gint cmd
= SCI_LOWERCASE
;
743 gboolean rectsel
= (gboolean
) scintilla_send_message(sci
, SCI_SELECTIONISRECTANGLE
, 0, 0);
745 text
= sci_get_selection_contents(sci
);
747 if (utils_str_has_upper(text
))
752 result
= g_utf8_strdown(text
, -1);
759 result
= g_utf8_strup(text
, -1);
764 sci_replace_sel(sci
, result
);
767 sci_set_selection_start(sci
, sci_get_current_position(sci
) - strlen(text
));
770 sci_send_command(sci
, cmd
);
778 G_MODULE_EXPORT
void on_show_toolbar1_toggled(GtkCheckMenuItem
*checkmenuitem
, gpointer user_data
)
780 if (ignore_callback
) return;
782 toolbar_prefs
.visible
= (toolbar_prefs
.visible
) ? FALSE
: TRUE
;;
783 ui_widget_show_hide(GTK_WIDGET(main_widgets
.toolbar
), toolbar_prefs
.visible
);
787 G_MODULE_EXPORT
void on_fullscreen1_toggled(GtkCheckMenuItem
*checkmenuitem
, gpointer user_data
)
792 ui_prefs
.fullscreen
= (ui_prefs
.fullscreen
) ? FALSE
: TRUE
;
797 G_MODULE_EXPORT
void on_show_messages_window1_toggled(GtkCheckMenuItem
*checkmenuitem
, gpointer user_data
)
802 ui_prefs
.msgwindow_visible
= (ui_prefs
.msgwindow_visible
) ? FALSE
: TRUE
;
803 msgwin_show_hide(ui_prefs
.msgwindow_visible
);
807 G_MODULE_EXPORT
void on_menu_color_schemes_activate(GtkImageMenuItem
*imagemenuitem
, gpointer user_data
)
809 highlighting_show_color_scheme_dialog();
813 G_MODULE_EXPORT
void on_markers_margin1_toggled(GtkCheckMenuItem
*checkmenuitem
, gpointer user_data
)
818 editor_prefs
.show_markers_margin
= ! editor_prefs
.show_markers_margin
;
819 ui_toggle_editor_features(GEANY_EDITOR_SHOW_MARKERS_MARGIN
);
823 G_MODULE_EXPORT
void on_show_line_numbers1_toggled(GtkCheckMenuItem
*checkmenuitem
, gpointer user_data
)
828 editor_prefs
.show_linenumber_margin
= ! editor_prefs
.show_linenumber_margin
;
829 ui_toggle_editor_features(GEANY_EDITOR_SHOW_LINE_NUMBERS
);
833 G_MODULE_EXPORT
void on_menu_show_white_space1_toggled(GtkCheckMenuItem
*checkmenuitem
, gpointer user_data
)
838 editor_prefs
.show_white_space
= ! editor_prefs
.show_white_space
;
839 ui_toggle_editor_features(GEANY_EDITOR_SHOW_WHITE_SPACE
);
843 G_MODULE_EXPORT
void on_menu_show_line_endings1_toggled(GtkCheckMenuItem
*checkmenuitem
, gpointer user_data
)
848 editor_prefs
.show_line_endings
= ! editor_prefs
.show_line_endings
;
849 ui_toggle_editor_features(GEANY_EDITOR_SHOW_LINE_ENDINGS
);
853 G_MODULE_EXPORT
void on_menu_show_indentation_guides1_toggled(GtkCheckMenuItem
*checkmenuitem
, gpointer user_data
)
858 editor_prefs
.show_indent_guide
= ! editor_prefs
.show_indent_guide
;
859 ui_toggle_editor_features(GEANY_EDITOR_SHOW_INDENTATION_GUIDES
);
863 G_MODULE_EXPORT
void on_line_wrapping1_toggled(GtkCheckMenuItem
*checkmenuitem
, gpointer user_data
)
865 if (! ignore_callback
)
867 GeanyDocument
*doc
= document_get_current();
868 g_return_if_fail(doc
!= NULL
);
870 editor_set_line_wrapping(doc
->editor
, ! doc
->editor
->line_wrapping
);
875 G_MODULE_EXPORT
void on_set_file_readonly1_toggled(GtkCheckMenuItem
*checkmenuitem
, gpointer user_data
)
877 if (! ignore_callback
)
879 GeanyDocument
*doc
= document_get_current();
880 g_return_if_fail(doc
!= NULL
);
882 doc
->readonly
= ! doc
->readonly
;
883 sci_set_readonly(doc
->editor
->sci
, doc
->readonly
);
884 ui_update_tab_status(doc
);
885 ui_update_statusbar(doc
, -1);
890 G_MODULE_EXPORT
void on_use_auto_indentation1_toggled(GtkCheckMenuItem
*checkmenuitem
, gpointer user_data
)
892 if (! ignore_callback
)
894 GeanyDocument
*doc
= document_get_current();
895 g_return_if_fail(doc
!= NULL
);
897 doc
->editor
->auto_indent
= ! doc
->editor
->auto_indent
;
902 static void find_usage(gboolean in_session
)
906 GeanyDocument
*doc
= document_get_current();
908 g_return_if_fail(doc
!= NULL
);
910 if (sci_has_selection(doc
->editor
->sci
))
911 { /* take selected text if there is a selection */
912 search_text
= sci_get_selection_contents(doc
->editor
->sci
);
913 flags
= SCFIND_MATCHCASE
;
917 editor_find_current_word_sciwc(doc
->editor
, -1,
918 editor_info
.current_word
, GEANY_MAX_WORD_LENGTH
);
919 search_text
= g_strdup(editor_info
.current_word
);
920 flags
= SCFIND_MATCHCASE
| SCFIND_WHOLEWORD
;
923 search_find_usage(search_text
, search_text
, flags
, in_session
);
928 G_MODULE_EXPORT
void on_find_document_usage1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
934 G_MODULE_EXPORT
void on_find_usage1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
940 static void goto_tag(gboolean definition
)
942 GeanyDocument
*doc
= document_get_current();
944 g_return_if_fail(doc
!= NULL
);
946 /* update cursor pos for navigating back afterwards */
947 if (!sci_has_selection(doc
->editor
->sci
))
948 sci_set_current_position(doc
->editor
->sci
, editor_info
.click_pos
, FALSE
);
950 /* use the keybinding callback as it checks for selections as well as current word */
952 keybindings_send_command(GEANY_KEY_GROUP_GOTO
, GEANY_KEYS_GOTO_TAGDEFINITION
);
954 keybindings_send_command(GEANY_KEY_GROUP_GOTO
, GEANY_KEYS_GOTO_TAGDECLARATION
);
958 G_MODULE_EXPORT
void on_goto_tag_definition1(GtkMenuItem
*menuitem
, gpointer user_data
)
964 G_MODULE_EXPORT
void on_goto_tag_declaration1(GtkMenuItem
*menuitem
, gpointer user_data
)
970 G_MODULE_EXPORT
void on_count_words1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
976 G_MODULE_EXPORT
void on_show_color_chooser1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
979 GeanyDocument
*doc
= document_get_current();
982 g_return_if_fail(doc
!= NULL
);
984 pos
= sci_get_current_position(doc
->editor
->sci
);
985 editor_find_current_word(doc
->editor
, pos
, colour
, sizeof colour
, GEANY_WORDCHARS
"#");
986 tools_color_chooser(colour
);
990 void on_toolbutton_compile_clicked(GtkAction
*action
, gpointer user_data
)
992 keybindings_send_command(GEANY_KEY_GROUP_BUILD
, GEANY_KEYS_BUILD_COMPILE
);
996 G_MODULE_EXPORT
void on_find1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
998 search_show_find_dialog();
1002 G_MODULE_EXPORT
void on_find_next1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1004 search_find_again(FALSE
);
1008 G_MODULE_EXPORT
void on_find_previous1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1010 if (search_data
.flags
& SCFIND_REGEXP
)
1011 /* Can't reverse search order for a regex (find next ignores search backwards) */
1014 search_find_again(TRUE
);
1018 G_MODULE_EXPORT
void on_find_nextsel1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1020 search_find_selection(document_get_current(), FALSE
);
1024 G_MODULE_EXPORT
void on_find_prevsel1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1026 search_find_selection(document_get_current(), TRUE
);
1030 G_MODULE_EXPORT
void on_replace1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1032 search_show_replace_dialog();
1036 G_MODULE_EXPORT
void on_find_in_files1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1038 search_show_find_in_files_dialog(NULL
);
1042 static void get_line_and_offset_from_text(const gchar
*text
, gint
*line_no
, gint
*offset
)
1044 if (*text
== '+' || *text
== '-')
1046 *line_no
= atoi(text
+ 1);
1047 *offset
= (*text
== '+') ? 1 : -1;
1051 *line_no
= atoi(text
) - 1;
1057 G_MODULE_EXPORT
void on_go_to_line_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1059 static gchar value
[16] = "";
1062 result
= dialogs_show_input_goto_line(
1063 _("Go to Line"), GTK_WINDOW(main_widgets
.window
),
1064 _("Enter the line you want to go to:"), value
);
1067 GeanyDocument
*doc
= document_get_current();
1071 g_return_if_fail(doc
!= NULL
);
1073 get_line_and_offset_from_text(result
, &line_no
, &offset
);
1074 if (! editor_goto_line(doc
->editor
, line_no
, offset
))
1076 /* remember value for future calls */
1077 g_snprintf(value
, sizeof(value
), "%s", result
);
1084 void on_toolbutton_goto_entry_activate(GtkAction
*action
, const gchar
*text
, gpointer user_data
)
1086 GeanyDocument
*doc
= document_get_current();
1090 g_return_if_fail(doc
!= NULL
);
1092 get_line_and_offset_from_text(text
, &line_no
, &offset
);
1093 if (! editor_goto_line(doc
->editor
, line_no
, offset
))
1096 keybindings_send_command(GEANY_KEY_GROUP_FOCUS
, GEANY_KEYS_FOCUS_EDITOR
);
1100 void on_toolbutton_goto_clicked(GtkAction
*action
, gpointer user_data
)
1102 GtkWidget
*entry
= toolbar_get_widget_child_by_name("GotoEntry");
1106 const gchar
*text
= gtk_entry_get_text(GTK_ENTRY(entry
));
1108 on_toolbutton_goto_entry_activate(NULL
, text
, NULL
);
1111 on_go_to_line_activate(NULL
, NULL
);
1115 G_MODULE_EXPORT
void on_help1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1119 uri
= utils_get_help_url(NULL
);
1120 utils_open_browser(uri
);
1125 G_MODULE_EXPORT
void on_help_shortcuts1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1127 keybindings_show_shortcuts();
1131 G_MODULE_EXPORT
void on_website1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1133 utils_open_browser(GEANY_HOMEPAGE
);
1137 G_MODULE_EXPORT
void on_help_menu_item_donate_activate(GtkMenuItem
*item
, gpointer user_data
)
1139 utils_open_browser(GEANY_DONATE
);
1143 G_MODULE_EXPORT
void on_help_menu_item_wiki_activate(GtkMenuItem
*item
, gpointer user_data
)
1145 utils_open_browser(GEANY_WIKI
);
1149 G_MODULE_EXPORT
void on_help_menu_item_bug_report_activate(GtkMenuItem
*item
, gpointer user_data
)
1151 utils_open_browser(GEANY_BUG_REPORT
);
1155 G_MODULE_EXPORT
void on_comments_function_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1157 GeanyDocument
*doc
= document_get_current();
1159 const gchar
*cur_tag
= NULL
;
1160 gint line
= -1, pos
= 0;
1162 if (doc
== NULL
|| doc
->file_type
== NULL
)
1164 ui_set_statusbar(FALSE
,
1165 _("Please set the filetype for the current file before using this function."));
1169 /* symbols_get_current_function returns -1 on failure, so sci_get_position_from_line
1170 * returns the current position, so it should be safe */
1171 line
= symbols_get_current_function(doc
, &cur_tag
);
1172 pos
= sci_get_position_from_line(doc
->editor
->sci
, line
);
1174 text
= templates_get_template_function(doc
, cur_tag
);
1176 sci_start_undo_action(doc
->editor
->sci
);
1177 sci_insert_text(doc
->editor
->sci
, pos
, text
);
1178 sci_end_undo_action(doc
->editor
->sci
);
1183 G_MODULE_EXPORT
void on_comments_multiline_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1185 GeanyDocument
*doc
= document_get_current();
1187 if (doc
== NULL
|| doc
->file_type
== NULL
)
1189 ui_set_statusbar(FALSE
,
1190 _("Please set the filetype for the current file before using this function."));
1194 verify_click_pos(doc
); /* make sure that the click_pos is valid */
1196 if (doc
->file_type
->comment_open
|| doc
->file_type
->comment_single
)
1197 editor_insert_multiline_comment(doc
->editor
);
1203 G_MODULE_EXPORT
void on_comments_gpl_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1205 GeanyDocument
*doc
= document_get_current();
1208 g_return_if_fail(doc
!= NULL
);
1210 text
= templates_get_template_licence(doc
, GEANY_TEMPLATE_GPL
);
1212 verify_click_pos(doc
); /* make sure that the click_pos is valid */
1214 sci_start_undo_action(doc
->editor
->sci
);
1215 sci_insert_text(doc
->editor
->sci
, editor_info
.click_pos
, text
);
1216 sci_end_undo_action(doc
->editor
->sci
);
1221 G_MODULE_EXPORT
void on_comments_bsd_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1223 GeanyDocument
*doc
= document_get_current();
1226 g_return_if_fail(doc
!= NULL
);
1228 text
= templates_get_template_licence(doc
, GEANY_TEMPLATE_BSD
);
1230 verify_click_pos(doc
); /* make sure that the click_pos is valid */
1232 sci_start_undo_action(doc
->editor
->sci
);
1233 sci_insert_text(doc
->editor
->sci
, editor_info
.click_pos
, text
);
1234 sci_end_undo_action(doc
->editor
->sci
);
1240 G_MODULE_EXPORT
void on_comments_changelog_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1242 GeanyDocument
*doc
= document_get_current();
1245 g_return_if_fail(doc
!= NULL
);
1247 text
= templates_get_template_changelog(doc
);
1248 sci_start_undo_action(doc
->editor
->sci
);
1249 sci_insert_text(doc
->editor
->sci
, 0, text
);
1250 /* sets the cursor to the right position to type the changelog text,
1251 * the template has 21 chars + length of name and email */
1252 sci_goto_pos(doc
->editor
->sci
, 21 + strlen(template_prefs
.developer
) + strlen(template_prefs
.mail
), TRUE
);
1253 sci_end_undo_action(doc
->editor
->sci
);
1259 G_MODULE_EXPORT
void on_comments_fileheader_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1261 GeanyDocument
*doc
= document_get_current();
1266 g_return_if_fail(doc
!= NULL
);
1268 ft
= doc
->file_type
;
1269 fname
= doc
->file_name
;
1270 text
= templates_get_template_fileheader(FILETYPE_ID(ft
), fname
);
1272 sci_start_undo_action(doc
->editor
->sci
);
1273 sci_insert_text(doc
->editor
->sci
, 0, text
);
1274 sci_goto_pos(doc
->editor
->sci
, 0, FALSE
);
1275 sci_end_undo_action(doc
->editor
->sci
);
1280 void on_insert_date_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1282 GeanyDocument
*doc
= document_get_current();
1283 const gchar
*format
= NULL
;
1286 g_return_if_fail(doc
!= NULL
);
1288 /* set default value */
1289 if (utils_str_equal("", ui_prefs
.custom_date_format
))
1291 g_free(ui_prefs
.custom_date_format
);
1292 ui_prefs
.custom_date_format
= g_strdup("%d.%m.%Y");
1295 if (utils_str_equal(_("dd.mm.yyyy"), (gchar
*) user_data
))
1296 format
= "%d.%m.%Y";
1297 else if (utils_str_equal(_("mm.dd.yyyy"), (gchar
*) user_data
))
1298 format
= "%m.%d.%Y";
1299 else if (utils_str_equal(_("yyyy/mm/dd"), (gchar
*) user_data
))
1300 format
= "%Y/%m/%d";
1301 else if (utils_str_equal(_("dd.mm.yyyy hh:mm:ss"), (gchar
*) user_data
))
1302 format
= "%d.%m.%Y %H:%M:%S";
1303 else if (utils_str_equal(_("mm.dd.yyyy hh:mm:ss"), (gchar
*) user_data
))
1304 format
= "%m.%d.%Y %H:%M:%S";
1305 else if (utils_str_equal(_("yyyy/mm/dd hh:mm:ss"), (gchar
*) user_data
))
1306 format
= "%Y/%m/%d %H:%M:%S";
1307 else if (utils_str_equal(_("_Use Custom Date Format"), (gchar
*) user_data
))
1308 format
= ui_prefs
.custom_date_format
;
1311 gchar
*str
= dialogs_show_input(_("Custom Date Format"), GTK_WINDOW(main_widgets
.window
),
1312 _("Enter here a custom date and time format. "
1313 "You can use any conversion specifiers which can be used with the ANSI C strftime function."),
1314 ui_prefs
.custom_date_format
);
1316 SETPTR(ui_prefs
.custom_date_format
, str
);
1320 time_str
= utils_get_date_time(format
, NULL
);
1321 if (time_str
!= NULL
)
1323 verify_click_pos(doc
); /* make sure that the click_pos is valid */
1325 sci_start_undo_action(doc
->editor
->sci
);
1326 sci_insert_text(doc
->editor
->sci
, editor_info
.click_pos
, time_str
);
1327 sci_goto_pos(doc
->editor
->sci
, editor_info
.click_pos
+ strlen(time_str
), FALSE
);
1328 sci_end_undo_action(doc
->editor
->sci
);
1334 ui_set_statusbar(TRUE
,
1335 _("Date format string could not be converted (possibly too long)."));
1340 void on_insert_include_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1342 GeanyDocument
*doc
= document_get_current();
1346 g_return_if_fail(doc
!= NULL
);
1347 g_return_if_fail(user_data
!= NULL
);
1349 verify_click_pos(doc
); /* make sure that the click_pos is valid */
1351 if (utils_str_equal(user_data
, "blank"))
1353 text
= g_strdup("#include \"\"\n");
1354 pos
= editor_info
.click_pos
+ 10;
1358 text
= g_strconcat("#include <", user_data
, ">\n", NULL
);
1361 sci_start_undo_action(doc
->editor
->sci
);
1362 sci_insert_text(doc
->editor
->sci
, editor_info
.click_pos
, text
);
1363 sci_end_undo_action(doc
->editor
->sci
);
1366 sci_goto_pos(doc
->editor
->sci
, pos
, FALSE
);
1370 G_MODULE_EXPORT
void on_file_properties_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1372 GeanyDocument
*doc
= document_get_current();
1373 g_return_if_fail(doc
!= NULL
);
1375 dialogs_show_file_properties(doc
);
1379 G_MODULE_EXPORT
void on_menu_fold_all1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1381 GeanyDocument
*doc
= document_get_current();
1382 g_return_if_fail(doc
!= NULL
);
1384 editor_fold_all(doc
->editor
);
1388 G_MODULE_EXPORT
void on_menu_unfold_all1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1390 GeanyDocument
*doc
= document_get_current();
1391 g_return_if_fail(doc
!= NULL
);
1393 editor_unfold_all(doc
->editor
);
1397 void on_toolbutton_run_clicked(GtkAction
*action
, gpointer user_data
)
1399 keybindings_send_command(GEANY_KEY_GROUP_BUILD
, GEANY_KEYS_BUILD_RUN
);
1403 G_MODULE_EXPORT
void on_menu_remove_indicators1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1405 GeanyDocument
*doc
= document_get_current();
1406 g_return_if_fail(doc
!= NULL
);
1408 editor_indicator_clear(doc
->editor
, GEANY_INDICATOR_ERROR
);
1412 G_MODULE_EXPORT
void on_print1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1414 GeanyDocument
*doc
= document_get_current();
1415 g_return_if_fail(doc
!= NULL
);
1417 printing_print_doc(doc
);
1421 G_MODULE_EXPORT
void on_menu_select_all1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1423 GeanyDocument
*doc
= document_get_current();
1424 g_return_if_fail(doc
!= NULL
);
1426 sci_select_all(doc
->editor
->sci
);
1430 G_MODULE_EXPORT
void on_menu_show_sidebar1_toggled(GtkCheckMenuItem
*checkmenuitem
, gpointer user_data
)
1432 if (ignore_callback
)
1435 ui_prefs
.sidebar_visible
= ! ui_prefs
.sidebar_visible
;
1437 /* show built-in tabs if no tabs visible */
1438 if (ui_prefs
.sidebar_visible
&&
1439 ! interface_prefs
.sidebar_openfiles_visible
&& ! interface_prefs
.sidebar_symbol_visible
&&
1440 gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_widgets
.sidebar_notebook
)) <= 2)
1442 interface_prefs
.sidebar_openfiles_visible
= TRUE
;
1443 interface_prefs
.sidebar_symbol_visible
= TRUE
;
1446 /* if window has input focus, set it back to the editor before toggling off */
1447 if (! ui_prefs
.sidebar_visible
&&
1448 gtk_container_get_focus_child(GTK_CONTAINER(main_widgets
.sidebar_notebook
)) != NULL
)
1450 keybindings_send_command(GEANY_KEY_GROUP_FOCUS
, GEANY_KEYS_FOCUS_EDITOR
);
1453 ui_sidebar_show_hide();
1457 G_MODULE_EXPORT
void on_menu_write_unicode_bom1_toggled(GtkCheckMenuItem
*checkmenuitem
, gpointer user_data
)
1459 if (! ignore_callback
)
1461 GeanyDocument
*doc
= document_get_current();
1463 g_return_if_fail(doc
!= NULL
);
1470 document_undo_add(doc
, UNDO_BOM
, GINT_TO_POINTER(doc
->has_bom
));
1472 doc
->has_bom
= ! doc
->has_bom
;
1474 ui_update_statusbar(doc
, -1);
1479 G_MODULE_EXPORT
void on_menu_comment_line1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1481 GeanyDocument
*doc
= document_get_current();
1482 g_return_if_fail(doc
!= NULL
);
1484 editor_do_comment(doc
->editor
, -1, FALSE
, FALSE
, TRUE
);
1488 G_MODULE_EXPORT
void on_menu_uncomment_line1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1490 GeanyDocument
*doc
= document_get_current();
1491 g_return_if_fail(doc
!= NULL
);
1493 editor_do_uncomment(doc
->editor
, -1, FALSE
);
1497 G_MODULE_EXPORT
void on_menu_toggle_line_commentation1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1499 GeanyDocument
*doc
= document_get_current();
1500 g_return_if_fail(doc
!= NULL
);
1502 editor_do_comment_toggle(doc
->editor
);
1506 G_MODULE_EXPORT
void on_menu_increase_indent1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1508 GeanyDocument
*doc
= document_get_current();
1509 g_return_if_fail(doc
!= NULL
);
1511 editor_indent(doc
->editor
, TRUE
);
1515 G_MODULE_EXPORT
void on_menu_decrease_indent1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1517 GeanyDocument
*doc
= document_get_current();
1518 g_return_if_fail(doc
!= NULL
);
1520 editor_indent(doc
->editor
, FALSE
);
1524 G_MODULE_EXPORT
void on_next_message1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1526 if (! ui_tree_view_find_next(GTK_TREE_VIEW(msgwindow
.tree_msg
),
1527 msgwin_goto_messages_file_line
))
1528 ui_set_statusbar(FALSE
, _("No more message items."));
1532 G_MODULE_EXPORT
void on_previous_message1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1534 if (! ui_tree_view_find_previous(GTK_TREE_VIEW(msgwindow
.tree_msg
),
1535 msgwin_goto_messages_file_line
))
1536 ui_set_statusbar(FALSE
, _("No more message items."));
1540 G_MODULE_EXPORT
void on_menu_comments_multiline_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1542 insert_callback_from_menu
= TRUE
;
1543 on_comments_multiline_activate(menuitem
, user_data
);
1547 G_MODULE_EXPORT
void on_menu_comments_gpl_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1549 insert_callback_from_menu
= TRUE
;
1550 on_comments_gpl_activate(menuitem
, user_data
);
1554 G_MODULE_EXPORT
void on_menu_comments_bsd_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1556 insert_callback_from_menu
= TRUE
;
1557 on_comments_bsd_activate(menuitem
, user_data
);
1561 void on_menu_insert_include_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1563 insert_callback_from_menu
= TRUE
;
1564 on_insert_include_activate(menuitem
, user_data
);
1568 void on_menu_insert_date_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1570 insert_callback_from_menu
= TRUE
;
1571 on_insert_date_activate(menuitem
, user_data
);
1575 G_MODULE_EXPORT
void on_project_new1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1581 G_MODULE_EXPORT
void on_project_open1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1587 G_MODULE_EXPORT
void on_project_close1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1589 project_close(TRUE
);
1593 G_MODULE_EXPORT
void on_project_properties1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1595 project_properties();
1599 G_MODULE_EXPORT
void on_menu_project1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1601 static GtkWidget
*item_close
= NULL
;
1602 static GtkWidget
*item_properties
= NULL
;
1604 if (item_close
== NULL
)
1606 item_close
= ui_lookup_widget(main_widgets
.window
, "project_close1");
1607 item_properties
= ui_lookup_widget(main_widgets
.window
, "project_properties1");
1610 gtk_widget_set_sensitive(item_close
, (app
->project
!= NULL
));
1611 gtk_widget_set_sensitive(item_properties
, (app
->project
!= NULL
));
1612 gtk_widget_set_sensitive(ui_widgets
.recent_projects_menuitem
,
1613 g_queue_get_length(ui_prefs
.recent_projects_queue
) > 0);
1617 G_MODULE_EXPORT
void on_menu_open_selected_file1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1619 GeanyDocument
*doc
= document_get_current();
1624 wc
= GEANY_WORDCHARS
"./-" "\\";
1626 wc
= GEANY_WORDCHARS
"./-";
1629 g_return_if_fail(doc
!= NULL
);
1631 sel
= editor_get_default_selection(doc
->editor
, TRUE
, wc
);
1632 SETPTR(sel
, utils_get_locale_from_utf8(sel
));
1636 gchar
*filename
= NULL
;
1638 if (g_path_is_absolute(sel
))
1639 filename
= g_strdup(sel
);
1641 { /* relative filename, add the path of the current file */
1644 path
= utils_get_current_file_dir_utf8();
1645 SETPTR(path
, utils_get_locale_from_utf8(path
));
1647 path
= g_get_current_dir();
1649 filename
= g_build_path(G_DIR_SEPARATOR_S
, path
, sel
, NULL
);
1651 if (! g_file_test(filename
, G_FILE_TEST_EXISTS
) &&
1652 app
->project
!= NULL
&& !EMPTY(app
->project
->base_path
))
1654 /* try the project's base path */
1655 SETPTR(path
, project_get_base_path());
1656 SETPTR(path
, utils_get_locale_from_utf8(path
));
1657 SETPTR(filename
, g_build_path(G_DIR_SEPARATOR_S
, path
, sel
, NULL
));
1661 if (! g_file_test(filename
, G_FILE_TEST_EXISTS
))
1662 SETPTR(filename
, g_build_path(G_DIR_SEPARATOR_S
, "/usr/local/include", sel
, NULL
));
1664 if (! g_file_test(filename
, G_FILE_TEST_EXISTS
))
1665 SETPTR(filename
, g_build_path(G_DIR_SEPARATOR_S
, "/usr/include", sel
, NULL
));
1669 if (g_file_test(filename
, G_FILE_TEST_EXISTS
))
1670 document_open_file(filename
, FALSE
, NULL
, NULL
);
1673 SETPTR(sel
, utils_get_utf8_from_locale(sel
));
1674 ui_set_statusbar(TRUE
, _("Could not open file %s (File not found)"), sel
);
1683 G_MODULE_EXPORT
void on_remove_markers1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1685 GeanyDocument
*doc
= document_get_current();
1686 g_return_if_fail(doc
!= NULL
);
1688 sci_marker_delete_all(doc
->editor
->sci
, 0); /* delete the yellow tag marker */
1689 sci_marker_delete_all(doc
->editor
->sci
, 1); /* delete user markers */
1690 editor_indicator_clear(doc
->editor
, GEANY_INDICATOR_SEARCH
);
1694 G_MODULE_EXPORT
void on_load_tags1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1696 symbols_show_load_tags_dialog();
1700 G_MODULE_EXPORT
void on_context_action1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1702 gchar
*word
, *command
;
1703 GError
*error
= NULL
;
1704 GeanyDocument
*doc
= document_get_current();
1706 g_return_if_fail(doc
!= NULL
);
1708 if (sci_has_selection(doc
->editor
->sci
))
1709 { /* take selected text if there is a selection */
1710 word
= sci_get_selection_contents(doc
->editor
->sci
);
1714 word
= g_strdup(editor_info
.current_word
);
1717 /* use the filetype specific command if available, fallback to global command otherwise */
1718 if (doc
->file_type
!= NULL
&&
1719 !EMPTY(doc
->file_type
->context_action_cmd
))
1721 command
= g_strdup(doc
->file_type
->context_action_cmd
);
1725 command
= g_strdup(tool_prefs
.context_action_cmd
);
1728 /* substitute the wildcard %s and run the command if it is non empty */
1729 if (G_LIKELY(!EMPTY(command
)))
1731 utils_str_replace_all(&command
, "%s", word
);
1733 if (! g_spawn_command_line_async(command
, &error
))
1735 ui_set_statusbar(TRUE
, "Context action command failed: %s", error
->message
);
1736 g_error_free(error
);
1744 G_MODULE_EXPORT
void on_menu_toggle_all_additional_widgets1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1746 static gint hide_all
= -1;
1747 GtkCheckMenuItem
*msgw
= GTK_CHECK_MENU_ITEM(
1748 ui_lookup_widget(main_widgets
.window
, "menu_show_messages_window1"));
1749 GtkCheckMenuItem
*toolbari
= GTK_CHECK_MENU_ITEM(
1750 ui_lookup_widget(main_widgets
.window
, "menu_show_toolbar1"));
1752 /* get the initial state (necessary if Geany was closed with hide_all = TRUE) */
1753 if (G_UNLIKELY(hide_all
== -1))
1755 if (! gtk_check_menu_item_get_active(msgw
) &&
1756 ! interface_prefs
.show_notebook_tabs
&&
1757 ! gtk_check_menu_item_get_active(toolbari
))
1765 hide_all
= ! hide_all
; /* toggle */
1769 if (gtk_check_menu_item_get_active(msgw
))
1770 gtk_check_menu_item_set_active(msgw
, ! gtk_check_menu_item_get_active(msgw
));
1772 interface_prefs
.show_notebook_tabs
= FALSE
;
1773 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(main_widgets
.notebook
), interface_prefs
.show_notebook_tabs
);
1775 ui_statusbar_showhide(FALSE
);
1777 if (gtk_check_menu_item_get_active(toolbari
))
1778 gtk_check_menu_item_set_active(toolbari
, ! gtk_check_menu_item_get_active(toolbari
));
1783 if (! gtk_check_menu_item_get_active(msgw
))
1784 gtk_check_menu_item_set_active(msgw
, ! gtk_check_menu_item_get_active(msgw
));
1786 interface_prefs
.show_notebook_tabs
= TRUE
;
1787 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(main_widgets
.notebook
), interface_prefs
.show_notebook_tabs
);
1789 ui_statusbar_showhide(TRUE
);
1791 if (! gtk_check_menu_item_get_active(toolbari
))
1792 gtk_check_menu_item_set_active(toolbari
, ! gtk_check_menu_item_get_active(toolbari
));
1797 void on_toolbutton_forward_activate(GtkAction
*menuitem
, gpointer user_data
)
1799 navqueue_go_forward();
1803 void on_toolbutton_back_activate(GtkAction
*menuitem
, gpointer user_data
)
1809 gboolean
on_motion_event(GtkWidget
*widget
, GdkEventMotion
*event
, gpointer user_data
)
1811 if (prefs
.auto_focus
&& ! gtk_widget_has_focus(widget
))
1812 gtk_widget_grab_focus(widget
);
1818 static void set_indent_type(GtkCheckMenuItem
*menuitem
, GeanyIndentType type
)
1822 if (ignore_callback
|| ! gtk_check_menu_item_get_active(menuitem
))
1825 doc
= document_get_current();
1826 g_return_if_fail(doc
!= NULL
);
1828 editor_set_indent(doc
->editor
, type
, doc
->editor
->indent_width
);
1829 ui_update_statusbar(doc
, -1);
1833 G_MODULE_EXPORT
void on_tabs1_activate(GtkCheckMenuItem
*menuitem
, gpointer user_data
)
1835 set_indent_type(menuitem
, GEANY_INDENT_TYPE_TABS
);
1839 G_MODULE_EXPORT
void on_spaces1_activate(GtkCheckMenuItem
*menuitem
, gpointer user_data
)
1841 set_indent_type(menuitem
, GEANY_INDENT_TYPE_SPACES
);
1845 G_MODULE_EXPORT
void on_tabs_and_spaces1_activate(GtkCheckMenuItem
*menuitem
, gpointer user_data
)
1847 set_indent_type(menuitem
, GEANY_INDENT_TYPE_BOTH
);
1851 G_MODULE_EXPORT
void on_strip_trailing_spaces1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1855 if (ignore_callback
)
1858 doc
= document_get_current();
1859 g_return_if_fail(doc
!= NULL
);
1861 editor_strip_trailing_spaces(doc
->editor
);
1865 G_MODULE_EXPORT
void on_page_setup1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1867 printing_page_setup_gtk();
1871 G_MODULE_EXPORT gboolean
on_escape_key_press_event(GtkWidget
*widget
, GdkEventKey
*event
, gpointer user_data
)
1873 guint state
= event
->state
& gtk_accelerator_get_default_mod_mask();
1875 /* make pressing escape in the sidebar and toolbar focus the editor */
1876 if (event
->keyval
== GDK_Escape
&& state
== 0)
1878 keybindings_send_command(GEANY_KEY_GROUP_FOCUS
, GEANY_KEYS_FOCUS_EDITOR
);
1885 G_MODULE_EXPORT
void on_line_breaking1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1889 if (ignore_callback
)
1892 doc
= document_get_current();
1893 g_return_if_fail(doc
!= NULL
);
1895 doc
->editor
->line_breaking
= !doc
->editor
->line_breaking
;
1899 G_MODULE_EXPORT
void on_replace_spaces_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1901 GeanyDocument
*doc
= document_get_current();
1903 g_return_if_fail(doc
!= NULL
);
1905 editor_replace_spaces(doc
->editor
);
1909 G_MODULE_EXPORT
void on_search1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1911 GtkWidget
*next_message
= ui_lookup_widget(main_widgets
.window
, "next_message1");
1912 GtkWidget
*previous_message
= ui_lookup_widget(main_widgets
.window
, "previous_message1");
1913 gboolean have_messages
;
1915 /* enable commands if the messages window has any items */
1916 have_messages
= gtk_tree_model_iter_n_children(GTK_TREE_MODEL(msgwindow
.store_msg
),
1919 gtk_widget_set_sensitive(next_message
, have_messages
);
1920 gtk_widget_set_sensitive(previous_message
, have_messages
);
1924 /* simple implementation (vs. close all which doesn't close documents if cancelled),
1925 * if user_data is set, it is the GeanyDocument to keep */
1926 G_MODULE_EXPORT
void on_close_other_documents1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1929 GeanyDocument
*cur_doc
= user_data
;
1931 if (cur_doc
== NULL
)
1932 cur_doc
= document_get_current();
1934 for (i
= 0; i
< documents_array
->len
; i
++)
1936 GeanyDocument
*doc
= documents
[i
];
1938 if (doc
== cur_doc
|| ! doc
->is_valid
)
1941 if (! document_close(doc
))
1947 G_MODULE_EXPORT
void on_menu_reload_configuration1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1949 main_reload_configuration();
1953 G_MODULE_EXPORT
void on_debug_messages1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1955 log_show_debug_messages_dialog();
1959 G_MODULE_EXPORT
void on_send_selection_to_vte1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
1962 if (vte_info
.have_vte
)
1963 vte_send_selection_to_vte();
1968 G_MODULE_EXPORT gboolean
on_window_state_event(GtkWidget
*widget
, GdkEventWindowState
*event
, gpointer user_data
)
1971 if (event
->changed_mask
& GDK_WINDOW_STATE_FULLSCREEN
)
1973 static GtkWidget
*menuitem
= NULL
;
1975 if (menuitem
== NULL
)
1976 menuitem
= ui_lookup_widget(widget
, "menu_fullscreen1");
1978 ignore_callback
= TRUE
;
1980 ui_prefs
.fullscreen
= (event
->new_window_state
& GDK_WINDOW_STATE_FULLSCREEN
) ? TRUE
: FALSE
;
1981 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem
), ui_prefs
.fullscreen
);
1983 ignore_callback
= FALSE
;
1989 static void show_notebook_page(const gchar
*notebook_name
, const gchar
*page_name
)
1992 GtkNotebook
*notebook
;
1994 widget
= ui_lookup_widget(ui_widgets
.prefs_dialog
, page_name
);
1995 notebook
= GTK_NOTEBOOK(ui_lookup_widget(ui_widgets
.prefs_dialog
, notebook_name
));
1997 if (notebook
!= NULL
&& widget
!= NULL
)
1998 gtk_notebook_set_current_page(notebook
, gtk_notebook_page_num(notebook
, widget
));
2002 G_MODULE_EXPORT
void on_customize_toolbar1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
2004 prefs_show_dialog();
2006 /* select the Interface page */
2007 show_notebook_page("notebook2", "notebook6");
2008 /* select the Toolbar subpage */
2009 show_notebook_page("notebook6", "vbox15");
2013 G_MODULE_EXPORT
void on_button_customize_toolbar_clicked(GtkButton
*button
, gpointer user_data
)
2015 toolbar_configure(GTK_WINDOW(ui_widgets
.prefs_dialog
));
2019 G_MODULE_EXPORT
void on_cut_current_lines1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
2021 keybindings_send_command(GEANY_KEY_GROUP_CLIPBOARD
, GEANY_KEYS_CLIPBOARD_CUTLINE
);
2025 G_MODULE_EXPORT
void on_copy_current_lines1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
2027 keybindings_send_command(GEANY_KEY_GROUP_CLIPBOARD
, GEANY_KEYS_CLIPBOARD_COPYLINE
);
2031 G_MODULE_EXPORT
void on_delete_current_lines1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
2033 keybindings_send_command(GEANY_KEY_GROUP_EDITOR
, GEANY_KEYS_EDITOR_DELETELINE
);
2037 G_MODULE_EXPORT
void on_duplicate_line_or_selection1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
2039 keybindings_send_command(GEANY_KEY_GROUP_EDITOR
, GEANY_KEYS_EDITOR_DUPLICATELINE
);
2043 G_MODULE_EXPORT
void on_select_current_lines1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
2045 keybindings_send_command(GEANY_KEY_GROUP_SELECT
, GEANY_KEYS_SELECT_LINE
);
2049 G_MODULE_EXPORT
void on_select_current_paragraph1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
2051 keybindings_send_command(GEANY_KEY_GROUP_SELECT
, GEANY_KEYS_SELECT_PARAGRAPH
);
2055 G_MODULE_EXPORT
void on_insert_alternative_white_space1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
2057 keybindings_send_command(GEANY_KEY_GROUP_INSERT
, GEANY_KEYS_INSERT_ALTWHITESPACE
);
2061 G_MODULE_EXPORT
void on_go_to_next_marker1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
2063 keybindings_send_command(GEANY_KEY_GROUP_GOTO
, GEANY_KEYS_GOTO_NEXTMARKER
);
2067 G_MODULE_EXPORT
void on_go_to_previous_marker1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
2069 keybindings_send_command(GEANY_KEY_GROUP_GOTO
, GEANY_KEYS_GOTO_PREVIOUSMARKER
);
2073 G_MODULE_EXPORT
void on_reflow_lines_block1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
2075 keybindings_send_command(GEANY_KEY_GROUP_FORMAT
, GEANY_KEYS_FORMAT_REFLOWPARAGRAPH
);
2079 G_MODULE_EXPORT
void on_move_lines_up1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
2081 keybindings_send_command(GEANY_KEY_GROUP_EDITOR
, GEANY_KEYS_EDITOR_MOVELINEUP
);
2085 G_MODULE_EXPORT
void on_move_lines_down1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
2087 keybindings_send_command(GEANY_KEY_GROUP_EDITOR
, GEANY_KEYS_EDITOR_MOVELINEDOWN
);
2091 G_MODULE_EXPORT
void on_smart_line_indent1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
2093 keybindings_send_command(GEANY_KEY_GROUP_FORMAT
, GEANY_KEYS_FORMAT_AUTOINDENT
);
2097 G_MODULE_EXPORT
void on_plugin_preferences1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
2100 plugin_show_configure(NULL
);
2105 G_MODULE_EXPORT
void on_indent_width_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
2111 if (ignore_callback
)
2114 label
= ui_menu_item_get_text(menuitem
);
2115 width
= atoi(label
);
2118 doc
= document_get_current();
2119 if (doc
!= NULL
&& width
> 0)
2120 editor_set_indent_width(doc
->editor
, width
);
2124 G_MODULE_EXPORT
void on_reset_indentation1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
2129 document_apply_indent_settings(documents
[i
]);
2131 ui_update_statusbar(NULL
, -1);
2132 ui_document_show_hide(NULL
);
2136 G_MODULE_EXPORT
void on_mark_all1_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
2138 keybindings_send_command(GEANY_KEY_GROUP_SEARCH
, GEANY_KEYS_SEARCH_MARKALL
);
2142 G_MODULE_EXPORT
void on_detect_type_from_file_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
2144 GeanyDocument
*doc
= document_get_current();
2145 GeanyIndentType type
;
2147 if (doc
!= NULL
&& document_detect_indent_type(doc
, &type
))
2149 editor_set_indent_type(doc
->editor
, type
);
2150 ui_document_show_hide(doc
);
2155 G_MODULE_EXPORT
void on_detect_width_from_file_activate(GtkMenuItem
*menuitem
, gpointer user_data
)
2157 GeanyDocument
*doc
= document_get_current();
2160 if (doc
!= NULL
&& document_detect_indent_width(doc
, &width
))
2162 editor_set_indent_width(doc
->editor
, width
);
2163 ui_document_show_hide(doc
);