Merge branch 'gtkbuilder'

This commit is contained in:
Matthew Brush 2011-12-10 15:50:05 -08:00
commit 2d41ee941b
18 changed files with 10060 additions and 17688 deletions

View File

@ -23,7 +23,8 @@ SYS_DATA_FILES = \
data/ui_toolbar.xml \
$(srcdir)/data/templates/* \
$(srcdir)/data/templates/files/* \
$(srcdir)/data/colorschemes/*
$(srcdir)/data/colorschemes/* \
$(top_srcdir)/data/geany.glade
EXTRA_DIST = \
autogen.sh \
@ -32,8 +33,6 @@ EXTRA_DIST = \
geany.desktop.in \
geany.pc.in \
geany.spec \
geany.glade \
geany.gladep \
ChangeLog.pre-0-17 \
HACKING \
README.I18N \

9077
data/geany.glade Normal file

File diff suppressed because it is too large Load Diff

10933
geany.glade

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,7 @@
# List of source files containing translatable strings.
geany.desktop.in
data/geany.glade
src/about.c
src/build.c
src/callbacks.c
@ -14,7 +15,6 @@ src/geanymenubuttonaction.c
src/geanyentryaction.c
src/highlighting.c
src/images.c
src/interface.c
src/keybindings.c
src/keyfile.c
src/log.c

View File

@ -22,7 +22,6 @@ SRCS = \
geanywraplabel.c geanywraplabel.h \
highlighting.c highlighting.h \
highlightingmappings.h \
interface.c interface.h \
keybindings.c keybindings.h \
keyfile.c keyfile.h \
log.c log.h \
@ -126,6 +125,8 @@ AM_CFLAGS = -DGEANY_DATADIR=\""$(datadir)"\" \
-DGTK \
-DG_LOG_DOMAIN=\""Geany"\"
geany_LDFLAGS = -Wl,--export-dynamic
clean-local:
endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +0,0 @@
/*
* DO NOT EDIT THIS FILE - it is generated by Glade.
*/
GtkWidget* create_window1 (void);
GtkWidget* create_toolbar_popup_menu1 (void);
GtkWidget* create_edit_menu1 (void);
GtkWidget* create_prefs_dialog (void);
GtkWidget* create_project_dialog (void);

View File

@ -284,7 +284,7 @@ static void init_default_kb(void)
LW(duplicate_line_or_selection1));
keybindings_set_item(group, GEANY_KEYS_EDITOR_DELETELINE, NULL,
GDK_k, GDK_CONTROL_MASK, "edit_deleteline", _("_Delete Current Line(s)"),
LW(delete_current_line_s_1));
LW(delete_current_lines1));
keybindings_set_item(group, GEANY_KEYS_EDITOR_DELETELINETOEND, NULL,
GDK_Delete, GDK_SHIFT_MASK | GDK_CONTROL_MASK, "edit_deletelinetoend",
_("Delete to line end"), NULL);
@ -329,10 +329,10 @@ static void init_default_kb(void)
GDK_v, GDK_CONTROL_MASK, "menu_paste", _("Paste"), NULL);
keybindings_set_item(group, GEANY_KEYS_CLIPBOARD_COPYLINE, NULL,
GDK_c, GDK_CONTROL_MASK | GDK_SHIFT_MASK, "edit_copyline", _("_Copy Current Line(s)"),
LW(copy_current_line_s_1));
LW(copy_current_lines1));
keybindings_set_item(group, GEANY_KEYS_CLIPBOARD_CUTLINE, NULL,
GDK_x, GDK_CONTROL_MASK | GDK_SHIFT_MASK, "edit_cutline", _("_Cut Current Line(s)"),
LW(cut_current_line_s_1));
LW(cut_current_lines1));
group = keybindings_get_core_group(GEANY_KEY_GROUP_SELECT);
@ -342,7 +342,7 @@ static void init_default_kb(void)
GDK_w, GDK_SHIFT_MASK | GDK_MOD1_MASK, "edit_selectword", _("Select current word"), NULL);
keybindings_set_item(group, GEANY_KEYS_SELECT_LINE, NULL,
GDK_l, GDK_SHIFT_MASK | GDK_MOD1_MASK, "edit_selectline", _("_Select Current Line(s)"),
LW(select_current_line_s_1));
LW(select_current_lines1));
keybindings_set_item(group, GEANY_KEYS_SELECT_PARAGRAPH, NULL,
GDK_p, GDK_SHIFT_MASK | GDK_MOD1_MASK, "edit_selectparagraph", _("_Select Current Paragraph"),
LW(select_current_paragraph1));
@ -756,17 +756,17 @@ static void add_popup_menu_accels(void)
group = keybindings_get_core_group(GEANY_KEY_GROUP_INSERT);
GEANY_ADD_POPUP_ACCEL(GEANY_KEYS_INSERT_DATE, insert_date_custom2);
GEANY_ADD_POPUP_ACCEL(GEANY_KEYS_INSERT_ALTWHITESPACE, insert_alternative_white_space1);
GEANY_ADD_POPUP_ACCEL(GEANY_KEYS_INSERT_ALTWHITESPACE, insert_alternative_white_space2);
group = keybindings_get_core_group(GEANY_KEY_GROUP_FILE);
GEANY_ADD_POPUP_ACCEL(GEANY_KEYS_FILE_OPENSELECTED, menu_open_selected_file2);
group = keybindings_get_core_group(GEANY_KEY_GROUP_SEARCH);
GEANY_ADD_POPUP_ACCEL(GEANY_KEYS_SEARCH_FINDUSAGE, find_usage1);
GEANY_ADD_POPUP_ACCEL(GEANY_KEYS_SEARCH_FINDDOCUMENTUSAGE, find_document_usage1);
GEANY_ADD_POPUP_ACCEL(GEANY_KEYS_SEARCH_FINDUSAGE, find_usage2);
GEANY_ADD_POPUP_ACCEL(GEANY_KEYS_SEARCH_FINDDOCUMENTUSAGE, find_document_usage2);
group = keybindings_get_core_group(GEANY_KEY_GROUP_GOTO);
GEANY_ADD_POPUP_ACCEL(GEANY_KEYS_GOTO_TAGDEFINITION, goto_tag_definition1);
GEANY_ADD_POPUP_ACCEL(GEANY_KEYS_GOTO_TAGDEFINITION, goto_tag_definition2);
/* Format and Commands share the menu bar submenus */
/* Build menu items are set if the build menus are created */

