Permalink
Browse files

Move custom styles to a resource file

  • Loading branch information...
1 parent 3070738 commit eeddd6f720e1ded79beeec9203b698c9191de624 @b4n b4n committed Sep 29, 2012
Showing with 38 additions and 54 deletions.
  1. +2 −1 Makefile.am
  2. +23 −0 data/geany.gtkrc
  3. +0 −11 src/notebook.c
  4. +0 −28 src/search.c
  5. +12 −14 src/ui_utils.c
  6. +1 −0 wscript
View
@@ -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 \
View
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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')

0 comments on commit eeddd6f

Please sign in to comment.