44#include <gdk/gdkkeysyms.h>
52#ifdef HAVE_SYS_TYPES_H
53# include <sys/types.h>
57#include <glib/gstdio.h>
96 GtkFileFilter *current;
97 GSList *filters, *item;
99 current = gtk_file_chooser_get_filter(chooser);
100 filters = gtk_file_chooser_list_filters(chooser);
103 if (item->data == current)
107 g_slist_free(filters);
115 GtkFileFilter *current;
118 filters = gtk_file_chooser_list_filters(chooser);
119 current = g_slist_nth_data(filters, idx);
120 g_slist_free(filters);
121 gtk_file_chooser_set_filter(chooser, current);
133 const gchar *charset =
NULL;
151 filelist = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(
dialog));
152 if (filelist !=
NULL)
154 const gchar *first = filelist->data;
157 if (!filelist->next && !g_file_test(first, G_FILE_TEST_EXISTS))
166 g_slist_foreach(filelist, (GFunc) g_free,
NULL);
168 g_slist_free(filelist);
171 gtk_file_chooser_remove_shortcut_folder(GTK_FILE_CHOOSER(
dialog),
178 GParamSpec *pspec, gpointer data)
180 GtkWidget *toggle_button;
184 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle_button),
185 gtk_file_chooser_get_show_hidden(GTK_FILE_CHOOSER(filechooser)));
198 GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data)
200 gboolean sensitive = !gtk_tree_model_iter_has_child(tree_model, iter);
203 gtk_tree_model_get(tree_model, iter, 1, &
text, -1);
204 g_object_set(cell,
"sensitive", sensitive,
"text",
text,
NULL);
212 GtkTreeIter iter_compiled, iter_script, iter_markup, iter_misc, iter_detect;
213 GtkTreeIter *iter_parent;
215 GtkCellRenderer *renderer;
218 store = gtk_tree_store_new(2, G_TYPE_INT, G_TYPE_STRING);
220 gtk_tree_store_insert_with_values(store, &iter_detect,
NULL, -1,
221 0, -1 , 1,
_(
"Detect from file"), -1);
223 gtk_tree_store_insert_with_values(store, &iter_compiled,
NULL, -1,
224 0, -1, 1,
_(
"Programming Languages"), -1);
225 gtk_tree_store_insert_with_values(store, &iter_script,
NULL, -1,
226 0, -1, 1,
_(
"Scripting Languages"), -1);
227 gtk_tree_store_insert_with_values(store, &iter_markup,
NULL, -1,
228 0, -1, 1,
_(
"Markup Languages"), -1);
229 gtk_tree_store_insert_with_values(store, &iter_misc,
NULL, -1,
230 0, -1, 1,
_(
"Miscellaneous"), -1);
243 default: iter_parent =
NULL;
245 gtk_tree_store_insert_with_values(store,
NULL, iter_parent, -1,
246 0, (gint) ft->
id, 1, ft->
title, -1);
249 combo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store));
250 gtk_combo_box_set_active_iter(GTK_COMBO_BOX(combo), &iter_detect);
251 renderer = gtk_cell_renderer_text_new();
252 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), renderer, TRUE);
253 gtk_cell_layout_set_cell_data_func(GTK_CELL_LAYOUT(combo), renderer,
256 g_object_unref(store);
268 if (gtk_combo_box_get_active_iter(combo, &iter))
270 GtkTreeModel *model = gtk_combo_box_get_model(combo);
271 gtk_tree_model_get(model, &iter, 0, &
id, -1);
279 GtkTreeModel *model = gtk_combo_box_get_model(combo);
282 if (gtk_tree_model_get_iter_first(model, &iter))
287 gtk_tree_model_get(model, &iter, 0, &row_id, -1);
290 gtk_combo_box_set_active_iter(combo, &iter);
303 GtkWidget *filetype_ebox, *filetype_label, *filetype_combo;
306 expander = gtk_expander_new_with_mnemonic(
_(
"_More Options"));
307 vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 6);
310 table = gtk_table_new(2, 4, FALSE);
313 check_hidden = gtk_check_button_new_with_mnemonic(
_(
"Show _hidden files"));
315 gtk_table_attach(GTK_TABLE(table),
check_hidden, 0, 1, 0, 1,
316 (GtkAttachOptions) (GTK_FILL | GTK_EXPAND),
317 (GtkAttachOptions) (0), 0, 5);
320 gtk_table_attach(GTK_TABLE(table), gtk_label_new(
""), 1, 2, 0, 1,
321 (GtkAttachOptions) (GTK_FILL),
322 (GtkAttachOptions) (0), 5, 5);
324 encoding_label = gtk_label_new(
_(
"Set encoding:"));
325 gtk_misc_set_alignment(GTK_MISC(encoding_label), 1, 0);
326 gtk_table_attach(GTK_TABLE(table), encoding_label, 2, 3, 0, 1,
327 (GtkAttachOptions) (GTK_FILL),
328 (GtkAttachOptions) (0), 4, 5);
330 encoding_ebox = gtk_event_box_new();
332 gtk_widget_set_tooltip_text(encoding_ebox,
333 _(
"Explicitly defines an encoding for the file, if it would not be detected. This is useful when you know that the encoding of a file cannot be detected correctly by Geany.\nNote if you choose multiple files, they will all be opened with the chosen encoding."));
335 gtk_table_attach(GTK_TABLE(table), encoding_ebox, 3, 4, 0, 1,
336 (GtkAttachOptions) (GTK_FILL),
337 (GtkAttachOptions) (0), 0, 5);
340 filetype_label = gtk_label_new(
_(
"Set filetype:"));
341 gtk_misc_set_alignment(GTK_MISC(filetype_label), 1, 0);
342 gtk_table_attach(GTK_TABLE(table), filetype_label, 2, 3, 1, 2,
343 (GtkAttachOptions) (GTK_FILL),
344 (GtkAttachOptions) (0), 4, 5);
346 filetype_ebox = gtk_event_box_new();
348 gtk_widget_set_tooltip_text(filetype_ebox,
349 _(
"Explicitly defines a filetype for the file, if it would not be detected by filename extension.\nNote if you choose multiple files, they will all be opened with the chosen filetype."));
351 gtk_table_attach(GTK_TABLE(table), filetype_ebox, 3, 4, 1, 2,
352 (GtkAttachOptions) (GTK_FILL),
353 (GtkAttachOptions) (0), 0, 5);
355 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
376 GTK_FILE_CHOOSER_ACTION_OPEN,
NULL,
NULL);
377 gtk_widget_set_name(
dialog,
"GeanyDialog");
380 gtk_widget_set_tooltip_text(viewbtn,
381 _(
"Opens the file in read-only mode. If you choose more than one file to open, all files will be opened read-only."));
383 gtk_dialog_add_buttons(GTK_DIALOG(
dialog),
384 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
385 GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
NULL);
386 gtk_dialog_set_default_response(GTK_DIALOG(
dialog), GTK_RESPONSE_ACCEPT);
388 gtk_widget_set_size_request(
dialog, -1, 460);
389 gtk_window_set_modal(GTK_WINDOW(
dialog), TRUE);
390 gtk_window_set_destroy_with_parent(GTK_WINDOW(
dialog), TRUE);
391 gtk_window_set_skip_taskbar_hint(GTK_WINDOW(
dialog), FALSE);
392 gtk_window_set_type_hint(GTK_WINDOW(
dialog), GDK_WINDOW_TYPE_HINT_DIALOG);
394 gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(
dialog), TRUE);
395 gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(
dialog), FALSE);
401 gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(
dialog),
404 gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(
dialog),
415 g_signal_connect(
dialog,
"notify::show-hidden",
424 static gboolean initialized = FALSE;
473 if (initdir !=
NULL && g_path_is_absolute(initdir))
474 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(
dialog), initdir);
477 gtk_file_chooser_add_shortcut_folder(GTK_FILE_CHOOSER(
dialog),
481 gtk_dialog_run(GTK_DIALOG(
dialog))));
482 gtk_widget_destroy(
dialog);
491 gboolean success = FALSE;
493 g_return_val_if_fail(doc !=
NULL, FALSE);
494 g_return_val_if_fail(!
EMPTY(utf8_filename), FALSE);
519 gboolean rename_file = FALSE;
520 gboolean success = FALSE;
521 gchar *new_filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(
dialog));
527 if (G_UNLIKELY(
EMPTY(new_filename)))
532 if (g_file_test(new_filename, G_FILE_TEST_EXISTS) &&
535 _(
"Filename already exists!")))
539 case GTK_RESPONSE_ACCEPT:
541 gchar *utf8_filename;
545 g_free(utf8_filename);
548 case GTK_RESPONSE_DELETE_EVENT:
549 case GTK_RESPONSE_CANCEL:
553 g_free(new_filename);
561 GtkWidget *
dialog, *rename_btn;
562 const gchar *initdir;
565 GTK_FILE_CHOOSER_ACTION_SAVE,
NULL,
NULL);
566 gtk_window_set_modal(GTK_WINDOW(
dialog), TRUE);
567 gtk_window_set_destroy_with_parent(GTK_WINDOW(
dialog), TRUE);
568 gtk_window_set_skip_taskbar_hint(GTK_WINDOW(
dialog), FALSE);
569 gtk_window_set_type_hint(GTK_WINDOW(
dialog), GDK_WINDOW_TYPE_HINT_DIALOG);
571 gtk_widget_set_name(
dialog,
"GeanyDialog");
574 gtk_widget_set_tooltip_text(rename_btn,
_(
"Save the file and rename it"));
576 gtk_widget_set_sensitive(rename_btn, doc->
real_path !=
NULL);
578 gtk_dialog_add_buttons(GTK_DIALOG(
dialog),
579 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
580 GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
NULL);
581 gtk_dialog_set_default_response(GTK_DIALOG(
dialog), GTK_RESPONSE_ACCEPT);
583 gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(
dialog), TRUE);
584 gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(
dialog), FALSE);
591 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(
dialog), linitdir);
603 g_return_val_if_fail(
DOC_VALID(doc), FALSE);
612 gchar *locale_basename = g_path_get_basename(locale_filename);
613 gchar *locale_dirname = g_path_get_dirname(locale_filename);
615 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(
dialog), locale_dirname);
616 gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(
dialog), locale_basename);
618 g_free(locale_filename);
619 g_free(locale_basename);
620 g_free(locale_dirname);
623 gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(
dialog), doc->
file_name);
635 gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(
dialog), fname);
641 gtk_file_chooser_add_shortcut_folder(GTK_FILE_CHOOSER(
dialog),
647 resp = gtk_dialog_run(GTK_DIALOG(
dialog));
652 gtk_file_chooser_remove_shortcut_folder(GTK_FILE_CHOOSER(
dialog),
655 gtk_widget_destroy(
dialog);
657 return (resp == GTK_RESPONSE_ACCEPT);
670 gboolean result = FALSE;
672 g_return_val_if_fail(doc, FALSE);
677 gchar *utf8_name = win32_show_document_save_as_dialog(GTK_WINDOW(
main_widgets.
window),
678 _(
"Save File"), doc);
679 if (utf8_name !=
NULL)
695 case GTK_MESSAGE_ERROR:
698 case GTK_MESSAGE_QUESTION:
699 title =
_(
"Question");
701 case GTK_MESSAGE_WARNING:
702 title =
_(
"Warning");
705 title =
_(
"Information");
708 gtk_window_set_title(GTK_WINDOW(
dialog), title);
709 gtk_window_set_icon_name(GTK_WINDOW(
dialog),
"geany");
710 gtk_widget_set_name(
dialog,
"GeanyDialog");
712 gtk_dialog_run(GTK_DIALOG(
dialog));
713 gtk_widget_destroy(
dialog);
738 va_start(args,
text);
739 string = g_strdup_vprintf(
text, args);
743 win32_message_dialog(GTK_WIDGET(parent), type,
string);
745 dialog = gtk_message_dialog_new(parent, GTK_DIALOG_DESTROY_WITH_PARENT,
746 type, GTK_BUTTONS_OK,
"%s",
string);
758 gchar *
string = g_strconcat(
text,
"\n", secondary,
NULL);
759 win32_message_dialog(GTK_WIDGET(parent), type,
string);
763 dialog = gtk_message_dialog_new(parent, GTK_DIALOG_DESTROY_WITH_PARENT,
764 type, GTK_BUTTONS_OK,
"%s",
text);
765 gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(
dialog),
"%s", secondary);
773 GtkWidget *
dialog, *button;
777 GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE,
"%s", msg);
778 gtk_window_set_title(GTK_WINDOW(
dialog),
_(
"Question"));
779 gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(
dialog),
"%s", msg2);
780 gtk_dialog_add_button(GTK_DIALOG(
dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
783 gtk_dialog_add_action_widget(GTK_DIALOG(
dialog), button, GTK_RESPONSE_NO);
784 gtk_widget_show(button);
786 gtk_dialog_add_button(GTK_DIALOG(
dialog), GTK_STOCK_SAVE, GTK_RESPONSE_YES);
788 gtk_dialog_set_default_response(GTK_DIALOG(
dialog), GTK_RESPONSE_YES);
789 ret = gtk_dialog_run(GTK_DIALOG(
dialog));
791 gtk_widget_destroy(
dialog);
799 gchar *msg, *short_fn =
NULL;
802 gboolean old_quitting_state =
main_status.quitting;
811 msg = g_strdup_printf(
_(
"The file '%s' is not saved."), short_fn);
812 msg2 =
_(
"Do you want to save it before closing?");
820 case GTK_RESPONSE_YES:
824 case GTK_RESPONSE_NO:
827 case GTK_RESPONSE_CANCEL:
836#if GTK_CHECK_VERSION(3, 2, 0)
837# undef GTK_FONT_SELECTION_DIALOG
838# define GTK_FONT_SELECTION_DIALOG GTK_FONT_CHOOSER_DIALOG
840# define gtk_font_selection_dialog_new(title) \
841 gtk_font_chooser_dialog_new((title), NULL)
842# define gtk_font_selection_dialog_get_font_name(dlg) \
843 gtk_font_chooser_get_font(GTK_FONT_CHOOSER(dlg))
844# define gtk_font_selection_dialog_set_font_name(dlg, font) \
845 gtk_font_chooser_set_font(GTK_FONT_CHOOSER(dlg), (font))
851 gboolean
close = TRUE;
855 case GTK_RESPONSE_APPLY:
856 case GTK_RESPONSE_OK:
860 fontname = gtk_font_selection_dialog_get_font_name(
861 GTK_FONT_SELECTION_DIALOG(
ui_widgets.open_fontsel));
865 close = (response == GTK_RESPONSE_OK);
881 win32_show_font_dialog();
888 GtkWidget *apply_button;
890 ui_widgets.open_fontsel = gtk_font_selection_dialog_new(
_(
"Choose font"));;
891 gtk_container_set_border_width(GTK_CONTAINER(
ui_widgets.open_fontsel), 4);
892 gtk_window_set_modal(GTK_WINDOW(
ui_widgets.open_fontsel), TRUE);
893 gtk_window_set_destroy_with_parent(GTK_WINDOW(
ui_widgets.open_fontsel), TRUE);
894 gtk_window_set_skip_taskbar_hint(GTK_WINDOW(
ui_widgets.open_fontsel), TRUE);
895 gtk_window_set_type_hint(GTK_WINDOW(
ui_widgets.open_fontsel), GDK_WINDOW_TYPE_HINT_DIALOG);
896 gtk_widget_set_name(
ui_widgets.open_fontsel,
"GeanyDialog");
898 apply_button = gtk_dialog_get_widget_for_response(GTK_DIALOG(
ui_widgets.open_fontsel), GTK_RESPONSE_APPLY);
901 gtk_widget_show(apply_button);
904 "delete-event", G_CALLBACK(gtk_widget_hide_on_delete),
NULL);
910 gtk_font_selection_dialog_set_font_name(
913 gtk_window_present(GTK_WINDOW(
ui_widgets.open_fontsel));
920 gtk_widget_grab_focus(
entry);
927 gtk_dialog_response(
dialog, GTK_RESPONSE_ACCEPT);
934 gtk_dialog_response(
dialog, GTK_RESPONSE_ACCEPT);
952 if (response == GTK_RESPONSE_ACCEPT)
954 const gchar *str = gtk_entry_get_text(GTK_ENTRY(data->
entry));
961 gtk_widget_hide(GTK_WIDGET(
dialog));
972 const gchar *label_text,
const gchar *default_text,
973 gboolean persistent, GeanyInputCallback input_cb, gpointer input_cb_data,
974 GCallback insert_text_cb, gpointer insert_text_cb_data)
979 dialog = gtk_dialog_new_with_buttons(title, parent,
980 GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
981 GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
NULL);
983 gtk_widget_set_name(
dialog,
"GeanyDialog");
984 gtk_box_set_spacing(GTK_BOX(vbox), 6);
989 data->
data = input_cb_data;
993 GtkWidget *
label = gtk_label_new(label_text);
994 gtk_label_set_line_wrap(GTK_LABEL(
label), TRUE);
995 gtk_misc_set_alignment(GTK_MISC(
label), 0, 0.5);
1001 data->
combo = gtk_combo_box_text_new_with_entry();
1002 data->
entry = gtk_bin_get_child(GTK_BIN(data->
combo));
1008 data->
entry = gtk_entry_new();
1013 if (default_text !=
NULL)
1015 gtk_entry_set_text(GTK_ENTRY(data->
entry), default_text);
1017 gtk_entry_set_max_length(GTK_ENTRY(data->
entry), 255);
1018 gtk_entry_set_width_chars(GTK_ENTRY(data->
entry), 30);
1020 if (insert_text_cb !=
NULL)
1021 g_signal_connect(data->
entry,
"insert-text", insert_text_cb, insert_text_cb_data);
1029 g_signal_connect(
dialog,
"delete-event", G_CALLBACK(gtk_widget_hide_on_delete),
NULL);
1034 gtk_dialog_run(GTK_DIALOG(
dialog));
1035 gtk_widget_destroy(
dialog);
1044 const gchar *label_text,
const gchar *default_text,
1045 GeanyInputCallback input_cb, gpointer input_cb_data)
1053 gchar **dialog_input = data;
1054 *dialog_input = g_strdup(str);
1068 const gchar *default_text)
1070 gchar *dialog_input =
NULL;
1072 return dialog_input;
1080 const gchar *default_text)
1082 gchar *dialog_input =
NULL;
1084 title, parent, label_text, default_text, FALSE,
on_dialog_input, &dialog_input,
1086 return dialog_input;
1109 gdouble *value, gdouble min, gdouble
max, gdouble step)
1112 gboolean res = FALSE;
1114 g_return_val_if_fail(title !=
NULL, FALSE);
1115 g_return_val_if_fail(label_text !=
NULL, FALSE);
1116 g_return_val_if_fail(value !=
NULL, FALSE);
1119 GTK_DIALOG_DESTROY_WITH_PARENT,
1120 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
1121 GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
NULL);
1122 gtk_dialog_set_default_response(GTK_DIALOG(
dialog), GTK_RESPONSE_CANCEL);
1124 gtk_widget_set_name(
dialog,
"GeanyDialog");
1126 label = gtk_label_new(label_text);
1127 gtk_misc_set_alignment(GTK_MISC(
label), 0, 0.5);
1129 spin = gtk_spin_button_new_with_range(min,
max, step);
1131 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin), *value);
1138 if (gtk_dialog_run(GTK_DIALOG(
dialog)) == GTK_RESPONSE_ACCEPT)
1140 *value = gtk_spin_button_get_value(GTK_SPIN_BUTTON(spin));
1143 gtk_widget_destroy(
dialog);
1152 gchar *file_size, *title, *base_name, *time_changed, *time_modified, *time_accessed, *enctext;
1154#ifdef HAVE_SYS_TYPES_H
1158 gchar *locale_filename;
1184 _(
"An error occurred or file information could not be retrieved (e.g. from a new file)."));
1189#ifdef HAVE_SYS_TYPES_H
1191 if (g_stat(locale_filename, &st) == 0)
1195 time_changed = g_strchomp(g_strdup(ctime(&st.st_ctime)));
1196 time_modified = g_strchomp(g_strdup(ctime(&st.st_mtime)));
1197 time_accessed = g_strchomp(g_strdup(ctime(&st.st_atime)));
1198 filesize = st.st_size;
1203 time_changed = g_strdup(
_(
"unknown"));
1204 time_modified = g_strdup(
_(
"unknown"));
1205 time_accessed = g_strdup(
_(
"unknown"));
1206 filesize = (off_t) 0;
1209 g_free(locale_filename);
1211 time_changed = g_strdup(
_(
"unknown"));
1212 time_modified = g_strdup(
_(
"unknown"));
1213 time_accessed = g_strdup(
_(
"unknown"));
1216 base_name = g_path_get_basename(doc->
file_name);
1218 title = g_strdup_printf(
_(
"%s Properties"), short_name);
1220 gtk_window_set_title(GTK_WINDOW(
dialog), title);
1223 gtk_widget_set_name(
dialog,
"GeanyDialog");
1226 gtk_label_set_text(GTK_LABEL(
label), base_name);
1229 gtk_image_set_from_gicon(GTK_IMAGE(image), doc->
file_type->
icon,
1230 GTK_ICON_SIZE_BUTTON);
1237 gtk_label_set_text(GTK_LABEL(
label), file_size);
1244 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check), doc->
readonly);
1247 enctext = g_strdup_printf(
"%s %s",
1250 ((doc->
has_bom) ?
_(
"(with BOM)") :
_(
"(without BOM)")) :
"");
1251 gtk_label_set_text(GTK_LABEL(
label), enctext);
1255 gtk_label_set_text(GTK_LABEL(
label), time_modified);
1257 gtk_label_set_text(GTK_LABEL(
label), time_changed);
1259 gtk_label_set_text(GTK_LABEL(
label), time_accessed);
1263 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check), mode &
S_IRUSR);
1265 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check), mode &
S_IWUSR);
1267 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check), mode &
S_IXUSR);
1269 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check), mode &
S_IRGRP);
1271 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check), mode &
S_IWGRP);
1273 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check), mode &
S_IXGRP);
1275 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check), mode &
S_IROTH);
1277 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check), mode &
S_IWOTH);
1279 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check), mode &
S_IXOTH);
1282 g_free(time_changed);
1283 g_free(time_modified);
1284 g_free(time_accessed);
1295 const gchar *btn_1, GtkResponseType response_1,
1296 const gchar *btn_2, GtkResponseType response_2,
1297 const gchar *btn_3, GtkResponseType response_3,
1298 const gchar *question_text,
const gchar *extra_text)
1300 gboolean ret = FALSE;
1306 btn_2 = GTK_STOCK_NO;
1307 response_2 = GTK_RESPONSE_NO;
1311 btn_3 = GTK_STOCK_YES;
1312 response_3 = GTK_RESPONSE_YES;
1320 gchar *
string = (extra_text ==
NULL) ? g_strdup(question_text) :
1321 g_strconcat(question_text,
"\n\n", extra_text,
NULL);
1323 ret = win32_message_dialog(parent, GTK_MESSAGE_QUESTION,
string);
1324 ret = ret ? response_3 : response_2;
1332 dialog = gtk_message_dialog_new(GTK_WINDOW(parent),
1333 GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION,
1334 GTK_BUTTONS_NONE,
"%s", question_text);
1335 gtk_widget_set_name(
dialog,
"GeanyDialog");
1336 gtk_window_set_title(GTK_WINDOW(
dialog),
_(
"Question"));
1337 gtk_window_set_icon_name(GTK_WINDOW(
dialog),
"geany");
1340 if (extra_text !=
NULL)
1341 gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(
dialog),
1345 gtk_dialog_add_button(GTK_DIALOG(
dialog), btn_1, response_1);
1347 btn = gtk_dialog_add_button(GTK_DIALOG(
dialog), btn_2, response_2);
1349 gtk_widget_grab_default(btn);
1350 gtk_dialog_add_button(GTK_DIALOG(
dialog), btn_3, response_3);
1352 ret = gtk_dialog_run(GTK_DIALOG(
dialog));
1353 gtk_widget_destroy(
dialog);
1377 va_start(args,
text);
1378 string = g_strdup_vprintf(
text, args);
1381 NULL, GTK_RESPONSE_NONE,
1382 GTK_STOCK_NO, GTK_RESPONSE_NO,
1383 GTK_STOCK_YES, GTK_RESPONSE_YES,
1386 return (result == GTK_RESPONSE_YES);
1394 const gchar *extra_text,
const gchar *main_text, ...)
1400 va_start(args, main_text);
1401 string = g_strdup_vprintf(main_text, args);
1404 NULL, GTK_RESPONSE_NONE,
1405 no_btn, GTK_RESPONSE_NO,
1406 yes_btn, GTK_RESPONSE_YES,
1407 string, extra_text);
1409 return (result == GTK_RESPONSE_YES);
1418 const gchar *btn_1, GtkResponseType response_1,
1419 const gchar *btn_2, GtkResponseType response_2,
1420 const gchar *btn_3, GtkResponseType response_3,
1421 const gchar *extra_text,
const gchar *main_text, ...)
1427 va_start(args, main_text);
1428 string = g_strdup_vprintf(main_text, args);
1430 result =
show_prompt(parent, btn_1, response_1, btn_2, response_2, btn_3, response_3,
1431 string, extra_text);
void build_menu_update(GeanyDocument *doc)
Interface to the Build menu functionality.
static void show_msgbox_dialog(GtkWidget *dialog, GtkMessageType type, GtkWindow *parent)
static guint file_chooser_get_filter_idx(GtkFileChooser *chooser)
static gboolean show_save_as_gtk(GeanyDocument *doc)
gboolean dialogs_show_question_full(GtkWidget *parent, const gchar *yes_btn, const gchar *no_btn, const gchar *extra_text, const gchar *main_text,...)
static gint show_prompt(GtkWidget *parent, const gchar *btn_1, GtkResponseType response_1, const gchar *btn_2, GtkResponseType response_2, const gchar *btn_3, GtkResponseType response_3, const gchar *question_text, const gchar *extra_text)
gboolean dialogs_show_save_as(void)
Shows the Save As dialog for the current notebook page.
static gint filetype_combo_box_get_active_filetype(GtkComboBox *combo)
static void file_chooser_set_filter_idx(GtkFileChooser *chooser, guint idx)
static GtkWidget * create_filetype_combo_box(void)
static GtkWidget * dialogs_show_input_full(const gchar *title, GtkWindow *parent, const gchar *label_text, const gchar *default_text, gboolean persistent, GeanyInputCallback input_cb, gpointer input_cb_data, GCallback insert_text_cb, gpointer insert_text_cb_data)
void dialogs_show_file_properties(GeanyDocument *doc)
static GtkWidget * create_save_file_dialog(GeanyDocument *doc)
static GtkWidget * add_file_open_extra_widget(GtkWidget *dialog)
GtkWidget * dialogs_show_input_persistent(const gchar *title, GtkWindow *parent, const gchar *label_text, const gchar *default_text, GeanyInputCallback input_cb, gpointer input_cb_data)
static void open_file_dialog_apply_settings(GtkWidget *dialog)
gboolean dialogs_show_question(const gchar *text,...)
Shows a question message box with text and Yes/No buttons.
static struct FileSelState filesel_state
gint dialogs_show_prompt(GtkWidget *parent, const gchar *btn_1, GtkResponseType response_1, const gchar *btn_2, GtkResponseType response_2, const gchar *btn_3, GtkResponseType response_3, const gchar *extra_text, const gchar *main_text,...)
static gint run_unsaved_dialog(const gchar *msg, const gchar *msg2)
static void on_file_open_show_hidden_notify(GObject *filechooser, GParamSpec *pspec, gpointer data)
void dialogs_show_open_file(void)
static void filetype_combo_cell_data_func(GtkCellLayout *cell_layout, GtkCellRenderer *cell, GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data)
static void on_input_dialog_response(GtkDialog *dialog, gint response, InputDialogData *data)
static void on_dialog_input(const gchar *str, gpointer data)
static gboolean handle_save_as(const gchar *utf8_filename, gboolean rename_file)
static void on_input_entry_activate(GtkEntry *entry, GtkDialog *dialog)
static void on_input_dialog_show(GtkDialog *dialog, GtkWidget *entry)
gboolean dialogs_show_input_numeric(const gchar *title, const gchar *label_text, gdouble *value, gdouble min, gdouble max, gdouble step)
Shows an input box to enter a numerical value using a GtkSpinButton.
gchar * dialogs_show_input_goto_line(const gchar *title, GtkWindow *parent, const gchar *label_text, const gchar *default_text)
gchar * dialogs_show_input(const gchar *title, GtkWindow *parent, const gchar *label_text, const gchar *default_text)
Asks the user for text input.
static void on_file_open_check_hidden_toggled(GtkToggleButton *togglebutton, GtkWidget *dialog)
gboolean dialogs_show_unsaved_file(GeanyDocument *doc)
static gboolean filetype_combo_box_set_active_filetype(GtkComboBox *combo, const gint id)
static gboolean save_as_dialog_handle_response(GtkWidget *dialog, gint response)
void dialogs_show_open_font(void)
static void on_font_dialog_response(GtkDialog *dialog, gint response, gpointer user_data)
static GtkWidget * create_open_file_dialog(void)
static void on_input_numeric_activate(GtkEntry *entry, GtkDialog *dialog)
static gboolean open_file_dialog_handle_response(GtkWidget *dialog, gint response)
void dialogs_show_msgbox(GtkMessageType type, const gchar *text,...)
Shows a message box of the type type with text.
void dialogs_show_msgbox_with_secondary(GtkMessageType type, const gchar *text, const gchar *secondary)
File related dialogs, miscellaneous dialogs, font dialog.
GeanyDocument * document_get_current(void)
Finds the current document.
gboolean document_save_file_as(GeanyDocument *doc, const gchar *utf8_fname)
Saves the document, detecting the filetype.
void document_show_tab(GeanyDocument *doc)
gboolean document_save_file(GeanyDocument *doc, gboolean force)
Saves the document.
void document_rename_file(GeanyDocument *doc, const gchar *new_filename)
Renames the file in doc to new_filename.
void document_open_files(const GSList *filenames, gboolean readonly, GeanyFiletype *ft, const gchar *forced_enc)
Opens each file in the list filenames.
gchar * document_get_basename_for_display(GeanyDocument *doc, gint length)
Returns the last part of the filename of the given GeanyDocument.
Document related actions: new, save, open, etc.
#define DOC_VALID(doc_ptr)
Null-safe way to check GeanyDocument::is_valid.
GeanyEncoding encodings[GEANY_ENCODINGS_MAX]
gboolean encodings_is_unicode_charset(const gchar *string)
Encoding conversion and Byte Order Mark (BOM) handling.
static gboolean check_hidden(const gchar *filename, const gchar *base_name)
Filetype detection, file extensions and filetype menu items.
#define filetypes
Wraps GeanyData::filetypes_array so it can be used with C array syntax.
@ GEANY_FILETYPE_GROUP_MISC
@ GEANY_FILETYPE_GROUP_MARKUP
@ GEANY_FILETYPE_GROUP_SCRIPT
@ GEANY_FILETYPE_GROUP_NONE
@ GEANY_FILETYPE_GROUP_COMPILED
#define GEANY_STRING_UNTITLED
Main program-related commands.
GtkWidget * encoding_combo
GeanyFiletype * filetypes_index(gint idx)
Accessor function for GeanyData::filetypes_array items.
GSList * filetypes_by_title
GtkFileFilter * filetypes_create_file_filter(const GeanyFiletype *ft)
GtkFileFilter * filetypes_create_file_filter_all_source(void)
gtk_container_add(GTK_CONTAINER(dialog->vbox), check_button)
ui_hookup_widget(dialog, check_button, "check_handle")
gtk_widget_show_all(dialog)
struct FileSelState::@83 open
gboolean more_options_visible
struct GeanyProject * project
Currently active project or NULL if none is open.
Structure for representing an open tab with all its properties.
gchar * file_name
The UTF-8 encoded file name.
GeanyFiletype * file_type
The filetype for this document, it's only a reference to one of the elements of the global filetypes ...
gboolean has_bom
Internally used flag to indicate whether the file of this document has a byte-order-mark.
gchar * real_path
The link-dereferenced, locale-encoded file name.
gchar * encoding
The encoding of the document, must be a valid string representation of an encoding,...
gboolean readonly
Whether this document is read-only.
gboolean is_valid
Flag used to check if this document is valid when iterating GeanyData::documents_array.
TMSourceFile * tm_file
TMSourceFile object for this document, or NULL.
GeanyFiletypeID id
Index in filetypes.
GeanyFiletypeGroupID group
gchar * title
Shown in the file open dialog, such as "C source file".
gchar * extension
Default file extension for new files, or NULL.
gboolean use_native_windows_dialogs
whether to use native Windows' dialogs (only used on Windows)
gchar * editor_font
editor font
GtkWidget * window
Main window.
gchar * base_path
Base path of the project directory (in UTF-8, maybe relative).
Defines internationalization macros.
#define C_(Context, String)
void tm_source_file_free(TMSourceFile *source_file)
Decrements the reference count of source_file.
void tm_workspace_remove_source_file(TMSourceFile *source_file)
Removes a source file from the workspace if it exists.
GtkWidget * ui_dialog_vbox_new(GtkDialog *dialog)
Makes a fixed border for dialogs without increasing the button box border.
gpointer ui_builder_get_object(const gchar *name)
void ui_set_editor_font(const gchar *font_name)
gboolean ui_encodings_combo_box_set_active_encoding(GtkComboBox *combo, gint enc)
gboolean ui_tree_model_iter_any_next(GtkTreeModel *model, GtkTreeIter *iter, gboolean down)
GtkWidget * ui_create_encodings_combo_box(gboolean has_detect, gint default_enc)
GeanyMainWidgets main_widgets
void ui_entry_add_clear_icon(GtkEntry *entry)
Adds a small clear icon to the right end of the passed entry.
gint ui_encodings_combo_box_get_active_encoding(GtkComboBox *combo)
void ui_combo_box_add_to_history(GtkComboBoxText *combo_entry, const gchar *text, gint history_len)
Prepends text to the drop down list, removing a duplicate element in the list if found.
GtkWidget * ui_button_new_with_image(const gchar *stock_id, const gchar *text)
Creates a GtkButton with custom text and a stock image similar to gtk_button_new_from_stock().
GtkWidget * ui_lookup_widget(GtkWidget *widget, const gchar *widget_name)
Returns a widget from a name in a component, usually created by Glade.
void ui_editable_insert_text_callback(GtkEditable *editable, gchar *new_text, gint new_text_len, gint *position, gpointer data)
GeanyInterfacePrefs interface_prefs
User Interface general utility functions.
gchar * utils_make_human_readable_str(guint64 size, gulong block_size, gulong display_unit)
gchar * utils_str_middle_truncate(const gchar *string, guint truncate_length)
Truncates the input string to a given length.
gchar * utils_get_utf8_from_locale(const gchar *locale_text)
Converts the given string (in locale encoding) into UTF-8 encoding.
gchar * utils_get_current_file_dir_utf8(void)
gboolean utils_str_equal(const gchar *a, const gchar *b)
NULL-safe string comparison.
const gchar * utils_get_default_dir_utf8(void)
gchar * utils_get_locale_from_utf8(const gchar *utf8_text)
Converts the given UTF-8 encoded string into locale encoding.
General utility functions, non-GTK related.
#define foreach_slist(node, list)
Iterates all the nodes in list.
#define SETPTR(ptr, result)
Assigns result to ptr, then frees the old value.
#define EMPTY(ptr)
Returns TRUE if ptr is NULL or *ptr is FALSE.