View File

@ -43,7 +43,6 @@
#include "main.h"
#include "prefix.h"
#include "prefs.h"
#include "interface.h"
#include "support.h"
#include "callbacks.h"
#include "log.h"
@ -230,6 +229,8 @@ static void apply_settings(void)
static void main_init(void)
{
/* inits */
ui_init_builder();
main_widgets.window = NULL;
app->project = NULL;
ui_widgets.open_fontsel = NULL;
@ -1259,6 +1260,8 @@ void main_quit()
g_free(app);
ui_finalize_builder();
gtk_main_quit();
}

View File

@ -60,11 +60,9 @@ endif
OBJS = about.o build.o callbacks.o dialogs.o document.o editor.o encodings.o filetypes.o \
geanyentryaction.o geanymenubuttonaction.o geanyobject.o geanywraplabel.o highlighting.o \
interface.o keybindings.o keyfile.o \
log.o main.o msgwindow.o navqueue.o notebook.o plugins.o pluginutils.o \
prefs.o printing.o project.o \
sciwrappers.o search.o socket.o stash.o \
symbols.o templates.o toolbar.o tools.o sidebar.o \
keybindings.o keyfile.o log.o main.o msgwindow.o navqueue.o notebook.o \
plugins.o pluginutils.o prefs.o printing.o project.o sciwrappers.o search.o \
socket.o stash.o symbols.o templates.o toolbar.o tools.o sidebar.o \
ui_utils.o utils.o win32.o
.c.o:

View File

@ -46,7 +46,6 @@
#include "msgwindow.h"
#include "keyfile.h"
#include "keybindings.h"
#include "interface.h"
#include "encodings.h"
#include "project.h"
#include "editor.h"

View File

