2005-11-22 12:26:26 +00:00
/*
* prefs . c - this file is part of Geany , a fast and lightweight IDE
*
2012-06-18 01:13:05 +02:00
* Copyright 2005 - 2012 Enrico Tröger < enrico ( dot ) troeger ( at ) uvena ( dot ) de >
* Copyright 2006 - 2012 Nick Treleaven < nick ( dot ) treleaven ( at ) btinternet ( dot ) com >
2005-11-22 12:26:26 +00:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 2 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
2012-08-24 19:25:57 +02:00
* You should have received a copy of the GNU General Public License along
* with this program ; if not , write to the Free Software Foundation , Inc . ,
* 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 USA .
2005-11-22 12:26:26 +00:00
*/
2010-03-18 13:13:11 +00:00
/*
* @ file prefs . h
* Preferences dialog .
*/
2007-02-24 11:41:56 +00:00
/*
* Preferences dialog support functions .
2010-10-21 16:19:06 +00:00
* New ' simple ' prefs should use Stash code in keyfile . c - init_pref_groups ( ) .
2007-02-24 11:41:56 +00:00
*/
2005-11-22 12:26:26 +00:00
2014-05-18 17:31:51 -07:00
# ifdef HAVE_CONFIG_H
# include "config.h"
# endif
2005-11-22 12:26:26 +00:00
# include "prefs.h"
2014-05-18 17:31:51 -07:00
# include "app.h"
2006-05-30 19:19:05 +00:00
# include "dialogs.h"
2008-06-02 15:31:59 +00:00
# include "documentprivate.h"
2007-05-29 16:30:54 +00:00
# include "editor.h"
2014-05-18 17:31:51 -07:00
# include "encodings.h"
# include "filetypes.h"
2008-01-09 13:24:36 +00:00
# include "geanywraplabel.h"
2014-05-18 17:31:51 -07:00
# include "keybindingsprivate.h"
# include "keyfile.h"
# include "msgwindow.h"
# include "prefs.h"
# include "printing.h"
# include "sidebar.h"
# include "stash.h"
# include "support.h"
2008-05-16 12:08:39 +00:00
# include "templates.h"
2008-12-06 11:10:06 +00:00
# include "toolbar.h"
2011-04-03 15:53:48 +00:00
# include "tools.h"
2014-05-18 17:31:51 -07:00
# include "ui_utils.h"
# include "utils.h"
# include "vte.h"
2006-06-16 19:58:26 +00:00
2014-05-18 17:31:51 -07:00
# include "gtkcompat.h"
# include <stdlib.h>
# include <string.h>
# include <gdk/gdkkeysyms.h>
2005-11-22 12:26:26 +00:00
2006-11-24 11:47:29 +00:00
2007-08-23 11:34:06 +00:00
GeanyPrefs prefs ;
2008-05-16 12:08:39 +00:00
GeanyToolPrefs tool_prefs ;
2007-08-23 11:34:06 +00:00
2008-04-23 16:53:40 +00:00
2014-08-10 14:57:33 +02:00
typedef struct
{
GtkTreeStore * store ;
GtkTreeView * tree ;
gboolean edited ;
}
KbData ;
2006-05-19 17:18:06 +00:00
2014-08-10 15:28:29 +02:00
static KbData global_kb_data = { NULL , NULL , FALSE } ;
2011-09-21 16:03:11 +00:00
static GtkTreeView * various_treeview = NULL ;
2012-04-04 13:37:31 +01:00
static GeanyKeyBinding * kb_index ( guint gidx , guint kid ) ;
2014-08-10 14:57:33 +02:00
static void kb_cell_edited_cb ( GtkCellRendererText * cellrenderertext , gchar * path , gchar * new_text , KbData * kbdata ) ;
2014-08-10 15:28:29 +02:00
static gboolean kb_grab_key_dialog_key_press_cb ( GtkWidget * dialog , GdkEventKey * event , GtkLabel * label ) ;
static void kb_change_iter_shortcut ( KbData * kbdata , GtkTreeIter * iter , const gchar * new_text ) ;
2014-08-10 14:57:33 +02:00
static gboolean kb_find_duplicate ( GtkTreeStore * store , GtkWidget * parent , GtkTreeIter * old_iter ,
2010-10-22 12:27:11 +00:00
guint key , GdkModifierType mods , const gchar * shortcut ) ;
2007-01-26 10:43:25 +00:00
static void on_toolbar_show_toggled ( GtkToggleButton * togglebutton , gpointer user_data ) ;
static void on_show_notebook_tabs_toggled ( GtkToggleButton * togglebutton , gpointer user_data ) ;
2009-03-13 10:02:29 +00:00
static void on_enable_plugins_toggled ( GtkToggleButton * togglebutton , gpointer user_data ) ;
2007-01-26 10:43:25 +00:00
static void on_use_folding_toggled ( GtkToggleButton * togglebutton , gpointer user_data ) ;
2007-06-26 15:41:27 +00:00
static void on_open_encoding_toggled ( GtkToggleButton * togglebutton , gpointer user_data ) ;
2009-12-31 15:48:39 +00:00
static void on_sidebar_visible_toggled ( GtkToggleButton * togglebutton , gpointer user_data ) ;
2007-11-17 14:04:27 +00:00
static void on_prefs_print_radio_button_toggled ( GtkToggleButton * togglebutton , gpointer user_data ) ;
static void on_prefs_print_page_header_toggled ( GtkToggleButton * togglebutton , gpointer user_data ) ;
2011-05-27 21:00:41 +00:00
static void open_preferences_help ( void ) ;
2005-11-22 12:26:26 +00:00
2008-07-28 13:42:14 +00:00
typedef enum PrefCallbackAction
{
PREF_DISPLAY ,
PREF_UPDATE
}
PrefCallbackAction ;
2008-12-22 16:03:16 +00:00
/* Synchronize Stash settings with widgets (see keyfile.c - init_pref_groups()). */
2008-07-29 17:46:21 +00:00
static void prefs_action ( PrefCallbackAction action )
{
2010-03-18 17:04:17 +00:00
StashGroup * group ;
2009-07-20 12:25:24 +00:00
guint i ;
2008-12-11 12:49:26 +00:00
2009-07-20 12:25:24 +00:00
foreach_ptr_array ( group , i , pref_groups )
2008-12-11 12:49:26 +00:00
{
switch ( action )
{
case PREF_DISPLAY :
stash_group_display ( group , ui_widgets . prefs_dialog ) ;
break ;
case PREF_UPDATE :
stash_group_update ( group , ui_widgets . prefs_dialog ) ;
break ;
}
}
2011-07-28 17:59:22 +00:00
2011-09-21 15:50:36 +00:00
switch ( action )
2011-07-28 17:59:22 +00:00
{
2011-09-21 15:50:36 +00:00
case PREF_DISPLAY :
2011-10-17 18:03:56 +01:00
stash_tree_display ( various_treeview ) ;
2011-09-21 15:50:36 +00:00
break ;
case PREF_UPDATE :
2011-10-17 18:03:56 +01:00
stash_tree_update ( various_treeview ) ;
2011-09-21 15:50:36 +00:00
break ;
2011-07-28 17:59:22 +00:00
}
2008-07-29 17:46:21 +00:00
}
2007-11-08 15:58:11 +00:00
enum
{
KB_TREE_ACTION ,
KB_TREE_SHORTCUT ,
2011-04-03 15:54:28 +00:00
KB_TREE_INDEX ,
2012-04-03 16:56:32 +01:00
KB_TREE_EDITABLE ,
KB_TREE_WEIGHT ,
KB_TREE_COLUMNS
2007-11-08 15:58:11 +00:00
} ;
2009-06-20 16:52:58 +00:00
2014-08-10 14:57:33 +02:00
static void kb_tree_view_change_button_clicked_cb ( GtkWidget * button , KbData * kbdata )
2009-06-20 16:53:12 +00:00
{
GtkTreeModel * model ;
2014-08-10 15:28:29 +02:00
GtkTreeIter iter ;
2009-06-20 16:53:12 +00:00
GtkTreeSelection * selection ;
gchar * name ;
2014-08-10 14:57:33 +02:00
selection = gtk_tree_view_get_selection ( kbdata - > tree ) ;
2014-08-10 15:28:29 +02:00
if ( gtk_tree_selection_get_selected ( selection , & model , & iter ) )
2009-06-20 16:53:12 +00:00
{
2014-08-10 15:28:29 +02:00
if ( gtk_tree_model_iter_has_child ( model , & iter ) )
2009-06-20 16:53:12 +00:00
{ /* double click on a section to expand or collapse it */
2014-08-10 15:28:29 +02:00
GtkTreePath * path = gtk_tree_model_get_path ( model , & iter ) ;
2009-06-20 16:53:12 +00:00
2014-08-10 14:57:33 +02:00
if ( gtk_tree_view_row_expanded ( kbdata - > tree , path ) )
gtk_tree_view_collapse_row ( kbdata - > tree , path ) ;
2009-06-20 16:53:12 +00:00
else
2014-08-10 14:57:33 +02:00
gtk_tree_view_expand_row ( kbdata - > tree , path , FALSE ) ;
2009-06-20 16:53:12 +00:00
gtk_tree_path_free ( path ) ;
return ;
}
2014-08-10 15:28:29 +02:00
gtk_tree_model_get ( model , & iter , KB_TREE_ACTION , & name , - 1 ) ;
2009-06-20 16:53:12 +00:00
if ( name ! = NULL )
{
GtkWidget * dialog ;
GtkWidget * label ;
2014-08-10 15:28:29 +02:00
GtkWidget * accel_label ;
2009-06-20 16:53:12 +00:00
gchar * str ;
dialog = gtk_dialog_new_with_buttons ( _ ( " Grab Key " ) , GTK_WINDOW ( ui_widgets . prefs_dialog ) ,
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR ,
GTK_STOCK_CANCEL , GTK_RESPONSE_CANCEL ,
GTK_STOCK_OK , GTK_RESPONSE_ACCEPT , NULL ) ;
str = g_strdup_printf (
_ ( " Press the combination of the keys you want to use for \" %s \" . " ) , name ) ;
label = gtk_label_new ( str ) ;
gtk_misc_set_padding ( GTK_MISC ( label ) , 5 , 10 ) ;
2012-09-11 16:48:57 +02:00
gtk_container_add ( GTK_CONTAINER ( gtk_dialog_get_content_area ( GTK_DIALOG ( dialog ) ) ) , label ) ;
2009-06-20 16:53:12 +00:00
2014-08-10 15:28:29 +02:00
accel_label = gtk_label_new ( " " ) ;
gtk_misc_set_padding ( GTK_MISC ( accel_label ) , 5 , 10 ) ;
gtk_container_add ( GTK_CONTAINER ( gtk_dialog_get_content_area ( GTK_DIALOG ( dialog ) ) ) , accel_label ) ;
2009-06-20 16:53:12 +00:00
g_signal_connect ( dialog , " key-press-event " ,
2014-08-10 15:28:29 +02:00
G_CALLBACK ( kb_grab_key_dialog_key_press_cb ) , accel_label ) ;
2009-06-20 16:53:12 +00:00
gtk_widget_show_all ( dialog ) ;
2014-08-10 15:28:29 +02:00
if ( gtk_dialog_run ( GTK_DIALOG ( dialog ) ) = = GTK_RESPONSE_ACCEPT )
{
const gchar * new_text = gtk_label_get_text ( GTK_LABEL ( accel_label ) ) ;
kb_change_iter_shortcut ( kbdata , & iter , new_text ) ;
}
gtk_widget_destroy ( dialog ) ;
2009-06-20 16:53:12 +00:00
g_free ( str ) ;
g_free ( name ) ;
}
}
}
2014-08-10 14:57:33 +02:00
static void kb_show_popup_menu ( KbData * kbdata , GtkWidget * widget , GdkEventButton * event )
2009-06-20 16:52:58 +00:00
{
GtkWidget * item ;
static GtkWidget * menu = NULL ;
2011-12-17 23:10:03 +01:00
guint button ;
guint32 event_time ;
2009-06-20 16:52:58 +00:00
if ( menu = = NULL )
{
menu = gtk_menu_new ( ) ;
item = ui_image_menu_item_new ( GTK_STOCK_ADD , _ ( " _Expand All " ) ) ;
gtk_widget_show ( item ) ;
gtk_container_add ( GTK_CONTAINER ( menu ) , item ) ;
2014-08-10 14:57:33 +02:00
g_signal_connect_swapped ( item , " activate " , G_CALLBACK ( gtk_tree_view_expand_all ) , kbdata - > tree ) ;
2009-06-20 16:52:58 +00:00
item = ui_image_menu_item_new ( GTK_STOCK_REMOVE , _ ( " _Collapse All " ) ) ;
gtk_widget_show ( item ) ;
gtk_container_add ( GTK_CONTAINER ( menu ) , item ) ;
2014-08-10 14:57:33 +02:00
g_signal_connect_swapped ( item , " activate " , G_CALLBACK ( gtk_tree_view_collapse_all ) , kbdata - > tree ) ;
2009-06-20 16:52:58 +00:00
gtk_menu_attach_to_widget ( GTK_MENU ( menu ) , widget , NULL ) ;
}
if ( event ! = NULL )
{
button = event - > button ;
event_time = event - > time ;
}
else
{
button = 0 ;
event_time = gtk_get_current_event_time ( ) ;
}
gtk_menu_popup ( GTK_MENU ( menu ) , NULL , NULL , NULL , NULL , button , event_time ) ;
}
2014-08-10 14:57:33 +02:00
static gboolean kb_popup_menu_cb ( GtkWidget * widget , KbData * kbdata )
2009-06-20 16:52:58 +00:00
{
2014-08-10 14:57:33 +02:00
kb_show_popup_menu ( kbdata , widget , NULL ) ;
2009-06-20 16:52:58 +00:00
return TRUE ;
}
2009-06-20 16:53:12 +00:00
static gboolean kb_tree_view_button_press_event_cb ( GtkWidget * widget , GdkEventButton * event ,
2014-08-10 14:57:33 +02:00
KbData * kbdata )
2009-06-20 16:53:12 +00:00
{
if ( event - > button = = 3 & & event - > type = = GDK_BUTTON_PRESS )
{
2014-08-10 14:57:33 +02:00
kb_show_popup_menu ( kbdata , widget , event ) ;
2009-06-20 16:53:12 +00:00
return TRUE ;
}
else if ( event - > type = = GDK_2BUTTON_PRESS )
{
2014-08-10 14:57:33 +02:00
kb_tree_view_change_button_clicked_cb ( NULL , kbdata ) ;
2009-06-20 16:53:12 +00:00
return TRUE ;
}
return FALSE ;
}
2014-08-10 14:57:33 +02:00
static void kb_init_tree ( KbData * kbdata )
2007-11-08 15:58:11 +00:00
{
GtkCellRenderer * renderer ;
GtkTreeViewColumn * column ;
2014-08-10 14:57:33 +02:00
kbdata - > tree = GTK_TREE_VIEW ( ui_lookup_widget ( ui_widgets . prefs_dialog , " treeview7 " ) ) ;
2007-11-08 15:58:11 +00:00
2014-08-10 14:57:33 +02:00
kbdata - > store = gtk_tree_store_new ( KB_TREE_COLUMNS ,
2012-04-03 16:56:32 +01:00
G_TYPE_STRING , G_TYPE_STRING , G_TYPE_INT , G_TYPE_BOOLEAN , G_TYPE_INT ) ;
2014-08-10 14:57:33 +02:00
gtk_tree_view_set_model ( GTK_TREE_VIEW ( kbdata - > tree ) , GTK_TREE_MODEL ( kbdata - > store ) ) ;
g_object_unref ( kbdata - > store ) ;
2007-11-08 15:58:11 +00:00
renderer = gtk_cell_renderer_text_new ( ) ;
2012-04-03 16:56:32 +01:00
column = gtk_tree_view_column_new_with_attributes ( _ ( " Action " ) , renderer ,
" text " , KB_TREE_ACTION , " weight " , KB_TREE_WEIGHT , NULL ) ;
2014-08-10 14:57:33 +02:00
gtk_tree_view_append_column ( GTK_TREE_VIEW ( kbdata - > tree ) , column ) ;
2007-11-08 15:58:11 +00:00
renderer = gtk_cell_renderer_text_new ( ) ;
2011-04-03 15:54:28 +00:00
column = gtk_tree_view_column_new_with_attributes ( _ ( " Shortcut " ) , renderer ,
2012-04-03 16:56:32 +01:00
" text " , KB_TREE_SHORTCUT , " editable " , KB_TREE_EDITABLE ,
" weight " , KB_TREE_WEIGHT , NULL ) ;
2014-08-10 14:57:33 +02:00
gtk_tree_view_append_column ( GTK_TREE_VIEW ( kbdata - > tree ) , column ) ;
2007-11-08 15:58:11 +00:00
2010-08-10 12:25:35 +00:00
/* set policy settings for the scrolled window around the treeview again, because glade
2008-02-27 13:17:29 +00:00
* doesn ' t keep the settings */
2007-11-08 15:58:11 +00:00
gtk_scrolled_window_set_policy (
2008-12-18 21:21:53 +00:00
GTK_SCROLLED_WINDOW ( ui_lookup_widget ( ui_widgets . prefs_dialog , " scrolledwindow8 " ) ) ,
2007-11-08 15:58:11 +00:00
GTK_POLICY_NEVER , GTK_POLICY_AUTOMATIC ) ;
2014-08-10 14:57:33 +02:00
g_signal_connect ( renderer , " edited " , G_CALLBACK ( kb_cell_edited_cb ) , kbdata ) ;
g_signal_connect ( kbdata - > tree , " button-press-event " , G_CALLBACK ( kb_tree_view_button_press_event_cb ) , kbdata ) ;
g_signal_connect ( kbdata - > tree , " popup-menu " , G_CALLBACK ( kb_popup_menu_cb ) , kbdata ) ;
2008-12-18 21:21:53 +00:00
g_signal_connect ( ui_lookup_widget ( ui_widgets . prefs_dialog , " button2 " ) , " clicked " ,
2014-08-10 14:57:33 +02:00
G_CALLBACK ( kb_tree_view_change_button_clicked_cb ) , kbdata ) ;
2007-11-08 15:58:11 +00:00
}
2012-04-04 13:37:31 +01:00
static void kb_set_shortcut ( GtkTreeStore * store , GtkTreeIter * iter ,
guint key , GdkModifierType mods )
{
gchar * key_string = gtk_accelerator_name ( key , mods ) ;
GtkTreeIter parent ;
guint kid , gid ;
GeanyKeyBinding * kb ;
gboolean bold ;
gtk_tree_store_set ( store , iter , KB_TREE_SHORTCUT , key_string , - 1 ) ;
g_free ( key_string ) ;
gtk_tree_model_get ( GTK_TREE_MODEL ( store ) , iter , KB_TREE_INDEX , & kid , - 1 ) ;
gtk_tree_model_iter_parent ( GTK_TREE_MODEL ( store ) , & parent , iter ) ;
gtk_tree_model_get ( GTK_TREE_MODEL ( store ) , & parent , KB_TREE_INDEX , & gid , - 1 ) ;
kb = kb_index ( gid , kid ) ;
bold = key ! = kb - > default_key | | mods ! = kb - > default_mods ;
gtk_tree_store_set ( store , iter , KB_TREE_WEIGHT ,
bold ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL , - 1 ) ;
}
2013-05-19 20:00:01 +04:00
void prefs_kb_search_name ( const gchar * search )
{
GtkTreeIter iter ;
gboolean valid ;
GtkTreeModel * model ;
2014-08-10 14:57:33 +02:00
KbData * kbdata = & global_kb_data ;
2013-06-01 01:56:31 +02:00
2014-08-10 14:57:33 +02:00
model = gtk_tree_view_get_model ( kbdata - > tree ) ;
2013-05-19 20:00:01 +04:00
valid = gtk_tree_model_get_iter_first ( model , & iter ) ;
while ( valid )
{
2013-06-01 01:56:31 +02:00
gchar * name ;
2013-05-19 20:00:01 +04:00
gtk_tree_model_get ( model , & iter , KB_TREE_ACTION , & name , - 1 ) ;
2013-06-01 01:56:31 +02:00
if ( g_strcmp0 ( name , search ) = = 0 )
2013-05-19 20:00:01 +04:00
{
GtkTreePath * path = gtk_tree_model_get_path ( model , & iter ) ;
2014-08-10 14:57:33 +02:00
gtk_tree_view_scroll_to_cell ( kbdata - > tree , path , NULL , TRUE , .0f , .0f ) ;
2013-05-19 20:00:01 +04:00
gtk_tree_path_free ( path ) ;
2013-06-01 01:56:31 +02:00
g_free ( name ) ;
2013-05-19 20:00:01 +04:00
break ;
}
2013-06-01 01:56:31 +02:00
g_free ( name ) ;
2013-05-19 20:00:01 +04:00
valid = gtk_tree_model_iter_next ( model , & iter ) ;
}
}
2014-08-10 14:57:33 +02:00
static void kb_init ( KbData * kbdata )
2007-11-08 15:58:11 +00:00
{
GtkTreeIter parent , iter ;
2008-02-29 19:30:28 +00:00
gsize g , i ;
2012-04-04 13:37:31 +01:00
gchar * label ;
2009-04-05 21:07:40 +00:00
GeanyKeyGroup * group ;
GeanyKeyBinding * kb ;
2007-11-08 15:58:11 +00:00
2014-08-10 14:57:33 +02:00
if ( kbdata - > store = = NULL )
kb_init_tree ( kbdata ) ;
2007-11-08 15:58:11 +00:00
2010-08-10 12:43:30 +00:00
foreach_ptr_array ( group , g , keybinding_groups )
2007-11-08 15:58:11 +00:00
{
2014-08-10 14:57:33 +02:00
gtk_tree_store_append ( kbdata - > store , & parent , NULL ) ;
gtk_tree_store_set ( kbdata - > store , & parent , KB_TREE_ACTION , group - > label ,
2008-02-29 19:30:28 +00:00
KB_TREE_INDEX , g , - 1 ) ;
2010-08-10 12:43:30 +00:00
foreach_ptr_array ( kb , i , group - > key_items )
2007-11-08 15:58:11 +00:00
{
2009-10-29 11:59:55 +00:00
label = keybindings_get_label ( kb ) ;
2014-08-10 14:57:33 +02:00
gtk_tree_store_append ( kbdata - > store , & iter , & parent ) ;
gtk_tree_store_set ( kbdata - > store , & iter , KB_TREE_ACTION , label ,
2012-04-04 13:37:31 +01:00
KB_TREE_EDITABLE , TRUE , KB_TREE_INDEX , kb - > id , - 1 ) ;
2014-08-10 14:57:33 +02:00
kb_set_shortcut ( kbdata - > store , & iter , kb - > key , kb - > mods ) ;
2009-10-29 11:59:55 +00:00
g_free ( label ) ;
2007-11-08 15:58:11 +00:00
}
}
2014-08-10 14:57:33 +02:00
gtk_tree_view_expand_all ( GTK_TREE_VIEW ( kbdata - > tree ) ) ;
2007-11-08 15:58:11 +00:00
}
2010-10-21 16:19:06 +00:00
/* note: new 'simple' prefs should use Stash code in keyfile.c */
2008-12-27 13:20:42 +00:00
static void prefs_init_dialog ( void )
2005-11-22 12:26:26 +00:00
{
GtkWidget * widget ;
2013-12-04 14:59:05 +01:00
GdkColor color = { 0 } ;
2005-11-22 12:26:26 +00:00
2008-12-22 16:03:16 +00:00
/* Synchronize with Stash settings */
2008-07-29 17:46:21 +00:00
prefs_action ( PREF_DISPLAY ) ;
2008-06-25 11:56:58 +00:00
2008-12-27 13:20:42 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " label_project_indent_warning " ) ;
ui_widget_show_hide ( widget , app - > project ! = NULL ) ;
2008-02-27 13:17:29 +00:00
/* General settings */
/* startup */
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_load_session " ) ;
2007-08-23 11:34:06 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , prefs . load_session ) ;
2005-11-22 12:26:26 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_project_session " ) ;
2008-01-16 16:30:34 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , project_prefs . project_session ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_project_file_in_basedir " ) ;
2008-10-02 15:09:33 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , project_prefs . project_file_in_basedir ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_save_win_pos " ) ;
2007-08-23 11:34:06 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , prefs . save_winpos ) ;
2005-11-22 12:26:26 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_ask_for_quit " ) ;
2007-08-23 11:34:06 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , prefs . confirm_exit ) ;
2007-08-16 15:20:38 +00:00
2008-02-27 13:17:29 +00:00
/* behaviour */
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_beep " ) ;
2007-08-23 11:34:06 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , prefs . beep_on_errors ) ;
2006-01-03 12:39:25 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_switch_pages " ) ;
2008-05-16 12:08:39 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , prefs . switch_to_status ) ;
2005-11-24 22:28:45 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_suppress_status_msgs " ) ;
2007-08-23 11:34:06 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , prefs . suppress_status_messages ) ;
2007-08-05 11:03:44 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_auto_focus " ) ;
2007-08-23 11:34:06 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , prefs . auto_focus ) ;
2007-06-11 08:58:37 +00:00
2010-05-16 18:22:24 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_native_windows_dialogs " ) ;
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) ,
interface_prefs . use_native_windows_dialogs ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " entry_contextaction " ) ;
2008-05-16 12:08:39 +00:00
gtk_entry_set_text ( GTK_ENTRY ( widget ) , tool_prefs . context_action_cmd ) ;
2007-04-15 18:09:59 +00:00
2008-02-27 13:17:29 +00:00
project_setup_prefs ( ) ; /* project files path */
2007-04-29 16:36:42 +00:00
2006-07-02 16:21:35 +00:00
2008-02-27 13:17:29 +00:00
/* Interface settings */
2009-12-31 15:48:39 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_sidebar_visible " ) ;
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , ui_prefs . sidebar_visible ) ;
on_sidebar_visible_toggled ( GTK_TOGGLE_BUTTON ( widget ) , NULL ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_list_symbol " ) ;
2008-05-16 12:08:39 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , interface_prefs . sidebar_symbol_visible ) ;
2005-12-11 02:16:02 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_list_openfiles " ) ;
2008-05-16 12:08:39 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , interface_prefs . sidebar_openfiles_visible ) ;
2005-11-22 12:26:26 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " tagbar_font " ) ;
2008-05-16 12:08:39 +00:00
gtk_font_button_set_font_name ( GTK_FONT_BUTTON ( widget ) , interface_prefs . tagbar_font ) ;
2005-11-22 12:26:26 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " msgwin_font " ) ;
2008-05-16 12:08:39 +00:00
gtk_font_button_set_font_name ( GTK_FONT_BUTTON ( widget ) , interface_prefs . msgwin_font ) ;
2005-11-22 12:26:26 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " editor_font " ) ;
2008-05-16 12:08:39 +00:00
gtk_font_button_set_font_name ( GTK_FONT_BUTTON ( widget ) , interface_prefs . editor_font ) ;
2006-07-02 16:21:35 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " spin_long_line " ) ;
2010-11-23 17:36:29 +00:00
gtk_spin_button_set_value ( GTK_SPIN_BUTTON ( widget ) , editor_prefs . long_line_column ) ;
2006-07-02 16:21:35 +00:00
2010-03-10 16:20:34 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_long_line " ) ;
2010-11-23 17:36:29 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , editor_prefs . long_line_enabled ) ;
2010-03-10 16:20:34 +00:00
2010-11-23 17:36:29 +00:00
switch ( editor_prefs . long_line_type )
2006-07-02 16:21:35 +00:00
{
2008-12-18 21:21:53 +00:00
case 0 : widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " radio_long_line_line " ) ; break ;
case 1 : widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " radio_long_line_background " ) ; break ;
2006-07-02 16:21:35 +00:00
}
2006-04-27 18:01:44 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , TRUE ) ;
2013-12-04 15:31:17 +01:00
utils_parse_color ( editor_prefs . long_line_color , & color ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " long_line_color " ) ;
2013-12-04 14:59:05 +01:00
gtk_color_button_set_color ( GTK_COLOR_BUTTON ( widget ) , & color ) ;
2006-07-02 16:21:35 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_show_notebook_tabs " ) ;
2008-05-16 12:08:39 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , interface_prefs . show_notebook_tabs ) ;
2008-02-27 13:17:29 +00:00
/* disable following setting if notebook tabs are hidden */
2007-04-29 16:36:42 +00:00
on_show_notebook_tabs_toggled ( GTK_TOGGLE_BUTTON (
2008-12-18 21:21:53 +00:00
ui_lookup_widget ( ui_widgets . prefs_dialog , " check_show_notebook_tabs " ) ) , NULL ) ;
2007-04-29 16:36:42 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_show_tab_cross " ) ;
2008-05-16 12:08:39 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , file_prefs . show_tab_cross ) ;
2007-08-25 14:16:52 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " combo_tab_editor " ) ;
2008-05-16 12:08:39 +00:00
gtk_combo_box_set_active ( GTK_COMBO_BOX ( widget ) , interface_prefs . tab_pos_editor ) ;
2006-07-02 16:21:35 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " combo_tab_msgwin " ) ;
2008-05-16 12:08:39 +00:00
gtk_combo_box_set_active ( GTK_COMBO_BOX ( widget ) , interface_prefs . tab_pos_msgwin ) ;
2006-07-02 16:21:35 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " combo_tab_sidebar " ) ;
2008-05-16 12:08:39 +00:00
gtk_combo_box_set_active ( GTK_COMBO_BOX ( widget ) , interface_prefs . tab_pos_sidebar ) ;
2006-07-02 16:21:35 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_statusbar_visible " ) ;
2008-05-16 12:08:39 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , interface_prefs . statusbar_visible ) ;
2007-04-10 17:06:57 +00:00
2005-11-22 12:26:26 +00:00
2008-02-27 13:17:29 +00:00
/* Toolbar settings */
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_toolbar_show " ) ;
2008-05-16 12:08:39 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , toolbar_prefs . visible ) ;
2009-03-29 16:15:35 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_toolbar_in_menu " ) ;
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , toolbar_prefs . append_to_menu ) ;
2006-07-11 14:15:56 +00:00
2008-05-16 12:08:39 +00:00
switch ( toolbar_prefs . icon_style )
2006-07-11 14:15:56 +00:00
{
2008-12-18 21:21:53 +00:00
case 0 : widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " radio_toolbar_image " ) ; break ;
case 1 : widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " radio_toolbar_text " ) ; break ;
default : widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " radio_toolbar_imagetext " ) ; break ;
2006-07-11 14:15:56 +00:00
}
2010-04-11 21:56:08 +00:00
if ( toolbar_prefs . use_gtk_default_style )
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " radio_toolbar_style_default " ) ;
2006-07-11 14:15:56 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , TRUE ) ;
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-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " radio_toolbar_large " ) ; break ;
2009-03-29 16:15:35 +00:00
case GTK_ICON_SIZE_SMALL_TOOLBAR :
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " radio_toolbar_small " ) ; break ;
default : widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " radio_toolbar_verysmall " ) ; break ;
2006-07-11 14:15:56 +00:00
}
2010-04-11 21:56:08 +00:00
if ( toolbar_prefs . use_gtk_default_icon )
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " radio_toolbar_icon_default " ) ;
2006-07-11 14:15:56 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , TRUE ) ;
2009-03-29 16:15:35 +00:00
2008-02-27 13:17:29 +00:00
/* disable elements if toolbar is hidden */
2007-01-26 10:43:25 +00:00
on_toolbar_show_toggled ( GTK_TOGGLE_BUTTON (
2008-12-18 21:21:53 +00:00
ui_lookup_widget ( ui_widgets . prefs_dialog , " check_toolbar_show " ) ) , NULL ) ;
2006-07-11 14:15:56 +00:00
2008-02-27 13:17:29 +00:00
/* Files settings */
2008-05-16 12:08:39 +00:00
if ( file_prefs . tab_order_ltr )
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " radio_tab_right " ) ;
2007-04-29 16:36:42 +00:00
else
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " radio_tab_left " ) ;
2007-04-29 16:36:42 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , TRUE ) ;
2010-05-16 17:45:39 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_tab_beside " ) ;
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , file_prefs . tab_order_beside ) ;
2007-04-29 16:36:42 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " combo_new_encoding " ) ;
2014-01-17 21:56:51 +01:00
ui_encodings_combo_box_set_active_encoding ( GTK_COMBO_BOX ( widget ) , file_prefs . default_new_encoding ) ;
2007-06-26 15:41:27 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_open_encoding " ) ;
2007-06-26 15:41:27 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) ,
2008-05-16 12:08:39 +00:00
( file_prefs . default_open_encoding > = 0 ) ? TRUE : FALSE ) ;
2007-06-26 15:41:27 +00:00
on_open_encoding_toggled ( GTK_TOGGLE_BUTTON ( widget ) , NULL ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " combo_open_encoding " ) ;
2008-05-16 12:08:39 +00:00
if ( file_prefs . default_open_encoding > = 0 )
2007-06-26 15:41:27 +00:00
{
2014-01-17 21:56:51 +01:00
ui_encodings_combo_box_set_active_encoding ( GTK_COMBO_BOX ( widget ) , file_prefs . default_open_encoding ) ;
2007-06-26 15:41:27 +00:00
}
else
2014-01-17 21:56:51 +01:00
ui_encodings_combo_box_set_active_encoding ( GTK_COMBO_BOX ( widget ) , GEANY_ENCODING_UTF_8 ) ;
2006-06-21 18:54:07 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " combo_eol " ) ;
2008-05-16 12:08:39 +00:00
if ( file_prefs . default_eol_character > = 0 & & file_prefs . default_eol_character < 3 )
2008-05-14 15:36:27 +00:00
{
2008-05-16 12:08:39 +00:00
gtk_combo_box_set_active ( GTK_COMBO_BOX ( widget ) , file_prefs . default_eol_character ) ;
2008-05-14 15:36:27 +00:00
}
else
gtk_combo_box_set_active ( GTK_COMBO_BOX ( widget ) , GEANY_DEFAULT_EOL_CHARACTER ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_trailing_spaces " ) ;
2008-05-16 12:08:39 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , file_prefs . strip_trailing_spaces ) ;
2005-11-22 12:26:26 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_new_line " ) ;
2008-05-16 12:08:39 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , file_prefs . final_new_line ) ;
2005-11-22 12:26:26 +00:00
2010-10-25 16:24:55 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_ensure_convert_new_lines " ) ;
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , file_prefs . ensure_convert_new_lines ) ;
2008-05-14 15:36:27 +00:00
/* Editor settings */
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " entry_toggle_mark " ) ;
2008-07-27 18:41:07 +00:00
gtk_entry_set_text ( GTK_ENTRY ( widget ) , editor_prefs . comment_toggle_mark ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_replace_tabs " ) ;
2008-05-16 12:08:39 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , file_prefs . replace_tabs ) ;
2006-06-21 18:54:07 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_indent " ) ;
2007-05-29 16:30:54 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , editor_prefs . show_indent_guide ) ;
2006-02-14 22:07:55 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_white_space " ) ;
2007-05-29 16:30:54 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , editor_prefs . show_white_space ) ;
2006-02-14 22:07:55 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_line_end " ) ;
2007-05-29 16:30:54 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , editor_prefs . show_line_endings ) ;
2006-02-14 22:07:55 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_line_numbers " ) ;
2008-12-07 19:12:08 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , editor_prefs . show_linenumber_margin ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_markers_margin " ) ;
2008-12-07 19:12:08 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , editor_prefs . show_markers_margin ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_scroll_stop_at_last_line " ) ;
2008-09-01 11:18:06 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , editor_prefs . scroll_stop_at_last_line ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_line_wrapping " ) ;
2007-08-24 16:20:33 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , editor_prefs . line_wrapping ) ;
2006-02-14 22:07:55 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_complete_snippets " ) ;
2007-11-12 09:27:43 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , editor_prefs . complete_snippets ) ;
2006-02-14 22:07:55 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_xmltag " ) ;
2007-05-29 16:30:54 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , editor_prefs . auto_close_xml_tags ) ;
2006-08-01 10:06:28 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_folding " ) ;
2007-05-29 16:30:54 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , editor_prefs . folding ) ;
2006-02-26 18:19:28 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_unfold_children " ) ;
2007-05-29 16:30:54 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , editor_prefs . unfold_all_children ) ;
2007-01-26 10:43:25 +00:00
on_use_folding_toggled ( GTK_TOGGLE_BUTTON (
2008-12-18 21:21:53 +00:00
ui_lookup_widget ( ui_widgets . prefs_dialog , " check_folding " ) ) , NULL ) ;
2006-12-03 22:33:46 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_disable_dnd " ) ;
2007-05-29 16:30:54 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , editor_prefs . disable_dnd ) ;
2007-01-13 20:50:36 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_smart_home " ) ;
2007-07-12 15:44:13 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , editor_prefs . smart_home_key ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_newline_strip " ) ;
2007-10-18 11:52:47 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , editor_prefs . newline_strip ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_indicators " ) ;
2007-05-29 16:30:54 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , editor_prefs . use_indicators ) ;
2006-06-13 19:37:21 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_auto_multiline " ) ;
2008-05-14 15:36:27 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , editor_prefs . auto_continue_multiline ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_symbol_auto_completion " ) ;
2007-05-29 16:30:54 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , editor_prefs . auto_complete_symbols ) ;
2007-01-26 10:43:25 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " spin_symbollistheight " ) ;
2007-11-12 09:27:43 +00:00
gtk_spin_button_set_value ( GTK_SPIN_BUTTON ( widget ) , editor_prefs . symbolcompletion_max_height ) ;
2006-08-13 15:04:30 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " spin_symbol_complete_chars " ) ;
2007-12-01 17:53:36 +00:00
gtk_spin_button_set_value ( GTK_SPIN_BUTTON ( widget ) , editor_prefs . symbolcompletion_min_chars ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " spin_line_break " ) ;
2008-05-09 12:13:29 +00:00
gtk_spin_button_set_value ( GTK_SPIN_BUTTON ( widget ) , editor_prefs . line_break_column ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_autoclose_parenthesis " ) ;
2008-12-04 20:19:20 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) ,
( editor_prefs . autoclose_chars & GEANY_AC_PARENTHESIS ) ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_autoclose_cbracket " ) ;
2008-12-04 20:19:20 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) ,
( editor_prefs . autoclose_chars & GEANY_AC_CBRACKET ) ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_autoclose_sbracket " ) ;
2008-12-04 20:19:20 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) ,
( editor_prefs . autoclose_chars & GEANY_AC_SBRACKET ) ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_autoclose_squote " ) ;
2008-12-04 20:19:20 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) ,
( editor_prefs . autoclose_chars & GEANY_AC_SQUOTE ) ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_autoclose_dquote " ) ;
2008-12-04 20:19:20 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) ,
( editor_prefs . autoclose_chars & GEANY_AC_DQUOTE ) ) ;
2005-11-22 12:26:26 +00:00
2008-02-27 13:17:29 +00:00
/* Tools Settings */
2007-11-01 12:54:38 +00:00
2011-08-06 18:34:14 +00:00
if ( tool_prefs . term_cmd )
gtk_entry_set_text ( GTK_ENTRY ( ui_lookup_widget ( ui_widgets . prefs_dialog , " entry_com_term " ) ) , tool_prefs . term_cmd ) ;
2006-09-11 11:13:36 +00:00
2008-05-16 12:08:39 +00:00
if ( tool_prefs . browser_cmd )
2008-12-18 21:21:53 +00:00
gtk_entry_set_text ( GTK_ENTRY ( ui_lookup_widget ( ui_widgets . prefs_dialog , " entry_browser " ) ) , tool_prefs . browser_cmd ) ;
2005-11-22 12:26:26 +00:00
2008-05-16 12:08:39 +00:00
if ( tool_prefs . grep_cmd )
2008-12-18 21:21:53 +00:00
gtk_entry_set_text ( GTK_ENTRY ( ui_lookup_widget ( ui_widgets . prefs_dialog , " entry_grep " ) ) , tool_prefs . grep_cmd ) ;
2006-07-13 14:30:44 +00:00
2005-11-22 12:26:26 +00:00
2008-02-27 13:17:29 +00:00
/* Template settings */
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " entry_template_developer " ) ;
2008-05-16 12:08:39 +00:00
gtk_entry_set_text ( GTK_ENTRY ( widget ) , template_prefs . developer ) ;
2005-11-22 12:26:26 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " entry_template_company " ) ;
2008-05-16 12:08:39 +00:00
gtk_entry_set_text ( GTK_ENTRY ( widget ) , template_prefs . company ) ;
2005-11-22 12:26:26 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " entry_template_mail " ) ;
2008-05-16 12:08:39 +00:00
gtk_entry_set_text ( GTK_ENTRY ( widget ) , template_prefs . mail ) ;
2005-11-22 12:26:26 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " entry_template_initial " ) ;
2008-05-16 12:08:39 +00:00
gtk_entry_set_text ( GTK_ENTRY ( widget ) , template_prefs . initials ) ;
2005-11-22 12:26:26 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " entry_template_version " ) ;
2008-05-16 12:08:39 +00:00
gtk_entry_set_text ( GTK_ENTRY ( widget ) , template_prefs . version ) ;
2005-12-11 02:16:02 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " entry_template_year " ) ;
2008-07-13 11:51:00 +00:00
gtk_entry_set_text ( GTK_ENTRY ( widget ) , template_prefs . year_format ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " entry_template_date " ) ;
2008-07-13 11:51:00 +00:00
gtk_entry_set_text ( GTK_ENTRY ( widget ) , template_prefs . date_format ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " entry_template_datetime " ) ;
2008-07-13 11:51:00 +00:00
gtk_entry_set_text ( GTK_ENTRY ( widget ) , template_prefs . datetime_format ) ;
2005-12-11 02:16:02 +00:00
2008-02-27 13:17:29 +00:00
/* Keybindings */
2014-08-10 14:57:33 +02:00
kb_init ( & global_kb_data ) ;
2006-05-19 17:18:06 +00:00
2008-02-27 13:17:29 +00:00
/* Printing */
2007-11-17 14:04:27 +00:00
{
2008-12-18 21:21:53 +00:00
GtkWidget * widget_gtk = ui_lookup_widget ( ui_widgets . prefs_dialog , " radio_print_gtk " ) ;
2007-11-17 14:04:27 +00:00
if ( printing_prefs . use_gtk_printing )
widget = widget_gtk ;
else
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " radio_print_external " ) ;
2007-11-17 14:04:27 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , TRUE ) ;
on_prefs_print_radio_button_toggled ( GTK_TOGGLE_BUTTON ( widget_gtk ) , NULL ) ;
}
if ( printing_prefs . external_print_cmd )
gtk_entry_set_text (
2008-12-18 21:21:53 +00:00
GTK_ENTRY ( ui_lookup_widget ( ui_widgets . prefs_dialog , " entry_print_external_cmd " ) ) ,
2007-11-17 14:04:27 +00:00
printing_prefs . external_print_cmd ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_print_linenumbers " ) ;
2007-11-17 14:04:27 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , printing_prefs . print_line_numbers ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_print_pagenumbers " ) ;
2007-11-17 14:04:27 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , printing_prefs . print_page_numbers ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_print_pageheader " ) ;
2007-11-17 14:04:27 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , printing_prefs . print_page_header ) ;
on_prefs_print_page_header_toggled ( GTK_TOGGLE_BUTTON ( widget ) , NULL ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_print_basename " ) ;
2007-11-17 14:04:27 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , printing_prefs . page_header_basename ) ;
if ( printing_prefs . page_header_datefmt )
gtk_entry_set_text (
2008-12-18 21:21:53 +00:00
GTK_ENTRY ( ui_lookup_widget ( ui_widgets . prefs_dialog , " entry_print_dateformat " ) ) ,
2007-11-17 14:04:27 +00:00
printing_prefs . page_header_datefmt ) ;
2007-08-16 15:20:38 +00:00
# ifndef HAVE_PLUGINS
2008-12-18 21:21:53 +00:00
gtk_widget_set_sensitive ( ui_lookup_widget ( ui_widgets . prefs_dialog , " check_plugins " ) , FALSE ) ;
2007-08-16 15:20:38 +00:00
# endif
2009-03-13 10:02:29 +00:00
on_enable_plugins_toggled ( GTK_TOGGLE_BUTTON ( ui_lookup_widget ( ui_widgets . prefs_dialog , " check_plugins " ) ) , NULL ) ;
2007-08-16 15:20:38 +00:00
2005-12-11 02:16:02 +00:00
# ifdef HAVE_VTE
2008-02-27 13:17:29 +00:00
/* make VTE switch visible only when VTE is compiled in, it is hidden by default */
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_vte " ) ;
2006-05-22 00:25:19 +00:00
gtk_widget_show ( widget ) ;
2006-08-19 15:07:11 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , vte_info . load_vte ) ;
2006-05-22 00:25:19 +00:00
2008-02-27 13:17:29 +00:00
/* VTE settings */
2006-08-19 15:07:11 +00:00
if ( vte_info . have_vte )
2005-12-16 22:34:41 +00:00
{
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " font_term " ) ;
2005-12-16 22:34:41 +00:00
gtk_font_button_set_font_name ( GTK_FONT_BUTTON ( widget ) , vc - > font ) ;
2005-12-11 02:16:02 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " color_fore " ) ;
2013-12-05 20:16:54 +01:00
gtk_color_button_set_color ( GTK_COLOR_BUTTON ( widget ) , & vc - > colour_fore ) ;
2005-12-11 02:16:02 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " color_back " ) ;
2013-12-05 20:16:54 +01:00
gtk_color_button_set_color ( GTK_COLOR_BUTTON ( widget ) , & vc - > colour_back ) ;
2005-12-11 02:16:02 +00:00
2012-12-18 10:26:48 +01:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " entry_image " ) ;
gtk_entry_set_text ( GTK_ENTRY ( widget ) , vc - > image ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " spin_scrollback " ) ;
2005-12-16 22:34:41 +00:00
gtk_spin_button_set_value ( GTK_SPIN_BUTTON ( widget ) , vc - > scrollback_lines ) ;
2005-12-11 02:16:02 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " entry_shell " ) ;
2006-08-23 16:37:05 +00:00
gtk_entry_set_text ( GTK_ENTRY ( widget ) , vc - > shell ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_scroll_key " ) ;
2005-12-16 22:34:41 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , vc - > scroll_on_key ) ;
2005-12-11 02:16:02 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_scroll_out " ) ;
2005-12-16 22:34:41 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , vc - > scroll_on_out ) ;
2006-07-02 18:34:03 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_enable_bash_keys " ) ;
2008-01-10 17:11:19 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , vc - > enable_bash_keys ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_ignore_menu_key " ) ;
2006-08-23 16:37:05 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , vc - > ignore_menu_bar_accel ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_follow_path " ) ;
2006-07-02 18:34:03 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , vc - > follow_path ) ;
2006-12-10 21:29:04 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_run_in_vte " ) ;
2006-12-10 21:29:04 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , vc - > run_in_vte ) ;
2007-12-17 16:58:26 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_skip_script " ) ;
2007-12-17 16:58:26 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , vc - > skip_run_script ) ;
2008-12-07 19:11:36 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_cursor_blinks " ) ;
2008-12-07 19:11:36 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( widget ) , vc - > cursor_blinks ) ;
2005-12-16 22:34:41 +00:00
}
2005-12-11 02:16:02 +00:00
# endif
2005-11-22 12:26:26 +00:00
}
2011-10-03 14:57:02 +00:00
/* note: uses group index, not group id, unlike keybindings_lookup_item(). */
static GeanyKeyBinding * kb_index ( guint gidx , guint kid )
{
GeanyKeyGroup * group ;
group = g_ptr_array_index ( keybinding_groups , gidx ) ;
return keybindings_get_item ( group , kid ) ;
}
2010-10-22 12:20:37 +00:00
/* read the treeview shortcut fields into keybindings */
2014-08-10 14:57:33 +02:00
static void kb_update ( KbData * kbdata )
2010-10-22 12:20:37 +00:00
{
2014-08-10 14:57:33 +02:00
GtkTreeModel * model = GTK_TREE_MODEL ( kbdata - > store ) ;
2010-10-22 12:20:37 +00:00
GtkTreeIter child , parent ;
guint gid = 0 ;
/* get first parent */
if ( ! gtk_tree_model_iter_children ( model , & parent , NULL ) )
return ;
/* foreach parent */
while ( TRUE )
{
/* get first child */
if ( ! gtk_tree_model_iter_children ( model , & child , & parent ) )
return ;
/* foreach child */
while ( TRUE )
{
guint kid ;
gchar * str ;
guint key ;
GdkModifierType mods ;
GeanyKeyBinding * kb ;
gtk_tree_model_get ( model , & child , KB_TREE_INDEX , & kid , KB_TREE_SHORTCUT , & str , - 1 ) ;
gtk_accelerator_parse ( str , & key , & mods ) ;
g_free ( str ) ;
2011-10-03 14:57:02 +00:00
kb = kb_index ( gid , kid ) ;
2010-10-22 12:20:37 +00:00
if ( kb - > key ! = key | | kb - > mods ! = mods )
keybindings_update_combo ( kb , key , mods ) ;
if ( ! gtk_tree_model_iter_next ( model , & child ) )
break ;
}
if ( ! gtk_tree_model_iter_next ( model , & parent ) )
return ;
gid + + ;
}
}
2005-11-22 12:26:26 +00:00
/*
* callbacks
*/
2010-10-21 16:19:06 +00:00
/* note: new 'simple' prefs should use Stash code in keyfile.c */
2007-08-23 11:34:06 +00:00
static void
2010-10-21 16:19:06 +00:00
on_prefs_dialog_response ( GtkDialog * dialog , gint response , gpointer user_data )
2005-11-22 12:26:26 +00:00
{
2006-10-29 01:28:58 +00:00
if ( response = = GTK_RESPONSE_OK | | response = = GTK_RESPONSE_APPLY )
2005-11-22 12:26:26 +00:00
{
GtkWidget * widget ;
2006-10-09 16:08:53 +00:00
guint i ;
2011-12-17 23:10:03 +01:00
gboolean autoclose_brackets [ 5 ] ;
2009-09-14 11:53:08 +00:00
gboolean old_invert_all = interface_prefs . highlighting_invert_all ;
2009-10-23 16:18:05 +00:00
gboolean old_sidebar_pos = interface_prefs . sidebar_pos ;
2011-07-28 17:59:22 +00:00
GeanyDocument * doc = document_get_current ( ) ;
2005-11-22 12:26:26 +00:00
2008-12-22 16:03:16 +00:00
/* Synchronize Stash settings */
2008-07-29 17:46:21 +00:00
prefs_action ( PREF_UPDATE ) ;
2008-06-25 11:56:58 +00:00
2009-09-14 11:53:08 +00:00
if ( interface_prefs . highlighting_invert_all ! = old_invert_all )
filetypes_reload ( ) ;
2009-10-23 16:18:05 +00:00
if ( interface_prefs . sidebar_pos ! = old_sidebar_pos )
ui_swap_sidebar_pos ( ) ;
2012-09-26 19:30:18 +02:00
widget = ui_lookup_widget ( main_widgets . window , " vpaned1 " ) ;
gtk_orientable_set_orientation ( GTK_ORIENTABLE ( widget ) , interface_prefs . msgwin_orientation ) ;
2008-02-27 13:17:29 +00:00
/* General settings */
/* startup */
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_load_session " ) ;
2007-08-23 11:34:06 +00:00
prefs . load_session = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2005-11-22 12:26:26 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_project_session " ) ;
2008-01-16 16:30:34 +00:00
project_prefs . project_session = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_project_file_in_basedir " ) ;
2008-10-02 15:09:33 +00:00
project_prefs . project_file_in_basedir = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_save_win_pos " ) ;
2007-08-23 11:34:06 +00:00
prefs . save_winpos = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2005-11-22 12:26:26 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_ask_for_quit " ) ;
2007-08-23 11:34:06 +00:00
prefs . confirm_exit = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2005-11-22 12:26:26 +00:00
2008-02-27 13:17:29 +00:00
/* behaviour */
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_beep " ) ;
2007-08-23 11:34:06 +00:00
prefs . beep_on_errors = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2007-08-16 15:20:38 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_switch_pages " ) ;
2008-05-16 12:08:39 +00:00
prefs . switch_to_status = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2005-11-24 22:28:45 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_suppress_status_msgs " ) ;
2007-08-23 11:34:06 +00:00
prefs . suppress_status_messages = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2008-03-23 16:29:43 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_auto_focus " ) ;
2007-08-23 11:34:06 +00:00
prefs . auto_focus = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2007-06-11 08:58:37 +00:00
2010-05-16 18:22:24 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_native_windows_dialogs " ) ;
interface_prefs . use_native_windows_dialogs =
gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " entry_contextaction " ) ;
2008-05-16 12:08:39 +00:00
g_free ( tool_prefs . context_action_cmd ) ;
tool_prefs . context_action_cmd = g_strdup ( gtk_entry_get_text ( GTK_ENTRY ( widget ) ) ) ;
2007-04-15 18:09:59 +00:00
2008-02-27 13:17:29 +00:00
project_apply_prefs ( ) ; /* project file path */
2007-04-29 16:36:42 +00:00
2006-07-02 16:21:35 +00:00
2008-02-27 13:17:29 +00:00
/* Interface settings */
2009-12-31 15:48:39 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_sidebar_visible " ) ;
ui_prefs . sidebar_visible = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_list_symbol " ) ;
2008-05-16 12:08:39 +00:00
interface_prefs . sidebar_symbol_visible = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2005-12-11 02:16:02 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_list_openfiles " ) ;
2008-05-16 12:08:39 +00:00
interface_prefs . sidebar_openfiles_visible = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2005-11-22 12:26:26 +00:00
2010-03-10 16:20:34 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_long_line " ) ;
2010-11-23 17:36:29 +00:00
editor_prefs . long_line_enabled = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2010-03-10 16:20:34 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " radio_long_line_line " ) ;
2010-03-10 16:20:34 +00:00
if ( gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) )
2010-11-23 17:36:29 +00:00
editor_prefs . long_line_type = 0 ;
2006-07-02 16:21:35 +00:00
else
2010-03-10 16:20:34 +00:00
/* now only the "background" radio remains */
2010-11-23 17:36:29 +00:00
editor_prefs . long_line_type = 1 ;
2010-03-10 16:20:34 +00:00
2010-11-23 17:36:29 +00:00
if ( editor_prefs . long_line_column = = 0 )
editor_prefs . long_line_enabled = FALSE ;
2006-07-02 16:21:35 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_show_notebook_tabs " ) ;
2008-05-16 12:08:39 +00:00
interface_prefs . show_notebook_tabs = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2007-04-29 16:36:42 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_show_tab_cross " ) ;
2008-05-16 12:08:39 +00:00
file_prefs . show_tab_cross = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2007-08-25 14:16:52 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " combo_tab_editor " ) ;
2008-05-16 12:08:39 +00:00
interface_prefs . tab_pos_editor = gtk_combo_box_get_active ( GTK_COMBO_BOX ( widget ) ) ;
2006-07-02 16:21:35 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " combo_tab_msgwin " ) ;
2008-05-16 12:08:39 +00:00
interface_prefs . tab_pos_msgwin = gtk_combo_box_get_active ( GTK_COMBO_BOX ( widget ) ) ;
2006-07-02 16:21:35 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " combo_tab_sidebar " ) ;
2008-05-16 12:08:39 +00:00
interface_prefs . tab_pos_sidebar = gtk_combo_box_get_active ( GTK_COMBO_BOX ( widget ) ) ;
2006-05-19 17:18:06 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_statusbar_visible " ) ;
2008-05-16 12:08:39 +00:00
interface_prefs . statusbar_visible = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2007-04-10 17:06:57 +00:00
2005-11-24 22:28:45 +00:00
2008-02-27 13:17:29 +00:00
/* Toolbar settings */
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_toolbar_show " ) ;
2008-05-16 12:08:39 +00:00
toolbar_prefs . visible = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2009-03-29 16:15:35 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_toolbar_in_menu " ) ;
toolbar_prefs . append_to_menu = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2006-07-11 14:15:56 +00:00
2010-04-11 21:56:08 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " radio_toolbar_style_default " ) ;
toolbar_prefs . use_gtk_default_style = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
if ( ! toolbar_prefs . use_gtk_default_style )
2006-07-11 14:15:56 +00:00
{
2010-04-11 21:56:08 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " radio_toolbar_imagetext " ) ;
2006-07-11 14:15:56 +00:00
if ( gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) )
2010-04-11 21:56:08 +00:00
toolbar_prefs . icon_style = 2 ;
2006-07-11 14:15:56 +00:00
else
2010-04-11 21:56:08 +00:00
{
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " radio_toolbar_image " ) ;
if ( gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) )
toolbar_prefs . icon_style = 0 ;
else
/* now only the text only radio remains, so set text only */
toolbar_prefs . icon_style = 1 ;
}
2006-07-11 14:15:56 +00:00
}
2010-04-11 21:56:08 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " radio_toolbar_icon_default " ) ;
toolbar_prefs . use_gtk_default_icon = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
if ( ! toolbar_prefs . use_gtk_default_icon )
{ toolbar_prefs . icon_size = GTK_ICON_SIZE_LARGE_TOOLBAR ;
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " radio_toolbar_large " ) ;
2009-03-29 16:15:35 +00:00
if ( gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) )
2010-04-11 21:56:08 +00:00
toolbar_prefs . icon_size = GTK_ICON_SIZE_LARGE_TOOLBAR ;
2009-03-29 16:15:35 +00:00
else
2010-04-11 21:56:08 +00:00
{
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " radio_toolbar_small " ) ;
if ( gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) )
toolbar_prefs . icon_size = GTK_ICON_SIZE_SMALL_TOOLBAR ;
else
toolbar_prefs . icon_size = GTK_ICON_SIZE_MENU ;
}
2009-03-29 16:15:35 +00:00
}
2006-07-11 14:15:56 +00:00
2008-02-27 13:17:29 +00:00
/* Files settings */
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " radio_tab_right " ) ;
2008-05-16 12:08:39 +00:00
file_prefs . tab_order_ltr = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2007-04-29 16:36:42 +00:00
2010-05-16 17:45:39 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_tab_beside " ) ;
file_prefs . tab_order_beside = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " combo_new_encoding " ) ;
2014-01-17 21:56:51 +01:00
file_prefs . default_new_encoding = ui_encodings_combo_box_get_active_encoding ( GTK_COMBO_BOX ( widget ) ) ;
2007-06-26 15:41:27 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_open_encoding " ) ;
2007-06-26 15:41:27 +00:00
if ( gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) )
{
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " combo_open_encoding " ) ;
2014-01-17 21:56:51 +01:00
file_prefs . default_open_encoding = ui_encodings_combo_box_get_active_encoding ( GTK_COMBO_BOX ( widget ) ) ;
2007-06-26 15:41:27 +00:00
}
else
2008-05-16 12:08:39 +00:00
file_prefs . default_open_encoding = - 1 ;
2006-06-21 18:54:07 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " combo_eol " ) ;
2008-05-16 12:08:39 +00:00
file_prefs . default_eol_character = gtk_combo_box_get_active ( GTK_COMBO_BOX ( widget ) ) ;
2008-05-14 15:36:27 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_trailing_spaces " ) ;
2008-05-16 12:08:39 +00:00
file_prefs . strip_trailing_spaces = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2005-11-22 12:26:26 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_new_line " ) ;
2008-05-16 12:08:39 +00:00
file_prefs . final_new_line = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2005-11-22 12:26:26 +00:00
2010-10-25 16:24:55 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_ensure_convert_new_lines " ) ;
file_prefs . ensure_convert_new_lines = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_replace_tabs " ) ;
2008-05-16 12:08:39 +00:00
file_prefs . replace_tabs = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2006-06-21 18:54:07 +00:00
2008-05-14 15:36:27 +00:00
/* Editor settings */
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " entry_toggle_mark " ) ;
2012-01-25 16:26:16 +00:00
SETPTR ( editor_prefs . comment_toggle_mark ,
2008-07-27 18:41:07 +00:00
gtk_editable_get_chars ( GTK_EDITABLE ( widget ) , 0 , - 1 ) ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " spin_long_line " ) ;
2009-01-08 17:27:57 +00:00
/* note: use stash for new code - it updates spin buttons itself */
gtk_spin_button_update ( GTK_SPIN_BUTTON ( widget ) ) ;
2010-11-23 17:36:29 +00:00
editor_prefs . long_line_column = gtk_spin_button_get_value_as_int ( GTK_SPIN_BUTTON ( widget ) ) ;
2005-11-22 12:26:26 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_folding " ) ;
2007-05-29 16:30:54 +00:00
editor_prefs . folding = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2006-09-05 14:24:47 +00:00
ui_update_fold_items ( ) ;
2006-02-26 18:19:28 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_unfold_children " ) ;
2007-05-29 16:30:54 +00:00
editor_prefs . unfold_all_children = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2006-12-03 22:33:46 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_indent " ) ;
2007-05-29 16:30:54 +00:00
editor_prefs . show_indent_guide = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2006-02-26 18:19:28 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_white_space " ) ;
2007-05-29 16:30:54 +00:00
editor_prefs . show_white_space = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2006-02-26 18:19:28 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_line_end " ) ;
2007-05-29 16:30:54 +00:00
editor_prefs . show_line_endings = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2006-02-26 18:19:28 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_line_numbers " ) ;
2008-12-07 19:12:08 +00:00
editor_prefs . show_linenumber_margin = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_markers_margin " ) ;
2008-12-07 19:12:08 +00:00
editor_prefs . show_markers_margin = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_scroll_stop_at_last_line " ) ;
2008-09-01 11:18:06 +00:00
editor_prefs . scroll_stop_at_last_line = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_line_wrapping " ) ;
2007-08-24 16:20:33 +00:00
editor_prefs . line_wrapping = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2006-02-26 18:19:28 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_complete_snippets " ) ;
2007-11-12 09:27:43 +00:00
editor_prefs . complete_snippets = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2006-02-26 18:19:28 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_xmltag " ) ;
2007-05-29 16:30:54 +00:00
editor_prefs . auto_close_xml_tags = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2006-08-01 10:06:28 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_indicators " ) ;
2007-05-29 16:30:54 +00:00
editor_prefs . use_indicators = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2006-06-13 19:37:21 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_disable_dnd " ) ;
2007-05-29 16:30:54 +00:00
editor_prefs . disable_dnd = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2007-01-13 20:50:36 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_smart_home " ) ;
2007-07-12 15:44:13 +00:00
editor_prefs . smart_home_key = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_newline_strip " ) ;
2007-10-18 11:52:47 +00:00
editor_prefs . newline_strip = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_auto_multiline " ) ;
2008-05-14 15:36:27 +00:00
editor_prefs . auto_continue_multiline = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_symbol_auto_completion " ) ;
2007-05-29 16:30:54 +00:00
editor_prefs . auto_complete_symbols = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2007-01-26 10:43:25 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " spin_symbol_complete_chars " ) ;
2009-01-08 17:27:57 +00:00
gtk_spin_button_update ( GTK_SPIN_BUTTON ( widget ) ) ;
2007-12-01 17:53:36 +00:00
editor_prefs . symbolcompletion_min_chars = gtk_spin_button_get_value_as_int ( GTK_SPIN_BUTTON ( widget ) ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " spin_symbollistheight " ) ;
2009-01-08 17:27:57 +00:00
gtk_spin_button_update ( GTK_SPIN_BUTTON ( widget ) ) ;
2007-11-12 09:27:43 +00:00
editor_prefs . symbolcompletion_max_height = gtk_spin_button_get_value_as_int ( GTK_SPIN_BUTTON ( widget ) ) ;
2006-08-13 15:04:30 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " spin_line_break " ) ;
2009-01-08 17:27:57 +00:00
gtk_spin_button_update ( GTK_SPIN_BUTTON ( widget ) ) ;
2008-05-09 12:13:29 +00:00
editor_prefs . line_break_column = gtk_spin_button_get_value_as_int ( GTK_SPIN_BUTTON ( widget ) ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_autoclose_parenthesis " ) ;
2008-12-04 20:19:20 +00:00
autoclose_brackets [ 0 ] = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_autoclose_cbracket " ) ;
2008-12-04 20:19:20 +00:00
autoclose_brackets [ 1 ] = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_autoclose_sbracket " ) ;
2008-12-04 20:19:20 +00:00
autoclose_brackets [ 2 ] = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_autoclose_squote " ) ;
2008-12-04 20:19:20 +00:00
autoclose_brackets [ 3 ] = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_autoclose_dquote " ) ;
2008-12-04 20:19:20 +00:00
autoclose_brackets [ 4 ] = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
editor_prefs . autoclose_chars =
2011-12-17 23:10:03 +01:00
( autoclose_brackets [ 0 ] ? GEANY_AC_PARENTHESIS : 0u )
| ( autoclose_brackets [ 1 ] ? GEANY_AC_CBRACKET : 0u )
| ( autoclose_brackets [ 2 ] ? GEANY_AC_SBRACKET : 0u )
| ( autoclose_brackets [ 3 ] ? GEANY_AC_SQUOTE : 0u )
| ( autoclose_brackets [ 4 ] ? GEANY_AC_DQUOTE : 0u ) ;
2005-11-22 12:26:26 +00:00
2008-02-27 13:17:29 +00:00
/* Tools Settings */
2005-11-22 12:26:26 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " entry_com_term " ) ;
2008-05-16 12:08:39 +00:00
g_free ( tool_prefs . term_cmd ) ;
tool_prefs . term_cmd = g_strdup ( gtk_entry_get_text ( GTK_ENTRY ( widget ) ) ) ;
2005-11-22 12:26:26 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " entry_browser " ) ;
2008-05-16 12:08:39 +00:00
g_free ( tool_prefs . browser_cmd ) ;
tool_prefs . browser_cmd = g_strdup ( gtk_entry_get_text ( GTK_ENTRY ( widget ) ) ) ;
2005-11-22 12:26:26 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " entry_grep " ) ;
2008-05-16 12:08:39 +00:00
g_free ( tool_prefs . grep_cmd ) ;
tool_prefs . grep_cmd = g_strdup ( gtk_entry_get_text ( GTK_ENTRY ( widget ) ) ) ;
2006-07-13 14:30:44 +00:00
2006-07-02 16:21:35 +00:00
2008-02-27 13:17:29 +00:00
/* Template settings */
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " entry_template_developer " ) ;
2008-05-16 12:08:39 +00:00
g_free ( template_prefs . developer ) ;
template_prefs . developer = g_strdup ( gtk_entry_get_text ( GTK_ENTRY ( widget ) ) ) ;
2005-11-22 12:26:26 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " entry_template_company " ) ;
2008-05-16 12:08:39 +00:00
g_free ( template_prefs . company ) ;
template_prefs . company = g_strdup ( gtk_entry_get_text ( GTK_ENTRY ( widget ) ) ) ;
2005-11-22 12:26:26 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " entry_template_mail " ) ;
2008-05-16 12:08:39 +00:00
g_free ( template_prefs . mail ) ;
template_prefs . mail = g_strdup ( gtk_entry_get_text ( GTK_ENTRY ( widget ) ) ) ;
2005-11-22 12:26:26 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " entry_template_initial " ) ;
2008-05-16 12:08:39 +00:00
g_free ( template_prefs . initials ) ;
template_prefs . initials = g_strdup ( gtk_entry_get_text ( GTK_ENTRY ( widget ) ) ) ;
2005-11-22 12:26:26 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " entry_template_version " ) ;
2008-05-16 12:08:39 +00:00
g_free ( template_prefs . version ) ;
template_prefs . version = g_strdup ( gtk_entry_get_text ( GTK_ENTRY ( widget ) ) ) ;
2005-11-22 12:26:26 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " entry_template_year " ) ;
2008-07-13 11:51:00 +00:00
g_free ( template_prefs . year_format ) ;
template_prefs . year_format = g_strdup ( gtk_entry_get_text ( GTK_ENTRY ( widget ) ) ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " entry_template_date " ) ;
2008-07-13 11:51:00 +00:00
g_free ( template_prefs . date_format ) ;
template_prefs . date_format = g_strdup ( gtk_entry_get_text ( GTK_ENTRY ( widget ) ) ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " entry_template_datetime " ) ;
2008-07-13 11:51:00 +00:00
g_free ( template_prefs . datetime_format ) ;
template_prefs . datetime_format = g_strdup ( gtk_entry_get_text ( GTK_ENTRY ( widget ) ) ) ;
2005-11-22 12:26:26 +00:00
2008-02-27 13:17:29 +00:00
/* Keybindings */
2014-08-10 14:57:33 +02:00
if ( global_kb_data . edited )
2010-10-22 12:20:37 +00:00
{
2014-08-10 14:57:33 +02:00
kb_update ( & global_kb_data ) ;
2011-04-03 15:53:48 +00:00
tools_create_insert_custom_command_menu_items ( ) ;
2009-03-29 16:15:35 +00:00
keybindings_write_to_file ( ) ;
2010-10-22 12:20:37 +00:00
}
2007-11-17 14:04:27 +00:00
2008-02-27 13:17:29 +00:00
/* Printing */
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " radio_print_gtk " ) ;
2007-11-17 14:04:27 +00:00
printing_prefs . use_gtk_printing = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " entry_print_external_cmd " ) ;
2007-11-17 14:04:27 +00:00
g_free ( printing_prefs . external_print_cmd ) ;
printing_prefs . external_print_cmd = g_strdup ( gtk_entry_get_text ( GTK_ENTRY ( widget ) ) ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_print_linenumbers " ) ;
2007-11-17 14:04:27 +00:00
printing_prefs . print_line_numbers = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_print_pagenumbers " ) ;
2007-11-17 14:04:27 +00:00
printing_prefs . print_page_numbers = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_print_pageheader " ) ;
2007-11-17 14:04:27 +00:00
printing_prefs . print_page_header = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_print_basename " ) ;
2007-11-17 14:04:27 +00:00
printing_prefs . page_header_basename = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " entry_print_dateformat " ) ;
2007-11-17 14:04:27 +00:00
g_free ( printing_prefs . page_header_datefmt ) ;
printing_prefs . page_header_datefmt = g_strdup ( gtk_entry_get_text ( GTK_ENTRY ( widget ) ) ) ;
2005-12-11 02:16:02 +00:00
# ifdef HAVE_VTE
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_vte " ) ;
2006-08-19 15:07:11 +00:00
vte_info . load_vte = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2006-05-22 00:25:19 +00:00
2008-02-27 13:17:29 +00:00
/* VTE settings */
2006-08-19 15:07:11 +00:00
if ( vte_info . have_vte )
2005-12-16 23:23:18 +00:00
{
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " spin_scrollback " ) ;
2009-01-08 17:27:57 +00:00
gtk_spin_button_update ( GTK_SPIN_BUTTON ( widget ) ) ;
2005-12-16 23:23:18 +00:00
vc - > scrollback_lines = gtk_spin_button_get_value_as_int ( GTK_SPIN_BUTTON ( widget ) ) ;
2005-12-11 02:16:02 +00:00
2012-12-18 10:26:48 +01:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " entry_image " ) ;
g_free ( vc - > image ) ;
vc - > image = g_strdup ( gtk_entry_get_text ( GTK_ENTRY ( widget ) ) ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " entry_shell " ) ;
2006-08-23 16:37:05 +00:00
g_free ( vc - > shell ) ;
vc - > shell = g_strdup ( gtk_entry_get_text ( GTK_ENTRY ( widget ) ) ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_scroll_key " ) ;
2005-12-16 23:23:18 +00:00
vc - > scroll_on_key = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2005-12-11 02:16:02 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_scroll_out " ) ;
2005-12-16 23:23:18 +00:00
vc - > scroll_on_out = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_enable_bash_keys " ) ;
2008-01-10 17:11:19 +00:00
vc - > enable_bash_keys = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_ignore_menu_key " ) ;
2006-08-23 16:37:05 +00:00
vc - > ignore_menu_bar_accel = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_follow_path " ) ;
2006-07-02 18:34:03 +00:00
vc - > follow_path = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2006-12-10 21:29:04 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_run_in_vte " ) ;
2006-12-10 21:29:04 +00:00
vc - > run_in_vte = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2006-07-02 18:34:03 +00:00
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_skip_script " ) ;
2007-12-17 16:58:26 +00:00
vc - > skip_run_script = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2008-12-18 21:21:53 +00:00
widget = ui_lookup_widget ( ui_widgets . prefs_dialog , " check_cursor_blinks " ) ;
2008-12-07 19:11:36 +00:00
vc - > cursor_blinks = gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ;
2005-12-16 23:23:18 +00:00
vte_apply_user_settings ( ) ;
}
2005-12-11 02:16:02 +00:00
# endif
2008-02-27 13:17:29 +00:00
/* apply the changes made */
2008-05-16 12:08:39 +00:00
ui_statusbar_showhide ( interface_prefs . statusbar_visible ) ;
2009-09-28 11:16:59 +00:00
sidebar_openfiles_update_all ( ) ; /* to update if full path setting has changed */
2009-07-21 22:10:42 +00:00
toolbar_apply_settings ( ) ;
2009-03-29 16:15:35 +00:00
toolbar_update_ui ( ) ;
2009-07-21 22:10:42 +00:00
toolbar_show_hide ( ) ;
2008-01-23 14:12:08 +00:00
ui_sidebar_show_hide ( ) ;
2008-05-22 14:41:28 +00:00
gtk_notebook_set_show_tabs ( GTK_NOTEBOOK ( main_widgets . notebook ) , interface_prefs . show_notebook_tabs ) ;
2005-11-22 12:26:26 +00:00
2008-05-22 14:41:28 +00:00
gtk_notebook_set_tab_pos ( GTK_NOTEBOOK ( main_widgets . notebook ) , interface_prefs . tab_pos_editor ) ;
2008-05-16 12:08:39 +00:00
gtk_notebook_set_tab_pos ( GTK_NOTEBOOK ( msgwindow . notebook ) , interface_prefs . tab_pos_msgwin ) ;
2008-05-22 14:41:28 +00:00
gtk_notebook_set_tab_pos ( GTK_NOTEBOOK ( main_widgets . sidebar_notebook ) , interface_prefs . tab_pos_sidebar ) ;
2006-07-02 16:21:35 +00:00
2008-02-27 13:17:29 +00:00
/* re-colourise all open documents, if tab width or long line settings have changed */
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 )
2005-11-22 12:26:26 +00:00
{
2008-09-21 16:43:45 +00:00
editor_apply_update_prefs ( documents [ i ] - > editor ) ;
2007-05-29 16:30:54 +00:00
if ( ! editor_prefs . folding )
2008-09-25 18:28:37 +00:00
editor_unfold_all ( documents [ i ] - > editor ) ;
2006-06-30 14:28:32 +00:00
}
2005-11-22 12:26:26 +00:00
}
2008-06-15 13:35:48 +00:00
ui_document_show_hide ( NULL ) ;
2008-12-07 19:12:08 +00:00
ui_update_view_editor_menu_items ( ) ;
2005-11-22 12:26:26 +00:00
2011-07-28 17:59:22 +00:00
/* various preferences */
ui_save_buttons_toggle ( ( doc ! = NULL ) ? doc - > changed : FALSE ) ;
msgwin_show_hide_tabs ( ) ;
ui_update_statusbar ( doc , - 1 ) ;
2008-02-27 13:17:29 +00:00
/* store all settings */
2006-02-20 15:11:38 +00:00
configuration_save ( ) ;
2005-11-22 12:26:26 +00:00
}
2006-12-03 22:33:46 +00:00
2011-05-27 21:00:41 +00:00
if ( response = = GTK_RESPONSE_HELP )
{
open_preferences_help ( ) ;
}
else if ( response ! = GTK_RESPONSE_APPLY )
2006-10-29 01:28:58 +00:00
{
2014-08-10 14:57:33 +02:00
gtk_tree_store_clear ( global_kb_data . store ) ;
2006-10-29 01:28:58 +00:00
gtk_widget_hide ( GTK_WIDGET ( dialog ) ) ;
}
2005-11-22 12:26:26 +00:00
}
2009-11-17 21:49:43 +00:00
static void on_color_button_choose_cb ( GtkColorButton * widget , gpointer user_data )
2005-11-22 12:26:26 +00:00
{
GdkColor color ;
2009-11-17 21:49:43 +00:00
gtk_color_button_get_color ( widget , & color ) ;
2012-01-25 16:26:16 +00:00
SETPTR ( editor_prefs . long_line_color , utils_get_hex_from_color ( & color ) ) ;
2005-11-22 12:26:26 +00:00
}
2009-11-17 21:49:43 +00:00
static void on_prefs_font_choosed ( GtkFontButton * widget , gpointer user_data )
2005-11-22 12:26:26 +00:00
{
2006-06-29 16:55:29 +00:00
const gchar * fontbtn = gtk_font_button_get_font_name ( widget ) ;
2006-10-09 16:08:53 +00:00
guint i ;
2006-06-29 16:55:29 +00:00
2005-12-11 02:16:02 +00:00
switch ( GPOINTER_TO_INT ( user_data ) )
2005-11-22 12:26:26 +00:00
{
2005-12-11 02:16:02 +00:00
case 1 :
{
2008-12-06 11:10:06 +00:00
if ( strcmp ( fontbtn , interface_prefs . tagbar_font ) = = 0 )
break ;
2012-01-25 16:26:16 +00:00
SETPTR ( interface_prefs . tagbar_font , g_strdup ( fontbtn ) ) ;
2008-05-29 17:00:54 +00:00
for ( i = 0 ; i < documents_array - > len ; i + + )
2006-06-29 16:55:29 +00:00
{
2008-09-26 17:28:50 +00:00
GeanyDocument * doc = documents [ i ] ;
2008-06-02 15:31:59 +00:00
2008-09-26 17:28:50 +00:00
if ( documents [ i ] - > is_valid & & GTK_IS_WIDGET ( doc - > priv - > tag_tree ) )
ui_widget_modify_font_from_string ( doc - > priv - > tag_tree ,
2008-05-16 12:08:39 +00:00
interface_prefs . tagbar_font ) ;
2006-06-29 16:55:29 +00:00
}
2007-08-23 11:34:06 +00:00
if ( GTK_IS_WIDGET ( tv . default_tag_tree ) )
2008-05-16 12:08:39 +00:00
ui_widget_modify_font_from_string ( tv . default_tag_tree , interface_prefs . tagbar_font ) ;
2008-12-06 18:04:46 +00:00
ui_widget_modify_font_from_string ( tv . tree_openfiles , interface_prefs . tagbar_font ) ;
2005-12-11 02:16:02 +00:00
break ;
}
case 2 :
{
2008-06-16 18:31:59 +00:00
if ( strcmp ( fontbtn , interface_prefs . msgwin_font ) = = 0 )
break ;
2012-01-25 16:26:16 +00:00
SETPTR ( interface_prefs . msgwin_font , g_strdup ( fontbtn ) ) ;
2008-05-16 12:08:39 +00:00
ui_widget_modify_font_from_string ( msgwindow . tree_compiler , interface_prefs . msgwin_font ) ;
ui_widget_modify_font_from_string ( msgwindow . tree_msg , interface_prefs . msgwin_font ) ;
ui_widget_modify_font_from_string ( msgwindow . tree_status , interface_prefs . msgwin_font ) ;
2009-12-20 20:07:04 +00:00
ui_widget_modify_font_from_string ( msgwindow . scribble , interface_prefs . msgwin_font ) ;
2005-12-11 02:16:02 +00:00
break ;
}
case 3 :
{
2006-09-05 14:24:47 +00:00
ui_set_editor_font ( fontbtn ) ;
2005-12-11 02:16:02 +00:00
break ;
}
2005-11-22 12:26:26 +00:00
}
}
2006-05-19 17:18:06 +00:00
2014-08-10 14:57:33 +02:00
static void kb_change_iter_shortcut ( KbData * kbdata , GtkTreeIter * iter , const gchar * new_text )
2010-10-21 16:40:31 +00:00
{
guint lkey ;
GdkModifierType lmods ;
gtk_accelerator_parse ( new_text , & lkey , & lmods ) ;
2014-08-10 14:57:33 +02:00
if ( kb_find_duplicate ( kbdata - > store , ui_widgets . prefs_dialog , iter , lkey , lmods , new_text ) )
2010-10-21 16:40:31 +00:00
return ;
/* set the values here, because of the above check, setting it in
* gtk_accelerator_parse would return a wrong key combination if it is duplicate */
2014-08-10 14:57:33 +02:00
kb_set_shortcut ( kbdata - > store , iter , lkey , lmods ) ;
2010-10-21 16:40:31 +00:00
2014-08-10 14:57:33 +02:00
kbdata - > edited = TRUE ;
2010-10-21 16:40:31 +00:00
}
static void kb_cell_edited_cb ( GtkCellRendererText * cellrenderertext ,
2014-08-10 14:57:33 +02:00
gchar * path , gchar * new_text , KbData * kbdata )
2006-05-19 17:18:06 +00:00
{
2009-04-15 22:47:33 +00:00
if ( path ! = NULL & & new_text ! = NULL )
2006-05-19 17:18:06 +00:00
{
2008-02-29 19:30:28 +00:00
GtkTreeIter iter ;
2006-05-19 17:18:06 +00:00
2014-08-10 14:57:33 +02:00
gtk_tree_model_get_iter_from_string ( GTK_TREE_MODEL ( kbdata - > store ) , & iter , path ) ;
if ( gtk_tree_model_iter_has_child ( GTK_TREE_MODEL ( kbdata - > store ) , & iter ) )
2008-02-29 19:30:28 +00:00
return ; /* ignore group items */
2006-05-19 17:18:06 +00:00
2014-08-10 14:57:33 +02:00
kb_change_iter_shortcut ( kbdata , & iter , new_text ) ;
2006-05-19 17:18:06 +00:00
}
}
2014-08-10 15:28:29 +02:00
static gboolean kb_grab_key_dialog_key_press_cb ( GtkWidget * dialog , GdkEventKey * event , GtkLabel * label )
2006-05-19 17:18:06 +00:00
{
gchar * str ;
2011-12-17 23:10:03 +01:00
guint state ;
2006-05-19 17:18:06 +00:00
2014-08-10 15:28:29 +02:00
g_return_val_if_fail ( GTK_IS_LABEL ( label ) , FALSE ) ;
2011-04-03 15:53:48 +00:00
state = event - > state & gtk_accelerator_get_default_mod_mask ( ) ;
2007-07-12 11:56:17 +00:00
2009-04-15 22:47:33 +00:00
if ( event - > keyval = = GDK_Escape )
2008-02-27 13:17:29 +00:00
return FALSE ; /* close the dialog, don't allow escape when detecting keybindings. */
2006-05-19 17:18:06 +00:00
2008-02-12 15:49:54 +00:00
str = gtk_accelerator_name ( event - > keyval , state ) ;
2006-05-19 17:18:06 +00:00
2014-08-10 15:28:29 +02:00
gtk_label_set_text ( label , str ) ;
2006-05-19 17:18:06 +00:00
g_free ( str ) ;
return TRUE ;
}
2009-09-14 17:10:22 +00:00
/* test if the entered key combination is already used
* returns true if cancelling duplicate */
2014-08-10 14:57:33 +02:00
static gboolean kb_find_duplicate ( GtkTreeStore * store , GtkWidget * parent , GtkTreeIter * old_iter ,
2010-10-22 12:27:11 +00:00
guint key , GdkModifierType mods , const gchar * shortcut )
2006-05-30 19:19:05 +00:00
{
2011-11-22 03:18:53 +01:00
GtkTreeModel * model = GTK_TREE_MODEL ( store ) ;
GtkTreeIter parent_iter ;
gchar * kb_str ;
guint kb_key ;
GdkModifierType kb_mods ;
2006-05-30 19:19:05 +00:00
2008-02-27 13:17:29 +00:00
/* allow duplicate if there is no key combination */
2009-04-15 22:47:33 +00:00
if ( key = = 0 & & mods = = 0 )
2009-04-05 21:07:40 +00:00
return FALSE ;
2006-05-30 19:19:05 +00:00
2011-11-22 03:18:53 +01:00
/* don't check if the new keybinding is the same as the old one */
gtk_tree_model_get ( model , old_iter , KB_TREE_SHORTCUT , & kb_str , - 1 ) ;
if ( kb_str )
2006-05-30 19:19:05 +00:00
{
2011-11-22 03:18:53 +01:00
gtk_accelerator_parse ( kb_str , & kb_key , & kb_mods ) ;
g_free ( kb_str ) ;
if ( key = = kb_key & & mods = = kb_mods )
return FALSE ;
}
if ( ! gtk_tree_model_get_iter_first ( model , & parent_iter ) )
return FALSE ;
do /* foreach top level */
{
GtkTreeIter iter ;
if ( ! gtk_tree_model_iter_children ( model , & iter , & parent_iter ) )
continue ;
do /* foreach children */
2006-05-30 19:19:05 +00:00
{
2011-11-22 03:18:53 +01:00
gtk_tree_model_get ( model , & iter , KB_TREE_SHORTCUT , & kb_str , - 1 ) ;
if ( ! kb_str )
continue ;
gtk_accelerator_parse ( kb_str , & kb_key , & kb_mods ) ;
g_free ( kb_str ) ;
/* search another item with the same key and modifiers */
if ( kb_key = = key & & kb_mods = = mods )
2008-02-29 19:30:28 +00:00
{
2011-11-22 03:18:53 +01:00
gchar * label ;
gint ret ;
gtk_tree_model_get ( model , & iter , KB_TREE_ACTION , & label , - 1 ) ;
ret = dialogs_show_prompt ( parent ,
2009-12-20 15:37:40 +00:00
_ ( " _Allow " ) , GTK_RESPONSE_APPLY ,
GTK_STOCK_CANCEL , GTK_RESPONSE_NO ,
_ ( " _Override " ) , GTK_RESPONSE_YES ,
2008-02-29 19:30:28 +00:00
_ ( " Override that keybinding? " ) ,
_ ( " The combination '%s' is already used for \" %s \" . " ) ,
2010-10-22 12:27:11 +00:00
shortcut , label ) ;
2009-10-29 11:59:55 +00:00
g_free ( label ) ;
2009-09-14 17:10:22 +00:00
if ( ret = = GTK_RESPONSE_YES )
2008-02-29 19:30:28 +00:00
{
2012-04-04 13:37:31 +01:00
kb_set_shortcut ( store , & iter , 0 , 0 ) ; /* clear shortcut */
2009-09-14 17:10:22 +00:00
/* carry on looking for other duplicates if overriding */
2008-02-29 19:30:28 +00:00
continue ;
}
2009-09-14 17:10:22 +00:00
return ret = = GTK_RESPONSE_NO ;
2007-11-08 15:58:11 +00:00
}
2006-05-30 19:19:05 +00:00
}
2011-11-22 03:18:53 +01:00
while ( gtk_tree_model_iter_next ( model , & iter ) ) ;
2006-05-30 19:19:05 +00:00
}
2011-11-22 03:18:53 +01:00
while ( gtk_tree_model_iter_next ( model , & parent_iter ) ) ;
2006-05-30 19:19:05 +00:00
return FALSE ;
}
2007-01-26 10:43:25 +00:00
static void on_toolbar_show_toggled ( GtkToggleButton * togglebutton , gpointer user_data )
2006-07-11 14:15:56 +00:00
{
gboolean sens = gtk_toggle_button_get_active ( togglebutton ) ;
2010-04-11 21:56:08 +00:00
gtk_widget_set_sensitive (
ui_lookup_widget ( ui_widgets . prefs_dialog , " frame_toolbar_style " ) , sens ) ;
gtk_widget_set_sensitive (
ui_lookup_widget ( ui_widgets . prefs_dialog , " frame_toolbar_icon " ) , sens ) ;
gtk_widget_set_sensitive (
ui_lookup_widget ( ui_widgets . prefs_dialog , " button_customize_toolbar " ) , sens ) ;
2009-03-29 16:15:35 +00:00
gtk_widget_set_sensitive (
ui_lookup_widget ( ui_widgets . prefs_dialog , " check_toolbar_in_menu " ) , sens ) ;
2006-07-11 14:15:56 +00:00
}
2007-01-26 10:43:25 +00:00
static void on_show_notebook_tabs_toggled ( GtkToggleButton * togglebutton , gpointer user_data )
2006-10-29 01:28:58 +00:00
{
gboolean sens = gtk_toggle_button_get_active ( togglebutton ) ;
2008-02-27 13:17:29 +00:00
/* tab placement only enabled when tabs are visible */
2008-12-18 21:21:53 +00:00
gtk_widget_set_sensitive ( ui_lookup_widget ( ui_widgets . prefs_dialog , " combo_tab_editor " ) , sens ) ;
gtk_widget_set_sensitive ( ui_lookup_widget ( ui_widgets . prefs_dialog , " check_show_tab_cross " ) , sens ) ;
2006-11-18 15:47:28 +00:00
}
2007-01-26 10:43:25 +00:00
static void on_use_folding_toggled ( GtkToggleButton * togglebutton , gpointer user_data )
2006-12-03 22:33:46 +00:00
{
gboolean sens = gtk_toggle_button_get_active ( togglebutton ) ;
2008-12-18 21:21:53 +00:00
gtk_widget_set_sensitive ( ui_lookup_widget ( ui_widgets . prefs_dialog , " check_unfold_children " ) , sens ) ;
2006-12-03 22:33:46 +00:00
}
2009-03-13 10:02:29 +00:00
static void on_enable_plugins_toggled ( GtkToggleButton * togglebutton , gpointer user_data )
{
gboolean sens = gtk_toggle_button_get_active ( togglebutton ) ;
gtk_widget_set_sensitive ( ui_lookup_widget ( ui_widgets . prefs_dialog , " extra_plugin_path_entry " ) , sens ) ;
gtk_widget_set_sensitive ( ui_lookup_widget ( ui_widgets . prefs_dialog , " extra_plugin_path_button " ) , sens ) ;
}
2007-06-26 15:41:27 +00:00
static void on_open_encoding_toggled ( GtkToggleButton * togglebutton , gpointer user_data )
{
gboolean sens = gtk_toggle_button_get_active ( togglebutton ) ;
2008-12-18 21:21:53 +00:00
gtk_widget_set_sensitive ( ui_lookup_widget ( ui_widgets . prefs_dialog , " eventbox3 " ) , sens ) ;
gtk_widget_set_sensitive ( ui_lookup_widget ( ui_widgets . prefs_dialog , " label_open_encoding " ) , sens ) ;
2007-06-26 15:41:27 +00:00
}
2009-12-31 15:48:39 +00:00
static void on_sidebar_visible_toggled ( GtkToggleButton * togglebutton , gpointer user_data )
{
gboolean sens = gtk_toggle_button_get_active ( togglebutton ) ;
gtk_widget_set_sensitive ( ui_lookup_widget ( ui_widgets . prefs_dialog , " check_list_openfiles " ) , sens ) ;
gtk_widget_set_sensitive ( ui_lookup_widget ( ui_widgets . prefs_dialog , " check_list_symbol " ) , sens ) ;
}
2007-11-17 14:04:27 +00:00
static void on_prefs_print_radio_button_toggled ( GtkToggleButton * togglebutton , gpointer user_data )
{
gboolean sens = gtk_toggle_button_get_active ( togglebutton ) ;
2008-12-18 21:21:53 +00:00
gtk_widget_set_sensitive ( ui_lookup_widget ( ui_widgets . prefs_dialog , " vbox29 " ) , sens ) ;
gtk_widget_set_sensitive ( ui_lookup_widget ( ui_widgets . prefs_dialog , " hbox9 " ) , ! sens ) ;
2007-11-17 14:04:27 +00:00
}
static void on_prefs_print_page_header_toggled ( GtkToggleButton * togglebutton , gpointer user_data )
{
gboolean sens = gtk_toggle_button_get_active ( togglebutton ) ;
2008-12-18 21:21:53 +00:00
gtk_widget_set_sensitive ( ui_lookup_widget ( ui_widgets . prefs_dialog , " check_print_basename " ) , sens ) ;
gtk_widget_set_sensitive ( ui_lookup_widget ( ui_widgets . prefs_dialog , " entry_print_dateformat " ) , sens ) ;
2007-11-17 14:04:27 +00:00
}
2009-11-23 23:03:39 +00:00
static void open_preferences_help ( void )
{
gchar * uri ;
2009-11-30 22:58:57 +00:00
const gchar * label , * suffix = NULL ;
2009-11-23 23:03:39 +00:00
GtkNotebook * notebook = GTK_NOTEBOOK (
ui_lookup_widget ( ui_widgets . prefs_dialog , " notebook2 " ) ) ;
gint page_nr = gtk_notebook_get_current_page ( notebook ) ;
GtkWidget * page = gtk_notebook_get_nth_page ( notebook , page_nr ) ;
label = gtk_notebook_get_tab_label_text ( notebook , page ) ;
/* TODO Find a better way to map the current notebook page to the
* corresponding chapter in the documentation , comparing translatable
* strings is easy to break . Maybe attach an identifying string to the
* tab label object . */
if ( utils_str_equal ( label , _ ( " General " ) ) )
suffix = " #general-startup-preferences " ;
else if ( utils_str_equal ( label , _ ( " Interface " ) ) )
suffix = " #interface-preferences " ;
else if ( utils_str_equal ( label , _ ( " Toolbar " ) ) )
suffix = " #toolbar-preferences " ;
else if ( utils_str_equal ( label , _ ( " Editor " ) ) )
suffix = " #editor-features-preferences " ;
else if ( utils_str_equal ( label , _ ( " Files " ) ) )
suffix = " #files-preferences " ;
else if ( utils_str_equal ( label , _ ( " Tools " ) ) )
suffix = " #tools-preferences " ;
else if ( utils_str_equal ( label , _ ( " Templates " ) ) )
suffix = " #template-preferences " ;
else if ( utils_str_equal ( label , _ ( " Keybindings " ) ) )
suffix = " #keybinding-preferences " ;
else if ( utils_str_equal ( label , _ ( " Printing " ) ) )
suffix = " #printing-preferences " ;
2011-07-28 17:59:22 +00:00
else if ( utils_str_equal ( label , _ ( " Various " ) ) )
suffix = " #various-preferences " ;
2009-11-23 23:03:39 +00:00
else if ( utils_str_equal ( label , _ ( " Terminal " ) ) )
suffix = " #terminal-vte-preferences " ;
uri = utils_get_help_url ( suffix ) ;
utils_open_browser ( uri ) ;
g_free ( uri ) ;
}
static gboolean prefs_dialog_key_press_response_cb ( GtkWidget * dialog , GdkEventKey * event ,
gpointer data )
{
2010-09-13 15:37:46 +00:00
GeanyKeyBinding * kb = keybindings_lookup_item ( GEANY_KEY_GROUP_HELP , GEANY_KEYS_HELP_HELP ) ;
2009-11-23 23:03:39 +00:00
2010-09-13 15:37:46 +00:00
if ( keybindings_check_event ( event , kb ) )
2009-11-23 23:03:39 +00:00
{
2010-09-13 15:37:46 +00:00
open_preferences_help ( ) ;
return TRUE ;
2009-11-23 23:03:39 +00:00
}
return FALSE ;
}
2012-01-20 19:22:22 +01:00
static void list_store_append_text ( GtkListStore * list , const gchar * text )
{
GtkTreeIter iter ;
gtk_list_store_append ( list , & iter ) ;
gtk_list_store_set ( list , & iter , 0 , text , - 1 ) ;
}
2007-03-23 16:47:27 +00:00
void prefs_show_dialog ( void )
2006-07-11 14:15:56 +00:00
{
2009-04-15 22:47:33 +00:00
if ( ui_widgets . prefs_dialog = = NULL )
2006-07-11 14:15:56 +00:00
{
2014-01-17 21:56:51 +01:00
GtkListStore * eol_list ;
GtkWidget * label ;
2006-07-11 14:15:56 +00:00
2011-10-19 00:35:24 -07:00
ui_widgets . prefs_dialog = create_prefs_dialog ( ) ;
2007-08-23 11:34:06 +00:00
gtk_widget_set_name ( ui_widgets . prefs_dialog , " GeanyPrefsDialog " ) ;
2008-05-22 14:41:28 +00:00
gtk_window_set_transient_for ( GTK_WINDOW ( ui_widgets . prefs_dialog ) , GTK_WINDOW ( main_widgets . window ) ) ;
2006-07-11 14:15:56 +00:00
2012-01-20 19:22:22 +01:00
/* init the file encoding combo boxes */
2006-07-11 14:15:56 +00:00
{
2014-01-17 21:56:51 +01:00
struct {
const gchar * combo , * renderer ;
} names [ ] = {
{ " combo_new_encoding " , " combo_new_encoding_renderer " } ,
{ " combo_open_encoding " , " combo_open_encoding_renderer " }
} ;
guint i ;
GtkTreeStore * encoding_list = encodings_encoding_store_new ( FALSE ) ;
for ( i = 0 ; i < G_N_ELEMENTS ( names ) ; i + + )
{
GtkWidget * combo = ui_lookup_widget ( ui_widgets . prefs_dialog , names [ i ] . combo ) ;
gtk_cell_layout_set_cell_data_func ( GTK_CELL_LAYOUT ( combo ) ,
ui_builder_get_object ( names [ i ] . renderer ) ,
encodings_encoding_store_cell_data_func , NULL , NULL ) ;
gtk_combo_box_set_model ( GTK_COMBO_BOX ( combo ) , GTK_TREE_MODEL ( encoding_list ) ) ;
}
g_object_unref ( encoding_list ) ;
2006-07-11 14:15:56 +00:00
}
2008-05-14 15:36:27 +00:00
/* init the eol character combo box */
2012-01-20 19:22:22 +01:00
eol_list = ui_builder_get_object ( " eol_list " ) ;
list_store_append_text ( eol_list , utils_get_eol_name ( SC_EOL_CRLF ) ) ;
list_store_append_text ( eol_list , utils_get_eol_name ( SC_EOL_CR ) ) ;
list_store_append_text ( eol_list , utils_get_eol_name ( SC_EOL_LF ) ) ;
2008-05-14 15:36:27 +00:00
2014-01-17 18:26:23 +01:00
2008-12-06 11:10:06 +00:00
/* add manually GeanyWrapLabels because they can't be added with Glade */
/* page Tools */
2008-01-09 13:24:36 +00:00
label = geany_wrap_label_new ( _ ( " Enter tool paths below. Tools you do not need can be left blank. " ) ) ;
gtk_widget_show ( label ) ;
2008-12-18 21:21:53 +00:00
gtk_box_pack_start ( GTK_BOX ( ui_lookup_widget ( ui_widgets . prefs_dialog , " vbox33 " ) ) ,
2008-01-09 13:24:36 +00:00
label , FALSE , TRUE , 5 ) ;
2008-02-27 13:17:29 +00:00
/* page Templates */
2008-01-09 13:24:36 +00:00
label = geany_wrap_label_new ( _ ( " Set the information to be used in templates. See the documentation for details. " ) ) ;
gtk_widget_show ( label ) ;
2008-12-18 21:21:53 +00:00
gtk_box_pack_start ( GTK_BOX ( ui_lookup_widget ( ui_widgets . prefs_dialog , " vbox31 " ) ) ,
2008-01-09 13:24:36 +00:00
label , FALSE , TRUE , 5 ) ;
2008-02-27 13:17:29 +00:00
/* page Keybindings */
2008-01-09 13:24:36 +00:00
label = geany_wrap_label_new ( _ ( " Here you can change keyboard shortcuts for various actions. Select one and press the Change button to enter a new shortcut, or double click on an action to edit the string representation of the shortcut directly. " ) ) ;
gtk_widget_show ( label ) ;
2008-12-18 21:21:53 +00:00
gtk_box_pack_start ( GTK_BOX ( ui_lookup_widget ( ui_widgets . prefs_dialog , " vbox32 " ) ) ,
2008-01-09 13:24:36 +00:00
label , FALSE , TRUE , 5 ) ;
2008-12-29 10:43:04 +00:00
/* page Editor->Indentation */
label = geany_wrap_label_new ( _ ( " <i>Warning: these settings are overridden by the current project. See <b>Project->Properties</b>.</i> " ) ) ;
gtk_widget_show ( label ) ;
gtk_label_set_use_markup ( GTK_LABEL ( label ) , TRUE ) ;
gtk_misc_set_padding ( GTK_MISC ( label ) , 6 , 0 ) ;
gtk_box_pack_start ( GTK_BOX ( ui_lookup_widget ( ui_widgets . prefs_dialog ,
" label_project_indent_warning " ) ) , label , FALSE , TRUE , 5 ) ;
2008-01-09 13:24:36 +00:00
2009-02-10 21:10:50 +00:00
/* add the clear icon to GtkEntry widgets in the dialog */
2009-09-21 16:46:16 +00:00
{
const gchar * names [ ] = {
" startup_path_entry " ,
" project_file_path_entry " ,
" extra_plugin_path_entry " ,
" entry_toggle_mark " ,
/* "entry_com_make", */
" entry_com_term " ,
" entry_browser " ,
" entry_grep " ,
" entry_contextaction " ,
" entry_template_developer " ,
" entry_template_initial " ,
" entry_template_mail " ,
" entry_template_company " ,
" entry_template_version " ,
" entry_template_year " ,
" entry_template_date " ,
" entry_template_datetime " ,
" entry_print_external_cmd " ,
" entry_print_dateformat " } ;
const gchar * * name ;
foreach_c_array ( name , names , G_N_ELEMENTS ( names ) )
ui_entry_add_clear_icon ( GTK_ENTRY ( ui_lookup_widget ( ui_widgets . prefs_dialog , * name ) ) ) ;
}
2008-01-09 13:24:36 +00:00
2011-07-28 17:59:22 +00:00
/* page Various */
2011-09-21 16:03:11 +00:00
various_treeview = GTK_TREE_VIEW ( ui_lookup_widget ( ui_widgets . prefs_dialog ,
" various_treeview " ) ) ;
stash_tree_setup ( pref_groups , various_treeview ) ;
2011-07-28 17:59:22 +00:00
2006-11-24 11:11:06 +00:00
# ifdef HAVE_VTE
2006-11-24 11:47:29 +00:00
vte_append_preferences_tab ( ) ;
2006-11-24 11:11:06 +00:00
# endif
2006-11-18 15:47:28 +00:00
2010-05-16 18:22:24 +00:00
# ifndef G_OS_WIN32
gtk_widget_hide ( ui_lookup_widget ( ui_widgets . prefs_dialog , " check_native_windows_dialogs " ) ) ;
# endif
2008-12-18 21:21:53 +00:00
ui_setup_open_button_callback ( ui_lookup_widget ( ui_widgets . prefs_dialog , " startup_path_button " ) , NULL ,
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER , GTK_ENTRY ( ui_lookup_widget ( ui_widgets . prefs_dialog , " startup_path_entry " ) ) ) ;
2009-03-13 10:02:29 +00:00
ui_setup_open_button_callback ( ui_lookup_widget ( ui_widgets . prefs_dialog , " extra_plugin_path_button " ) , NULL ,
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER , GTK_ENTRY ( ui_lookup_widget ( ui_widgets . prefs_dialog , " extra_plugin_path_entry " ) ) ) ;
2007-08-16 15:20:38 +00:00
2008-07-18 13:40:48 +00:00
g_signal_connect ( ui_widgets . prefs_dialog , " response " ,
2010-10-21 16:19:06 +00:00
G_CALLBACK ( on_prefs_dialog_response ) , NULL ) ;
2008-07-18 13:40:48 +00:00
g_signal_connect ( ui_widgets . prefs_dialog , " delete-event " ,
2007-01-19 23:17:40 +00:00
G_CALLBACK ( gtk_widget_hide_on_delete ) , NULL ) ;
2007-05-23 13:44:25 +00:00
2008-12-18 21:21:53 +00:00
g_signal_connect ( ui_lookup_widget ( ui_widgets . prefs_dialog , " tagbar_font " ) ,
2006-07-11 14:15:56 +00:00
" font-set " , G_CALLBACK ( on_prefs_font_choosed ) , GINT_TO_POINTER ( 1 ) ) ;
2008-12-18 21:21:53 +00:00
g_signal_connect ( ui_lookup_widget ( ui_widgets . prefs_dialog , " msgwin_font " ) ,
2006-07-11 14:15:56 +00:00
" font-set " , G_CALLBACK ( on_prefs_font_choosed ) , GINT_TO_POINTER ( 2 ) ) ;
2008-12-18 21:21:53 +00:00
g_signal_connect ( ui_lookup_widget ( ui_widgets . prefs_dialog , " editor_font " ) ,
2006-07-11 14:15:56 +00:00
" font-set " , G_CALLBACK ( on_prefs_font_choosed ) , GINT_TO_POINTER ( 3 ) ) ;
2008-12-18 21:21:53 +00:00
g_signal_connect ( ui_lookup_widget ( ui_widgets . prefs_dialog , " long_line_color " ) ,
2009-11-17 21:49:43 +00:00
" color-set " , G_CALLBACK ( on_color_button_choose_cb ) , NULL ) ;
/* file chooser buttons in the tools tab */
ui_setup_open_button_callback ( ui_lookup_widget ( ui_widgets . prefs_dialog , " button_term " ) ,
2009-11-17 23:01:33 +00:00
NULL ,
2009-11-17 21:49:43 +00:00
GTK_FILE_CHOOSER_ACTION_OPEN ,
GTK_ENTRY ( ui_lookup_widget ( ui_widgets . prefs_dialog , " entry_com_term " ) ) ) ;
ui_setup_open_button_callback ( ui_lookup_widget ( ui_widgets . prefs_dialog , " button_browser " ) ,
2009-11-17 23:01:33 +00:00
NULL ,
2009-11-17 21:49:43 +00:00
GTK_FILE_CHOOSER_ACTION_OPEN ,
GTK_ENTRY ( ui_lookup_widget ( ui_widgets . prefs_dialog , " entry_browser " ) ) ) ;
ui_setup_open_button_callback ( ui_lookup_widget ( ui_widgets . prefs_dialog , " button_grep " ) ,
2009-11-17 23:01:33 +00:00
NULL ,
2009-11-17 21:49:43 +00:00
GTK_FILE_CHOOSER_ACTION_OPEN ,
GTK_ENTRY ( ui_lookup_widget ( ui_widgets . prefs_dialog , " entry_grep " ) ) ) ;
2006-07-11 14:15:56 +00:00
2008-02-27 13:17:29 +00:00
/* tools commands */
2009-11-17 21:49:43 +00:00
ui_setup_open_button_callback ( ui_lookup_widget ( ui_widgets . prefs_dialog , " button_contextaction " ) ,
2009-11-17 23:01:33 +00:00
NULL ,
2009-11-17 21:49:43 +00:00
GTK_FILE_CHOOSER_ACTION_OPEN ,
GTK_ENTRY ( ui_lookup_widget ( ui_widgets . prefs_dialog , " entry_contextaction " ) ) ) ;
2007-11-17 14:04:27 +00:00
2008-02-27 13:17:29 +00:00
/* printing */
2009-11-17 21:49:43 +00:00
ui_setup_open_button_callback ( ui_lookup_widget ( ui_widgets . prefs_dialog , " button_print_external_cmd " ) ,
2009-11-17 23:01:33 +00:00
NULL ,
2009-11-17 21:49:43 +00:00
GTK_FILE_CHOOSER_ACTION_OPEN ,
GTK_ENTRY ( ui_lookup_widget ( ui_widgets . prefs_dialog , " entry_print_external_cmd " ) ) ) ;
2008-12-18 21:21:53 +00:00
g_signal_connect ( ui_lookup_widget ( ui_widgets . prefs_dialog , " radio_print_gtk " ) ,
2007-11-17 14:04:27 +00:00
" toggled " , G_CALLBACK ( on_prefs_print_radio_button_toggled ) , NULL ) ;
2008-12-18 21:21:53 +00:00
g_signal_connect ( ui_lookup_widget ( ui_widgets . prefs_dialog , " check_print_pageheader " ) ,
2007-11-17 14:04:27 +00:00
" toggled " , G_CALLBACK ( on_prefs_print_page_header_toggled ) , NULL ) ;
2007-07-07 16:30:44 +00:00
2009-03-13 10:02:29 +00:00
g_signal_connect ( ui_lookup_widget ( ui_widgets . prefs_dialog , " check_plugins " ) ,
" toggled " , G_CALLBACK ( on_enable_plugins_toggled ) , NULL ) ;
2008-12-18 21:21:53 +00:00
g_signal_connect ( ui_lookup_widget ( ui_widgets . prefs_dialog , " check_toolbar_show " ) ,
2007-01-26 10:43:25 +00:00
" toggled " , G_CALLBACK ( on_toolbar_show_toggled ) , NULL ) ;
2008-12-18 21:21:53 +00:00
g_signal_connect ( ui_lookup_widget ( ui_widgets . prefs_dialog , " check_show_notebook_tabs " ) ,
2007-01-26 10:43:25 +00:00
" toggled " , G_CALLBACK ( on_show_notebook_tabs_toggled ) , NULL ) ;
2008-12-18 21:21:53 +00:00
g_signal_connect ( ui_lookup_widget ( ui_widgets . prefs_dialog , " check_folding " ) ,
2007-01-26 10:43:25 +00:00
" toggled " , G_CALLBACK ( on_use_folding_toggled ) , NULL ) ;
2008-12-18 21:21:53 +00:00
g_signal_connect ( ui_lookup_widget ( ui_widgets . prefs_dialog , " check_open_encoding " ) ,
2007-06-26 15:41:27 +00:00
" toggled " , G_CALLBACK ( on_open_encoding_toggled ) , NULL ) ;
2009-12-31 15:48:39 +00:00
g_signal_connect ( ui_lookup_widget ( ui_widgets . prefs_dialog , " check_sidebar_visible " ) ,
" toggled " , G_CALLBACK ( on_sidebar_visible_toggled ) , NULL ) ;
2009-11-23 23:03:39 +00:00
g_signal_connect ( ui_widgets . prefs_dialog ,
" key-press-event " , G_CALLBACK ( prefs_dialog_key_press_response_cb ) , NULL ) ;
2006-07-11 14:15:56 +00:00
}
prefs_init_dialog ( ) ;
2008-05-10 08:32:30 +00:00
gtk_window_present ( GTK_WINDOW ( ui_widgets . prefs_dialog ) ) ;
2006-07-11 14:15:56 +00:00
}