2005-11-22 12:26:26 +00:00
|
|
|
/*
|
|
|
|
* callbacks.c - this file is part of Geany, a fast and lightweight IDE
|
|
|
|
*
|
2008-01-06 18:11:57 +00:00
|
|
|
* Copyright 2005-2008 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
|
|
|
|
* Copyright 2006-2008 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.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2006-05-10 19:54:44 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2005-11-22 12:26:26 +00:00
|
|
|
*
|
2005-11-27 20:54:28 +00:00
|
|
|
* $Id$
|
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
|
|
|
|
2005-12-29 20:01:18 +00:00
|
|
|
#include "geany.h"
|
|
|
|
|
2005-11-22 12:26:26 +00:00
|
|
|
#include <stdlib.h>
|
2006-04-27 18:06:35 +00:00
|
|
|
#include <unistd.h>
|
2005-12-29 20:01:18 +00:00
|
|
|
#include <string.h>
|
2005-11-22 12:26:26 +00:00
|
|
|
#include <gdk/gdkkeysyms.h>
|
2007-06-12 16:45:24 +00:00
|
|
|
#include <glib/gstdio.h>
|
2006-08-19 12:56:30 +00:00
|
|
|
#include <time.h>
|
2005-11-22 12:26:26 +00:00
|
|
|
|
|
|
|
#include "callbacks.h"
|
|
|
|
#include "interface.h"
|
|
|
|
#include "support.h"
|
|
|
|
|
|
|
|
#include "keyfile.h"
|
|
|
|
#include "document.h"
|
2008-06-02 15:31:59 +00:00
|
|
|
#include "documentprivate.h"
|
2007-08-15 15:37:21 +00:00
|
|
|
#include "filetypes.h"
|
2005-11-22 12:26:26 +00:00
|
|
|
#include "sciwrappers.h"
|
2007-05-28 16:07:30 +00:00
|
|
|
#include "editor.h"
|
2006-09-05 14:24:47 +00:00
|
|
|
#include "ui_utils.h"
|
2005-11-22 12:26:26 +00:00
|
|
|
#include "utils.h"
|
|
|
|
#include "dialogs.h"
|
2006-05-22 00:25:19 +00:00
|
|
|
#include "about.h"
|
2005-11-22 12:26:26 +00:00
|
|
|
#include "msgwindow.h"
|
|
|
|
#include "build.h"
|
|
|
|
#include "prefs.h"
|
|
|
|
#include "templates.h"
|
|
|
|
#include "treeviews.h"
|
2006-06-16 19:58:26 +00:00
|
|
|
#include "keybindings.h"
|
2006-06-19 18:31:17 +00:00
|
|
|
#include "encodings.h"
|
2006-07-13 14:30:44 +00:00
|
|
|
#include "search.h"
|
2006-10-21 11:34:18 +00:00
|
|
|
#include "main.h"
|
2006-11-08 11:42:05 +00:00
|
|
|
#include "symbols.h"
|
2006-12-13 00:46:14 +00:00
|
|
|
#include "tools.h"
|
2007-01-15 18:12:32 +00:00
|
|
|
#include "project.h"
|
2007-06-02 16:14:07 +00:00
|
|
|
#include "navqueue.h"
|
2007-11-17 14:04:27 +00:00
|
|
|
#include "printing.h"
|
2007-11-20 18:15:46 +00:00
|
|
|
#include "plugins.h"
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2007-08-23 15:22:13 +00:00
|
|
|
#include "geanyobject.h"
|
|
|
|
|
2006-06-19 18:31:17 +00:00
|
|
|
#ifdef HAVE_VTE
|
2005-11-27 20:54:28 +00:00
|
|
|
# include "vte.h"
|
|
|
|
#endif
|
|
|
|
|
2006-09-07 15:51:24 +00:00
|
|
|
#ifdef HAVE_SOCKET
|
|
|
|
# include "socket.h"
|
|
|
|
#endif
|
|
|
|
|
2005-11-27 20:54:28 +00:00
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* flag to indicate the explicit change of a toggle button of the toolbar menu and so the
|
|
|
|
* toggled callback should ignore the change since it is not triggered by the user */
|
2006-07-11 14:15:56 +00:00
|
|
|
static gboolean ignore_toolbar_toggle = FALSE;
|
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* flag to indicate that an insert callback was triggered from the file menu,
|
|
|
|
* so we need to store the current cursor position in editor_info.click_pos. */
|
2006-12-17 19:31:32 +00:00
|
|
|
static gboolean insert_callback_from_menu = FALSE;
|
|
|
|
|
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
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
CallbacksData callbacks_data = { NULL };
|
2007-03-13 17:00:12 +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
|
|
|
{
|
2008-06-18 14:18:26 +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
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* set editor_info.click_pos to the current cursor position if insert_callback_from_menu is TRUE
|
|
|
|
* to prevent invalid cursor positions which can cause segfaults */
|
2008-06-15 13:35:48 +00:00
|
|
|
static void verify_click_pos(GeanyDocument *doc)
|
2006-12-17 19:31:32 +00:00
|
|
|
{
|
|
|
|
if (insert_callback_from_menu)
|
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
editor_info.click_pos = sci_get_current_position(doc->sci);
|
2006-12-17 19:31:32 +00:00
|
|
|
insert_callback_from_menu = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-03 15:45:23 +00:00
|
|
|
/* should only be called from on_exit_clicked */
|
|
|
|
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
|
|
|
|
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 */
|
2006-11-07 11:24:22 +00:00
|
|
|
gboolean
|
|
|
|
on_exit_clicked (GtkWidget *widget, gpointer gdata)
|
|
|
|
{
|
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
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
|
|
|
on_new1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2007-09-03 16:09:53 +00:00
|
|
|
document_new_file(NULL, NULL, NULL);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_save1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2008-05-22 14:41:28 +00:00
|
|
|
gint cur_page = gtk_notebook_get_current_page(GTK_NOTEBOOK(main_widgets.notebook));
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
if (doc != NULL && cur_page >= 0)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
if (doc->file_name == NULL)
|
2005-11-22 12:26:26 +00:00
|
|
|
dialogs_show_save_as();
|
|
|
|
else
|
2008-06-15 13:35:48 +00:00
|
|
|
document_save_file(doc, FALSE);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_save_as1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
dialogs_show_save_as();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_save_all1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
gint i, max = gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_widgets.notebook));
|
|
|
|
GeanyDocument *doc, *cur_doc = document_get_current();
|
2007-08-24 11:19:26 +00:00
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
document_delay_colourise(); /* avoid recolourising all C files after each save */
|
2007-09-13 11:31:19 +00:00
|
|
|
|
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);
|
|
|
|
if (! doc->changed) continue;
|
|
|
|
if (doc->file_name == NULL)
|
2007-08-24 11:19:26 +00:00
|
|
|
{
|
2008-02-27 13:17:29 +00:00
|
|
|
/* display unnamed document */
|
2008-05-22 14:41:28 +00:00
|
|
|
gtk_notebook_set_current_page(GTK_NOTEBOOK(main_widgets.notebook),
|
2008-06-15 13:35:48 +00:00
|
|
|
document_get_notebook_page(doc));
|
2005-11-22 12:26:26 +00:00
|
|
|
dialogs_show_save_as();
|
2007-08-24 11:19:26 +00:00
|
|
|
}
|
2005-11-22 12:26:26 +00:00
|
|
|
else
|
2008-06-15 13:35:48 +00:00
|
|
|
document_save_file(doc, FALSE);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
2007-09-13 11:31:19 +00:00
|
|
|
document_colourise_new();
|
2008-06-15 13:35:48 +00:00
|
|
|
treeviews_update_tag_list(cur_doc, TRUE);
|
|
|
|
ui_set_window_title(cur_doc);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-13 17:33:51 +00:00
|
|
|
void
|
2005-11-22 12:26:26 +00:00
|
|
|
on_close_all1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2008-04-24 14:33:12 +00:00
|
|
|
document_close_all();
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_close1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2008-05-22 14:41:28 +00:00
|
|
|
guint cur_page = gtk_notebook_get_current_page(GTK_NOTEBOOK(main_widgets.notebook));
|
2008-06-15 13:35:48 +00:00
|
|
|
document_remove_page(cur_page);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_quit1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
on_exit_clicked(NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-05-25 14:42:43 +00:00
|
|
|
void
|
|
|
|
on_file1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
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);
|
2007-11-17 14:04:27 +00:00
|
|
|
#if GTK_CHECK_VERSION(2, 10, 0)
|
2008-02-27 13:17:29 +00:00
|
|
|
/* hide Page setup when GTK printing is not used
|
|
|
|
* (on GTK < 2.10 the menu item is hidden completely) */
|
2007-11-17 14:04:27 +00:00
|
|
|
ui_widget_show_hide(ui_widgets.print_page_setup,
|
|
|
|
printing_prefs.use_gtk_printing || gtk_check_version(2, 10, 0) != NULL);
|
|
|
|
#endif
|
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 */
|
2005-11-22 12:26:26 +00:00
|
|
|
void
|
|
|
|
on_edit1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
|
|
|
ui_update_menu_copy_items(doc);
|
|
|
|
ui_update_insert_include_item(doc, 1);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_undo1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
|
|
|
if (doc != NULL && document_can_undo(doc))
|
|
|
|
document_undo(doc);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_redo1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2008-06-18 13:36:33 +00:00
|
|
|
if (doc != NULL && document_can_redo(doc))
|
2008-06-15 13:35:48 +00:00
|
|
|
document_redo(doc);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_cut1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
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
|
2008-06-15 13:35:48 +00:00
|
|
|
if (IS_SCINTILLA(focusw) && doc != NULL)
|
|
|
|
sci_cut(doc->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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_copy1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
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
|
2008-06-18 13:36:33 +00:00
|
|
|
if (IS_SCINTILLA(focusw) && doc != NULL)
|
2008-06-15 13:35:48 +00:00
|
|
|
sci_copy(doc->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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_paste1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
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
|
2008-06-15 13:35:48 +00:00
|
|
|
if (IS_SCINTILLA(focusw) && doc != NULL)
|
2006-12-21 16:41:36 +00:00
|
|
|
{
|
2008-03-13 15:18:42 +00:00
|
|
|
#if 0
|
|
|
|
//#ifdef G_OS_WIN32
|
2008-02-27 13:17:29 +00:00
|
|
|
/* insert the text manually for now, because the auto conversion of EOL characters by
|
|
|
|
* by Scintilla seems to make problems */
|
|
|
|
/** TODO this is probably obsolete now since we fixed PLAT_GTK_WIN32 in Scintilla */
|
2006-12-21 16:41:36 +00:00
|
|
|
if (gtk_clipboard_wait_is_text_available(gtk_clipboard_get(GDK_NONE)))
|
|
|
|
{
|
|
|
|
gchar *content = gtk_clipboard_wait_for_text(gtk_clipboard_get(GDK_NONE));
|
|
|
|
if (content != NULL)
|
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
sci_replace_sel(doc->sci, content);
|
2006-12-21 16:41:36 +00:00
|
|
|
g_free(content);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
2008-06-15 13:35:48 +00:00
|
|
|
sci_paste(doc->sci);
|
2006-12-21 16:41:36 +00:00
|
|
|
#endif
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_delete1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
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
|
2008-06-15 13:35:48 +00:00
|
|
|
if (IS_SCINTILLA(focusw) && doc != NULL)
|
|
|
|
sci_clear(doc->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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_preferences1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
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 */
|
2005-11-22 12:26:26 +00:00
|
|
|
void
|
|
|
|
on_info1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
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 */
|
2005-11-22 12:26:26 +00:00
|
|
|
void
|
|
|
|
on_open1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
dialogs_show_open_file();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* quit toolbar button */
|
2005-11-22 12:26:26 +00:00
|
|
|
void
|
|
|
|
on_toolbutton19_clicked (GtkToolButton *toolbutton,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
on_exit_clicked(NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* reload file */
|
2005-11-22 12:26:26 +00:00
|
|
|
void
|
|
|
|
on_toolbutton23_clicked (GtkToolButton *toolbutton,
|
|
|
|
gpointer user_data)
|
2006-08-18 17:24:44 +00:00
|
|
|
{
|
|
|
|
on_reload_as_activate(NULL, GINT_TO_POINTER(-1));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* also used for reloading when user_data is -1 */
|
2006-08-18 17:24:44 +00:00
|
|
|
void
|
|
|
|
on_reload_as_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();
|
2007-07-17 08:10:29 +00:00
|
|
|
gchar *base_name;
|
2006-08-18 17:24:44 +00:00
|
|
|
gint i = GPOINTER_TO_INT(user_data);
|
|
|
|
gchar *charset = NULL;
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
if (doc == NULL || doc->file_name == NULL)
|
2006-08-18 17:24:44 +00:00
|
|
|
return;
|
|
|
|
if (i >= 0)
|
|
|
|
{
|
|
|
|
if (i >= GEANY_ENCODINGS_MAX || encodings[i].charset == NULL) return;
|
|
|
|
charset = encodings[i].charset;
|
|
|
|
}
|
2006-06-29 14:00:09 +00:00
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
base_name = g_path_get_basename(doc->file_name);
|
2007-07-04 17:08:53 +00:00
|
|
|
if (dialogs_show_question_full(NULL, _("_Reload"), GTK_STOCK_CANCEL,
|
2006-08-18 17:24:44 +00:00
|
|
|
_("Any unsaved changes will be lost."),
|
2007-07-17 08:10:29 +00:00
|
|
|
_("Are you sure you want to reload '%s'?"), base_name))
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
document_reload_file(doc, charset);
|
2006-08-18 17:24:44 +00:00
|
|
|
if (charset != NULL)
|
2008-06-15 13:35:48 +00:00
|
|
|
ui_update_statusbar(doc, -1);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
2007-07-17 08:10:29 +00:00
|
|
|
g_free(base_name);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_images_and_text2_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2006-07-11 14:15:56 +00:00
|
|
|
if (ignore_toolbar_toggle) return;
|
|
|
|
|
2008-05-22 14:41:28 +00:00
|
|
|
gtk_toolbar_set_style(GTK_TOOLBAR(main_widgets.toolbar), GTK_TOOLBAR_BOTH);
|
2008-05-16 12:08:39 +00:00
|
|
|
toolbar_prefs.icon_style = GTK_TOOLBAR_BOTH;
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_images_only2_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2006-07-11 14:15:56 +00:00
|
|
|
if (ignore_toolbar_toggle) return;
|
|
|
|
|
2008-05-22 14:41:28 +00:00
|
|
|
gtk_toolbar_set_style(GTK_TOOLBAR(main_widgets.toolbar), GTK_TOOLBAR_ICONS);
|
2008-05-16 12:08:39 +00:00
|
|
|
toolbar_prefs.icon_style = GTK_TOOLBAR_ICONS;
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_text_only2_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2006-07-11 14:15:56 +00:00
|
|
|
if (ignore_toolbar_toggle) return;
|
|
|
|
|
2008-05-22 14:41:28 +00:00
|
|
|
gtk_toolbar_set_style(GTK_TOOLBAR(main_widgets.toolbar), GTK_TOOLBAR_TEXT);
|
2008-05-16 12:08:39 +00:00
|
|
|
toolbar_prefs.icon_style = GTK_TOOLBAR_TEXT;
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_change_font1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
dialogs_show_open_font();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* new file */
|
2005-11-22 12:26:26 +00:00
|
|
|
void
|
|
|
|
on_toolbutton8_clicked (GtkToolButton *toolbutton,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2007-09-03 16:09:53 +00:00
|
|
|
document_new_file(NULL, NULL, NULL);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* open file */
|
2005-11-22 12:26:26 +00:00
|
|
|
void
|
|
|
|
on_toolbutton9_clicked (GtkToolButton *toolbutton,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
dialogs_show_open_file();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* save file */
|
2005-11-22 12:26:26 +00:00
|
|
|
void
|
|
|
|
on_toolbutton10_clicked (GtkToolButton *toolbutton,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
on_save1_activate(NULL, user_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-07-20 12:06:51 +00:00
|
|
|
static void set_search_bar_background(gboolean success)
|
2007-07-09 17:33:31 +00:00
|
|
|
{
|
|
|
|
const GdkColor red = {0, 0xffff, 0x6666, 0x6666};
|
|
|
|
const GdkColor white = {0, 0xffff, 0xffff, 0xffff};
|
|
|
|
static gboolean old_value = TRUE;
|
2008-05-22 14:41:28 +00:00
|
|
|
GtkWidget *widget = lookup_widget(main_widgets.window, "entry1");
|
2007-07-09 17:33:31 +00:00
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* only update if really needed */
|
2007-07-11 17:44:43 +00:00
|
|
|
if (search_data.search_bar && old_value != success)
|
2007-07-09 17:33:31 +00:00
|
|
|
{
|
|
|
|
gtk_widget_modify_base(widget, GTK_STATE_NORMAL, success ? NULL : &red);
|
|
|
|
gtk_widget_modify_text(widget, GTK_STATE_NORMAL, success ? NULL : &white);
|
|
|
|
|
|
|
|
old_value = success;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* store text, clear search flags so we can use Search->Find Next/Previous */
|
2006-08-01 11:33:42 +00:00
|
|
|
static void setup_find_next(GtkEditable *editable)
|
|
|
|
{
|
2006-08-11 21:12:49 +00:00
|
|
|
g_free(search_data.text);
|
2007-01-24 12:35:05 +00:00
|
|
|
search_data.text = gtk_editable_get_chars(editable, 0, -1);
|
2006-08-11 21:12:49 +00:00
|
|
|
search_data.flags = 0;
|
|
|
|
search_data.backwards = FALSE;
|
2007-07-11 17:44:43 +00:00
|
|
|
search_data.search_bar = TRUE;
|
2006-08-01 11:33:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* search text */
|
2005-11-22 12:26:26 +00:00
|
|
|
void
|
|
|
|
on_entry1_activate (GtkEntry *entry,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
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
|
|
|
|
2006-08-01 11:33:42 +00:00
|
|
|
setup_find_next(GTK_EDITABLE(entry));
|
2008-06-15 13:35:48 +00:00
|
|
|
result = document_search_bar_find(doc, search_data.text, 0, FALSE);
|
2007-07-20 12:06:51 +00:00
|
|
|
set_search_bar_background(result);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* search text */
|
2005-11-22 12:26:26 +00:00
|
|
|
void
|
|
|
|
on_entry1_changed (GtkEditable *editable,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
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
|
|
|
|
2006-08-01 11:33:42 +00:00
|
|
|
setup_find_next(editable);
|
2008-06-15 13:35:48 +00:00
|
|
|
result = document_search_bar_find(doc, search_data.text, 0, TRUE);
|
2007-07-20 12:06:51 +00:00
|
|
|
set_search_bar_background(result);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* search text */
|
2005-11-22 12:26:26 +00:00
|
|
|
void
|
|
|
|
on_toolbutton18_clicked (GtkToolButton *toolbutton,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2007-07-09 17:33:31 +00:00
|
|
|
gboolean result;
|
2008-05-22 14:41:28 +00:00
|
|
|
GtkWidget *entry = lookup_widget(GTK_WIDGET(main_widgets.window), "entry1");
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2006-08-01 11:33:42 +00:00
|
|
|
setup_find_next(GTK_EDITABLE(entry));
|
2008-06-15 13:35:48 +00:00
|
|
|
result = document_search_bar_find(doc, search_data.text, 0, FALSE);
|
2007-07-20 12:06:51 +00:00
|
|
|
set_search_bar_background(result);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_toolbar_large_icons1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2006-07-11 14:15:56 +00:00
|
|
|
if (ignore_toolbar_toggle) return;
|
|
|
|
|
2008-05-16 12:08:39 +00:00
|
|
|
toolbar_prefs.icon_size = GTK_ICON_SIZE_LARGE_TOOLBAR;
|
2006-09-05 14:24:47 +00:00
|
|
|
ui_update_toolbar_icons(GTK_ICON_SIZE_LARGE_TOOLBAR);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_toolbar_small_icons1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2006-07-11 14:15:56 +00:00
|
|
|
if (ignore_toolbar_toggle) return;
|
|
|
|
|
2008-05-16 12:08:39 +00:00
|
|
|
toolbar_prefs.icon_size = GTK_ICON_SIZE_SMALL_TOOLBAR;
|
2006-09-05 14:24:47 +00:00
|
|
|
ui_update_toolbar_icons(GTK_ICON_SIZE_SMALL_TOOLBAR);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* hides toolbar from toolbar popup menu */
|
2005-11-22 12:26:26 +00:00
|
|
|
void
|
|
|
|
on_hide_toolbar1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2008-05-22 14:41:28 +00:00
|
|
|
GtkWidget *tool_item = 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 */
|
2005-11-22 12:26:26 +00:00
|
|
|
void
|
|
|
|
on_zoom_in1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2005-11-22 12:26:26 +00:00
|
|
|
static gboolean done = 1;
|
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
if (doc != NULL)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
if (done++ % 3 == 0)
|
|
|
|
sci_set_line_numbers(doc->sci, editor_prefs.show_linenumber_margin,
|
|
|
|
(sci_get_zoom(doc->sci) / 2));
|
|
|
|
sci_zoom_in(doc->sci);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* zoom out from menu bar and popup menu */
|
2005-11-22 12:26:26 +00:00
|
|
|
void
|
|
|
|
on_zoom_out1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
|
|
|
if (doc != NULL)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
if (sci_get_zoom(doc->sci) == 0)
|
|
|
|
sci_set_line_numbers(doc->sci, editor_prefs.show_linenumber_margin, 0);
|
|
|
|
sci_zoom_out(doc->sci);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_normal_size1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
|
|
|
if (doc != NULL)
|
2006-02-06 06:25:01 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
sci_zoom_off(doc->sci);
|
|
|
|
sci_set_line_numbers(doc->sci, editor_prefs.show_linenumber_margin, 0);
|
2006-02-06 06:25:01 +00:00
|
|
|
}
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* close tab */
|
2005-11-22 12:26:26 +00:00
|
|
|
void
|
|
|
|
on_toolbutton15_clicked (GtkToolButton *toolbutton,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2008-05-22 14:41:28 +00:00
|
|
|
gint cur_page = gtk_notebook_get_current_page(GTK_NOTEBOOK(main_widgets.notebook));
|
2008-06-15 13:35:48 +00:00
|
|
|
document_remove_page(cur_page);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_notebook1_switch_page (GtkNotebook *notebook,
|
|
|
|
GtkNotebookPage *page,
|
|
|
|
guint page_num,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
callbacks_data.last_doc = document_get_current();
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* changes window-title on switching tabs and lots of other things */
|
2006-05-26 12:22:39 +00:00
|
|
|
void
|
|
|
|
on_notebook1_switch_page_after (GtkNotebook *notebook,
|
|
|
|
GtkNotebookPage *page,
|
|
|
|
guint page_num,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc;
|
2006-05-26 12:22:39 +00:00
|
|
|
|
2008-04-02 13:48:39 +00:00
|
|
|
if (main_status.opening_session_files || main_status.closing_all)
|
|
|
|
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
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
if (doc != NULL)
|
2006-05-26 12:22:39 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
treeviews_select_openfiles_item(doc);
|
|
|
|
document_set_text_changed(doc, doc->changed); /* also sets window title and status bar */
|
|
|
|
ui_update_popup_reundo_items(doc);
|
|
|
|
ui_document_show_hide(doc); /* update the document menu */
|
|
|
|
build_menu_update(doc);
|
|
|
|
treeviews_update_tag_list(doc, FALSE);
|
2007-03-14 12:03:15 +00:00
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
document_check_disk_status(doc, FALSE);
|
2006-06-29 23:51:32 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_VTE
|
2008-06-15 13:35:48 +00:00
|
|
|
vte_cwd(DOC_FILENAME(doc), FALSE);
|
2006-06-29 23:51:32 +00:00
|
|
|
#endif
|
2007-08-23 15:22:13 +00:00
|
|
|
|
|
|
|
if (geany_object)
|
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
g_signal_emit_by_name(geany_object, "document-activate", doc);
|
2007-08-23 15:22:13 +00:00
|
|
|
}
|
2006-08-19 15:07:11 +00:00
|
|
|
}
|
2006-05-26 12:22:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-11-22 12:26:26 +00:00
|
|
|
void
|
|
|
|
on_tv_notebook_switch_page (GtkNotebook *notebook,
|
|
|
|
GtkNotebookPage *page,
|
|
|
|
guint page_num,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_tv_notebook_switch_page_after (GtkNotebook *notebook,
|
|
|
|
GtkNotebookPage *page,
|
|
|
|
guint page_num,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2008-05-22 14:41:28 +00:00
|
|
|
ignore_callback = FALSE;
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_crlf_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
|
|
|
if (ignore_callback || doc == NULL) return;
|
|
|
|
sci_convert_eols(doc->sci, SC_EOL_CRLF);
|
|
|
|
sci_set_eol_mode(doc->sci, SC_EOL_CRLF);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_lf_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
|
|
|
if (ignore_callback || doc == NULL) return;
|
|
|
|
sci_convert_eols(doc->sci, SC_EOL_LF);
|
|
|
|
sci_set_eol_mode(doc->sci, SC_EOL_LF);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_cr_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
|
|
|
if (ignore_callback || doc == NULL) return;
|
|
|
|
sci_convert_eols(doc->sci, SC_EOL_CR);
|
|
|
|
sci_set_eol_mode(doc->sci, SC_EOL_CR);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_replace_tabs_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
editor_replace_tabs(doc);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
toolbar_popup_menu (GtkWidget *widget,
|
|
|
|
GdkEventButton *event,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
if (event->button == 3)
|
|
|
|
{
|
2007-03-09 13:52:26 +00:00
|
|
|
GtkWidget *w;
|
2006-07-11 14:15:56 +00:00
|
|
|
|
|
|
|
ignore_toolbar_toggle = TRUE;
|
|
|
|
|
2008-05-16 12:08:39 +00:00
|
|
|
switch (toolbar_prefs.icon_style)
|
2006-07-11 14:15:56 +00:00
|
|
|
{
|
2007-08-23 11:34:06 +00:00
|
|
|
case 0: w = lookup_widget(ui_widgets.toolbar_menu, "images_only2"); break;
|
|
|
|
case 1: w = lookup_widget(ui_widgets.toolbar_menu, "text_only2"); break;
|
|
|
|
default: w = lookup_widget(ui_widgets.toolbar_menu, "images_and_text2"); break;
|
2006-07-11 14:15:56 +00:00
|
|
|
}
|
2007-03-09 13:52:26 +00:00
|
|
|
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(w), TRUE);
|
2006-07-11 14:15:56 +00:00
|
|
|
|
2008-05-16 12:08:39 +00:00
|
|
|
switch (toolbar_prefs.icon_size)
|
2006-07-11 14:15:56 +00:00
|
|
|
{
|
|
|
|
case GTK_ICON_SIZE_LARGE_TOOLBAR:
|
2008-03-28 17:06:41 +00:00
|
|
|
w = lookup_widget(ui_widgets.toolbar_menu, "large_icons1"); break;
|
|
|
|
default: w = lookup_widget(ui_widgets.toolbar_menu, "small_icons1"); break;
|
2006-07-11 14:15:56 +00:00
|
|
|
}
|
2007-03-09 13:52:26 +00:00
|
|
|
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(w), TRUE);
|
2006-07-11 14:15:56 +00:00
|
|
|
|
|
|
|
ignore_toolbar_toggle = FALSE;
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-12 16:01:23 +00:00
|
|
|
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
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
if (doc == NULL)
|
2007-09-07 19:01:55 +00:00
|
|
|
return;
|
2006-09-12 08:32:52 +00:00
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
sci = doc->sci;
|
2007-09-12 16:01:23 +00:00
|
|
|
if (! sci_can_copy(sci))
|
|
|
|
{
|
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;
|
|
|
|
}
|
2008-06-15 13:35:48 +00:00
|
|
|
else
|
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;
|
2007-09-12 16:01:23 +00:00
|
|
|
gint text_len = sci_get_selected_text_length(sci);
|
2008-03-06 15:47:43 +00:00
|
|
|
gboolean rectsel = scintilla_send_message(sci, SCI_SELECTIONISRECTANGLE, 0, 0);
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2007-09-12 16:01:23 +00:00
|
|
|
text = g_malloc(text_len + 1);
|
|
|
|
sci_get_selected_text(sci, text);
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2007-09-07 19:01:55 +00:00
|
|
|
if (utils_str_has_upper(text))
|
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)
|
|
|
|
sci_set_selection_start(sci, sci_get_current_position(sci) - text_len + 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
sci_cmd(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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_show_toolbar1_toggled (GtkCheckMenuItem *checkmenuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_fullscreen1_toggled (GtkCheckMenuItem *checkmenuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_show_messages_window1_toggled (GtkCheckMenuItem *checkmenuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2008-05-22 14:41:28 +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;
|
2008-05-22 14:41:28 +00:00
|
|
|
ui_widget_show_hide(lookup_widget(main_widgets.window, "scrolledwindow1"), ui_prefs.msgwindow_visible);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_markers_margin1_toggled (GtkCheckMenuItem *checkmenuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2007-08-23 11:34:06 +00:00
|
|
|
editor_prefs.show_markers_margin = (editor_prefs.show_markers_margin) ? FALSE : TRUE;
|
2006-09-05 14:24:47 +00:00
|
|
|
ui_show_markers_margin();
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2006-02-14 22:07:55 +00:00
|
|
|
on_show_line_numbers1_toggled (GtkCheckMenuItem *checkmenuitem,
|
2005-11-22 12:26:26 +00:00
|
|
|
gpointer user_data)
|
|
|
|
{
|
2007-08-23 11:34:06 +00:00
|
|
|
editor_prefs.show_linenumber_margin = (editor_prefs.show_linenumber_margin) ? FALSE : TRUE;
|
2006-09-05 14:24:47 +00:00
|
|
|
ui_show_linenumber_margin();
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2008-05-09 14:17:25 +00:00
|
|
|
on_line_wrapping1_toggled (GtkCheckMenuItem *checkmenuitem,
|
2005-11-22 12:26:26 +00:00
|
|
|
gpointer user_data)
|
|
|
|
{
|
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();
|
2008-06-16 18:31:59 +00:00
|
|
|
if (doc != NULL)
|
|
|
|
editor_set_line_wrapping(doc, ! doc->line_wrapping);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-02-20 22:55:53 +00:00
|
|
|
void
|
|
|
|
on_set_file_readonly1_toggled (GtkCheckMenuItem *checkmenuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
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();
|
2008-06-16 18:31:59 +00:00
|
|
|
if (doc == NULL)
|
|
|
|
return;
|
2008-06-15 13:35:48 +00:00
|
|
|
doc->readonly = ! doc->readonly;
|
|
|
|
sci_set_readonly(doc->sci, doc->readonly);
|
|
|
|
ui_update_tab_status(doc);
|
|
|
|
ui_update_statusbar(doc, -1);
|
2006-02-20 22:55:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-11-22 12:26:26 +00:00
|
|
|
void
|
2007-06-12 15:16:17 +00:00
|
|
|
on_use_auto_indentation1_toggled (GtkCheckMenuItem *checkmenuitem,
|
2005-11-22 12:26:26 +00:00
|
|
|
gpointer user_data)
|
|
|
|
{
|
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();
|
2008-06-16 18:31:59 +00:00
|
|
|
if (doc != NULL)
|
|
|
|
doc->auto_indent = ! doc->auto_indent;
|
2006-02-14 22:07:55 +00:00
|
|
|
}
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_find_usage1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
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
|
|
|
|
2008-06-16 18:31:59 +00:00
|
|
|
if (doc == NULL)
|
|
|
|
return;
|
2006-11-01 15:26:41 +00:00
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
if (sci_can_copy(doc->sci))
|
2008-02-27 13:17:29 +00:00
|
|
|
{ /* take selected text if there is a selection */
|
2008-06-15 13:35:48 +00:00
|
|
|
search_text = g_malloc(sci_get_selected_text_length(doc->sci) + 1);
|
|
|
|
sci_get_selected_text(doc->sci, search_text);
|
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
|
|
|
{
|
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
|
|
|
|
2006-11-01 15:26:41 +00:00
|
|
|
search_find_usage(search_text, flags, TRUE);
|
2006-07-23 20:26:57 +00:00
|
|
|
g_free(search_text);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_goto_tag_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2007-09-25 12:39:41 +00:00
|
|
|
gboolean definition = (menuitem ==
|
2008-05-22 14:41:28 +00:00
|
|
|
GTK_MENU_ITEM(lookup_widget(main_widgets.editor_menu, "goto_tag_definition1")));
|
2008-05-16 14:17:54 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2008-06-16 18:31:59 +00:00
|
|
|
g_return_if_fail(doc != NULL);
|
2007-06-02 16:14:07 +00:00
|
|
|
|
2007-09-25 12:39:41 +00:00
|
|
|
sci_set_current_position(doc->sci, editor_info.click_pos, FALSE);
|
|
|
|
symbols_goto_tag(editor_info.current_word, definition);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_count_words1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2007-07-27 11:28:17 +00:00
|
|
|
tools_word_count();
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_show_color_chooser1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
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
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
if (doc == NULL)
|
2006-07-27 23:17:31 +00:00
|
|
|
return;
|
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
pos = sci_get_current_position(doc->sci);
|
|
|
|
editor_find_current_word(doc->sci, 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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_compile_button_clicked (GtkToolButton *toolbutton,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_find1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2006-08-11 21:12:49 +00:00
|
|
|
search_show_find_dialog();
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-22 13:30:16 +00:00
|
|
|
static void find_again(gboolean change_direction)
|
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
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
g_return_if_fail(doc != NULL);
|
2008-02-22 13:30:16 +00:00
|
|
|
|
2006-08-11 21:12:49 +00:00
|
|
|
if (search_data.text)
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2008-02-22 13:30:16 +00:00
|
|
|
gboolean forward = ! search_data.backwards;
|
2008-06-15 13:35:48 +00:00
|
|
|
gint result = document_find_text(doc, search_data.text, search_data.flags,
|
2008-02-22 13:30:16 +00:00
|
|
|
change_direction ? forward : !forward, FALSE, NULL);
|
|
|
|
|
|
|
|
if (result > -1)
|
2008-06-15 13:35:48 +00:00
|
|
|
editor_display_current_line(doc, 0.3F);
|
2007-07-20 12:06:51 +00:00
|
|
|
|
|
|
|
set_search_bar_background((result > -1) ? TRUE : FALSE);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-07-18 17:43:22 +00:00
|
|
|
void
|
2008-02-22 13:30:16 +00:00
|
|
|
on_find_next1_activate (GtkMenuItem *menuitem,
|
2006-07-18 17:43:22 +00:00
|
|
|
gpointer user_data)
|
|
|
|
{
|
2008-02-22 13:30:16 +00:00
|
|
|
find_again(FALSE);
|
|
|
|
}
|
2006-07-18 17:43:22 +00:00
|
|
|
|
|
|
|
|
2008-02-22 13:30:16 +00:00
|
|
|
void
|
|
|
|
on_find_previous1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
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
|
2008-02-22 13:30:16 +00:00
|
|
|
find_again(TRUE);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-01-23 17:51:30 +00:00
|
|
|
void
|
|
|
|
on_find_nextsel1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
search_find_selection(document_get_current(), FALSE);
|
2007-01-23 17:51:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_find_prevsel1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
search_find_selection(document_get_current(), TRUE);
|
2007-01-23 17:51:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-11-22 12:26:26 +00:00
|
|
|
void
|
2006-08-11 21:12:49 +00:00
|
|
|
on_replace1_activate (GtkMenuItem *menuitem,
|
2005-11-22 12:26:26 +00:00
|
|
|
gpointer user_data)
|
|
|
|
{
|
2006-08-11 21:12:49 +00:00
|
|
|
search_show_replace_dialog();
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-07-13 14:30:44 +00:00
|
|
|
void
|
|
|
|
on_find_in_files1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2007-12-02 10:52:19 +00:00
|
|
|
search_show_find_in_files_dialog(NULL);
|
2006-07-13 14:30:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-11-22 12:26:26 +00:00
|
|
|
void
|
2006-02-20 22:55:53 +00:00
|
|
|
on_toolbutton_new_clicked (GtkToolButton *toolbutton,
|
2005-11-22 12:26:26 +00:00
|
|
|
gpointer user_data)
|
|
|
|
{
|
2007-09-03 16:09:53 +00:00
|
|
|
document_new_file(NULL, NULL, NULL);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_go_to_line_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
dialogs_show_goto_line();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_goto_line_dialog_response (GtkDialog *dialog,
|
|
|
|
gint response,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
if (response == GTK_RESPONSE_ACCEPT)
|
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2005-11-22 12:26:26 +00:00
|
|
|
gint line = strtol(gtk_entry_get_text(GTK_ENTRY(user_data)), NULL, 10);
|
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
if (doc != NULL && line > 0 && line <= sci_get_line_count(doc->sci))
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
2008-05-22 14:41:28 +00:00
|
|
|
gint pos;
|
|
|
|
|
|
|
|
line--; /* the user counts lines from 1, we begin at 0 so bring the user line to our one */
|
2008-06-15 13:35:48 +00:00
|
|
|
pos = sci_get_position_from_line(doc->sci, line);
|
|
|
|
editor_goto_pos(doc, pos, TRUE);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-02-10 21:02:54 +00:00
|
|
|
utils_beep();
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
}
|
2008-05-22 14:41:28 +00:00
|
|
|
if (dialog)
|
|
|
|
gtk_widget_destroy(GTK_WIDGET(dialog));
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_goto_line_entry_activate (GtkEntry *entry,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
on_goto_line_dialog_response(GTK_DIALOG(user_data), GTK_RESPONSE_ACCEPT, entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-02-26 18:29:24 +00:00
|
|
|
void
|
|
|
|
on_entry_goto_line_activate (GtkEntry *entry,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
on_goto_line_dialog_response(NULL, GTK_RESPONSE_ACCEPT, entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_toolbutton_goto_clicked (GtkToolButton *toolbutton,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
on_goto_line_dialog_response(NULL, GTK_RESPONSE_ACCEPT,
|
2008-05-22 14:41:28 +00:00
|
|
|
lookup_widget(main_widgets.window, "entry_goto_line"));
|
2006-02-26 18:29:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-11-22 12:26:26 +00:00
|
|
|
void
|
|
|
|
on_help1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2007-06-10 20:09:22 +00:00
|
|
|
gint skip;
|
|
|
|
gchar *uri;
|
|
|
|
|
2006-07-26 17:02:16 +00:00
|
|
|
#ifdef G_OS_WIN32
|
2007-06-10 20:09:22 +00:00
|
|
|
skip = 8;
|
2007-09-11 18:18:09 +00:00
|
|
|
uri = g_strconcat("file:///", app->docdir, "/Manual.html", NULL);
|
2008-02-27 13:17:29 +00:00
|
|
|
g_strdelimit(uri, "\\", '/'); /* replace '\\' by '/' */
|
2005-11-22 12:26:26 +00:00
|
|
|
#else
|
2007-06-10 20:09:22 +00:00
|
|
|
skip = 7;
|
|
|
|
uri = g_strconcat("file://", app->docdir, "index.html", NULL);
|
2005-12-18 22:38:57 +00:00
|
|
|
#endif
|
2006-03-16 03:15:23 +00:00
|
|
|
|
2007-06-10 20:09:22 +00:00
|
|
|
if (! g_file_test(uri + skip, G_FILE_TEST_IS_REGULAR))
|
2008-02-27 13:17:29 +00:00
|
|
|
{ /* fall back to online documentation if it is not found on the hard disk */
|
2006-03-16 03:15:23 +00:00
|
|
|
g_free(uri);
|
2008-03-21 13:42:31 +00:00
|
|
|
uri = g_strconcat(GEANY_HOMEPAGE, "manual/", VERSION, "/index.html", NULL);
|
2006-03-16 03:15:23 +00:00
|
|
|
}
|
|
|
|
|
2005-12-18 22:38:57 +00:00
|
|
|
utils_start_browser(uri);
|
|
|
|
g_free(uri);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_help_shortcuts1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2007-03-23 16:34:54 +00:00
|
|
|
keybindings_show_shortcuts();
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_website1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
utils_start_browser(GEANY_HOMEPAGE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_comments_function_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
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;
|
|
|
|
|
2008-06-15 13:35:48 +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-02-27 13:17:29 +00:00
|
|
|
/* utils_get_current_function returns -1 on failure, so sci_get_position_from_line
|
|
|
|
* returns the current position, so it should be safe */
|
2008-06-15 13:35:48 +00:00
|
|
|
line = utils_get_current_function(doc, &cur_tag);
|
|
|
|
pos = sci_get_position_from_line(doc->sci, line - 1);
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
text = templates_get_template_function(doc->file_type->id, cur_tag);
|
2006-05-10 19:54:44 +00:00
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
sci_insert_text(doc->sci, pos, text);
|
2005-11-22 12:26:26 +00:00
|
|
|
g_free(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_comments_multiline_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2005-11-22 12:26:26 +00:00
|
|
|
|
2008-06-15 13:35:48 +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-06-15 13:35:48 +00:00
|
|
|
verify_click_pos(doc); /* make sure that the click_pos is valid */
|
2007-01-06 15:03:53 +00:00
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
editor_insert_multiline_comment(doc);
|
2007-01-06 15:03:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_comments_gpl_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2007-01-06 15:03:53 +00:00
|
|
|
gchar *text;
|
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
if (doc == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
text = templates_get_template_licence(FILETYPE_ID(doc->file_type), GEANY_TEMPLATE_GPL);
|
2006-05-10 19:54:44 +00:00
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
verify_click_pos(doc); /* make sure that the click_pos is valid */
|
2006-12-17 19:31:32 +00:00
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
sci_insert_text(doc->sci, editor_info.click_pos, text);
|
2005-11-22 12:26:26 +00:00
|
|
|
g_free(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2007-01-06 15:03:53 +00:00
|
|
|
on_comments_bsd_activate (GtkMenuItem *menuitem,
|
2005-11-22 12:26:26 +00:00
|
|
|
gpointer user_data)
|
|
|
|
{
|
2007-01-06 15:38:44 +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;
|
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
if (doc == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
text = templates_get_template_licence(FILETYPE_ID(doc->file_type), GEANY_TEMPLATE_BSD);
|
2006-05-10 19:54:44 +00:00
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
verify_click_pos(doc); /* make sure that the click_pos is valid */
|
2006-12-17 19:31:32 +00:00
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
sci_insert_text(doc->sci, editor_info.click_pos, text);
|
2005-11-22 12:26:26 +00:00
|
|
|
g_free(text);
|
2007-01-06 15:38:44 +00:00
|
|
|
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_comments_changelog_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2005-11-22 12:26:26 +00:00
|
|
|
gchar *text;
|
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
if (doc == NULL)
|
|
|
|
return;
|
|
|
|
|
2005-11-22 12:26:26 +00:00
|
|
|
text = templates_get_template_changelog();
|
2008-06-15 13:35:48 +00:00
|
|
|
sci_insert_text(doc->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-06-15 13:35:48 +00:00
|
|
|
sci_goto_pos(doc->sci, 21 + strlen(template_prefs.developer) + strlen(template_prefs.mail), TRUE);
|
2005-11-22 12:26:26 +00:00
|
|
|
|
|
|
|
g_free(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_comments_fileheader_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2005-11-22 12:26:26 +00:00
|
|
|
gchar *text;
|
2007-07-04 11:32:33 +00:00
|
|
|
gchar *fname;
|
2008-05-16 14:17:54 +00:00
|
|
|
GeanyFiletype *ft;
|
2006-05-22 15:28:48 +00:00
|
|
|
|
2008-06-15 13:35:48 +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
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
sci_insert_text(doc->sci, 0, text);
|
|
|
|
sci_goto_pos(doc->sci, 0, FALSE);
|
2005-11-22 12:26:26 +00:00
|
|
|
g_free(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-21 13:09:09 +00:00
|
|
|
static void
|
|
|
|
on_custom_date_input_response(const gchar *input)
|
2006-08-19 12:56:30 +00:00
|
|
|
{
|
2007-12-21 13:09:09 +00:00
|
|
|
setptr(ui_prefs.custom_date_format, g_strdup(input));
|
2006-08-19 12:56:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_insert_date_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2006-08-19 12:56:30 +00:00
|
|
|
gchar *format;
|
2008-02-27 13:17:29 +00:00
|
|
|
gchar time_str[300]; /* the entered format string can be maximal 256 chars long, so we have
|
|
|
|
* 44 additional characters for strtime's conversion */
|
2006-08-19 12:56:30 +00:00
|
|
|
time_t t;
|
|
|
|
struct tm *tm;
|
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
if (doc == NULL) return;
|
2006-08-19 12:56:30 +00:00
|
|
|
|
2006-12-07 16:09:45 +00:00
|
|
|
if (utils_str_equal(_("dd.mm.yyyy"), (gchar*) user_data))
|
2006-08-19 12:56:30 +00:00
|
|
|
format = "%d.%m.%Y";
|
2006-12-07 16:09:45 +00:00
|
|
|
else if (utils_str_equal(_("mm.dd.yyyy"), (gchar*) user_data))
|
2006-08-19 12:56:30 +00:00
|
|
|
format = "%m.%d.%Y";
|
2006-12-07 16:09:45 +00:00
|
|
|
else if (utils_str_equal(_("yyyy/mm/dd"), (gchar*) user_data))
|
2006-08-19 12:56:30 +00:00
|
|
|
format = "%Y/%m/%d";
|
2006-12-07 16:09:45 +00:00
|
|
|
else if (utils_str_equal(_("dd.mm.yyyy hh:mm:ss"), (gchar*) user_data))
|
2006-08-19 12:56:30 +00:00
|
|
|
format = "%d.%m.%Y %H:%M:%S";
|
2006-12-07 16:09:45 +00:00
|
|
|
else if (utils_str_equal(_("mm.dd.yyyy hh:mm:ss"), (gchar*) user_data))
|
2006-08-19 12:56:30 +00:00
|
|
|
format = "%m.%d.%Y %H:%M:%S";
|
2006-12-07 16:09:45 +00:00
|
|
|
else if (utils_str_equal(_("yyyy/mm/dd hh:mm:ss"), (gchar*) user_data))
|
2006-08-19 12:56:30 +00:00
|
|
|
format = "%Y/%m/%d %H:%M:%S";
|
2007-10-13 09:35:34 +00:00
|
|
|
else if (utils_str_equal(_("_Use Custom Date Format"), (gchar*) user_data))
|
2007-08-23 11:34:06 +00:00
|
|
|
format = ui_prefs.custom_date_format;
|
2006-08-19 12:56:30 +00:00
|
|
|
else
|
|
|
|
{
|
2008-02-27 13:17:29 +00:00
|
|
|
/* set default value */
|
2007-08-23 11:34:06 +00:00
|
|
|
if (utils_str_equal("", ui_prefs.custom_date_format))
|
2006-12-13 15:18:49 +00:00
|
|
|
{
|
2007-08-23 11:34:06 +00:00
|
|
|
g_free(ui_prefs.custom_date_format);
|
|
|
|
ui_prefs.custom_date_format = g_strdup("%d.%m.%Y");
|
2006-12-13 15:18:49 +00:00
|
|
|
}
|
2006-08-19 12:56:30 +00:00
|
|
|
|
2006-12-12 12:12:20 +00:00
|
|
|
dialogs_show_input(_("Custom Date Format"),
|
2007-09-09 16:13:30 +00:00
|
|
|
_("Enter here a custom date and time format. You can use any conversion specifiers which can be used with the ANSI C strftime function."),
|
2007-12-21 13:09:09 +00:00
|
|
|
ui_prefs.custom_date_format, FALSE, &on_custom_date_input_response);
|
2006-08-19 12:56:30 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* get the current time */
|
2006-08-19 12:56:30 +00:00
|
|
|
t = time(NULL);
|
|
|
|
tm = localtime(&t);
|
|
|
|
if (strftime(time_str, sizeof time_str, format, tm) != 0)
|
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
verify_click_pos(doc); /* make sure that the click_pos is valid */
|
2006-12-17 19:31:32 +00:00
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
sci_insert_text(doc->sci, editor_info.click_pos, time_str);
|
|
|
|
sci_goto_pos(doc->sci, editor_info.click_pos + strlen(time_str), FALSE);
|
2006-08-19 12:56:30 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
utils_beep();
|
2007-10-24 10:52:48 +00:00
|
|
|
ui_set_statusbar(TRUE,
|
2006-08-19 12:56:30 +00:00
|
|
|
_("Date format string could not be converted (possibly too long)."));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-11-22 12:26:26 +00:00
|
|
|
void
|
|
|
|
on_insert_include_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2006-12-17 19:31:32 +00:00
|
|
|
gint pos = -1;
|
2005-11-22 12:26:26 +00:00
|
|
|
gchar *text;
|
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
if (doc == NULL || user_data == NULL) return;
|
2006-12-17 19:31:32 +00:00
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
verify_click_pos(doc); /* make sure that the click_pos is valid */
|
2006-12-17 19:31:32 +00:00
|
|
|
|
2006-12-07 16:09:45 +00:00
|
|
|
if (utils_str_equal(user_data, "blank"))
|
2005-11-22 12:26:26 +00:00
|
|
|
{
|
|
|
|
text = g_strdup("#include \"\"\n");
|
2006-09-04 15:57:46 +00:00
|
|
|
pos = editor_info.click_pos + 10;
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
text = g_strconcat("#include <", user_data, ">\n", NULL);
|
|
|
|
}
|
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
sci_insert_text(doc->sci, editor_info.click_pos, text);
|
2005-11-22 12:26:26 +00:00
|
|
|
g_free(text);
|
2006-12-17 19:31:32 +00:00
|
|
|
if (pos >= 0)
|
2008-06-15 13:35:48 +00:00
|
|
|
sci_goto_pos(doc->sci, pos, FALSE);
|
2005-11-22 12:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-02-14 22:07:55 +00:00
|
|
|
void
|
|
|
|
on_file_properties_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
|
|
|
dialogs_show_file_properties(doc);
|
2006-02-14 22:07:55 +00:00
|
|
|
}
|
|
|
|
|
2006-02-20 22:55:53 +00:00
|
|
|
|
2006-02-26 18:29:24 +00:00
|
|
|
void
|
|
|
|
on_menu_fold_all1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
|
|
|
editor_fold_all(doc);
|
2006-02-26 18:29:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_menu_unfold_all1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
|
|
|
editor_unfold_all(doc);
|
2006-02-26 18:29:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-04-27 18:06:35 +00:00
|
|
|
void
|
|
|
|
on_run_button_clicked (GtkToolButton *toolbutton,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
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
|
|
|
|
|
|
|
void
|
|
|
|
on_go_to_line1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2008-02-27 13:17:29 +00:00
|
|
|
/* this is search menu cb; call popup menu goto cb */
|
2006-05-23 19:31:09 +00:00
|
|
|
on_go_to_line_activate(menuitem, user_data);
|
|
|
|
}
|
|
|
|
|
2006-06-13 20:03:44 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
on_menu_remove_indicators1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2007-02-17 18:06:08 +00:00
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
if (doc != NULL)
|
|
|
|
editor_clear_indicators(doc);
|
2006-06-13 20:03:44 +00:00
|
|
|
}
|
|
|
|
|
2006-06-19 18:31:17 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
on_encoding_change (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2006-06-19 18:31:17 +00:00
|
|
|
guint i = GPOINTER_TO_INT(user_data);
|
2006-06-29 14:00:09 +00:00
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
if (ignore_callback || doc == NULL || encodings[i].charset == NULL ||
|
|
|
|
utils_str_equal(encodings[i].charset, doc->encoding))
|
|
|
|
return;
|
2006-06-19 18:31:17 +00:00
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
if (doc->readonly)
|
2006-10-23 20:56:11 +00:00
|
|
|
{
|
|
|
|
utils_beep();
|
|
|
|
return;
|
|
|
|
}
|
2008-06-15 13:35:48 +00:00
|
|
|
document_undo_add(doc, UNDO_ENCODING, g_strdup(doc->encoding));
|
2006-10-10 16:02:41 +00:00
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
document_set_encoding(doc, encodings[i].charset);
|
2006-06-19 18:31:17 +00:00
|
|
|
}
|
|
|
|
|
2006-06-29 17:14:52 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
on_print1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
|
|
|
if (doc != NULL)
|
|
|
|
printing_print_doc(doc);
|
2006-06-29 17:14:52 +00:00
|
|
|
}
|
2006-06-30 13:42:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_menu_select_all1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2006-06-30 13:42:53 +00:00
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
if (doc != NULL)
|
|
|
|
sci_select_all(doc->sci);
|
2006-06-30 13:42:53 +00:00
|
|
|
}
|
|
|
|
|
2006-07-11 14:15:56 +00:00
|
|
|
|
2006-07-21 11:41:33 +00:00
|
|
|
void
|
|
|
|
on_menu_show_sidebar1_toggled (GtkCheckMenuItem *checkmenuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2007-05-06 14:49:51 +00:00
|
|
|
static gint active_page = -1;
|
|
|
|
|
2008-05-22 14:41:28 +00:00
|
|
|
if (ignore_callback) return;
|
2006-07-21 11:41:33 +00:00
|
|
|
|
2007-08-23 11:34:06 +00:00
|
|
|
if (ui_prefs.sidebar_visible)
|
2007-05-06 14:49:51 +00:00
|
|
|
{
|
2008-02-27 13:17:29 +00:00
|
|
|
/* to remember the active page because GTK (e.g. 2.8.18) doesn't do it and shows always
|
|
|
|
* the last page (for unknown reason, with GTK 2.6.4 it works) */
|
2008-05-22 14:41:28 +00:00
|
|
|
active_page = gtk_notebook_get_current_page(GTK_NOTEBOOK(main_widgets.sidebar_notebook));
|
2007-05-06 14:49:51 +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
|
|
|
|
2008-05-16 12:08:39 +00:00
|
|
|
if ((! interface_prefs.sidebar_openfiles_visible && ! interface_prefs.sidebar_symbol_visible))
|
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
|
|
|
|
2008-01-23 14:12:08 +00:00
|
|
|
ui_sidebar_show_hide();
|
2008-05-22 14:41:28 +00:00
|
|
|
gtk_notebook_set_current_page(GTK_NOTEBOOK(main_widgets.sidebar_notebook), active_page);
|
2006-07-21 11:41:33 +00:00
|
|
|
}
|
2006-07-24 20:23:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_menu_write_unicode_bom1_toggled (GtkCheckMenuItem *checkmenuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
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
|
|
|
|
2008-06-16 18:31:59 +00:00
|
|
|
if (doc == NULL)
|
|
|
|
return;
|
2008-06-15 13:35:48 +00:00
|
|
|
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
|
|
|
|
|
|
|
void
|
|
|
|
on_menu_comment_line1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
|
|
|
if (doc != NULL)
|
|
|
|
editor_do_comment(doc, -1, FALSE, FALSE);
|
2006-08-01 10:35:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_menu_uncomment_line1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
|
|
|
if (doc != NULL)
|
|
|
|
editor_do_uncomment(doc, -1, FALSE);
|
2006-08-01 10:35:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-09-12 08:32:52 +00:00
|
|
|
void
|
|
|
|
on_menu_toggle_line_commentation1_activate
|
|
|
|
(GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
|
|
|
if (doc != NULL)
|
|
|
|
editor_do_comment_toggle(doc);
|
2006-09-12 08:32:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-01 10:35:32 +00:00
|
|
|
void
|
|
|
|
on_menu_duplicate_line1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2008-03-12 13:37:39 +00:00
|
|
|
keybindings_send_command(GEANY_KEY_GROUP_EDITOR, GEANY_KEYS_EDITOR_DUPLICATELINE);
|
2006-08-01 10:35:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_menu_increase_indent1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
|
|
|
if (doc == NULL)
|
|
|
|
return;
|
2006-08-01 10:35:32 +00:00
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
if (sci_get_lines_selected(doc->sci) > 1)
|
2006-08-15 08:51:48 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
sci_cmd(doc->sci, SCI_TAB);
|
2006-08-15 08:51:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-05-08 16:03:07 +00:00
|
|
|
gint line, ind_pos, old_pos, new_pos, step;
|
2006-08-15 08:51:48 +00:00
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
old_pos = sci_get_current_position(doc->sci);
|
|
|
|
line = sci_get_line_from_position(doc->sci, old_pos);
|
|
|
|
ind_pos = sci_get_line_indent_position(doc->sci, line);
|
2008-02-27 13:17:29 +00:00
|
|
|
/* when using tabs increase cur pos by 1, when using space increase it by tab_width */
|
2008-06-15 13:35:48 +00:00
|
|
|
step = (doc->use_tabs) ? 1 : editor_prefs.tab_width;
|
2007-05-08 16:03:07 +00:00
|
|
|
new_pos = (old_pos > ind_pos) ? old_pos + step : old_pos;
|
2006-08-01 10:35:32 +00:00
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
sci_set_current_position(doc->sci, ind_pos, TRUE);
|
|
|
|
sci_cmd(doc->sci, SCI_TAB);
|
|
|
|
sci_set_current_position(doc->sci, new_pos, TRUE);
|
2006-08-15 08:51:48 +00:00
|
|
|
}
|
2006-08-01 10:35:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_menu_decrease_indent1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
|
|
|
if (doc == NULL)
|
|
|
|
return;
|
2006-08-01 10:35:32 +00:00
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
if (sci_get_lines_selected(doc->sci) > 1)
|
2006-08-15 08:51:48 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
sci_cmd(doc->sci, SCI_BACKTAB);
|
2006-08-15 08:51:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-05-08 16:03:07 +00:00
|
|
|
gint line, ind_pos, old_pos, new_pos, step, indent;
|
2006-08-15 08:51:48 +00:00
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
old_pos = sci_get_current_position(doc->sci);
|
|
|
|
line = sci_get_line_from_position(doc->sci, old_pos);
|
|
|
|
ind_pos = sci_get_line_indent_position(doc->sci, line);
|
|
|
|
step = (doc->use_tabs) ? 1 : editor_prefs.tab_width;
|
2007-05-08 16:03:07 +00:00
|
|
|
new_pos = (old_pos >= ind_pos) ? old_pos - step : old_pos;
|
2006-08-01 10:35:32 +00:00
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
if (ind_pos == sci_get_position_from_line(doc->sci, line))
|
2006-12-11 12:26:10 +00:00
|
|
|
return;
|
2007-05-08 16:03:07 +00:00
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
sci_set_current_position(doc->sci, ind_pos, TRUE);
|
|
|
|
indent = sci_get_line_indentation(doc->sci, line);
|
2007-05-29 16:30:54 +00:00
|
|
|
indent -= editor_prefs.tab_width;
|
2007-05-08 16:03:07 +00:00
|
|
|
if (indent < 0)
|
|
|
|
indent = 0;
|
2008-06-15 13:35:48 +00:00
|
|
|
sci_set_line_indentation(doc->sci, line, indent);
|
2007-05-08 16:03:07 +00:00
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
sci_set_current_position(doc->sci, new_pos, TRUE);
|
2006-08-15 08:51:48 +00:00
|
|
|
}
|
2006-08-01 10:35:32 +00:00
|
|
|
}
|
|
|
|
|
2006-12-08 15:50:10 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
on_next_message1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
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
|
|
|
|
|
|
|
|
2006-12-17 19:31:32 +00:00
|
|
|
void
|
|
|
|
on_menu_comments_multiline_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
insert_callback_from_menu = TRUE;
|
|
|
|
on_comments_multiline_activate(menuitem, user_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_menu_comments_gpl_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
insert_callback_from_menu = TRUE;
|
|
|
|
on_comments_gpl_activate(menuitem, user_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-01-06 15:03:53 +00:00
|
|
|
void
|
|
|
|
on_menu_comments_bsd_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
insert_callback_from_menu = TRUE;
|
|
|
|
on_comments_bsd_activate(menuitem, user_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-12-17 19:31:32 +00:00
|
|
|
void
|
|
|
|
on_menu_insert_include_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
insert_callback_from_menu = TRUE;
|
|
|
|
on_insert_include_activate(menuitem, user_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_menu_insert_date_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
insert_callback_from_menu = TRUE;
|
|
|
|
on_insert_date_activate(menuitem, user_data);
|
|
|
|
}
|
2007-01-06 15:03:53 +00:00
|
|
|
|
|
|
|
|
2007-01-15 18:12:32 +00:00
|
|
|
void
|
|
|
|
on_project_new1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
project_new();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_project_open1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
project_open();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_project_close1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2007-11-18 18:24:23 +00:00
|
|
|
project_close(TRUE);
|
2007-01-15 18:12:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_project_properties1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
project_properties();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_menu_project1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
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
|
|
|
|
|
|
|
if (item_close == NULL)
|
|
|
|
{
|
2008-05-22 14:41:28 +00:00
|
|
|
item_close = lookup_widget(main_widgets.window, "project_close1");
|
|
|
|
item_properties = 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));
|
|
|
|
}
|
|
|
|
|
2007-01-24 19:20:12 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
on_menu_open_selected_file1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2008-01-14 17:30:59 +00:00
|
|
|
gchar *sel = NULL;
|
2007-01-24 19:20:12 +00:00
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
if (doc == NULL)
|
|
|
|
return;
|
2007-01-24 19:20:12 +00:00
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
sel = editor_get_default_selection(doc, TRUE, GEANY_WORDCHARS"./");
|
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
|
|
|
{
|
2008-01-14 17:30:59 +00:00
|
|
|
gchar *locale_filename, *filename;
|
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;
|
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
path = g_path_get_dirname(doc->file_name);
|
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) &&
|
|
|
|
app->project != NULL && NZV(app->project->base_path))
|
|
|
|
{
|
2008-02-27 13:17:29 +00:00
|
|
|
/* try the project's base path */
|
2008-01-14 17:30:59 +00:00
|
|
|
setptr(path, project_get_base_path());
|
|
|
|
setptr(filename, g_build_path(G_DIR_SEPARATOR_S, path, sel, NULL));
|
|
|
|
}
|
2007-01-24 19:20:12 +00:00
|
|
|
g_free(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
locale_filename = utils_get_locale_from_utf8(filename);
|
2007-09-11 15:21:11 +00:00
|
|
|
document_open_file(locale_filename, FALSE, NULL, NULL);
|
2007-01-24 19:20:12 +00:00
|
|
|
|
|
|
|
g_free(filename);
|
|
|
|
g_free(locale_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
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_remove_markers1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2007-02-17 18:06:08 +00:00
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
if (doc == NULL)
|
2007-02-17 18:06:08 +00:00
|
|
|
return;
|
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
sci_marker_delete_all(doc->sci, 0); /* delete the yellow tag marker */
|
|
|
|
sci_marker_delete_all(doc->sci, 1); /* delete user markers */
|
2007-02-17 18:06:08 +00:00
|
|
|
}
|
|
|
|
|
2007-04-15 18:09:59 +00:00
|
|
|
|
2007-04-18 15:21:33 +00:00
|
|
|
void
|
|
|
|
on_load_tags1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
symbols_show_load_tags_dialog();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-15 18:09:59 +00:00
|
|
|
void
|
|
|
|
on_context_action1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
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
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
if (doc == NULL)
|
|
|
|
return;
|
2007-04-15 18:09:59 +00:00
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
if (sci_can_copy(doc->sci))
|
2008-02-27 13:17:29 +00:00
|
|
|
{ /* take selected text if there is a selection */
|
2008-06-15 13:35:48 +00:00
|
|
|
word = g_malloc(sci_get_selected_text_length(doc->sci) + 1);
|
|
|
|
sci_get_selected_text(doc->sci, word);
|
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 &&
|
2008-06-18 13:36:33 +00:00
|
|
|
NZV(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 */
|
2007-04-15 18:09:59 +00:00
|
|
|
if (command != NULL && *command != '\0')
|
|
|
|
{
|
|
|
|
command = utils_str_replace(command, "%s", word);
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
void
|
|
|
|
on_menu_toggle_all_additional_widgets1_activate
|
|
|
|
(GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
static gint hide_all = -1;
|
2008-02-27 13:17:29 +00:00
|
|
|
GtkCheckMenuItem *msgw = GTK_CHECK_MENU_ITEM(
|
2008-05-22 14:41:28 +00:00
|
|
|
lookup_widget(main_widgets.window, "menu_show_messages_window1"));
|
2008-02-27 13:17:29 +00:00
|
|
|
GtkCheckMenuItem *toolbari = GTK_CHECK_MENU_ITEM(
|
2008-05-22 14:41:28 +00:00
|
|
|
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) */
|
2007-05-06 14:49:51 +00:00
|
|
|
if (hide_all == -1)
|
|
|
|
{
|
|
|
|
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
|
|
|
|
2007-06-02 16:14:07 +00:00
|
|
|
void
|
|
|
|
on_forward_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
navqueue_go_forward();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_back_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
navqueue_go_back();
|
|
|
|
}
|
|
|
|
|
2007-06-11 08:58:37 +00:00
|
|
|
|
|
|
|
gboolean on_motion_event(GtkWidget *widget, GdkEventMotion *event, gpointer user_data)
|
|
|
|
{
|
2007-08-23 11:34:06 +00: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
|
|
|
|
|
|
|
void
|
|
|
|
on_tabs1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2007-10-17 12:27:07 +00:00
|
|
|
|
2008-06-16 18:31:59 +00:00
|
|
|
if (doc == NULL || ignore_callback)
|
|
|
|
return;
|
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
editor_set_use_tabs(doc, TRUE);
|
|
|
|
ui_update_statusbar(doc, -1);
|
2007-10-17 12:27:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_spaces1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2007-10-17 12:27:07 +00:00
|
|
|
|
2008-06-16 18:31:59 +00:00
|
|
|
if (doc == NULL || ignore_callback)
|
|
|
|
return;
|
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
editor_set_use_tabs(doc, FALSE);
|
|
|
|
ui_update_statusbar(doc, -1);
|
2007-10-17 12:27:07 +00:00
|
|
|
}
|
|
|
|
|
2007-11-06 13:24:39 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
on_strip_trailing_spaces1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
2007-11-06 13:24:39 +00:00
|
|
|
|
2008-06-16 18:31:59 +00:00
|
|
|
if (doc == NULL || ignore_callback)
|
|
|
|
return;
|
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
editor_strip_trailing_spaces(doc);
|
2007-11-06 13:24:39 +00:00
|
|
|
}
|
|
|
|
|
2007-11-17 14:04:27 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
on_page_setup1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
#if GTK_CHECK_VERSION(2, 10, 0)
|
|
|
|
printing_page_setup_gtk();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2007-11-20 18:15:46 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
on_tools1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_PLUGINS
|
|
|
|
plugins_update_tools_menu();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2008-04-16 11:34:34 +00:00
|
|
|
|
|
|
|
gboolean
|
|
|
|
on_escape_key_press_event (GtkWidget *widget,
|
|
|
|
GdkEventKey *event,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
/* make pressing escape in the sidebar and toolbar focus the editor */
|
|
|
|
if (event->keyval == GDK_Escape && event->state == 0)
|
|
|
|
{
|
|
|
|
keybindings_send_command(GEANY_KEY_GROUP_FOCUS, GEANY_KEYS_FOCUS_EDITOR);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
2008-05-09 12:13:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
on_line_breaking1_activate (GtkMenuItem *menuitem,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
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();
|
2008-06-16 18:31:59 +00:00
|
|
|
g_return_if_fail(doc != NULL);
|
2008-05-09 12:13:29 +00:00
|
|
|
|
|
|
|
doc->line_breaking = !doc->line_breaking;
|
|
|
|
}
|