@ -42,7 +42,6 @@
#include "keyfile.h"
#include "win32.h"
#include "build.h"
#include "interface.h"
#include "editor.h"
#include "stash.h"
#include "sidebar.h"
@ -408,7 +407,7 @@ static void create_properties_dialog(PropertyDialogElements *e)
gtk_window_set_destroy_with_parent(GTK_WINDOW(e->dialog), TRUE);
gtk_widget_set_name(e->dialog, "GeanyDialogProject");
ui_entry_add_clear_icon(GTK_ENTRY(ui_lookup_widget(e->dialog, "spin_indent_width")));
ui_entry_add_clear_icon(GTK_ENTRY(ui_lookup_widget(e->dialog, "spin_indent_width_project")));
table = gtk_table_new(5, 2, FALSE);
gtk_container_set_border_width(GTK_CONTAINER(table), 6);
@ -484,8 +483,8 @@ static void create_properties_dialog(PropertyDialogElements *e)
build_page_num = gtk_notebook_insert_page(GTK_NOTEBOOK(notebook), build_table, label, 2);
e->notebook = notebook;
g_signal_connect(ui_lookup_widget(e->dialog, "radio_long_line_custom"), "toggled",
G_CALLBACK(on_radio_long_line_custom_toggled), ui_lookup_widget(e->dialog, "spin_long_line"));
g_signal_connect(ui_lookup_widget(e->dialog, "radio_long_line_custom_project"), "toggled",
G_CALLBACK(on_radio_long_line_custom_toggled), ui_lookup_widget(e->dialog, "spin_long_line_project"));
label = gtk_label_new(_("File patterns:"));
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 4, 5,
@ -527,16 +526,16 @@ static void show_project_properties(gboolean show_build)
gtk_label_set_text(GTK_LABEL(e->file_name), p->file_name);
gtk_entry_set_text(GTK_ENTRY(e->base_path), p->base_path);
radio_long_line_custom = ui_lookup_widget(e->dialog, "radio_long_line_custom");
radio_long_line_custom = ui_lookup_widget(e->dialog, "radio_long_line_custom_project");
switch (p->long_line_behaviour)
{
case 0: widget = ui_lookup_widget(e->dialog, "radio_long_line_disabled"); break;
case 1: widget = ui_lookup_widget(e->dialog, "radio_long_line_default"); break;
case 0: widget = ui_lookup_widget(e->dialog, "radio_long_line_disabled_project"); break;
case 1: widget = ui_lookup_widget(e->dialog, "radio_long_line_default_project"); break;
case 2: widget = radio_long_line_custom; break;
}
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), TRUE);
widget = ui_lookup_widget(e->dialog, "spin_long_line");
widget = ui_lookup_widget(e->dialog, "spin_long_line_project");
gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget), (gdouble)p->long_line_column);
on_radio_long_line_custom_toggled(GTK_TOGGLE_BUTTON(radio_long_line_custom), widget);
@ -768,12 +767,12 @@ static gboolean update_config(const PropertyDialogElements *e, gboolean new_proj
}
build_menu_update(doc);
widget = ui_lookup_widget(e->dialog, "radio_long_line_disabled");
widget = ui_lookup_widget(e->dialog, "radio_long_line_disabled_project");
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)))
p->long_line_behaviour = 0;
else
{
widget = ui_lookup_widget(e->dialog, "radio_long_line_default");
widget = ui_lookup_widget(e->dialog, "radio_long_line_default_project");
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)))
p->long_line_behaviour = 1;
else
@ -781,7 +780,7 @@ static gboolean update_config(const PropertyDialogElements *e, gboolean new_proj
p->long_line_behaviour = 2;
}
widget = ui_lookup_widget(e->dialog, "spin_long_line");
widget = ui_lookup_widget(e->dialog, "spin_long_line_project");
p->long_line_column = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget));
apply_editor_prefs();
@ -1185,22 +1184,22 @@ void project_init(void)
indent_group = group;
stash_group_add_spin_button_integer(group, &indentation.width,
"indent_width", 4, "spin_indent_width");
"indent_width", 4, "spin_indent_width_project");
stash_group_add_radio_buttons(group, (gint*)(gpointer)&indentation.type,
"indent_type", GEANY_INDENT_TYPE_TABS,
"radio_indent_spaces", GEANY_INDENT_TYPE_SPACES,
"radio_indent_tabs", GEANY_INDENT_TYPE_TABS,
"radio_indent_both", GEANY_INDENT_TYPE_BOTH,
"radio_indent_spaces_project", GEANY_INDENT_TYPE_SPACES,
"radio_indent_tabs_project", GEANY_INDENT_TYPE_TABS,
"radio_indent_both_project", GEANY_INDENT_TYPE_BOTH,
NULL);
/* This is a 'hidden' pref for backwards-compatibility */
stash_group_add_integer(group, &indentation.hard_tab_width,
"indent_hard_tab_width", 8);
stash_group_add_toggle_button(group, &indentation.detect_type,
"detect_indent", FALSE, "check_detect_indent_type");
"detect_indent", FALSE, "check_detect_indent_type_project");
stash_group_add_toggle_button(group, &indentation.detect_width,
"detect_indent_width", FALSE, "check_detect_indent_width");
"detect_indent_width", FALSE, "check_detect_indent_width_project");
stash_group_add_combo_box(group, (gint*)(gpointer)&indentation.auto_indent_mode,
"indent_mode", GEANY_AUTOINDENT_CURRENTCHARS, "combo_auto_indent_mode");
"indent_mode", GEANY_AUTOINDENT_CURRENTCHARS, "combo_auto_indent_mode_project");
}

View File

