[gnome-builder/wip/gtk4-port] libide/gui: allow toggling .flat from property
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port] libide/gui: allow toggling .flat from property
- Date: Mon, 16 May 2022 19:53:31 +0000 (UTC)
commit 74c8649a0cf4a361e1f511c511430b54a9b0d955
Author: Christian Hergert <chergert redhat com>
Date: Mon May 16 12:19:24 2022 -0700
libide/gui: allow toggling .flat from property
Since we can't really control the css-name/etc from workspace subclasses
as they don't control construction, just make this a bit easier to toggle.
src/libide/gui/ide-header-bar.c | 49 +++++++++++++++++++++++++++++++++++++++++
src/libide/gui/ide-header-bar.h | 5 +++++
2 files changed, 54 insertions(+)
---
diff --git a/src/libide/gui/ide-header-bar.c b/src/libide/gui/ide-header-bar.c
index fcab48110..5c2b32b47 100644
--- a/src/libide/gui/ide-header-bar.c
+++ b/src/libide/gui/ide-header-bar.c
@@ -36,10 +36,13 @@ typedef struct
GtkBox *left_of_center;
GtkBox *right;
GtkBox *right_of_center;
+
+ guint flat : 1;
} IdeHeaderBarPrivate;
enum {
PROP_0,
+ PROP_FLAT,
PROP_MENU_ID,
N_PROPS
};
@@ -75,6 +78,10 @@ ide_header_bar_get_property (GObject *object,
switch (prop_id)
{
+ case PROP_FLAT:
+ g_value_set_boolean (value, ide_header_bar_get_flat (self));
+ break;
+
case PROP_MENU_ID:
g_value_set_string (value, ide_header_bar_get_menu_id (self));
break;
@@ -94,6 +101,10 @@ ide_header_bar_set_property (GObject *object,
switch (prop_id)
{
+ case PROP_FLAT:
+ ide_header_bar_set_flat (self, g_value_get_boolean (value));
+ break;
+
case PROP_MENU_ID:
ide_header_bar_set_menu_id (self, g_value_get_string (value));
break;
@@ -113,6 +124,11 @@ ide_header_bar_class_init (IdeHeaderBarClass *klass)
object_class->get_property = ide_header_bar_get_property;
object_class->set_property = ide_header_bar_set_property;
+ properties [PROP_FLAT] =
+ g_param_spec_boolean ("flat", NULL, NULL,
+ FALSE,
+ (G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
+
properties [PROP_MENU_ID] =
g_param_spec_string ("menu-id",
"Menu ID",
@@ -405,3 +421,36 @@ ide_header_bar_remove (IdeHeaderBar *self,
g_warning ("Failed to locate widget of type %s within headerbar",
G_OBJECT_TYPE_NAME (widget));
}
+
+gboolean
+ide_header_bar_get_flat (IdeHeaderBar *self)
+{
+ IdeHeaderBarPrivate *priv = ide_header_bar_get_instance_private (self);
+
+ g_return_val_if_fail (IDE_IS_HEADER_BAR (self), FALSE);
+
+ return priv->flat;
+}
+
+void
+ide_header_bar_set_flat (IdeHeaderBar *self,
+ gboolean flat)
+{
+ IdeHeaderBarPrivate *priv = ide_header_bar_get_instance_private (self);
+
+ g_return_if_fail (IDE_IS_HEADER_BAR (self));
+
+ flat = !!flat;
+
+ if (priv->flat != flat)
+ {
+ priv->flat = flat;
+
+ if (flat)
+ gtk_widget_add_css_class (GTK_WIDGET (priv->header_bar), "flat");
+ else
+ gtk_widget_remove_css_class (GTK_WIDGET (priv->header_bar), "flat");
+
+ g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_FLAT]);
+ }
+}
diff --git a/src/libide/gui/ide-header-bar.h b/src/libide/gui/ide-header-bar.h
index c459d67d4..70d66915f 100644
--- a/src/libide/gui/ide-header-bar.h
+++ b/src/libide/gui/ide-header-bar.h
@@ -63,5 +63,10 @@ const char *ide_header_bar_get_menu_id (IdeHeaderBar *self);
IDE_AVAILABLE_IN_ALL
void ide_header_bar_set_menu_id (IdeHeaderBar *self,
const char *menu_id);
+IDE_AVAILABLE_IN_ALL
+gboolean ide_header_bar_get_flat (IdeHeaderBar *self);
+IDE_AVAILABLE_IN_ALL
+void ide_header_bar_set_flat (IdeHeaderBar *self,
+ gboolean flat);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]