[Xfce4-commits] [xfce/xfce4-panel] 01/02: pager: Add option to show ws number
noreply at xfce.org
noreply at xfce.org
Wed Oct 9 01:21:00 CEST 2019
This is an automated email from the git hooks/post-receive script.
o c h o s i p u s h e d a c o m m i t t o b r a n c h m a s t e r
in repository xfce/xfce4-panel.
commit c710beb945c34987f121ec0ba9562a3b19298435
Author: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
Date: Tue Oct 8 00:14:32 2019 +0200
pager: Add option to show ws number
---
plugins/pager/pager-buttons.c | 52 ++++++++++++++++++++++++++++++++++++----
plugins/pager/pager-buttons.h | 3 +++
plugins/pager/pager-dialog.glade | 16 ++++++++++++-
plugins/pager/pager.c | 35 ++++++++++++++++++++++++++-
4 files changed, 99 insertions(+), 7 deletions(-)
diff --git a/plugins/pager/pager-buttons.c b/plugins/pager/pager-buttons.c
index 6c635be..c83f46e 100644
--- a/plugins/pager/pager-buttons.c
+++ b/plugins/pager/pager-buttons.c
@@ -75,6 +75,7 @@ struct _PagerButtons
WnckScreen *wnck_screen;
gint rows;
+ gboolean numbering;
GtkOrientation orientation;
};
@@ -83,7 +84,8 @@ enum
PROP_0,
PROP_SCREEN,
PROP_ROWS,
- PROP_ORIENTATION
+ PROP_ORIENTATION,
+ PROP_NUMBERING
};
enum
@@ -131,6 +133,13 @@ pager_buttons_class_init (PagerButtonsClass *klass)
GTK_TYPE_ORIENTATION,
GTK_ORIENTATION_HORIZONTAL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (gobject_class,
+ PROP_NUMBERING,
+ g_param_spec_boolean ("numbering",
+ NULL, NULL,
+ FALSE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
}
@@ -141,13 +150,13 @@ pager_buttons_init (PagerButtons *pager)
pager->rows = 1;
pager->wnck_screen = NULL;
pager->orientation = GTK_ORIENTATION_HORIZONTAL;
+ pager->numbering = FALSE;
pager->buttons = NULL;
pager->rebuild_id = 0;
/* although I'd prefer normal allocation, the homogeneous setting
* takes care of small panels, while non-homogeneous tables allocate
* outside the panel size --nick */
- /* gtk_table_set_homogeneous (GTK_TABLE (pager), TRUE); */
gtk_grid_set_row_homogeneous (GTK_GRID (pager), TRUE);
gtk_grid_set_column_homogeneous (GTK_GRID (pager), TRUE);
}
@@ -172,6 +181,10 @@ pager_buttons_get_property (GObject *object,
g_value_set_enum (value, pager->orientation);
break;
+ case PROP_NUMBERING:
+ g_value_set_boolean (value, pager->numbering);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -214,6 +227,10 @@ pager_buttons_set_property (GObject *object,
pager_buttons_set_orientation (pager, g_value_get_enum (value));
break;
+ case PROP_NUMBERING:
+ pager_buttons_set_numbering (pager, g_value_get_boolean (value));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -422,6 +439,7 @@ pager_buttons_rebuild_idle (gpointer user_data)
gtk_widget_show (button);
label = gtk_label_new (NULL);
+ g_object_set_data (G_OBJECT (label), "numbering", GINT_TO_POINTER (pager->numbering));
g_signal_connect_object (G_OBJECT (workspace), "name-changed",
G_CALLBACK (pager_buttons_workspace_button_label), label, 0);
pager_buttons_workspace_button_label (workspace, label);
@@ -554,11 +572,14 @@ pager_buttons_workspace_button_label (WnckWorkspace *workspace,
GtkWidget *label)
{
const gchar *name;
- gchar *utf8 = NULL, *name_num = NULL;
+ gchar *utf8 = NULL, *name_fallback = NULL, *name_num = NULL;
+ gboolean numbering;
panel_return_if_fail (WNCK_IS_WORKSPACE (workspace));
panel_return_if_fail (GTK_IS_LABEL (label));
+ numbering = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (label), "numbering"));
+
/* try to get an utf-8 valid name */
name = wnck_workspace_get_name (workspace);
if (!panel_str_is_empty (name)
@@ -566,12 +587,18 @@ pager_buttons_workspace_button_label (WnckWorkspace *workspace,
name = utf8 = g_locale_to_utf8 (name, -1, NULL, NULL, NULL);
if (panel_str_is_empty (name))
- name = name_num = g_strdup_printf (_("Workspace %d"),
- wnck_workspace_get_number (workspace) + 1);
+ name = name_fallback = g_strdup_printf (_("Workspace %d"),
+ wnck_workspace_get_number (workspace) + 1);
+
+ if (numbering)
+ name = name_num = g_strdup_printf ("%d - %s",
+ wnck_workspace_get_number (workspace) + 1,
+ name);
gtk_label_set_text (GTK_LABEL (label), name);
g_free (utf8);
+ g_free (name_fallback);
g_free (name_num);
}
@@ -655,3 +682,18 @@ pager_buttons_set_n_rows (PagerButtons *pager,
pager->rows = rows;
pager_buttons_queue_rebuild (pager);
}
+
+
+
+void
+pager_buttons_set_numbering (PagerButtons *pager,
+ gboolean numbering)
+{
+ panel_return_if_fail (XFCE_IS_PAGER_BUTTONS (pager));
+
+ if (pager->numbering == numbering)
+ return;
+
+ pager->numbering = numbering;
+ pager_buttons_queue_rebuild (pager);
+}
diff --git a/plugins/pager/pager-buttons.h b/plugins/pager/pager-buttons.h
index b8014f5..f03fc7c 100644
--- a/plugins/pager/pager-buttons.h
+++ b/plugins/pager/pager-buttons.h
@@ -46,6 +46,9 @@ void pager_buttons_set_orientation (PagerButtons *pager,
void pager_buttons_set_n_rows (PagerButtons *pager,
gint rows);
+void pager_buttons_set_numbering (PagerButtons *pager,
+ gboolean numbering);
+
G_END_DECLS
#endif /* !__PAGER_BUTTONS_H__ */
diff --git a/plugins/pager/pager-dialog.glade b/plugins/pager/pager-dialog.glade
index 9ee35db..95a6be7 100644
--- a/plugins/pager/pager-dialog.glade
+++ b/plugins/pager/pager-dialog.glade
@@ -163,6 +163,20 @@
</packing>
</child>
<child>
+ <object class="GtkCheckButton" id="numbering">
+ <property name="label" translatable="yes">Show workspace number</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkAlignment" id="alignment1">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -182,7 +196,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">2</property>
+ <property name="position">3</property>
</packing>
</child>
</object>
diff --git a/plugins/pager/pager.c b/plugins/pager/pager.c
index 5637bea..2e032e6 100644
--- a/plugins/pager/pager.c
+++ b/plugins/pager/pager.c
@@ -101,6 +101,7 @@ struct _PagerPlugin
XfcePanelPlugin __parent__;
GtkWidget *pager;
+ GObject *numbering_switch;
WnckScreen *wnck_screen;
@@ -109,6 +110,7 @@ struct _PagerPlugin
guint wrap_workspaces : 1;
guint miniature_view : 1;
gint rows;
+ gboolean numbering;
gfloat ratio;
};
@@ -118,7 +120,8 @@ enum
PROP_WORKSPACE_SCROLLING,
PROP_WRAP_WORKSPACES,
PROP_MINIATURE_VIEW,
- PROP_ROWS
+ PROP_ROWS,
+ PROP_NUMBERING
};
@@ -181,6 +184,13 @@ pager_plugin_class_init (PagerPluginClass *klass)
NULL, NULL,
1, 50, 1,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (gobject_class,
+ PROP_NUMBERING,
+ g_param_spec_boolean ("numbering",
+ NULL, NULL,
+ FALSE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
}
@@ -193,6 +203,7 @@ pager_plugin_init (PagerPlugin *plugin)
plugin->wrap_workspaces = FALSE;
plugin->miniature_view = TRUE;
plugin->rows = 1;
+ plugin->numbering = FALSE;
plugin->ratio = 1.0;
plugin->pager = NULL;
}
@@ -220,6 +231,8 @@ pager_plugin_get_property (GObject *object,
case PROP_MINIATURE_VIEW:
g_value_set_boolean (value, plugin->miniature_view);
+ if (G_IS_OBJECT (plugin->numbering_switch))
+ gtk_widget_set_visible (GTK_WIDGET (plugin->numbering_switch), !plugin->miniature_view);
pager_plugin_screen_layout_changed (plugin);
break;
@@ -227,6 +240,10 @@ pager_plugin_get_property (GObject *object,
g_value_set_uint (value, plugin->rows);
break;
+ case PROP_NUMBERING:
+ g_value_set_boolean (value, plugin->numbering);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -273,6 +290,13 @@ pager_plugin_set_property (GObject *object,
}
break;
+ case PROP_NUMBERING:
+ plugin->numbering = g_value_get_boolean (value);
+
+ if (!plugin->miniature_view)
+ pager_buttons_set_numbering (XFCE_PAGER_BUTTONS (plugin->pager), plugin->numbering);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -451,6 +475,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS
plugin->pager = pager_buttons_new (plugin->wnck_screen);
pager_buttons_set_n_rows (XFCE_PAGER_BUTTONS (plugin->pager), plugin->rows);
pager_buttons_set_orientation (XFCE_PAGER_BUTTONS (plugin->pager), orientation);
+ pager_buttons_set_numbering (XFCE_PAGER_BUTTONS (plugin->pager), plugin->numbering);
}
gtk_container_add (GTK_CONTAINER (plugin), plugin->pager);
@@ -502,6 +527,7 @@ pager_plugin_construct (XfcePanelPlugin *panel_plugin)
{ "wrap-workspaces", G_TYPE_BOOLEAN },
{ "miniature-view", G_TYPE_BOOLEAN },
{ "rows", G_TYPE_UINT },
+ { "numbering", G_TYPE_BOOLEAN },
{ NULL }
};
@@ -696,6 +722,13 @@ pager_plugin_configure_plugin (XfcePanelPlugin *panel_plugin)
G_OBJECT (object), "value",
G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
+ plugin->numbering_switch = gtk_builder_get_object (builder, "numbering");
+ panel_return_if_fail (GTK_IS_TOGGLE_BUTTON (plugin->numbering_switch));
+ g_object_bind_property (G_OBJECT (plugin), "numbering",
+ G_OBJECT (plugin->numbering_switch), "active",
+ G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
+ gtk_widget_set_visible (GTK_WIDGET (plugin->numbering_switch), !plugin->miniature_view);
+
/* update the rows limit */
pager_plugin_configure_n_workspaces_changed (plugin->wnck_screen, NULL, builder);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list