Move custom styles to a resource file

This commit is contained in:
Colomban Wendling 2012-09-29 20:18:19 +02:00
parent 3070738df8
commit eeddd6f720
6 changed files with 38 additions and 54 deletions

View File

@ -24,7 +24,8 @@ SYS_DATA_FILES = \
$(srcdir)/data/templates/* \
$(srcdir)/data/templates/files/* \
$(srcdir)/data/colorschemes/* \
$(top_srcdir)/data/geany.glade
$(top_srcdir)/data/geany.glade \
$(top_srcdir)/data/geany.gtkrc
EXTRA_DIST = \
autogen.sh \

23
data/geany.gtkrc Normal file
View File

@ -0,0 +1,23 @@
# custom GTK2 style for Geany
# make close button on the editor's tabs smaller
style "geany-close-tab-button-style" {
GtkWidget::focus-padding = 0
GtkWidget::focus-line-width = 0
xthickness = 0
ythickness = 0
}
widget "*.geany-close-tab-button" style "geany-close-tab-button-style"
# use monospaced font in search entries for easier reading of regexp (#1907117)
style "geany-monospace" {
font_name = "Monospace"
}
widget "GeanyDialogSearch.*.GtkEntry" style "geany-monospace"
# set red background for GtkEntries showing unmatched searches
style "geany-search-entry-no-match-style" {
base[NORMAL] = "#ffff66666666"
text[NORMAL] = "#ffffffffffff"
}
widget "*.geany-search-entry-no-match" style "geany-search-entry-no-match-style"

View File

@ -535,17 +535,6 @@ static gboolean notebook_tab_bar_click_cb(GtkWidget *widget, GdkEventButton *eve
void notebook_init()
{
/* Individual style for the tab close buttons */
gtk_rc_parse_string(
"style \"geany-close-tab-button-style\" {\n"
" GtkWidget::focus-padding = 0\n"
" GtkWidget::focus-line-width = 0\n"
" xthickness = 0\n"
" ythickness = 0\n"
"}\n"
"widget \"*.geany-close-tab-button\" style \"geany-close-tab-button-style\""
);
g_signal_connect_after(main_widgets.notebook, "button-press-event",
G_CALLBACK(notebook_tab_bar_click_cb), NULL);

View File

@ -423,28 +423,6 @@ void search_find_selection(GeanyDocument *doc, gboolean search_backwards)
}
/* this will load a GTK rc style to set a monospace font for text fields(GtkEntry) in all
* search dialogs. This needs to be done only once.
* The monospace font should increase readibility of regular expressions containing spaces, points,
* commas and similar (#1907117). */
static void load_monospace_style(void)
{
static const gchar *rcstyle =
"style \"geany-monospace\"\n" \
"{\n" \
" font_name=\"Monospace\"\n" \
"}\n" \
"widget \"GeanyDialogSearch.*.GtkEntry\" style \"geany-monospace\"";
static gboolean load = TRUE;
if (load)
{
gtk_rc_parse_string(rcstyle);
load = FALSE;
}
}
static void on_expander_activated(GtkExpander *exp, gpointer data)
{
gboolean *setting = data;
@ -458,8 +436,6 @@ static void create_find_dialog(void)
GtkWidget *label, *entry, *sbox, *vbox;
GtkWidget *exp, *bbox, *button, *check_close;
load_monospace_style();
find_dlg.dialog = gtk_dialog_new_with_buttons(_("Find"),
GTK_WINDOW(main_widgets.window), GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_CLOSE, GTK_RESPONSE_CANCEL, NULL);
@ -614,8 +590,6 @@ static void create_replace_dialog(void)
*check_close, *button, *rbox, *fbox, *vbox, *exp, *bbox;
GtkSizeGroup *label_size;
load_monospace_style();
replace_dlg.dialog = gtk_dialog_new_with_buttons(_("Replace"),
GTK_WINDOW(main_widgets.window), GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_CLOSE, GTK_RESPONSE_CANCEL, NULL);
@ -865,8 +839,6 @@ static void create_fif_dialog(void)
gchar *encoding_string;
guint i;
load_monospace_style();
fif_dlg.dialog = gtk_dialog_new_with_buttons(
_("Find in Files"), GTK_WINDOW(main_widgets.window), GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL);

View File

@ -944,20 +944,7 @@ void ui_document_show_hide(GeanyDocument *doc)
void ui_set_search_entry_background(GtkWidget *widget, gboolean success)
{
static const GdkColor red = {0, 0xffff, 0x6666, 0x6666};
static const GdkColor white = {0, 0xffff, 0xffff, 0xffff};
static gboolean old_value = TRUE;
g_return_if_fail(widget != NULL);
/* update only if really needed */
if (old_value != success)
{
gtk_widget_modify_base(widget, GTK_STATE_NORMAL, success ? NULL : &red);
gtk_widget_modify_text(widget, GTK_STATE_NORMAL, success ? NULL : &white);
old_value = success;
}
gtk_widget_set_name(widget, success ? NULL : "geany-search-entry-no-match");
}
@ -2270,8 +2257,19 @@ void ui_init_builder(void)
}
static void init_custom_style(void)
{
gchar *gtkrc_file = g_build_filename(app->datadir, "geany.gtkrc", NULL);
gtk_rc_parse(gtkrc_file);
g_free(gtkrc_file);
}
void ui_init(void)
{
init_custom_style();
init_recent_files();
ui_widgets.statusbar = ui_lookup_widget(main_widgets.window, "statusbar");

View File

@ -485,6 +485,7 @@ def build(bld):
bld.install_files('${DATADIR}/%s' % data_dir, start_dir.ant_glob('filetype*'), cwd=start_dir)
bld.install_files('${DATADIR}/%s' % data_dir, start_dir.ant_glob('*.tags'), cwd=start_dir)
bld.install_files('${DATADIR}/%s' % data_dir, 'data/geany.glade')
bld.install_files('${DATADIR}/%s' % data_dir, 'data/geany.gtkrc')
bld.install_files('${DATADIR}/%s' % data_dir, 'data/snippets.conf')
bld.install_files('${DATADIR}/%s' % data_dir, 'data/ui_toolbar.xml')
start_dir = bld.path.find_dir('data/colorschemes')