See individual commits. Needs more testing. You can view, comment on, or merge this pull request online at:
https://github.com/geany/geany/pull/1382
-- Commit Summary --
* Improve GTK+3 theme loading * Add initial documentation for GTK+ CSS theming * Add geany.css file to the `Tools->Configuration Files` menu * Allow customizing message window using GTK+ themes * Improve GTK+3 CSS docs a bit
-- File Changes --
M data/Makefile.am (1) D data/geany-3.0.css (10) M data/geany-3.20.css (2) M data/geany.css (20) M data/geany.gtkrc (17) M doc/geany.txt (21) M src/msgwindow.c (53) M src/ui_utils.c (84)
-- Patch Links --
https://github.com/geany/geany/pull/1382.patch https://github.com/geany/geany/pull/1382.diff
@Rakksor does it look OK?
Yes, looks good, my only complaint would be that the documentation is only for the GTK3 version.
b4n commented on this pull request.
@@ -1,10 +0,0 @@
-@import "geany.css"; - -/* make close button on the editor's tabs smaller */ -#geany-close-tab-button { - -GtkWidget-focus-padding: 0; - -GtkWidget-focus-line-width: 0; - -GtkButton-default-border: 0; - -GtkButton-default-outside-border: 0; - -GtkButton-inner-border: 0; -}
IIUC this was conditional and not loaded on 3.20 because it was redundant, and would possibly lead to runtime deprecation warnings. Why drop it?
}
- g_object_unref(css); - g_free(css_file); -#else - /* see setup_gtk2_styles() in main.c */ + // if the user provided a geany.css file in their config dir, try and load that
Do we really need that? Isn't *~/.config/gtk-3.0/gtk.css* enough? AFAIK all our styles can easily be applied to Geany only, so I don't see why we'd need extra stuff?
@@ -494,6 +494,27 @@ An example of a simple ``.gtkrc-2.0``::
widget "GeanyPrefsDialog" style "geanyStyle"
+Customizing Geany's appearance using GTK+ 3 CSS +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +To override GTK+ CSS styles, you can use traditional mechanisms or you +can create a file named ``geany.css`` in the user configuration directory +(usually ``~/.config/geany``) which will be loaded after other CSS styles +are applied to allow overriding the default styles. + +Geany offers a number of CSS classes which can be overridden to taylor its
Those are CSS IDs (`#name`), not classes (`.name`)
@@ -83,6 +83,11 @@ enum
};
+static GdkColor color_error = {0, 65535, 0, 0}; +static GdkColor color_context = {0, 65535 / 2, 0, 0}; +static GdkColor color_message = {0, 0, 0, 0xD000};
different literals look odd, I'd rather use `0xFFFF` and `0x7FFF`
@@ -2097,7 +2097,9 @@ static void on_config_file_clicked(GtkWidget *widget, gpointer user_data)
if (g_file_test(global_file, G_FILE_TEST_EXISTS)) g_file_get_contents(global_file, &global_content, NULL, NULL);
- document_new_file(utf8_filename, ft, global_content); + // open or create the document and mark it as changed if it didn't already exist + GeanyDocument *doc = document_new_file(utf8_filename, ft, global_content); + document_set_text_changed(doc, ! g_file_test(file_name, G_FILE_TEST_EXISTS));
Why? saving an empty file, or a copy of the system version, doesn't seem to useful?
@@ -36,6 +36,17 @@
color: #007f00; }
+/* compiler message colors */ +#geany-compiler-error { + color: #ff0000; +} +#geany-compiler-context { + color: #880000;
shouldn't that be `0x7f0000` to be the same as the hardcoded one? Not that it matters too much though, I don't imagine anybody will really see the difference
@@ -50,5 +50,22 @@ widget "*.geany-document-status-changed" style "geany-document-status-changed-st
widget "*.geany-document-status-disk-changed" style "geany-document-status-disk-changed-style" widget "*.geany-document-status-readonly" style "geany-document-status-readonly-style"
+# compiler message colors +style "geany-compiler-error-style" { + fg[NORMAL] = "#ffff00000000" + fg[ACTIVE] = "#ffff00000000" +} +style "geany-compiler-context-style" { + fg[NORMAL] = "#888800000000" + fg[ACTIVE] = "#888800000000"
same pickyness than for the GTK3 variant, for me `65535 / 2` is `7fff`
switch (msg_color)
{ case COLOR_RED: return &color_error; - case COLOR_DARK_RED: return &dark_red; - case COLOR_BLUE: return &blue; + case COLOR_DARK_RED: return &color_context; + case COLOR_BLUE: return &color_message;
We really should rename those color names someday to something semantic. But well.
@@ -83,6 +83,11 @@ enum
};
+static GdkColor color_error = {0, 65535, 0, 0}; +static GdkColor color_context = {0, 65535 / 2, 0, 0}; +static GdkColor color_message = {0, 0, 0, 0xD000};
OK I see it comes from the old code. Well, as you want then, but could be the occasion to make that less odd :)
b4n commented on this pull request.
@@ -1,10 +0,0 @@
-@import "geany.css"; - -/* make close button on the editor's tabs smaller */ -#geany-close-tab-button { - -GtkWidget-focus-padding: 0; - -GtkWidget-focus-line-width: 0; - -GtkButton-default-border: 0; - -GtkButton-default-outside-border: 0; - -GtkButton-inner-border: 0; -}
Okay apparently GTK 3.22 doesn't complain.
Still, I'm not sure this whole "load geany.css from user's dir" makes much sense to me.
codebrainz commented on this pull request.
@@ -36,6 +36,17 @@
color: #007f00; }
+/* compiler message colors */ +#geany-compiler-error { + color: #ff0000; +} +#geany-compiler-context { + color: #880000;
This is the commit from #1381, I just imported into this PR.
codebrainz commented on this pull request.
@@ -50,5 +50,22 @@ widget "*.geany-document-status-changed" style "geany-document-status-changed-st
widget "*.geany-document-status-disk-changed" style "geany-document-status-disk-changed-style" widget "*.geany-document-status-readonly" style "geany-document-status-readonly-style"
+# compiler message colors +style "geany-compiler-error-style" { + fg[NORMAL] = "#ffff00000000" + fg[ACTIVE] = "#ffff00000000" +} +style "geany-compiler-context-style" { + fg[NORMAL] = "#888800000000" + fg[ACTIVE] = "#888800000000"
From #1381 also.
codebrainz commented on this pull request.
@@ -494,6 +494,27 @@ An example of a simple ``.gtkrc-2.0``::
widget "GeanyPrefsDialog" style "geanyStyle"
+Customizing Geany's appearance using GTK+ 3 CSS +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +To override GTK+ CSS styles, you can use traditional mechanisms or you +can create a file named ``geany.css`` in the user configuration directory +(usually ``~/.config/geany``) which will be loaded after other CSS styles +are applied to allow overriding the default styles. + +Geany offers a number of CSS classes which can be overridden to taylor its
Oops, been too long since I've touched CSS.
codebrainz commented on this pull request.
@@ -83,6 +83,11 @@ enum
};
+static GdkColor color_error = {0, 65535, 0, 0}; +static GdkColor color_context = {0, 65535 / 2, 0, 0}; +static GdkColor color_message = {0, 0, 0, 0xD000};
From #1381
codebrainz commented on this pull request.
switch (msg_color)
{ case COLOR_RED: return &color_error; - case COLOR_DARK_RED: return &dark_red; - case COLOR_BLUE: return &blue; + case COLOR_DARK_RED: return &color_context; + case COLOR_BLUE: return &color_message;
+1
codebrainz commented on this pull request.
@@ -2097,7 +2097,9 @@ static void on_config_file_clicked(GtkWidget *widget, gpointer user_data)
if (g_file_test(global_file, G_FILE_TEST_EXISTS)) g_file_get_contents(global_file, &global_content, NULL, NULL);
- document_new_file(utf8_filename, ft, global_content); + // open or create the document and mark it as changed if it didn't already exist + GeanyDocument *doc = document_new_file(utf8_filename, ft, global_content); + document_set_text_changed(doc, ! g_file_test(file_name, G_FILE_TEST_EXISTS));
It feels weird that when you click one of the configuration file items, it generates you a new file with a path into home dir but you cannot see the file on the file system or save it unless you make a change. You shouldn't be able to have a open a file that doesn't exist on disk yet and close it without getting asked what to do, IMO.
For the CSS file, it doesn't matter if it's just a blank file, it gets applied after the system one(s) and if it's blank it will do nothing. For other config files if you clicked it by accident, you just discard the file instead of going hunting for a file which doesn't actually exist on disk despite it being open in Geany with a file name.
codebrainz commented on this pull request.
@@ -1,10 +0,0 @@
-@import "geany.css"; - -/* make close button on the editor's tabs smaller */ -#geany-close-tab-button { - -GtkWidget-focus-padding: 0; - -GtkWidget-focus-line-width: 0; - -GtkButton-default-border: 0; - -GtkButton-default-outside-border: 0; - -GtkButton-inner-border: 0; -}
Using `~/.config/gtk-3.0/gtk.css`, how do you make all the gtkpaned splitters wider or make the statusbar background colour pink, just in Geany without affecting other applications? Using the global gtk.css would only allow you to tweak Geany's named IDs without affecting other applications, any other changes will affect all GTK+ apps.
The only other way is quite a bit complicated, involving custom GTK+ themes applied to Geany alone using environment variables to override the theme, AFAICT.
b4n commented on this pull request.
@@ -1,10 +0,0 @@
-@import "geany.css"; - -/* make close button on the editor's tabs smaller */ -#geany-close-tab-button { - -GtkWidget-focus-padding: 0; - -GtkWidget-focus-line-width: 0; - -GtkButton-default-border: 0; - -GtkButton-default-outside-border: 0; - -GtkButton-inner-border: 0; -}
We provide custom names for all our windows just for that https://www.geany.org/manual/#defining-own-widget-styles-using-gtkrc-2-0
So you can do, for your suggested yellow button text in the prefs dialog: ```css #GeanyDialogPrefs button { color: yellow; } ``` So long as no other app name something "GeanyDialogPrefs", nothing else will be affected. We have this for a long time just for this purpose -- style Geany and nothing else.
b4n commented on this pull request.
@@ -2097,7 +2097,9 @@ static void on_config_file_clicked(GtkWidget *widget, gpointer user_data)
if (g_file_test(global_file, G_FILE_TEST_EXISTS)) g_file_get_contents(global_file, &global_content, NULL, NULL);
- document_new_file(utf8_filename, ft, global_content); + // open or create the document and mark it as changed if it didn't already exist + GeanyDocument *doc = document_new_file(utf8_filename, ft, global_content); + document_set_text_changed(doc, ! g_file_test(file_name, G_FILE_TEST_EXISTS));
Well, I don't mind too much, but I don't really see how it's a big deal. But okay if you feel strongly.
b4n commented on this pull request.
@@ -83,6 +83,11 @@ enum
};
+static GdkColor color_error = {0, 65535, 0, 0}; +static GdkColor color_context = {0, 65535 / 2, 0, 0}; +static GdkColor color_message = {0, 0, 0, 0xD000};
Oh. I didn't check that one as you had done another "superseding" one by the time I checked anything. Still applies though :)
codebrainz commented on this pull request.
@@ -1,10 +0,0 @@
-@import "geany.css"; - -/* make close button on the editor's tabs smaller */ -#geany-close-tab-button { - -GtkWidget-focus-padding: 0; - -GtkWidget-focus-line-width: 0; - -GtkButton-default-border: 0; - -GtkButton-default-outside-border: 0; - -GtkButton-inner-border: 0; -}
Ok, now show how you'd make the text in Geany's open dialog larger.
b4n commented on this pull request.
@@ -1,10 +0,0 @@
-@import "geany.css"; - -/* make close button on the editor's tabs smaller */ -#geany-close-tab-button { - -GtkWidget-focus-padding: 0; - -GtkWidget-focus-line-width: 0; - -GtkButton-default-border: 0; - -GtkButton-default-outside-border: 0; - -GtkButton-inner-border: 0; -}
Okay, you can't apparently, as we don't seem to set the `GeanyDialog` name on it. So well, ok I guess, point taken. Not that I can imagine any single good reason why one would want to style differently the very same dialog, but well.
b4n commented on this pull request.
@@ -1,10 +0,0 @@
-@import "geany.css"; - -/* make close button on the editor's tabs smaller */ -#geany-close-tab-button { - -GtkWidget-focus-padding: 0; - -GtkWidget-focus-line-width: 0; - -GtkButton-default-border: 0; - -GtkButton-default-outside-border: 0; - -GtkButton-inner-border: 0; -}
If I wanted to be somewhat unfair, give me a snippet that styles only the file open fialog in all GTK apps :)
b4n commented on this pull request.
@@ -2566,6 +2582,10 @@ void ui_init(void)
ui_init_toolbar_widgets(); init_document_widgets(); create_config_files_menu(); + + // after UI is initialized, apply user's custom CSS (if it exists) + // to override other CSS styles + init_user_style();
why do it after? loading order shouldn't matter, only priority
codebrainz commented on this pull request.
@@ -1,10 +0,0 @@
-@import "geany.css"; - -/* make close button on the editor's tabs smaller */ -#geany-close-tab-button { - -GtkWidget-focus-padding: 0; - -GtkWidget-focus-line-width: 0; - -GtkButton-default-border: 0; - -GtkButton-default-outside-border: 0; - -GtkButton-inner-border: 0; -}
I don't know specifically about file dialogs with the open file action, since GTK+'s CSS documentation is garbage, I don't even know where to look to find special stuff on a per-widget basis, but to do what I originally meant, style the file chooser for which we have no custom ID, it would just be:
```css GtkFileChooserDialog { font-size: x-large; } ```
b4n commented on this pull request.
@@ -1,10 +0,0 @@
-@import "geany.css"; - -/* make close button on the editor's tabs smaller */ -#geany-close-tab-button { - -GtkWidget-focus-padding: 0; - -GtkWidget-focus-line-width: 0; - -GtkButton-default-border: 0; - -GtkButton-default-outside-border: 0; - -GtkButton-inner-border: 0; -}
@codebrainz that doesn't work wit hGTK >= 3.20; widget class names aren't user anymore.
codebrainz commented on this pull request.
@@ -1,10 +0,0 @@
-@import "geany.css"; - -/* make close button on the editor's tabs smaller */ -#geany-close-tab-button { - -GtkWidget-focus-padding: 0; - -GtkWidget-focus-line-width: 0; - -GtkButton-default-border: 0; - -GtkButton-default-outside-border: 0; - -GtkButton-inner-border: 0; -}
Lovely, they really like to break stuff in GTK+ don't they :)
(I only tested on my 3.18)
b4n commented on this pull request.
@@ -1,10 +0,0 @@
-@import "geany.css"; - -/* make close button on the editor's tabs smaller */ -#geany-close-tab-button { - -GtkWidget-focus-padding: 0; - -GtkWidget-focus-line-width: 0; - -GtkButton-default-border: 0; - -GtkButton-default-outside-border: 0; - -GtkButton-inner-border: 0; -}
Well, anyway. If you really think there's a point in application-specific theming (and that it's not implemented generically in GTK :]), I don't mind so much. I just don't really like the loss of flexibility we had on version-specific files (as yeah, GTK 3.20 changed everything), but well, let's hope they didn't break anything else, and that there's nothing we might ever need on < 3.20 that break >= 3.20.
codebrainz commented on this pull request.
@@ -1,10 +0,0 @@
-@import "geany.css"; - -/* make close button on the editor's tabs smaller */ -#geany-close-tab-button { - -GtkWidget-focus-padding: 0; - -GtkWidget-focus-line-width: 0; - -GtkButton-default-border: 0; - -GtkButton-default-outside-border: 0; - -GtkButton-inner-border: 0; -}
It's not really a loss of flexibility, I just saw the opportunity to remove one redundant file. If something else comes up, we can add other CSS files and load them conditionally based on version, like is done for 3.20. The main improvement is that it's now using the Cascading effect instead of relying on `@import`ing another file.
b4n commented on this pull request.
@@ -1,10 +0,0 @@
-@import "geany.css"; - -/* make close button on the editor's tabs smaller */ -#geany-close-tab-button { - -GtkWidget-focus-padding: 0; - -GtkWidget-focus-line-width: 0; - -GtkButton-default-border: 0; - -GtkButton-default-outside-border: 0; - -GtkButton-inner-border: 0; -}
Lovely, they really like to break stuff in GTK+ don't they :)
I guess. Funniest thing is that as a result (I guess?) it makes derived widgets not inherit the theme if they do set the name of their "style name". So if you derive from `GtkButton` but set the name to "mybutton", you won't inherit the theme from "button". And I'm not sure, but I don't think there is another way to allow specific theming apart adding custom style classes. But who knows, they might change that in the future, breaking many apps in the process :)
codebrainz commented on this pull request.
@@ -2566,6 +2582,10 @@ void ui_init(void)
ui_init_toolbar_widgets(); init_document_widgets(); create_config_files_menu(); + + // after UI is initialized, apply user's custom CSS (if it exists) + // to override other CSS styles + init_user_style();
Originally I had it all done at the same time but it didn't work. I suspect we setup something in the intervening code that is required. If you're going to test this PR, just try moving `init_user_style` directly under `init_default_style` and it should be reproduced.
b4n commented on this pull request.
@@ -1,10 +0,0 @@
-@import "geany.css"; - -/* make close button on the editor's tabs smaller */ -#geany-close-tab-button { - -GtkWidget-focus-padding: 0; - -GtkWidget-focus-line-width: 0; - -GtkButton-default-border: 0; - -GtkButton-default-outside-border: 0; - -GtkButton-inner-border: 0; -}
If something else comes up, we can add other CSS files and load them conditionally based on version, like is done for 3.20.
Mmyeah indeed, fair point. Although it does make it a bit more complex adding specifics; before you could `@import` e.g. 3.0 into 3.18 but not into 3.20, and decide that in the 3.18-specific file, not inside the code.
codebrainz commented on this pull request.
@@ -2566,6 +2582,10 @@ void ui_init(void)
ui_init_toolbar_widgets(); init_document_widgets(); create_config_files_menu(); + + // after UI is initialized, apply user's custom CSS (if it exists) + // to override other CSS styles + init_user_style();
@b4n ah, right, it was this:
``` Geany-INFO: Using alternate configuration directory Geany-INFO: Geany 1.30 (git >= 30a8921), en_CA.UTF-8 Geany-INFO: GTK 3.18.9, GLib 2.48.2 Geany-INFO: System data dir: /opt/geany/share/geany Geany-INFO: User config dir: /tmp/gtkcsstestconfig Geany-INFO: Loaded GTK+ CSS theme '/opt/geany/share/geany/geany.css'
(geany:27568): Gtk-CRITICAL **: gtk_container_add: assertion 'GTK_IS_CONTAINER (container)' failed Geany-INFO: System plugin path: /opt/geany/lib/geany Geany-INFO: Added filetype JSON (61). Geany-INFO: Added filetype Cython (62). Geany-INFO: Added filetype Scala (63). Geany-INFO: Added filetype CUDA (64). Geany-INFO: Added filetype Genie (65). Geany-INFO: Added filetype Clojure (66). Geany-INFO: Added filetype Graphviz (67). Geany-INFO: Added filetype Arduino (68). Geany-INFO: Loaded libvte from libvte-2.91.so Geany-INFO: unknown : None (UTF-8) ```
I could figure it out, but doing it after fixes this.
b4n commented on this pull request.
@@ -1,10 +0,0 @@
-@import "geany.css"; - -/* make close button on the editor's tabs smaller */ -#geany-close-tab-button { - -GtkWidget-focus-padding: 0; - -GtkWidget-focus-line-width: 0; - -GtkButton-default-border: 0; - -GtkButton-default-outside-border: 0; - -GtkButton-inner-border: 0; -}
Okay apparently GTK 3.22 doesn't complain.
My bad, I mistested. GTK 3.22 complains a lot: ```console (geany:20553): Gtk-WARNING **: Theme parsing error: geany.css:57:27: The style property GtkWidget:focus-padding is deprecated and shouldn't be used anymore. It will be removed in a future version
(geany:20553): Gtk-WARNING **: Theme parsing error: geany.css:58:30: The style property GtkWidget:focus-line-width is deprecated and shouldn't be used anymore. It will be removed in a future version
(geany:20553): Gtk-WARNING **: Theme parsing error: geany.css:59:28: The style property GtkButton:default-border is deprecated and shouldn't be used anymore. It will be removed in a future version
(geany:20553): Gtk-WARNING **: Theme parsing error: geany.css:60:36: The style property GtkButton:default-outside-border is deprecated and shouldn't be used anymore. It will be removed in a future version
(geany:20553): Gtk-WARNING **: Theme parsing error: geany.css:61:26: The style property GtkButton:inner-border is deprecated and shouldn't be used anymore. It will be removed in a future version ```
b4n commented on this pull request.
@@ -2097,7 +2097,9 @@ static void on_config_file_clicked(GtkWidget *widget, gpointer user_data)
if (g_file_test(global_file, G_FILE_TEST_EXISTS)) g_file_get_contents(global_file, &global_content, NULL, NULL);
- document_new_file(utf8_filename, ft, global_content); + // open or create the document and mark it as changed if it didn't already exist + GeanyDocument *doc = document_new_file(utf8_filename, ft, global_content); + document_set_text_changed(doc, ! g_file_test(file_name, G_FILE_TEST_EXISTS));
For the CSS file, it doesn't matter if it's just a blank file, it gets applied after the system one(s) and if it's blank it will do nothing. […]
The thing is that by default Geany fills up the file with the system version's content. So if you save that, it'll overwrite the system forever. Actually we probably shouldn't suggest to overwrite everything, although it's a fairly good thing to give an example of what the file should contain…
b4n commented on this pull request.
@@ -2566,6 +2582,10 @@ void ui_init(void)
ui_init_toolbar_widgets(); init_document_widgets(); create_config_files_menu(); + + // after UI is initialized, apply user's custom CSS (if it exists) + // to override other CSS styles + init_user_style();
Ah, it's because you call `ui_add_config_file_menu_item()` in the same function, which relies on the menu to exist.
codebrainz commented on this pull request.
@@ -2566,6 +2582,10 @@ void ui_init(void)
ui_init_toolbar_widgets(); init_document_widgets(); create_config_files_menu(); + + // after UI is initialized, apply user's custom CSS (if it exists) + // to override other CSS styles + init_user_style();
I really dislike the way items are added to that menu, a bunch of scattered calls mixed in to all kinds of different modules, each calling that function in a different way. It would be nice to move this to Glade or at least have a single location that populates the menu (which could itself be in glade at least).
codebrainz commented on this pull request.
@@ -1,10 +0,0 @@
-@import "geany.css"; - -/* make close button on the editor's tabs smaller */ -#geany-close-tab-button { - -GtkWidget-focus-padding: 0; - -GtkWidget-focus-line-width: 0; - -GtkButton-default-border: 0; - -GtkButton-default-outside-border: 0; - -GtkButton-inner-border: 0; -}
Bummer, so yet another place GTK+ CSS fails to be like real CSS :(
I will fix the PR.
codebrainz commented on this pull request.
@@ -2097,7 +2097,9 @@ static void on_config_file_clicked(GtkWidget *widget, gpointer user_data)
if (g_file_test(global_file, G_FILE_TEST_EXISTS)) g_file_get_contents(global_file, &global_content, NULL, NULL);
- document_new_file(utf8_filename, ft, global_content); + // open or create the document and mark it as changed if it didn't already exist + GeanyDocument *doc = document_new_file(utf8_filename, ft, global_content); + document_set_text_changed(doc, ! g_file_test(file_name, G_FILE_TEST_EXISTS));
Ah my bad, I was trying to make it open a new blank CSS file with the correct filename. I agree we shouldn't pre-populate with everything, it'd be better to just put a comment in them like:
Customize this file to override the system default file. See `$prefix/share/geany/whatever.file` for examples of what can go here
b4n commented on this pull request.
@@ -2097,7 +2097,9 @@ static void on_config_file_clicked(GtkWidget *widget, gpointer user_data)
if (g_file_test(global_file, G_FILE_TEST_EXISTS)) g_file_get_contents(global_file, &global_content, NULL, NULL);
- document_new_file(utf8_filename, ft, global_content); + // open or create the document and mark it as changed if it didn't already exist + GeanyDocument *doc = document_new_file(utf8_filename, ft, global_content); + document_set_text_changed(doc, ! g_file_test(file_name, G_FILE_TEST_EXISTS));
Yeah that would be better.
BTW, I tested your changes, and was annoyed to have to answer even though I didn't modify the file :) It's just as weird to open modified files, don't you think? :]
codebrainz commented on this pull request.
@@ -2097,7 +2097,9 @@ static void on_config_file_clicked(GtkWidget *widget, gpointer user_data)
if (g_file_test(global_file, G_FILE_TEST_EXISTS)) g_file_get_contents(global_file, &global_content, NULL, NULL);
- document_new_file(utf8_filename, ft, global_content); + // open or create the document and mark it as changed if it didn't already exist + GeanyDocument *doc = document_new_file(utf8_filename, ft, global_content); + document_set_text_changed(doc, ! g_file_test(file_name, G_FILE_TEST_EXISTS));
It's not opening an existing file, it's creating a new unsaved file.
b4n commented on this pull request.
@@ -2097,7 +2097,9 @@ static void on_config_file_clicked(GtkWidget *widget, gpointer user_data)
if (g_file_test(global_file, G_FILE_TEST_EXISTS)) g_file_get_contents(global_file, &global_content, NULL, NULL);
- document_new_file(utf8_filename, ft, global_content); + // open or create the document and mark it as changed if it didn't already exist + GeanyDocument *doc = document_new_file(utf8_filename, ft, global_content); + document_set_text_changed(doc, ! g_file_test(file_name, G_FILE_TEST_EXISTS));
Yeah OK. But I didn't touch it nonetheless, why would I car about the "changes"? Just saying I find it more annoying than practical, but I don't really mind either way either.
codebrainz commented on this pull request.
@@ -2097,7 +2097,9 @@ static void on_config_file_clicked(GtkWidget *widget, gpointer user_data)
if (g_file_test(global_file, G_FILE_TEST_EXISTS)) g_file_get_contents(global_file, &global_content, NULL, NULL);
- document_new_file(utf8_filename, ft, global_content); + // open or create the document and mark it as changed if it didn't already exist + GeanyDocument *doc = document_new_file(utf8_filename, ft, global_content); + document_set_text_changed(doc, ! g_file_test(file_name, G_FILE_TEST_EXISTS));
You did touch it, you asked Geany to generate you a new file. How does it make sense to have a file open in Geany that has a path, has contents that aren't saved to disk, and yet if you close Geany the file vapourizes into thin air?
b4n commented on this pull request.
@@ -2097,7 +2097,9 @@ static void on_config_file_clicked(GtkWidget *widget, gpointer user_data)
if (g_file_test(global_file, G_FILE_TEST_EXISTS)) g_file_get_contents(global_file, &global_content, NULL, NULL);
- document_new_file(utf8_filename, ft, global_content); + // open or create the document and mark it as changed if it didn't already exist + GeanyDocument *doc = document_new_file(utf8_filename, ft, global_content); + document_set_text_changed(doc, ! g_file_test(file_name, G_FILE_TEST_EXISTS));
I didn't really ask to create it, but to open it. And if there is data (actually, there shouldn't, as mentioned) it comes from somewhere already if I didn't write it myself, so why would I care about it? For all I care it opened a file. Agreed it's somewhat "magical", but the whole menu is, it's not merely opening the file.
Anyway, again I don't really mind, and can see your point technically, I just think it's not practically useful, and I fear getting a lot more users with modified configuration when the didn't mean to.
codebrainz commented on this pull request.
@@ -2097,7 +2097,9 @@ static void on_config_file_clicked(GtkWidget *widget, gpointer user_data)
if (g_file_test(global_file, G_FILE_TEST_EXISTS)) g_file_get_contents(global_file, &global_content, NULL, NULL);
- document_new_file(utf8_filename, ft, global_content); + // open or create the document and mark it as changed if it didn't already exist + GeanyDocument *doc = document_new_file(utf8_filename, ft, global_content); + document_set_text_changed(doc, ! g_file_test(file_name, G_FILE_TEST_EXISTS));
Maybe I should just take it out of this PR, since it's kind of tangential. Another PR could deal with this and also not filling in the files with all the contents of system files.
@codebrainz pushed 3 commits.
92bfbfe Go back to conditionally loading geany-3.0.css be44ce8 Don't mark unedited config files as changed 1b45a25 Fix misuse of CSS ID vs class in manual
Updated based on discussions/feedback.
@codebrainz pushed 1 commit.
0bb5b7f Minor colour value tweaks
b4n commented on this pull request.
@@ -56,8 +56,8 @@ style "geany-compiler-error-style" {
fg[ACTIVE] = "#ffff00000000" } style "geany-compiler-context-style" { - fg[NORMAL] = "#888800000000" - fg[ACTIVE] = "#888800000000" + fg[NORMAL] = "#7f7f00000000" + fg[ACTIVE] = "#7f7f00000000"
Odd choice? AFAIK these are 3 16bits values, not 6 8bits ones. (BTW, AFAIK it's also possible to use the short 8bit values instead of the 16bits ones)
@@ -494,6 +494,27 @@ An example of a simple ``.gtkrc-2.0``::
widget "GeanyPrefsDialog" style "geanyStyle"
+Customizing Geany's appearance using GTK+ 3 CSS +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +To override GTK+ CSS styles, you can use traditional mechanisms or you +can create a file named ``geany.css`` in the user configuration directory +(usually ``~/.config/geany``) which will be loaded after other CSS styles
might be interesting linking http://www.geany.org/manual/#configuration-file-paths
@@ -112,6 +117,40 @@ void msgwin_set_messages_dir(const gchar *messages_dir)
}
+GdkColor load_color(gchar *color_name) {
could this avoid returning an aggregate and "return" through an arg? Yeah I know it's valid C and all, but it's copying at least twice the data (well, 12 instead of 8 bytes on a Linux 64), and it's common to return "by reference" (don't lynch me :]) in such cases. I don't mind *so* much, but I build with `-Waggregate-return` -- and yeah, it *did* spot some meaningful issue once or twice (ok, in other ppl's code generally, but still)
- theme_fn = g_build_filename(app->datadir, "geany.css", NULL);
+ load_css_theme(theme_fn, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + g_free(theme_fn); + + // load themes to handle breakage between various GTK+ versions + const struct + { + guint min_version; + guint max_version; + const gchar *file; + } + css_files[] = + { + { 20, G_MAXUINT, "geany-3.20.css" }, + { 0, 19, "geany-3.0.css" }, + };
Any reason why you still change how it's loaded? I don't really mind both seem OK, but AFAIK there's no more point in changing it, and I fairly like the in-CSS flexibility of the `@import`. No biggie though.
More generally I still don't really like/understand why we need the `$configdir/geany.css` stuff, as the only use case for it seems to style GTK stock dialogs differently inside Geany only (which seems an artificial need, but well), and that IMO it makes more sense to let user use the GTK-provided facility for that. They can always `@import` their secondary files from *~/.config/gtk-3.0/gtk.css* if they want to have nice splitting or something.
BTW, if we really want to load a geany-specific user-specific theme, we probably want to do the same for GTK2 I guess.
elextr commented on this pull request.
@@ -112,6 +117,40 @@ void msgwin_set_messages_dir(const gchar *messages_dir)
}
+GdkColor load_color(gchar *color_name) {
IIUC standard x86-64 ABI says up to 16 bytes can be returned in 2 registers, so probably no real copying takes place.
codebrainz commented on this pull request.
@@ -56,8 +56,8 @@ style "geany-compiler-error-style" {
fg[ACTIVE] = "#ffff00000000" } style "geany-compiler-context-style" { - fg[NORMAL] = "#888800000000" - fg[ACTIVE] = "#888800000000" + fg[NORMAL] = "#7f7f00000000" + fg[ACTIVE] = "#7f7f00000000"
I just went in python and did `hex(int((0x7f/255.0)*65536))` to scale from 8-bit to 16-bit. Would be better to use 8-bit HTML-style notation, if supported.
codebrainz commented on this pull request.
@@ -494,6 +494,27 @@ An example of a simple ``.gtkrc-2.0``::
widget "GeanyPrefsDialog" style "geanyStyle"
+Customizing Geany's appearance using GTK+ 3 CSS +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +To override GTK+ CSS styles, you can use traditional mechanisms or you +can create a file named ``geany.css`` in the user configuration directory +(usually ``~/.config/geany``) which will be loaded after other CSS styles
What is the syntax in this markup language for linking?
codebrainz commented on this pull request.
@@ -112,6 +117,40 @@ void msgwin_set_messages_dir(const gchar *messages_dir)
}
+GdkColor load_color(gchar *color_name) {
I don't mind either way and didn't write this, let me know which way you want.
codebrainz commented on this pull request.
- theme_fn = g_build_filename(app->datadir, "geany.css", NULL);
+ load_css_theme(theme_fn, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + g_free(theme_fn); + + // load themes to handle breakage between various GTK+ versions + const struct + { + guint min_version; + guint max_version; + const gchar *file; + } + css_files[] = + { + { 20, G_MAXUINT, "geany-3.20.css" }, + { 0, 19, "geany-3.0.css" }, + };
Not a particularly strong reason (other than avoiding `@import`ing files into each other). I was going to put it back exactly like before, but this seems just as flexible.
More generally I still don't really like/understand why we need the $configdir/geany.css stuff, as the only use case for it seems to style GTK stock dialogs differently inside Geany only (which seems an artificial need, but well)
That's just an example use-case (even if the only one), but the idea is that instead of us dictating what the user can style, they can just use normal CSS without being limited by stuff we happen to have given IDs too (or stuff below it). Also, the CSS doesn't require to make every selector contain `GeanyWhatever` or `geany-whatever`.
Finally, it's a completely trivial [4-lines of code](https://github.com/geany/geany/pull/1382/files#diff-4bbd8d1b91370dfb89a7e350...) to make it work and it doesn't prevent the user from using other mechanism/file (ex. `~/.config/gtk-3.0/gtk.css`) to style Geany.
IMO it makes more sense to let user use the GTK-provided facility for that
Why can't they if they want to?
BTW, if we really want to load a geany-specific user-specific theme, we probably want to do the same for GTK2 I guess.
Probably, or it could be a GTK+ 3-only feature.
b4n commented on this pull request.
@@ -112,6 +117,40 @@ void msgwin_set_messages_dir(const gchar *messages_dir)
}
+GdkColor load_color(gchar *color_name) {
I'd like return in parameter, please :)
b4n commented on this pull request.
- theme_fn = g_build_filename(app->datadir, "geany.css", NULL);
+ load_css_theme(theme_fn, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + g_free(theme_fn); + + // load themes to handle breakage between various GTK+ versions + const struct + { + guint min_version; + guint max_version; + const gchar *file; + } + css_files[] = + { + { 20, G_MAXUINT, "geany-3.20.css" }, + { 0, 19, "geany-3.0.css" }, + };
I like `@import`ing because it gives the flexibility when writing the style. But OTOH as we don't try and load `geany-$(gtk_version).css` new specific style mean code change, so I don't mind either.
I would revert it because I liked it and it proven itself working, but it you prefer it like that I fine with it too.
b4n commented on this pull request.
@@ -56,8 +56,8 @@ style "geany-compiler-error-style" {
fg[ACTIVE] = "#ffff00000000" } style "geany-compiler-context-style" { - fg[NORMAL] = "#888800000000" - fg[ACTIVE] = "#888800000000" + fg[NORMAL] = "#7f7f00000000" + fg[ACTIVE] = "#7f7f00000000"
I just went in python and did `hex(int((0x7f/255.0)*65535))` to scale from 8-bit to 16-bit.
Hence the precision loss :) ```pycon
hex(int(0xff/2))
'0x7f'
hex(int(0xffff/2))
'0x7fff'
hex(int(int(0x7fff*0xff/0xffff)/0xff*0xffff))
'0x7f7f' ```
Would be better to use 8-bit HTML-style notation, if supported.
I think it is supported, just use `"#7f0000"`
b4n commented on this pull request.
@@ -494,6 +494,27 @@ An example of a simple ``.gtkrc-2.0``::
widget "GeanyPrefsDialog" style "geanyStyle"
+Customizing Geany's appearance using GTK+ 3 CSS +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +To override GTK+ CSS styles, you can use traditional mechanisms or you +can create a file named ``geany.css`` in the user configuration directory +(usually ``~/.config/geany``) which will be loaded after other CSS styles
Good question… it's weird, but it seems to involve `__`: http://docutils.sourceforge.net/docs/user/rst/quickref.html#internal-hyperli... (see also `anonymous__` [in the *Inline markup* section](http://docutils.sourceforge.net/docs/user/rst/quickref.html#inline-markup)).
That's just an example use-case (even if the only one), but the idea is that instead of us dictating what the user can style, they can just use normal CSS without being limited by stuff we happen to have given IDs too (or stuff below it). Also, the CSS doesn't require to make every selector contain `GeanyWhatever` or `geany-whatever`.
Well, if you think it's worth it, OK.
IMO it makes more sense to let user use the GTK-provided facility for that
Why can't they if they want to?
I didn't mean to imply they couldn't, but that it was enough.
Probably, or it could be a GTK+ 3-only feature.
People might guess why, but as nobody will ever use it I guess it doesn't matter :)
Probably, or it could be a GTK+ 3-only feature.
Ok by me.
HybridDog commented on this pull request.
@@ -56,8 +56,8 @@ style "geany-compiler-error-style" {
fg[ACTIVE] = "#ffff00000000" } style "geany-compiler-context-style" { - fg[NORMAL] = "#888800000000" - fg[ACTIVE] = "#888800000000" + fg[NORMAL] = "#7f7f00000000" + fg[ACTIVE] = "#7f7f00000000"
screens can only display 8 bit truecolor anyway, can't they?
I guess the milestone should be upped here (and for various other open 1.31 PRs).
For the record, I have been using this patch with my build of Geany for about a week, and can confirm it works as described. My custom CSS file controls the colors of the compiler output tab properly, with no observable changes in any other behavior.
elextr approved this pull request.
Worked on GTK3 when I tried it.
Merged #1382.
I have merged this as is because:
1. It works for me and others
2. The remaining issues appear to only be stylistic in code and manual, they can be fixed later if "somebody" is interested enough
3. those who understand accessibility issues will understand that colour perception issues affect a significant proportion of the population, who have been unable to use dark themes due to hard coded colours whilst we bickered about code style
Just want to confirm since Unable to change compiler window font colors with themes, gtkrc, or css. #1737 was closed; I can edit the load_color colours in the compiler window in geany (gtk2) then?
@lulcat correct, should be in 1.33
github-comments@lists.geany.org