@ -533,22 +533,25 @@ lookup_widget(GtkWidget *widget, const gchar *widget_name)
{
GtkWidget *parent, *found_widget;
for (;;)
{
if (GTK_IS_MENU (widget))
parent = gtk_menu_get_attach_widget (GTK_MENU (widget));
else
parent = widget->parent;
if (!parent)
parent = (GtkWidget*) g_object_get_data (G_OBJECT (widget), "GladeParentKey");
if (parent == NULL)
break;
widget = parent;
}
g_return_val_if_fail(widget != NULL, NULL);
g_return_val_if_fail(widget_name != NULL, NULL);
found_widget = (GtkWidget*) g_object_get_data (G_OBJECT (widget), widget_name);
if (!found_widget)
g_warning ("Widget not found: %s", widget_name);
for (;;)
{
if (GTK_IS_MENU(widget))
parent = gtk_menu_get_attach_widget(GTK_MENU(widget));
else
parent = widget->parent;
if (parent == NULL)
parent = (GtkWidget*) g_object_get_data(G_OBJECT(widget), "GladeParentKey");
if (parent == NULL)
break;
widget = parent;
}
found_widget = (GtkWidget*) g_object_get_data(G_OBJECT(widget), widget_name);
if (G_UNLIKELY(found_widget == NULL))
g_warning("Widget not found: %s", widget_name);
return found_widget;
}

View File

