2005-11-22 12:26:26 +00:00
/*
* callbacks . c - this file is part of Geany , a fast and lightweight IDE
*
2007-01-14 17:36:42 +00:00
* Copyright 2005 - 2007 Enrico Tröger < enrico . troeger @ uvena . de >
2007-01-06 15:03:53 +00:00
* Copyright 2006 - 2007 Nick Treleaven < nick . treleaven @ btinternet . 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"
# 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"
2005-11-22 12:26:26 +00:00
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
2005-11-22 12:26:26 +00:00
// represents the state while closing all tabs(used to prevent notebook switch page signals)
static gboolean closing_all = FALSE ;
2006-07-11 14:15:56 +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
static gboolean ignore_toolbar_toggle = FALSE ;
2006-12-17 19:31:32 +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.
static gboolean insert_callback_from_menu = FALSE ;
2005-11-22 12:26:26 +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;
2007-03-13 17:00:12 +00:00
CallbacksData callbacks_data = { - 1 } ;
2005-12-01 22:59:02 +00:00
2006-11-07 11:24:22 +00:00
static gboolean check_no_unsaved ( )
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
2006-11-07 11:24:22 +00:00
for ( i = 0 ; i < doc_array - > len ; i + + )
2005-11-22 12:26:26 +00:00
{
2006-11-07 11:24:22 +00:00
if ( doc_list [ i ] . is_valid & & doc_list [ 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
}
}
2006-11-07 11:24:22 +00:00
return TRUE ; // no unsaved edits
}
static gboolean account_for_unsaved ( )
{
gint p ;
for ( p = 0 ; p < gtk_notebook_get_n_pages ( GTK_NOTEBOOK ( app - > notebook ) ) ; p + + )
2005-11-22 12:26:26 +00:00
{
2006-11-07 11:24:22 +00:00
gint idx = document_get_n_idx ( p ) ;
if ( doc_list [ idx ] . changed )
2005-11-22 12:26:26 +00:00
{
2006-11-07 11:24:22 +00:00
if ( ! dialogs_show_unsaved_file ( idx ) )
return FALSE ;
2005-11-22 12:26:26 +00:00
}
2006-11-07 11:24:22 +00:00
}
return TRUE ;
}
2006-12-17 19:31:32 +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
static void verify_click_pos ( gint idx )
{
if ( insert_callback_from_menu )
{
editor_info . click_pos = sci_get_current_position ( doc_list [ idx ] . sci ) ;
insert_callback_from_menu = FALSE ;
}
}
2006-11-07 11:24:22 +00:00
// should only be called from on_exit_clicked
static void quit_app ( )
{
guint i ;
configuration_save ( ) ;
// force close all tabs
for ( i = 0 ; i < doc_array - > len ; i + + )
{
if ( doc_list [ i ] . is_valid & & doc_list [ i ] . changed )
2005-11-22 12:26:26 +00:00
{
2006-11-07 11:24:22 +00:00
doc_list [ i ] . changed = FALSE ; // ignore changes (already asked user in on_exit_clicked)
2005-11-22 12:26:26 +00:00
}
}
2006-11-07 11:24:22 +00:00
on_close_all1_activate ( NULL , NULL ) ;
2007-06-04 15:37:11 +00:00
main_quit ( ) ;
2006-11-07 11:24:22 +00:00
}
// wrapper function to abort exit process if cancel button is pressed
gboolean
on_exit_clicked ( GtkWidget * widget , gpointer gdata )
{
app - > quitting = TRUE ;
if ( ! check_no_unsaved ( ) )
{
if ( 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
if ( ! app - > pref_main_confirm_exit | |
dialogs_show_question_full ( GTK_STOCK_QUIT , GTK_STOCK_CANCEL , NULL ,
_ ( " 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
app - > quitting = FALSE ;
2005-11-22 12:26:26 +00:00
return TRUE ;
}
/*
* GUI callbacks
*/
void
on_new1_activate ( GtkMenuItem * menuitem ,
gpointer user_data )
{
2007-02-15 23:56:15 +00:00
document_new_file ( NULL , NULL ) ;
2005-11-22 12:26:26 +00:00
}
void
on_save1_activate ( GtkMenuItem * menuitem ,
gpointer user_data )
{
gint cur_page = gtk_notebook_get_current_page ( GTK_NOTEBOOK ( app - > notebook ) ) ;
gint idx = document_get_cur_idx ( ) ;
if ( cur_page > = 0 )
{
if ( doc_list [ idx ] . file_name = = NULL )
dialogs_show_save_as ( ) ;
else
2006-08-02 10:50:53 +00:00
document_save_file ( idx , 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 )
{
gint i , idx , max = gtk_notebook_get_n_pages ( GTK_NOTEBOOK ( app - > notebook ) ) ;
gint cur_idx = document_get_cur_idx ( ) ;
for ( i = 0 ; i < max ; i + + )
{
idx = document_get_n_idx ( i ) ;
if ( ! doc_list [ idx ] . changed ) continue ;
if ( doc_list [ idx ] . file_name = = NULL )
dialogs_show_save_as ( ) ;
else
2006-08-02 10:50:53 +00:00
document_save_file ( idx , FALSE ) ;
2005-11-22 12:26:26 +00:00
}
2007-02-05 16:17:44 +00:00
treeviews_update_tag_list ( cur_idx , TRUE ) ;
2006-09-05 14:24:47 +00:00
ui_set_window_title ( cur_idx ) ;
2005-11-22 12:26:26 +00:00
}
gboolean
on_close_all1_activate ( GtkMenuItem * menuitem ,
gpointer user_data )
{
gboolean ret = TRUE ;
gint i , max = gtk_notebook_get_n_pages ( GTK_NOTEBOOK ( app - > notebook ) ) ;
closing_all = TRUE ;
for ( i = 0 ; i < max ; i + + )
{
if ( ! document_remove ( 0 ) )
{
ret = FALSE ;
break ;
}
}
closing_all = FALSE ;
tm_workspace_update ( TM_WORK_OBJECT ( app - > tm_workspace ) , TRUE , TRUE , FALSE ) ;
// if cancel is clicked, cancel the complete exit process
return ret ;
}
void
on_close1_activate ( GtkMenuItem * menuitem ,
gpointer user_data )
{
2006-01-03 12:39:25 +00:00
guint cur_page = gtk_notebook_get_current_page ( GTK_NOTEBOOK ( app - > notebook ) ) ;
2005-11-22 12:26:26 +00:00
document_remove ( cur_page ) ;
}
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 )
{
gtk_widget_set_sensitive ( app - > recent_files_menuitem ,
g_queue_get_length ( app - > recent_queue ) > 0 ) ;
}
2005-11-22 12:26:26 +00:00
// edit actions, c&p & co, from menu bar and from popup menu
void
on_edit1_activate ( GtkMenuItem * menuitem ,
gpointer user_data )
{
gint idx = document_get_cur_idx ( ) ;
2006-09-05 14:24:47 +00:00
ui_update_menu_copy_items ( idx ) ;
ui_update_insert_include_item ( idx , 1 ) ;
2005-11-22 12:26:26 +00:00
}
void
on_undo1_activate ( GtkMenuItem * menuitem ,
gpointer user_data )
{
gint idx = document_get_cur_idx ( ) ;
2006-06-24 18:46:08 +00:00
if ( idx = = - 1 | | ! doc_list [ idx ] . is_valid ) return ;
2006-09-06 16:09:08 +00:00
if ( document_can_undo ( idx ) ) document_undo ( idx ) ;
2005-11-22 12:26:26 +00:00
}
void
on_redo1_activate ( GtkMenuItem * menuitem ,
gpointer user_data )
{
gint idx = document_get_cur_idx ( ) ;
2006-06-24 18:46:08 +00:00
if ( idx = = - 1 | | ! doc_list [ idx ] . is_valid ) return ;
2006-09-06 16:09:08 +00:00
if ( document_can_redo ( idx ) ) document_redo ( idx ) ;
2005-11-22 12:26:26 +00:00
}
void
on_cut1_activate ( GtkMenuItem * menuitem ,
gpointer user_data )
{
gint idx = document_get_cur_idx ( ) ;
2006-06-25 19:57:07 +00:00
GtkWidget * focusw = gtk_window_get_focus ( GTK_WINDOW ( app - > 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
if ( IS_SCINTILLA ( focusw ) & & idx > = 0 )
2005-11-22 12:26:26 +00:00
sci_cut ( doc_list [ idx ] . 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 )
{
gint idx = document_get_cur_idx ( ) ;
2006-06-25 19:57:07 +00:00
GtkWidget * focusw = gtk_window_get_focus ( GTK_WINDOW ( app - > 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
if ( IS_SCINTILLA ( focusw ) & & idx > = 0 )
2005-11-22 12:26:26 +00:00
sci_copy ( doc_list [ idx ] . 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 )
{
gint idx = document_get_cur_idx ( ) ;
2006-06-25 19:57:07 +00:00
GtkWidget * focusw = gtk_window_get_focus ( GTK_WINDOW ( app - > 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
if ( IS_SCINTILLA ( focusw ) & & idx > = 0 )
2006-12-21 16:41:36 +00:00
{
# ifdef G_OS_WIN32
// insert the text manually for now, because the auto conversion of EOL characters by
// by Scintilla seems to make problems
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 )
{
2007-01-09 23:53:25 +00:00
sci_replace_sel ( doc_list [ idx ] . sci , content ) ;
2006-12-21 16:41:36 +00:00
g_free ( content ) ;
}
}
# else
2005-11-22 12:26:26 +00:00
sci_paste ( doc_list [ idx ] . 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 )
{
gint idx = document_get_cur_idx ( ) ;
2006-06-25 19:57:07 +00:00
GtkWidget * focusw = gtk_window_get_focus ( GTK_WINDOW ( app - > 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
if ( IS_SCINTILLA ( focusw ) & & idx > = 0 )
2005-11-22 12:26:26 +00:00
sci_clear ( doc_list [ idx ] . 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
}
// about menu item
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
}
// open file
void
on_open1_activate ( GtkMenuItem * menuitem ,
gpointer user_data )
{
dialogs_show_open_file ( ) ;
}
// quit toolbar button
void
on_toolbutton19_clicked ( GtkToolButton * toolbutton ,
gpointer user_data )
{
on_exit_clicked ( NULL , NULL ) ;
}
// reload file
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 ) ) ;
}
// also used for reloading when user_data is -1
void
on_reload_as_activate ( GtkMenuItem * menuitem ,
gpointer user_data )
2005-11-22 12:26:26 +00:00
{
gint idx = document_get_cur_idx ( ) ;
2006-06-24 18:46:08 +00:00
gchar * basename ;
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
2006-08-18 17:24:44 +00:00
if ( idx < 0 | | ! doc_list [ idx ] . is_valid | | doc_list [ idx ] . file_name = = NULL )
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
2006-06-24 18:46:08 +00:00
basename = g_path_get_basename ( doc_list [ idx ] . file_name ) ;
2006-08-18 17:24:44 +00:00
if ( dialogs_show_question_full ( _ ( " _Reload " ) , GTK_STOCK_CANCEL ,
_ ( " Any unsaved changes will be lost. " ) ,
_ ( " Are you sure you want to reload '%s'? " ) , basename ) )
2005-11-22 12:26:26 +00:00
{
2006-08-18 17:24:44 +00:00
document_reload_file ( idx , charset ) ;
if ( charset ! = NULL )
2006-09-05 14:24:47 +00:00
ui_update_statusbar ( idx , - 1 ) ;
2005-11-22 12:26:26 +00:00
}
2006-02-10 21:02:54 +00:00
g_free ( basename ) ;
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 ;
2005-11-22 12:26:26 +00:00
gtk_toolbar_set_style ( GTK_TOOLBAR ( app - > toolbar ) , GTK_TOOLBAR_BOTH ) ;
app - > toolbar_icon_style = GTK_TOOLBAR_BOTH ;
}
void
on_images_only2_activate ( GtkMenuItem * menuitem ,
gpointer user_data )
{
2006-07-11 14:15:56 +00:00
if ( ignore_toolbar_toggle ) return ;
2005-11-22 12:26:26 +00:00
gtk_toolbar_set_style ( GTK_TOOLBAR ( app - > toolbar ) , GTK_TOOLBAR_ICONS ) ;
app - > toolbar_icon_style = GTK_TOOLBAR_ICONS ;
}
void
on_text_only2_activate ( GtkMenuItem * menuitem ,
gpointer user_data )
{
2006-07-11 14:15:56 +00:00
if ( ignore_toolbar_toggle ) return ;
2005-11-22 12:26:26 +00:00
gtk_toolbar_set_style ( GTK_TOOLBAR ( app - > toolbar ) , GTK_TOOLBAR_TEXT ) ;
app - > toolbar_icon_style = GTK_TOOLBAR_TEXT ;
}
void
on_change_font1_activate ( GtkMenuItem * menuitem ,
gpointer user_data )
{
dialogs_show_open_font ( ) ;
}
// new file
void
on_toolbutton8_clicked ( GtkToolButton * toolbutton ,
gpointer user_data )
{
2007-02-15 23:56:15 +00:00
document_new_file ( NULL , NULL ) ;
2005-11-22 12:26:26 +00:00
}
// open file
void
on_toolbutton9_clicked ( GtkToolButton * toolbutton ,
gpointer user_data )
{
dialogs_show_open_file ( ) ;
}
// save file
void
on_toolbutton10_clicked ( GtkToolButton * toolbutton ,
gpointer user_data )
{
on_save1_activate ( NULL , user_data ) ;
}
2007-01-24 12:35:05 +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 ;
2006-08-01 11:33:42 +00:00
}
2005-11-22 12:26:26 +00:00
// search text
void
on_entry1_activate ( GtkEntry * entry ,
gpointer user_data )
{
gint idx = document_get_cur_idx ( ) ;
2006-08-01 11:33:42 +00:00
setup_find_next ( GTK_EDITABLE ( entry ) ) ;
2006-11-03 15:09:13 +00:00
document_search_bar_find ( idx , search_data . text , 0 , FALSE ) ;
2005-11-22 12:26:26 +00:00
}
// search text
void
on_entry1_changed ( GtkEditable * editable ,
gpointer user_data )
{
gint idx = document_get_cur_idx ( ) ;
2006-08-01 11:33:42 +00:00
setup_find_next ( editable ) ;
2006-11-03 15:09:13 +00:00
document_search_bar_find ( idx , search_data . text , 0 , TRUE ) ;
2005-11-22 12:26:26 +00:00
}
// search text
void
on_toolbutton18_clicked ( GtkToolButton * toolbutton ,
gpointer user_data )
{
//on_entry1_changed(NULL, NULL);
gint idx = document_get_cur_idx ( ) ;
GtkWidget * entry = lookup_widget ( GTK_WIDGET ( app - > window ) , " entry1 " ) ;
2006-08-01 11:33:42 +00:00
setup_find_next ( GTK_EDITABLE ( entry ) ) ;
2006-11-03 15:09:13 +00:00
document_search_bar_find ( idx , search_data . text , 0 , FALSE ) ;
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 ;
2005-11-22 12:26:26 +00:00
app - > toolbar_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 ;
2005-11-22 12:26:26 +00:00
app - > toolbar_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
}
// hides toolbar from toolbar popup menu
void
on_hide_toolbar1_activate ( GtkMenuItem * menuitem ,
gpointer user_data )
{
GtkWidget * tool_item = lookup_widget ( GTK_WIDGET ( app - > window ) , " menu_show_toolbar1 " ) ;
gtk_check_menu_item_set_active ( GTK_CHECK_MENU_ITEM ( tool_item ) , FALSE ) ;
}
// zoom in from menu bar and popup menu
void
on_zoom_in1_activate ( GtkMenuItem * menuitem ,
gpointer user_data )
{
gint idx = document_get_cur_idx ( ) ;
static gboolean done = 1 ;
2006-06-24 18:46:08 +00:00
if ( idx > = 0 & & doc_list [ idx ] . is_valid )
2005-11-22 12:26:26 +00:00
{
2006-02-14 22:07:55 +00:00
if ( done + + % 3 = = 0 ) sci_set_line_numbers ( doc_list [ idx ] . sci , app - > show_linenumber_margin ,
2005-11-22 12:26:26 +00:00
( sci_get_zoom ( doc_list [ idx ] . sci ) / 2 ) ) ;
sci_zoom_in ( doc_list [ idx ] . sci ) ;
}
}
// zoom out from menu bar and popup menu
void
on_zoom_out1_activate ( GtkMenuItem * menuitem ,
gpointer user_data )
{
gint idx = document_get_cur_idx ( ) ;
2006-06-24 18:46:08 +00:00
if ( idx > = 0 & & doc_list [ idx ] . is_valid )
2005-11-22 12:26:26 +00:00
{
if ( sci_get_zoom ( doc_list [ idx ] . sci ) = = 0 )
2006-02-14 22:07:55 +00:00
sci_set_line_numbers ( doc_list [ idx ] . sci , app - > show_linenumber_margin , 0 ) ;
2005-11-22 12:26:26 +00:00
sci_zoom_out ( doc_list [ idx ] . sci ) ;
}
}
void
on_normal_size1_activate ( GtkMenuItem * menuitem ,
gpointer user_data )
{
gint idx = document_get_cur_idx ( ) ;
2006-06-24 18:46:08 +00:00
if ( idx > = 0 & & doc_list [ idx ] . is_valid )
2006-02-06 06:25:01 +00:00
{
sci_zoom_off ( doc_list [ idx ] . sci ) ;
2006-02-14 22:07:55 +00:00
sci_set_line_numbers ( doc_list [ idx ] . sci , app - > show_linenumber_margin , 0 ) ;
2006-02-06 06:25:01 +00:00
}
2005-11-22 12:26:26 +00:00
}
// close tab
void
on_toolbutton15_clicked ( GtkToolButton * toolbutton ,
gpointer user_data )
{
gint cur_page = gtk_notebook_get_current_page ( GTK_NOTEBOOK ( app - > notebook ) ) ;
document_remove ( cur_page ) ;
}
void
on_notebook1_switch_page ( GtkNotebook * notebook ,
GtkNotebookPage * page ,
guint page_num ,
gpointer user_data )
{
2007-03-13 17:00:12 +00:00
callbacks_data . last_doc_idx = document_get_cur_idx ( ) ;
2005-11-22 12:26:26 +00:00
}
2007-03-14 12:03:15 +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 )
{
gint idx ;
if ( closing_all ) return ;
// guint == -1 seems useless, but it isn't!
2006-08-08 13:01:50 +00:00
if ( page_num = = ( guint ) - 1 & & page ! = NULL )
2006-05-26 12:22:39 +00:00
idx = document_find_by_sci ( SCINTILLA ( page ) ) ;
else
idx = document_get_n_idx ( page_num ) ;
if ( idx > = 0 & & app - > opening_session_files = = FALSE )
{
2007-03-14 12:03:15 +00:00
gtk_tree_model_foreach ( GTK_TREE_MODEL ( tv . store_openfiles ) , treeviews_find_node , GINT_TO_POINTER ( idx ) ) ;
document_set_text_changed ( idx ) ; // also sets window title and status bar
ui_update_popup_reundo_items ( idx ) ;
ui_document_show_hide ( idx ) ; // update the document menu
build_menu_update ( idx ) ;
treeviews_update_tag_list ( idx , FALSE ) ;
2006-12-18 13:04:18 +00:00
utils_check_disk_status ( idx , FALSE ) ;
2006-06-29 23:51:32 +00:00
# ifdef HAVE_VTE
2007-03-13 17:00:12 +00:00
vte_cwd ( doc_list [ idx ] . file_name , FALSE ) ;
2006-06-29 23:51:32 +00:00
# endif
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 )
{
//switch_tv_notebook_page = TRUE;
}
/*
* open dialog callbacks
*/
// file open dialog, opened
void
2006-02-10 21:02:54 +00:00
on_file_open_dialog_response ( GtkDialog * dialog ,
gint response ,
gpointer user_data )
2005-11-22 12:26:26 +00:00
{
gtk_widget_hide ( app - > open_filesel ) ;
2006-04-27 18:06:35 +00:00
if ( response = = GTK_RESPONSE_ACCEPT | | response = = GTK_RESPONSE_APPLY )
2005-11-22 12:26:26 +00:00
{
2006-04-27 18:06:35 +00:00
GSList * filelist ;
2006-10-23 00:05:42 +00:00
gint filetype_idx = gtk_combo_box_get_active ( GTK_COMBO_BOX (
lookup_widget ( GTK_WIDGET ( dialog ) , " filetype_combo " ) ) ) ;
gint encoding_idx = gtk_combo_box_get_active ( GTK_COMBO_BOX (
lookup_widget ( GTK_WIDGET ( dialog ) , " encoding_combo " ) ) ) ;
2006-02-10 21:02:54 +00:00
filetype * ft = NULL ;
2006-10-23 00:05:42 +00:00
gchar * charset = NULL ;
2006-04-27 18:06:35 +00:00
gboolean ro = ( response = = GTK_RESPONSE_APPLY ) ; // View clicked
2006-02-10 21:02:54 +00:00
2006-10-23 00:05:42 +00:00
if ( filetype_idx > = 0 & & filetype_idx < GEANY_FILETYPES_ALL ) ft = filetypes [ filetype_idx ] ;
if ( encoding_idx > = 0 & & encoding_idx < GEANY_ENCODINGS_MAX )
charset = encodings [ encoding_idx ] . charset ;
2006-02-10 21:02:54 +00:00
2006-04-27 18:06:35 +00:00
filelist = gtk_file_chooser_get_filenames ( GTK_FILE_CHOOSER ( app - > open_filesel ) ) ;
2007-03-06 16:57:09 +00:00
if ( filelist ! = NULL )
2005-11-22 12:26:26 +00:00
{
2007-03-06 16:57:09 +00:00
document_open_files ( filelist , ro , ft , charset ) ;
g_slist_foreach ( filelist , ( GFunc ) g_free , NULL ) ; // free filenames
2005-11-22 12:26:26 +00:00
}
2006-04-27 18:06:35 +00:00
g_slist_free ( filelist ) ;
2005-11-22 12:26:26 +00:00
}
}
2006-02-10 21:02:54 +00:00
// callback for the text entry for typing in filename
2005-11-22 12:26:26 +00:00
void
on_file_open_entry_activate ( GtkEntry * entry ,
gpointer user_data )
{
2006-08-13 09:07:10 +00:00
gchar * locale_filename = utils_get_locale_from_utf8 ( gtk_entry_get_text ( entry ) ) ;
2006-02-10 21:02:54 +00:00
2006-04-27 18:06:35 +00:00
if ( g_file_test ( locale_filename , G_FILE_TEST_IS_DIR ) )
2006-02-10 21:02:54 +00:00
{
2006-04-27 18:06:35 +00:00
gtk_file_chooser_set_current_folder ( GTK_FILE_CHOOSER ( app - > open_filesel ) , locale_filename ) ;
2006-02-10 21:02:54 +00:00
}
2006-04-27 18:06:35 +00:00
else if ( g_file_test ( locale_filename , G_FILE_TEST_IS_REGULAR | G_FILE_TEST_IS_SYMLINK ) )
2006-02-10 21:02:54 +00:00
{
2006-04-27 18:06:35 +00:00
gtk_file_chooser_set_filename ( GTK_FILE_CHOOSER ( app - > open_filesel ) , locale_filename ) ;
on_file_open_dialog_response ( GTK_DIALOG ( app - > open_filesel ) , GTK_RESPONSE_ACCEPT , NULL ) ;
2006-02-10 21:02:54 +00:00
}
g_free ( locale_filename ) ;
2005-11-22 12:26:26 +00:00
}
void
2006-02-10 21:02:54 +00:00
on_file_open_selection_changed ( GtkFileChooser * filechooser ,
2005-11-22 12:26:26 +00:00
gpointer user_data )
{
gchar * filename = gtk_file_chooser_get_filename ( filechooser ) ;
2006-02-10 21:02:54 +00:00
gboolean is_on = gtk_file_chooser_get_show_hidden ( filechooser ) ;
2005-11-22 12:26:26 +00:00
if ( filename )
{
2006-02-10 21:02:54 +00:00
// try to get the UTF-8 equivalent for the filename, fallback to filename if error
2006-08-13 09:07:10 +00:00
gchar * utf8_filename = utils_get_utf8_from_locale ( filename ) ;
2006-02-10 21:02:54 +00:00
2005-11-22 12:26:26 +00:00
gtk_entry_set_text ( GTK_ENTRY ( lookup_widget (
2006-02-10 21:02:54 +00:00
GTK_WIDGET ( filechooser ) , " file_entry " ) ) , utf8_filename ) ;
g_free ( utf8_filename ) ;
2005-11-22 12:26:26 +00:00
g_free ( filename ) ;
}
2006-02-10 21:02:54 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON (
lookup_widget ( GTK_WIDGET ( filechooser ) , " check_hidden " ) ) , is_on ) ;
2005-11-22 12:26:26 +00:00
}
/*
* save dialog callbacks
*/
void
2006-02-14 22:07:55 +00:00
on_file_save_dialog_response ( GtkDialog * dialog ,
gint response ,
gpointer user_data )
2005-11-22 12:26:26 +00:00
{
2006-02-14 22:07:55 +00:00
if ( response = = GTK_RESPONSE_ACCEPT )
{
gint idx = document_get_cur_idx ( ) ;
2006-04-27 18:06:35 +00:00
gchar * new_filename = gtk_file_chooser_get_filename ( GTK_FILE_CHOOSER ( app - > save_filesel ) ) ;
2007-06-12 16:45:24 +00:00
gchar * utf8_filename ;
gboolean open_new_tab = gtk_toggle_button_get_active (
GTK_TOGGLE_BUTTON ( lookup_widget ( app - > save_filesel , " check_open_new_tab " ) ) ) ;
gboolean rename_file = gtk_toggle_button_get_active (
GTK_TOGGLE_BUTTON ( lookup_widget ( app - > save_filesel , " check_rename " ) ) ) ;
utf8_filename = utils_get_utf8_from_locale ( new_filename ) ;
2006-04-27 18:06:35 +00:00
// check if file exists and ask whether to overwrite or not
if ( g_file_test ( new_filename , G_FILE_TEST_EXISTS ) )
{
if ( dialogs_show_question (
2007-06-12 16:45:24 +00:00
_ ( " The file '%s' already exists. Do you want to overwrite it? " ) ,
utf8_filename ) = = FALSE )
return ;
2006-04-27 18:06:35 +00:00
}
2005-11-22 12:26:26 +00:00
2007-06-12 16:45:24 +00:00
if ( open_new_tab )
{ // "open" the saved file in a new tab
// (actually create a new file and copy file content and properties)
gint len , old_idx ;
gchar * data ;
old_idx = idx ;
// use old file type (or maybe NULL for auto detect would be better?)
idx = document_new_file ( utf8_filename , doc_list [ idx ] . file_type ) ;
2007-06-14 15:47:09 +00:00
sci_set_undo_collection ( doc_list [ idx ] . sci , FALSE ) ; // avoid creation of an undo action
sci_empty_undo_buffer ( doc_list [ idx ] . sci ) ;
2007-06-12 16:45:24 +00:00
len = sci_get_length ( doc_list [ old_idx ] . sci ) + 1 ;
data = ( gchar * ) g_malloc ( len ) ;
sci_get_text ( doc_list [ old_idx ] . sci , len , data ) ;
sci_set_text ( doc_list [ idx ] . sci , data ) ;
// copy file properties
doc_list [ idx ] . line_breaking = doc_list [ old_idx ] . line_breaking ;
doc_list [ idx ] . readonly = doc_list [ old_idx ] . readonly ;
doc_list [ idx ] . has_bom = doc_list [ old_idx ] . has_bom ;
document_set_encoding ( idx , doc_list [ old_idx ] . encoding ) ;
sci_set_lines_wrapped ( doc_list [ idx ] . sci , doc_list [ idx ] . line_breaking ) ;
sci_set_readonly ( doc_list [ idx ] . sci , doc_list [ idx ] . readonly ) ;
2007-06-14 15:47:09 +00:00
sci_set_undo_collection ( doc_list [ idx ] . sci , TRUE ) ;
2007-06-12 16:45:24 +00:00
ui_document_show_hide ( idx ) ;
g_free ( data ) ;
g_free ( utf8_filename ) ;
2006-06-29 19:08:21 +00:00
}
2007-06-12 16:45:24 +00:00
else
{
if ( doc_list [ idx ] . file_name ! = NULL )
2007-06-13 12:14:58 +00:00
{
if ( rename_file )
{ // delete the previous file name
gchar * old_filename = utils_get_locale_from_utf8 ( doc_list [ idx ] . file_name ) ;
g_unlink ( old_filename ) ;
g_free ( old_filename ) ;
}
// create a new tm_source_file object otherwise tagmanager won't work correctly
2007-06-12 16:45:24 +00:00
tm_workspace_remove_object ( doc_list [ idx ] . tm_file , TRUE ) ;
doc_list [ idx ] . tm_file = NULL ;
g_free ( doc_list [ idx ] . file_name ) ;
}
doc_list [ idx ] . file_name = utf8_filename ;
}
2006-02-14 22:07:55 +00:00
utils_replace_filename ( idx ) ;
2006-08-02 10:50:53 +00:00
document_save_file ( idx , TRUE ) ;
2005-11-22 12:26:26 +00:00
2007-06-12 16:45:24 +00:00
if ( ! open_new_tab )
build_menu_update ( idx ) ;
2005-11-22 12:26:26 +00:00
2006-02-14 22:07:55 +00:00
// finally add current file to recent files menu
2006-09-05 14:24:47 +00:00
ui_add_recent_file ( doc_list [ idx ] . file_name ) ;
2007-06-12 16:45:24 +00:00
g_free ( new_filename ) ;
2005-11-22 12:26:26 +00:00
}
2007-06-12 16:45:24 +00:00
gtk_widget_hide ( app - > save_filesel ) ;
2005-11-22 12:26:26 +00:00
}
/*
* font dialog callbacks
*/
void
on_font_ok_button_clicked ( GtkButton * button ,
gpointer user_data )
{
// We do the same thing as apply, but we close the dialog after.
on_font_apply_button_clicked ( button , NULL ) ;
gtk_widget_hide ( app - > open_fontsel ) ;
}
void
on_font_apply_button_clicked ( GtkButton * button ,
gpointer user_data )
{
2006-06-29 16:55:29 +00:00
gchar * fontname ;
2005-11-22 12:26:26 +00:00
2006-06-29 16:55:29 +00:00
fontname = gtk_font_selection_dialog_get_font_name (
GTK_FONT_SELECTION_DIALOG ( app - > open_fontsel ) ) ;
2006-09-05 14:24:47 +00:00
ui_set_editor_font ( fontname ) ;
2006-06-29 16:55:29 +00:00
g_free ( fontname ) ;
2005-11-22 12:26:26 +00:00
}
2006-02-22 13:43:50 +00:00
void
on_font_cancel_button_clicked ( GtkButton * button ,
2005-11-22 12:26:26 +00:00
gpointer user_data )
{
gtk_widget_hide ( app - > open_fontsel ) ;
}
/*
* color dialog callbacks
*/
2006-02-22 13:43:50 +00:00
void
on_color_cancel_button_clicked ( GtkButton * button ,
gpointer user_data )
{
gtk_widget_hide ( app - > open_colorsel ) ;
}
2005-11-22 12:26:26 +00:00
void
on_color_ok_button_clicked ( GtkButton * button ,
gpointer user_data )
{
GdkColor color ;
gint idx = document_get_cur_idx ( ) ;
2005-12-11 02:16:02 +00:00
gchar * hex ;
2005-11-22 12:26:26 +00:00
2006-02-20 22:55:53 +00:00
gtk_widget_hide ( app - > open_colorsel ) ;
if ( idx = = - 1 | | ! doc_list [ idx ] . is_valid ) return ;
2006-02-25 22:26:43 +00:00
2005-11-22 12:26:26 +00:00
gtk_color_selection_get_current_color (
GTK_COLOR_SELECTION ( GTK_COLOR_SELECTION_DIALOG ( app - > open_colorsel ) - > colorsel ) , & color ) ;
2005-12-11 02:16:02 +00:00
hex = utils_get_hex_from_color ( & color ) ;
2005-11-22 12:26:26 +00:00
sci_add_text ( doc_list [ idx ] . sci , hex ) ;
g_free ( hex ) ;
}
2005-11-30 23:33:35 +00:00
gboolean
on_window_key_press_event ( GtkWidget * widget ,
GdkEventKey * event ,
gpointer user_data )
{
2006-08-07 15:05:21 +00:00
return event - > keyval = = 0 ? FALSE : keybindings_got_event ( widget , event , user_data ) ;
2005-11-22 12:26:26 +00:00
}
void
on_crlf_activate ( GtkMenuItem * menuitem ,
gpointer user_data )
{
gint idx = document_get_cur_idx ( ) ;
2006-08-03 22:17:10 +00:00
if ( app - > ignore_callback | | idx = = - 1 | | ! doc_list [ idx ] . is_valid ) return ;
2005-11-22 12:26:26 +00:00
sci_convert_eols ( doc_list [ idx ] . sci , SC_EOL_CRLF ) ;
sci_set_eol_mode ( doc_list [ idx ] . sci , SC_EOL_CRLF ) ;
}
void
on_lf_activate ( GtkMenuItem * menuitem ,
gpointer user_data )
{
gint idx = document_get_cur_idx ( ) ;
2006-08-03 22:17:10 +00:00
if ( app - > ignore_callback | | idx = = - 1 | | ! doc_list [ idx ] . is_valid ) return ;
2005-11-22 12:26:26 +00:00
sci_convert_eols ( doc_list [ idx ] . sci , SC_EOL_LF ) ;
sci_set_eol_mode ( doc_list [ idx ] . sci , SC_EOL_LF ) ;
}
void
on_cr_activate ( GtkMenuItem * menuitem ,
gpointer user_data )
{
gint idx = document_get_cur_idx ( ) ;
2006-08-03 22:17:10 +00:00
if ( app - > ignore_callback | | idx = = - 1 | | ! doc_list [ idx ] . is_valid ) return ;
2005-11-22 12:26:26 +00:00
sci_convert_eols ( doc_list [ idx ] . sci , SC_EOL_CR ) ;
sci_set_eol_mode ( doc_list [ idx ] . sci , SC_EOL_CR ) ;
}
void
on_replace_tabs_activate ( GtkMenuItem * menuitem ,
gpointer user_data )
{
gint idx = document_get_cur_idx ( ) ;
2006-07-17 10:42:26 +00:00
document_replace_tabs ( idx ) ;
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 ;
switch ( app - > toolbar_icon_style )
{
2007-03-09 13:52:26 +00:00
case 0 : w = lookup_widget ( app - > toolbar_menu , " images_only2 " ) ; break ;
case 1 : w = lookup_widget ( app - > toolbar_menu , " text_only2 " ) ; break ;
default : w = lookup_widget ( app - > 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
switch ( app - > toolbar_icon_size )
{
case GTK_ICON_SIZE_LARGE_TOOLBAR :
widget = lookup_widget ( app - > toolbar_menu , " large_icons1 " ) ; break ;
default : widget = lookup_widget ( app - > toolbar_menu , " small_icons1 " ) ; break ;
}
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 ;
2005-11-22 12:26:26 +00:00
gtk_menu_popup ( GTK_MENU ( app - > toolbar_menu ) , NULL , NULL , NULL , NULL , event - > button , event - > time ) ;
return TRUE ;
}
return FALSE ;
}
void
on_to_lower_case1_activate ( GtkMenuItem * menuitem ,
gpointer user_data )
{
gint idx = document_get_cur_idx ( ) ;
2006-09-12 08:32:52 +00:00
if ( idx < 0 | | ! doc_list [ idx ] . is_valid ) return ;
sci_cmd ( doc_list [ idx ] . sci , SCI_LOWERCASE ) ;
2005-11-22 12:26:26 +00:00
}
void
on_to_upper_case1_activate ( GtkMenuItem * menuitem ,
gpointer user_data )
{
gint idx = document_get_cur_idx ( ) ;
2006-09-12 08:32:52 +00:00
if ( idx < 0 | | ! doc_list [ idx ] . is_valid ) return ;
sci_cmd ( doc_list [ idx ] . sci , SCI_UPPERCASE ) ;
2005-11-22 12:26:26 +00:00
}
void
on_show_toolbar1_toggled ( GtkCheckMenuItem * checkmenuitem ,
gpointer user_data )
{
2006-07-21 11:41:33 +00:00
if ( app - > ignore_callback ) return ;
2005-11-22 12:26:26 +00:00
app - > toolbar_visible = ( app - > toolbar_visible ) ? FALSE : TRUE ; ;
2006-09-05 14:24:47 +00:00
ui_widget_show_hide ( GTK_WIDGET ( app - > toolbar ) , app - > toolbar_visible ) ;
2005-11-22 12:26:26 +00:00
}
void
on_fullscreen1_toggled ( GtkCheckMenuItem * checkmenuitem ,
gpointer user_data )
{
app - > fullscreen = ( app - > 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 )
{
2006-07-21 11:41:33 +00:00
if ( app - > ignore_callback ) return ;
2005-11-22 12:26:26 +00:00
app - > msgwindow_visible = ( app - > msgwindow_visible ) ? FALSE : TRUE ;
2006-09-05 14:24:47 +00:00
ui_widget_show_hide ( lookup_widget ( app - > window , " scrolledwindow1 " ) , app - > msgwindow_visible ) ;
2005-11-22 12:26:26 +00:00
}
void
on_markers_margin1_toggled ( GtkCheckMenuItem * checkmenuitem ,
gpointer user_data )
{
app - > show_markers_margin = ( app - > 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 )
{
2006-02-14 22:07:55 +00:00
app - > show_linenumber_margin = ( app - > 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
on_line_breaking1_toggled ( GtkCheckMenuItem * checkmenuitem ,
gpointer user_data )
{
2006-07-24 20:23:56 +00:00
if ( ! app - > ignore_callback )
2005-11-22 12:26:26 +00:00
{
gint idx = document_get_cur_idx ( ) ;
2006-02-14 22:07:55 +00:00
if ( idx = = - 1 | | ! doc_list [ idx ] . is_valid ) return ;
2005-11-22 12:26:26 +00:00
doc_list [ idx ] . line_breaking = ! doc_list [ idx ] . line_breaking ;
sci_set_lines_wrapped ( doc_list [ idx ] . sci , doc_list [ idx ] . line_breaking ) ;
}
}
2006-02-20 22:55:53 +00:00
void
on_set_file_readonly1_toggled ( GtkCheckMenuItem * checkmenuitem ,
gpointer user_data )
{
2006-07-24 20:23:56 +00:00
if ( ! app - > ignore_callback )
2006-02-20 22:55:53 +00:00
{
gint idx = document_get_cur_idx ( ) ;
if ( idx = = - 1 | | ! doc_list [ idx ] . is_valid ) return ;
doc_list [ idx ] . readonly = ! doc_list [ idx ] . readonly ;
sci_set_readonly ( doc_list [ idx ] . sci , doc_list [ idx ] . readonly ) ;
2006-12-05 10:37:36 +00:00
ui_update_tab_status ( idx ) ;
2006-09-05 14:24:47 +00:00
ui_update_statusbar ( idx , - 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 )
{
2006-07-24 20:23:56 +00:00
if ( ! app - > ignore_callback )
2006-02-14 22:07:55 +00:00
{
gint idx = document_get_cur_idx ( ) ;
if ( idx = = - 1 | | ! doc_list [ idx ] . is_valid ) return ;
2007-06-12 15:16:17 +00:00
doc_list [ idx ] . auto_indent = ! doc_list [ idx ] . 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 )
{
2006-11-01 15:26:41 +00:00
gint flags , idx ;
gchar * search_text ;
2006-07-23 20:26:57 +00:00
idx = document_get_cur_idx ( ) ;
2006-11-01 15:26:41 +00:00
if ( ! DOC_IDX_VALID ( idx ) ) return ;
2006-07-23 20:26:57 +00:00
if ( sci_can_copy ( doc_list [ idx ] . sci ) )
{ // take selected text if there is a selection
search_text = g_malloc ( sci_get_selected_text_length ( doc_list [ idx ] . sci ) + 1 ) ;
sci_get_selected_text ( doc_list [ idx ] . 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-01-17 17:42:23 +00:00
const gint forward_types = tm_tag_prototype_t | tm_tag_externvar_t ;
2006-04-27 18:06:35 +00:00
gint type ;
2006-07-01 13:16:52 +00:00
TMTag * tmtag ;
2005-11-22 12:26:26 +00:00
2007-01-17 17:42:23 +00:00
// goto tag definition: all except prototypes / forward declarations / externs
2006-06-02 14:26:34 +00:00
if ( menuitem = = GTK_MENU_ITEM ( lookup_widget ( app - > popup_menu , " goto_tag_definition1 " ) ) )
2007-01-17 17:42:23 +00:00
type = tm_tag_max_t - forward_types ;
2005-11-22 12:26:26 +00:00
else
2007-01-17 17:42:23 +00:00
type = forward_types ;
2005-11-22 12:26:26 +00:00
2006-11-08 11:42:05 +00:00
tmtag = symbols_find_in_workspace ( editor_info . current_word , type ) ;
if ( tmtag ! = NULL )
2005-11-22 12:26:26 +00:00
{
2007-06-02 16:14:07 +00:00
gint old_idx = document_get_cur_idx ( ) ; // get idx before switching the file
2006-11-08 11:42:05 +00:00
if ( utils_goto_file_line (
tmtag - > atts . entry . file - > work_object . file_name ,
TRUE , tmtag - > atts . entry . line ) )
2007-06-02 16:14:07 +00:00
{
// first add old file as old position
2007-06-20 12:42:06 +00:00
if ( doc_list [ old_idx ] . tm_file )
navqueue_new_position ( doc_list [ old_idx ] . tm_file - > file_name ,
sci_get_line_from_position ( doc_list [ old_idx ] . sci , editor_info . click_pos ) + 1 ) ;
2007-06-02 16:14:07 +00:00
navqueue_new_position ( tmtag - > atts . entry . file - > work_object . file_name ,
tmtag - > atts . entry . line ) ;
2006-11-08 11:42:05 +00:00
return ;
2007-06-02 16:14:07 +00:00
}
2005-11-22 12:26:26 +00:00
}
// if we are here, there was no match and we are beeping ;-)
2006-02-10 21:02:54 +00:00
utils_beep ( ) ;
2007-01-17 17:42:23 +00:00
if ( type = = forward_types )
ui_set_statusbar ( _ ( " Forward declaration \" %s \" not found. " ) , editor_info . current_word ) ;
2006-07-01 13:16:52 +00:00
else
2007-01-17 17:42:23 +00:00
ui_set_statusbar ( _ ( " Definition of \" %s \" not found. " ) , editor_info . current_word ) ;
2005-11-22 12:26:26 +00:00
}
void
on_count_words1_activate ( GtkMenuItem * menuitem ,
gpointer user_data )
{
dialogs_show_word_count ( ) ;
}
void
on_show_color_chooser1_activate ( GtkMenuItem * menuitem ,
gpointer user_data )
{
2006-12-20 15:57:28 +00:00
gchar colour [ 9 ] ;
2006-07-27 20:57:13 +00:00
gint idx = document_get_cur_idx ( ) ;
gint pos = sci_get_current_position ( doc_list [ idx ] . sci ) ;
2006-07-27 23:17:31 +00:00
if ( idx = = - 1 | | ! doc_list [ idx ] . is_valid )
return ;
2007-05-28 16:07:30 +00:00
editor_find_current_word ( doc_list [ idx ] . sci , pos , colour , sizeof colour , NULL ) ;
2006-07-27 20:57:13 +00:00
dialogs_show_color ( colour ) ;
2005-11-22 12:26:26 +00:00
}
void
on_compile_button_clicked ( GtkToolButton * toolbutton ,
gpointer user_data )
{
2006-04-27 18:06:35 +00:00
on_build_compile_activate ( NULL , NULL ) ;
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
}
void
on_find_next1_activate ( GtkMenuItem * menuitem ,
gpointer user_data )
{
gint idx = document_get_cur_idx ( ) ;
2006-08-11 21:12:49 +00:00
if ( search_data . text )
2005-11-22 12:26:26 +00:00
{
2006-11-03 15:09:13 +00:00
document_find_text ( idx , search_data . text , search_data . flags ,
search_data . backwards , TRUE ) ;
2005-11-22 12:26:26 +00:00
}
}
2006-07-18 17:43:22 +00:00
void
on_find_previous1_activate ( GtkMenuItem * menuitem ,
gpointer user_data )
{
gint idx = document_get_cur_idx ( ) ;
2006-08-11 21:12:49 +00:00
if ( search_data . text = = NULL ) return ;
2006-07-18 17:43:22 +00:00
2006-08-11 21:12:49 +00:00
if ( search_data . flags & SCFIND_REGEXP )
2006-07-18 17:43:22 +00:00
utils_beep ( ) ; //Can't reverse search order for a regex (find next ignores search backwards)
else
{
2006-11-03 15:09:13 +00:00
document_find_text ( idx , search_data . text , search_data . flags ,
! search_data . backwards , 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 )
{
search_find_selection ( document_get_cur_idx ( ) , FALSE ) ;
}
void
on_find_prevsel1_activate ( GtkMenuItem * menuitem ,
gpointer user_data )
{
search_find_selection ( document_get_cur_idx ( ) , TRUE ) ;
}
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 )
{
2006-08-11 21:12:49 +00:00
search_show_find_in_files_dialog ( ) ;
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-02-15 23:56:15 +00:00
document_new_file ( 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 )
{
gint idx = document_get_cur_idx ( ) ;
gint line = strtol ( gtk_entry_get_text ( GTK_ENTRY ( user_data ) ) , NULL , 10 ) ;
if ( line > 0 & & line < = sci_get_line_count ( doc_list [ idx ] . sci ) )
{
utils_goto_line ( idx , line ) ;
}
else
{
2006-02-10 21:02:54 +00:00
utils_beep ( ) ;
2005-11-22 12:26:26 +00:00
}
}
2006-02-26 18:29:24 +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 ,
lookup_widget ( app - > window , " entry_goto_line " ) ) ;
}
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 ;
uri = g_strconcat ( " file:/// " , app - > docdir , " /index.html " , NULL ) ;
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 ) )
2006-07-26 17:02:16 +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 ) ;
uri = g_strconcat ( GEANY_HOMEPAGE , " manual/index.html " , NULL ) ;
}
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 )
{
gint idx = document_get_cur_idx ( ) ;
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 ;
2006-06-07 16:50:41 +00:00
if ( doc_list [ idx ] . file_type = = NULL )
{
2006-12-18 11:56:46 +00:00
ui_set_statusbar ( _ ( " Please set the filetype for the current file before using this function. " ) ) ;
2006-06-07 16:50:41 +00:00
return ;
}
2006-06-16 17:11:09 +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
line = utils_get_current_function ( idx , & cur_tag ) ;
pos = sci_get_position_from_line ( doc_list [ idx ] . sci , line - 1 ) ;
2005-11-22 12:26:26 +00:00
2007-01-06 15:03:53 +00:00
text = templates_get_template_function ( doc_list [ idx ] . file_type - > id , cur_tag ) ;
2006-05-10 19:54:44 +00:00
2005-11-22 12:26:26 +00:00
sci_insert_text ( doc_list [ idx ] . sci , pos , text ) ;
g_free ( text ) ;
}
void
on_comments_multiline_activate ( GtkMenuItem * menuitem ,
gpointer user_data )
{
gint idx = document_get_cur_idx ( ) ;
2007-01-06 15:03:53 +00:00
if ( ! DOC_IDX_VALID ( idx ) | | doc_list [ idx ] . file_type = = NULL )
2006-06-07 16:50:41 +00:00
{
2006-12-18 11:56:46 +00:00
ui_set_statusbar ( _ ( " Please set the filetype for the current file before using this function. " ) ) ;
2006-06-07 16:50:41 +00:00
return ;
}
2007-01-06 15:03:53 +00:00
verify_click_pos ( idx ) ; // make sure that the click_pos is valid
2007-05-28 16:07:30 +00:00
editor_insert_multiline_comment ( idx ) ;
2007-01-06 15:03:53 +00:00
}
void
on_comments_gpl_activate ( GtkMenuItem * menuitem ,
gpointer user_data )
{
gint idx = document_get_cur_idx ( ) ;
gchar * text ;
2007-01-06 15:38:44 +00:00
text = templates_get_template_licence ( FILETYPE_ID ( doc_list [ idx ] . file_type ) , GEANY_TEMPLATE_GPL ) ;
2006-05-10 19:54:44 +00:00
2006-12-17 19:31:32 +00:00
verify_click_pos ( idx ) ; // make sure that the click_pos is valid
2006-09-04 15:57:46 +00:00
sci_insert_text ( doc_list [ idx ] . 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
2005-11-22 12:26:26 +00:00
gint idx = document_get_cur_idx ( ) ;
gchar * text ;
2007-01-06 15:03:53 +00:00
text = templates_get_template_licence ( FILETYPE_ID ( doc_list [ idx ] . file_type ) , GEANY_TEMPLATE_BSD ) ;
2006-05-10 19:54:44 +00:00
2006-12-17 19:31:32 +00:00
verify_click_pos ( idx ) ; // make sure that the click_pos is valid
2006-09-04 15:57:46 +00:00
sci_insert_text ( doc_list [ idx ] . 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 )
{
gint idx = document_get_cur_idx ( ) ;
gchar * text ;
text = templates_get_template_changelog ( ) ;
sci_insert_text ( doc_list [ idx ] . sci , 0 , text ) ;
// sets the cursor to the right position to type the changelog text,
// the template has 21 chars + length of name and email
2006-02-26 18:29:24 +00:00
sci_goto_pos ( doc_list [ idx ] . sci , 21 + strlen ( app - > pref_template_developer ) + strlen ( app - > pref_template_mail ) , TRUE ) ;
2005-11-22 12:26:26 +00:00
g_free ( text ) ;
}
void
on_comments_fileheader_activate ( GtkMenuItem * menuitem ,
gpointer user_data )
{
gint idx = document_get_cur_idx ( ) ;
gchar * text ;
2006-05-22 15:28:48 +00:00
2006-11-14 16:03:25 +00:00
text = templates_get_template_fileheader ( idx ) ;
2006-05-10 19:54:44 +00:00
2005-11-22 12:26:26 +00:00
sci_insert_text ( doc_list [ idx ] . sci , 0 , text ) ;
2006-02-26 18:29:24 +00:00
sci_goto_pos ( doc_list [ idx ] . sci , 0 , FALSE ) ;
2005-11-22 12:26:26 +00:00
g_free ( text ) ;
}
2006-08-19 12:56:30 +00:00
void
on_custom_date_dialog_response ( GtkDialog * dialog ,
gint response ,
gpointer user_data )
{
if ( response = = GTK_RESPONSE_ACCEPT )
{
g_free ( app - > custom_date_format ) ;
app - > custom_date_format = g_strdup ( gtk_entry_get_text ( GTK_ENTRY ( user_data ) ) ) ;
}
gtk_widget_destroy ( GTK_WIDGET ( dialog ) ) ;
}
void
on_custom_date_entry_activate ( GtkEntry * entry ,
gpointer user_data )
{
on_custom_date_dialog_response ( GTK_DIALOG ( user_data ) , GTK_RESPONSE_ACCEPT , entry ) ;
}
void
on_insert_date_activate ( GtkMenuItem * menuitem ,
gpointer user_data )
{
gint idx = document_get_cur_idx ( ) ;
gchar * format ;
gchar time_str [ 300 ] ; // the entered format string can be maximal 256 chars long, so we have
// 44 additional characters for strtime's conversion
time_t t ;
struct tm * tm ;
if ( idx < 0 | | ! doc_list [ idx ] . is_valid ) return ;
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 " ;
2006-12-12 12:12:20 +00:00
else if ( utils_str_equal ( _ ( " Use Custom Date Format " ) , ( gchar * ) user_data ) )
2006-08-19 12:56:30 +00:00
format = app - > custom_date_format ;
else
{
// set default value
2006-12-13 15:18:49 +00:00
if ( utils_str_equal ( " " , app - > custom_date_format ) )
{
g_free ( app - > custom_date_format ) ;
app - > custom_date_format = g_strdup ( " %d.%m.%Y " ) ;
}
2006-08-19 12:56:30 +00:00
2006-12-12 12:12:20 +00:00
dialogs_show_input ( _ ( " Custom Date Format " ) ,
2006-09-01 15:48:56 +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. See \" man strftime \" for more information. " ) ,
2006-08-19 12:56:30 +00:00
app - > custom_date_format ,
G_CALLBACK ( on_custom_date_dialog_response ) ,
G_CALLBACK ( on_custom_date_entry_activate ) ) ;
return ;
}
// get the current time
t = time ( NULL ) ;
tm = localtime ( & t ) ;
if ( strftime ( time_str , sizeof time_str , format , tm ) ! = 0 )
{
2006-12-17 19:31:32 +00:00
verify_click_pos ( idx ) ; // make sure that the click_pos is valid
2006-09-04 15:57:46 +00:00
sci_insert_text ( doc_list [ idx ] . sci , editor_info . click_pos , time_str ) ;
2006-08-19 12:56:30 +00:00
}
else
{
utils_beep ( ) ;
msgwin_status_add (
_ ( " 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 )
{
2006-12-17 19:31:32 +00:00
gint idx = document_get_cur_idx ( ) ;
gint pos = - 1 ;
2005-11-22 12:26:26 +00:00
gchar * text ;
2006-12-17 19:31:32 +00:00
if ( ! DOC_IDX_VALID ( idx ) | | user_data = = NULL ) return ;
verify_click_pos ( idx ) ; // make sure that the click_pos is valid
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 ) ;
}
2006-09-04 15:57:46 +00:00
sci_insert_text ( doc_list [ idx ] . 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 )
sci_goto_pos ( doc_list [ idx ] . sci , pos , FALSE ) ;
2005-11-22 12:26:26 +00:00
}
void
on_file_open_check_hidden_toggled ( GtkToggleButton * togglebutton ,
gpointer user_data )
{
gboolean is_on = gtk_toggle_button_get_active ( togglebutton ) ;
2006-02-10 21:02:54 +00:00
gtk_file_chooser_set_show_hidden ( GTK_FILE_CHOOSER ( app - > open_filesel ) , is_on ) ;
2005-11-22 12:26:26 +00:00
}
2005-12-18 22:38:57 +00:00
2006-02-14 22:07:55 +00:00
void
on_file_properties_activate ( GtkMenuItem * menuitem ,
gpointer user_data )
{
2006-02-20 22:55:53 +00:00
gint idx = document_get_cur_idx ( ) ;
dialogs_show_file_properties ( idx ) ;
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 )
{
gint idx = document_get_cur_idx ( ) ;
document_fold_all ( idx ) ;
}
void
on_menu_unfold_all1_activate ( GtkMenuItem * menuitem ,
gpointer user_data )
{
gint idx = document_get_cur_idx ( ) ;
document_unfold_all ( idx ) ;
}
2006-04-27 18:06:35 +00:00
void
on_run_button_clicked ( GtkToolButton * toolbutton ,
gpointer user_data )
{
on_build_execute_activate ( NULL , NULL ) ;
}
2006-05-23 19:31:09 +00:00
void
on_go_to_line1_activate ( GtkMenuItem * menuitem ,
gpointer user_data )
{
// this is search menu cb; call popup menu goto cb
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 )
{
gint idx = document_get_cur_idx ( ) ;
2007-02-17 18:06:08 +00:00
if ( ! DOC_IDX_VALID ( idx ) )
return ;
2006-06-13 20:03:44 +00:00
document_clear_indicators ( idx ) ;
}
2006-06-19 18:31:17 +00:00
void
on_encoding_change ( GtkMenuItem * menuitem ,
gpointer user_data )
{
gint idx = document_get_cur_idx ( ) ;
guint i = GPOINTER_TO_INT ( user_data ) ;
2006-06-29 14:00:09 +00:00
2006-10-10 16:02:41 +00:00
if ( app - > ignore_callback | | ! DOC_IDX_VALID ( idx ) | | encodings [ i ] . charset = = NULL | |
2006-12-07 16:09:45 +00:00
utils_str_equal ( encodings [ i ] . charset , doc_list [ idx ] . encoding ) ) return ;
2006-06-19 18:31:17 +00:00
2006-10-23 20:56:11 +00:00
if ( doc_list [ idx ] . readonly )
{
utils_beep ( ) ;
return ;
}
2006-10-10 16:02:41 +00:00
document_undo_add ( idx , UNDO_ENCODING , g_strdup ( doc_list [ idx ] . encoding ) ) ;
document_set_encoding ( idx , 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 )
{
gint idx = document_get_cur_idx ( ) ;
document_print ( idx ) ;
}
2006-06-30 13:42:53 +00:00
void
on_menu_select_all1_activate ( GtkMenuItem * menuitem ,
gpointer user_data )
{
gint idx = document_get_cur_idx ( ) ;
if ( idx < 0 | | ! doc_list [ idx ] . is_valid ) return ;
sci_select_all ( doc_list [ idx ] . sci ) ;
}
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 ;
2006-07-21 11:41:33 +00:00
if ( app - > ignore_callback ) return ;
2007-05-06 14:49:51 +00:00
if ( app - > sidebar_visible )
{
// 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)
active_page = gtk_notebook_get_current_page ( GTK_NOTEBOOK ( app - > treeview_notebook ) ) ;
}
2006-07-21 11:41:33 +00:00
app - > sidebar_visible = ! app - > sidebar_visible ;
2007-05-06 14:49:51 +00:00
if ( ( ! app - > sidebar_openfiles_visible & & ! app - > sidebar_symbol_visible ) )
2006-07-22 11:09:48 +00:00
{
app - > sidebar_openfiles_visible = TRUE ;
2007-05-06 14:49:51 +00:00
app - > sidebar_symbol_visible = TRUE ;
2006-07-22 11:09:48 +00:00
}
2007-05-06 14:49:51 +00:00
2006-09-05 14:24:47 +00:00
ui_treeviews_show_hide ( TRUE ) ;
2007-05-06 14:49:51 +00:00
gtk_notebook_set_current_page ( GTK_NOTEBOOK ( app - > treeview_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 )
{
if ( ! app - > ignore_callback )
{
gint idx = document_get_cur_idx ( ) ;
if ( idx = = - 1 | | ! doc_list [ idx ] . is_valid ) return ;
2006-10-23 20:56:11 +00:00
if ( doc_list [ idx ] . readonly )
{
utils_beep ( ) ;
return ;
}
2006-07-24 20:23:56 +00:00
2006-10-10 16:02:41 +00:00
document_undo_add ( idx , UNDO_BOM , GINT_TO_POINTER ( doc_list [ idx ] . has_bom ) ) ;
2006-07-24 20:23:56 +00:00
doc_list [ idx ] . has_bom = ! doc_list [ idx ] . has_bom ;
2006-09-05 14:24:47 +00:00
ui_update_statusbar ( idx , - 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 )
{
gint idx = document_get_cur_idx ( ) ;
if ( idx = = - 1 | | ! doc_list [ idx ] . is_valid ) return ;
2007-05-28 16:07:30 +00:00
editor_do_comment ( idx , - 1 , FALSE ) ;
2006-08-01 10:35:32 +00:00
}
void
on_menu_uncomment_line1_activate ( GtkMenuItem * menuitem ,
gpointer user_data )
{
gint idx = document_get_cur_idx ( ) ;
if ( idx = = - 1 | | ! doc_list [ idx ] . is_valid ) return ;
2007-05-28 16:07:30 +00:00
editor_do_uncomment ( idx , - 1 ) ;
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 )
{
gint idx = document_get_cur_idx ( ) ;
if ( idx = = - 1 | | ! doc_list [ idx ] . is_valid ) return ;
2007-05-28 16:07:30 +00:00
editor_do_comment_toggle ( idx ) ;
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 )
{
gint idx = document_get_cur_idx ( ) ;
if ( idx = = - 1 | | ! doc_list [ idx ] . is_valid ) return ;
if ( sci_can_copy ( doc_list [ idx ] . sci ) )
sci_selection_duplicate ( doc_list [ idx ] . sci ) ;
else
sci_line_duplicate ( doc_list [ idx ] . sci ) ;
}
void
on_menu_increase_indent1_activate ( GtkMenuItem * menuitem ,
gpointer user_data )
{
gint idx = document_get_cur_idx ( ) ;
2007-05-08 16:03:07 +00:00
if ( ! DOC_IDX_VALID ( idx ) ) return ;
2006-08-01 10:35:32 +00:00
2006-09-21 10:31:06 +00:00
if ( sci_get_lines_selected ( doc_list [ idx ] . sci ) > 1 )
2006-08-15 08:51:48 +00:00
{
sci_cmd ( doc_list [ idx ] . sci , SCI_TAB ) ;
}
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
old_pos = sci_get_current_position ( doc_list [ idx ] . sci ) ;
line = sci_get_current_line ( doc_list [ idx ] . sci , old_pos ) ;
2006-12-11 12:26:10 +00:00
ind_pos = sci_get_line_indent_position ( doc_list [ idx ] . sci , line ) ;
2007-05-08 16:03:07 +00:00
// when using tabs increase cur pos by 1, when using space increase it by tab_width
2007-05-29 16:30:54 +00:00
step = ( editor_prefs . 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
2007-01-27 18:45:47 +00:00
sci_set_current_position ( doc_list [ idx ] . sci , ind_pos , TRUE ) ;
2006-08-15 08:51:48 +00:00
sci_cmd ( doc_list [ idx ] . sci , SCI_TAB ) ;
2007-05-08 16:03:07 +00:00
sci_set_current_position ( doc_list [ idx ] . 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 )
{
gint idx = document_get_cur_idx ( ) ;
2007-05-08 16:03:07 +00:00
if ( ! DOC_IDX_VALID ( idx ) ) return ;
2006-08-01 10:35:32 +00:00
2006-09-21 10:31:06 +00:00
if ( sci_get_lines_selected ( doc_list [ idx ] . sci ) > 1 )
2006-08-15 08:51:48 +00:00
{
sci_cmd ( doc_list [ idx ] . sci , SCI_BACKTAB ) ;
}
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
old_pos = sci_get_current_position ( doc_list [ idx ] . sci ) ;
line = sci_get_current_line ( doc_list [ idx ] . sci , old_pos ) ;
2006-12-11 12:26:10 +00:00
ind_pos = sci_get_line_indent_position ( doc_list [ idx ] . sci , line ) ;
2007-05-29 16:30:54 +00:00
step = ( editor_prefs . 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
2006-12-11 12:26:10 +00:00
if ( ind_pos = = sci_get_position_from_line ( doc_list [ idx ] . sci , line ) )
return ;
2007-05-08 16:03:07 +00:00
2007-01-27 18:45:47 +00:00
sci_set_current_position ( doc_list [ idx ] . sci , ind_pos , TRUE ) ;
2007-05-08 16:03:07 +00:00
indent = sci_get_line_indentation ( doc_list [ idx ] . 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 ;
sci_set_line_indentation ( doc_list [ idx ] . sci , line , indent ) ;
sci_set_current_position ( doc_list [ idx ] . 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 ) )
ui_set_statusbar ( _ ( " No more message items. " ) ) ;
}
2006-12-13 00:46:14 +00:00
void
on_menu_insert_special_chars1_activate ( GtkMenuItem * menuitem ,
gpointer user_data )
{
2007-01-24 19:20:12 +00:00
// refuse opening the dialog if we don't have an active tab
gint idx = document_get_cur_idx ( ) ;
if ( idx = = - 1 | | ! doc_list [ idx ] . is_valid ) return ;
2006-12-13 00:46:14 +00:00
tools_show_dialog_insert_special_chars ( ) ;
}
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 )
{
project_close ( ) ;
}
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 )
{
item_close = lookup_widget ( app - > window , " project_close1 " ) ;
item_properties = lookup_widget ( app - > window , " project_properties1 " ) ;
}
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 )
{
gint idx = document_get_cur_idx ( ) ;
gchar * filename = NULL ;
if ( idx = = - 1 | | ! doc_list [ idx ] . is_valid ) return ;
if ( sci_get_lines_selected ( doc_list [ idx ] . sci ) = = 1 )
{
filename = g_malloc ( sci_get_selected_text_length ( doc_list [ idx ] . sci ) ) ;
sci_get_selected_text ( doc_list [ idx ] . sci , filename ) ;
}
else if ( sci_get_lines_selected ( doc_list [ idx ] . sci ) = = 0 )
{ // use the word at current cursor position
gchar word [ GEANY_MAX_WORD_LENGTH ] ;
2007-05-28 16:07:30 +00:00
editor_find_current_word ( doc_list [ idx ] . sci , - 1 , word , sizeof ( word ) , GEANY_WORDCHARS " ./ " ) ;
2007-01-24 19:20:12 +00:00
if ( word [ 0 ] ! = ' \0 ' )
filename = g_strdup ( word ) ;
}
if ( filename ! = NULL )
{
gchar * locale_filename ;
if ( ! g_path_is_absolute ( filename ) )
{ // relative filename, add the path of the current file
gchar * path ;
gchar * tmp = filename ;
// use the projects base path if we have an open project (useful?)
if ( app - > project ! = NULL & & app - > project - > base_path ! = NULL )
path = g_strdup ( app - > project - > base_path ) ;
else
path = g_path_get_dirname ( doc_list [ idx ] . file_name ) ;
filename = g_strconcat ( path , G_DIR_SEPARATOR_S , filename , NULL ) ;
g_free ( tmp ) ;
g_free ( path ) ;
}
locale_filename = utils_get_locale_from_utf8 ( filename ) ;
document_open_file ( - 1 , locale_filename , 0 , FALSE , NULL , NULL ) ;
g_free ( filename ) ;
g_free ( locale_filename ) ;
}
}
2007-02-17 18:06:08 +00:00
void
on_remove_markers1_activate ( GtkMenuItem * menuitem ,
gpointer user_data )
{
gint idx = document_get_cur_idx ( ) ;
if ( ! DOC_IDX_VALID ( idx ) )
return ;
sci_marker_delete_all ( doc_list [ idx ] . sci , 0 ) ; // delete the yellow tag marker
sci_marker_delete_all ( doc_list [ idx ] . sci , 1 ) ; // delete user markers
}
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 )
{
gint idx ;
gchar * word , * command ;
GError * error = NULL ;
idx = document_get_cur_idx ( ) ;
if ( ! DOC_IDX_VALID ( idx ) ) return ;
if ( sci_can_copy ( doc_list [ idx ] . sci ) )
{ // take selected text if there is a selection
word = g_malloc ( sci_get_selected_text_length ( doc_list [ idx ] . sci ) + 1 ) ;
sci_get_selected_text ( doc_list [ idx ] . sci , word ) ;
}
else
{
word = g_strdup ( editor_info . current_word ) ;
}
// use the filetype specific command if available, fallback to global command otherwise
if ( doc_list [ idx ] . file_type ! = NULL & &
doc_list [ idx ] . file_type - > context_action_cmd ! = NULL & &
* doc_list [ idx ] . file_type - > context_action_cmd ! = ' \0 ' )
{
command = g_strdup ( doc_list [ idx ] . file_type - > context_action_cmd ) ;
}
else
{
command = g_strdup ( app - > context_action_cmd ) ;
}
// substitute the wildcard %s and run the command if it is non empty
if ( command ! = NULL & & * command ! = ' \0 ' )
{
command = utils_str_replace ( command , " %s " , word ) ;
if ( ! g_spawn_command_line_async ( command , & error ) )
{
msgwin_status_add ( " Context action command failed: %s " , error - > message ) ;
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 ;
GtkCheckMenuItem * msgw = GTK_CHECK_MENU_ITEM ( lookup_widget ( app - > window , " menu_show_messages_window1 " ) ) ;
GtkCheckMenuItem * toolbari = GTK_CHECK_MENU_ITEM ( lookup_widget ( app - > window , " menu_show_toolbar1 " ) ) ;
// get the initial state (necessary if Geany was closed with hide_all = TRUE)
if ( hide_all = = - 1 )
{
if ( ! gtk_check_menu_item_get_active ( msgw ) & &
2007-05-15 13:02:23 +00:00
! app - > 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 ;
}
hide_all = ! hide_all ; // toggle
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 ) ) ;
2007-05-15 13:02:23 +00:00
app - > show_notebook_tabs = FALSE ;
gtk_notebook_set_show_tabs ( GTK_NOTEBOOK ( app - > notebook ) , app - > 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 ) ) ;
2007-05-15 13:02:23 +00:00
app - > show_notebook_tabs = TRUE ;
gtk_notebook_set_show_tabs ( GTK_NOTEBOOK ( app - > notebook ) , app - > 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 )
{
if ( app - > auto_focus & & ! GTK_WIDGET_HAS_FOCUS ( widget ) )
gtk_widget_grab_focus ( widget ) ;
return FALSE ;
}
2007-06-14 13:10:51 +00:00
void
on_menu_create_cpp_class_activate ( GtkMenuItem * menuitem ,
gpointer user_data )
{
tools_show_dialog_create_class ( GEANY_CLASS_TYPE_CPP ) ;
}
void
on_menu_create_gtk_class_activate ( GtkMenuItem * menuitem ,
gpointer user_data )
{
tools_show_dialog_create_class ( GEANY_CLASS_TYPE_GTK ) ;
}