[gnome-panel/wip/muktupavels/alignment: 5/6] toplevel: add alignment setting
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel/wip/muktupavels/alignment: 5/6] toplevel: add alignment setting
- Date: Thu, 22 Apr 2021 09:46:15 +0000 (UTC)
commit 7e726900fc32c39f40e58c8f95d6024605a3eba5
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Wed Apr 21 17:15:08 2021 +0300
toplevel: add alignment setting
This setting will replace existing x, y, x-right, y-bottom,
x-centered and y-centered settings.
https://gitlab.gnome.org/GNOME/gnome-panel/-/merge_requests/9
data/org.gnome.gnome-panel.toplevel.gschema.xml | 5 +++
gnome-panel/panel-enums-gsettings.h | 6 +++
gnome-panel/panel-layout.c | 1 +
gnome-panel/panel-schemas.h | 1 +
gnome-panel/panel-toplevel.c | 52 +++++++++++++++++++++++++
5 files changed, 65 insertions(+)
---
diff --git a/data/org.gnome.gnome-panel.toplevel.gschema.xml b/data/org.gnome.gnome-panel.toplevel.gschema.xml
index 873549ad2..0f70e3ccb 100644
--- a/data/org.gnome.gnome-panel.toplevel.gschema.xml
+++ b/data/org.gnome.gnome-panel.toplevel.gschema.xml
@@ -20,6 +20,11 @@
<summary>Panel orientation</summary>
<description>The orientation of the panel. Possible values are "top", "bottom", "left", "right". In
expanded mode the key specifies which screen edge the panel is on. In un-expanded mode the difference between
"top" and "bottom" is less important - both indicate that this is a horizontal panel - but still give a
useful hint as to how some panel objects should behave. For example, on a "top" panel a menu button will pop
up its menu below the panel, whereas on a "bottom" panel the menu will be popped up above the
panel.</description>
</key>
+ <key name="alignment" enum="org.gnome.gnome-panel.PanelAlignment">
+ <default>'center'</default>
+ <summary>Panel alignment</summary>
+ <description>The alignment of the panel. Possible values are "start", "center", "end".</description>
+ </key>
<key name="size" type="i">
<default>24</default>
<summary>Panel size</summary>
diff --git a/gnome-panel/panel-enums-gsettings.h b/gnome-panel/panel-enums-gsettings.h
index 93f9fe3a3..40176fb50 100644
--- a/gnome-panel/panel-enums-gsettings.h
+++ b/gnome-panel/panel-enums-gsettings.h
@@ -43,6 +43,12 @@ typedef enum { /*< flags=0 >*/
#define PANEL_HORIZONTAL_MASK (PANEL_ORIENTATION_TOP | PANEL_ORIENTATION_BOTTOM)
#define PANEL_VERTICAL_MASK (PANEL_ORIENTATION_LEFT | PANEL_ORIENTATION_RIGHT)
+typedef enum {
+ PANEL_ALIGNMENT_START = 0,
+ PANEL_ALIGNMENT_CENTER = 1,
+ PANEL_ALIGNMENT_END = 2
+} PanelAlignment;
+
typedef enum {
PANEL_ANIMATION_SLOW = 0,
PANEL_ANIMATION_MEDIUM = 1,
diff --git a/gnome-panel/panel-layout.c b/gnome-panel/panel-layout.c
index 639c3051e..f7265743b 100644
--- a/gnome-panel/panel-layout.c
+++ b/gnome-panel/panel-layout.c
@@ -90,6 +90,7 @@ static PanelLayoutKeyDefinition panel_layout_toplevel_keys[] = {
{ PANEL_TOPLEVEL_MONITOR_KEY, G_TYPE_INT },
{ PANEL_TOPLEVEL_EXPAND_KEY, G_TYPE_BOOLEAN },
{ PANEL_TOPLEVEL_ORIENTATION_KEY, G_TYPE_STRING },
+ { PANEL_TOPLEVEL_ALIGNMENT_KEY, G_TYPE_INT },
{ PANEL_TOPLEVEL_SIZE_KEY, G_TYPE_INT },
{ PANEL_TOPLEVEL_X_KEY, G_TYPE_INT },
{ PANEL_TOPLEVEL_Y_KEY, G_TYPE_INT },
diff --git a/gnome-panel/panel-schemas.h b/gnome-panel/panel-schemas.h
index cbf28b300..d0ee8dcca 100644
--- a/gnome-panel/panel-schemas.h
+++ b/gnome-panel/panel-schemas.h
@@ -38,6 +38,7 @@
#define PANEL_TOPLEVEL_MONITOR_KEY "monitor"
#define PANEL_TOPLEVEL_EXPAND_KEY "expand"
#define PANEL_TOPLEVEL_ORIENTATION_KEY "orientation"
+#define PANEL_TOPLEVEL_ALIGNMENT_KEY "alignment"
#define PANEL_TOPLEVEL_SIZE_KEY "size"
#define PANEL_TOPLEVEL_X_KEY "x"
#define PANEL_TOPLEVEL_Y_KEY "y"
diff --git a/gnome-panel/panel-toplevel.c b/gnome-panel/panel-toplevel.c
index a5d7077a5..bf4b6fb14 100644
--- a/gnome-panel/panel-toplevel.c
+++ b/gnome-panel/panel-toplevel.c
@@ -89,6 +89,7 @@ struct _PanelToplevelPrivate {
gboolean expand;
PanelOrientation orientation;
+ PanelAlignment alignment;
int size;
/* relative to the monitor origin */
@@ -141,6 +142,7 @@ struct _PanelToplevelPrivate {
int orig_y_bottom;
int orig_size;
int orig_orientation;
+ PanelAlignment orig_alignment;
/* relative to the monitor origin */
int animation_end_x;
@@ -204,6 +206,7 @@ enum {
PROP_NAME,
PROP_EXPAND,
PROP_ORIENTATION,
+ PROP_ALIGNMENT,
PROP_SIZE,
PROP_X,
PROP_X_RIGHT,
@@ -243,6 +246,8 @@ static void panel_toplevel_set_monitor_internal (PanelToplevel *toplevel,
int monitor,
gboolean force_resize);
+static void panel_toplevel_apply_delayed_settings_queue (PanelToplevel *toplevel);
+
static void
update_style_classes (PanelToplevel *toplevel)
{
@@ -575,6 +580,7 @@ panel_toplevel_begin_grab_op (PanelToplevel *toplevel,
toplevel->priv->orig_y_centered = toplevel->priv->y_centered;
toplevel->priv->orig_size = toplevel->priv->size;
toplevel->priv->orig_orientation = toplevel->priv->orientation;
+ toplevel->priv->orig_alignment = toplevel->priv->alignment;
gtk_grab_add (widget);
@@ -623,11 +629,33 @@ panel_toplevel_end_grab_op (PanelToplevel *toplevel,
gdk_seat_ungrab (seat);
}
+static void
+panel_toplevel_set_alignment (PanelToplevel *toplevel,
+ PanelAlignment alignment)
+{
+ g_return_if_fail (PANEL_IS_TOPLEVEL (toplevel));
+
+ if (toplevel->priv->alignment == alignment)
+ return;
+
+ g_object_freeze_notify (G_OBJECT (toplevel));
+
+ toplevel->priv->alignment = alignment;
+
+ gtk_widget_queue_resize (GTK_WIDGET (toplevel));
+
+ panel_toplevel_apply_delayed_settings_queue (toplevel);
+ g_object_notify (G_OBJECT (toplevel), "alignment");
+
+ g_object_thaw_notify (G_OBJECT (toplevel));
+}
+
static void
panel_toplevel_cancel_grab_op (PanelToplevel *toplevel,
guint32 time_)
{
panel_toplevel_set_orientation (toplevel, toplevel->priv->orig_orientation);
+ panel_toplevel_set_alignment (toplevel, toplevel->priv->orig_alignment);
panel_toplevel_set_monitor (toplevel, toplevel->priv->orig_monitor);
panel_toplevel_set_size (toplevel, toplevel->priv->orig_size);
panel_toplevel_set_x (toplevel,
@@ -3250,6 +3278,9 @@ panel_toplevel_set_property (GObject *object,
case PROP_ORIENTATION:
panel_toplevel_set_orientation (toplevel, g_value_get_enum (value));
break;
+ case PROP_ALIGNMENT:
+ panel_toplevel_set_alignment (toplevel, g_value_get_enum (value));
+ break;
case PROP_SIZE:
panel_toplevel_set_size (toplevel, g_value_get_int (value));
break;
@@ -3347,6 +3378,9 @@ panel_toplevel_get_property (GObject *object,
case PROP_ORIENTATION:
g_value_set_enum (value, toplevel->priv->orientation);
break;
+ case PROP_ALIGNMENT:
+ g_value_set_enum (value, toplevel->priv->alignment);
+ break;
case PROP_SIZE:
g_value_set_int (value, toplevel->priv->size);
break;
@@ -3541,6 +3575,17 @@ panel_toplevel_class_init (PanelToplevelClass *klass)
PANEL_ORIENTATION_TOP,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ g_object_class_install_property (
+ gobject_class,
+ PROP_ALIGNMENT,
+ g_param_spec_enum (
+ "alignment",
+ "Alignment",
+ "The alignment of the panel",
+ PANEL_TYPE_ALIGNMENT,
+ PANEL_ALIGNMENT_CENTER,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
g_object_class_install_property (
gobject_class,
PROP_SIZE,
@@ -3873,6 +3918,7 @@ panel_toplevel_init (PanelToplevel *toplevel)
toplevel->priv->expand = TRUE;
toplevel->priv->orientation = PANEL_ORIENTATION_BOTTOM;
+ toplevel->priv->alignment = PANEL_ALIGNMENT_CENTER;
toplevel->priv->size = DEFAULT_SIZE;
toplevel->priv->x = 0;
toplevel->priv->y = 0;
@@ -4040,6 +4086,12 @@ panel_toplevel_bind_gsettings (PanelToplevel *toplevel)
"orientation",
G_SETTINGS_BIND_DEFAULT|G_SETTINGS_BIND_NO_SENSITIVITY);
+ g_settings_bind (toplevel->priv->delayed_settings,
+ PANEL_TOPLEVEL_ALIGNMENT_KEY,
+ toplevel,
+ "alignment",
+ G_SETTINGS_BIND_DEFAULT|G_SETTINGS_BIND_NO_SENSITIVITY);
+
g_settings_bind (toplevel->priv->delayed_settings,
PANEL_TOPLEVEL_X_KEY,
toplevel,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]