summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Chimento <philip@endlessm.com>2015-12-16 00:02:46 -0800
committerPhilip Chimento <philip@endlessm.com>2015-12-16 00:02:46 -0800
commit5498390ba93922ea5977052068e81b42bf53cefc (patch)
treefcb9d76b7cc6aa6c1518b53e5caaa728571a6156
parentfef6ea4704c375876b844ade88b0a344e1cd9519 (diff)
Add composite CSS class to EosWindow
If an EosWindow is on a composite TV screen, then add the "composite" CSS class to it. Also add a constant, EOS_STYLE_CLASS_COMPOSITE. This allows us to do specific styling for composite. [endlessm/eos-sdk#3930]
-rw-r--r--docs/reference/endless/endless-sections.txt1
-rw-r--r--endless/eosmacros.h12
-rw-r--r--endless/eoswindow.c18
3 files changed, 27 insertions, 4 deletions
diff --git a/docs/reference/endless/endless-sections.txt b/docs/reference/endless/endless-sections.txt
index c543d42..7c96978 100644
--- a/docs/reference/endless/endless-sections.txt
+++ b/docs/reference/endless/endless-sections.txt
@@ -50,6 +50,7 @@ eos_window_set_font_scaling_default_window_size
eos_window_get_font_scaling_min_font_size
eos_window_set_font_scaling_min_font_size
eos_window_get_font_scaling_calculated_font_size
+EOS_STYLE_CLASS_COMPOSITE
<SUBSECTION Standard>
EosWindowClass
EOS_IS_WINDOW
diff --git a/endless/eosmacros.h b/endless/eosmacros.h
index 1dfa786..ba4b5f0 100644
--- a/endless/eosmacros.h
+++ b/endless/eosmacros.h
@@ -30,4 +30,16 @@ enum_type##_get_type (void) \
return g_define_type_id__volatile; \
}
+/**
+ * EOS_STYLE_CLASS_COMPOSITE:
+ *
+ * A CSS class to match a window on a composite TV.
+ *
+ * This is added to #EosWindow when it is detected to be on a composite TV
+ * screen.
+ *
+ * Since: 0.6
+ */
+#define EOS_STYLE_CLASS_COMPOSITE "composite"
+
#endif /* EOS_MACROS_H */
diff --git a/endless/eoswindow.c b/endless/eoswindow.c
index 75f213d..795d8c0 100644
--- a/endless/eoswindow.c
+++ b/endless/eoswindow.c
@@ -2,10 +2,7 @@
#include "config.h"
#include "string.h"
-#include "eoswindow.h"
-
-#include "eosapplication.h"
-#include "eospagemanager.h"
+#include "endless.h"
#include "eostopbar-private.h"
#include <gtk/gtk.h>
@@ -633,6 +630,16 @@ eos_window_class_init (EosWindowClass *klass)
}
static void
+update_screen (EosWindow *self)
+{
+ GtkStyleContext *context = gtk_widget_get_style_context (GTK_WIDGET (self));
+ if (eos_is_composite_tv_screen (gtk_window_get_screen (GTK_WINDOW (self))))
+ gtk_style_context_add_class (context, EOS_STYLE_CLASS_COMPOSITE);
+ else
+ gtk_style_context_remove_class (context, EOS_STYLE_CLASS_COMPOSITE);
+}
+
+static void
on_credits_clicked (GtkWidget *top_bar,
EosWindow *self)
{
@@ -669,6 +676,8 @@ eos_window_init (EosWindow *self)
{
EosWindowPrivate *priv = eos_window_get_instance_private (self);
+ update_screen (self);
+
priv->top_bar = eos_top_bar_new ();
gtk_widget_show_all (priv->top_bar);
gtk_window_set_titlebar (GTK_WINDOW (self), priv->top_bar);
@@ -730,6 +739,7 @@ eos_window_init (EosWindow *self)
g_signal_connect (priv->top_bar, "credits-clicked",
G_CALLBACK (on_credits_clicked), self);
+ g_signal_connect (self, "notify::screen", G_CALLBACK (update_screen), NULL);
eos_window_set_page_manager (self,
EOS_PAGE_MANAGER (eos_page_manager_new ()));