2005-11-27 20:54:28 +00:00
/*
* vte . c - this file is part of Geany , a fast and lightweight IDE
*
2008-01-06 18:11:57 +00:00
* Copyright 2005 - 2008 Enrico Tröger < enrico ( dot ) troeger ( at ) uvena ( dot ) de >
* Copyright 2006 - 2008 Nick Treleaven < nick ( dot ) treleaven ( at ) btinternet ( dot ) com >
2005-11-27 20:54:28 +00:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 2 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software
2006-05-22 00:19:15 +00:00
* Foundation , Inc . , 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 , USA .
2005-11-27 20:54:28 +00:00
*
* $ Id $
*/
2007-02-24 11:41:56 +00:00
/*
* Virtual Terminal Emulation setup and handling code , using the libvte plugin library .
*/
2005-11-27 20:54:28 +00:00
# include "geany.h"
# ifdef HAVE_VTE
# include <gdk/gdkkeysyms.h>
# include <signal.h>
# include <string.h>
# include "vte.h"
# include "msgwindow.h"
# include "support.h"
2006-11-23 15:04:10 +00:00
# include "prefs.h"
2006-11-24 11:47:29 +00:00
# include "ui_utils.h"
2006-12-07 16:51:31 +00:00
# include "utils.h"
2007-05-23 13:40:57 +00:00
# include "document.h"
2007-06-11 08:58:37 +00:00
# include "callbacks.h"
2008-01-09 13:24:36 +00:00
# include "geanywraplabel.h"
2005-11-27 20:54:28 +00:00
2006-08-19 15:07:11 +00:00
VteInfo vte_info ;
2005-11-27 20:54:28 +00:00
extern gchar * * environ ;
static pid_t pid ;
2007-12-06 16:38:13 +00:00
static gboolean clean = TRUE ;
2005-11-27 20:54:28 +00:00
static GModule * module = NULL ;
2006-08-22 19:03:38 +00:00
static struct VteFunctions * vf ;
2006-08-13 08:45:59 +00:00
static gboolean popup_menu_created = FALSE ;
2006-08-23 16:37:05 +00:00
static gchar * gtk_menu_key_accel = NULL ;
2006-11-24 11:47:29 +00:00
static gint vte_prefs_tab_num = - 1 ;
2005-11-27 20:54:28 +00:00
2006-11-24 11:47:29 +00:00
// use vte wordchars to select paths
2006-09-27 14:57:17 +00:00
static const gchar VTE_WORDCHARS [ ] = " -A-Za-z0-9,./?%&#:_ " ;
2005-12-11 02:16:02 +00:00
2005-11-27 20:54:28 +00:00
# define VTE_TERMINAL(obj) (GTK_CHECK_CAST((obj), VTE_TYPE_TERMINAL, VteTerminal))
# define VTE_TYPE_TERMINAL (vf->vte_terminal_get_type())
2007-09-26 16:22:20 +00:00
static void create_vte ( ) ;
2006-04-27 17:54:02 +00:00
static void vte_start ( GtkWidget * widget ) ;
2006-05-22 00:19:15 +00:00
static gboolean vte_button_pressed ( GtkWidget * widget , GdkEventButton * event , gpointer user_data ) ;
2007-12-06 16:38:13 +00:00
static gboolean vte_keyrelease ( GtkWidget * widget , GdkEventKey * event , gpointer data ) ;
2006-05-22 00:19:15 +00:00
static gboolean vte_keypress ( GtkWidget * widget , GdkEventKey * event , gpointer data ) ;
static void vte_register_symbols ( GModule * module ) ;
static void vte_popup_menu_clicked ( GtkMenuItem * menuitem , gpointer user_data ) ;
static GtkWidget * vte_create_popup_menu ( void ) ;
2007-12-06 16:38:13 +00:00
void vte_commit ( VteTerminal * vte , gchar * arg1 , guint arg2 , gpointer user_data ) ;
2007-12-12 16:55:00 +00:00
void vte_drag_data_received ( GtkWidget * widget , GdkDragContext * drag_context , gint x , gint y ,
GtkSelectionData * data , guint info , guint ltime ) ;
2006-04-27 17:54:02 +00:00
2005-11-27 20:54:28 +00:00
2007-05-23 13:40:57 +00:00
enum
{
POPUP_COPY ,
POPUP_PASTE ,
POPUP_CHANGEPATH ,
2007-11-07 17:16:28 +00:00
POPUP_RESTARTTERMINAL ,
2007-12-12 16:55:00 +00:00
POPUP_PREFERENCES ,
TARGET_UTF8_STRING = 0 ,
TARGET_TEXT ,
TARGET_COMPOUND_TEXT ,
TARGET_STRING ,
TARGET_TEXT_PLAIN ,
} ;
static const GtkTargetEntry dnd_targets [ ] =
{
{ " UTF8_STRING " , 0 , TARGET_UTF8_STRING } ,
{ " TEXT " , 0 , TARGET_TEXT } ,
{ " COMPOUND_TEXT " , 0 , TARGET_COMPOUND_TEXT } ,
{ " STRING " , 0 , TARGET_STRING } ,
{ " text/plain " , 0 , TARGET_TEXT_PLAIN } ,
2007-05-23 13:40:57 +00:00
} ;
2007-09-26 16:22:20 +00:00
2005-11-27 20:54:28 +00:00
/* taken from anjuta, thanks */
2006-04-27 17:54:02 +00:00
static gchar * * vte_get_child_environment ( void )
2005-11-27 20:54:28 +00:00
{
2006-04-25 16:29:48 +00:00
// code from gnome-terminal, sort of.
2005-11-27 20:54:28 +00:00
gchar * * p ;
gint i ;
gchar * * retval ;
# define EXTRA_ENV_VARS 5
2006-04-25 16:29:48 +00:00
// count env vars that are set
2005-11-27 20:54:28 +00:00
for ( p = environ ; * p ; p + + ) ;
i = p - environ ;
2006-04-25 16:29:48 +00:00
retval = g_new0 ( gchar * , i + 1 + EXTRA_ENV_VARS ) ;
2005-11-27 20:54:28 +00:00
for ( i = 0 , p = environ ; * p ; p + + )
{
2006-04-25 16:29:48 +00:00
// Strip all these out, we'll replace some of them
2005-11-27 20:54:28 +00:00
if ( ( strncmp ( * p , " COLUMNS= " , 8 ) = = 0 ) | |
( strncmp ( * p , " LINES= " , 6 ) = = 0 ) | |
( strncmp ( * p , " TERM= " , 5 ) = = 0 ) )
{
2006-04-25 16:29:48 +00:00
// nothing: do not copy
2005-11-27 20:54:28 +00:00
}
else
{
retval [ i ] = g_strdup ( * p ) ;
+ + i ;
}
}
2006-04-25 16:29:48 +00:00
retval [ i ] = g_strdup ( " TERM=xterm " ) ;
2005-11-27 20:54:28 +00:00
+ + i ;
retval [ i ] = NULL ;
return retval ;
}
2006-12-01 12:19:09 +00:00
static void override_menu_key ( )
{
if ( gtk_menu_key_accel = = NULL ) // for restoring the default value
g_object_get ( G_OBJECT ( gtk_settings_get_default ( ) ) , " gtk-menu-bar-accel " ,
& gtk_menu_key_accel , NULL ) ;
if ( vc - > ignore_menu_bar_accel )
gtk_settings_set_string_property ( gtk_settings_get_default ( ) , " gtk-menu-bar-accel " ,
" <Shift><Control><Mod1><Mod2><Mod3><Mod4><Mod5>F10 " , " Geany " ) ;
else
gtk_settings_set_string_property ( gtk_settings_get_default ( ) ,
" gtk-menu-bar-accel " , gtk_menu_key_accel , " Geany " ) ;
}
2005-11-27 20:54:28 +00:00
void vte_init ( void )
{
2006-08-19 15:07:11 +00:00
if ( vte_info . have_vte = = FALSE )
2006-04-05 14:15:14 +00:00
{ // app->have_vte can be false, even if VTE is compiled in, think of command line option
geany_debug ( " Disabling terminal support " ) ;
return ;
}
2006-05-22 00:19:15 +00:00
2007-10-19 14:48:19 +00:00
if ( vte_info . lib_vte & & vte_info . lib_vte [ 0 ] ! = ' \0 ' )
2006-01-06 18:37:24 +00:00
{
2006-08-19 15:07:11 +00:00
module = g_module_open ( vte_info . lib_vte , G_MODULE_BIND_LAZY ) ;
2006-01-06 18:37:24 +00:00
}
2007-10-19 14:48:19 +00:00
# ifdef VTE_MODULE_PATH
2006-01-06 18:37:24 +00:00
else
2007-10-19 14:48:19 +00:00
{
module = g_module_open ( VTE_MODULE_PATH , G_MODULE_BIND_LAZY ) ;
}
# endif
if ( module = = NULL )
2006-01-06 18:37:24 +00:00
{
2007-01-25 15:45:14 +00:00
gint i ;
const gchar * sonames [ ] = { " libvte.so " , " libvte.so.4 " ,
" libvte.so.8 " , " libvte.so.9 " , NULL } ;
for ( i = 0 ; sonames [ i ] ! = NULL & & module = = NULL ; i + + )
{
module = g_module_open ( sonames [ i ] , G_MODULE_BIND_LAZY ) ;
}
2006-01-06 18:37:24 +00:00
}
2005-11-27 20:54:28 +00:00
2006-04-05 14:15:14 +00:00
if ( module = = NULL )
2005-11-27 20:54:28 +00:00
{
2006-08-19 15:07:11 +00:00
vte_info . have_vte = FALSE ;
2006-11-11 00:07:49 +00:00
geany_debug ( " Could not load libvte.so, terminal support disabled " ) ;
2005-11-27 20:54:28 +00:00
return ;
}
else
{
2006-08-19 15:07:11 +00:00
vte_info . have_vte = TRUE ;
2006-08-22 19:03:38 +00:00
vf = g_new0 ( struct VteFunctions , 1 ) ;
2005-11-27 20:54:28 +00:00
vte_register_symbols ( module ) ;
}
2007-09-26 16:22:20 +00:00
create_vte ( ) ;
// setup the f10 menu override (so it works before the widget is first realized).
override_menu_key ( ) ;
}
static void create_vte ( )
{
GtkWidget * vte , * scrollbar , * hbox , * frame ;
2005-11-27 20:54:28 +00:00
vte = vf - > vte_terminal_new ( ) ;
2005-12-11 02:16:02 +00:00
vc - > vte = vte ;
2005-11-27 20:54:28 +00:00
scrollbar = gtk_vscrollbar_new ( GTK_ADJUSTMENT ( VTE_TERMINAL ( vte ) - > adjustment ) ) ;
GTK_WIDGET_UNSET_FLAGS ( scrollbar , GTK_CAN_FOCUS ) ;
frame = gtk_frame_new ( NULL ) ;
hbox = gtk_hbox_new ( FALSE , 0 ) ;
gtk_container_add ( GTK_CONTAINER ( frame ) , hbox ) ;
gtk_box_pack_start ( GTK_BOX ( hbox ) , vte , TRUE , TRUE , 0 ) ;
2006-07-15 19:10:37 +00:00
gtk_box_pack_start ( GTK_BOX ( hbox ) , scrollbar , FALSE , FALSE , 0 ) ;
2005-11-27 20:54:28 +00:00
2006-11-25 12:23:49 +00:00
/* set the default widget size first to prevent VTE expanding too much,
* sometimes causing the hscrollbar to be too big or out of view . */
2006-11-12 15:29:40 +00:00
gtk_widget_set_size_request ( GTK_WIDGET ( vte ) , 10 , 10 ) ;
2005-12-16 22:19:51 +00:00
vf - > vte_terminal_set_size ( VTE_TERMINAL ( vte ) , 30 , 1 ) ;
2006-11-25 12:23:49 +00:00
2005-12-11 02:16:02 +00:00
vf - > vte_terminal_set_mouse_autohide ( VTE_TERMINAL ( vte ) , TRUE ) ;
2006-09-27 14:57:17 +00:00
vf - > vte_terminal_set_word_chars ( VTE_TERMINAL ( vte ) , VTE_WORDCHARS ) ;
2005-11-27 20:54:28 +00:00
2007-12-12 16:55:00 +00:00
gtk_drag_dest_set ( vte , GTK_DEST_DEFAULT_ALL ,
dnd_targets , G_N_ELEMENTS ( dnd_targets ) , GDK_ACTION_COPY ) ;
2005-11-27 20:54:28 +00:00
g_signal_connect ( G_OBJECT ( vte ) , " child-exited " , G_CALLBACK ( vte_start ) , NULL ) ;
2005-12-11 02:16:02 +00:00
g_signal_connect ( G_OBJECT ( vte ) , " button-press-event " , G_CALLBACK ( vte_button_pressed ) , NULL ) ;
2008-01-10 17:11:19 +00:00
g_signal_connect ( G_OBJECT ( vte ) , " event " , G_CALLBACK ( vte_keypress ) , NULL ) ;
2007-12-06 16:38:13 +00:00
g_signal_connect ( G_OBJECT ( vte ) , " key-release-event " , G_CALLBACK ( vte_keyrelease ) , NULL ) ;
g_signal_connect ( G_OBJECT ( vte ) , " commit " , G_CALLBACK ( vte_commit ) , NULL ) ;
2007-06-11 08:58:37 +00:00
g_signal_connect ( G_OBJECT ( vte ) , " motion-notify-event " , G_CALLBACK ( on_motion_event ) , NULL ) ;
2007-12-12 16:55:00 +00:00
g_signal_connect ( G_OBJECT ( vte ) , " drag-data-received " , G_CALLBACK ( vte_drag_data_received ) , NULL ) ;
2005-11-27 20:54:28 +00:00
2006-04-27 17:54:02 +00:00
vte_start ( vte ) ;
2005-11-27 20:54:28 +00:00
gtk_widget_show_all ( frame ) ;
gtk_notebook_insert_page ( GTK_NOTEBOOK ( msgwindow . notebook ) , frame , gtk_label_new ( _ ( " Terminal " ) ) , MSG_VTE ) ;
2005-12-12 01:55:21 +00:00
2006-04-05 14:15:14 +00:00
// the vte widget has to be realised before color changes take effect
2006-07-15 19:10:37 +00:00
g_signal_connect ( G_OBJECT ( vte ) , " realize " , G_CALLBACK ( vte_apply_user_settings ) , NULL ) ;
2005-11-27 20:54:28 +00:00
}
void vte_close ( void )
{
g_free ( vf ) ;
2006-04-29 18:14:19 +00:00
/* free the vte widget before unloading vte module
2006-12-20 15:43:01 +00:00
* this prevents a segfault on X close window if the message window is hidden */
2006-04-29 18:14:19 +00:00
gtk_widget_destroy ( vc - > vte ) ;
2006-08-13 08:45:59 +00:00
if ( popup_menu_created ) gtk_widget_destroy ( vc - > menu ) ;
2005-12-11 02:16:02 +00:00
g_free ( vc - > emulation ) ;
2006-12-20 15:43:01 +00:00
g_free ( vc - > shell ) ;
g_free ( vc - > font ) ;
2006-08-22 19:03:38 +00:00
g_free ( vc - > colour_back ) ;
g_free ( vc - > colour_fore ) ;
2005-12-11 02:16:02 +00:00
g_free ( vc ) ;
2006-08-23 16:37:05 +00:00
g_free ( gtk_menu_key_accel ) ;
2006-11-15 18:20:13 +00:00
// don't unload the module explicitly because it causes a segfault on FreeBSD
//g_module_close(module);
2005-11-27 20:54:28 +00:00
}
2007-12-06 16:38:13 +00:00
static gboolean vte_keyrelease ( GtkWidget * widget , GdkEventKey * event , gpointer data )
{
if ( event - > keyval = = GDK_Return | |
event - > keyval = = GDK_ISO_Enter | |
event - > keyval = = GDK_KP_Enter )
{
clean = TRUE ; // assume any text on the prompt has been executed when pressing Enter/Return
}
return FALSE ;
}
2006-05-22 00:19:15 +00:00
static gboolean vte_keypress ( GtkWidget * widget , GdkEventKey * event , gpointer data )
2005-11-27 20:54:28 +00:00
{
2008-01-10 17:11:19 +00:00
if ( vc - > enable_bash_keys )
return FALSE ; // Ctrl-[CD] will be handled by the VTE itself
2007-10-18 11:37:45 +00:00
if ( event - > type ! = GDK_KEY_RELEASE )
2005-11-27 20:54:28 +00:00
return FALSE ;
2006-05-22 00:19:15 +00:00
if ( ( event - > keyval = = GDK_c | |
2005-11-27 20:54:28 +00:00
event - > keyval = = GDK_d | |
event - > keyval = = GDK_C | |
2006-05-22 00:19:15 +00:00
event - > keyval = = GDK_D ) & &
2007-09-26 16:22:20 +00:00
event - > state & GDK_CONTROL_MASK & &
! ( event - > state & GDK_SHIFT_MASK ) & & ! ( event - > state & GDK_MOD1_MASK ) )
2005-11-27 20:54:28 +00:00
{
2006-08-23 16:37:05 +00:00
vte_get_working_directory ( ) ; // try to keep the working directory when restarting the VTE
2007-04-19 13:44:42 +00:00
if ( pid > 0 )
{
kill ( pid , SIGINT ) ;
pid = 0 ;
}
2006-06-29 23:51:32 +00:00
vf - > vte_terminal_reset ( VTE_TERMINAL ( widget ) , TRUE , TRUE ) ;
2006-05-22 00:19:15 +00:00
vte_start ( widget ) ;
2006-08-23 16:37:05 +00:00
2006-05-22 00:19:15 +00:00
return TRUE ;
2005-11-27 20:54:28 +00:00
}
return FALSE ;
}
2007-12-06 16:38:13 +00:00
void vte_commit ( VteTerminal * vte , gchar * arg1 , guint arg2 , gpointer user_data )
{
clean = FALSE ;
}
2006-04-27 17:54:02 +00:00
static void vte_start ( GtkWidget * widget )
2005-11-27 20:54:28 +00:00
{
VteTerminal * vte = VTE_TERMINAL ( widget ) ;
gchar * * env ;
2007-04-19 13:44:42 +00:00
gchar * * argv ;
// split the shell command line, so arguments will work too
argv = g_strsplit ( vc - > shell , " " , - 1 ) ;
2005-11-27 20:54:28 +00:00
2007-04-19 13:44:42 +00:00
if ( argv ! = NULL )
{
env = vte_get_child_environment ( ) ;
pid = vf - > vte_terminal_fork_command ( VTE_TERMINAL ( vte ) , argv [ 0 ] , argv , env ,
2006-08-22 19:03:38 +00:00
vte_info . dir , TRUE , TRUE , TRUE ) ;
2007-04-19 13:44:42 +00:00
g_strfreev ( env ) ;
g_strfreev ( argv ) ;
}
else
pid = 0 ; // use 0 as invalid pid
2007-12-06 16:38:13 +00:00
clean = TRUE ;
2005-11-27 20:54:28 +00:00
}
2007-11-07 17:16:28 +00:00
static void vte_restart ( GtkWidget * widget )
{
vte_get_working_directory ( ) ; // try to keep the working directory when restarting the VTE
if ( pid > 0 )
{
kill ( pid , SIGINT ) ;
pid = 0 ;
}
vf - > vte_terminal_reset ( VTE_TERMINAL ( widget ) , TRUE , TRUE ) ;
vte_start ( widget ) ;
}
2006-05-22 00:19:15 +00:00
static gboolean vte_button_pressed ( GtkWidget * widget , GdkEventButton * event , gpointer user_data )
2005-12-11 02:16:02 +00:00
{
2006-05-23 20:26:23 +00:00
if ( event - > button = = 3 )
2005-12-11 02:16:02 +00:00
{
2006-08-13 08:45:59 +00:00
if ( ! popup_menu_created )
{
vc - > menu = vte_create_popup_menu ( ) ;
vf - > vte_terminal_im_append_menuitems ( VTE_TERMINAL ( vc - > vte ) , GTK_MENU_SHELL ( vc - > im_submenu ) ) ;
popup_menu_created = TRUE ;
}
2007-12-04 15:28:17 +00:00
gtk_widget_grab_focus ( vc - > vte ) ;
2005-12-16 22:19:51 +00:00
gtk_menu_popup ( GTK_MENU ( vc - > menu ) , NULL , NULL , NULL , NULL , event - > button , event - > time ) ;
2005-12-11 02:16:02 +00:00
}
return FALSE ;
}
2006-05-22 00:19:15 +00:00
static void vte_register_symbols ( GModule * mod )
2005-11-27 20:54:28 +00:00
{
g_module_symbol ( mod , " vte_terminal_new " , ( void * ) & vf - > vte_terminal_new ) ;
g_module_symbol ( mod , " vte_terminal_set_size " , ( void * ) & vf - > vte_terminal_set_size ) ;
g_module_symbol ( mod , " vte_terminal_fork_command " , ( void * ) & vf - > vte_terminal_fork_command ) ;
g_module_symbol ( mod , " vte_terminal_set_word_chars " , ( void * ) & vf - > vte_terminal_set_word_chars ) ;
g_module_symbol ( mod , " vte_terminal_set_mouse_autohide " , ( void * ) & vf - > vte_terminal_set_mouse_autohide ) ;
g_module_symbol ( mod , " vte_terminal_reset " , ( void * ) & vf - > vte_terminal_reset ) ;
g_module_symbol ( mod , " vte_terminal_get_type " , ( void * ) & vf - > vte_terminal_get_type ) ;
g_module_symbol ( mod , " vte_terminal_set_scroll_on_output " , ( void * ) & vf - > vte_terminal_set_scroll_on_output ) ;
g_module_symbol ( mod , " vte_terminal_set_scroll_on_keystroke " , ( void * ) & vf - > vte_terminal_set_scroll_on_keystroke ) ;
g_module_symbol ( mod , " vte_terminal_set_font_from_string " , ( void * ) & vf - > vte_terminal_set_font_from_string ) ;
g_module_symbol ( mod , " vte_terminal_set_scrollback_lines " , ( void * ) & vf - > vte_terminal_set_scrollback_lines ) ;
g_module_symbol ( mod , " vte_terminal_get_has_selection " , ( void * ) & vf - > vte_terminal_get_has_selection ) ;
2005-12-11 02:16:02 +00:00
g_module_symbol ( mod , " vte_terminal_copy_clipboard " , ( void * ) & vf - > vte_terminal_copy_clipboard ) ;
g_module_symbol ( mod , " vte_terminal_paste_clipboard " , ( void * ) & vf - > vte_terminal_paste_clipboard ) ;
g_module_symbol ( mod , " vte_terminal_set_emulation " , ( void * ) & vf - > vte_terminal_set_emulation ) ;
g_module_symbol ( mod , " vte_terminal_set_color_foreground " , ( void * ) & vf - > vte_terminal_set_color_foreground ) ;
g_module_symbol ( mod , " vte_terminal_set_color_background " , ( void * ) & vf - > vte_terminal_set_color_background ) ;
2006-06-29 23:51:32 +00:00
g_module_symbol ( mod , " vte_terminal_feed_child " , ( void * ) & vf - > vte_terminal_feed_child ) ;
2006-08-13 08:45:59 +00:00
g_module_symbol ( mod , " vte_terminal_im_append_menuitems " , ( void * ) & vf - > vte_terminal_im_append_menuitems ) ;
2005-11-27 20:54:28 +00:00
}
2005-12-11 02:16:02 +00:00
void vte_apply_user_settings ( void )
{
2007-08-23 11:34:06 +00:00
if ( ! ui_prefs . msgwindow_visible ) return ;
2006-05-22 00:19:15 +00:00
//if (! GTK_WIDGET_REALIZED(vc->vte)) gtk_widget_realize(vc->vte);
2005-12-11 02:16:02 +00:00
vf - > vte_terminal_set_scrollback_lines ( VTE_TERMINAL ( vc - > vte ) , vc - > scrollback_lines ) ;
vf - > vte_terminal_set_scroll_on_keystroke ( VTE_TERMINAL ( vc - > vte ) , vc - > scroll_on_key ) ;
vf - > vte_terminal_set_scroll_on_output ( VTE_TERMINAL ( vc - > vte ) , vc - > scroll_on_out ) ;
vf - > vte_terminal_set_emulation ( VTE_TERMINAL ( vc - > vte ) , vc - > emulation ) ;
2006-05-22 00:19:15 +00:00
vf - > vte_terminal_set_font_from_string ( VTE_TERMINAL ( vc - > vte ) , vc - > font ) ;
2006-08-22 19:03:38 +00:00
vf - > vte_terminal_set_color_foreground ( VTE_TERMINAL ( vc - > vte ) , vc - > colour_fore ) ;
vf - > vte_terminal_set_color_background ( VTE_TERMINAL ( vc - > vte ) , vc - > colour_back ) ;
2005-12-11 02:16:02 +00:00
2006-12-01 12:19:09 +00:00
override_menu_key ( ) ;
2005-12-11 02:16:02 +00:00
}
2006-05-22 00:19:15 +00:00
static void vte_popup_menu_clicked ( GtkMenuItem * menuitem , gpointer user_data )
2005-12-16 22:19:51 +00:00
{
switch ( GPOINTER_TO_INT ( user_data ) )
{
2007-05-23 13:40:57 +00:00
case POPUP_COPY :
2005-12-16 22:19:51 +00:00
{
if ( vf - > vte_terminal_get_has_selection ( VTE_TERMINAL ( vc - > vte ) ) )
vf - > vte_terminal_copy_clipboard ( VTE_TERMINAL ( vc - > vte ) ) ;
break ;
}
2007-05-23 13:40:57 +00:00
case POPUP_PASTE :
2005-12-16 22:19:51 +00:00
{
vf - > vte_terminal_paste_clipboard ( VTE_TERMINAL ( vc - > vte ) ) ;
break ;
}
2007-05-23 13:40:57 +00:00
case POPUP_CHANGEPATH :
{
gint idx = document_get_cur_idx ( ) ;
if ( DOC_IDX_VALID ( idx ) )
vte_cwd ( doc_list [ idx ] . file_name , TRUE ) ;
break ;
}
2007-11-07 17:16:28 +00:00
case POPUP_RESTARTTERMINAL :
{
vte_restart ( vc - > vte ) ;
break ;
}
2007-05-23 13:40:57 +00:00
case POPUP_PREFERENCES :
2005-12-16 22:19:51 +00:00
{
2006-11-23 15:04:10 +00:00
GtkWidget * notebook ;
2007-03-23 16:47:27 +00:00
prefs_show_dialog ( ) ;
2006-11-23 15:04:10 +00:00
2007-08-23 11:34:06 +00:00
notebook = lookup_widget ( ui_widgets . prefs_dialog , " notebook2 " ) ;
2006-11-18 15:47:28 +00:00
2006-11-24 11:47:29 +00:00
gtk_notebook_set_current_page ( GTK_NOTEBOOK ( notebook ) , vte_prefs_tab_num ) ;
2005-12-16 22:19:51 +00:00
break ;
}
}
}
2006-05-22 00:19:15 +00:00
static GtkWidget * vte_create_popup_menu ( void )
2005-12-16 22:19:51 +00:00
{
GtkWidget * menu , * item ;
menu = gtk_menu_new ( ) ;
item = gtk_image_menu_item_new_from_stock ( " gtk-copy " , NULL ) ;
gtk_widget_show ( item ) ;
gtk_container_add ( GTK_CONTAINER ( menu ) , item ) ;
2007-05-23 13:40:57 +00:00
g_signal_connect ( ( gpointer ) item , " activate " , G_CALLBACK ( vte_popup_menu_clicked ) , GINT_TO_POINTER ( POPUP_COPY ) ) ;
2005-12-16 22:19:51 +00:00
item = gtk_image_menu_item_new_from_stock ( " gtk-paste " , NULL ) ;
gtk_widget_show ( item ) ;
gtk_container_add ( GTK_CONTAINER ( menu ) , item ) ;
2007-05-23 13:40:57 +00:00
g_signal_connect ( ( gpointer ) item , " activate " , G_CALLBACK ( vte_popup_menu_clicked ) , GINT_TO_POINTER ( POPUP_PASTE ) ) ;
2007-11-08 16:21:46 +00:00
item = gtk_separator_menu_item_new ( ) ;
gtk_widget_show ( item ) ;
gtk_container_add ( GTK_CONTAINER ( menu ) , item ) ;
item = gtk_image_menu_item_new_with_label ( _ ( " Set Path From Document " ) ) ;
2007-05-23 13:40:57 +00:00
gtk_widget_show ( item ) ;
gtk_container_add ( GTK_CONTAINER ( menu ) , item ) ;
g_signal_connect ( ( gpointer ) item , " activate " , G_CALLBACK ( vte_popup_menu_clicked ) , GINT_TO_POINTER ( POPUP_CHANGEPATH ) ) ;
2005-12-16 22:19:51 +00:00
2007-11-08 16:21:46 +00:00
item = gtk_image_menu_item_new_with_label ( _ ( " Restart Terminal " ) ) ;
2007-11-07 17:16:28 +00:00
gtk_widget_show ( item ) ;
gtk_container_add ( GTK_CONTAINER ( menu ) , item ) ;
g_signal_connect ( ( gpointer ) item , " activate " , G_CALLBACK ( vte_popup_menu_clicked ) , GINT_TO_POINTER ( POPUP_RESTARTTERMINAL ) ) ;
2005-12-16 22:19:51 +00:00
item = gtk_separator_menu_item_new ( ) ;
gtk_widget_show ( item ) ;
gtk_container_add ( GTK_CONTAINER ( menu ) , item ) ;
2007-11-08 16:21:46 +00:00
vc - > im_submenu = gtk_menu_new ( ) ;
item = gtk_image_menu_item_new_with_mnemonic ( _ ( " _Input Methods " ) ) ;
2005-12-16 22:19:51 +00:00
gtk_widget_show ( item ) ;
gtk_container_add ( GTK_CONTAINER ( menu ) , item ) ;
2007-11-08 16:21:46 +00:00
gtk_menu_item_set_submenu ( GTK_MENU_ITEM ( item ) , vc - > im_submenu ) ;
2005-12-16 22:19:51 +00:00
2006-08-13 08:45:59 +00:00
item = gtk_separator_menu_item_new ( ) ;
gtk_widget_show ( item ) ;
gtk_container_add ( GTK_CONTAINER ( menu ) , item ) ;
2007-11-08 16:21:46 +00:00
item = gtk_image_menu_item_new_from_stock ( " gtk-preferences " , NULL ) ;
2006-08-13 08:45:59 +00:00
gtk_widget_show ( item ) ;
gtk_container_add ( GTK_CONTAINER ( menu ) , item ) ;
2007-11-08 16:21:46 +00:00
g_signal_connect ( ( gpointer ) item , " activate " , G_CALLBACK ( vte_popup_menu_clicked ) , GINT_TO_POINTER ( POPUP_PREFERENCES ) ) ;
2006-08-13 08:45:59 +00:00
2006-12-13 16:41:25 +00:00
msgwin_menu_add_common_items ( GTK_MENU ( menu ) ) ;
2005-12-16 22:19:51 +00:00
return menu ;
}
2007-12-06 16:38:13 +00:00
/* if the command could be executed, TRUE is returned, FALSE otherwise (i.e. there was some text
* on the prompt ) . */
gboolean vte_send_cmd ( const gchar * cmd )
2006-06-29 23:51:32 +00:00
{
2007-12-06 16:38:13 +00:00
if ( clean )
{
vf - > vte_terminal_feed_child ( VTE_TERMINAL ( vc - > vte ) , cmd , strlen ( cmd ) ) ;
clean = TRUE ; // vte_terminal_feed_child() also marks the vte as not clean
return TRUE ;
}
else
return FALSE ;
2006-06-29 23:51:32 +00:00
}
2005-12-16 22:19:51 +00:00
2006-08-19 15:07:11 +00:00
/* Taken from Terminal by os-cillation: terminal_screen_get_working_directory, thanks.
2006-08-20 15:47:18 +00:00
* Determines the working directory using various OS - specific mechanisms . */
2006-08-19 15:07:11 +00:00
const gchar * vte_get_working_directory ( )
{
2006-12-10 21:29:04 +00:00
gchar buffer [ 4096 + 1 ] ;
gchar * file ;
gchar * cwd ;
gint length ;
2007-04-19 13:44:42 +00:00
if ( pid > 0 )
2006-12-10 21:29:04 +00:00
{
file = g_strdup_printf ( " /proc/%d/cwd " , pid ) ;
length = readlink ( file , buffer , sizeof ( buffer ) ) ;
if ( length > 0 & & * buffer = = ' / ' )
{
buffer [ length ] = ' \0 ' ;
g_free ( vte_info . dir ) ;
vte_info . dir = g_strdup ( buffer ) ;
}
else if ( length = = 0 )
{
cwd = g_get_current_dir ( ) ;
if ( G_LIKELY ( cwd ! = NULL ) )
{
if ( chdir ( file ) = = 0 )
{
g_free ( vte_info . dir ) ;
vte_info . dir = g_get_current_dir ( ) ;
chdir ( cwd ) ;
}
g_free ( cwd ) ;
}
}
g_free ( file ) ;
}
return vte_info . dir ;
2006-08-19 15:07:11 +00:00
}
2007-12-17 16:58:26 +00:00
/* Changes the current working directory of the VTE to the path of the given filename.
* filename is expected to be in UTF - 8 encoding .
* filename can also be a path , then it is used directly .
* If force is set to TRUE , it will always change the cwd
* */
2006-12-10 21:29:04 +00:00
void vte_cwd ( const gchar * filename , gboolean force )
2006-08-30 18:53:45 +00:00
{
2006-12-10 21:29:04 +00:00
if ( vte_info . have_vte & & ( vc - > follow_path | | force ) & & filename ! = NULL )
2006-08-30 18:53:45 +00:00
{
gchar * path ;
2007-12-17 16:58:26 +00:00
if ( g_file_test ( filename , G_FILE_TEST_IS_DIR ) )
path = g_strdup ( filename ) ;
else
path = g_path_get_dirname ( filename ) ;
vte_get_working_directory ( ) ; // refresh vte_info.dir
2006-12-07 16:12:01 +00:00
if ( ! utils_str_equal ( path , vte_info . dir ) )
2006-08-30 18:53:45 +00:00
{
2007-01-16 15:57:00 +00:00
// use g_shell_quote to avoid problems with spaces, '!' or something else in path
gchar * quoted_path = g_shell_quote ( path ) ;
gchar * cmd = g_strconcat ( " cd " , quoted_path , " \n " , NULL ) ;
2007-12-06 16:38:13 +00:00
if ( ! vte_send_cmd ( cmd ) )
ui_set_statusbar ( FALSE ,
_ ( " Could not change the directory in the VTE because it probably contains a command. " ) ) ;
2007-01-16 15:57:00 +00:00
g_free ( quoted_path ) ;
2006-08-30 18:53:45 +00:00
g_free ( cmd ) ;
}
g_free ( path ) ;
}
}
2007-12-12 16:55:00 +00:00
void vte_drag_data_received ( GtkWidget * widget , GdkDragContext * drag_context , gint x , gint y ,
GtkSelectionData * data , guint info , guint ltime )
2005-12-16 22:19:51 +00:00
{
2007-12-12 16:55:00 +00:00
if ( info = = TARGET_TEXT_PLAIN )
2005-12-16 22:19:51 +00:00
{
2007-12-12 16:55:00 +00:00
if ( data - > format = = 8 & & data - > length > 0 )
vf - > vte_terminal_feed_child ( VTE_TERMINAL ( widget ) ,
( const gchar * ) data - > data , data - > length ) ;
2005-12-16 22:19:51 +00:00
}
2007-12-12 16:55:00 +00:00
else
{
gchar * text = ( gchar * ) gtk_selection_data_get_text ( data ) ;
if ( NZV ( text ) )
vf - > vte_terminal_feed_child ( VTE_TERMINAL ( widget ) , text , strlen ( text ) ) ;
g_free ( text ) ;
}
gtk_drag_finish ( drag_context , TRUE , FALSE , ltime ) ;
2005-12-16 22:19:51 +00:00
}
2006-08-22 19:03:38 +00:00
2007-12-17 16:58:26 +00:00
static void check_run_in_vte_toggled ( GtkToggleButton * togglebutton , GtkWidget * user_data )
{
gtk_widget_set_sensitive ( user_data , gtk_toggle_button_get_active ( togglebutton ) ) ;
}
2006-11-24 11:47:29 +00:00
void vte_append_preferences_tab ( )
{
if ( vte_info . have_vte )
{
GtkWidget * notebook , * vbox , * label , * alignment , * table , * frame , * box ;
GtkWidget * font_term , * color_fore , * color_back , * spin_scrollback , * entry_emulation ;
2008-01-10 17:11:19 +00:00
GtkWidget * check_scroll_key , * check_scroll_out , * check_follow_path ;
GtkWidget * check_enable_bash_keys , * check_ignore_menu_key ;
2007-12-17 16:58:26 +00:00
GtkWidget * check_run_in_vte , * check_skip_script , * entry_shell , * button_shell , * image_shell ;
2006-11-24 11:47:29 +00:00
GtkTooltips * tooltips ;
GtkObject * spin_scrollback_adj ;
2007-08-23 11:34:06 +00:00
tooltips = GTK_TOOLTIPS ( lookup_widget ( ui_widgets . prefs_dialog , " tooltips " ) ) ;
notebook = lookup_widget ( ui_widgets . prefs_dialog , " notebook2 " ) ;
2006-11-24 11:47:29 +00:00
frame = ui_frame_new_with_alignment ( _ ( " Terminal plugin " ) , & alignment ) ;
vbox = gtk_vbox_new ( FALSE , 12 ) ;
gtk_container_add ( GTK_CONTAINER ( alignment ) , vbox ) ;
label = gtk_label_new ( _ ( " Terminal " ) ) ;
vte_prefs_tab_num = gtk_notebook_append_page ( GTK_NOTEBOOK ( notebook ) , frame , label ) ;
2008-01-09 13:24:36 +00:00
label = geany_wrap_label_new ( _ ( " These settings for the virtual terminal emulator widget (VTE) only apply if the VTE library could be loaded. " ) ) ;
2006-11-24 11:47:29 +00:00
gtk_box_pack_start ( GTK_BOX ( vbox ) , label , FALSE , FALSE , 6 ) ;
gtk_label_set_justify ( GTK_LABEL ( label ) , GTK_JUSTIFY_FILL ) ;
gtk_label_set_line_wrap ( GTK_LABEL ( label ) , TRUE ) ;
gtk_misc_set_alignment ( GTK_MISC ( label ) , 0 , 0.5 ) ;
table = gtk_table_new ( 6 , 2 , FALSE ) ;
gtk_box_pack_start ( GTK_BOX ( vbox ) , table , FALSE , FALSE , 0 ) ;
gtk_table_set_row_spacings ( GTK_TABLE ( table ) , 3 ) ;
gtk_table_set_col_spacings ( GTK_TABLE ( table ) , 10 ) ;
label = gtk_label_new ( _ ( " Terminal font: " ) ) ;
gtk_table_attach ( GTK_TABLE ( table ) , label , 0 , 1 , 0 , 1 ,
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
gtk_misc_set_alignment ( GTK_MISC ( label ) , 0 , 0.5 ) ;
font_term = gtk_font_button_new ( ) ;
gtk_table_attach ( GTK_TABLE ( table ) , font_term , 1 , 2 , 0 , 1 ,
( GtkAttachOptions ) ( GTK_EXPAND | GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
gtk_tooltips_set_tip ( tooltips , font_term , _ ( " Sets the font for the terminal widget. " ) , NULL ) ;
label = gtk_label_new ( _ ( " Foreground color: " ) ) ;
gtk_table_attach ( GTK_TABLE ( table ) , label , 0 , 1 , 1 , 2 ,
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
gtk_misc_set_alignment ( GTK_MISC ( label ) , 0 , 0.5 ) ;
label = gtk_label_new ( _ ( " Background color: " ) ) ;
gtk_table_attach ( GTK_TABLE ( table ) , label , 0 , 1 , 2 , 3 ,
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
gtk_misc_set_alignment ( GTK_MISC ( label ) , 0 , 0.5 ) ;
color_fore = gtk_color_button_new ( ) ;
gtk_table_attach ( GTK_TABLE ( table ) , color_fore , 1 , 2 , 1 , 2 ,
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
gtk_tooltips_set_tip ( tooltips , color_fore , _ ( " Sets the foreground color of the text in the terminal widget. " ) , NULL ) ;
gtk_color_button_set_title ( GTK_COLOR_BUTTON ( color_fore ) , _ ( " Color Chooser " ) ) ;
color_back = gtk_color_button_new ( ) ;
gtk_table_attach ( GTK_TABLE ( table ) , color_back , 1 , 2 , 2 , 3 ,
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
gtk_tooltips_set_tip ( tooltips , color_back , _ ( " Sets the background color of the text in the terminal widget. " ) , NULL ) ;
gtk_color_button_set_title ( GTK_COLOR_BUTTON ( color_back ) , _ ( " Color Chooser " ) ) ;
label = gtk_label_new ( _ ( " Scrollback lines: " ) ) ;
gtk_table_attach ( GTK_TABLE ( table ) , label , 0 , 1 , 3 , 4 ,
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
gtk_misc_set_alignment ( GTK_MISC ( label ) , 0 , 0.5 ) ;
spin_scrollback_adj = gtk_adjustment_new ( 500 , 0 , 5000 , 1 , 10 , 10 ) ;
spin_scrollback = gtk_spin_button_new ( GTK_ADJUSTMENT ( spin_scrollback_adj ) , 1 , 0 ) ;
gtk_table_attach ( GTK_TABLE ( table ) , spin_scrollback , 1 , 2 , 3 , 4 ,
( GtkAttachOptions ) ( GTK_EXPAND | GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
gtk_tooltips_set_tip ( tooltips , spin_scrollback , _ ( " Specifies the history in lines, which you can scroll back in the terminal widget. " ) , NULL ) ;
gtk_spin_button_set_numeric ( GTK_SPIN_BUTTON ( spin_scrollback ) , TRUE ) ;
gtk_spin_button_set_wrap ( GTK_SPIN_BUTTON ( spin_scrollback ) , TRUE ) ;
label = gtk_label_new ( _ ( " Terminal emulation: " ) ) ;
gtk_table_attach ( GTK_TABLE ( table ) , label , 0 , 1 , 4 , 5 ,
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
gtk_misc_set_alignment ( GTK_MISC ( label ) , 0 , 0.5 ) ;
entry_emulation = gtk_entry_new ( ) ;
gtk_table_attach ( GTK_TABLE ( table ) , entry_emulation , 1 , 2 , 4 , 5 ,
( GtkAttachOptions ) ( GTK_EXPAND | GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
2007-01-08 18:24:45 +00:00
gtk_tooltips_set_tip ( tooltips , entry_emulation , _ ( " Controls how the terminal emulator should behave. Do not change this value unless you know exactly what you are doing. " ) , NULL ) ;
2006-11-24 11:47:29 +00:00
label = gtk_label_new ( _ ( " Shell: " ) ) ;
gtk_table_attach ( GTK_TABLE ( table ) , label , 0 , 1 , 5 , 6 ,
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
gtk_misc_set_alignment ( GTK_MISC ( label ) , 0 , 0.5 ) ;
entry_shell = gtk_entry_new ( ) ;
gtk_tooltips_set_tip ( tooltips , entry_shell , _ ( " Sets the path to the shell which should be started inside the terminal emulation. " ) , NULL ) ;
button_shell = gtk_button_new ( ) ;
gtk_widget_show ( button_shell ) ;
box = gtk_hbox_new ( FALSE , 6 ) ;
gtk_box_pack_start_defaults ( GTK_BOX ( box ) , entry_shell ) ;
gtk_box_pack_start ( GTK_BOX ( box ) , button_shell , FALSE , FALSE , 0 ) ;
gtk_table_attach ( GTK_TABLE ( table ) , box , 1 , 2 , 5 , 6 ,
( GtkAttachOptions ) ( GTK_EXPAND | GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
image_shell = gtk_image_new_from_stock ( " gtk-open " , GTK_ICON_SIZE_BUTTON ) ;
gtk_widget_show ( image_shell ) ;
gtk_container_add ( GTK_CONTAINER ( button_shell ) , image_shell ) ;
box = gtk_vbox_new ( FALSE , 3 ) ;
check_scroll_key = gtk_check_button_new_with_mnemonic ( _ ( " Scroll on keystroke " ) ) ;
gtk_tooltips_set_tip ( tooltips , check_scroll_key , _ ( " Whether to scroll to the bottom if a key was pressed. " ) , NULL ) ;
gtk_button_set_focus_on_click ( GTK_BUTTON ( check_scroll_key ) , FALSE ) ;
gtk_container_add ( GTK_CONTAINER ( box ) , check_scroll_key ) ;
check_scroll_out = gtk_check_button_new_with_mnemonic ( _ ( " Scroll on output " ) ) ;
gtk_tooltips_set_tip ( tooltips , check_scroll_out , _ ( " Whether to scroll to the bottom when output is generated. " ) , NULL ) ;
gtk_button_set_focus_on_click ( GTK_BUTTON ( check_scroll_out ) , FALSE ) ;
gtk_container_add ( GTK_CONTAINER ( box ) , check_scroll_out ) ;
2008-01-10 17:11:19 +00:00
check_enable_bash_keys = gtk_check_button_new_with_mnemonic ( _ ( " Override Geany keybindings " ) ) ;
gtk_tooltips_set_tip ( tooltips , check_enable_bash_keys ,
_ ( " Allows the VTE to receive keyboard shortcuts (apart from focus commands). " ) , NULL ) ;
gtk_button_set_focus_on_click ( GTK_BUTTON ( check_enable_bash_keys ) , FALSE ) ;
gtk_container_add ( GTK_CONTAINER ( box ) , check_enable_bash_keys ) ;
2006-11-24 11:47:29 +00:00
check_ignore_menu_key = gtk_check_button_new_with_mnemonic ( _ ( " Disable menu shortcut key (F10 by default) " ) ) ;
gtk_tooltips_set_tip ( tooltips , check_ignore_menu_key , _ ( " This option disables the keybinding to popup the menu bar (default is F10). Disabling it can be useful if you use, for example, Midnight Commander within the VTE. " ) , NULL ) ;
gtk_button_set_focus_on_click ( GTK_BUTTON ( check_ignore_menu_key ) , FALSE ) ;
gtk_container_add ( GTK_CONTAINER ( box ) , check_ignore_menu_key ) ;
check_follow_path = gtk_check_button_new_with_mnemonic ( _ ( " Follow the path of the current file " ) ) ;
gtk_tooltips_set_tip ( tooltips , check_follow_path , _ ( " Whether to execute \" cd $path \" when you switch between opened files. " ) , NULL ) ;
gtk_button_set_focus_on_click ( GTK_BUTTON ( check_follow_path ) , FALSE ) ;
gtk_container_add ( GTK_CONTAINER ( box ) , check_follow_path ) ;
2007-12-17 16:58:26 +00:00
// create check_skip_script checkbox before the check_skip_script checkbox to be able to
// use the object for the toggled handler of check_skip_script checkbox
check_skip_script = gtk_check_button_new_with_mnemonic ( _ ( " Don't use run script " ) ) ;
gtk_tooltips_set_tip ( tooltips , check_skip_script , _ ( " Don't use the simple run script which is usually used to display the exit status of the executed program. " ) , NULL ) ;
gtk_button_set_focus_on_click ( GTK_BUTTON ( check_skip_script ) , FALSE ) ;
gtk_widget_set_sensitive ( check_skip_script , vc - > run_in_vte ) ;
2006-12-10 21:29:04 +00:00
check_run_in_vte = gtk_check_button_new_with_mnemonic ( _ ( " Execute programs in VTE " ) ) ;
gtk_tooltips_set_tip ( tooltips , check_run_in_vte , _ ( " Run programs in VTE instead of opening a terminal emulation window. Please note, programs executed in VTE cannot be stopped. " ) , NULL ) ;
gtk_button_set_focus_on_click ( GTK_BUTTON ( check_run_in_vte ) , FALSE ) ;
gtk_container_add ( GTK_CONTAINER ( box ) , check_run_in_vte ) ;
2007-12-17 16:58:26 +00:00
g_signal_connect ( ( gpointer ) check_run_in_vte , " toggled " ,
G_CALLBACK ( check_run_in_vte_toggled ) , check_skip_script ) ;
// now add the check_skip_script checkbox after the check_run_in_vte checkbox
gtk_container_add ( GTK_CONTAINER ( box ) , check_skip_script ) ;
2006-12-10 21:29:04 +00:00
2006-11-24 11:47:29 +00:00
gtk_box_pack_start ( GTK_BOX ( vbox ) , box , FALSE , FALSE , 0 ) ;
2007-08-23 11:34:06 +00:00
g_object_set_data_full ( G_OBJECT ( ui_widgets . prefs_dialog ) , " font_term " ,
2006-11-24 11:47:29 +00:00
gtk_widget_ref ( font_term ) , ( GDestroyNotify ) gtk_widget_unref ) ;
2007-08-23 11:34:06 +00:00
g_object_set_data_full ( G_OBJECT ( ui_widgets . prefs_dialog ) , " color_fore " ,
2006-11-24 11:47:29 +00:00
gtk_widget_ref ( color_fore ) , ( GDestroyNotify ) gtk_widget_unref ) ;
2007-08-23 11:34:06 +00:00
g_object_set_data_full ( G_OBJECT ( ui_widgets . prefs_dialog ) , " color_back " ,
2006-11-24 11:47:29 +00:00
gtk_widget_ref ( color_back ) , ( GDestroyNotify ) gtk_widget_unref ) ;
2007-08-23 11:34:06 +00:00
g_object_set_data_full ( G_OBJECT ( ui_widgets . prefs_dialog ) , " spin_scrollback " ,
2006-11-24 11:47:29 +00:00
gtk_widget_ref ( spin_scrollback ) , ( GDestroyNotify ) gtk_widget_unref ) ;
2007-08-23 11:34:06 +00:00
g_object_set_data_full ( G_OBJECT ( ui_widgets . prefs_dialog ) , " entry_emulation " ,
2006-11-24 11:47:29 +00:00
gtk_widget_ref ( entry_emulation ) , ( GDestroyNotify ) gtk_widget_unref ) ;
2007-08-23 11:34:06 +00:00
g_object_set_data_full ( G_OBJECT ( ui_widgets . prefs_dialog ) , " entry_shell " ,
2006-11-24 11:47:29 +00:00
gtk_widget_ref ( entry_shell ) , ( GDestroyNotify ) gtk_widget_unref ) ;
2007-08-23 11:34:06 +00:00
g_object_set_data_full ( G_OBJECT ( ui_widgets . prefs_dialog ) , " check_scroll_key " ,
2006-11-24 11:47:29 +00:00
gtk_widget_ref ( check_scroll_key ) , ( GDestroyNotify ) gtk_widget_unref ) ;
2007-08-23 11:34:06 +00:00
g_object_set_data_full ( G_OBJECT ( ui_widgets . prefs_dialog ) , " check_scroll_out " ,
2006-11-24 11:47:29 +00:00
gtk_widget_ref ( check_scroll_out ) , ( GDestroyNotify ) gtk_widget_unref ) ;
2008-01-10 17:11:19 +00:00
g_object_set_data_full ( G_OBJECT ( ui_widgets . prefs_dialog ) , " check_enable_bash_keys " ,
gtk_widget_ref ( check_enable_bash_keys ) , ( GDestroyNotify ) gtk_widget_unref ) ;
2007-08-23 11:34:06 +00:00
g_object_set_data_full ( G_OBJECT ( ui_widgets . prefs_dialog ) , " check_ignore_menu_key " ,
2006-11-24 11:47:29 +00:00
gtk_widget_ref ( check_ignore_menu_key ) , ( GDestroyNotify ) gtk_widget_unref ) ;
2007-08-23 11:34:06 +00:00
g_object_set_data_full ( G_OBJECT ( ui_widgets . prefs_dialog ) , " check_follow_path " ,
2006-11-24 11:47:29 +00:00
gtk_widget_ref ( check_follow_path ) , ( GDestroyNotify ) gtk_widget_unref ) ;
2007-08-23 11:34:06 +00:00
g_object_set_data_full ( G_OBJECT ( ui_widgets . prefs_dialog ) , " check_run_in_vte " ,
2006-12-10 21:29:04 +00:00
gtk_widget_ref ( check_run_in_vte ) , ( GDestroyNotify ) gtk_widget_unref ) ;
2007-12-17 16:58:26 +00:00
g_object_set_data_full ( G_OBJECT ( ui_widgets . prefs_dialog ) , " check_skip_script " ,
gtk_widget_ref ( check_skip_script ) , ( GDestroyNotify ) gtk_widget_unref ) ;
2006-11-24 11:47:29 +00:00
gtk_widget_show_all ( frame ) ;
g_signal_connect ( ( gpointer ) font_term , " font-set " , G_CALLBACK ( on_prefs_font_choosed ) ,
GINT_TO_POINTER ( 4 ) ) ;
g_signal_connect ( ( gpointer ) color_fore , " color-set " , G_CALLBACK ( on_prefs_color_choosed ) ,
GINT_TO_POINTER ( 2 ) ) ;
g_signal_connect ( ( gpointer ) color_back , " color-set " , G_CALLBACK ( on_prefs_color_choosed ) ,
GINT_TO_POINTER ( 3 ) ) ;
g_signal_connect ( ( gpointer ) button_shell , " clicked " ,
G_CALLBACK ( on_prefs_tools_button_clicked ) , entry_shell ) ;
}
}
2005-11-27 20:54:28 +00:00
# endif