2005-11-22 12:26:26 +00:00
/*
* dialogs . c - this file is part of Geany , a fast and lightweight IDE
*
2006-01-11 18:44:52 +00:00
* Copyright 2006 Enrico Troeger < enrico . troeger @ uvena . de >
2005-11-22 12:26:26 +00:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 2 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software
* Foundation , Inc . , 675 Mass Ave , Cambridge , MA 0213 9 , USA .
*
2005-12-11 02:16:02 +00:00
* $ Id $
2005-11-22 12:26:26 +00:00
*/
2006-02-22 13:46:20 +00:00
# include "geany.h"
2005-11-22 12:26:26 +00:00
# include <gdk/gdkkeysyms.h>
2005-12-29 19:50:50 +00:00
# include <string.h>
2006-02-22 13:46:20 +00:00
# ifdef HAVE_SYS_STAT_H
# include <sys / stat.h>
# endif
# ifdef TIME_WITH_SYS_TIME
# include <sys / time.h>
# include <time.h>
# endif
# ifdef HAVE_SYS_TYPES_H
# include <sys / types.h>
# endif
2005-11-22 12:26:26 +00:00
# include "dialogs.h"
# include "callbacks.h"
# include "document.h"
# include "win32.h"
2005-12-29 19:50:50 +00:00
# include "sciwrappers.h"
# include "support.h"
# include "interface.h"
# include "utils.h"
2006-04-27 18:06:35 +00:00
# include "prefs.h"
2005-11-22 12:26:26 +00:00
2006-02-10 20:57:09 +00:00
2005-11-22 12:26:26 +00:00
/* This shows the file selection dialog to open a file. */
void dialogs_show_open_file ( )
{
if ( gtk_notebook_get_n_pages ( GTK_NOTEBOOK ( app - > notebook ) ) < GEANY_MAX_OPEN_FILES )
{
# ifdef GEANY_WIN32
win32_show_file_dialog ( TRUE ) ;
# else /* X11, not win32: use GTK_FILE_CHOOSER */
/* We use the same file selection widget each time, so first
of all we create it if it hasn ' t already been created . */
if ( app - > open_filesel = = NULL )
{
2006-02-10 20:57:09 +00:00
GtkWidget * combo ;
2006-04-27 18:06:35 +00:00
GtkWidget * viewbtn ;
GtkTooltips * tooltips = GTK_TOOLTIPS ( lookup_widget ( app - > window , " tooltips " ) ) ;
2005-11-22 12:26:26 +00:00
gint i ;
2006-02-10 20:57:09 +00:00
app - > open_filesel = gtk_file_chooser_dialog_new ( _ ( " Open File " ) , NULL ,
2006-04-27 18:06:35 +00:00
GTK_FILE_CHOOSER_ACTION_OPEN , NULL ) ;
viewbtn = gtk_button_new_with_mnemonic ( _ ( " _View " ) ) ;
gtk_tooltips_set_tip ( tooltips , viewbtn ,
_ ( " Opens the file in read-only mode. If you choose more than one file to open, all files will be opened read-only. " ) , NULL ) ;
gtk_widget_show ( viewbtn ) ;
gtk_dialog_add_action_widget ( GTK_DIALOG ( app - > open_filesel ) ,
viewbtn , GTK_RESPONSE_APPLY ) ;
gtk_dialog_add_buttons ( GTK_DIALOG ( app - > open_filesel ) ,
GTK_STOCK_CANCEL , GTK_RESPONSE_CANCEL ,
GTK_STOCK_OPEN , GTK_RESPONSE_ACCEPT , NULL ) ;
2006-05-20 12:52:24 +00:00
// set default Open, so pressing enter can open multiple files
gtk_dialog_set_default_response ( GTK_DIALOG ( app - > open_filesel ) ,
GTK_RESPONSE_ACCEPT ) ;
2006-02-10 20:57:09 +00:00
gtk_widget_set_size_request ( app - > open_filesel , 520 , 460 ) ;
gtk_window_set_modal ( GTK_WINDOW ( app - > open_filesel ) , TRUE ) ;
gtk_window_set_destroy_with_parent ( GTK_WINDOW ( app - > open_filesel ) , TRUE ) ;
gtk_window_set_skip_taskbar_hint ( GTK_WINDOW ( app - > open_filesel ) , TRUE ) ;
gtk_window_set_type_hint ( GTK_WINDOW ( app - > open_filesel ) , GDK_WINDOW_TYPE_HINT_DIALOG ) ;
gtk_window_set_transient_for ( GTK_WINDOW ( app - > open_filesel ) , GTK_WINDOW ( app - > window ) ) ;
gtk_file_chooser_set_select_multiple ( GTK_FILE_CHOOSER ( app - > open_filesel ) , TRUE ) ;
// add checkboxes and filename entry
gtk_file_chooser_set_extra_widget ( GTK_FILE_CHOOSER ( app - > open_filesel ) ,
dialogs_add_file_open_extra_widget ( ) ) ;
combo = lookup_widget ( app - > open_filesel , " filetype_combo " ) ;
2005-11-22 12:26:26 +00:00
// add FileFilters(start with "All Files")
gtk_file_chooser_add_filter ( GTK_FILE_CHOOSER ( app - > open_filesel ) ,
utils_create_file_filter ( filetypes [ GEANY_FILETYPES_ALL ] ) ) ;
2005-12-11 02:16:02 +00:00
for ( i = 0 ; i < GEANY_MAX_FILE_TYPES - 1 ; i + + )
2005-11-22 12:26:26 +00:00
{
if ( filetypes [ i ] )
{
2006-02-10 20:57:09 +00:00
gtk_combo_box_append_text ( GTK_COMBO_BOX ( combo ) , filetypes [ i ] - > title ) ;
2005-11-22 12:26:26 +00:00
gtk_file_chooser_add_filter ( GTK_FILE_CHOOSER ( app - > open_filesel ) ,
utils_create_file_filter ( filetypes [ i ] ) ) ;
}
}
2006-02-10 20:57:09 +00:00
gtk_combo_box_append_text ( GTK_COMBO_BOX ( combo ) , _ ( " Detect by file extension " ) ) ;
gtk_combo_box_set_active ( GTK_COMBO_BOX ( combo ) , GEANY_MAX_FILE_TYPES - 1 ) ;
g_signal_connect ( ( gpointer ) app - > open_filesel , " selection-changed " ,
2005-11-22 12:26:26 +00:00
G_CALLBACK ( on_file_open_selection_changed ) , NULL ) ;
2006-02-10 20:57:09 +00:00
g_signal_connect ( ( gpointer ) app - > open_filesel , " delete_event " ,
G_CALLBACK ( gtk_widget_hide ) , NULL ) ;
g_signal_connect ( ( gpointer ) app - > open_filesel , " response " ,
2006-02-14 22:07:55 +00:00
G_CALLBACK ( on_file_open_dialog_response ) , NULL ) ;
2006-02-10 20:57:09 +00:00
}
2006-01-26 21:32:46 +00:00
// set dialog directory to the current file's directory, if present
{
gchar * initdir = utils_get_current_file_dir ( ) ;
if ( initdir ! = NULL )
{
2006-04-27 18:06:35 +00:00
gchar * locale_filename ;
2006-05-14 16:07:30 +00:00
2006-04-27 18:06:35 +00:00
locale_filename = g_locale_from_utf8 ( initdir , - 1 , NULL , NULL , NULL ) ;
if ( locale_filename = = NULL ) locale_filename = g_strdup ( initdir ) ;
2006-05-14 16:07:30 +00:00
2006-01-26 21:32:46 +00:00
gtk_file_chooser_set_current_folder (
2006-04-27 18:06:35 +00:00
GTK_FILE_CHOOSER ( app - > open_filesel ) , locale_filename ) ;
2006-01-26 21:32:46 +00:00
g_free ( initdir ) ;
2006-04-27 18:06:35 +00:00
g_free ( locale_filename ) ;
2006-01-26 21:32:46 +00:00
}
}
2005-11-22 12:26:26 +00:00
gtk_file_chooser_unselect_all ( GTK_FILE_CHOOSER ( app - > open_filesel ) ) ;
2006-02-10 20:57:09 +00:00
gtk_widget_show ( app - > open_filesel ) ;
2005-11-22 12:26:26 +00:00
# endif
}
else
{
dialogs_show_file_open_error ( ) ;
}
}
/* This shows the file selection dialog to save a file. */
void dialogs_show_save_as ( )
{
# ifdef GEANY_WIN32
win32_show_file_dialog ( FALSE ) ;
# else
gint idx = document_get_cur_idx ( ) ;
if ( app - > save_filesel = = NULL )
{
2006-02-14 22:07:55 +00:00
app - > save_filesel = gtk_file_chooser_dialog_new ( _ ( " Save File " ) , NULL ,
GTK_FILE_CHOOSER_ACTION_SAVE , GTK_STOCK_CANCEL , GTK_RESPONSE_CANCEL ,
GTK_STOCK_SAVE , GTK_RESPONSE_ACCEPT , NULL ) ;
gtk_window_set_modal ( GTK_WINDOW ( app - > save_filesel ) , TRUE ) ;
gtk_window_set_destroy_with_parent ( GTK_WINDOW ( app - > save_filesel ) , TRUE ) ;
gtk_window_set_skip_taskbar_hint ( GTK_WINDOW ( app - > save_filesel ) , TRUE ) ;
gtk_window_set_type_hint ( GTK_WINDOW ( app - > save_filesel ) , GDK_WINDOW_TYPE_HINT_DIALOG ) ;
2006-04-27 18:06:35 +00:00
gtk_dialog_set_default_response ( GTK_DIALOG ( app - > save_filesel ) , GTK_RESPONSE_ACCEPT ) ;
2006-02-14 22:07:55 +00:00
g_signal_connect ( ( gpointer ) app - > save_filesel , " delete_event " , G_CALLBACK ( gtk_widget_hide ) , NULL ) ;
g_signal_connect ( ( gpointer ) app - > save_filesel , " response " , G_CALLBACK ( on_file_save_dialog_response ) , NULL ) ;
2005-11-22 12:26:26 +00:00
gtk_window_set_transient_for ( GTK_WINDOW ( app - > save_filesel ) , GTK_WINDOW ( app - > window ) ) ;
}
2006-04-27 18:06:35 +00:00
// If the current document has a filename we use that as the default.
if ( doc_list [ idx ] . file_name ! = NULL )
{
gchar * locale_filename = g_locale_from_utf8 ( doc_list [ idx ] . file_name , - 1 , NULL , NULL , NULL ) ;
if ( locale_filename = = NULL ) locale_filename = g_strdup ( doc_list [ idx ] . file_name ) ;
2006-05-14 16:07:30 +00:00
2006-04-27 18:06:35 +00:00
gtk_file_chooser_set_filename ( GTK_FILE_CHOOSER ( app - > save_filesel ) , locale_filename ) ;
g_free ( locale_filename ) ;
}
2005-11-22 12:26:26 +00:00
else
{
2006-04-27 18:06:35 +00:00
gchar * fname = NULL ;
2006-05-14 16:07:30 +00:00
2006-04-27 18:06:35 +00:00
if ( doc_list [ idx ] . file_type ! = NULL & & doc_list [ idx ] . file_type - > id ! = GEANY_FILETYPES_ALL & &
doc_list [ idx ] . file_type - > extension ! = NULL )
fname = g_strconcat ( GEANY_STRING_UNTITLED , " . " ,
doc_list [ idx ] . file_type - > extension , NULL ) ;
2006-05-14 16:07:30 +00:00
else
2006-04-27 18:06:35 +00:00
fname = g_strdup ( GEANY_STRING_UNTITLED ) ;
2005-11-22 12:26:26 +00:00
gtk_file_chooser_unselect_all ( GTK_FILE_CHOOSER ( app - > save_filesel ) ) ;
2006-04-27 18:06:35 +00:00
gtk_file_chooser_set_current_name ( GTK_FILE_CHOOSER ( app - > save_filesel ) , fname ) ;
g_free ( fname ) ;
2005-11-22 12:26:26 +00:00
}
2006-04-27 18:06:35 +00:00
// We make sure the dialog is visible.
2005-11-22 12:26:26 +00:00
gtk_window_present ( GTK_WINDOW ( app - > save_filesel ) ) ;
# endif
}
void dialogs_show_file_open_error ( void )
{
gchar * pri = g_strdup_printf ( _ ( " There is a limit of %d concurrent open tabs. " ) , GEANY_MAX_OPEN_FILES ) ;
gchar * sec = _ ( " error: too many open files " ) ;
# ifdef GEANY_WIN32
MessageBox ( NULL , pri , sec , MB_OK | MB_ICONERROR ) ;
# else
GtkWidget * dialog ;
dialog = gtk_message_dialog_new ( GTK_WINDOW ( app - > window ) , GTK_DIALOG_DESTROY_WITH_PARENT ,
GTK_MESSAGE_ERROR , GTK_BUTTONS_OK , sec ) ;
gtk_message_dialog_format_secondary_text ( GTK_MESSAGE_DIALOG ( dialog ) , pri ) ;
gtk_dialog_run ( GTK_DIALOG ( dialog ) ) ;
gtk_widget_destroy ( dialog ) ;
# endif
g_free ( pri ) ;
}
2006-05-19 17:18:06 +00:00
/// TODO is there a difference to dialogs_show_question? if not, remove this one
2005-11-22 12:26:26 +00:00
gboolean dialogs_show_not_found ( const gchar * text )
{
GtkWidget * dialog ;
2005-12-28 14:28:18 +00:00
gchar * string ;
2005-11-22 12:26:26 +00:00
gint ret ;
2005-12-28 14:28:18 +00:00
string = g_strdup_printf ( _ ( " The match \" %s \" was not found. Wrap search around the document? " ) , text ) ;
2005-11-22 12:26:26 +00:00
# ifdef GEANY_WIN32
dialog = NULL ;
2006-04-27 18:06:35 +00:00
ret = MessageBox ( NULL , string , _ ( " Question " ) , MB_YESNO | MB_ICONWARNING ) ;
2005-12-28 14:28:18 +00:00
g_free ( string ) ;
2005-11-22 12:26:26 +00:00
if ( ret = = IDYES ) return TRUE ;
else return FALSE ;
# else
dialog = gtk_message_dialog_new ( GTK_WINDOW ( app - > window ) , GTK_DIALOG_DESTROY_WITH_PARENT ,
2005-12-29 19:50:50 +00:00
GTK_MESSAGE_QUESTION , GTK_BUTTONS_YES_NO , " %s " , string ) ;
2005-12-28 14:28:18 +00:00
g_free ( string ) ;
2005-11-22 12:26:26 +00:00
ret = gtk_dialog_run ( GTK_DIALOG ( dialog ) ) ;
gtk_widget_destroy ( dialog ) ;
if ( ret = = GTK_RESPONSE_YES ) return TRUE ;
else return FALSE ;
# endif
}
void dialogs_show_info ( const gchar * text , . . . )
{
# ifndef GEANY_WIN32
GtkWidget * dialog ;
# endif
gchar * string = g_malloc ( 512 ) ;
va_list args ;
va_start ( args , text ) ;
g_vsnprintf ( string , 511 , text , args ) ;
va_end ( args ) ;
# ifdef GEANY_WIN32
MessageBox ( NULL , string , _ ( " Information " ) , MB_OK | MB_ICONINFORMATION ) ;
# else
dialog = gtk_message_dialog_new ( GTK_WINDOW ( app - > window ) , GTK_DIALOG_DESTROY_WITH_PARENT ,
GTK_MESSAGE_INFO , GTK_BUTTONS_OK , string ) ;
gtk_dialog_run ( GTK_DIALOG ( dialog ) ) ;
gtk_widget_destroy ( dialog ) ;
# endif
g_free ( string ) ;
}
2006-05-19 17:18:06 +00:00
/// TODO is there a difference to dialogs_show_question? if not, remove this one
2006-02-22 13:46:20 +00:00
gboolean dialogs_show_fifo_error ( const gchar * text , . . . )
{
GtkWidget * dialog ;
gchar string [ 300 ] ;
gint ret ;
va_list args ;
va_start ( args , text ) ;
g_vsnprintf ( string , 299 , text , args ) ;
va_end ( args ) ;
dialog = gtk_message_dialog_new ( NULL , GTK_DIALOG_DESTROY_WITH_PARENT ,
GTK_MESSAGE_ERROR , GTK_BUTTONS_YES_NO , string ) ;
ret = gtk_dialog_run ( GTK_DIALOG ( dialog ) ) ;
gtk_widget_destroy ( dialog ) ;
2006-02-25 22:26:43 +00:00
2006-02-22 13:46:20 +00:00
if ( ret = = GTK_RESPONSE_YES ) return TRUE ;
else return FALSE ;
}
2005-11-22 12:26:26 +00:00
void dialogs_show_error ( const gchar * text , . . . )
{
# ifndef GEANY_WIN32
GtkWidget * dialog ;
# endif
gchar * string = g_malloc ( 512 ) ;
va_list args ;
va_start ( args , text ) ;
g_vsnprintf ( string , 511 , text , args ) ;
va_end ( args ) ;
# ifdef GEANY_WIN32
MessageBox ( NULL , string , _ ( " Error " ) , MB_OK | MB_ICONERROR ) ;
# else
2006-02-14 22:07:55 +00:00
dialog = gtk_message_dialog_new ( NULL , GTK_DIALOG_DESTROY_WITH_PARENT ,
2005-11-22 12:26:26 +00:00
GTK_MESSAGE_ERROR , GTK_BUTTONS_OK , string ) ;
2006-02-22 13:46:20 +00:00
gtk_dialog_run ( GTK_DIALOG ( dialog ) ) ;
2005-11-22 12:26:26 +00:00
gtk_widget_destroy ( dialog ) ;
# endif
g_free ( string ) ;
}
gboolean dialogs_show_unsaved_file ( gint idx )
{
# ifndef GEANY_WIN32
GtkWidget * dialog , * button , * label , * image , * hbox , * align ;
# endif
gchar * msg ;
gint ret ;
if ( doc_list [ idx ] . file_name ! = NULL )
{
gchar * short_fn = g_path_get_basename ( doc_list [ idx ] . file_name ) ;
msg = ( gchar * ) g_malloc ( 100 + strlen ( short_fn ) ) ;
g_snprintf ( msg , 100 + strlen ( doc_list [ idx ] . file_name ) ,
_ ( " The file '%s' is not saved. \n Do you want to save it before closing? " ) , short_fn ) ;
g_free ( short_fn ) ;
}
else
{
msg = g_strdup ( _ ( " The file is not saved. \n Do you want to save it before closing? " ) ) ;
}
# ifdef GEANY_WIN32
ret = MessageBox ( NULL , msg , _ ( " Error " ) , MB_YESNOCANCEL | MB_ICONQUESTION ) ;
switch ( ret )
{
case IDYES : ret = GTK_RESPONSE_YES ; break ;
case IDNO : ret = GTK_RESPONSE_NO ; break ;
case IDCANCEL : ret = GTK_RESPONSE_CANCEL ; break ;
}
# else
dialog = gtk_message_dialog_new ( GTK_WINDOW ( app - > window ) , GTK_DIALOG_DESTROY_WITH_PARENT ,
GTK_MESSAGE_QUESTION , GTK_BUTTONS_NONE , msg ) ;
gtk_dialog_add_button ( GTK_DIALOG ( dialog ) , GTK_STOCK_CANCEL , GTK_RESPONSE_CANCEL ) ;
button = gtk_button_new ( ) ;
label = gtk_label_new ( _ ( " Don't save " ) ) ;
image = gtk_image_new_from_stock ( GTK_STOCK_NO , GTK_ICON_SIZE_BUTTON ) ;
hbox = gtk_hbox_new ( FALSE , 2 ) ;
align = gtk_alignment_new ( 0.5 , 0.5 , 0.0 , 0.0 ) ;
gtk_box_pack_start ( GTK_BOX ( hbox ) , image , FALSE , FALSE , 0 ) ;
gtk_box_pack_end ( GTK_BOX ( hbox ) , label , FALSE , FALSE , 0 ) ;
gtk_container_add ( GTK_CONTAINER ( button ) , align ) ;
gtk_container_add ( GTK_CONTAINER ( align ) , hbox ) ;
gtk_widget_show_all ( align ) ;
gtk_dialog_add_action_widget ( GTK_DIALOG ( dialog ) , button , GTK_RESPONSE_NO ) ;
gtk_widget_show ( button ) ;
gtk_dialog_add_button ( GTK_DIALOG ( dialog ) , GTK_STOCK_SAVE , GTK_RESPONSE_YES ) ;
gtk_dialog_set_default_response ( GTK_DIALOG ( dialog ) , GTK_RESPONSE_YES ) ;
ret = gtk_dialog_run ( GTK_DIALOG ( dialog ) ) ;
gtk_widget_destroy ( dialog ) ;
# endif
g_free ( msg ) ;
switch ( ret )
{
case GTK_RESPONSE_YES :
{
if ( doc_list [ idx ] . file_name = = NULL )
dialogs_show_save_as ( ) ;
else
document_save_file ( idx ) ;
ret = TRUE ;
break ;
}
case GTK_RESPONSE_NO : ret = TRUE ; break ;
case GTK_RESPONSE_CANCEL : /* fall through to default and leave the function */
default : ret = FALSE ; break ;
}
return ( gboolean ) ret ;
}
/* This shows the font selection dialog to choose a font. */
void dialogs_show_open_font ( void )
{
# ifdef GEANY_WIN32
win32_show_font_dialog ( ) ;
2006-02-22 13:46:20 +00:00
# else
2005-11-22 12:26:26 +00:00
if ( app - > open_fontsel = = NULL )
{
2006-02-22 13:46:20 +00:00
app - > open_fontsel = gtk_font_selection_dialog_new ( _ ( " Choose font " ) ) ; ;
gtk_container_set_border_width ( GTK_CONTAINER ( app - > open_fontsel ) , 4 ) ;
gtk_window_set_modal ( GTK_WINDOW ( app - > open_fontsel ) , TRUE ) ;
gtk_window_set_destroy_with_parent ( GTK_WINDOW ( app - > open_fontsel ) , TRUE ) ;
gtk_window_set_skip_taskbar_hint ( GTK_WINDOW ( app - > open_fontsel ) , TRUE ) ;
gtk_window_set_type_hint ( GTK_WINDOW ( app - > open_fontsel ) , GDK_WINDOW_TYPE_HINT_DIALOG ) ;
2006-02-25 22:26:43 +00:00
2006-02-22 13:46:20 +00:00
gtk_widget_show ( GTK_FONT_SELECTION_DIALOG ( app - > open_fontsel ) - > apply_button ) ;
g_signal_connect ( ( gpointer ) app - > open_fontsel ,
" delete_event " , G_CALLBACK ( gtk_widget_hide ) , NULL ) ;
g_signal_connect ( ( gpointer ) GTK_FONT_SELECTION_DIALOG ( app - > open_fontsel ) - > ok_button ,
" clicked " , G_CALLBACK ( on_font_ok_button_clicked ) , NULL ) ;
g_signal_connect ( ( gpointer ) GTK_FONT_SELECTION_DIALOG ( app - > open_fontsel ) - > cancel_button ,
" clicked " , G_CALLBACK ( on_font_cancel_button_clicked ) , NULL ) ;
g_signal_connect ( ( gpointer ) GTK_FONT_SELECTION_DIALOG ( app - > open_fontsel ) - > apply_button ,
" clicked " , G_CALLBACK ( on_font_apply_button_clicked ) , NULL ) ;
2005-11-22 12:26:26 +00:00
gtk_font_selection_dialog_set_font_name ( GTK_FONT_SELECTION_DIALOG ( app - > open_fontsel ) , app - > editor_font ) ;
gtk_window_set_transient_for ( GTK_WINDOW ( app - > open_fontsel ) , GTK_WINDOW ( app - > window ) ) ;
}
/* We make sure the dialog is visible. */
gtk_window_present ( GTK_WINDOW ( app - > open_fontsel ) ) ;
# endif
}
void dialogs_show_word_count ( void )
{
GtkWidget * dialog , * label ;
gint idx ;
guint chars , lines , words ;
gchar * string , * text , * range ;
2006-02-22 13:46:20 +00:00
GtkRequisition * size ;
2005-11-22 12:26:26 +00:00
idx = document_get_cur_idx ( ) ;
2006-02-22 13:46:20 +00:00
if ( idx = = - 1 | | ! doc_list [ idx ] . is_valid ) return ;
2005-11-22 12:26:26 +00:00
2006-02-22 13:46:20 +00:00
size = g_new ( GtkRequisition , 1 ) ;
2005-11-22 12:26:26 +00:00
dialog = gtk_dialog_new_with_buttons ( _ ( " Word Count " ) , GTK_WINDOW ( app - > window ) ,
GTK_DIALOG_DESTROY_WITH_PARENT ,
GTK_STOCK_CLOSE , GTK_RESPONSE_NONE , NULL ) ;
if ( sci_can_copy ( doc_list [ idx ] . sci ) )
{
text = g_malloc0 ( sci_get_selected_text_length ( doc_list [ idx ] . sci ) + 1 ) ;
sci_get_selected_text ( doc_list [ idx ] . sci , text ) ;
utils_wordcount ( text , & chars , & lines , & words ) ;
g_free ( text ) ;
range = _ ( " selection " ) ;
}
else
{
text = g_malloc ( sci_get_length ( doc_list [ idx ] . sci ) + 1 ) ;
sci_get_text ( doc_list [ idx ] . sci , sci_get_length ( doc_list [ idx ] . sci ) + 1 , text ) ;
utils_wordcount ( text , & chars , & lines , & words ) ;
g_free ( text ) ;
range = _ ( " whole document " ) ;
}
string = g_strdup_printf ( _ ( " Range: \t \t %s \n \n Lines: \t \t %d \n Words: \t \t %d \n Characters: \t %d \n " ) , range , lines , words , chars ) ;
label = gtk_label_new ( string ) ;
g_free ( string ) ;
2006-02-22 13:46:20 +00:00
g_signal_connect ( dialog , " response " , G_CALLBACK ( gtk_widget_destroy ) , dialog ) ;
2006-04-27 18:06:35 +00:00
g_signal_connect ( dialog , " delete-event " , G_CALLBACK ( gtk_widget_destroy ) , dialog ) ;
2005-11-22 12:26:26 +00:00
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( dialog ) - > vbox ) , label ) ;
gtk_widget_size_request ( label , size ) ;
gtk_widget_set_size_request ( dialog , size - > width + 20 , size - > height + 50 ) ;
g_free ( size ) ;
gtk_widget_show_all ( dialog ) ;
}
/* This shows the color selection dialog to choose a color. */
void dialogs_show_color ( void )
{
# ifdef GEANY_WIN32
win32_show_color_dialog ( ) ;
2006-04-27 18:06:35 +00:00
# else
2005-11-22 12:26:26 +00:00
if ( app - > open_colorsel = = NULL )
{
app - > open_colorsel = gtk_color_selection_dialog_new ( _ ( " Color Chooser " ) ) ;
gtk_window_set_transient_for ( GTK_WINDOW ( app - > open_colorsel ) , GTK_WINDOW ( app - > window ) ) ;
g_signal_connect ( GTK_COLOR_SELECTION_DIALOG ( app - > open_colorsel ) - > cancel_button , " clicked " ,
G_CALLBACK ( on_color_cancel_button_clicked ) , NULL ) ;
g_signal_connect ( GTK_COLOR_SELECTION_DIALOG ( app - > open_colorsel ) - > ok_button , " clicked " ,
G_CALLBACK ( on_color_ok_button_clicked ) , NULL ) ;
g_signal_connect ( app - > open_colorsel , " delete_event " ,
2006-02-22 13:46:20 +00:00
G_CALLBACK ( gtk_widget_hide ) , NULL ) ;
2005-11-22 12:26:26 +00:00
}
2006-04-27 18:06:35 +00:00
// We make sure the dialog is visible.
2005-11-22 12:26:26 +00:00
gtk_window_present ( GTK_WINDOW ( app - > open_colorsel ) ) ;
# endif
}
2006-04-27 18:06:35 +00:00
GtkWidget * dialogs_create_build_menu_gen ( gint idx )
2005-11-22 12:26:26 +00:00
{
GtkWidget * menu , * item , * image , * separator ;
GtkAccelGroup * accel_group = gtk_accel_group_new ( ) ;
GtkTooltips * tooltips = GTK_TOOLTIPS ( lookup_widget ( app - > window , " tooltips " ) ) ;
2006-04-27 18:06:35 +00:00
filetype * ft = doc_list [ idx ] . file_type ;
2005-11-22 12:26:26 +00:00
menu = gtk_menu_new ( ) ;
2006-04-27 18:06:35 +00:00
if ( ft - > menu_items - > can_compile )
{
// compile the code
item = gtk_image_menu_item_new_with_mnemonic ( _ ( " Compile " ) ) ;
gtk_widget_show ( item ) ;
gtk_container_add ( GTK_CONTAINER ( menu ) , item ) ;
gtk_tooltips_set_tip ( tooltips , item , _ ( " Compiles the current file " ) , NULL ) ;
2006-05-19 17:18:06 +00:00
if ( keys [ GEANY_KEYS_BUILD_COMPILE ] - > key )
gtk_widget_add_accelerator ( item , " activate " , accel_group , keys [ GEANY_KEYS_BUILD_COMPILE ] - > key ,
keys [ GEANY_KEYS_BUILD_COMPILE ] - > mods , GTK_ACCEL_VISIBLE ) ;
image = gtk_image_new_from_stock ( " gtk-convert " , GTK_ICON_SIZE_MENU ) ;
2006-04-27 18:06:35 +00:00
gtk_widget_show ( image ) ;
gtk_image_menu_item_set_image ( GTK_IMAGE_MENU_ITEM ( item ) , image ) ;
g_signal_connect ( ( gpointer ) item , " activate " , G_CALLBACK ( on_build_compile_activate ) , NULL ) ;
ft - > menu_items - > item_compile = item ;
}
2006-01-11 18:44:52 +00:00
2006-04-27 18:06:35 +00:00
if ( ft - > menu_items - > can_link )
2006-01-11 18:44:52 +00:00
{ // build the code
2006-04-27 18:06:35 +00:00
item = gtk_image_menu_item_new_with_mnemonic ( _ ( " Build " ) ) ;
2006-02-25 22:26:43 +00:00
gtk_widget_show ( item ) ;
gtk_container_add ( GTK_CONTAINER ( menu ) , item ) ;
gtk_tooltips_set_tip ( tooltips , item ,
2006-01-11 18:44:52 +00:00
_ ( " Builds the current file (generate an executable file) " ) , NULL ) ;
2006-05-19 17:18:06 +00:00
if ( keys [ GEANY_KEYS_BUILD_LINK ] - > key )
gtk_widget_add_accelerator ( item , " activate " , accel_group , keys [ GEANY_KEYS_BUILD_LINK ] - > key ,
keys [ GEANY_KEYS_BUILD_LINK ] - > mods , GTK_ACCEL_VISIBLE ) ;
2006-02-25 22:26:43 +00:00
g_signal_connect ( ( gpointer ) item , " activate " , G_CALLBACK ( on_build_build_activate ) , NULL ) ;
2006-04-27 18:06:35 +00:00
ft - > menu_items - > item_link = item ;
2006-01-11 18:44:52 +00:00
}
2005-11-22 12:26:26 +00:00
// build the code with make all
2006-04-27 18:06:35 +00:00
item = gtk_image_menu_item_new_with_mnemonic ( _ ( " Build with \" make \" " ) ) ;
2005-11-22 12:26:26 +00:00
gtk_widget_show ( item ) ;
gtk_container_add ( GTK_CONTAINER ( menu ) , item ) ;
gtk_tooltips_set_tip ( tooltips , item , _ ( " Builds the current file with the "
" make tool and the default target " ) , NULL ) ;
2006-05-19 17:18:06 +00:00
if ( keys [ GEANY_KEYS_BUILD_MAKE ] - > key )
gtk_widget_add_accelerator ( item , " activate " , accel_group , keys [ GEANY_KEYS_BUILD_MAKE ] - > key ,
keys [ GEANY_KEYS_BUILD_MAKE ] - > mods , GTK_ACCEL_VISIBLE ) ;
2006-01-11 18:44:52 +00:00
g_signal_connect ( ( gpointer ) item , " activate " , G_CALLBACK ( on_build_make_activate ) , GINT_TO_POINTER ( 0 ) ) ;
2005-11-22 12:26:26 +00:00
// build the code with make
2006-04-27 18:06:35 +00:00
item = gtk_image_menu_item_new_with_mnemonic ( _ ( " Build with make (custom target) " ) ) ;
2005-11-22 12:26:26 +00:00
gtk_widget_show ( item ) ;
2006-05-19 17:18:06 +00:00
if ( keys [ GEANY_KEYS_BUILD_MAKEOWNTARGET ] - > key )
gtk_widget_add_accelerator ( item , " activate " , accel_group , keys [ GEANY_KEYS_BUILD_MAKEOWNTARGET ] - > key ,
keys [ GEANY_KEYS_BUILD_MAKEOWNTARGET ] - > mods , GTK_ACCEL_VISIBLE ) ;
2005-11-22 12:26:26 +00:00
gtk_container_add ( GTK_CONTAINER ( menu ) , item ) ;
gtk_tooltips_set_tip ( tooltips , item , _ ( " Builds the current file with the "
" make tool and the specified target " ) , NULL ) ;
2006-01-11 18:44:52 +00:00
g_signal_connect ( ( gpointer ) item , " activate " , G_CALLBACK ( on_build_make_activate ) , GINT_TO_POINTER ( 1 ) ) ;
2006-04-27 18:06:35 +00:00
if ( ft - > menu_items - > can_exec )
2006-01-11 18:44:52 +00:00
{ // execute the code
item = gtk_image_menu_item_new_from_stock ( " gtk-execute " , accel_group ) ;
gtk_widget_show ( item ) ;
gtk_container_add ( GTK_CONTAINER ( menu ) , item ) ;
2006-04-27 18:06:35 +00:00
gtk_tooltips_set_tip ( tooltips , item , _ ( " Run or view the current file " ) , NULL ) ;
2006-05-19 17:18:06 +00:00
if ( keys [ GEANY_KEYS_BUILD_RUN ] - > key )
gtk_widget_add_accelerator ( item , " activate " , accel_group , keys [ GEANY_KEYS_BUILD_RUN ] - > key ,
keys [ GEANY_KEYS_BUILD_RUN ] - > mods , GTK_ACCEL_VISIBLE ) ;
2006-01-11 18:44:52 +00:00
g_signal_connect ( ( gpointer ) item , " activate " , G_CALLBACK ( on_build_execute_activate ) , NULL ) ;
2006-04-27 18:06:35 +00:00
ft - > menu_items - > item_exec = item ;
2006-01-11 18:44:52 +00:00
}
// arguments
2006-04-27 18:06:35 +00:00
if ( ft - > menu_items - > can_compile | | ft - > menu_items - > can_link | | ft - > menu_items - > can_exec )
{
// separator
separator = gtk_separator_menu_item_new ( ) ;
gtk_widget_show ( separator ) ;
gtk_container_add ( GTK_CONTAINER ( menu ) , separator ) ;
gtk_widget_set_sensitive ( separator , FALSE ) ;
2006-01-11 18:44:52 +00:00
2006-04-27 18:06:35 +00:00
item = gtk_image_menu_item_new_with_mnemonic ( _ ( " Set Includes and Arguments " ) ) ;
gtk_widget_show ( item ) ;
2006-05-19 17:18:06 +00:00
if ( keys [ GEANY_KEYS_BUILD_OPTIONS ] - > key )
gtk_widget_add_accelerator ( item , " activate " , accel_group , keys [ GEANY_KEYS_BUILD_OPTIONS ] - > key ,
keys [ GEANY_KEYS_BUILD_OPTIONS ] - > mods , GTK_ACCEL_VISIBLE ) ;
2006-04-27 18:06:35 +00:00
gtk_container_add ( GTK_CONTAINER ( menu ) , item ) ;
gtk_tooltips_set_tip ( tooltips , item ,
_ ( " Sets the includes and library paths for the compiler and "
" the program arguments for execution " ) , NULL ) ;
image = gtk_image_new_from_stock ( " gtk-preferences " , GTK_ICON_SIZE_MENU ) ;
gtk_widget_show ( image ) ;
gtk_image_menu_item_set_image ( GTK_IMAGE_MENU_ITEM ( item ) , image ) ;
g_signal_connect ( ( gpointer ) item , " activate " , G_CALLBACK ( on_build_arguments_activate ) , NULL ) ;
}
2006-05-14 16:07:30 +00:00
2006-01-11 18:44:52 +00:00
return menu ;
}
2006-04-27 18:06:35 +00:00
GtkWidget * dialogs_create_build_menu_tex ( gint idx )
2006-01-11 18:44:52 +00:00
{
GtkWidget * menu , * item , * image , * separator ;
GtkAccelGroup * accel_group = gtk_accel_group_new ( ) ;
GtkTooltips * tooltips = GTK_TOOLTIPS ( lookup_widget ( app - > window , " tooltips " ) ) ;
menu = gtk_menu_new ( ) ;
// DVI
2006-04-27 18:06:35 +00:00
item = gtk_image_menu_item_new_with_mnemonic ( _ ( " LaTeX -> DVI " ) ) ;
2006-01-11 18:44:52 +00:00
gtk_widget_show ( item ) ;
gtk_container_add ( GTK_CONTAINER ( menu ) , item ) ;
gtk_tooltips_set_tip ( tooltips , item , _ ( " Compiles the current file into a DVI file " ) , NULL ) ;
2006-05-19 17:18:06 +00:00
if ( keys [ GEANY_KEYS_BUILD_COMPILE ] - > key )
gtk_widget_add_accelerator ( item , " activate " , accel_group , keys [ GEANY_KEYS_BUILD_COMPILE ] - > key ,
keys [ GEANY_KEYS_BUILD_COMPILE ] - > mods , GTK_ACCEL_VISIBLE ) ;
2006-01-11 18:44:52 +00:00
image = gtk_image_new_from_stock ( " gtk-convert " , GTK_ICON_SIZE_MENU ) ;
gtk_widget_show ( image ) ;
gtk_image_menu_item_set_image ( GTK_IMAGE_MENU_ITEM ( item ) , image ) ;
2006-01-18 12:11:44 +00:00
g_signal_connect ( ( gpointer ) item , " activate " , G_CALLBACK ( on_build_tex_activate ) , GINT_TO_POINTER ( 0 ) ) ;
2006-01-11 18:44:52 +00:00
// PDF
2006-04-27 18:06:35 +00:00
item = gtk_image_menu_item_new_with_mnemonic ( _ ( " LaTeX -> PDF " ) ) ;
2006-01-11 18:44:52 +00:00
gtk_widget_show ( item ) ;
gtk_container_add ( GTK_CONTAINER ( menu ) , item ) ;
gtk_tooltips_set_tip ( tooltips , item , _ ( " Compiles the current file into a PDF file " ) , NULL ) ;
2006-05-19 17:18:06 +00:00
if ( keys [ GEANY_KEYS_BUILD_LINK ] - > key )
gtk_widget_add_accelerator ( item , " activate " , accel_group , keys [ GEANY_KEYS_BUILD_LINK ] - > key ,
keys [ GEANY_KEYS_BUILD_LINK ] - > mods , GTK_ACCEL_VISIBLE ) ;
2006-01-11 18:44:52 +00:00
image = gtk_image_new_from_stock ( " gtk-convert " , GTK_ICON_SIZE_MENU ) ;
gtk_widget_show ( image ) ;
gtk_image_menu_item_set_image ( GTK_IMAGE_MENU_ITEM ( item ) , image ) ;
2006-01-18 12:11:44 +00:00
g_signal_connect ( ( gpointer ) item , " activate " , G_CALLBACK ( on_build_tex_activate ) , GINT_TO_POINTER ( 1 ) ) ;
2005-11-22 12:26:26 +00:00
2006-01-11 18:44:52 +00:00
// build the code with make all
2006-04-27 18:06:35 +00:00
item = gtk_image_menu_item_new_with_mnemonic ( _ ( " Build with \" make \" " ) ) ;
2006-01-11 18:44:52 +00:00
gtk_widget_show ( item ) ;
gtk_container_add ( GTK_CONTAINER ( menu ) , item ) ;
gtk_tooltips_set_tip ( tooltips , item , _ ( " Builds the current file with the "
" make tool and the default target " ) , NULL ) ;
2006-05-19 17:18:06 +00:00
if ( keys [ GEANY_KEYS_BUILD_MAKE ] - > key )
gtk_widget_add_accelerator ( item , " activate " , accel_group , keys [ GEANY_KEYS_BUILD_MAKE ] - > key ,
keys [ GEANY_KEYS_BUILD_MAKE ] - > mods , GTK_ACCEL_VISIBLE ) ;
g_signal_connect ( ( gpointer ) item , " activate " , G_CALLBACK ( on_build_make_activate ) , GINT_TO_POINTER ( 0 ) ) ;
2006-01-11 18:44:52 +00:00
// build the code with make
2006-04-27 18:06:35 +00:00
item = gtk_image_menu_item_new_with_mnemonic ( _ ( " Build with make (custom target) " ) ) ;
2006-01-11 18:44:52 +00:00
gtk_widget_show ( item ) ;
2006-05-19 17:18:06 +00:00
if ( keys [ GEANY_KEYS_BUILD_MAKEOWNTARGET ] - > key )
gtk_widget_add_accelerator ( item , " activate " , accel_group , keys [ GEANY_KEYS_BUILD_MAKEOWNTARGET ] - > key ,
keys [ GEANY_KEYS_BUILD_MAKEOWNTARGET ] - > mods , GTK_ACCEL_VISIBLE ) ;
2006-01-11 18:44:52 +00:00
gtk_container_add ( GTK_CONTAINER ( menu ) , item ) ;
gtk_tooltips_set_tip ( tooltips , item , _ ( " Builds the current file with the "
" make tool and the specified target " ) , NULL ) ;
g_signal_connect ( ( gpointer ) item , " activate " , G_CALLBACK ( on_build_make_activate ) , GINT_TO_POINTER ( 1 ) ) ;
2005-11-22 12:26:26 +00:00
2006-01-18 12:11:44 +00:00
// DVI view
2006-04-27 18:06:35 +00:00
item = gtk_image_menu_item_new_with_mnemonic ( _ ( " View DVI file " ) ) ;
2006-01-18 12:11:44 +00:00
gtk_widget_show ( item ) ;
gtk_container_add ( GTK_CONTAINER ( menu ) , item ) ;
2006-05-19 17:18:06 +00:00
if ( keys [ GEANY_KEYS_BUILD_RUN ] - > key )
gtk_widget_add_accelerator ( item , " activate " , accel_group , keys [ GEANY_KEYS_BUILD_RUN ] - > key ,
keys [ GEANY_KEYS_BUILD_RUN ] - > mods , GTK_ACCEL_VISIBLE ) ;
2006-01-18 12:11:44 +00:00
gtk_tooltips_set_tip ( tooltips , item , _ ( " Compiles and view the current file " ) , NULL ) ;
image = gtk_image_new_from_stock ( " gtk-find " , GTK_ICON_SIZE_MENU ) ;
gtk_widget_show ( image ) ;
gtk_image_menu_item_set_image ( GTK_IMAGE_MENU_ITEM ( item ) , image ) ;
g_signal_connect ( ( gpointer ) item , " activate " , G_CALLBACK ( on_build_tex_activate ) , GINT_TO_POINTER ( 2 ) ) ;
// PDF view
2006-04-27 18:06:35 +00:00
item = gtk_image_menu_item_new_with_mnemonic ( _ ( " View PDF file " ) ) ;
2006-01-18 12:11:44 +00:00
gtk_widget_show ( item ) ;
gtk_container_add ( GTK_CONTAINER ( menu ) , item ) ;
2006-05-19 17:18:06 +00:00
if ( keys [ GEANY_KEYS_BUILD_RUN2 ] - > key )
gtk_widget_add_accelerator ( item , " activate " , accel_group , keys [ GEANY_KEYS_BUILD_RUN2 ] - > key ,
keys [ GEANY_KEYS_BUILD_RUN2 ] - > mods , GTK_ACCEL_VISIBLE ) ;
gtk_tooltips_set_tip ( tooltips , item , _ ( " Compiles and view the current file " ) , NULL ) ;
2006-01-18 12:11:44 +00:00
image = gtk_image_new_from_stock ( " gtk-find " , GTK_ICON_SIZE_MENU ) ;
gtk_widget_show ( image ) ;
gtk_image_menu_item_set_image ( GTK_IMAGE_MENU_ITEM ( item ) , image ) ;
g_signal_connect ( ( gpointer ) item , " activate " , G_CALLBACK ( on_build_tex_activate ) , GINT_TO_POINTER ( 3 ) ) ;
2005-11-22 12:26:26 +00:00
// separator
separator = gtk_separator_menu_item_new ( ) ;
gtk_widget_show ( separator ) ;
gtk_container_add ( GTK_CONTAINER ( menu ) , separator ) ;
gtk_widget_set_sensitive ( separator , FALSE ) ;
// arguments
2006-04-27 18:06:35 +00:00
item = gtk_image_menu_item_new_with_mnemonic ( _ ( " Set Arguments " ) ) ;
2005-11-22 12:26:26 +00:00
gtk_widget_show ( item ) ;
2006-05-19 17:18:06 +00:00
if ( keys [ GEANY_KEYS_BUILD_OPTIONS ] - > key )
gtk_widget_add_accelerator ( item , " activate " , accel_group , keys [ GEANY_KEYS_BUILD_OPTIONS ] - > key ,
keys [ GEANY_KEYS_BUILD_OPTIONS ] - > mods , GTK_ACCEL_VISIBLE ) ;
2005-11-22 12:26:26 +00:00
gtk_container_add ( GTK_CONTAINER ( menu ) , item ) ;
gtk_tooltips_set_tip ( tooltips , item ,
2006-01-11 18:44:52 +00:00
_ ( " Sets the program paths and arguments " ) , NULL ) ;
2005-11-22 12:26:26 +00:00
image = gtk_image_new_from_stock ( " gtk-preferences " , GTK_ICON_SIZE_MENU ) ;
gtk_widget_show ( image ) ;
gtk_image_menu_item_set_image ( GTK_IMAGE_MENU_ITEM ( item ) , image ) ;
2006-01-11 18:44:52 +00:00
g_signal_connect ( ( gpointer ) item , " activate " , G_CALLBACK ( on_build_tex_arguments_activate ) , NULL ) ;
2005-11-22 12:26:26 +00:00
gtk_window_add_accel_group ( GTK_WINDOW ( app - > window ) , accel_group ) ;
2006-01-11 18:44:52 +00:00
return menu ;
2005-11-22 12:26:26 +00:00
}
void dialogs_create_recent_menu ( void )
{
GtkWidget * recent_menu = lookup_widget ( app - > window , " recent_files1_menu " ) ;
GtkWidget * tmp ;
gint i ;
gchar * filename ;
2005-12-12 02:23:51 +00:00
for ( i = ( MIN ( app - > mru_length , g_queue_get_length ( app - > recent_queue ) ) - 1 ) ; i > = 0 ; i - - )
2005-11-22 12:26:26 +00:00
{
filename = g_queue_peek_nth ( app - > recent_queue , i ) ;
tmp = gtk_menu_item_new_with_label ( filename ) ;
gtk_widget_show ( tmp ) ;
gtk_container_add ( GTK_CONTAINER ( recent_menu ) , tmp ) ;
g_signal_connect ( ( gpointer ) tmp , " activate " ,
G_CALLBACK ( on_recent_file_activate ) , ( gpointer ) filename ) ;
}
}
void dialogs_show_make_target ( void )
{
GtkWidget * dialog , * label , * entry ;
dialog = gtk_dialog_new_with_buttons ( _ ( " Enter custom options for the make tool " ) , GTK_WINDOW ( app - > window ) ,
GTK_DIALOG_DESTROY_WITH_PARENT ,
GTK_STOCK_CANCEL , GTK_RESPONSE_REJECT ,
GTK_STOCK_OK , GTK_RESPONSE_ACCEPT , NULL ) ;
label = gtk_label_new ( _ ( " Enter custom options here, all entered text is passed to the make command. " ) ) ;
gtk_misc_set_padding ( GTK_MISC ( label ) , 0 , 6 ) ;
gtk_misc_set_alignment ( GTK_MISC ( label ) , 0 , 0 ) ;
entry = gtk_entry_new ( ) ;
if ( app - > build_make_custopt )
{
gtk_entry_set_text ( GTK_ENTRY ( entry ) , app - > build_make_custopt ) ;
}
gtk_entry_set_max_length ( GTK_ENTRY ( entry ) , 248 ) ;
gtk_entry_set_width_chars ( GTK_ENTRY ( entry ) , 30 ) ;
g_signal_connect ( ( gpointer ) entry , " activate " , G_CALLBACK ( on_make_target_entry_activate ) , dialog ) ;
g_signal_connect ( ( gpointer ) dialog , " response " , G_CALLBACK ( on_make_target_dialog_response ) , entry ) ;
2006-05-19 17:18:06 +00:00
g_signal_connect ( ( gpointer ) dialog , " delete_event " , G_CALLBACK ( gtk_widget_destroy ) , NULL ) ;
2005-11-22 12:26:26 +00:00
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( dialog ) - > vbox ) , label ) ;
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( dialog ) - > vbox ) , entry ) ;
gtk_widget_show_all ( dialog ) ;
}
void dialogs_show_goto_line ( void )
{
GtkWidget * dialog , * label , * entry ;
dialog = gtk_dialog_new_with_buttons ( _ ( " Go to line " ) , GTK_WINDOW ( app - > window ) ,
GTK_DIALOG_DESTROY_WITH_PARENT ,
GTK_STOCK_CANCEL , GTK_RESPONSE_REJECT ,
GTK_STOCK_OK , GTK_RESPONSE_ACCEPT , NULL ) ;
label = gtk_label_new ( _ ( " Enter the line you want to go to " ) ) ;
gtk_misc_set_padding ( GTK_MISC ( label ) , 0 , 6 ) ;
gtk_misc_set_alignment ( GTK_MISC ( label ) , 0 , 0 ) ;
entry = gtk_entry_new ( ) ;
gtk_entry_set_max_length ( GTK_ENTRY ( entry ) , 6 ) ;
gtk_entry_set_width_chars ( GTK_ENTRY ( entry ) , 30 ) ;
g_signal_connect ( ( gpointer ) entry , " activate " , G_CALLBACK ( on_goto_line_entry_activate ) , dialog ) ;
g_signal_connect ( ( gpointer ) dialog , " response " , G_CALLBACK ( on_goto_line_dialog_response ) , entry ) ;
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( dialog ) - > vbox ) , label ) ;
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( dialog ) - > vbox ) , entry ) ;
gtk_widget_show_all ( dialog ) ;
}
void dialogs_show_find ( void )
{
2006-02-10 20:57:09 +00:00
gint idx = document_get_cur_idx ( ) ;
gchar * sel = NULL ;
2006-03-10 21:40:20 +00:00
if ( sci_get_lines_selected ( doc_list [ idx ] . sci ) = = 1 )
2006-02-10 20:57:09 +00:00
{
sel = g_malloc ( sci_get_selected_text_length ( doc_list [ idx ] . sci ) ) ;
sci_get_selected_text ( doc_list [ idx ] . sci , sel ) ;
}
2006-02-14 22:07:55 +00:00
2005-11-22 12:26:26 +00:00
if ( app - > find_dialog = = NULL )
{
GtkWidget * label , * entry , * checkbox1 , * checkbox2 , * checkbox3 , * checkbox4 , * checkbox5 ;
GtkTooltips * tooltips = GTK_TOOLTIPS ( lookup_widget ( app - > window , " tooltips " ) ) ;
app - > find_dialog = gtk_dialog_new_with_buttons ( _ ( " Find " ) , GTK_WINDOW ( app - > window ) ,
GTK_DIALOG_DESTROY_WITH_PARENT , GTK_STOCK_CANCEL , GTK_RESPONSE_CANCEL , NULL ) ;
gtk_dialog_add_button ( GTK_DIALOG ( app - > find_dialog ) , " gtk-find " , GTK_RESPONSE_ACCEPT ) ;
label = gtk_label_new ( _ ( " Enter the search text here " ) ) ;
gtk_misc_set_padding ( GTK_MISC ( label ) , 0 , 6 ) ;
gtk_misc_set_alignment ( GTK_MISC ( label ) , 0 , 0 ) ;
entry = gtk_combo_box_entry_new_text ( ) ;
gtk_entry_set_max_length ( GTK_ENTRY ( gtk_bin_get_child ( GTK_BIN ( entry ) ) ) , 248 ) ;
gtk_entry_set_width_chars ( GTK_ENTRY ( gtk_bin_get_child ( GTK_BIN ( entry ) ) ) , 50 ) ;
2006-02-10 20:57:09 +00:00
if ( sel ) gtk_entry_set_text ( GTK_ENTRY ( GTK_BIN ( entry ) - > child ) , sel ) ;
2005-11-22 12:26:26 +00:00
g_object_set_data_full ( G_OBJECT ( app - > find_dialog ) , " entry " ,
gtk_widget_ref ( entry ) , ( GDestroyNotify ) gtk_widget_unref ) ;
g_signal_connect ( ( gpointer ) gtk_bin_get_child ( GTK_BIN ( entry ) ) , " activate " ,
G_CALLBACK ( on_find_entry_activate ) , NULL ) ;
g_signal_connect ( ( gpointer ) app - > find_dialog , " response " ,
G_CALLBACK ( on_find_dialog_response ) , entry ) ;
2006-03-02 21:12:27 +00:00
g_signal_connect ( ( gpointer ) app - > find_dialog , " delete_event " ,
G_CALLBACK ( gtk_widget_hide ) , NULL ) ;
2005-11-22 12:26:26 +00:00
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( app - > find_dialog ) - > vbox ) , label ) ;
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( app - > find_dialog ) - > vbox ) , entry ) ;
checkbox1 = gtk_check_button_new_with_mnemonic ( _ ( " _Case sensitive " ) ) ;
g_object_set_data_full ( G_OBJECT ( app - > find_dialog ) , " check_case " ,
gtk_widget_ref ( checkbox1 ) , ( GDestroyNotify ) gtk_widget_unref ) ;
gtk_button_set_focus_on_click ( GTK_BUTTON ( checkbox1 ) , FALSE ) ;
checkbox2 = gtk_check_button_new_with_mnemonic ( _ ( " Match only a _whole word " ) ) ;
g_object_set_data_full ( G_OBJECT ( app - > find_dialog ) , " check_word " ,
gtk_widget_ref ( checkbox2 ) , ( GDestroyNotify ) gtk_widget_unref ) ;
gtk_button_set_focus_on_click ( GTK_BUTTON ( checkbox2 ) , FALSE ) ;
checkbox3 = gtk_check_button_new_with_mnemonic ( _ ( " _Use regular expressions " ) ) ;
g_object_set_data_full ( G_OBJECT ( app - > find_dialog ) , " check_regexp " ,
gtk_widget_ref ( checkbox3 ) , ( GDestroyNotify ) gtk_widget_unref ) ;
gtk_button_set_focus_on_click ( GTK_BUTTON ( checkbox3 ) , FALSE ) ;
gtk_tooltips_set_tip ( tooltips , checkbox3 ,
_ ( " For detailed information about using regular expressions, please read the documentation. " ) , NULL ) ;
checkbox4 = gtk_check_button_new_with_mnemonic ( _ ( " _Search backwards " ) ) ;
g_object_set_data_full ( G_OBJECT ( app - > find_dialog ) , " check_back " ,
gtk_widget_ref ( checkbox4 ) , ( GDestroyNotify ) gtk_widget_unref ) ;
gtk_button_set_focus_on_click ( GTK_BUTTON ( checkbox4 ) , FALSE ) ;
2006-05-26 15:51:32 +00:00
checkbox5 = gtk_check_button_new_with_mnemonic ( _ ( " Match only word s_tart " ) ) ;
2005-11-22 12:26:26 +00:00
g_object_set_data_full ( G_OBJECT ( app - > find_dialog ) , " check_wordstart " ,
gtk_widget_ref ( checkbox5 ) , ( GDestroyNotify ) gtk_widget_unref ) ;
gtk_button_set_focus_on_click ( GTK_BUTTON ( checkbox5 ) , FALSE ) ;
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( app - > find_dialog ) - > vbox ) , checkbox1 ) ;
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( app - > find_dialog ) - > vbox ) , checkbox2 ) ;
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( app - > find_dialog ) - > vbox ) , checkbox5 ) ;
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( app - > find_dialog ) - > vbox ) , checkbox3 ) ;
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( app - > find_dialog ) - > vbox ) , checkbox4 ) ;
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( app - > find_dialog ) - > vbox ) , gtk_label_new ( " " ) ) ;
gtk_box_set_spacing ( GTK_BOX ( GTK_DIALOG ( app - > find_dialog ) - > vbox ) , 3 ) ;
gtk_widget_show_all ( app - > find_dialog ) ;
}
else
{
2006-02-10 20:57:09 +00:00
if ( sel ) gtk_entry_set_text ( GTK_ENTRY ( GTK_BIN (
lookup_widget ( app - > find_dialog , " entry " ) ) - > child ) , sel ) ;
gtk_widget_grab_focus ( GTK_WIDGET ( GTK_BIN ( lookup_widget ( app - > find_dialog , " entry " ) ) - > child ) ) ;
2005-11-22 12:26:26 +00:00
gtk_widget_show ( app - > find_dialog ) ;
}
2006-02-10 20:57:09 +00:00
g_free ( sel ) ;
2005-11-22 12:26:26 +00:00
}
void dialogs_show_replace ( void )
{
2006-02-10 20:57:09 +00:00
gint idx = document_get_cur_idx ( ) ;
gchar * sel = NULL ;
2006-03-10 21:40:20 +00:00
if ( sci_get_lines_selected ( doc_list [ idx ] . sci ) = = 1 )
2006-02-10 20:57:09 +00:00
{
sel = g_malloc ( sci_get_selected_text_length ( doc_list [ idx ] . sci ) ) ;
sci_get_selected_text ( doc_list [ idx ] . sci , sel ) ;
}
2006-02-14 22:07:55 +00:00
2005-11-22 12:26:26 +00:00
if ( app - > replace_dialog = = NULL )
{
2006-05-26 15:51:32 +00:00
GtkWidget * label_find , * label_replace , * entry_find , * entry_replace ;
GtkWidget * checkbox1 , * checkbox2 , * checkbox3 , * checkbox5 , * checkbox4 ;
GtkWidget * button ;
2005-11-22 12:26:26 +00:00
GtkTooltips * tooltips = GTK_TOOLTIPS ( lookup_widget ( app - > window , " tooltips " ) ) ;
app - > replace_dialog = gtk_dialog_new_with_buttons ( _ ( " Replace " ) , GTK_WINDOW ( app - > window ) ,
GTK_DIALOG_DESTROY_WITH_PARENT , GTK_STOCK_CANCEL , GTK_RESPONSE_CANCEL , NULL ) ;
2006-05-26 17:03:32 +00:00
button = gtk_button_new_with_mnemonic ( _ ( " _In Selection " ) ) ;
2006-05-26 15:51:32 +00:00
gtk_tooltips_set_tip ( tooltips , button ,
_ ( " Replace all matches found in the currently selected text " ) , NULL ) ;
gtk_widget_show ( button ) ;
gtk_dialog_add_action_widget ( GTK_DIALOG ( app - > replace_dialog ) , button ,
GEANY_RESPONSE_REPLACE_SEL ) ;
button = gtk_button_new_with_mnemonic ( _ ( " Replace _All " ) ) ;
gtk_widget_show ( button ) ;
gtk_dialog_add_action_widget ( GTK_DIALOG ( app - > replace_dialog ) , button ,
GEANY_RESPONSE_REPLACE_ALL ) ;
button = gtk_button_new_with_mnemonic ( _ ( " _Replace " ) ) ;
gtk_widget_show ( button ) ;
gtk_dialog_add_action_widget ( GTK_DIALOG ( app - > replace_dialog ) , button ,
GEANY_RESPONSE_REPLACE ) ;
2005-11-22 12:26:26 +00:00
label_find = gtk_label_new ( _ ( " Enter the search text here " ) ) ;
gtk_misc_set_padding ( GTK_MISC ( label_find ) , 0 , 6 ) ;
gtk_misc_set_alignment ( GTK_MISC ( label_find ) , 0 , 0 ) ;
label_replace = gtk_label_new ( _ ( " Enter the replace text here " ) ) ;
gtk_misc_set_padding ( GTK_MISC ( label_replace ) , 0 , 6 ) ;
gtk_misc_set_alignment ( GTK_MISC ( label_replace ) , 0 , 0 ) ;
entry_find = gtk_combo_box_entry_new_text ( ) ;
gtk_entry_set_max_length ( GTK_ENTRY ( gtk_bin_get_child ( GTK_BIN ( entry_find ) ) ) , 248 ) ;
gtk_entry_set_width_chars ( GTK_ENTRY ( gtk_bin_get_child ( GTK_BIN ( entry_find ) ) ) , 50 ) ;
2006-02-10 20:57:09 +00:00
if ( sel ) gtk_entry_set_text ( GTK_ENTRY ( GTK_BIN ( entry_find ) - > child ) , sel ) ;
2005-11-22 12:26:26 +00:00
g_object_set_data_full ( G_OBJECT ( app - > replace_dialog ) , " entry_find " ,
gtk_widget_ref ( entry_find ) , ( GDestroyNotify ) gtk_widget_unref ) ;
entry_replace = gtk_combo_box_entry_new_text ( ) ;
gtk_entry_set_max_length ( GTK_ENTRY ( gtk_bin_get_child ( GTK_BIN ( entry_replace ) ) ) , 248 ) ;
gtk_entry_set_width_chars ( GTK_ENTRY ( gtk_bin_get_child ( GTK_BIN ( entry_replace ) ) ) , 50 ) ;
g_object_set_data_full ( G_OBJECT ( app - > replace_dialog ) , " entry_replace " ,
gtk_widget_ref ( entry_replace ) , ( GDestroyNotify ) gtk_widget_unref ) ;
g_signal_connect ( ( gpointer ) gtk_bin_get_child ( GTK_BIN ( entry_replace ) ) , " activate " ,
G_CALLBACK ( on_replace_entry_activate ) , NULL ) ;
g_signal_connect ( ( gpointer ) app - > replace_dialog , " response " ,
G_CALLBACK ( on_replace_dialog_response ) , entry_replace ) ;
2006-03-02 21:12:27 +00:00
g_signal_connect ( ( gpointer ) app - > replace_dialog , " delete_event " ,
G_CALLBACK ( gtk_widget_hide ) , NULL ) ;
2005-11-22 12:26:26 +00:00
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( app - > replace_dialog ) - > vbox ) , label_find ) ;
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( app - > replace_dialog ) - > vbox ) , entry_find ) ;
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( app - > replace_dialog ) - > vbox ) , label_replace ) ;
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( app - > replace_dialog ) - > vbox ) , entry_replace ) ;
checkbox1 = gtk_check_button_new_with_mnemonic ( _ ( " _Case sensitive " ) ) ;
g_object_set_data_full ( G_OBJECT ( app - > replace_dialog ) , " check_case " ,
gtk_widget_ref ( checkbox1 ) , ( GDestroyNotify ) gtk_widget_unref ) ;
gtk_button_set_focus_on_click ( GTK_BUTTON ( checkbox1 ) , FALSE ) ;
checkbox2 = gtk_check_button_new_with_mnemonic ( _ ( " Match only a _whole word " ) ) ;
g_object_set_data_full ( G_OBJECT ( app - > replace_dialog ) , " check_word " ,
gtk_widget_ref ( checkbox2 ) , ( GDestroyNotify ) gtk_widget_unref ) ;
gtk_button_set_focus_on_click ( GTK_BUTTON ( checkbox2 ) , FALSE ) ;
checkbox3 = gtk_check_button_new_with_mnemonic ( _ ( " _Use regular expressions " ) ) ;
g_object_set_data_full ( G_OBJECT ( app - > replace_dialog ) , " check_regexp " ,
gtk_widget_ref ( checkbox3 ) , ( GDestroyNotify ) gtk_widget_unref ) ;
gtk_button_set_focus_on_click ( GTK_BUTTON ( checkbox3 ) , FALSE ) ;
gtk_tooltips_set_tip ( tooltips , checkbox3 ,
_ ( " For detailed information about using regular expressions, please read the documentation. " ) , NULL ) ;
checkbox4 = gtk_check_button_new_with_mnemonic ( _ ( " _Search backwards " ) ) ;
g_object_set_data_full ( G_OBJECT ( app - > replace_dialog ) , " check_back " ,
gtk_widget_ref ( checkbox4 ) , ( GDestroyNotify ) gtk_widget_unref ) ;
gtk_button_set_focus_on_click ( GTK_BUTTON ( checkbox4 ) , FALSE ) ;
2006-05-26 15:51:32 +00:00
checkbox5 = gtk_check_button_new_with_mnemonic ( _ ( " Match only word s_tart " ) ) ;
2005-11-22 12:26:26 +00:00
g_object_set_data_full ( G_OBJECT ( app - > replace_dialog ) , " check_wordstart " ,
gtk_widget_ref ( checkbox5 ) , ( GDestroyNotify ) gtk_widget_unref ) ;
gtk_button_set_focus_on_click ( GTK_BUTTON ( checkbox5 ) , FALSE ) ;
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( app - > replace_dialog ) - > vbox ) , checkbox1 ) ;
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( app - > replace_dialog ) - > vbox ) , checkbox2 ) ;
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( app - > replace_dialog ) - > vbox ) , checkbox5 ) ;
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( app - > replace_dialog ) - > vbox ) , checkbox3 ) ;
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( app - > replace_dialog ) - > vbox ) , checkbox4 ) ;
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( app - > replace_dialog ) - > vbox ) , gtk_label_new ( " " ) ) ;
gtk_box_set_spacing ( GTK_BOX ( GTK_DIALOG ( app - > replace_dialog ) - > vbox ) , 3 ) ;
gtk_widget_show_all ( app - > replace_dialog ) ;
}
else
{
2006-02-10 20:57:09 +00:00
if ( sel ) gtk_entry_set_text ( GTK_ENTRY ( GTK_BIN (
lookup_widget ( app - > replace_dialog , " entry_find " ) ) - > child ) , sel ) ;
gtk_widget_grab_focus ( GTK_WIDGET ( GTK_BIN ( lookup_widget ( app - > replace_dialog , " entry_find " ) ) - > child ) ) ;
2005-11-22 12:26:26 +00:00
gtk_widget_show ( app - > replace_dialog ) ;
}
2006-02-10 20:57:09 +00:00
g_free ( sel ) ;
2005-11-22 12:26:26 +00:00
}
2006-01-11 18:44:52 +00:00
void dialogs_show_includes_arguments_tex ( void )
{
2006-04-27 18:06:35 +00:00
GtkWidget * dialog , * label , * entries [ 4 ] ;
gint idx = document_get_cur_idx ( ) ;
filetype * ft = doc_list [ idx ] . file_type ;
2006-01-11 18:44:52 +00:00
2006-01-18 12:11:44 +00:00
dialog = gtk_dialog_new_with_buttons ( _ ( " Set Arguments " ) , GTK_WINDOW ( app - > window ) ,
2006-01-11 18:44:52 +00:00
GTK_DIALOG_DESTROY_WITH_PARENT ,
GTK_STOCK_CANCEL , GTK_RESPONSE_REJECT ,
GTK_STOCK_OK , GTK_RESPONSE_ACCEPT , NULL ) ;
2006-01-18 12:11:44 +00:00
label = gtk_label_new ( _ ( " Set programs and options for compilation and viewing (La)TeX files. \n The filename is appended automatically at the end. \n " ) ) ;
2006-01-11 18:44:52 +00:00
gtk_misc_set_padding ( GTK_MISC ( label ) , 0 , 6 ) ;
gtk_misc_set_alignment ( GTK_MISC ( label ) , 0 , 0 ) ;
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( dialog ) - > vbox ) , label ) ;
// LaTeX -> DVI args
2006-04-27 18:06:35 +00:00
if ( ft - > programs - > compiler ! = NULL )
{
label = gtk_label_new ( _ ( " Enter here the (La)TeX command (for DVI creation) and some useful options. " ) ) ;
gtk_misc_set_padding ( GTK_MISC ( label ) , 0 , 6 ) ;
gtk_misc_set_alignment ( GTK_MISC ( label ) , 0 , 0 ) ;
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( dialog ) - > vbox ) , label ) ;
entries [ 0 ] = gtk_entry_new ( ) ;
gtk_entry_set_width_chars ( GTK_ENTRY ( entries [ 0 ] ) , 30 ) ;
if ( ft - > programs - > compiler )
{
gtk_entry_set_text ( GTK_ENTRY ( entries [ 0 ] ) , ft - > programs - > compiler ) ;
}
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( dialog ) - > vbox ) , entries [ 0 ] ) ;
2006-01-11 18:44:52 +00:00
2006-04-27 18:06:35 +00:00
// whitespace
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( dialog ) - > vbox ) , gtk_label_new ( " " ) ) ;
g_object_set_data_full ( G_OBJECT ( dialog ) , " tex_entry1 " ,
gtk_widget_ref ( entries [ 0 ] ) , ( GDestroyNotify ) gtk_widget_unref ) ;
}
2005-11-22 12:26:26 +00:00
2006-01-11 18:44:52 +00:00
// LaTeX -> PDF args
2006-04-27 18:06:35 +00:00
if ( ft - > programs - > linker ! = NULL )
{
label = gtk_label_new ( _ ( " Enter here the (La)TeX command (for PDF creation) and some useful options. " ) ) ;
gtk_misc_set_padding ( GTK_MISC ( label ) , 0 , 6 ) ;
gtk_misc_set_alignment ( GTK_MISC ( label ) , 0 , 0 ) ;
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( dialog ) - > vbox ) , label ) ;
entries [ 1 ] = gtk_entry_new ( ) ;
gtk_entry_set_width_chars ( GTK_ENTRY ( entries [ 1 ] ) , 30 ) ;
if ( ft - > programs - > linker )
{
gtk_entry_set_text ( GTK_ENTRY ( entries [ 1 ] ) , ft - > programs - > linker ) ;
}
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( dialog ) - > vbox ) , entries [ 1 ] ) ;
2006-01-11 18:44:52 +00:00
2006-04-27 18:06:35 +00:00
// whitespace
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( dialog ) - > vbox ) , gtk_label_new ( " " ) ) ;
g_object_set_data_full ( G_OBJECT ( dialog ) , " tex_entry2 " ,
gtk_widget_ref ( entries [ 1 ] ) , ( GDestroyNotify ) gtk_widget_unref ) ;
}
2006-01-11 18:44:52 +00:00
// View LaTeX -> DVI args
2006-04-27 18:06:35 +00:00
if ( ft - > programs - > run_cmd ! = NULL )
{
label = gtk_label_new ( _ ( " Enter here the (La)TeX command (for DVI preview) and some useful options. " ) ) ;
gtk_misc_set_padding ( GTK_MISC ( label ) , 0 , 6 ) ;
gtk_misc_set_alignment ( GTK_MISC ( label ) , 0 , 0 ) ;
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( dialog ) - > vbox ) , label ) ;
entries [ 2 ] = gtk_entry_new ( ) ;
gtk_entry_set_width_chars ( GTK_ENTRY ( entries [ 2 ] ) , 30 ) ;
if ( ft - > programs - > run_cmd )
{
gtk_entry_set_text ( GTK_ENTRY ( entries [ 2 ] ) , ft - > programs - > run_cmd ) ;
}
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( dialog ) - > vbox ) , entries [ 2 ] ) ;
2006-01-11 18:44:52 +00:00
2006-04-27 18:06:35 +00:00
// whitespace
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( dialog ) - > vbox ) , gtk_label_new ( " " ) ) ;
g_object_set_data_full ( G_OBJECT ( dialog ) , " tex_entry3 " ,
gtk_widget_ref ( entries [ 2 ] ) , ( GDestroyNotify ) gtk_widget_unref ) ;
}
2006-01-11 18:44:52 +00:00
// View LaTeX -> PDF args
2006-04-27 18:06:35 +00:00
if ( ft - > programs - > run_cmd2 ! = NULL )
{
label = gtk_label_new ( _ ( " Enter here the (La)TeX command (for PDF preview) and some useful options. " ) ) ;
gtk_misc_set_padding ( GTK_MISC ( label ) , 0 , 6 ) ;
gtk_misc_set_alignment ( GTK_MISC ( label ) , 0 , 0 ) ;
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( dialog ) - > vbox ) , label ) ;
entries [ 3 ] = gtk_entry_new ( ) ;
gtk_entry_set_width_chars ( GTK_ENTRY ( entries [ 3 ] ) , 30 ) ;
if ( ft - > programs - > run_cmd2 )
{
gtk_entry_set_text ( GTK_ENTRY ( entries [ 3 ] ) , ft - > programs - > run_cmd2 ) ;
}
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( dialog ) - > vbox ) , entries [ 3 ] ) ;
2006-01-11 18:44:52 +00:00
2006-04-27 18:06:35 +00:00
// whitespace
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( dialog ) - > vbox ) , gtk_label_new ( " " ) ) ;
g_object_set_data_full ( G_OBJECT ( dialog ) , " tex_entry4 " ,
2006-01-11 18:44:52 +00:00
gtk_widget_ref ( entries [ 3 ] ) , ( GDestroyNotify ) gtk_widget_unref ) ;
2006-04-27 18:06:35 +00:00
}
2006-01-11 18:44:52 +00:00
2006-04-27 18:06:35 +00:00
g_signal_connect ( ( gpointer ) dialog , " response " ,
G_CALLBACK ( on_includes_arguments_tex_dialog_response ) , GINT_TO_POINTER ( idx ) ) ;
2006-01-11 18:44:52 +00:00
gtk_widget_show_all ( dialog ) ;
}
2006-04-27 18:06:35 +00:00
void dialogs_show_includes_arguments_gen ( void )
2005-11-22 12:26:26 +00:00
{
GtkWidget * dialog , * label , * entries [ 3 ] ;
2006-04-27 18:06:35 +00:00
gint idx = document_get_cur_idx ( ) ;
filetype * ft = doc_list [ idx ] . file_type ;
GtkTooltips * tooltips ;
2005-11-22 12:26:26 +00:00
dialog = gtk_dialog_new_with_buttons ( _ ( " Set Includes and Arguments " ) , GTK_WINDOW ( app - > window ) ,
GTK_DIALOG_DESTROY_WITH_PARENT ,
GTK_STOCK_CANCEL , GTK_RESPONSE_REJECT ,
GTK_STOCK_OK , GTK_RESPONSE_ACCEPT , NULL ) ;
2006-01-11 18:44:52 +00:00
label = gtk_label_new ( _ ( " Sets the includes and library paths for the compiler and the program arguments for execution \n " ) ) ;
2005-11-22 12:26:26 +00:00
gtk_misc_set_padding ( GTK_MISC ( label ) , 0 , 6 ) ;
gtk_misc_set_alignment ( GTK_MISC ( label ) , 0 , 0 ) ;
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( dialog ) - > vbox ) , label ) ;
2006-04-27 18:06:35 +00:00
tooltips = GTK_TOOLTIPS ( lookup_widget ( app - > window , " tooltips " ) ) ;
2005-11-22 12:26:26 +00:00
// include-args
2006-04-27 18:06:35 +00:00
if ( ft - > menu_items - > can_compile )
2005-11-22 12:26:26 +00:00
{
2006-04-27 18:06:35 +00:00
label = gtk_label_new ( _ ( " Enter here arguments to your compiler. " ) ) ;
gtk_misc_set_padding ( GTK_MISC ( label ) , 0 , 6 ) ;
gtk_misc_set_alignment ( GTK_MISC ( label ) , 0 , 0 ) ;
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( dialog ) - > vbox ) , label ) ;
entries [ 0 ] = gtk_entry_new ( ) ;
gtk_tooltips_set_tip ( tooltips , entries [ 0 ] ,
_ ( " %f will be replaced by the complete filename \n %e will be replaced by filename without extension "
" \n Example: test_file.c \n %f -> test_file.c \n %e -> test_file " ) , NULL ) ;
gtk_entry_set_width_chars ( GTK_ENTRY ( entries [ 0 ] ) , 30 ) ;
if ( ft - > programs - > compiler )
{
gtk_entry_set_text ( GTK_ENTRY ( entries [ 0 ] ) , ft - > programs - > compiler ) ;
}
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( dialog ) - > vbox ) , entries [ 0 ] ) ;
2005-11-22 12:26:26 +00:00
2006-04-27 18:06:35 +00:00
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( dialog ) - > vbox ) , gtk_label_new ( " " ) ) ;
g_object_set_data_full ( G_OBJECT ( dialog ) , " includes_entry1 " ,
gtk_widget_ref ( entries [ 0 ] ) , ( GDestroyNotify ) gtk_widget_unref ) ;
}
2006-05-14 16:07:30 +00:00
2005-11-22 12:26:26 +00:00
// lib-args
2006-04-27 18:06:35 +00:00
if ( ft - > menu_items - > can_link )
2005-11-22 12:26:26 +00:00
{
2006-04-27 18:06:35 +00:00
label = gtk_label_new ( _ ( " Enter here arguments to your linker. " ) ) ;
gtk_misc_set_padding ( GTK_MISC ( label ) , 0 , 6 ) ;
gtk_misc_set_alignment ( GTK_MISC ( label ) , 0 , 0 ) ;
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( dialog ) - > vbox ) , label ) ;
entries [ 1 ] = gtk_entry_new ( ) ;
gtk_tooltips_set_tip ( tooltips , entries [ 1 ] ,
_ ( " %f will be replaced by the complete filename \n %e will be replaced by filename without extension "
" \n Example: test_file.c \n %f -> test_file.c \n %e -> test_file " ) , NULL ) ;
gtk_entry_set_width_chars ( GTK_ENTRY ( entries [ 1 ] ) , 30 ) ;
if ( ft - > programs - > linker )
{
gtk_entry_set_text ( GTK_ENTRY ( entries [ 1 ] ) , ft - > programs - > linker ) ;
}
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( dialog ) - > vbox ) , entries [ 1 ] ) ;
2005-11-22 12:26:26 +00:00
2006-04-27 18:06:35 +00:00
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( dialog ) - > vbox ) , gtk_label_new ( " " ) ) ;
g_object_set_data_full ( G_OBJECT ( dialog ) , " includes_entry2 " ,
gtk_widget_ref ( entries [ 1 ] ) , ( GDestroyNotify ) gtk_widget_unref ) ;
2005-11-22 12:26:26 +00:00
}
2006-01-11 18:44:52 +00:00
2006-04-27 18:06:35 +00:00
// lib-args
if ( ft - > menu_items - > can_exec )
{
// program-args
label = gtk_label_new ( _ ( " Enter here arguments to your program. " ) ) ;
gtk_misc_set_padding ( GTK_MISC ( label ) , 0 , 6 ) ;
gtk_misc_set_alignment ( GTK_MISC ( label ) , 0 , 0 ) ;
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( dialog ) - > vbox ) , label ) ;
entries [ 2 ] = gtk_entry_new ( ) ;
gtk_tooltips_set_tip ( tooltips , entries [ 2 ] ,
_ ( " %f will be replaced by the complete filename \n %e will be replaced by filename without extension "
" \n Example: test_file.c \n %f -> test_file.c \n %e -> test_file " ) , NULL ) ;
gtk_entry_set_width_chars ( GTK_ENTRY ( entries [ 2 ] ) , 30 ) ;
if ( ft - > programs - > run_cmd )
{
gtk_entry_set_text ( GTK_ENTRY ( entries [ 2 ] ) , ft - > programs - > run_cmd ) ;
}
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( dialog ) - > vbox ) , entries [ 2 ] ) ;
2005-11-22 12:26:26 +00:00
2006-04-27 18:06:35 +00:00
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( dialog ) - > vbox ) , gtk_label_new ( " " ) ) ;
g_object_set_data_full ( G_OBJECT ( dialog ) , " includes_entry3 " ,
gtk_widget_ref ( entries [ 2 ] ) , ( GDestroyNotify ) gtk_widget_unref ) ;
}
2005-11-22 12:26:26 +00:00
2006-04-27 18:06:35 +00:00
g_signal_connect ( ( gpointer ) dialog , " response " ,
G_CALLBACK ( on_includes_arguments_dialog_response ) , GINT_TO_POINTER ( idx ) ) ;
2005-11-22 12:26:26 +00:00
gtk_widget_show_all ( dialog ) ;
}
GtkWidget * dialogs_add_file_open_extra_widget ( void )
{
GtkWidget * vbox ;
2006-04-27 18:06:35 +00:00
GtkWidget * lbox ;
2006-02-10 20:57:09 +00:00
GtkWidget * ebox ;
GtkWidget * hbox ;
2005-11-22 12:26:26 +00:00
GtkWidget * file_entry ;
2006-04-27 18:06:35 +00:00
GtkSizeGroup * sizegroup ;
GtkWidget * align ;
2005-11-22 12:26:26 +00:00
GtkWidget * check_hidden ;
2006-02-10 20:57:09 +00:00
GtkWidget * filetype_label ;
GtkWidget * filetype_combo ;
2005-11-22 12:26:26 +00:00
GtkTooltips * tooltips = GTK_TOOLTIPS ( lookup_widget ( app - > window , " tooltips " ) ) ;
2006-04-27 18:06:35 +00:00
vbox = gtk_vbox_new ( FALSE , 6 ) ;
sizegroup = gtk_size_group_new ( GTK_SIZE_GROUP_HORIZONTAL ) ;
align = gtk_alignment_new ( 1.0 , 0.0 , 0.0 , 0.0 ) ;
check_hidden = gtk_check_button_new_with_mnemonic ( _ ( " Show _hidden files " ) ) ;
gtk_widget_show ( check_hidden ) ;
gtk_size_group_add_widget ( GTK_SIZE_GROUP ( sizegroup ) , check_hidden ) ;
gtk_container_add ( GTK_CONTAINER ( align ) , check_hidden ) ;
gtk_box_pack_start ( GTK_BOX ( vbox ) , align , FALSE , FALSE , 0 ) ;
gtk_button_set_focus_on_click ( GTK_BUTTON ( check_hidden ) , FALSE ) ;
2005-11-22 12:26:26 +00:00
2006-04-27 18:06:35 +00:00
lbox = gtk_hbox_new ( FALSE , 12 ) ;
2005-11-22 12:26:26 +00:00
file_entry = gtk_entry_new ( ) ;
gtk_widget_show ( file_entry ) ;
2006-04-27 18:06:35 +00:00
gtk_box_pack_start ( GTK_BOX ( lbox ) , file_entry , TRUE , TRUE , 0 ) ;
//gtk_editable_set_editable(GTK_EDITABLE(file_entry), FALSE);
2005-11-22 12:26:26 +00:00
gtk_entry_set_activates_default ( GTK_ENTRY ( file_entry ) , TRUE ) ;
2006-02-10 20:57:09 +00:00
// the ebox is for the tooltip, because gtk_combo_box doesn't show a tooltip for unknown reason
ebox = gtk_event_box_new ( ) ;
2006-04-27 18:06:35 +00:00
hbox = gtk_hbox_new ( FALSE , 6 ) ;
filetype_label = gtk_label_new ( _ ( " Set filetype: " ) ) ;
2006-02-10 20:57:09 +00:00
filetype_combo = gtk_combo_box_new_text ( ) ;
gtk_tooltips_set_tip ( tooltips , ebox ,
2006-04-27 18:06:35 +00:00
_ ( " Explicitly defines a filetype for the file, if it would not be detected by filename extension. \n Note if you choose multiple files, they will all be opened with the chosen filetype. " ) , NULL ) ;
2006-02-10 20:57:09 +00:00
gtk_box_pack_start ( GTK_BOX ( hbox ) , filetype_label , FALSE , FALSE , 0 ) ;
gtk_box_pack_start ( GTK_BOX ( hbox ) , filetype_combo , FALSE , FALSE , 0 ) ;
2006-04-27 18:06:35 +00:00
gtk_size_group_add_widget ( GTK_SIZE_GROUP ( sizegroup ) , filetype_combo ) ;
2006-02-10 20:57:09 +00:00
gtk_container_add ( GTK_CONTAINER ( ebox ) , hbox ) ;
2006-04-27 18:06:35 +00:00
gtk_box_pack_start ( GTK_BOX ( lbox ) , ebox , FALSE , FALSE , 0 ) ;
gtk_box_pack_start ( GTK_BOX ( vbox ) , lbox , FALSE , FALSE , 0 ) ;
2006-02-10 20:57:09 +00:00
gtk_widget_show_all ( vbox ) ;
2005-11-22 12:26:26 +00:00
g_signal_connect ( ( gpointer ) file_entry , " activate " ,
G_CALLBACK ( on_file_open_entry_activate ) , NULL ) ;
g_signal_connect ( ( gpointer ) check_hidden , " toggled " ,
G_CALLBACK ( on_file_open_check_hidden_toggled ) , NULL ) ;
g_object_set_data_full ( G_OBJECT ( app - > open_filesel ) , " file_entry " ,
gtk_widget_ref ( file_entry ) , ( GDestroyNotify ) gtk_widget_unref ) ;
g_object_set_data_full ( G_OBJECT ( app - > open_filesel ) , " check_hidden " ,
gtk_widget_ref ( check_hidden ) , ( GDestroyNotify ) gtk_widget_unref ) ;
2006-02-10 20:57:09 +00:00
g_object_set_data_full ( G_OBJECT ( app - > open_filesel ) , " filetype_combo " ,
gtk_widget_ref ( filetype_combo ) , ( GDestroyNotify ) gtk_widget_unref ) ;
2005-11-22 12:26:26 +00:00
return vbox ;
}
gboolean dialogs_show_mkcfgdir_error ( gint error_nr )
{
GtkWidget * dialog ;
gchar string [ 255 ] ;
gint ret ;
snprintf ( string , 255 , _ ( " Configuration directory could not be created (%s). \n There could be some problems using %s without a configuration directory. \n Start %s anyway? " ) ,
g_strerror ( error_nr ) , PACKAGE , PACKAGE ) ;
# ifdef GEANY_WIN32
dialog = NULL ;
ret = MessageBox ( NULL , string , _ ( " Error " ) , MB_YESNO | MB_ICONERROR ) ;
if ( ret = = IDYES ) return TRUE ;
else return FALSE ;
# else
2006-02-22 13:46:20 +00:00
dialog = gtk_message_dialog_new ( NULL , GTK_DIALOG_DESTROY_WITH_PARENT ,
2005-11-22 12:26:26 +00:00
GTK_MESSAGE_ERROR , GTK_BUTTONS_YES_NO , string ) ;
2006-02-22 13:46:20 +00:00
ret = gtk_dialog_run ( GTK_DIALOG ( dialog ) ) ;
2005-11-22 12:26:26 +00:00
gtk_widget_destroy ( dialog ) ;
if ( ret = = GTK_RESPONSE_YES ) return TRUE ;
else return FALSE ;
# endif
}
2006-02-22 13:46:20 +00:00
void dialogs_show_file_properties ( gint idx )
{
GtkWidget * dialog , * label , * table , * hbox , * image , * perm_table , * check ;
2006-04-27 18:06:35 +00:00
gchar * file_size , * title , * base_name , * time_changed , * time_modified , * time_accessed ;
2006-02-22 13:46:20 +00:00
# if defined(HAVE_SYS_STAT_H) && defined(HAVE_SYS_TYPES_H)
struct stat st ;
2006-02-25 22:26:43 +00:00
off_t filesize ;
2006-02-22 13:46:20 +00:00
mode_t mode ;
2006-04-27 18:06:35 +00:00
gchar * locale_filename ;
2006-02-22 13:46:20 +00:00
# else
gint filesize = 0 ;
gint mode = 0 ;
# endif
2006-05-05 16:37:35 +00:00
// define this ones, to avoid later trouble
# ifndef S_IRUSR
# define S_IRUSR 0
# define S_IWUSR 0
# define S_IXUSR 0
# endif
# ifndef S_IRGRP
# define S_IRGRP 0
# define S_IWGRP 0
# define S_IXGRP 0
# define S_IROTH 0
# define S_IWOTH 0
# define S_IXOTH 0
# endif
2006-04-27 18:06:35 +00:00
if ( idx = = - 1 | | ! doc_list [ idx ] . is_valid | | doc_list [ idx ] . file_name = = NULL )
{
dialogs_show_error ( _ ( " An error occurred or file information could not be retrieved(e.g. from a new file). " ) ) ;
return ;
}
2006-05-14 16:07:30 +00:00
2006-02-22 13:46:20 +00:00
# if defined(HAVE_SYS_STAT_H) && defined(TIME_WITH_SYS_TIME) && defined(HAVE_SYS_TYPES_H)
locale_filename = g_locale_from_utf8 ( doc_list [ idx ] . file_name , - 1 , NULL , NULL , NULL ) ;
if ( locale_filename = = NULL ) locale_filename = g_strdup ( doc_list [ idx ] . file_name ) ;
if ( stat ( locale_filename , & st ) = = 0 )
{
2006-04-27 18:06:35 +00:00
// first copy the returned string and the trim it, to not modify the static glibc string
// g_strchomp() is used to remove trailing EOL chars, which are there for whatever reason
time_changed = g_strchomp ( g_strdup ( ctime ( & st . st_ctime ) ) ) ;
time_modified = g_strchomp ( g_strdup ( ctime ( & st . st_mtime ) ) ) ;
time_accessed = g_strchomp ( g_strdup ( ctime ( & st . st_atime ) ) ) ;
2006-02-22 13:46:20 +00:00
filesize = st . st_size ;
mode = st . st_mode ;
}
2006-02-25 22:26:43 +00:00
else
2006-02-22 13:46:20 +00:00
{
time_changed = g_strdup ( _ ( " unknown " ) ) ;
time_modified = g_strdup ( _ ( " unknown " ) ) ;
time_accessed = g_strdup ( _ ( " unknown " ) ) ;
2006-02-25 22:26:43 +00:00
filesize = ( off_t ) 0 ;
mode = ( mode_t ) 0 ;
2006-02-22 13:46:20 +00:00
}
g_free ( locale_filename ) ;
# else
time_changed = g_strdup ( _ ( " unknown " ) ) ;
time_modified = g_strdup ( _ ( " unknown " ) ) ;
time_accessed = g_strdup ( _ ( " unknown " ) ) ;
# endif
base_name = g_path_get_basename ( doc_list [ idx ] . file_name ) ;
title = g_strconcat ( base_name , " " , _ ( " Properties " ) , NULL ) ;
dialog = gtk_dialog_new_with_buttons ( title , GTK_WINDOW ( app - > window ) ,
GTK_DIALOG_DESTROY_WITH_PARENT ,
GTK_STOCK_CLOSE , GTK_RESPONSE_NONE , NULL ) ;
g_free ( title ) ;
2006-03-02 21:12:27 +00:00
g_signal_connect ( dialog , " response " , G_CALLBACK ( gtk_widget_destroy ) , NULL ) ;
g_signal_connect ( dialog , " delete_event " , G_CALLBACK ( gtk_widget_destroy ) , NULL ) ;
2006-02-22 13:46:20 +00:00
2006-04-27 18:06:35 +00:00
gtk_window_set_default_size ( GTK_WINDOW ( dialog ) , 300 , - 1 ) ;
title = g_strdup_printf ( " <b>%s \n </b> \n " , base_name ) ;
2006-02-22 13:46:20 +00:00
label = gtk_label_new ( title ) ;
2006-04-27 18:06:35 +00:00
gtk_misc_set_alignment ( GTK_MISC ( label ) , 0.0 , 1.0 ) ;
2006-02-22 13:46:20 +00:00
image = gtk_image_new_from_stock ( " gtk-file " , GTK_ICON_SIZE_BUTTON ) ;
2006-04-27 18:06:35 +00:00
gtk_misc_set_alignment ( GTK_MISC ( image ) , 1.0 , 0.0 ) ;
hbox = gtk_hbox_new ( FALSE , 10 ) ;
2006-02-22 13:46:20 +00:00
gtk_label_set_use_markup ( GTK_LABEL ( label ) , TRUE ) ;
gtk_container_add ( GTK_CONTAINER ( hbox ) , image ) ;
gtk_container_add ( GTK_CONTAINER ( hbox ) , label ) ;
2006-04-27 18:06:35 +00:00
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( dialog ) - > vbox ) , gtk_label_new ( " " ) ) ;
2006-02-22 13:46:20 +00:00
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( dialog ) - > vbox ) , hbox ) ;
g_free ( title ) ;
2006-04-27 18:06:35 +00:00
table = gtk_table_new ( 8 , 2 , FALSE ) ;
2006-02-22 13:46:20 +00:00
gtk_table_set_row_spacings ( GTK_TABLE ( table ) , 10 ) ;
2006-04-27 18:06:35 +00:00
gtk_table_set_col_spacings ( GTK_TABLE ( table ) , 10 ) ;
2006-02-22 13:46:20 +00:00
label = gtk_label_new ( _ ( " <b>Type:</b> " ) ) ;
gtk_table_attach ( GTK_TABLE ( table ) , label , 0 , 1 , 0 , 1 ,
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
gtk_label_set_use_markup ( GTK_LABEL ( label ) , TRUE ) ;
gtk_misc_set_alignment ( GTK_MISC ( label ) , 1 , 0 ) ;
label = gtk_label_new ( doc_list [ idx ] . file_type - > title ) ;
gtk_table_attach ( GTK_TABLE ( table ) , label , 1 , 2 , 0 , 1 ,
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
gtk_misc_set_alignment ( GTK_MISC ( label ) , 0 , 0 ) ;
label = gtk_label_new ( _ ( " <b>Size:</b> " ) ) ;
gtk_table_attach ( GTK_TABLE ( table ) , label , 0 , 1 , 1 , 2 ,
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
gtk_label_set_use_markup ( GTK_LABEL ( label ) , TRUE ) ;
gtk_misc_set_alignment ( GTK_MISC ( label ) , 1 , 0 ) ;
file_size = utils_make_human_readable_str ( filesize , 1 , 0 ) ;
label = gtk_label_new ( file_size ) ;
gtk_table_attach ( GTK_TABLE ( table ) , label , 1 , 2 , 1 , 2 ,
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
g_free ( file_size ) ;
gtk_misc_set_alignment ( GTK_MISC ( label ) , 0 , 0 ) ;
label = gtk_label_new ( _ ( " <b>Location:</b> " ) ) ;
gtk_table_attach ( GTK_TABLE ( table ) , label , 0 , 1 , 2 , 3 ,
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
gtk_label_set_use_markup ( GTK_LABEL ( label ) , TRUE ) ;
gtk_misc_set_alignment ( GTK_MISC ( label ) , 1 , 0 ) ;
label = gtk_label_new ( doc_list [ idx ] . file_name ) ;
gtk_table_attach ( GTK_TABLE ( table ) , label , 1 , 2 , 2 , 3 ,
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
2006-04-27 18:06:35 +00:00
gtk_misc_set_alignment ( GTK_MISC ( label ) , 0.0 , 0 ) ;
2006-02-22 13:46:20 +00:00
2006-04-27 18:06:35 +00:00
label = gtk_label_new ( _ ( " <b>Read-only:</b> " ) ) ;
2006-02-22 13:46:20 +00:00
gtk_table_attach ( GTK_TABLE ( table ) , label , 0 , 1 , 3 , 4 ,
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
gtk_label_set_use_markup ( GTK_LABEL ( label ) , TRUE ) ;
gtk_misc_set_alignment ( GTK_MISC ( label ) , 1 , 0 ) ;
2006-04-27 18:06:35 +00:00
check = gtk_check_button_new_with_label ( _ ( " (only inside Geany) " ) ) ;
gtk_widget_set_sensitive ( check , FALSE ) ;
gtk_button_set_focus_on_click ( GTK_BUTTON ( check ) , FALSE ) ;
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( check ) , doc_list [ idx ] . readonly ) ;
gtk_table_attach ( GTK_TABLE ( table ) , check , 1 , 2 , 3 , 4 ,
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
gtk_button_set_alignment ( GTK_BUTTON ( check ) , 0.0 , 0 ) ;
label = gtk_label_new ( _ ( " <b>Encoding:</b> " ) ) ;
gtk_table_attach ( GTK_TABLE ( table ) , label , 0 , 1 , 4 , 5 ,
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
gtk_label_set_use_markup ( GTK_LABEL ( label ) , TRUE ) ;
gtk_misc_set_alignment ( GTK_MISC ( label ) , 1 , 0 ) ;
label = gtk_label_new ( doc_list [ idx ] . encoding ) ;
gtk_table_attach ( GTK_TABLE ( table ) , label , 1 , 2 , 4 , 5 ,
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
gtk_misc_set_alignment ( GTK_MISC ( label ) , 0.0 , 0 ) ;
label = gtk_label_new ( _ ( " <b>Modified:</b> " ) ) ;
gtk_table_attach ( GTK_TABLE ( table ) , label , 0 , 1 , 5 , 6 ,
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
gtk_label_set_use_markup ( GTK_LABEL ( label ) , TRUE ) ;
gtk_misc_set_alignment ( GTK_MISC ( label ) , 1 , 0 ) ;
2006-02-22 13:46:20 +00:00
label = gtk_label_new ( time_modified ) ;
2006-04-27 18:06:35 +00:00
gtk_table_attach ( GTK_TABLE ( table ) , label , 1 , 2 , 5 , 6 ,
2006-02-22 13:46:20 +00:00
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
gtk_misc_set_alignment ( GTK_MISC ( label ) , 0 , 0 ) ;
label = gtk_label_new ( _ ( " <b>Changed:</b> " ) ) ;
2006-04-27 18:06:35 +00:00
gtk_table_attach ( GTK_TABLE ( table ) , label , 0 , 1 , 6 , 7 ,
2006-02-22 13:46:20 +00:00
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
gtk_label_set_use_markup ( GTK_LABEL ( label ) , TRUE ) ;
gtk_misc_set_alignment ( GTK_MISC ( label ) , 1 , 0 ) ;
label = gtk_label_new ( time_changed ) ;
2006-04-27 18:06:35 +00:00
gtk_table_attach ( GTK_TABLE ( table ) , label , 1 , 2 , 6 , 7 ,
2006-02-22 13:46:20 +00:00
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
gtk_misc_set_alignment ( GTK_MISC ( label ) , 0 , 0 ) ;
label = gtk_label_new ( _ ( " <b>Accessed:</b> " ) ) ;
2006-04-27 18:06:35 +00:00
gtk_table_attach ( GTK_TABLE ( table ) , label , 0 , 1 , 7 , 8 ,
2006-02-22 13:46:20 +00:00
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
gtk_label_set_use_markup ( GTK_LABEL ( label ) , TRUE ) ;
gtk_misc_set_alignment ( GTK_MISC ( label ) , 1 , 0 ) ;
label = gtk_label_new ( time_accessed ) ;
2006-04-27 18:06:35 +00:00
gtk_table_attach ( GTK_TABLE ( table ) , label , 1 , 2 , 7 , 8 ,
2006-02-22 13:46:20 +00:00
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
gtk_misc_set_alignment ( GTK_MISC ( label ) , 0 , 0 ) ;
// add table
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( dialog ) - > vbox ) , table ) ;
2006-05-14 16:07:30 +00:00
2006-04-27 18:06:35 +00:00
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( dialog ) - > vbox ) , gtk_label_new ( " " ) ) ;
2006-02-22 13:46:20 +00:00
// create permission label and then table with the permissions
label = gtk_label_new ( " <b>Permissions:</b> " ) ;
gtk_label_set_use_markup ( GTK_LABEL ( label ) , TRUE ) ;
gtk_misc_set_alignment ( GTK_MISC ( label ) , 0 , 0 ) ;
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( dialog ) - > vbox ) , label ) ;
2006-02-25 22:26:43 +00:00
2006-04-27 18:06:35 +00:00
perm_table = gtk_table_new ( 4 , 4 , TRUE ) ;
2006-02-22 13:46:20 +00:00
gtk_table_set_row_spacings ( GTK_TABLE ( perm_table ) , 5 ) ;
gtk_table_set_col_spacings ( GTK_TABLE ( perm_table ) , 5 ) ;
// Header
2006-04-27 18:06:35 +00:00
label = gtk_label_new ( _ ( " Read: " ) ) ;
2006-02-22 13:46:20 +00:00
gtk_table_attach ( GTK_TABLE ( perm_table ) , label , 1 , 2 , 0 , 1 ,
2006-04-27 18:06:35 +00:00
( GtkAttachOptions ) ( GTK_EXPAND | GTK_FILL ) ,
2006-02-22 13:46:20 +00:00
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
gtk_label_set_use_markup ( GTK_LABEL ( label ) , TRUE ) ;
2006-04-27 18:06:35 +00:00
gtk_misc_set_alignment ( GTK_MISC ( label ) , 0.0 , 0 ) ;
2006-02-22 13:46:20 +00:00
2006-04-27 18:06:35 +00:00
label = gtk_label_new ( _ ( " Write: " ) ) ;
2006-02-22 13:46:20 +00:00
gtk_table_attach ( GTK_TABLE ( perm_table ) , label , 2 , 3 , 0 , 1 ,
2006-04-27 18:06:35 +00:00
( GtkAttachOptions ) ( GTK_EXPAND | GTK_FILL ) ,
2006-02-22 13:46:20 +00:00
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
gtk_label_set_use_markup ( GTK_LABEL ( label ) , TRUE ) ;
2006-04-27 18:06:35 +00:00
gtk_misc_set_alignment ( GTK_MISC ( label ) , 0.0 , 0 ) ;
2006-02-22 13:46:20 +00:00
2006-04-27 18:06:35 +00:00
label = gtk_label_new ( _ ( " Execute: " ) ) ;
2006-02-22 13:46:20 +00:00
gtk_table_attach ( GTK_TABLE ( perm_table ) , label , 3 , 4 , 0 , 1 ,
2006-04-27 18:06:35 +00:00
( GtkAttachOptions ) ( GTK_EXPAND | GTK_FILL ) ,
2006-02-22 13:46:20 +00:00
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
gtk_label_set_use_markup ( GTK_LABEL ( label ) , TRUE ) ;
2006-04-27 18:06:35 +00:00
gtk_misc_set_alignment ( GTK_MISC ( label ) , 0.0 , 0 ) ;
2006-02-22 13:46:20 +00:00
// Owner
2006-04-27 18:06:35 +00:00
label = gtk_label_new ( _ ( " Owner: " ) ) ;
2006-02-22 13:46:20 +00:00
gtk_table_attach ( GTK_TABLE ( perm_table ) , label , 0 , 1 , 1 , 2 ,
2006-04-27 18:06:35 +00:00
( GtkAttachOptions ) ( GTK_EXPAND | GTK_FILL ) ,
2006-02-22 13:46:20 +00:00
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
gtk_label_set_use_markup ( GTK_LABEL ( label ) , TRUE ) ;
gtk_misc_set_alignment ( GTK_MISC ( label ) , 0.5 , 0 ) ;
check = gtk_check_button_new ( ) ;
2006-04-27 18:06:35 +00:00
gtk_widget_set_sensitive ( check , FALSE ) ;
2006-02-22 13:46:20 +00:00
gtk_button_set_focus_on_click ( GTK_BUTTON ( check ) , FALSE ) ;
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( check ) , mode & S_IRUSR ) ;
gtk_table_attach ( GTK_TABLE ( perm_table ) , check , 1 , 2 , 1 , 2 ,
2006-04-27 18:06:35 +00:00
( GtkAttachOptions ) ( GTK_EXPAND | GTK_EXPAND | GTK_FILL ) ,
2006-02-22 13:46:20 +00:00
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
gtk_button_set_alignment ( GTK_BUTTON ( check ) , 0.5 , 0 ) ;
check = gtk_check_button_new ( ) ;
2006-04-27 18:06:35 +00:00
gtk_widget_set_sensitive ( check , FALSE ) ;
2006-02-22 13:46:20 +00:00
gtk_button_set_focus_on_click ( GTK_BUTTON ( check ) , FALSE ) ;
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( check ) , mode & S_IWUSR ) ;
gtk_table_attach ( GTK_TABLE ( perm_table ) , check , 2 , 3 , 1 , 2 ,
2006-04-27 18:06:35 +00:00
( GtkAttachOptions ) ( GTK_EXPAND | GTK_FILL ) ,
2006-02-22 13:46:20 +00:00
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
gtk_button_set_alignment ( GTK_BUTTON ( check ) , 0.5 , 0 ) ;
check = gtk_check_button_new ( ) ;
2006-04-27 18:06:35 +00:00
gtk_widget_set_sensitive ( check , FALSE ) ;
2006-02-22 13:46:20 +00:00
gtk_button_set_focus_on_click ( GTK_BUTTON ( check ) , FALSE ) ;
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( check ) , mode & S_IXUSR ) ;
gtk_table_attach ( GTK_TABLE ( perm_table ) , check , 3 , 4 , 1 , 2 ,
2006-04-27 18:06:35 +00:00
( GtkAttachOptions ) ( GTK_EXPAND | GTK_FILL ) ,
2006-02-22 13:46:20 +00:00
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
gtk_button_set_alignment ( GTK_BUTTON ( check ) , 0.5 , 0 ) ;
// Group
2006-04-27 18:06:35 +00:00
label = gtk_label_new ( _ ( " Group: " ) ) ;
2006-02-22 13:46:20 +00:00
gtk_table_attach ( GTK_TABLE ( perm_table ) , label , 0 , 1 , 2 , 3 ,
2006-04-27 18:06:35 +00:00
( GtkAttachOptions ) ( GTK_EXPAND | GTK_FILL ) ,
2006-02-22 13:46:20 +00:00
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
gtk_label_set_use_markup ( GTK_LABEL ( label ) , TRUE ) ;
gtk_misc_set_alignment ( GTK_MISC ( label ) , 0.5 , 0 ) ;
check = gtk_check_button_new ( ) ;
2006-04-27 18:06:35 +00:00
gtk_widget_set_sensitive ( check , FALSE ) ;
2006-02-22 13:46:20 +00:00
gtk_button_set_focus_on_click ( GTK_BUTTON ( check ) , FALSE ) ;
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( check ) , mode & S_IRGRP ) ;
gtk_table_attach ( GTK_TABLE ( perm_table ) , check , 1 , 2 , 2 , 3 ,
2006-04-27 18:06:35 +00:00
( GtkAttachOptions ) ( GTK_EXPAND | GTK_FILL ) ,
2006-02-22 13:46:20 +00:00
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
gtk_button_set_alignment ( GTK_BUTTON ( check ) , 0.5 , 0 ) ;
check = gtk_check_button_new ( ) ;
2006-04-27 18:06:35 +00:00
gtk_widget_set_sensitive ( check , FALSE ) ;
2006-02-22 13:46:20 +00:00
gtk_button_set_focus_on_click ( GTK_BUTTON ( check ) , FALSE ) ;
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( check ) , mode & S_IWGRP ) ;
gtk_table_attach ( GTK_TABLE ( perm_table ) , check , 2 , 3 , 2 , 3 ,
2006-04-27 18:06:35 +00:00
( GtkAttachOptions ) ( GTK_EXPAND | GTK_FILL ) ,
2006-02-22 13:46:20 +00:00
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
gtk_button_set_alignment ( GTK_BUTTON ( check ) , 0.5 , 0 ) ;
check = gtk_check_button_new ( ) ;
2006-04-27 18:06:35 +00:00
gtk_widget_set_sensitive ( check , FALSE ) ;
2006-02-22 13:46:20 +00:00
gtk_button_set_focus_on_click ( GTK_BUTTON ( check ) , FALSE ) ;
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( check ) , mode & S_IXGRP ) ;
gtk_table_attach ( GTK_TABLE ( perm_table ) , check , 3 , 4 , 2 , 3 ,
2006-04-27 18:06:35 +00:00
( GtkAttachOptions ) ( GTK_EXPAND | GTK_FILL ) ,
2006-02-22 13:46:20 +00:00
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
gtk_button_set_alignment ( GTK_BUTTON ( check ) , 0.5 , 0 ) ;
// Other
2006-04-27 18:06:35 +00:00
label = gtk_label_new ( _ ( " Other: " ) ) ;
2006-02-22 13:46:20 +00:00
gtk_table_attach ( GTK_TABLE ( perm_table ) , label , 0 , 1 , 3 , 4 ,
2006-04-27 18:06:35 +00:00
( GtkAttachOptions ) ( GTK_EXPAND | GTK_FILL ) ,
2006-02-22 13:46:20 +00:00
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
gtk_label_set_use_markup ( GTK_LABEL ( label ) , TRUE ) ;
gtk_misc_set_alignment ( GTK_MISC ( label ) , 0.5 , 0 ) ;
check = gtk_check_button_new ( ) ;
2006-04-27 18:06:35 +00:00
gtk_widget_set_sensitive ( check , FALSE ) ;
2006-02-22 13:46:20 +00:00
gtk_button_set_focus_on_click ( GTK_BUTTON ( check ) , FALSE ) ;
2006-02-25 22:26:43 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( check ) , mode & S_IROTH ) ;
2006-02-22 13:46:20 +00:00
gtk_table_attach ( GTK_TABLE ( perm_table ) , check , 1 , 2 , 3 , 4 ,
2006-04-27 18:06:35 +00:00
( GtkAttachOptions ) ( GTK_EXPAND | GTK_FILL ) ,
2006-02-22 13:46:20 +00:00
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
gtk_button_set_alignment ( GTK_BUTTON ( check ) , 0.5 , 0 ) ;
check = gtk_check_button_new ( ) ;
2006-04-27 18:06:35 +00:00
gtk_widget_set_sensitive ( check , FALSE ) ;
2006-02-22 13:46:20 +00:00
gtk_button_set_focus_on_click ( GTK_BUTTON ( check ) , FALSE ) ;
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( check ) , mode & S_IWOTH ) ;
gtk_table_attach ( GTK_TABLE ( perm_table ) , check , 2 , 3 , 3 , 4 ,
2006-04-27 18:06:35 +00:00
( GtkAttachOptions ) ( GTK_EXPAND | GTK_FILL ) ,
2006-02-22 13:46:20 +00:00
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
gtk_button_set_alignment ( GTK_BUTTON ( check ) , 0.5 , 0 ) ;
check = gtk_check_button_new ( ) ;
2006-04-27 18:06:35 +00:00
gtk_widget_set_sensitive ( check , FALSE ) ;
2006-02-22 13:46:20 +00:00
gtk_button_set_focus_on_click ( GTK_BUTTON ( check ) , FALSE ) ;
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( check ) , mode & S_IXOTH ) ;
gtk_table_attach ( GTK_TABLE ( perm_table ) , check , 3 , 4 , 3 , 4 ,
2006-04-27 18:06:35 +00:00
( GtkAttachOptions ) ( GTK_EXPAND | GTK_FILL ) ,
2006-02-22 13:46:20 +00:00
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
gtk_button_set_alignment ( GTK_BUTTON ( check ) , 0.5 , 0 ) ;
gtk_container_add ( GTK_CONTAINER ( GTK_DIALOG ( dialog ) - > vbox ) , perm_table ) ;
g_free ( base_name ) ;
g_free ( time_changed ) ;
g_free ( time_modified ) ;
g_free ( time_accessed ) ;
gtk_widget_show_all ( dialog ) ;
}
2006-04-27 18:06:35 +00:00
void dialogs_show_prefs_dialog ( void )
{
if ( app - > prefs_dialog = = NULL )
{
# ifdef HAVE_VTE
GtkWidget * notebook , * vbox , * label , * alignment , * table ;
GtkWidget * font_term , * color_fore , * color_back , * spin_scrollback , * entry_emulation ;
GtkWidget * check_scroll_key , * check_scroll_out ;
GtkTooltips * tooltips ;
GtkObject * spin_scrollback_adj ;
# endif
app - > prefs_dialog = create_prefs_dialog ( ) ;
# ifdef HAVE_VTE
2006-05-22 00:25:19 +00:00
if ( app - > have_vte )
{
tooltips = GTK_TOOLTIPS ( lookup_widget ( app - > prefs_dialog , " tooltips " ) ) ;
notebook = lookup_widget ( app - > prefs_dialog , " notebook2 " ) ;
vbox = gtk_vbox_new ( FALSE , 0 ) ;
gtk_container_add ( GTK_CONTAINER ( notebook ) , vbox ) ;
label = gtk_label_new ( _ ( " These are settings for the virtual terminal emulator widget (VTE). They only apply, if the VTE library could be loaded. " ) ) ;
gtk_box_pack_start ( GTK_BOX ( vbox ) , label , FALSE , FALSE , 0 ) ;
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.14 , 0.19 ) ;
gtk_misc_set_padding ( GTK_MISC ( label ) , 0 , 8 ) ;
alignment = gtk_alignment_new ( 0.5 , 0.5 , 1 , 1 ) ;
gtk_box_pack_start ( GTK_BOX ( vbox ) , alignment , FALSE , FALSE , 0 ) ;
gtk_alignment_set_padding ( GTK_ALIGNMENT ( alignment ) , 0 , 0 , 12 , 6 ) ;
table = gtk_table_new ( 7 , 2 , FALSE ) ;
gtk_container_add ( GTK_CONTAINER ( alignment ) , table ) ;
gtk_table_set_row_spacings ( GTK_TABLE ( table ) , 3 ) ;
gtk_table_set_col_spacings ( GTK_TABLE ( table ) , 25 ) ;
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 ) ;
gtk_tooltips_set_tip ( tooltips , entry_emulation , _ ( " Controls how the terminal emulator should behave. xterm is a good start. " ) , NULL ) ;
check_scroll_key = gtk_check_button_new_with_mnemonic ( _ ( " Scroll on keystroke " ) ) ;
gtk_table_attach ( GTK_TABLE ( table ) , check_scroll_key , 1 , 2 , 5 , 6 ,
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
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 ) ;
check_scroll_out = gtk_check_button_new_with_mnemonic ( _ ( " Scroll on output " ) ) ;
gtk_table_attach ( GTK_TABLE ( table ) , check_scroll_out , 1 , 2 , 6 , 7 ,
( GtkAttachOptions ) ( GTK_FILL ) ,
( GtkAttachOptions ) ( 0 ) , 0 , 0 ) ;
gtk_tooltips_set_tip ( tooltips , check_scroll_out , _ ( " Whether to scroll to the bottom if an output was generated. " ) , NULL ) ;
gtk_button_set_focus_on_click ( GTK_BUTTON ( check_scroll_out ) , FALSE ) ;
label = gtk_label_new ( _ ( " Terminal " ) ) ;
gtk_notebook_set_tab_label ( GTK_NOTEBOOK ( notebook ) , gtk_notebook_get_nth_page (
GTK_NOTEBOOK ( notebook ) , 5 ) , label ) ;
g_object_set_data_full ( G_OBJECT ( app - > prefs_dialog ) , " font_term " ,
gtk_widget_ref ( font_term ) , ( GDestroyNotify ) gtk_widget_unref ) ;
g_object_set_data_full ( G_OBJECT ( app - > prefs_dialog ) , " color_fore " ,
gtk_widget_ref ( color_fore ) , ( GDestroyNotify ) gtk_widget_unref ) ;
g_object_set_data_full ( G_OBJECT ( app - > prefs_dialog ) , " color_back " ,
gtk_widget_ref ( color_back ) , ( GDestroyNotify ) gtk_widget_unref ) ;
g_object_set_data_full ( G_OBJECT ( app - > prefs_dialog ) , " spin_scrollback " ,
gtk_widget_ref ( spin_scrollback ) , ( GDestroyNotify ) gtk_widget_unref ) ;
g_object_set_data_full ( G_OBJECT ( app - > prefs_dialog ) , " entry_emulation " ,
gtk_widget_ref ( entry_emulation ) , ( GDestroyNotify ) gtk_widget_unref ) ;
g_object_set_data_full ( G_OBJECT ( app - > prefs_dialog ) , " check_scroll_key " ,
gtk_widget_ref ( check_scroll_key ) , ( GDestroyNotify ) gtk_widget_unref ) ;
g_object_set_data_full ( G_OBJECT ( app - > prefs_dialog ) , " check_scroll_out " ,
gtk_widget_ref ( check_scroll_out ) , ( GDestroyNotify ) gtk_widget_unref ) ;
gtk_widget_show_all ( vbox ) ;
g_signal_connect ( ( gpointer ) lookup_widget ( app - > prefs_dialog , " font_term " ) ,
" font-set " , G_CALLBACK ( on_prefs_font_choosed ) , GINT_TO_POINTER ( 4 ) ) ;
g_signal_connect ( ( gpointer ) lookup_widget ( app - > prefs_dialog , " color_fore " ) ,
" color-set " , G_CALLBACK ( on_prefs_color_choosed ) , GINT_TO_POINTER ( 2 ) ) ;
g_signal_connect ( ( gpointer ) lookup_widget ( app - > prefs_dialog , " color_back " ) ,
" color-set " , G_CALLBACK ( on_prefs_color_choosed ) , GINT_TO_POINTER ( 3 ) ) ;
}
2006-04-27 18:06:35 +00:00
# endif
g_signal_connect ( ( gpointer ) app - > prefs_dialog , " response " , G_CALLBACK ( on_prefs_button_clicked ) , NULL ) ;
g_signal_connect ( ( gpointer ) app - > prefs_dialog , " delete_event " , G_CALLBACK ( on_prefs_delete_event ) , NULL ) ;
g_signal_connect ( ( gpointer ) lookup_widget ( app - > prefs_dialog , " tagbar_font " ) ,
" font-set " , G_CALLBACK ( on_prefs_font_choosed ) , GINT_TO_POINTER ( 1 ) ) ;
g_signal_connect ( ( gpointer ) lookup_widget ( app - > prefs_dialog , " msgwin_font " ) ,
" font-set " , G_CALLBACK ( on_prefs_font_choosed ) , GINT_TO_POINTER ( 2 ) ) ;
g_signal_connect ( ( gpointer ) lookup_widget ( app - > prefs_dialog , " editor_font " ) ,
" font-set " , G_CALLBACK ( on_prefs_font_choosed ) , GINT_TO_POINTER ( 3 ) ) ;
g_signal_connect ( ( gpointer ) lookup_widget ( app - > prefs_dialog , " long_line_color " ) ,
" color-set " , G_CALLBACK ( on_prefs_color_choosed ) , GINT_TO_POINTER ( 1 ) ) ;
// file chooser buttons in the tools tab
g_signal_connect ( ( gpointer ) lookup_widget ( app - > prefs_dialog , " button_make " ) ,
" clicked " , G_CALLBACK ( on_pref_tools_button_clicked ) , lookup_widget ( app - > prefs_dialog , " entry_com_make " ) ) ;
g_signal_connect ( ( gpointer ) lookup_widget ( app - > prefs_dialog , " button_term " ) ,
" clicked " , G_CALLBACK ( on_pref_tools_button_clicked ) , lookup_widget ( app - > prefs_dialog , " entry_com_term " ) ) ;
g_signal_connect ( ( gpointer ) lookup_widget ( app - > prefs_dialog , " button_browser " ) ,
" clicked " , G_CALLBACK ( on_pref_tools_button_clicked ) , lookup_widget ( app - > prefs_dialog , " entry_browser " ) ) ;
}
prefs_init_dialog ( ) ;
gtk_widget_show ( app - > prefs_dialog ) ;
}
gboolean dialogs_show_question ( const gchar * text , . . . )
{
# ifndef GEANY_WIN32
GtkWidget * dialog ;
# endif
gchar * string = g_malloc ( 512 ) ;
gboolean ret = FALSE ;
va_list args ;
va_start ( args , text ) ;
g_vsnprintf ( string , 511 , text , args ) ;
va_end ( args ) ;
# ifdef GEANY_WIN32
if ( MessageBox ( NULL , string , _ ( " Question " ) , MB_YESNO | MB_ICONWARNING ) = = IDYES ) return TRUE ;
else return FALSE ;
# else
dialog = gtk_message_dialog_new ( NULL , GTK_DIALOG_DESTROY_WITH_PARENT ,
GTK_MESSAGE_QUESTION , GTK_BUTTONS_YES_NO , string ) ;
if ( gtk_dialog_run ( GTK_DIALOG ( dialog ) ) = = GTK_RESPONSE_YES ) ret = TRUE ;
gtk_widget_destroy ( dialog ) ;
# endif
g_free ( string ) ;
2006-05-14 16:07:30 +00:00
2006-04-27 18:06:35 +00:00
return ret ;
}