@ -3,6 +3,7 @@
*
* Copyright 2006-2011 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
* Copyright 2006-2011 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
* Copyright 2011 Matthew Brush <mbrush(at)codebrainz(dot)ca>
*
* 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
@ -25,6 +26,8 @@
#include "geany.h"
#include "support.h"
#include <string.h>
#include <ctype.h>
#include <gdk/gdkkeysyms.h>
@ -60,6 +63,13 @@ GeanyMainWidgets main_widgets;
UIPrefs ui_prefs;
UIWidgets ui_widgets;
static GtkBuilder *builder = NULL;
static GtkWidget* window1 = NULL;
static GtkWidget* toolbar_popup_menu1 = NULL;
static GtkWidget* edit_menu1 = NULL;
static GtkWidget* prefs_dialog = NULL;
static GtkWidget* project_dialog = NULL;
static struct
{
/* pointers to widgets only sensitive when there is at least one document, the pointers can
@ -2102,6 +2112,166 @@ void ui_init_prefs(void)
}
/* Used to find out the name of the GtkBuilder retrieved object since
* some objects will be GTK_IS_BUILDABLE() and use the GtkBuildable
* 'name' property for that and those that don't implement GtkBuildable
* will have a "gtk-builder-name" stored in the GObject's data list. */
static const gchar *ui_guess_object_name(GObject *obj)
{
const gchar *name = NULL;
g_return_val_if_fail(G_IS_OBJECT(obj), NULL);
if (GTK_IS_BUILDABLE(obj))
name = gtk_buildable_get_name(GTK_BUILDABLE(obj));
if (! name)
name = g_object_get_data(obj, "gtk-builder-name");
if (! name)
return NULL;
return name;
}
/* Compatibility functions */
GtkWidget *create_edit_menu1(void)
{
return edit_menu1;
}
GtkWidget *create_prefs_dialog(void)
{
return prefs_dialog;
}
GtkWidget *create_project_dialog(void)
{
return project_dialog;
}
GtkWidget *create_toolbar_popup_menu1(void)
{
return toolbar_popup_menu1;
}
GtkWidget *create_window1(void)
{
return window1;
}
static GtkWidget *ui_get_top_parent(GtkWidget *widget)
{
GtkWidget *parent, *found_widget;
g_return_val_if_fail(GTK_IS_WIDGET(widget), NULL);
for (;;)
{
if (GTK_IS_MENU(widget))
parent = gtk_menu_get_attach_widget(GTK_MENU(widget));
else
parent = gtk_widget_get_parent(widget);
if (parent == NULL)
parent = (GtkWidget*) g_object_get_data(G_OBJECT(widget), "GladeParentKey");
if (parent == NULL)
break;
widget = parent;
}
return widget;
}
void ui_init_builder(void)
{
gchar *interface_file;
const gchar *name, *toplevel_name;
GError *error;
GSList *iter, *all_objects;
GtkCellRenderer *renderer;
GtkWidget *widget, *toplevel;
/* prevent function from being called twice */
if (GTK_IS_BUILDER(builder))
return;
builder = gtk_builder_new();
if (! builder)
{
g_error("Failed to initialize the user-interface");
return;
}
gtk_builder_set_translation_domain(builder, GETTEXT_PACKAGE);
error = NULL;
interface_file = g_build_filename(app->datadir, "geany.glade", NULL);
if (! gtk_builder_add_from_file(builder, interface_file, &error))
{
/* Show the user this message so they know WTF happened */
dialogs_show_msgbox_with_secondary(GTK_MESSAGE_ERROR,
_("Geany cannot start!"), error->message);
/* Aborts */
g_error("Cannot create user-interface: %s", error->message);
g_error_free(error);
g_free(interface_file);
g_object_unref(builder);
return;
}
g_free(interface_file);
gtk_builder_connect_signals(builder, NULL);
edit_menu1 = GTK_WIDGET(gtk_builder_get_object(builder, "edit_menu1"));
prefs_dialog = GTK_WIDGET(gtk_builder_get_object(builder, "prefs_dialog"));
project_dialog = GTK_WIDGET(gtk_builder_get_object(builder, "project_dialog"));
toolbar_popup_menu1 = GTK_WIDGET(gtk_builder_get_object(builder, "toolbar_popup_menu1"));
window1 = GTK_WIDGET(gtk_builder_get_object(builder, "window1"));
g_object_set_data(G_OBJECT(edit_menu1), "edit_menu1", edit_menu1);
g_object_set_data(G_OBJECT(prefs_dialog), "prefs_dialog", prefs_dialog);
g_object_set_data(G_OBJECT(project_dialog), "project_dialog", project_dialog);
g_object_set_data(G_OBJECT(toolbar_popup_menu1), "toolbar_popup_menu1", toolbar_popup_menu1);
g_object_set_data(G_OBJECT(window1), "window1", window1);
all_objects = gtk_builder_get_objects(builder);
for (iter = all_objects; iter != NULL; iter = g_slist_next(iter))
{
if (! GTK_IS_WIDGET(iter->data))
continue;
widget = GTK_WIDGET(iter->data);
name = ui_guess_object_name(G_OBJECT(widget));
if (! name)
{
g_warning("Unable to get name from GtkBuilder object");
continue;
}
toplevel = ui_get_top_parent(widget);
if (toplevel)
ui_hookup_widget(toplevel, widget, name);
/* Glade doesn't seem to add cell renderers for the combo boxes,
* so they are added here. */
if (GTK_IS_COMBO_BOX(widget))
{
renderer = gtk_cell_renderer_text_new();
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(widget), renderer, TRUE);
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(widget),
renderer, "text", 0, NULL);
}
}
g_slist_free(all_objects);
}
void ui_init(void)
{
init_recent_files();
@ -2112,10 +2282,10 @@ void ui_init(void)
main_widgets.progressbar = progress_bar_create();
/* current word sensitive items */
widgets.popup_goto_items[0] = ui_lookup_widget(main_widgets.editor_menu, "goto_tag_definition1");
widgets.popup_goto_items[0] = ui_lookup_widget(main_widgets.editor_menu, "goto_tag_definition2");
widgets.popup_goto_items[1] = ui_lookup_widget(main_widgets.editor_menu, "context_action1");
widgets.popup_goto_items[2] = ui_lookup_widget(main_widgets.editor_menu, "find_usage1");
widgets.popup_goto_items[3] = ui_lookup_widget(main_widgets.editor_menu, "find_document_usage1");
widgets.popup_goto_items[2] = ui_lookup_widget(main_widgets.editor_menu, "find_usage2");
widgets.popup_goto_items[3] = ui_lookup_widget(main_widgets.editor_menu, "find_document_usage2");
widgets.popup_copy_items[0] = ui_lookup_widget(main_widgets.editor_menu, "cut1");
widgets.popup_copy_items[1] = ui_lookup_widget(main_widgets.editor_menu, "copy1");
@ -2153,6 +2323,25 @@ void ui_init(void)
}
void ui_finalize_builder(void)
{
if (GTK_IS_BUILDER(builder))
g_object_unref(builder);
/* cleanup refs lingering even after GtkBuilder is destroyed */
if (GTK_IS_WIDGET(edit_menu1))
gtk_widget_destroy(edit_menu1);
if (GTK_IS_WIDGET(prefs_dialog))
gtk_widget_destroy(prefs_dialog);
if (GTK_IS_WIDGET(project_dialog))
gtk_widget_destroy(project_dialog);
if (GTK_IS_WIDGET(toolbar_popup_menu1))
gtk_widget_destroy(toolbar_popup_menu1);
if (GTK_IS_WIDGET(window1))
gtk_widget_destroy(window1);
}
void ui_finalize(void)
{
g_free(statusbar_template);

View File

@ -22,6 +22,7 @@
#ifndef GEANY_UI_UTILS_H
#define GEANY_UI_UTILS_H 1
/** Sets a name to lookup @a widget from @a owner.
* @param owner Usually a window, dialog or popup menu.
* @param widget Widget.
@ -64,6 +65,7 @@ typedef struct GeanyInterfacePrefs
}
GeanyInterfacePrefs;
extern GeanyInterfacePrefs interface_prefs;
@ -207,6 +209,13 @@ void ui_widget_set_tooltip_text(GtkWidget *widget, const gchar *text);
GtkWidget *ui_lookup_widget(GtkWidget *widget, const gchar *widget_name);
/* Compatibility functions */
GtkWidget *create_edit_menu1(void);
GtkWidget *create_prefs_dialog(void);
GtkWidget *create_project_dialog(void);
GtkWidget *create_toolbar_popup_menu1(void);
GtkWidget *create_window1(void);
void ui_widget_set_sensitive(GtkWidget *widget, gboolean set);
void ui_entry_add_clear_icon(GtkEntry *entry);
@ -222,11 +231,14 @@ void ui_label_set_markup(GtkLabel *label, const gchar *format, ...) G_GNUC_PRINT
/* End of general widget functions */
void ui_init_builder(void);
void ui_init(void);
void ui_init_prefs(void);
void ui_finalize_builder(void);
void ui_finalize(void);
void ui_init_toolbar_widgets(void);

230
src/vte.c
View File

@ -59,7 +59,6 @@ static gboolean clean = TRUE;
static GModule *module = NULL;
static struct VteFunctions *vf;
static gchar *gtk_menu_key_accel = NULL;
static gint vte_prefs_tab_num = -1;
/* use vte wordchars to select paths */
static const gchar VTE_WORDCHARS[] = "-A-Za-z0-9,./?%&#:_";
@ -493,13 +492,16 @@ static void vte_popup_menu_clicked(GtkMenuItem *menuitem, gpointer user_data)
}
case POPUP_PREFERENCES:
{
GtkWidget *notebook;
GtkWidget *notebook, *tab_page;
prefs_show_dialog();
notebook = ui_lookup_widget(ui_widgets.prefs_dialog, "notebook2");
tab_page = ui_lookup_widget(ui_widgets.prefs_dialog, "frame_term");
gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook),
gtk_notebook_page_num(GTK_NOTEBOOK(notebook), GTK_WIDGET(tab_page)));
gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), vte_prefs_tab_num);
break;
}
}
@ -697,13 +699,14 @@ static void vte_drag_data_received(GtkWidget *widget, GdkDragContext *drag_conte
}
static void check_run_in_vte_toggled(GtkToggleButton *togglebutton, GtkWidget *user_data)
G_MODULE_EXPORT void on_check_run_in_vte_toggled(GtkToggleButton *togglebutton, GtkWidget *user_data)
{
g_return_if_fail(GTK_IS_WIDGET(user_data));
gtk_widget_set_sensitive(user_data, gtk_toggle_button_get_active(togglebutton));
}
static void font_button_clicked_cb(GtkFontButton *widget, gpointer user_data)
G_MODULE_EXPORT void on_term_font_set(GtkFontButton *widget, gpointer user_data)
{
const gchar *fontbtn = gtk_font_button_get_font_name(widget);
@ -715,25 +718,19 @@ static void font_button_clicked_cb(GtkFontButton *widget, gpointer user_data)
}
static void on_color_button_choose_cb(GtkColorButton *widget, gpointer user_data)
G_MODULE_EXPORT void on_term_fg_color_set(GtkColorButton *widget, gpointer user_data)
{
switch (GPOINTER_TO_INT(user_data))
{
case 1:
{
g_free(vc->colour_fore);
vc->colour_fore = g_new0(GdkColor, 1);
gtk_color_button_get_color(widget, vc->colour_fore);
break;
}
case 2:
{
g_free(vc->colour_back);
vc->colour_back = g_new0(GdkColor, 1);
gtk_color_button_get_color(widget, vc->colour_back);
break;
}
}
g_free(vc->colour_fore);
vc->colour_fore = g_new0(GdkColor, 1);
gtk_color_button_get_color(widget, vc->colour_fore);
}
G_MODULE_EXPORT void on_term_bg_color_set(GtkColorButton *widget, gpointer user_data)
{
g_free(vc->colour_back);
vc->colour_back = g_new0(GdkColor, 1);
gtk_color_button_get_color(widget, vc->colour_back);
}
@ -741,172 +738,33 @@ void vte_append_preferences_tab(void)
{
if (vte_info.have_vte)
{
GtkWidget *notebook, *vbox, *label, *alignment, *table, *frame, *box;
GtkWidget *font_term, *color_fore, *color_back, *spin_scrollback;
GtkWidget *check_scroll_key, *check_scroll_out, *check_follow_path;
GtkWidget *check_enable_bash_keys, *check_ignore_menu_key, *check_cursor_blinks;
GtkWidget *check_run_in_vte, *check_skip_script, *entry_shell, *button_shell, *image_shell;
GtkObject *spin_scrollback_adj;
GtkWidget *frame_term, *button_shell, *entry_shell;
GtkWidget *check_run_in_vte, *check_skip_script;
GtkWidget *font_button, *fg_color_button, *bg_color_button;
notebook = ui_lookup_widget(ui_widgets.prefs_dialog, "notebook2");
frame = ui_frame_new_with_alignment(_("Terminal"), &alignment);
gtk_container_set_border_width(GTK_CONTAINER(frame), 5);
vbox = gtk_vbox_new(FALSE, 12);
gtk_container_add(GTK_CONTAINER(alignment), vbox);
label = gtk_label_new(_("Terminal"));
vte_prefs_tab_num = gtk_notebook_append_page(GTK_NOTEBOOK(notebook), frame, label);
table = gtk_table_new(6, 2, FALSE);
gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
gtk_table_set_row_spacings(GTK_TABLE(table), 3);
gtk_table_set_col_spacings(GTK_TABLE(table), 10);
label = gtk_label_new(_("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_widget_set_tooltip_text(font_term, _("Sets the font for the terminal widget"));
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_widget_set_tooltip_text(color_fore, _("Sets the foreground color of the text in the terminal widget"));
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_widget_set_tooltip_text(color_back, _("Sets the background color of the text in the terminal widget"));
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, 0);
spin_scrollback = gtk_spin_button_new(GTK_ADJUSTMENT(spin_scrollback_adj), 1, 0);
ui_entry_add_clear_icon(GTK_ENTRY(spin_scrollback));
gtk_table_attach(GTK_TABLE(table), spin_scrollback, 1, 2, 3, 4,
(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_widget_set_tooltip_text(spin_scrollback, _("Specifies the history in lines, which you can scroll back in the terminal widget"));
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(_("Shell:"));
gtk_table_attach(GTK_TABLE(table), label, 0, 1, 5, 6,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
entry_shell = gtk_entry_new();
ui_entry_add_clear_icon(GTK_ENTRY(entry_shell));
gtk_widget_set_tooltip_text(entry_shell, _("Sets the path to the shell which should be started inside the terminal emulation"));
button_shell = gtk_button_new();
gtk_widget_show(button_shell);
box = gtk_hbox_new(FALSE, 6);
gtk_box_pack_start_defaults(GTK_BOX(box), entry_shell);
gtk_box_pack_start(GTK_BOX(box), button_shell, FALSE, FALSE, 0);
gtk_table_attach(GTK_TABLE(table), box, 1, 2, 5, 6,
(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
image_shell = gtk_image_new_from_stock(GTK_STOCK_OPEN, GTK_ICON_SIZE_BUTTON);
gtk_widget_show(image_shell);
gtk_container_add(GTK_CONTAINER(button_shell), image_shell);
box = gtk_vbox_new(FALSE, 3);
check_scroll_key = gtk_check_button_new_with_mnemonic(_("Scroll on keystroke"));
gtk_widget_set_tooltip_text(check_scroll_key, _("Whether to scroll to the bottom if a key was pressed"));
gtk_container_add(GTK_CONTAINER(box), check_scroll_key);
check_scroll_out = gtk_check_button_new_with_mnemonic(_("Scroll on output"));
gtk_widget_set_tooltip_text(check_scroll_out, _("Whether to scroll to the bottom when output is generated"));
gtk_container_add(GTK_CONTAINER(box), check_scroll_out);
check_cursor_blinks = gtk_check_button_new_with_mnemonic(_("Cursor blinks"));
gtk_widget_set_tooltip_text(check_cursor_blinks, _("Whether to blink the cursor"));
gtk_container_add(GTK_CONTAINER(box), check_cursor_blinks);
check_enable_bash_keys = gtk_check_button_new_with_mnemonic(_("Override Geany keybindings"));
gtk_widget_set_tooltip_text(check_enable_bash_keys,
_("Allows the VTE to receive keyboard shortcuts (apart from focus commands)"));
gtk_container_add(GTK_CONTAINER(box), check_enable_bash_keys);
check_ignore_menu_key = gtk_check_button_new_with_mnemonic(_("Disable menu shortcut key (F10 by default)"));
gtk_widget_set_tooltip_text(check_ignore_menu_key, _("This option disables the keybinding to popup the menu bar (default is F10). Disabling it can be useful if you use, for example, Midnight Commander within the VTE."));
gtk_container_add(GTK_CONTAINER(box), check_ignore_menu_key);
check_follow_path = gtk_check_button_new_with_mnemonic(_("Follow the path of the current file"));
gtk_widget_set_tooltip_text(check_follow_path, _("Whether to execute \"cd $path\" when you switch between opened files"));
gtk_container_add(GTK_CONTAINER(box), check_follow_path);
/* create check_skip_script checkbox before the check_skip_script checkbox to be able to
* use the object for the toggled handler of check_skip_script checkbox */
check_skip_script = gtk_check_button_new_with_mnemonic(_("Don't use run script"));
gtk_widget_set_tooltip_text(check_skip_script, _("Don't use the simple run script which is usually used to display the exit status of the executed program"));
gtk_widget_set_sensitive(check_skip_script, vc->run_in_vte);
check_run_in_vte = gtk_check_button_new_with_mnemonic(_("Execute programs in VTE"));
gtk_widget_set_tooltip_text(check_run_in_vte, _("Run programs in VTE instead of opening a terminal emulation window. Please note, programs executed in VTE cannot be stopped"));
gtk_container_add(GTK_CONTAINER(box), check_run_in_vte);
g_signal_connect(check_run_in_vte, "toggled",
G_CALLBACK(check_run_in_vte_toggled), check_skip_script);
/* now add the check_skip_script checkbox after the check_run_in_vte checkbox */
gtk_container_add(GTK_CONTAINER(box), check_skip_script);
gtk_box_pack_start(GTK_BOX(vbox), box, FALSE, FALSE, 0);
ui_hookup_widget(ui_widgets.prefs_dialog, font_term, "font_term");
ui_hookup_widget(ui_widgets.prefs_dialog, color_fore, "color_fore");
ui_hookup_widget(ui_widgets.prefs_dialog, color_back, "color_back");
ui_hookup_widget(ui_widgets.prefs_dialog, spin_scrollback, "spin_scrollback");
ui_hookup_widget(ui_widgets.prefs_dialog, entry_shell, "entry_shell");
ui_hookup_widget(ui_widgets.prefs_dialog, check_scroll_key, "check_scroll_key");
ui_hookup_widget(ui_widgets.prefs_dialog, check_scroll_out, "check_scroll_out");
ui_hookup_widget(ui_widgets.prefs_dialog, check_cursor_blinks, "check_cursor_blinks");
ui_hookup_widget(ui_widgets.prefs_dialog, check_enable_bash_keys, "check_enable_bash_keys");
ui_hookup_widget(ui_widgets.prefs_dialog, check_ignore_menu_key, "check_ignore_menu_key");
ui_hookup_widget(ui_widgets.prefs_dialog, check_follow_path, "check_follow_path");
ui_hookup_widget(ui_widgets.prefs_dialog, check_run_in_vte, "check_run_in_vte");
ui_hookup_widget(ui_widgets.prefs_dialog, check_skip_script, "check_skip_script");
gtk_widget_show_all(frame);
g_signal_connect(font_term, "font-set", G_CALLBACK(font_button_clicked_cb), NULL);
g_signal_connect(color_fore, "color-set", G_CALLBACK(on_color_button_choose_cb),
GINT_TO_POINTER(1));
g_signal_connect(color_back, "color-set", G_CALLBACK(on_color_button_choose_cb),
GINT_TO_POINTER(2));
button_shell = GTK_WIDGET(ui_lookup_widget(ui_widgets.prefs_dialog, "button_term_shell"));
entry_shell = GTK_WIDGET(ui_lookup_widget(ui_widgets.prefs_dialog, "entry_shell"));
ui_setup_open_button_callback(button_shell, NULL,
GTK_FILE_CHOOSER_ACTION_OPEN, GTK_ENTRY(entry_shell));
check_skip_script = GTK_WIDGET(ui_lookup_widget(ui_widgets.prefs_dialog, "check_skip_script"));
gtk_widget_set_sensitive(check_skip_script, vc->run_in_vte);
check_run_in_vte = GTK_WIDGET(ui_lookup_widget(ui_widgets.prefs_dialog, "check_run_in_vte"));
g_signal_connect(G_OBJECT(check_run_in_vte), "toggled",
G_CALLBACK(on_check_run_in_vte_toggled), check_skip_script);
font_button = ui_lookup_widget(ui_widgets.prefs_dialog, "font_term");
g_signal_connect(font_button, "font-set", G_CALLBACK(on_term_font_set), NULL);
fg_color_button = ui_lookup_widget(ui_widgets.prefs_dialog, "color_fore");
g_signal_connect(fg_color_button, "color-set", G_CALLBACK(on_term_fg_color_set), NULL);
bg_color_button = ui_lookup_widget(ui_widgets.prefs_dialog, "color_back");
g_signal_connect(bg_color_button, "color-set", G_CALLBACK(on_term_bg_color_set), NULL);
frame_term = ui_lookup_widget(ui_widgets.prefs_dialog, "frame_term");
gtk_widget_show_all(frame_term);
}
}