2005-11-22 12:26:26 +00:00
|
|
|
/*
|
|
|
|
* callbacks.c - this file is part of Geany, a fast and lightweight IDE
|
|
|
|
*
|
2012-06-18 01:13:05 +02:00
|
|
|
* Copyright 2005-2012 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
|
|
|
|
* Copyright 2006-2012 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
|
2005-11-22 12:26:26 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
2012-08-24 19:25:57 +02:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2005-11-22 12:26:26 +00:00
|
|
|
*/
|
|
|
|
|
2007-02-24 11:41:56 +00:00
|
|
|
/*
|
|
|
|
* Callbacks used by Glade. These are mainly in response to menu item and button events in the
|
|
|
|
* main window. Callbacks not used by Glade should go elsewhere.
|
|
|
|
*/
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2014-05-18 17:31:51 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
2005-11-22 12:26:26 +00:00
|
|
|
|
|
|
|
#include "callbacks.h"
|
|
|
|
|
2006-05-22 00:25:19 +00:00
|
|
|
#include "about.h"
|
2014-05-18 17:31:51 -07:00
|
|
|
#include "app.h"
|
2005-11-22 12:26:26 +00:00
|
|
|
#include "build.h"
|
2014-05-18 17:31:51 -07:00
|
|
|
#include "dialogs.h"
|
|
|
|
#include "documentprivate.h"
|
2006-06-19 18:31:17 +00:00
|
|
|
#include "encodings.h"
|
2014-05-18 17:31:51 -07:00
|
|
|
#include "filetypes.h"
|
|
|
|
#include "geanyobject.h"
|
|
|
|
#include "highlighting.h"
|
|
|
|
#include "keybindings.h"
|
|
|
|
#include "keyfile.h"
|
|
|
|
#include "log.h"
|
2006-10-21 11:34:18 +00:00
|
|
|
#include "main.h"
|
2014-05-18 17:31:51 -07:00
|
|
|
#include "msgwindow.h"
|
2007-06-02 16:14:07 +00:00
|
|
|
#include "navqueue.h"
|
2007-11-20 18:15:46 +00:00
|
|
|
#include "plugins.h"
|
2009-10-28 18:06:16 +00:00
|
|
|
#include "pluginutils.h"
|
2014-05-18 17:31:51 -07:00
|
|
|
#include "prefs.h"
|
|
|
|
#include "printing.h"
|
|
|
|
#include "sciwrappers.h"
|
|
|
|
#include "sidebar.h"
|
2006-09-07 15:51:24 +00:00
|
|
|
#ifdef HAVE_SOCKET
|
|
|
|
# include "socket.h"
|
|
|
|
#endif
|
2014-05-18 17:31:51 -07:00
|
|
|
#include "support.h"
|
|
|
|
#include "symbols.h"
|
|
|
|
#include "templates.h"
|
|
|
|
#include "toolbar.h"
|
|
|
|
#include "tools.h"
|
|
|
|
#include "ui_utils.h"
|
|
|
|
#include "utils.h"
|
|
|
|
#include "vte.h"
|
|
|
|
|
|
|
|
#include "gtkcompat.h"
|
2006-09-07 15:51:24 +00:00
|
|
|
|
2014-05-18 17:31:51 -07:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <gdk/gdkkeysyms.h>
|
|
|
|
#include <glib/gstdio.h>
|
|
|
|
#include <time.h>
|
2005-11-27 20:54:28 +00:00
|
|
|
|
2006-07-11 14:15:56 +00:00
|
|
|
|
2014-06-24 17:48:54 +02:00
|
|
|
/* prototypes of Glade-only callback to let the compiler know they really are meant to be exported */
|
2014-06-24 18:15:46 +02:00
|
|
|
G_MODULE_EXPORT gboolean on_window_delete_event(GtkWidget *widget, GdkEvent *event, gpointer gdata);
|
2014-06-24 17:48:54 +02:00
|
|
|
G_MODULE_EXPORT void on_info1_activate(GtkMenuItem *menuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_change_font1_activate(GtkMenuItem *menuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_crlf_activate(GtkCheckMenuItem *menuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_lf_activate(GtkCheckMenuItem *menuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_cr_activate(GtkCheckMenuItem *menuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_hide_toolbar1_activate(GtkMenuItem *menuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_show_toolbar1_toggled(GtkCheckMenuItem *checkmenuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_fullscreen1_toggled(GtkCheckMenuItem *checkmenuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_markers_margin1_toggled(GtkCheckMenuItem *checkmenuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_show_messages_window1_toggled(GtkCheckMenuItem *checkmenuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_menu_color_schemes_activate(GtkImageMenuItem *imagemenuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_count_words1_activate(GtkMenuItem *menuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_edit1_activate(GtkMenuItem *menuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_website1_activate(GtkMenuItem *menuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_help_menu_item_donate_activate(GtkMenuItem *item, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_help_menu_item_wiki_activate(GtkMenuItem *item, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_help_menu_item_bug_report_activate(GtkMenuItem *item, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_comments_function_activate(GtkMenuItem *menuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_comments_multiline_activate(GtkMenuItem *menuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_comments_changelog_activate(GtkMenuItem *menuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_comments_gpl_activate(GtkMenuItem *menuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_comments_fileheader_activate(GtkMenuItem *menuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_set_file_readonly1_toggled(GtkCheckMenuItem *checkmenuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_tv_notebook_switch_page(GtkNotebook *notebook, gpointer page, guint page_num, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_help_shortcuts1_activate(GtkMenuItem *menuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_file_properties_activate(GtkMenuItem *menuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_show_line_numbers1_toggled(GtkCheckMenuItem *checkmenuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_use_auto_indentation1_toggled(GtkCheckMenuItem *checkmenuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_menu_fold_all1_activate(GtkMenuItem *menuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_menu_unfold_all1_activate(GtkMenuItem *menuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_notebook1_switch_page_after(GtkNotebook *notebook, gpointer page, guint page_num, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_menu_write_unicode_bom1_toggled(GtkCheckMenuItem *checkmenuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_menu_comments_multiline_activate(GtkMenuItem *menuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_menu_comments_gpl_activate(GtkMenuItem *menuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_menu_comments_bsd_activate(GtkMenuItem *menuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_comments_bsd_activate(GtkMenuItem *menuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_menu_project1_activate(GtkMenuItem *menuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_load_tags1_activate(GtkMenuItem *menuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_file1_activate(GtkMenuItem *menuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_tv_notebook_switch_page_after(GtkNotebook *notebook, gpointer page, guint page_num, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_tabs1_activate(GtkCheckMenuItem *menuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_spaces1_activate(GtkCheckMenuItem *menuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_strip_trailing_spaces1_activate(GtkMenuItem *menuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_page_setup1_activate(GtkMenuItem *menuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_search1_activate(GtkMenuItem *menuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_menu_reload_configuration1_activate(GtkMenuItem *menuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_tabs_and_spaces1_activate(GtkCheckMenuItem *menuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_debug_messages1_activate(GtkMenuItem *menuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_menu_show_white_space1_toggled(GtkCheckMenuItem *checkmenuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_menu_show_line_endings1_toggled(GtkCheckMenuItem *checkmenuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_menu_show_indentation_guides1_toggled(GtkCheckMenuItem *checkmenuitem, gpointer user_data);
|
2014-06-24 18:15:46 +02:00
|
|
|
G_MODULE_EXPORT gboolean on_window_state_event(GtkWidget *widget, GdkEventWindowState *event, gpointer user_data);
|
2014-06-24 17:48:54 +02:00
|
|
|
G_MODULE_EXPORT void on_customize_toolbar1_activate(GtkMenuItem *menuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_button_customize_toolbar_clicked(GtkButton *button, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_cut_current_lines1_activate(GtkMenuItem *menuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_copy_current_lines1_activate(GtkMenuItem *menuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_delete_current_lines1_activate(GtkMenuItem *menuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_duplicate_line_or_selection1_activate(GtkMenuItem *menuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_select_current_lines1_activate(GtkMenuItem *menuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_select_current_paragraph1_activate(GtkMenuItem *menuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_insert_alternative_white_space1_activate(GtkMenuItem *menuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_go_to_next_marker1_activate(GtkMenuItem *menuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_go_to_previous_marker1_activate(GtkMenuItem *menuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_reflow_lines_block1_activate(GtkMenuItem *menuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_smart_line_indent1_activate(GtkMenuItem *menuitem, gpointer user_data);
|
2014-06-24 18:07:29 +02:00
|
|
|
G_MODULE_EXPORT void on_move_lines_up1_activate(GtkMenuItem *menuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_move_lines_down1_activate(GtkMenuItem *menuitem, gpointer user_data);
|
2014-06-24 17:48:54 +02:00
|
|
|
G_MODULE_EXPORT void on_goto_tag_definition1(GtkMenuItem *menuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_goto_tag_declaration1(GtkMenuItem *menuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_indent_width_activate(GtkMenuItem *menuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_reset_indentation1_activate(GtkMenuItem *menuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_mark_all1_activate(GtkMenuItem *menuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_detect_type_from_file_activate(GtkMenuItem *menuitem, gpointer user_data);
|
|
|
|
G_MODULE_EXPORT void on_detect_width_from_file_activate(GtkMenuItem *menuitem, gpointer user_data);
|
2014-06-24 18:26:44 +02:00
|
|
|
G_MODULE_EXPORT void on_clone1_activate(GtkMenuItem *menuitem, gpointer user_data);
|
2014-06-24 17:48:54 +02:00
|
|
|
|
2006-12-17 19:31:32 +00:00
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* represents the state at switching a notebook page(in the left treeviews widget), to not emit
|
|
|
|
* the selection-changed signal from tv.tree_openfiles */
|
|
|
|
/*static gboolean switch_tv_notebook_page = FALSE; */
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2005-12-01 22:59:02 +00:00
|
|
|
|
2008-02-20 11:24:23 +00:00
|
|
|
static gboolean check_no_unsaved(void)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2006-11-07 11:24:22 +00:00
|
|
|
guint i;
|
2006-10-01 16:14:45 +00:00
|
|
|
|
2008-05-29 17:00:54 +00:00
|
|
|
for (i = 0; i < documents_array->len; i++)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2009-04-15 22:47:33 +00:00
|
|
|
if (documents[i]->is_valid && documents[i]->changed)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2006-11-07 11:24:22 +00:00
|
|
|
return FALSE;
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
}
|
2008-02-27 13:17:29 +00:00
|
|
|
return TRUE; /* no unsaved edits */
|
2006-11-07 11:24:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-06-24 18:11:34 +02:00
|
|
|
/* should only be called from on_window_delete_event */
|
2008-04-03 15:45:23 +00:00
|
|
|
static void quit_app(void)
|
|
|
|
{
|
|
|
|
configuration_save();
|
|
|
|
|
2008-01-25 13:14:38 +00:00
|
|
|
if (app->project != NULL)
|
2008-02-27 13:17:29 +00:00
|
|
|
project_close(FALSE); /* save project session files */
|
2008-01-25 13:14:38 +00:00
|
|
|
|
2008-04-24 14:33:12 +00:00
|
|
|
document_close_all();
|
2006-11-07 11:24:22 +00:00
|
|
|
|
2009-03-25 19:38:14 +00:00
|
|
|
main_status.quitting = TRUE;
|
|
|
|
|
2007-06-04 15:37:11 +00:00
|
|
|
main_quit();
|
2006-11-07 11:24:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* wrapper function to abort exit process if cancel button is pressed */
|
2014-06-24 18:15:46 +02:00
|
|
|
G_MODULE_EXPORT gboolean on_window_delete_event(GtkWidget *widget, GdkEvent *event, gpointer gdata)
|
2006-11-07 11:24:22 +00:00
|
|
|
{
|
2007-08-23 11:34:06 +00:00
|
|
|
main_status.quitting = TRUE;
|
2006-11-07 11:24:22 +00:00
|
|
|
|
|
|
|
if (! check_no_unsaved())
|
|
|
|
{
|
2008-04-24 14:33:12 +00:00
|
|
|
if (document_account_for_unsaved())
|
2006-11-13 16:47:26 +00:00
|
|
|
{
|
2006-11-07 11:24:22 +00:00
|
|
|
quit_app();
|
2006-11-13 16:47:26 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2006-11-07 11:24:22 +00:00
|
|
|
}
|
|
|
|
else
|
2007-08-23 11:34:06 +00:00
|
|
|
if (! prefs.confirm_exit ||
|
2007-07-04 17:08:53 +00:00
|
|
|
dialogs_show_question_full(NULL, GTK_STOCK_QUIT, GTK_STOCK_CANCEL, NULL,
|
2006-11-07 11:24:22 +00:00
|
|
|
_("Do you really want to quit?")))
|
2006-11-13 16:47:26 +00:00
|
|
|
{
|
|
|
|
quit_app();
|
|
|
|
return FALSE;
|
|
|
|
}
|
2006-11-07 11:24:22 +00:00
|
|
|
|
2007-08-23 11:34:06 +00:00
|
|
|
main_status.quitting = FALSE;
|
2005-11-22 12:26:26 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* GUI callbacks
|
|
|
|
*/
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_new1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2007-09-03 16:09:53 +00:00
|
|
|
document_new_file(NULL, NULL, NULL);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-06-24 18:26:44 +02:00
|
|
|
/* create a new file and copy file content and properties */
|
|
|
|
G_MODULE_EXPORT void on_clone1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
|
|
|
{
|
|
|
|
GeanyDocument *old_doc = document_get_current();
|
|
|
|
|
|
|
|
if (old_doc)
|
|
|
|
document_clone(old_doc);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_save1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2014-06-26 20:04:15 +02:00
|
|
|
if (doc != NULL)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2012-12-01 23:37:21 +01:00
|
|
|
document_save_file(doc, ui_prefs.allow_always_save);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_save_as1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
|
|
|
dialogs_show_save_as();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_save_all1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2011-11-06 01:12:42 +01:00
|
|
|
guint i, max = (guint) gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_widgets.notebook));
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc, *cur_doc = document_get_current();
|
2011-11-06 01:12:42 +01:00
|
|
|
guint count = 0;
|
2007-08-24 11:19:26 +00:00
|
|
|
|
2011-11-02 00:04:35 +01:00
|
|
|
/* iterate over documents in tabs order */
|
2007-08-24 11:19:26 +00:00
|
|
|
for (i = 0; i < max; i++)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
doc = document_get_from_page(i);
|
2009-04-15 22:47:33 +00:00
|
|
|
if (! doc->changed)
|
|
|
|
continue;
|
2011-11-02 15:17:17 +00:00
|
|
|
|
|
|
|
if (document_save_file(doc, FALSE))
|
|
|
|
count++;
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
2009-11-05 18:02:08 +00:00
|
|
|
if (!count)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ui_set_statusbar(FALSE, ngettext("%d file saved.", "%d files saved.", count), count);
|
|
|
|
/* saving may have changed window title, sidebar for another doc, so update */
|
2014-06-26 20:00:24 +02:00
|
|
|
document_show_tab(cur_doc);
|
2009-09-28 11:16:59 +00:00
|
|
|
sidebar_update_tag_list(cur_doc, TRUE);
|
2008-06-15 13:35:48 +00:00
|
|
|
ui_set_window_title(cur_doc);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_close_all1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2008-04-24 14:33:12 +00:00
|
|
|
document_close_all();
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_close1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2008-11-03 17:38:50 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
|
|
|
|
2013-07-21 13:50:25 +02:00
|
|
|
if (doc != NULL)
|
|
|
|
document_close(doc);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_quit1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2014-06-24 18:11:34 +02:00
|
|
|
on_window_delete_event(NULL, NULL, NULL);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_file1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2007-05-25 14:42:43 +00:00
|
|
|
{
|
2007-08-23 11:34:06 +00:00
|
|
|
gtk_widget_set_sensitive(ui_widgets.recent_files_menuitem,
|
|
|
|
g_queue_get_length(ui_prefs.recent_queue) > 0);
|
2011-06-13 20:42:31 +00:00
|
|
|
/* hide Page setup when GTK printing is not used */
|
|
|
|
ui_widget_show_hide(ui_widgets.print_page_setup, printing_prefs.use_gtk_printing);
|
2007-05-25 14:42:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* edit actions, c&p & co, from menu bar and from popup menu */
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_edit1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2009-10-28 18:06:16 +00:00
|
|
|
GtkWidget *item;
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2009-10-28 18:06:16 +00:00
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
ui_update_menu_copy_items(doc);
|
|
|
|
ui_update_insert_include_item(doc, 1);
|
2009-10-28 18:06:16 +00:00
|
|
|
|
|
|
|
item = ui_lookup_widget(main_widgets.window, "plugin_preferences1");
|
|
|
|
#ifndef HAVE_PLUGINS
|
|
|
|
gtk_widget_hide(item);
|
|
|
|
#else
|
2009-12-29 18:35:30 +00:00
|
|
|
gtk_widget_set_sensitive(item, plugins_have_preferences());
|
2009-10-28 18:06:16 +00:00
|
|
|
#endif
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_undo1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2008-09-17 12:12:49 +00:00
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
g_return_if_fail(doc != NULL);
|
|
|
|
|
|
|
|
if (document_can_undo(doc))
|
2008-09-17 12:12:49 +00:00
|
|
|
{
|
2008-09-25 18:29:53 +00:00
|
|
|
sci_cancel(doc->editor->sci);
|
2008-06-15 13:35:48 +00:00
|
|
|
document_undo(doc);
|
2008-09-17 12:12:49 +00:00
|
|
|
}
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_redo1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2008-09-17 12:12:49 +00:00
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
g_return_if_fail(doc != NULL);
|
|
|
|
|
|
|
|
if (document_can_redo(doc))
|
2008-09-17 12:12:49 +00:00
|
|
|
{
|
2008-09-25 18:29:53 +00:00
|
|
|
sci_cancel(doc->editor->sci);
|
2008-06-15 13:35:48 +00:00
|
|
|
document_redo(doc);
|
2008-09-17 12:12:49 +00:00
|
|
|
}
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_cut1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2008-05-22 14:41:28 +00:00
|
|
|
GtkWidget *focusw = gtk_window_get_focus(GTK_WINDOW(main_widgets.window));
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2006-06-25 19:57:07 +00:00
|
|
|
if (GTK_IS_EDITABLE(focusw))
|
|
|
|
gtk_editable_cut_clipboard(GTK_EDITABLE(focusw));
|
|
|
|
else
|
2009-04-15 22:47:33 +00:00
|
|
|
if (IS_SCINTILLA(focusw) && doc != NULL)
|
2008-07-14 11:13:54 +00:00
|
|
|
sci_cut(doc->editor->sci);
|
2006-06-25 20:18:24 +00:00
|
|
|
else
|
|
|
|
if (GTK_IS_TEXT_VIEW(focusw))
|
|
|
|
{
|
|
|
|
GtkTextBuffer *buffer = gtk_text_view_get_buffer(
|
|
|
|
GTK_TEXT_VIEW(focusw));
|
|
|
|
gtk_text_buffer_cut_clipboard(buffer, gtk_clipboard_get(GDK_NONE), TRUE);
|
|
|
|
}
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_copy1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2008-05-22 14:41:28 +00:00
|
|
|
GtkWidget *focusw = gtk_window_get_focus(GTK_WINDOW(main_widgets.window));
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2006-06-25 19:57:07 +00:00
|
|
|
if (GTK_IS_EDITABLE(focusw))
|
|
|
|
gtk_editable_copy_clipboard(GTK_EDITABLE(focusw));
|
|
|
|
else
|
2009-04-15 22:47:33 +00:00
|
|
|
if (IS_SCINTILLA(focusw) && doc != NULL)
|
2008-07-14 11:13:54 +00:00
|
|
|
sci_copy(doc->editor->sci);
|
2006-06-25 20:18:24 +00:00
|
|
|
else
|
|
|
|
if (GTK_IS_TEXT_VIEW(focusw))
|
|
|
|
{
|
|
|
|
GtkTextBuffer *buffer = gtk_text_view_get_buffer(
|
|
|
|
GTK_TEXT_VIEW(focusw));
|
|
|
|
gtk_text_buffer_copy_clipboard(buffer, gtk_clipboard_get(GDK_NONE));
|
|
|
|
}
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_paste1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2008-05-22 14:41:28 +00:00
|
|
|
GtkWidget *focusw = gtk_window_get_focus(GTK_WINDOW(main_widgets.window));
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2006-06-25 19:57:07 +00:00
|
|
|
if (GTK_IS_EDITABLE(focusw))
|
|
|
|
gtk_editable_paste_clipboard(GTK_EDITABLE(focusw));
|
|
|
|
else
|
2009-04-15 22:47:33 +00:00
|
|
|
if (IS_SCINTILLA(focusw) && doc != NULL)
|
2006-12-21 16:41:36 +00:00
|
|
|
{
|
2008-07-14 11:13:54 +00:00
|
|
|
sci_paste(doc->editor->sci);
|
2006-12-21 16:41:36 +00:00
|
|
|
}
|
2006-06-25 20:18:24 +00:00
|
|
|
else
|
|
|
|
if (GTK_IS_TEXT_VIEW(focusw))
|
|
|
|
{
|
|
|
|
GtkTextBuffer *buffer = gtk_text_view_get_buffer(
|
|
|
|
GTK_TEXT_VIEW(focusw));
|
|
|
|
gtk_text_buffer_paste_clipboard(buffer, gtk_clipboard_get(GDK_NONE), NULL,
|
|
|
|
TRUE);
|
|
|
|
}
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_delete1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2008-05-22 14:41:28 +00:00
|
|
|
GtkWidget *focusw = gtk_window_get_focus(GTK_WINDOW(main_widgets.window));
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2006-06-25 19:57:07 +00:00
|
|
|
if (GTK_IS_EDITABLE(focusw))
|
|
|
|
gtk_editable_delete_selection(GTK_EDITABLE(focusw));
|
|
|
|
else
|
2009-04-15 22:47:33 +00:00
|
|
|
if (IS_SCINTILLA(focusw) && doc != NULL && sci_has_selection(doc->editor->sci))
|
2008-07-14 11:13:54 +00:00
|
|
|
sci_clear(doc->editor->sci);
|
2006-06-25 20:18:24 +00:00
|
|
|
else
|
|
|
|
if (GTK_IS_TEXT_VIEW(focusw))
|
|
|
|
{
|
|
|
|
GtkTextBuffer *buffer = gtk_text_view_get_buffer(
|
|
|
|
GTK_TEXT_VIEW(focusw));
|
|
|
|
gtk_text_buffer_delete_selection(buffer, TRUE, TRUE);
|
|
|
|
}
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_preferences1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2007-03-23 16:47:27 +00:00
|
|
|
prefs_show_dialog();
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* about menu item */
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_info1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2006-05-21 17:51:22 +00:00
|
|
|
about_dialog_show();
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* open file */
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_open1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
|
|
|
dialogs_show_open_file();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* reload file */
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_toolbutton_reload_clicked(GtkAction *action, gpointer user_data)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
g_return_if_fail(doc != NULL);
|
2012-07-24 17:56:29 -07:00
|
|
|
|
2014-06-24 09:13:44 +02:00
|
|
|
document_reload_prompt(doc, NULL);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_change_font1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
|
|
|
dialogs_show_open_font();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* store text, clear search flags so we can use Search->Find Next/Previous */
|
2011-03-24 16:51:02 +00:00
|
|
|
static void setup_find(const gchar *text, gboolean backwards)
|
2006-08-01 11:33:42 +00:00
|
|
|
{
|
2012-01-25 16:26:16 +00:00
|
|
|
SETPTR(search_data.text, g_strdup(text));
|
|
|
|
SETPTR(search_data.original_text, g_strdup(text));
|
2006-08-11 21:12:49 +00:00
|
|
|
search_data.flags = 0;
|
2011-03-24 16:51:02 +00:00
|
|
|
search_data.backwards = backwards;
|
2007-07-11 17:44:43 +00:00
|
|
|
search_data.search_bar = TRUE;
|
2006-08-01 11:33:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-24 16:51:02 +00:00
|
|
|
static void do_toolbar_search(const gchar *text, gboolean incremental, gboolean backwards)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2007-07-09 17:33:31 +00:00
|
|
|
gboolean result;
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2011-03-24 16:51:02 +00:00
|
|
|
setup_find(text, backwards);
|
|
|
|
result = document_search_bar_find(doc, search_data.text, 0, incremental, backwards);
|
2009-02-27 14:05:50 +00:00
|
|
|
if (search_data.search_bar)
|
|
|
|
ui_set_search_entry_background(toolbar_get_widget_child_by_name("SearchEntry"), result);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-24 16:51:02 +00:00
|
|
|
/* search text */
|
2014-06-24 16:44:10 +02:00
|
|
|
void on_toolbar_search_entry_changed(GtkAction *action, const gchar *text, gpointer user_data)
|
2011-03-24 16:51:02 +00:00
|
|
|
{
|
|
|
|
do_toolbar_search(text, TRUE, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* search text */
|
2014-06-24 16:44:10 +02:00
|
|
|
void on_toolbar_search_entry_activate(GtkAction *action, const gchar *text, gpointer user_data)
|
2011-03-24 16:51:02 +00:00
|
|
|
{
|
|
|
|
do_toolbar_search(text, FALSE, GPOINTER_TO_INT(user_data));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* search text */
|
2014-06-24 16:44:10 +02:00
|
|
|
void on_toolbutton_search_clicked(GtkAction *action, gpointer user_data)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2007-07-09 17:33:31 +00:00
|
|
|
gboolean result;
|
2008-12-06 11:10:06 +00:00
|
|
|
GtkWidget *entry = toolbar_get_widget_child_by_name("SearchEntry");
|
|
|
|
|
|
|
|
if (entry != NULL)
|
|
|
|
{
|
|
|
|
const gchar *text = gtk_entry_get_text(GTK_ENTRY(entry));
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2011-03-24 16:51:02 +00:00
|
|
|
setup_find(text, FALSE);
|
|
|
|
result = document_search_bar_find(doc, search_data.text, 0, FALSE, FALSE);
|
2009-02-27 14:05:50 +00:00
|
|
|
if (search_data.search_bar)
|
|
|
|
ui_set_search_entry_background(entry, result);
|
2008-12-06 11:10:06 +00:00
|
|
|
}
|
2009-12-29 18:40:55 +00:00
|
|
|
else
|
|
|
|
on_find1_activate(NULL, NULL);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* hides toolbar from toolbar popup menu */
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_hide_toolbar1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2008-12-18 21:21:53 +00:00
|
|
|
GtkWidget *tool_item = ui_lookup_widget(GTK_WIDGET(main_widgets.window), "menu_show_toolbar1");
|
2005-11-22 12:26:26 +00:00
|
|
|
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(tool_item), FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* zoom in from menu bar and popup menu */
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_zoom_in1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
g_return_if_fail(doc != NULL);
|
|
|
|
|
|
|
|
sci_zoom_in(doc->editor->sci);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
2009-09-16 14:13:38 +00:00
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* zoom out from menu bar and popup menu */
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_zoom_out1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2009-04-15 22:47:33 +00:00
|
|
|
|
|
|
|
g_return_if_fail(doc != NULL);
|
|
|
|
|
|
|
|
sci_zoom_out(doc->editor->sci);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_normal_size1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2009-04-15 22:47:33 +00:00
|
|
|
|
|
|
|
g_return_if_fail(doc != NULL);
|
|
|
|
|
|
|
|
sci_zoom_off(doc->editor->sci);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-03-24 18:12:39 +00:00
|
|
|
static gboolean delayed_check_disk_status(gpointer data)
|
|
|
|
{
|
|
|
|
document_check_disk_status(data, FALSE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-01-03 12:54:13 +00:00
|
|
|
/* Changes window-title after switching tabs and lots of other things.
|
|
|
|
* note: using 'after' makes Scintilla redraw before the UI, appearing more responsive */
|
2012-09-11 16:52:19 +02:00
|
|
|
G_MODULE_EXPORT void on_notebook1_switch_page_after(GtkNotebook *notebook, gpointer page,
|
2011-08-06 18:34:14 +00:00
|
|
|
guint page_num, gpointer user_data)
|
2006-05-26 12:22:39 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc;
|
2006-05-26 12:22:39 +00:00
|
|
|
|
2011-03-24 22:00:18 +00:00
|
|
|
if (G_UNLIKELY(main_status.opening_session_files || main_status.closing_all))
|
2008-04-02 13:48:39 +00:00
|
|
|
return;
|
2006-05-26 12:22:39 +00:00
|
|
|
|
2006-08-08 13:01:50 +00:00
|
|
|
if (page_num == (guint) -1 && page != NULL)
|
2008-06-15 13:35:48 +00:00
|
|
|
doc = document_find_by_sci(SCINTILLA(page));
|
2006-05-26 12:22:39 +00:00
|
|
|
else
|
2008-06-15 13:35:48 +00:00
|
|
|
doc = document_get_from_page(page_num);
|
2006-05-26 12:22:39 +00:00
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
if (doc != NULL)
|
2006-05-26 12:22:39 +00:00
|
|
|
{
|
2009-09-28 11:16:59 +00:00
|
|
|
sidebar_select_openfiles_item(doc);
|
2010-04-27 15:09:34 +00:00
|
|
|
ui_save_buttons_toggle(doc->changed);
|
|
|
|
ui_set_window_title(doc);
|
|
|
|
ui_update_statusbar(doc, -1);
|
2008-06-15 13:35:48 +00:00
|
|
|
ui_update_popup_reundo_items(doc);
|
|
|
|
ui_document_show_hide(doc); /* update the document menu */
|
|
|
|
build_menu_update(doc);
|
2009-09-28 11:16:59 +00:00
|
|
|
sidebar_update_tag_list(doc, FALSE);
|
2012-01-03 10:21:09 -08:00
|
|
|
document_highlight_tags(doc);
|
2007-03-14 12:03:15 +00:00
|
|
|
|
2009-03-24 18:12:39 +00:00
|
|
|
/* We delay the check to avoid weird fast, unintended switching of notebook pages when
|
|
|
|
* the 'file has changed' dialog is shown while the switch event is not yet completely
|
|
|
|
* finished. So, we check after the switch has been performed to be safe. */
|
|
|
|
g_idle_add(delayed_check_disk_status, doc);
|
2006-06-29 23:51:32 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_VTE
|
2009-02-01 18:03:19 +00:00
|
|
|
vte_cwd((doc->real_path != NULL) ? doc->real_path : doc->file_name, FALSE);
|
2006-06-29 23:51:32 +00:00
|
|
|
#endif
|
2007-08-23 15:22:13 +00:00
|
|
|
|
2008-11-21 17:33:35 +00:00
|
|
|
g_signal_emit_by_name(geany_object, "document-activate", doc);
|
2006-08-19 15:07:11 +00:00
|
|
|
}
|
2006-05-26 12:22:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-09-11 16:52:19 +02:00
|
|
|
G_MODULE_EXPORT void on_tv_notebook_switch_page(GtkNotebook *notebook, gpointer page,
|
2011-08-06 18:34:14 +00:00
|
|
|
guint page_num, gpointer user_data)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2008-02-27 13:17:29 +00:00
|
|
|
/* suppress selection changed signal when switching to the open files list */
|
2008-05-22 14:41:28 +00:00
|
|
|
ignore_callback = TRUE;
|
2007-10-16 08:54:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-09-11 16:52:19 +02:00
|
|
|
G_MODULE_EXPORT void on_tv_notebook_switch_page_after(GtkNotebook *notebook, gpointer page,
|
2011-08-06 18:34:14 +00:00
|
|
|
guint page_num, gpointer user_data)
|
2007-10-16 08:54:54 +00:00
|
|
|
{
|
2008-05-22 14:41:28 +00:00
|
|
|
ignore_callback = FALSE;
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-04-09 12:30:28 +00:00
|
|
|
static void convert_eol(gint mode)
|
|
|
|
{
|
|
|
|
GeanyDocument *doc = document_get_current();
|
|
|
|
|
|
|
|
g_return_if_fail(doc != NULL);
|
|
|
|
|
|
|
|
sci_convert_eols(doc->editor->sci, mode);
|
|
|
|
sci_set_eol_mode(doc->editor->sci, mode);
|
|
|
|
ui_update_statusbar(doc, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_crlf_activate(GtkCheckMenuItem *menuitem, gpointer user_data)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2009-04-17 15:30:01 +00:00
|
|
|
if (ignore_callback || ! gtk_check_menu_item_get_active(menuitem))
|
2009-04-05 21:07:40 +00:00
|
|
|
return;
|
2009-04-15 22:47:33 +00:00
|
|
|
|
2010-04-09 12:30:28 +00:00
|
|
|
convert_eol(SC_EOL_CRLF);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_lf_activate(GtkCheckMenuItem *menuitem, gpointer user_data)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2009-04-17 15:30:01 +00:00
|
|
|
if (ignore_callback || ! gtk_check_menu_item_get_active(menuitem))
|
2009-04-05 21:07:40 +00:00
|
|
|
return;
|
2009-04-15 22:47:33 +00:00
|
|
|
|
2010-04-09 12:30:28 +00:00
|
|
|
convert_eol(SC_EOL_LF);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_cr_activate(GtkCheckMenuItem *menuitem, gpointer user_data)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2009-04-17 15:30:01 +00:00
|
|
|
if (ignore_callback || ! gtk_check_menu_item_get_active(menuitem))
|
2009-04-05 21:07:40 +00:00
|
|
|
return;
|
2009-04-15 22:47:33 +00:00
|
|
|
|
2010-04-09 12:30:28 +00:00
|
|
|
convert_eol(SC_EOL_CR);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_replace_tabs_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
g_return_if_fail(doc != NULL);
|
|
|
|
|
|
|
|
editor_replace_tabs(doc->editor);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-06 18:34:14 +00:00
|
|
|
gboolean toolbar_popup_menu(GtkWidget *widget, GdkEventButton *event, gpointer user_data)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
|
|
|
if (event->button == 3)
|
|
|
|
{
|
2007-08-23 11:34:06 +00:00
|
|
|
gtk_menu_popup(GTK_MENU(ui_widgets.toolbar_menu), NULL, NULL, NULL, NULL, event->button, event->time);
|
2005-11-22 12:26:26 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_toggle_case1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
|
|
|
ScintillaObject *sci;
|
2007-09-07 19:01:55 +00:00
|
|
|
gchar *text;
|
2007-09-12 16:01:23 +00:00
|
|
|
gboolean keep_sel = TRUE;
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
g_return_if_fail(doc != NULL);
|
2006-09-12 08:32:52 +00:00
|
|
|
|
2008-07-14 11:13:54 +00:00
|
|
|
sci = doc->editor->sci;
|
2008-09-17 18:02:55 +00:00
|
|
|
if (! sci_has_selection(sci))
|
2007-09-12 16:01:23 +00:00
|
|
|
{
|
2008-03-12 13:37:39 +00:00
|
|
|
keybindings_send_command(GEANY_KEY_GROUP_SELECT, GEANY_KEYS_SELECT_WORD);
|
2007-09-12 16:01:23 +00:00
|
|
|
keep_sel = FALSE;
|
|
|
|
}
|
2011-10-03 17:05:25 +00:00
|
|
|
|
|
|
|
/* either we already had a selection or we created one for current word */
|
|
|
|
if (sci_has_selection(sci))
|
2007-09-07 19:01:55 +00:00
|
|
|
{
|
2008-03-06 15:47:43 +00:00
|
|
|
gchar *result = NULL;
|
2008-03-13 15:18:42 +00:00
|
|
|
gint cmd = SCI_LOWERCASE;
|
2011-11-06 01:12:42 +01:00
|
|
|
gboolean rectsel = (gboolean) scintilla_send_message(sci, SCI_SELECTIONISRECTANGLE, 0, 0);
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2013-05-22 04:22:53 +02:00
|
|
|
text = sci_get_selection_contents(sci);
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2007-09-07 19:01:55 +00:00
|
|
|
if (utils_str_has_upper(text))
|
2011-08-06 18:34:14 +00:00
|
|
|
{
|
2008-03-06 15:47:43 +00:00
|
|
|
if (rectsel)
|
|
|
|
cmd = SCI_LOWERCASE;
|
|
|
|
else
|
|
|
|
result = g_utf8_strdown(text, -1);
|
|
|
|
}
|
2007-09-07 19:01:55 +00:00
|
|
|
else
|
2008-03-06 15:47:43 +00:00
|
|
|
{
|
|
|
|
if (rectsel)
|
|
|
|
cmd = SCI_UPPERCASE;
|
|
|
|
else
|
|
|
|
result = g_utf8_strup(text, -1);
|
|
|
|
}
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2008-03-06 15:47:43 +00:00
|
|
|
if (result != NULL)
|
|
|
|
{
|
|
|
|
sci_replace_sel(sci, result);
|
|
|
|
g_free(result);
|
|
|
|
if (keep_sel)
|
2013-05-22 04:22:53 +02:00
|
|
|
sci_set_selection_start(sci, sci_get_current_position(sci) - strlen(text));
|
2008-03-06 15:47:43 +00:00
|
|
|
}
|
|
|
|
else
|
2008-12-05 12:34:20 +00:00
|
|
|
sci_send_command(sci, cmd);
|
2006-09-12 08:32:52 +00:00
|
|
|
|
2007-09-07 19:01:55 +00:00
|
|
|
g_free(text);
|
2007-09-12 16:01:23 +00:00
|
|
|
|
2007-09-07 19:01:55 +00:00
|
|
|
}
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_show_toolbar1_toggled(GtkCheckMenuItem *checkmenuitem, gpointer user_data)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2008-05-22 14:41:28 +00:00
|
|
|
if (ignore_callback) return;
|
2006-07-21 11:41:33 +00:00
|
|
|
|
2008-05-16 12:08:39 +00:00
|
|
|
toolbar_prefs.visible = (toolbar_prefs.visible) ? FALSE : TRUE;;
|
2008-05-22 14:41:28 +00:00
|
|
|
ui_widget_show_hide(GTK_WIDGET(main_widgets.toolbar), toolbar_prefs.visible);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_fullscreen1_toggled(GtkCheckMenuItem *checkmenuitem, gpointer user_data)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2009-04-30 17:17:13 +00:00
|
|
|
if (ignore_callback)
|
|
|
|
return;
|
|
|
|
|
2007-08-23 11:34:06 +00:00
|
|
|
ui_prefs.fullscreen = (ui_prefs.fullscreen) ? FALSE : TRUE;
|
2006-09-05 14:24:47 +00:00
|
|
|
ui_set_fullscreen();
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_show_messages_window1_toggled(GtkCheckMenuItem *checkmenuitem, gpointer user_data)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2010-03-07 17:57:45 +00:00
|
|
|
if (ignore_callback)
|
|
|
|
return;
|
2006-07-21 11:41:33 +00:00
|
|
|
|
2007-08-23 11:34:06 +00:00
|
|
|
ui_prefs.msgwindow_visible = (ui_prefs.msgwindow_visible) ? FALSE : TRUE;
|
2010-03-07 17:57:45 +00:00
|
|
|
msgwin_show_hide(ui_prefs.msgwindow_visible);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-05-27 01:03:18 +02:00
|
|
|
G_MODULE_EXPORT void on_menu_color_schemes_activate(GtkImageMenuItem *imagemenuitem, gpointer user_data)
|
|
|
|
{
|
|
|
|
highlighting_show_color_scheme_dialog();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_markers_margin1_toggled(GtkCheckMenuItem *checkmenuitem, gpointer user_data)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2008-12-07 19:12:08 +00:00
|
|
|
if (ignore_callback)
|
|
|
|
return;
|
|
|
|
|
|
|
|
editor_prefs.show_markers_margin = ! editor_prefs.show_markers_margin;
|
|
|
|
ui_toggle_editor_features(GEANY_EDITOR_SHOW_MARKERS_MARGIN);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_show_line_numbers1_toggled(GtkCheckMenuItem *checkmenuitem, gpointer user_data)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2008-12-07 19:12:08 +00:00
|
|
|
if (ignore_callback)
|
|
|
|
return;
|
|
|
|
|
|
|
|
editor_prefs.show_linenumber_margin = ! editor_prefs.show_linenumber_margin;
|
|
|
|
ui_toggle_editor_features(GEANY_EDITOR_SHOW_LINE_NUMBERS);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_menu_show_white_space1_toggled(GtkCheckMenuItem *checkmenuitem, gpointer user_data)
|
2008-12-07 19:12:08 +00:00
|
|
|
{
|
|
|
|
if (ignore_callback)
|
|
|
|
return;
|
|
|
|
|
|
|
|
editor_prefs.show_white_space = ! editor_prefs.show_white_space;
|
|
|
|
ui_toggle_editor_features(GEANY_EDITOR_SHOW_WHITE_SPACE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_menu_show_line_endings1_toggled(GtkCheckMenuItem *checkmenuitem, gpointer user_data)
|
2008-12-07 19:12:08 +00:00
|
|
|
{
|
|
|
|
if (ignore_callback)
|
|
|
|
return;
|
|
|
|
|
|
|
|
editor_prefs.show_line_endings = ! editor_prefs.show_line_endings;
|
|
|
|
ui_toggle_editor_features(GEANY_EDITOR_SHOW_LINE_ENDINGS);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_menu_show_indentation_guides1_toggled(GtkCheckMenuItem *checkmenuitem, gpointer user_data)
|
2008-12-07 19:12:08 +00:00
|
|
|
{
|
|
|
|
if (ignore_callback)
|
|
|
|
return;
|
|
|
|
|
|
|
|
editor_prefs.show_indent_guide = ! editor_prefs.show_indent_guide;
|
|
|
|
ui_toggle_editor_features(GEANY_EDITOR_SHOW_INDENTATION_GUIDES);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_line_wrapping1_toggled(GtkCheckMenuItem *checkmenuitem, gpointer user_data)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2008-05-22 14:41:28 +00:00
|
|
|
if (! ignore_callback)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2009-04-15 22:47:33 +00:00
|
|
|
g_return_if_fail(doc != NULL);
|
|
|
|
|
|
|
|
editor_set_line_wrapping(doc->editor, ! doc->editor->line_wrapping);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_set_file_readonly1_toggled(GtkCheckMenuItem *checkmenuitem, gpointer user_data)
|
2006-02-20 22:55:53 +00:00
|
|
|
{
|
2008-05-22 14:41:28 +00:00
|
|
|
if (! ignore_callback)
|
2006-02-20 22:55:53 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2009-04-15 22:47:33 +00:00
|
|
|
g_return_if_fail(doc != NULL);
|
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
doc->readonly = ! doc->readonly;
|
2008-07-14 11:13:54 +00:00
|
|
|
sci_set_readonly(doc->editor->sci, doc->readonly);
|
2008-06-15 13:35:48 +00:00
|
|
|
ui_update_tab_status(doc);
|
|
|
|
ui_update_statusbar(doc, -1);
|
2006-02-20 22:55:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_use_auto_indentation1_toggled(GtkCheckMenuItem *checkmenuitem, gpointer user_data)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2008-05-22 14:41:28 +00:00
|
|
|
if (! ignore_callback)
|
2006-02-14 22:07:55 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2009-04-15 22:47:33 +00:00
|
|
|
g_return_if_fail(doc != NULL);
|
|
|
|
|
|
|
|
doc->editor->auto_indent = ! doc->editor->auto_indent;
|
2006-02-14 22:07:55 +00:00
|
|
|
}
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-17 16:42:03 +00:00
|
|
|
static void find_usage(gboolean in_session)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
gint flags;
|
2006-11-01 15:26:41 +00:00
|
|
|
gchar *search_text;
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2006-07-23 20:26:57 +00:00
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
g_return_if_fail(doc != NULL);
|
2006-11-01 15:26:41 +00:00
|
|
|
|
2008-09-17 18:02:55 +00:00
|
|
|
if (sci_has_selection(doc->editor->sci))
|
2008-02-27 13:17:29 +00:00
|
|
|
{ /* take selected text if there is a selection */
|
2013-05-22 04:22:53 +02:00
|
|
|
search_text = sci_get_selection_contents(doc->editor->sci);
|
2006-08-05 12:11:55 +00:00
|
|
|
flags = SCFIND_MATCHCASE;
|
2006-07-23 20:26:57 +00:00
|
|
|
}
|
|
|
|
else
|
2006-08-05 12:11:55 +00:00
|
|
|
{
|
2011-08-21 17:15:19 +00:00
|
|
|
editor_find_current_word_sciwc(doc->editor, -1,
|
|
|
|
editor_info.current_word, GEANY_MAX_WORD_LENGTH);
|
2006-09-04 15:57:46 +00:00
|
|
|
search_text = g_strdup(editor_info.current_word);
|
2006-08-05 12:11:55 +00:00
|
|
|
flags = SCFIND_MATCHCASE | SCFIND_WHOLEWORD;
|
|
|
|
}
|
2006-07-23 20:26:57 +00:00
|
|
|
|
2011-06-03 13:40:42 +00:00
|
|
|
search_find_usage(search_text, search_text, flags, in_session);
|
2006-07-23 20:26:57 +00:00
|
|
|
g_free(search_text);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_find_document_usage1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2008-07-17 16:42:03 +00:00
|
|
|
{
|
|
|
|
find_usage(FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_find_usage1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2008-07-17 16:42:03 +00:00
|
|
|
{
|
|
|
|
find_usage(TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-09 11:58:55 +00:00
|
|
|
static void goto_tag(gboolean definition)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2008-05-16 14:17:54 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
g_return_if_fail(doc != NULL);
|
2007-06-02 16:14:07 +00:00
|
|
|
|
2009-09-16 12:13:50 +00:00
|
|
|
/* update cursor pos for navigating back afterwards */
|
|
|
|
if (!sci_has_selection(doc->editor->sci))
|
|
|
|
sci_set_current_position(doc->editor->sci, editor_info.click_pos, FALSE);
|
|
|
|
|
|
|
|
/* use the keybinding callback as it checks for selections as well as current word */
|
|
|
|
if (definition)
|
|
|
|
keybindings_send_command(GEANY_KEY_GROUP_GOTO, GEANY_KEYS_GOTO_TAGDEFINITION);
|
|
|
|
else
|
|
|
|
keybindings_send_command(GEANY_KEY_GROUP_GOTO, GEANY_KEYS_GOTO_TAGDECLARATION);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_goto_tag_definition1(GtkMenuItem *menuitem, gpointer user_data)
|
2010-09-09 11:58:55 +00:00
|
|
|
{
|
|
|
|
goto_tag(TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_goto_tag_declaration1(GtkMenuItem *menuitem, gpointer user_data)
|
2010-09-09 11:58:55 +00:00
|
|
|
{
|
|
|
|
goto_tag(FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_count_words1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2007-07-27 11:28:17 +00:00
|
|
|
tools_word_count();
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_show_color_chooser1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2006-12-20 15:57:28 +00:00
|
|
|
gchar colour[9];
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
|
|
|
gint pos;
|
2006-07-27 20:57:13 +00:00
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
g_return_if_fail(doc != NULL);
|
2006-07-27 23:17:31 +00:00
|
|
|
|
2008-07-14 11:13:54 +00:00
|
|
|
pos = sci_get_current_position(doc->editor->sci);
|
2008-09-25 18:28:37 +00:00
|
|
|
editor_find_current_word(doc->editor, pos, colour, sizeof colour, GEANY_WORDCHARS"#");
|
2007-07-27 11:28:17 +00:00
|
|
|
tools_color_chooser(colour);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-06-24 16:44:10 +02:00
|
|
|
void on_toolbutton_compile_clicked(GtkAction *action, gpointer user_data)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2008-03-12 13:37:39 +00:00
|
|
|
keybindings_send_command(GEANY_KEY_GROUP_BUILD, GEANY_KEYS_BUILD_COMPILE);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_find1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2006-08-11 21:12:49 +00:00
|
|
|
search_show_find_dialog();
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_find_next1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2006-07-18 17:43:22 +00:00
|
|
|
{
|
2010-09-21 16:16:15 +00:00
|
|
|
search_find_again(FALSE);
|
2008-02-22 13:30:16 +00:00
|
|
|
}
|
2006-07-18 17:43:22 +00:00
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_find_previous1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2008-02-22 13:30:16 +00:00
|
|
|
{
|
2006-08-11 21:12:49 +00:00
|
|
|
if (search_data.flags & SCFIND_REGEXP)
|
2008-02-27 13:17:29 +00:00
|
|
|
/* Can't reverse search order for a regex (find next ignores search backwards) */
|
|
|
|
utils_beep();
|
2006-07-18 17:43:22 +00:00
|
|
|
else
|
2010-09-21 16:16:15 +00:00
|
|
|
search_find_again(TRUE);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_find_nextsel1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2007-01-23 17:51:30 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
search_find_selection(document_get_current(), FALSE);
|
2007-01-23 17:51:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_find_prevsel1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2007-01-23 17:51:30 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
search_find_selection(document_get_current(), TRUE);
|
2007-01-23 17:51:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_replace1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2006-08-11 21:12:49 +00:00
|
|
|
search_show_replace_dialog();
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_find_in_files1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2006-07-13 14:30:44 +00:00
|
|
|
{
|
2007-12-02 10:52:19 +00:00
|
|
|
search_show_find_in_files_dialog(NULL);
|
2006-07-13 14:30:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-05-09 15:48:55 +00:00
|
|
|
static void get_line_and_offset_from_text(const gchar *text, gint *line_no, gint *offset)
|
|
|
|
{
|
|
|
|
if (*text == '+' || *text == '-')
|
|
|
|
{
|
|
|
|
*line_no = atoi(text + 1);
|
|
|
|
*offset = (*text == '+') ? 1 : -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*line_no = atoi(text) - 1;
|
|
|
|
*offset = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_go_to_line_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2010-05-09 15:48:55 +00:00
|
|
|
static gchar value[16] = "";
|
|
|
|
gchar *result;
|
2008-10-23 20:55:06 +00:00
|
|
|
|
2010-05-09 15:48:55 +00:00
|
|
|
result = dialogs_show_input_goto_line(
|
2010-11-18 16:15:10 +00:00
|
|
|
_("Go to Line"), GTK_WINDOW(main_widgets.window),
|
|
|
|
_("Enter the line you want to go to:"), value);
|
2010-05-09 15:48:55 +00:00
|
|
|
if (result != NULL)
|
2008-10-23 20:55:06 +00:00
|
|
|
{
|
|
|
|
GeanyDocument *doc = document_get_current();
|
2010-05-09 15:48:55 +00:00
|
|
|
gint offset;
|
|
|
|
gint line_no;
|
2008-10-23 20:55:06 +00:00
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
g_return_if_fail(doc != NULL);
|
|
|
|
|
2010-05-09 15:48:55 +00:00
|
|
|
get_line_and_offset_from_text(result, &line_no, &offset);
|
|
|
|
if (! editor_goto_line(doc->editor, line_no, offset))
|
2009-04-15 22:47:33 +00:00
|
|
|
utils_beep();
|
2010-05-09 15:48:55 +00:00
|
|
|
/* remember value for future calls */
|
|
|
|
g_snprintf(value, sizeof(value), "%s", result);
|
|
|
|
|
|
|
|
g_free(result);
|
2008-10-23 20:55:06 +00:00
|
|
|
}
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-06-24 16:44:10 +02:00
|
|
|
void on_toolbutton_goto_entry_activate(GtkAction *action, const gchar *text, gpointer user_data)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2008-12-06 11:10:06 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2010-05-09 15:48:55 +00:00
|
|
|
gint offset;
|
|
|
|
gint line_no;
|
2008-12-06 11:10:06 +00:00
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
g_return_if_fail(doc != NULL);
|
|
|
|
|
2010-05-09 15:48:55 +00:00
|
|
|
get_line_and_offset_from_text(text, &line_no, &offset);
|
|
|
|
if (! editor_goto_line(doc->editor, line_no, offset))
|
2009-04-15 22:47:33 +00:00
|
|
|
utils_beep();
|
2009-09-27 11:06:04 +00:00
|
|
|
else
|
|
|
|
keybindings_send_command(GEANY_KEY_GROUP_FOCUS, GEANY_KEYS_FOCUS_EDITOR);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-06-24 16:44:10 +02:00
|
|
|
void on_toolbutton_goto_clicked(GtkAction *action, gpointer user_data)
|
2006-02-26 18:29:24 +00:00
|
|
|
{
|
2008-12-06 11:10:06 +00:00
|
|
|
GtkWidget *entry = toolbar_get_widget_child_by_name("GotoEntry");
|
2006-02-26 18:29:24 +00:00
|
|
|
|
2008-12-06 11:10:06 +00:00
|
|
|
if (entry != NULL)
|
|
|
|
{
|
|
|
|
const gchar *text = gtk_entry_get_text(GTK_ENTRY(entry));
|
2006-02-26 18:29:24 +00:00
|
|
|
|
2008-12-06 11:10:06 +00:00
|
|
|
on_toolbutton_goto_entry_activate(NULL, text, NULL);
|
|
|
|
}
|
2009-12-29 18:40:55 +00:00
|
|
|
else
|
|
|
|
on_go_to_line_activate(NULL, NULL);
|
2006-02-26 18:29:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_help1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2007-06-10 20:09:22 +00:00
|
|
|
gchar *uri;
|
|
|
|
|
2009-11-23 22:59:36 +00:00
|
|
|
uri = utils_get_help_url(NULL);
|
2009-01-28 19:30:18 +00:00
|
|
|
utils_open_browser(uri);
|
2005-12-18 22:38:57 +00:00
|
|
|
g_free(uri);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_help_shortcuts1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2005-12-18 22:38:57 +00:00
|
|
|
{
|
2007-03-23 16:34:54 +00:00
|
|
|
keybindings_show_shortcuts();
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_website1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2009-01-28 19:30:18 +00:00
|
|
|
utils_open_browser(GEANY_HOMEPAGE);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-02-26 20:12:38 -08:00
|
|
|
G_MODULE_EXPORT void on_help_menu_item_donate_activate(GtkMenuItem *item, gpointer user_data)
|
|
|
|
{
|
|
|
|
utils_open_browser(GEANY_DONATE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
G_MODULE_EXPORT void on_help_menu_item_wiki_activate(GtkMenuItem *item, gpointer user_data)
|
|
|
|
{
|
|
|
|
utils_open_browser(GEANY_WIKI);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
G_MODULE_EXPORT void on_help_menu_item_bug_report_activate(GtkMenuItem *item, gpointer user_data)
|
|
|
|
{
|
|
|
|
utils_open_browser(GEANY_BUG_REPORT);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_comments_function_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2005-11-22 12:26:26 +00:00
|
|
|
gchar *text;
|
2006-06-16 17:11:09 +00:00
|
|
|
const gchar *cur_tag = NULL;
|
2005-11-22 12:26:26 +00:00
|
|
|
gint line = -1, pos = 0;
|
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
if (doc == NULL || doc->file_type == NULL)
|
2006-06-07 16:50:41 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
ui_set_statusbar(FALSE,
|
|
|
|
_("Please set the filetype for the current file before using this function."));
|
2006-06-07 16:50:41 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-07-08 16:30:37 +00:00
|
|
|
/* symbols_get_current_function returns -1 on failure, so sci_get_position_from_line
|
2008-02-27 13:17:29 +00:00
|
|
|
* returns the current position, so it should be safe */
|
2008-07-08 16:30:37 +00:00
|
|
|
line = symbols_get_current_function(doc, &cur_tag);
|
2012-09-17 20:22:52 +02:00
|
|
|
pos = sci_get_position_from_line(doc->editor->sci, line);
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2010-01-24 14:52:46 +00:00
|
|
|
text = templates_get_template_function(doc, cur_tag);
|
2006-05-10 19:54:44 +00:00
|
|
|
|
2011-03-19 22:48:43 +00:00
|
|
|
sci_start_undo_action(doc->editor->sci);
|
2008-07-14 11:13:54 +00:00
|
|
|
sci_insert_text(doc->editor->sci, pos, text);
|
2011-03-19 22:48:43 +00:00
|
|
|
sci_end_undo_action(doc->editor->sci);
|
2005-11-22 12:26:26 +00:00
|
|
|
g_free(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-06-26 18:23:34 +02:00
|
|
|
static void insert_multiline_comment(GeanyDocument *doc, gint pos)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2014-06-26 18:23:34 +02:00
|
|
|
g_return_if_fail(doc != NULL);
|
|
|
|
g_return_if_fail(pos == -1 || pos >= 0);
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2014-06-26 18:23:34 +02:00
|
|
|
if (doc->file_type == NULL)
|
2006-06-07 16:50:41 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
ui_set_statusbar(FALSE,
|
|
|
|
_("Please set the filetype for the current file before using this function."));
|
2006-06-07 16:50:41 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-03-20 15:02:22 +00:00
|
|
|
if (doc->file_type->comment_open || doc->file_type->comment_single)
|
2014-06-26 18:23:34 +02:00
|
|
|
{
|
|
|
|
/* editor_insert_multiline_comment() uses editor_info.click_pos */
|
|
|
|
if (pos == -1)
|
|
|
|
editor_info.click_pos = sci_get_current_position(doc->editor->sci);
|
|
|
|
else
|
|
|
|
editor_info.click_pos = pos;
|
2010-01-22 16:41:04 +00:00
|
|
|
editor_insert_multiline_comment(doc->editor);
|
2014-06-26 18:23:34 +02:00
|
|
|
}
|
2010-01-22 16:41:04 +00:00
|
|
|
else
|
|
|
|
utils_beep();
|
2007-01-06 15:03:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-06-26 18:23:34 +02:00
|
|
|
G_MODULE_EXPORT void on_comments_multiline_activate(GtkMenuItem *menuitem, gpointer user_data)
|
|
|
|
{
|
|
|
|
insert_multiline_comment(document_get_current(), editor_info.click_pos);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
G_MODULE_EXPORT void on_menu_comments_multiline_activate(GtkMenuItem *menuitem, gpointer user_data)
|
|
|
|
{
|
|
|
|
insert_multiline_comment(document_get_current(), -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void insert_comment_template(GeanyDocument *doc, gint pos, guint template)
|
2007-01-06 15:03:53 +00:00
|
|
|
{
|
|
|
|
gchar *text;
|
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
g_return_if_fail(doc != NULL);
|
2014-06-26 18:23:34 +02:00
|
|
|
g_return_if_fail(pos == -1 || pos >= 0);
|
|
|
|
g_return_if_fail(template < GEANY_MAX_TEMPLATES);
|
2008-06-15 13:35:48 +00:00
|
|
|
|
2014-06-26 18:23:34 +02:00
|
|
|
if (pos == -1)
|
|
|
|
pos = sci_get_current_position(doc->editor->sci);
|
2006-05-10 19:54:44 +00:00
|
|
|
|
2014-06-26 18:23:34 +02:00
|
|
|
text = templates_get_template_licence(doc, template);
|
2006-12-17 19:31:32 +00:00
|
|
|
|
2011-03-19 22:48:43 +00:00
|
|
|
sci_start_undo_action(doc->editor->sci);
|
2014-06-26 18:23:34 +02:00
|
|
|
sci_insert_text(doc->editor->sci, pos, text);
|
2011-03-19 22:48:43 +00:00
|
|
|
sci_end_undo_action(doc->editor->sci);
|
2005-11-22 12:26:26 +00:00
|
|
|
g_free(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-06-26 18:23:34 +02:00
|
|
|
G_MODULE_EXPORT void on_comments_gpl_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2014-06-26 18:23:34 +02:00
|
|
|
insert_comment_template(document_get_current(), editor_info.click_pos, GEANY_TEMPLATE_GPL);
|
|
|
|
}
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
|
2014-06-26 18:23:34 +02:00
|
|
|
G_MODULE_EXPORT void on_menu_comments_gpl_activate(GtkMenuItem *menuitem, gpointer user_data)
|
|
|
|
{
|
|
|
|
insert_comment_template(document_get_current(), -1, GEANY_TEMPLATE_GPL);
|
|
|
|
}
|
2006-05-10 19:54:44 +00:00
|
|
|
|
2006-12-17 19:31:32 +00:00
|
|
|
|
2014-06-26 18:23:34 +02:00
|
|
|
G_MODULE_EXPORT void on_comments_bsd_activate(GtkMenuItem *menuitem, gpointer user_data)
|
|
|
|
{
|
|
|
|
insert_comment_template(document_get_current(), editor_info.click_pos, GEANY_TEMPLATE_BSD);
|
|
|
|
}
|
2007-01-06 15:38:44 +00:00
|
|
|
|
|
|
|
|
2014-06-26 18:23:34 +02:00
|
|
|
G_MODULE_EXPORT void on_menu_comments_bsd_activate(GtkMenuItem *menuitem, gpointer user_data)
|
|
|
|
{
|
|
|
|
insert_comment_template(document_get_current(), -1, GEANY_TEMPLATE_BSD);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_comments_changelog_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2005-11-22 12:26:26 +00:00
|
|
|
gchar *text;
|
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
g_return_if_fail(doc != NULL);
|
2008-06-15 13:35:48 +00:00
|
|
|
|
2010-01-24 14:52:46 +00:00
|
|
|
text = templates_get_template_changelog(doc);
|
2011-03-19 22:48:43 +00:00
|
|
|
sci_start_undo_action(doc->editor->sci);
|
2008-07-14 11:13:54 +00:00
|
|
|
sci_insert_text(doc->editor->sci, 0, text);
|
2008-02-27 13:17:29 +00:00
|
|
|
/* sets the cursor to the right position to type the changelog text,
|
|
|
|
* the template has 21 chars + length of name and email */
|
2008-07-14 11:13:54 +00:00
|
|
|
sci_goto_pos(doc->editor->sci, 21 + strlen(template_prefs.developer) + strlen(template_prefs.mail), TRUE);
|
2011-03-19 22:48:43 +00:00
|
|
|
sci_end_undo_action(doc->editor->sci);
|
2005-11-22 12:26:26 +00:00
|
|
|
|
|
|
|
g_free(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_comments_fileheader_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2005-11-22 12:26:26 +00:00
|
|
|
gchar *text;
|
2010-04-25 17:43:39 +00:00
|
|
|
const gchar *fname;
|
2008-05-16 14:17:54 +00:00
|
|
|
GeanyFiletype *ft;
|
2006-05-22 15:28:48 +00:00
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
g_return_if_fail(doc != NULL);
|
2007-07-04 11:32:33 +00:00
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
ft = doc->file_type;
|
|
|
|
fname = doc->file_name;
|
2007-07-04 11:32:33 +00:00
|
|
|
text = templates_get_template_fileheader(FILETYPE_ID(ft), fname);
|
2006-05-10 19:54:44 +00:00
|
|
|
|
2011-03-19 22:48:43 +00:00
|
|
|
sci_start_undo_action(doc->editor->sci);
|
2008-07-14 11:13:54 +00:00
|
|
|
sci_insert_text(doc->editor->sci, 0, text);
|
|
|
|
sci_goto_pos(doc->editor->sci, 0, FALSE);
|
2011-03-19 22:48:43 +00:00
|
|
|
sci_end_undo_action(doc->editor->sci);
|
2005-11-22 12:26:26 +00:00
|
|
|
g_free(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_file_properties_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2006-02-14 22:07:55 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2009-04-15 22:47:33 +00:00
|
|
|
g_return_if_fail(doc != NULL);
|
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
dialogs_show_file_properties(doc);
|
2006-02-14 22:07:55 +00:00
|
|
|
}
|
|
|
|
|
2006-02-20 22:55:53 +00:00
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_menu_fold_all1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2006-02-26 18:29:24 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2009-04-15 22:47:33 +00:00
|
|
|
g_return_if_fail(doc != NULL);
|
|
|
|
|
|
|
|
editor_fold_all(doc->editor);
|
2006-02-26 18:29:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_menu_unfold_all1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2006-02-26 18:29:24 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2009-04-15 22:47:33 +00:00
|
|
|
g_return_if_fail(doc != NULL);
|
|
|
|
|
|
|
|
editor_unfold_all(doc->editor);
|
2006-02-26 18:29:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-06-24 16:44:10 +02:00
|
|
|
void on_toolbutton_run_clicked(GtkAction *action, gpointer user_data)
|
2006-04-27 18:06:35 +00:00
|
|
|
{
|
2008-03-12 13:37:39 +00:00
|
|
|
keybindings_send_command(GEANY_KEY_GROUP_BUILD, GEANY_KEYS_BUILD_RUN);
|
2006-04-27 18:06:35 +00:00
|
|
|
}
|
|
|
|
|
2006-05-23 19:31:09 +00:00
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_menu_remove_indicators1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2006-06-13 20:03:44 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2009-04-15 22:47:33 +00:00
|
|
|
g_return_if_fail(doc != NULL);
|
2007-02-17 18:06:08 +00:00
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
editor_indicator_clear(doc->editor, GEANY_INDICATOR_ERROR);
|
2006-06-13 20:03:44 +00:00
|
|
|
}
|
|
|
|
|
2006-06-19 18:31:17 +00:00
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_print1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2006-06-29 17:14:52 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2009-04-15 22:47:33 +00:00
|
|
|
g_return_if_fail(doc != NULL);
|
|
|
|
|
|
|
|
printing_print_doc(doc);
|
2006-06-29 17:14:52 +00:00
|
|
|
}
|
2006-06-30 13:42:53 +00:00
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_menu_select_all1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2006-06-30 13:42:53 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2009-04-15 22:47:33 +00:00
|
|
|
g_return_if_fail(doc != NULL);
|
2006-06-30 13:42:53 +00:00
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
sci_select_all(doc->editor->sci);
|
2006-06-30 13:42:53 +00:00
|
|
|
}
|
|
|
|
|
2006-07-11 14:15:56 +00:00
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_menu_show_sidebar1_toggled(GtkCheckMenuItem *checkmenuitem, gpointer user_data)
|
2006-07-21 11:41:33 +00:00
|
|
|
{
|
2009-04-27 19:30:29 +00:00
|
|
|
if (ignore_callback)
|
|
|
|
return;
|
2006-07-21 11:41:33 +00:00
|
|
|
|
2007-08-23 11:34:06 +00:00
|
|
|
ui_prefs.sidebar_visible = ! ui_prefs.sidebar_visible;
|
2007-05-06 14:49:51 +00:00
|
|
|
|
2010-11-22 13:49:38 +00:00
|
|
|
/* show built-in tabs if no tabs visible */
|
|
|
|
if (ui_prefs.sidebar_visible &&
|
|
|
|
! interface_prefs.sidebar_openfiles_visible && ! interface_prefs.sidebar_symbol_visible &&
|
|
|
|
gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_widgets.sidebar_notebook)) <= 2)
|
2006-07-22 11:09:48 +00:00
|
|
|
{
|
2008-05-16 12:08:39 +00:00
|
|
|
interface_prefs.sidebar_openfiles_visible = TRUE;
|
|
|
|
interface_prefs.sidebar_symbol_visible = TRUE;
|
2006-07-22 11:09:48 +00:00
|
|
|
}
|
2007-05-06 14:49:51 +00:00
|
|
|
|
2010-03-07 17:44:14 +00:00
|
|
|
/* if window has input focus, set it back to the editor before toggling off */
|
2010-03-07 17:57:45 +00:00
|
|
|
if (! ui_prefs.sidebar_visible &&
|
2010-03-07 17:44:14 +00:00
|
|
|
gtk_container_get_focus_child(GTK_CONTAINER(main_widgets.sidebar_notebook)) != NULL)
|
2010-03-07 17:57:45 +00:00
|
|
|
{
|
2010-03-07 17:44:14 +00:00
|
|
|
keybindings_send_command(GEANY_KEY_GROUP_FOCUS, GEANY_KEYS_FOCUS_EDITOR);
|
2010-03-07 17:57:45 +00:00
|
|
|
}
|
2010-03-07 17:44:14 +00:00
|
|
|
|
2008-01-23 14:12:08 +00:00
|
|
|
ui_sidebar_show_hide();
|
2006-07-21 11:41:33 +00:00
|
|
|
}
|
2006-07-24 20:23:56 +00:00
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_menu_write_unicode_bom1_toggled(GtkCheckMenuItem *checkmenuitem, gpointer user_data)
|
2006-07-24 20:23:56 +00:00
|
|
|
{
|
2008-05-22 14:41:28 +00:00
|
|
|
if (! ignore_callback)
|
2006-07-24 20:23:56 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2006-07-24 20:23:56 +00:00
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
g_return_if_fail(doc != NULL);
|
|
|
|
if (doc->readonly)
|
2006-10-23 20:56:11 +00:00
|
|
|
{
|
|
|
|
utils_beep();
|
|
|
|
return;
|
|
|
|
}
|
2006-07-24 20:23:56 +00:00
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
document_undo_add(doc, UNDO_BOM, GINT_TO_POINTER(doc->has_bom));
|
2006-10-10 16:02:41 +00:00
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
doc->has_bom = ! doc->has_bom;
|
2006-07-24 20:23:56 +00:00
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
ui_update_statusbar(doc, -1);
|
2006-07-24 20:23:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-08-01 10:35:32 +00:00
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_menu_comment_line1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2006-08-01 10:35:32 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2009-04-15 22:47:33 +00:00
|
|
|
g_return_if_fail(doc != NULL);
|
|
|
|
|
2011-12-04 00:21:41 +01:00
|
|
|
editor_do_comment(doc->editor, -1, FALSE, FALSE, TRUE);
|
2006-08-01 10:35:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_menu_uncomment_line1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2006-08-01 10:35:32 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2009-04-15 22:47:33 +00:00
|
|
|
g_return_if_fail(doc != NULL);
|
|
|
|
|
|
|
|
editor_do_uncomment(doc->editor, -1, FALSE);
|
2006-08-01 10:35:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_menu_toggle_line_commentation1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2006-09-12 08:32:52 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2009-04-15 22:47:33 +00:00
|
|
|
g_return_if_fail(doc != NULL);
|
|
|
|
|
|
|
|
editor_do_comment_toggle(doc->editor);
|
2006-09-12 08:32:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_menu_increase_indent1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2006-08-01 10:35:32 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2009-04-15 22:47:33 +00:00
|
|
|
g_return_if_fail(doc != NULL);
|
2006-08-01 10:35:32 +00:00
|
|
|
|
2009-05-18 15:17:48 +00:00
|
|
|
editor_indent(doc->editor, TRUE);
|
2006-08-01 10:35:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_menu_decrease_indent1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2006-08-01 10:35:32 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2009-04-15 22:47:33 +00:00
|
|
|
g_return_if_fail(doc != NULL);
|
2006-08-01 10:35:32 +00:00
|
|
|
|
2009-05-18 15:17:48 +00:00
|
|
|
editor_indent(doc->editor, FALSE);
|
2006-08-01 10:35:32 +00:00
|
|
|
}
|
|
|
|
|
2006-12-08 15:50:10 +00:00
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_next_message1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2006-12-08 15:50:10 +00:00
|
|
|
{
|
|
|
|
if (! ui_tree_view_find_next(GTK_TREE_VIEW(msgwindow.tree_msg),
|
|
|
|
msgwin_goto_messages_file_line))
|
2007-10-24 10:52:48 +00:00
|
|
|
ui_set_statusbar(FALSE, _("No more message items."));
|
2006-12-08 15:50:10 +00:00
|
|
|
}
|
2006-12-13 00:46:14 +00:00
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_previous_message1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2008-06-25 17:38:31 +00:00
|
|
|
{
|
|
|
|
if (! ui_tree_view_find_previous(GTK_TREE_VIEW(msgwindow.tree_msg),
|
|
|
|
msgwin_goto_messages_file_line))
|
|
|
|
ui_set_statusbar(FALSE, _("No more message items."));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_project_new1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2007-01-15 18:12:32 +00:00
|
|
|
{
|
|
|
|
project_new();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_project_open1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2007-01-15 18:12:32 +00:00
|
|
|
{
|
|
|
|
project_open();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_project_close1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2007-01-15 18:12:32 +00:00
|
|
|
{
|
2007-11-18 18:24:23 +00:00
|
|
|
project_close(TRUE);
|
2007-01-15 18:12:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_project_properties1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2007-01-15 18:12:32 +00:00
|
|
|
{
|
|
|
|
project_properties();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_menu_project1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2007-01-15 18:12:32 +00:00
|
|
|
{
|
2007-01-18 22:20:30 +00:00
|
|
|
static GtkWidget *item_close = NULL;
|
|
|
|
static GtkWidget *item_properties = NULL;
|
2007-01-15 18:12:32 +00:00
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
if (item_close == NULL)
|
2007-01-15 18:12:32 +00:00
|
|
|
{
|
2008-12-18 21:21:53 +00:00
|
|
|
item_close = ui_lookup_widget(main_widgets.window, "project_close1");
|
|
|
|
item_properties = ui_lookup_widget(main_widgets.window, "project_properties1");
|
2007-01-15 18:12:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gtk_widget_set_sensitive(item_close, (app->project != NULL));
|
|
|
|
gtk_widget_set_sensitive(item_properties, (app->project != NULL));
|
2009-07-20 23:09:03 +00:00
|
|
|
gtk_widget_set_sensitive(ui_widgets.recent_projects_menuitem,
|
|
|
|
g_queue_get_length(ui_prefs.recent_projects_queue) > 0);
|
2007-01-15 18:12:32 +00:00
|
|
|
}
|
|
|
|
|
2007-01-24 19:20:12 +00:00
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_menu_open_selected_file1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2007-01-24 19:20:12 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2008-01-14 17:30:59 +00:00
|
|
|
gchar *sel = NULL;
|
2009-06-08 19:16:23 +00:00
|
|
|
const gchar *wc;
|
|
|
|
|
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
wc = GEANY_WORDCHARS "./-" "\\";
|
|
|
|
#else
|
|
|
|
wc = GEANY_WORDCHARS "./-";
|
|
|
|
#endif
|
2007-01-24 19:20:12 +00:00
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
g_return_if_fail(doc != NULL);
|
2007-01-24 19:20:12 +00:00
|
|
|
|
2009-06-08 19:16:23 +00:00
|
|
|
sel = editor_get_default_selection(doc->editor, TRUE, wc);
|
2012-01-25 16:26:16 +00:00
|
|
|
SETPTR(sel, utils_get_locale_from_utf8(sel));
|
2007-01-24 19:20:12 +00:00
|
|
|
|
2008-01-14 17:30:59 +00:00
|
|
|
if (sel != NULL)
|
2007-01-24 19:20:12 +00:00
|
|
|
{
|
2010-07-24 01:29:15 +02:00
|
|
|
gchar *filename = NULL;
|
2007-01-24 19:20:12 +00:00
|
|
|
|
2008-01-14 17:30:59 +00:00
|
|
|
if (g_path_is_absolute(sel))
|
|
|
|
filename = g_strdup(sel);
|
|
|
|
else
|
2008-02-27 13:17:29 +00:00
|
|
|
{ /* relative filename, add the path of the current file */
|
2007-01-24 19:20:12 +00:00
|
|
|
gchar *path;
|
|
|
|
|
2009-08-18 13:47:29 +00:00
|
|
|
path = utils_get_current_file_dir_utf8();
|
2012-01-25 16:26:16 +00:00
|
|
|
SETPTR(path, utils_get_locale_from_utf8(path));
|
2009-08-18 13:47:29 +00:00
|
|
|
if (!path)
|
|
|
|
path = g_get_current_dir();
|
|
|
|
|
2008-01-14 17:30:59 +00:00
|
|
|
filename = g_build_path(G_DIR_SEPARATOR_S, path, sel, NULL);
|
2007-01-24 19:20:12 +00:00
|
|
|
|
2008-01-14 17:30:59 +00:00
|
|
|
if (! g_file_test(filename, G_FILE_TEST_EXISTS) &&
|
2013-08-11 14:10:57 +01:00
|
|
|
app->project != NULL && !EMPTY(app->project->base_path))
|
2008-01-14 17:30:59 +00:00
|
|
|
{
|
2008-02-27 13:17:29 +00:00
|
|
|
/* try the project's base path */
|
2012-01-25 16:26:16 +00:00
|
|
|
SETPTR(path, project_get_base_path());
|
|
|
|
SETPTR(path, utils_get_locale_from_utf8(path));
|
|
|
|
SETPTR(filename, g_build_path(G_DIR_SEPARATOR_S, path, sel, NULL));
|
2008-01-14 17:30:59 +00:00
|
|
|
}
|
2007-01-24 19:20:12 +00:00
|
|
|
g_free(path);
|
2010-07-24 01:29:15 +02:00
|
|
|
#ifdef G_OS_UNIX
|
|
|
|
if (! g_file_test(filename, G_FILE_TEST_EXISTS))
|
2012-01-25 16:26:16 +00:00
|
|
|
SETPTR(filename, g_build_path(G_DIR_SEPARATOR_S, "/usr/local/include", sel, NULL));
|
2010-07-24 01:29:15 +02:00
|
|
|
|
|
|
|
if (! g_file_test(filename, G_FILE_TEST_EXISTS))
|
2012-01-25 16:26:16 +00:00
|
|
|
SETPTR(filename, g_build_path(G_DIR_SEPARATOR_S, "/usr/include", sel, NULL));
|
2010-07-24 01:29:15 +02:00
|
|
|
#endif
|
2007-01-24 19:20:12 +00:00
|
|
|
}
|
|
|
|
|
2010-07-24 01:29:15 +02:00
|
|
|
if (g_file_test(filename, G_FILE_TEST_EXISTS))
|
|
|
|
document_open_file(filename, FALSE, NULL, NULL);
|
|
|
|
else
|
|
|
|
{
|
2012-01-25 16:26:16 +00:00
|
|
|
SETPTR(sel, utils_get_utf8_from_locale(sel));
|
2010-07-24 01:29:15 +02:00
|
|
|
ui_set_statusbar(TRUE, _("Could not open file %s (File not found)"), sel);
|
|
|
|
}
|
2007-01-24 19:20:12 +00:00
|
|
|
|
|
|
|
g_free(filename);
|
2008-01-14 17:30:59 +00:00
|
|
|
g_free(sel);
|
2007-01-24 19:20:12 +00:00
|
|
|
}
|
|
|
|
}
|
2007-02-17 18:06:08 +00:00
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_remove_markers1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2007-02-17 18:06:08 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2009-04-15 22:47:33 +00:00
|
|
|
g_return_if_fail(doc != NULL);
|
2007-02-17 18:06:08 +00:00
|
|
|
|
2008-07-14 11:13:54 +00:00
|
|
|
sci_marker_delete_all(doc->editor->sci, 0); /* delete the yellow tag marker */
|
|
|
|
sci_marker_delete_all(doc->editor->sci, 1); /* delete user markers */
|
2008-11-16 17:54:28 +00:00
|
|
|
editor_indicator_clear(doc->editor, GEANY_INDICATOR_SEARCH);
|
2007-02-17 18:06:08 +00:00
|
|
|
}
|
|
|
|
|
2007-04-15 18:09:59 +00:00
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_load_tags1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2007-04-18 15:21:33 +00:00
|
|
|
{
|
|
|
|
symbols_show_load_tags_dialog();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_context_action1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2007-04-15 18:09:59 +00:00
|
|
|
{
|
|
|
|
gchar *word, *command;
|
|
|
|
GError *error = NULL;
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2007-04-15 18:09:59 +00:00
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
g_return_if_fail(doc != NULL);
|
2007-04-15 18:09:59 +00:00
|
|
|
|
2008-09-17 18:02:55 +00:00
|
|
|
if (sci_has_selection(doc->editor->sci))
|
2008-02-27 13:17:29 +00:00
|
|
|
{ /* take selected text if there is a selection */
|
2013-05-22 04:22:53 +02:00
|
|
|
word = sci_get_selection_contents(doc->editor->sci);
|
2007-04-15 18:09:59 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
word = g_strdup(editor_info.current_word);
|
|
|
|
}
|
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* use the filetype specific command if available, fallback to global command otherwise */
|
2008-06-15 13:35:48 +00:00
|
|
|
if (doc->file_type != NULL &&
|
2013-08-11 14:10:57 +01:00
|
|
|
!EMPTY(doc->file_type->context_action_cmd))
|
2007-04-15 18:09:59 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
command = g_strdup(doc->file_type->context_action_cmd);
|
2007-04-15 18:09:59 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-05-16 12:08:39 +00:00
|
|
|
command = g_strdup(tool_prefs.context_action_cmd);
|
2007-04-15 18:09:59 +00:00
|
|
|
}
|
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* substitute the wildcard %s and run the command if it is non empty */
|
2013-08-11 14:10:57 +01:00
|
|
|
if (G_LIKELY(!EMPTY(command)))
|
2007-04-15 18:09:59 +00:00
|
|
|
{
|
2009-07-23 16:01:45 +00:00
|
|
|
utils_str_replace_all(&command, "%s", word);
|
2007-04-15 18:09:59 +00:00
|
|
|
|
|
|
|
if (! g_spawn_command_line_async(command, &error))
|
|
|
|
{
|
2007-10-24 10:52:48 +00:00
|
|
|
ui_set_statusbar(TRUE, "Context action command failed: %s", error->message);
|
2007-04-15 18:09:59 +00:00
|
|
|
g_error_free(error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
g_free(word);
|
|
|
|
g_free(command);
|
|
|
|
}
|
|
|
|
|
2007-05-06 14:49:51 +00:00
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_menu_toggle_all_additional_widgets1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2007-05-06 14:49:51 +00:00
|
|
|
{
|
|
|
|
static gint hide_all = -1;
|
2008-02-27 13:17:29 +00:00
|
|
|
GtkCheckMenuItem *msgw = GTK_CHECK_MENU_ITEM(
|
2008-12-18 21:21:53 +00:00
|
|
|
ui_lookup_widget(main_widgets.window, "menu_show_messages_window1"));
|
2008-02-27 13:17:29 +00:00
|
|
|
GtkCheckMenuItem *toolbari = GTK_CHECK_MENU_ITEM(
|
2008-12-18 21:21:53 +00:00
|
|
|
ui_lookup_widget(main_widgets.window, "menu_show_toolbar1"));
|
2007-05-06 14:49:51 +00:00
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* get the initial state (necessary if Geany was closed with hide_all = TRUE) */
|
2009-04-05 21:07:40 +00:00
|
|
|
if (G_UNLIKELY(hide_all == -1))
|
2007-05-06 14:49:51 +00:00
|
|
|
{
|
|
|
|
if (! gtk_check_menu_item_get_active(msgw) &&
|
2008-05-16 12:08:39 +00:00
|
|
|
! interface_prefs.show_notebook_tabs &&
|
2007-05-06 14:49:51 +00:00
|
|
|
! gtk_check_menu_item_get_active(toolbari))
|
|
|
|
{
|
|
|
|
hide_all = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
hide_all = FALSE;
|
|
|
|
}
|
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
hide_all = ! hide_all; /* toggle */
|
2007-05-06 14:49:51 +00:00
|
|
|
|
|
|
|
if (hide_all)
|
|
|
|
{
|
|
|
|
if (gtk_check_menu_item_get_active(msgw))
|
|
|
|
gtk_check_menu_item_set_active(msgw, ! gtk_check_menu_item_get_active(msgw));
|
|
|
|
|
2008-05-16 12:08:39 +00:00
|
|
|
interface_prefs.show_notebook_tabs = FALSE;
|
2008-05-22 14:41:28 +00:00
|
|
|
gtk_notebook_set_show_tabs(GTK_NOTEBOOK(main_widgets.notebook), interface_prefs.show_notebook_tabs);
|
2007-05-06 14:49:51 +00:00
|
|
|
|
|
|
|
ui_statusbar_showhide(FALSE);
|
|
|
|
|
|
|
|
if (gtk_check_menu_item_get_active(toolbari))
|
|
|
|
gtk_check_menu_item_set_active(toolbari, ! gtk_check_menu_item_get_active(toolbari));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
|
|
|
|
if (! gtk_check_menu_item_get_active(msgw))
|
|
|
|
gtk_check_menu_item_set_active(msgw, ! gtk_check_menu_item_get_active(msgw));
|
|
|
|
|
2008-05-16 12:08:39 +00:00
|
|
|
interface_prefs.show_notebook_tabs = TRUE;
|
2008-05-22 14:41:28 +00:00
|
|
|
gtk_notebook_set_show_tabs(GTK_NOTEBOOK(main_widgets.notebook), interface_prefs.show_notebook_tabs);
|
2007-05-06 14:49:51 +00:00
|
|
|
|
|
|
|
ui_statusbar_showhide(TRUE);
|
|
|
|
|
|
|
|
if (! gtk_check_menu_item_get_active(toolbari))
|
|
|
|
gtk_check_menu_item_set_active(toolbari, ! gtk_check_menu_item_get_active(toolbari));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-05-25 14:42:43 +00:00
|
|
|
|
2014-06-24 18:04:11 +02:00
|
|
|
void on_toolbutton_forward_activate(GtkAction *menuitem, gpointer user_data)
|
2007-06-02 16:14:07 +00:00
|
|
|
{
|
|
|
|
navqueue_go_forward();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-06-24 18:04:11 +02:00
|
|
|
void on_toolbutton_back_activate(GtkAction *menuitem, gpointer user_data)
|
2007-06-02 16:14:07 +00:00
|
|
|
{
|
|
|
|
navqueue_go_back();
|
|
|
|
}
|
|
|
|
|
2007-06-11 08:58:37 +00:00
|
|
|
|
2014-06-24 16:44:10 +02:00
|
|
|
gboolean on_motion_event(GtkWidget *widget, GdkEventMotion *event, gpointer user_data)
|
2007-06-11 08:58:37 +00:00
|
|
|
{
|
2012-09-15 13:52:49 +02:00
|
|
|
if (prefs.auto_focus && ! gtk_widget_has_focus(widget))
|
2007-06-11 08:58:37 +00:00
|
|
|
gtk_widget_grab_focus(widget);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2007-10-17 12:27:07 +00:00
|
|
|
|
2009-04-17 15:30:01 +00:00
|
|
|
static void set_indent_type(GtkCheckMenuItem *menuitem, GeanyIndentType type)
|
2007-10-17 12:27:07 +00:00
|
|
|
{
|
2009-04-15 22:47:33 +00:00
|
|
|
GeanyDocument *doc;
|
2007-10-17 12:27:07 +00:00
|
|
|
|
2009-04-17 15:30:01 +00:00
|
|
|
if (ignore_callback || ! gtk_check_menu_item_get_active(menuitem))
|
2008-06-16 18:31:59 +00:00
|
|
|
return;
|
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
doc = document_get_current();
|
|
|
|
g_return_if_fail(doc != NULL);
|
|
|
|
|
2010-09-14 15:01:29 +00:00
|
|
|
editor_set_indent(doc->editor, type, doc->editor->indent_width);
|
2008-06-15 13:35:48 +00:00
|
|
|
ui_update_statusbar(doc, -1);
|
2007-10-17 12:27:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_tabs1_activate(GtkCheckMenuItem *menuitem, gpointer user_data)
|
2008-08-04 14:07:49 +00:00
|
|
|
{
|
2009-04-17 15:30:01 +00:00
|
|
|
set_indent_type(menuitem, GEANY_INDENT_TYPE_TABS);
|
2008-08-04 14:07:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_spaces1_activate(GtkCheckMenuItem *menuitem, gpointer user_data)
|
2007-10-17 12:27:07 +00:00
|
|
|
{
|
2009-04-17 15:30:01 +00:00
|
|
|
set_indent_type(menuitem, GEANY_INDENT_TYPE_SPACES);
|
2008-08-04 14:07:49 +00:00
|
|
|
}
|
2007-10-17 12:27:07 +00:00
|
|
|
|
2008-06-16 18:31:59 +00:00
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_tabs_and_spaces1_activate(GtkCheckMenuItem *menuitem, gpointer user_data)
|
2008-08-04 14:07:49 +00:00
|
|
|
{
|
2009-04-17 15:30:01 +00:00
|
|
|
set_indent_type(menuitem, GEANY_INDENT_TYPE_BOTH);
|
2007-10-17 12:27:07 +00:00
|
|
|
}
|
|
|
|
|
2007-11-06 13:24:39 +00:00
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_strip_trailing_spaces1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2007-11-06 13:24:39 +00:00
|
|
|
{
|
2008-09-25 18:28:37 +00:00
|
|
|
GeanyDocument *doc;
|
2007-11-06 13:24:39 +00:00
|
|
|
|
2008-09-25 18:28:37 +00:00
|
|
|
if (ignore_callback)
|
2008-06-16 18:31:59 +00:00
|
|
|
return;
|
|
|
|
|
2008-09-25 18:28:37 +00:00
|
|
|
doc = document_get_current();
|
2009-04-15 22:47:33 +00:00
|
|
|
g_return_if_fail(doc != NULL);
|
2008-09-25 18:28:37 +00:00
|
|
|
|
|
|
|
editor_strip_trailing_spaces(doc->editor);
|
2007-11-06 13:24:39 +00:00
|
|
|
}
|
|
|
|
|
2007-11-17 14:04:27 +00:00
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_page_setup1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2007-11-17 14:04:27 +00:00
|
|
|
{
|
|
|
|
printing_page_setup_gtk();
|
|
|
|
}
|
|
|
|
|
2007-11-20 18:15:46 +00:00
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT gboolean on_escape_key_press_event(GtkWidget *widget, GdkEventKey *event, gpointer user_data)
|
2008-04-16 11:34:34 +00:00
|
|
|
{
|
2009-04-21 20:51:53 +00:00
|
|
|
guint state = event->state & gtk_accelerator_get_default_mod_mask();
|
2008-12-07 19:11:13 +00:00
|
|
|
|
2008-04-16 11:34:34 +00:00
|
|
|
/* make pressing escape in the sidebar and toolbar focus the editor */
|
2008-12-07 19:11:13 +00:00
|
|
|
if (event->keyval == GDK_Escape && state == 0)
|
2008-04-16 11:34:34 +00:00
|
|
|
{
|
|
|
|
keybindings_send_command(GEANY_KEY_GROUP_FOCUS, GEANY_KEYS_FOCUS_EDITOR);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
2008-05-09 12:13:29 +00:00
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_line_breaking1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2008-05-09 12:13:29 +00:00
|
|
|
{
|
2008-05-16 14:17:54 +00:00
|
|
|
GeanyDocument *doc;
|
2008-05-09 12:13:29 +00:00
|
|
|
|
2008-05-22 14:41:28 +00:00
|
|
|
if (ignore_callback)
|
2008-05-09 12:13:29 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
doc = document_get_current();
|
2009-04-15 22:47:33 +00:00
|
|
|
g_return_if_fail(doc != NULL);
|
2008-05-09 12:13:29 +00:00
|
|
|
|
2008-07-08 16:30:37 +00:00
|
|
|
doc->editor->line_breaking = !doc->editor->line_breaking;
|
2008-05-09 12:13:29 +00:00
|
|
|
}
|
2008-06-19 14:34:53 +00:00
|
|
|
|
2009-09-16 14:13:38 +00:00
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_replace_spaces_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2008-06-19 14:34:53 +00:00
|
|
|
{
|
|
|
|
GeanyDocument *doc = document_get_current();
|
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
g_return_if_fail(doc != NULL);
|
|
|
|
|
|
|
|
editor_replace_spaces(doc->editor);
|
2008-06-19 14:34:53 +00:00
|
|
|
}
|
|
|
|
|
2008-06-25 17:38:31 +00:00
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_search1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2008-06-25 17:38:31 +00:00
|
|
|
{
|
2008-12-18 21:21:53 +00:00
|
|
|
GtkWidget *next_message = ui_lookup_widget(main_widgets.window, "next_message1");
|
|
|
|
GtkWidget *previous_message = ui_lookup_widget(main_widgets.window, "previous_message1");
|
2008-06-25 17:38:31 +00:00
|
|
|
gboolean have_messages;
|
|
|
|
|
|
|
|
/* enable commands if the messages window has any items */
|
|
|
|
have_messages = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(msgwindow.store_msg),
|
|
|
|
NULL) > 0;
|
|
|
|
|
|
|
|
gtk_widget_set_sensitive(next_message, have_messages);
|
|
|
|
gtk_widget_set_sensitive(previous_message, have_messages);
|
|
|
|
}
|
|
|
|
|
2008-06-27 17:30:14 +00:00
|
|
|
|
2011-11-20 16:05:39 +01:00
|
|
|
/* simple implementation (vs. close all which doesn't close documents if cancelled),
|
2014-05-26 16:21:16 +02:00
|
|
|
* if user_data is set, it is the GeanyDocument to keep */
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_close_other_documents1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2008-06-27 17:30:14 +00:00
|
|
|
{
|
|
|
|
guint i;
|
2014-05-26 16:21:16 +02:00
|
|
|
GeanyDocument *cur_doc = user_data;
|
2011-11-20 16:05:39 +01:00
|
|
|
|
2014-05-26 16:21:16 +02:00
|
|
|
if (cur_doc == NULL)
|
2011-11-20 16:05:39 +01:00
|
|
|
cur_doc = document_get_current();
|
|
|
|
|
2008-06-27 17:30:14 +00:00
|
|
|
for (i = 0; i < documents_array->len; i++)
|
|
|
|
{
|
2014-05-26 16:21:16 +02:00
|
|
|
GeanyDocument *doc = documents[i];
|
2008-06-27 17:30:14 +00:00
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
if (doc == cur_doc || ! doc->is_valid)
|
2008-06-27 17:30:14 +00:00
|
|
|
continue;
|
|
|
|
|
2008-07-01 14:20:16 +00:00
|
|
|
if (! document_close(doc))
|
2008-06-27 17:30:14 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-06-30 16:29:12 +00:00
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_menu_reload_configuration1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2008-06-30 16:29:12 +00:00
|
|
|
{
|
2008-07-23 11:46:02 +00:00
|
|
|
main_reload_configuration();
|
2008-06-30 16:29:12 +00:00
|
|
|
}
|
|
|
|
|
2008-08-07 11:49:06 +00:00
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_debug_messages1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2008-08-11 18:16:35 +00:00
|
|
|
{
|
|
|
|
log_show_debug_messages_dialog();
|
|
|
|
}
|
|
|
|
|
2009-02-25 23:28:01 +00:00
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_send_selection_to_vte1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2009-02-25 23:28:01 +00:00
|
|
|
{
|
|
|
|
#ifdef HAVE_VTE
|
2010-12-07 13:02:46 +00:00
|
|
|
if (vte_info.have_vte)
|
2009-02-25 23:28:01 +00:00
|
|
|
vte_send_selection_to_vte();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-09-16 14:13:38 +00:00
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT gboolean on_window_state_event(GtkWidget *widget, GdkEventWindowState *event, gpointer user_data)
|
2009-04-30 17:17:13 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
if (event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN)
|
|
|
|
{
|
|
|
|
static GtkWidget *menuitem = NULL;
|
|
|
|
|
|
|
|
if (menuitem == NULL)
|
|
|
|
menuitem = ui_lookup_widget(widget, "menu_fullscreen1");
|
|
|
|
|
|
|
|
ignore_callback = TRUE;
|
|
|
|
|
|
|
|
ui_prefs.fullscreen = (event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN) ? TRUE : FALSE;
|
|
|
|
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), ui_prefs.fullscreen);
|
|
|
|
|
|
|
|
ignore_callback = FALSE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2009-06-25 17:29:37 +00:00
|
|
|
|
2011-05-06 15:59:30 +00:00
|
|
|
static void show_notebook_page(const gchar *notebook_name, const gchar *page_name)
|
2009-06-25 17:29:37 +00:00
|
|
|
{
|
2010-04-11 21:56:23 +00:00
|
|
|
GtkWidget *widget;
|
|
|
|
GtkNotebook *notebook;
|
|
|
|
|
2011-05-06 15:59:30 +00:00
|
|
|
widget = ui_lookup_widget(ui_widgets.prefs_dialog, page_name);
|
|
|
|
notebook = GTK_NOTEBOOK(ui_lookup_widget(ui_widgets.prefs_dialog, notebook_name));
|
2010-04-11 21:56:23 +00:00
|
|
|
|
|
|
|
if (notebook != NULL && widget != NULL)
|
|
|
|
gtk_notebook_set_current_page(notebook, gtk_notebook_page_num(notebook, widget));
|
2009-06-25 17:29:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_customize_toolbar1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2011-05-06 15:59:30 +00:00
|
|
|
{
|
|
|
|
prefs_show_dialog();
|
|
|
|
|
|
|
|
/* select the Interface page */
|
|
|
|
show_notebook_page("notebook2", "notebook6");
|
|
|
|
/* select the Toolbar subpage */
|
|
|
|
show_notebook_page("notebook6", "vbox15");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_button_customize_toolbar_clicked(GtkButton *button, gpointer user_data)
|
2009-06-25 17:29:37 +00:00
|
|
|
{
|
2009-12-20 20:49:28 +00:00
|
|
|
toolbar_configure(GTK_WINDOW(ui_widgets.prefs_dialog));
|
2009-06-25 17:29:37 +00:00
|
|
|
}
|
|
|
|
|
2009-10-27 13:40:34 +00:00
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_cut_current_lines1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2009-10-27 13:40:34 +00:00
|
|
|
{
|
|
|
|
keybindings_send_command(GEANY_KEY_GROUP_CLIPBOARD, GEANY_KEYS_CLIPBOARD_CUTLINE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_copy_current_lines1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2009-10-27 13:40:34 +00:00
|
|
|
{
|
|
|
|
keybindings_send_command(GEANY_KEY_GROUP_CLIPBOARD, GEANY_KEYS_CLIPBOARD_COPYLINE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_delete_current_lines1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2009-10-27 13:40:34 +00:00
|
|
|
{
|
|
|
|
keybindings_send_command(GEANY_KEY_GROUP_EDITOR, GEANY_KEYS_EDITOR_DELETELINE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_duplicate_line_or_selection1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2009-10-27 13:40:34 +00:00
|
|
|
{
|
|
|
|
keybindings_send_command(GEANY_KEY_GROUP_EDITOR, GEANY_KEYS_EDITOR_DUPLICATELINE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_select_current_lines1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2009-10-27 13:40:34 +00:00
|
|
|
{
|
|
|
|
keybindings_send_command(GEANY_KEY_GROUP_SELECT, GEANY_KEYS_SELECT_LINE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_select_current_paragraph1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2009-10-27 13:40:34 +00:00
|
|
|
{
|
|
|
|
keybindings_send_command(GEANY_KEY_GROUP_SELECT, GEANY_KEYS_SELECT_PARAGRAPH);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_insert_alternative_white_space1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2009-10-27 13:40:34 +00:00
|
|
|
{
|
|
|
|
keybindings_send_command(GEANY_KEY_GROUP_INSERT, GEANY_KEYS_INSERT_ALTWHITESPACE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_go_to_next_marker1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2009-10-27 13:40:34 +00:00
|
|
|
{
|
|
|
|
keybindings_send_command(GEANY_KEY_GROUP_GOTO, GEANY_KEYS_GOTO_NEXTMARKER);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_go_to_previous_marker1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2009-10-27 13:40:34 +00:00
|
|
|
{
|
|
|
|
keybindings_send_command(GEANY_KEY_GROUP_GOTO, GEANY_KEYS_GOTO_PREVIOUSMARKER);
|
|
|
|
}
|
|
|
|
|
2009-10-28 11:33:11 +00:00
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_reflow_lines_block1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2009-10-28 11:33:11 +00:00
|
|
|
{
|
|
|
|
keybindings_send_command(GEANY_KEY_GROUP_FORMAT, GEANY_KEYS_FORMAT_REFLOWPARAGRAPH);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-11-23 16:18:50 +00:00
|
|
|
G_MODULE_EXPORT void on_move_lines_up1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2009-10-28 11:33:11 +00:00
|
|
|
{
|
2012-11-23 16:18:50 +00:00
|
|
|
keybindings_send_command(GEANY_KEY_GROUP_EDITOR, GEANY_KEYS_EDITOR_MOVELINEUP);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
G_MODULE_EXPORT void on_move_lines_down1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
|
|
|
{
|
|
|
|
keybindings_send_command(GEANY_KEY_GROUP_EDITOR, GEANY_KEYS_EDITOR_MOVELINEDOWN);
|
2009-10-28 11:33:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_smart_line_indent1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2009-10-28 11:33:11 +00:00
|
|
|
{
|
|
|
|
keybindings_send_command(GEANY_KEY_GROUP_FORMAT, GEANY_KEYS_FORMAT_AUTOINDENT);
|
|
|
|
}
|
|
|
|
|
2009-10-28 18:06:16 +00:00
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_plugin_preferences1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2009-10-28 18:06:16 +00:00
|
|
|
{
|
|
|
|
#ifdef HAVE_PLUGINS
|
|
|
|
plugin_show_configure(NULL);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2010-09-09 11:58:55 +00:00
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_indent_width_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2010-09-14 15:01:29 +00:00
|
|
|
{
|
|
|
|
GeanyDocument *doc;
|
2011-08-25 20:14:40 +00:00
|
|
|
gchar *label;
|
|
|
|
gint width;
|
2010-09-14 15:01:29 +00:00
|
|
|
|
|
|
|
if (ignore_callback)
|
|
|
|
return;
|
|
|
|
|
2011-08-25 20:14:40 +00:00
|
|
|
label = ui_menu_item_get_text(menuitem);
|
|
|
|
width = atoi(label);
|
2010-09-14 15:10:46 +00:00
|
|
|
g_free(label);
|
2011-08-25 20:14:40 +00:00
|
|
|
|
|
|
|
doc = document_get_current();
|
|
|
|
if (doc != NULL && width > 0)
|
|
|
|
editor_set_indent_width(doc->editor, width);
|
2010-09-14 15:01:29 +00:00
|
|
|
}
|
|
|
|
|
2010-11-08 18:15:14 +00:00
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_reset_indentation1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2010-11-08 18:15:14 +00:00
|
|
|
{
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
foreach_document(i)
|
|
|
|
document_apply_indent_settings(documents[i]);
|
|
|
|
|
|
|
|
ui_update_statusbar(NULL, -1);
|
|
|
|
ui_document_show_hide(NULL);
|
|
|
|
}
|
|
|
|
|
2010-11-23 12:50:24 +00:00
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_mark_all1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2010-11-23 12:50:24 +00:00
|
|
|
{
|
|
|
|
keybindings_send_command(GEANY_KEY_GROUP_SEARCH, GEANY_KEYS_SEARCH_MARKALL);
|
|
|
|
}
|
2011-08-25 20:15:02 +00:00
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_detect_type_from_file_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2011-08-25 20:15:02 +00:00
|
|
|
{
|
|
|
|
GeanyDocument *doc = document_get_current();
|
|
|
|
GeanyIndentType type;
|
|
|
|
|
|
|
|
if (doc != NULL && document_detect_indent_type(doc, &type))
|
|
|
|
{
|
|
|
|
editor_set_indent_type(doc->editor, type);
|
|
|
|
ui_document_show_hide(doc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-21 21:26:02 -07:00
|
|
|
G_MODULE_EXPORT void on_detect_width_from_file_activate(GtkMenuItem *menuitem, gpointer user_data)
|
2011-08-25 20:15:02 +00:00
|
|
|
{
|
|
|
|
GeanyDocument *doc = document_get_current();
|
|
|
|
gint width;
|
|
|
|
|
|
|
|
if (doc != NULL && document_detect_indent_width(doc, &width))
|
|
|
|
{
|
|
|
|
editor_set_indent_width(doc->editor, width);
|
|
|
|
ui_document_show_hide(doc);
|
|
|
|
}
|
|
|
|
}
|