[gtranslator] Custom styles in header to show devel built
- From: Daniel Garcia Moreno <danigm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtranslator] Custom styles in header to show devel built
- Date: Sun, 16 Sep 2018 08:28:26 +0000 (UTC)
commit 6a45040b6c58ca6bb6615f0395da0fd0554116e3
Author: Daniel GarcĂa Moreno <danigm wadobo com>
Date: Sun Sep 16 10:24:43 2018 +0200
Custom styles in header to show devel built
meson.build | 1 +
src/gtr-application.c | 22 +++++++++++++++++-----
src/gtranslator.gresource.xml | 1 +
src/styles.css | 11 +++++++++++
4 files changed, 30 insertions(+), 5 deletions(-)
---
diff --git a/meson.build b/meson.build
index b0163155..1195b6c9 100644
--- a/meson.build
+++ b/meson.build
@@ -74,6 +74,7 @@ set_defines = [
['PACKAGE_URL', 'https://wiki.gnome.org/Apps/Gtranslator'],
['PACKAGE_VERSION', gtranslator_version],
['VERSION', gtranslator_version],
+ ['PACKAGE_APPID', application_id],
['GETTEXT_PACKAGE', meson.project_name()]
]
diff --git a/src/gtr-application.c b/src/gtr-application.c
index 7f075820..f126940e 100644
--- a/src/gtr-application.c
+++ b/src/gtr-application.c
@@ -49,15 +49,11 @@
#include <gdk/gdkx.h>
#endif
-#define GTR_APPLICATION_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ( \
- (object), \
- GTR_TYPE_APPLICATION, \
- GtrApplicationPrivate))
-
typedef struct
{
GSettings *settings;
GSettings *window_settings;
+ GtkCssProvider *provider;
GtrWindow *active_window;
@@ -188,6 +184,10 @@ gtr_application_init (GtrApplication *application)
priv->first_run = TRUE;
g_free (profiles_file);
+ /* Custom css */
+ priv->provider = gtk_css_provider_new ();
+ gtk_css_provider_load_from_resource (priv->provider, "/org/gnome/translator/styles.css");
+
load_accels ();
}
@@ -199,6 +199,7 @@ gtr_application_dispose (GObject * object)
g_clear_object (&priv->settings);
g_clear_object (&priv->window_settings);
+ g_clear_object (&priv->provider);
G_OBJECT_CLASS (gtr_application_parent_class)->dispose (object);
}
@@ -423,6 +424,7 @@ static void
gtr_application_startup (GApplication *application)
{
GtkBuilder *builder;
+ GtrApplicationPrivate *priv = gtr_application_get_instance_private (application);
G_APPLICATION_CLASS (gtr_application_parent_class)->startup (application);
@@ -457,6 +459,9 @@ gtr_application_startup (GApplication *application)
gtk_application_set_app_menu (GTK_APPLICATION (application),
G_MENU_MODEL (gtk_builder_get_object (builder, "appmenu")));
g_object_unref (builder);
+
+ gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
+ GTK_STYLE_PROVIDER (priv->provider), 600);
}
static void
@@ -482,6 +487,13 @@ gtr_application_setup_window (GApplication *application,
window = gtr_application_create_window (GTR_APPLICATION (application));
gtk_application_add_window (GTK_APPLICATION (application), GTK_WINDOW (window));
+ /** loading custom styles **/
+ if (g_strrstr (PACKAGE_APPID, "Devel") != NULL)
+ {
+ GtkStyleContext *ctx = gtk_widget_get_style_context (GTK_WIDGET (window));
+ gtk_style_context_add_class (ctx, "devel");
+ }
+
/* If it is the first run, the default directory was created in this
* run, then we show the First run Assistant
*/
diff --git a/src/gtranslator.gresource.xml b/src/gtranslator.gresource.xml
index 355b7260..c9189e11 100644
--- a/src/gtranslator.gresource.xml
+++ b/src/gtranslator.gresource.xml
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/gnome/translator">
+ <file>styles.css</file>
<file preprocess="xml-stripblanks">gtranslator-ui.xml</file>
<file preprocess="xml-stripblanks">gtranslator-menu.ui</file>
<file preprocess="xml-stripblanks">gtr-context.ui</file>
diff --git a/src/styles.css b/src/styles.css
new file mode 100644
index 00000000..b922d85e
--- /dev/null
+++ b/src/styles.css
@@ -0,0 +1,11 @@
+.devel .titlebar {
+ background: transparent -gtk-icontheme("system-run-symbolic") 80% 0/128px 128px no-repeat,
+ linear-gradient(to left,
+ mix(@theme_selected_bg_color, @theme_bg_color, 0.5) 8%,
+ @theme_bg_color 25%);
+ color: alpha(@theme_fg_color, 0.1);
+}
+
+.devel .titlebar label {
+ color: @theme_fg_color;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]