Commit 3dda1330 authored by Sean Davis's avatar Sean Davis 🕶

Enable single-row for systray

parent a7dae10a
Pipeline #1132 passed with stages
in 4 minutes and 10 seconds
......@@ -276,7 +276,7 @@ sn_plugin_button_set_arrow(SnPlugin *plugin)
void
static void
sn_plugin_button_toggled (GtkWidget *button,
SnPlugin *plugin)
{
......
......@@ -111,6 +111,9 @@ struct _SystrayBox
/* whether icons are squared */
guint square_icons : 1;
/* whether icons are in a single row */
guint single_row : 1;
/* allocated size by the plugin */
gint size_alloc_init;
gint size_alloc;
......@@ -248,17 +251,24 @@ systray_box_size_get_max_child_size (SystrayBox *box,
else
{
/* count the number of rows that fit in the allocated space */
for (rows = 1;; rows++)
if (box->single_row)
{
rows = 1;
}
else
{
size = rows * box->size_max + (rows - 1) * SPACING;
if (size < alloc_size)
continue;
for (rows = 1;; rows++)
{
size = rows * box->size_max + (rows - 1) * SPACING;
if (size < alloc_size)
continue;
/* decrease rows if the new size doesn't fit */
if (rows > 1 && size > alloc_size)
rows--;
/* decrease rows if the new size doesn't fit */
if (rows > 1 && size > alloc_size)
rows--;
break;
break;
}
}
row_size = (alloc_size - (rows - 1) * SPACING) / rows;
......@@ -949,3 +959,12 @@ systray_box_has_hidden_items (SystrayBox *box)
g_return_val_if_fail (XFCE_IS_SYSTRAY_BOX (box), FALSE);
return box->n_hidden_children > 0;
}
void
systray_box_set_single_row (SystrayBox *box,
gboolean single_row)
{
box->single_row = single_row;
gtk_widget_queue_resize (GTK_WIDGET (box));
}
......@@ -67,4 +67,7 @@ void systray_box_update (SystrayBox *box,
gboolean systray_box_has_hidden_items (SystrayBox *box);
void systray_box_set_single_row (SystrayBox *box,
gboolean single_row);
#endif /* !__SYSTRAY_BOX_H__ */
......@@ -59,6 +59,7 @@ void systray_plugin_configuration_changed (SnConfig *config,
{
gint icon_size;
gboolean square_icons;
gboolean single_row;
GList *list;
GList *l;
gchar *name;
......@@ -71,8 +72,10 @@ void systray_plugin_configuration_changed (SnConfig *config,
/* square-icons */
square_icons = sn_config_get_square_icons (config);
systray_box_set_squared (XFCE_SYSTRAY_BOX (plugin->systray_box), square_icons);
systray_plugin_size_changed (XFCE_PANEL_PLUGIN (plugin),
xfce_panel_plugin_get_size (XFCE_PANEL_PLUGIN (plugin)));
/* single-row */
single_row = sn_config_get_single_row (config);
systray_box_set_single_row (XFCE_SYSTRAY_BOX (plugin->systray_box), single_row);
/* known-legacy-items */
{
......@@ -100,13 +103,16 @@ void systray_plugin_configuration_changed (SnConfig *config,
name = g_strdup (l->data);
g_hash_table_replace (plugin->names_hidden, name, NULL);
}
if (list != NULL)
g_list_free (list);
}
/* update icons in the box */
systray_plugin_names_update (plugin);
systray_plugin_size_changed (XFCE_PANEL_PLUGIN (plugin),
xfce_panel_plugin_get_size (XFCE_PANEL_PLUGIN (plugin)));
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment