[Xfce4-commits] [panel-plugins/xfce4-indicator-plugin] 02/06: Add option to display indicators squared
noreply at xfce.org
noreply at xfce.org
Sun Jul 16 12:52:05 CEST 2017
This is an automated email from the git hooks/post-receive script.
a n d r z e j r 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 panel-plugins/xfce4-indicator-plugin.
commit c72cff7ac80cb6d65bbf9876ddd85006e988bc02
Author: Viktor Odintsev <zakhams at gmail.com>
Date: Sat Jul 8 20:48:11 2017 +0300
Add option to display indicators squared
---
panel-plugin/indicator-box.c | 38 ++++++++++++++++++++++++++++++------
panel-plugin/indicator-button-box.c | 16 +++++++++++----
panel-plugin/indicator-config.c | 39 +++++++++++++++++++++++++++++++++++++
panel-plugin/indicator-config.h | 3 +++
panel-plugin/indicator-dialog.c | 10 ++++++----
panel-plugin/indicator-dialog.glade | 16 +++++++++++++++
6 files changed, 108 insertions(+), 14 deletions(-)
diff --git a/panel-plugin/indicator-box.c b/panel-plugin/indicator-box.c
index 66523d6..1c36b95 100644
--- a/panel-plugin/indicator-box.c
+++ b/panel-plugin/indicator-box.c
@@ -315,6 +315,7 @@ xfce_indicator_box_get_preferred_length (GtkWidget *widget,
GtkRequisition child_req;
GList *known_indicators, *li, *li_int, *li_tmp;
gint panel_size, size;
+ gboolean single_row, square_icons;
gint length;
gint row;
gint nrows;
@@ -338,10 +339,20 @@ xfce_indicator_box_get_preferred_length (GtkWidget *widget,
border_thickness = MAX (padding.left+padding.right+border.left+border.right,
padding.top+padding.bottom+border.top+border.bottom);
- size = ICON_SIZE + border_thickness;
panel_size = indicator_config_get_panel_size (box->config);
- nrows = MAX (1, panel_size / size);
- allow_small = !((nrows == 1) || indicator_config_get_single_row (box->config));
+ single_row = indicator_config_get_single_row (box->config);
+ square_icons = indicator_config_get_square_icons (box->config);
+ if (square_icons)
+ {
+ nrows = indicator_config_get_nrows (box->config);
+ size = (panel_size - border_thickness) / (single_row ? 1 : nrows);
+ }
+ else
+ {
+ size = MIN (ICON_SIZE + border_thickness, panel_size);
+ nrows = MAX (1, panel_size / size);
+ }
+ allow_small = !((nrows == 1) || single_row);
panel_orientation = indicator_config_get_panel_orientation (box->config);
@@ -375,6 +386,8 @@ xfce_indicator_box_get_preferred_length (GtkWidget *widget,
length =
MAX (length, (panel_orientation == GTK_ORIENTATION_HORIZONTAL) ? child_req.width :child_req.height);
+ if (square_icons)
+ length = MAX (length, size);
if (row >= nrows || !is_small)
{
@@ -460,6 +473,7 @@ xfce_indicator_box_size_allocate (GtkWidget *widget,
GtkAllocation child_alloc;
GtkRequisition child_req;
gint panel_size, size, full_size;
+ gboolean single_row, square_icons;
gint x, y;
gint x0, y0;
GList *known_indicators, *li, *li_int, *li_tmp;
@@ -495,11 +509,21 @@ xfce_indicator_box_size_allocate (GtkWidget *widget,
padding.top+padding.bottom+border.top+border.bottom);
panel_size = indicator_config_get_panel_size (box->config);
- size = MIN (ICON_SIZE + border_thickness, panel_size);
- nrows = panel_size / size;
+ single_row = indicator_config_get_single_row (box->config);
+ square_icons = indicator_config_get_square_icons (box->config);
+ if (square_icons)
+ {
+ nrows = indicator_config_get_nrows (box->config);
+ size = (panel_size - border_thickness) / (single_row ? 1 : nrows);
+ }
+ else
+ {
+ size = MIN (ICON_SIZE + border_thickness, panel_size);
+ nrows = MAX (1, panel_size / size);
+ }
//full_size = ((nrows-1)*panel_size + nrows*size) / nrows; // regular pitch, margins
full_size = panel_size; // irregular pitch, no margins
- allow_small = !((nrows == 1) || indicator_config_get_single_row (box->config));
+ allow_small = !((nrows == 1) || single_row);
panel_orientation = indicator_config_get_panel_orientation (box->config);
@@ -540,6 +564,8 @@ xfce_indicator_box_size_allocate (GtkWidget *widget,
width = (is_small) ? size : full_size;
length = MAX (length,
(panel_orientation == GTK_ORIENTATION_HORIZONTAL) ? child_req.width :child_req.height);
+ if (square_icons)
+ length = MAX (length, size);
if (panel_orientation == GTK_ORIENTATION_HORIZONTAL)
{
diff --git a/panel-plugin/indicator-button-box.c b/panel-plugin/indicator-button-box.c
index d4cf065..5a8c97f 100644
--- a/panel-plugin/indicator-button-box.c
+++ b/panel-plugin/indicator-button-box.c
@@ -401,6 +401,8 @@ indicator_button_box_get_preferred_width (GtkWidget *widget,
{
IndicatorButtonBox *box = XFCE_INDICATOR_BUTTON_BOX (widget);
gint min_size, nat_size;
+ gint panel_size, nrows, size;
+ gboolean square_icons;
if (indicator_button_box_is_small (box)) // check & cache
{
@@ -414,13 +416,13 @@ indicator_button_box_get_preferred_width (GtkWidget *widget,
gtk_image_get_storage_type (GTK_IMAGE (box->icon)) != GTK_IMAGE_EMPTY &&
box->orientation == GTK_ORIENTATION_HORIZONTAL)
{
- min_size = min_size + ICON_SIZE + SPACING;
- nat_size = nat_size + ICON_SIZE + SPACING;
+ min_size = min_size + ICON_SIZE + 2 * SPACING;
+ nat_size = nat_size + ICON_SIZE + 2 * SPACING;
}
else
{
- min_size = MAX (min_size, ICON_SIZE);
- nat_size = MAX (nat_size, ICON_SIZE);
+ min_size = MAX (min_size + 2 * SPACING, ICON_SIZE);
+ nat_size = MAX (nat_size + 2 * SPACING, ICON_SIZE);
}
}
else // rectangular icon
@@ -511,6 +513,7 @@ indicator_button_box_size_allocate (GtkWidget *widget,
IndicatorButtonBox *box = XFCE_INDICATOR_BUTTON_BOX (widget);
gint x, y, width, height;
GtkAllocation icon_alloc, label_alloc;
+ GtkRequisition requisition;
gtk_widget_set_allocation (widget, allocation);
@@ -521,6 +524,11 @@ indicator_button_box_size_allocate (GtkWidget *widget,
indicator_button_box_is_small (box); // refresh cache
+ if (box->icon != NULL)
+ gtk_widget_get_preferred_size (box->icon, NULL, &requisition);
+ if (box->label != NULL)
+ gtk_widget_get_preferred_size (box->label, NULL, &requisition);
+
if (box->icon != NULL &&
gtk_image_get_storage_type (GTK_IMAGE (box->icon)) != GTK_IMAGE_EMPTY &&
box->label != NULL &&
diff --git a/panel-plugin/indicator-config.c b/panel-plugin/indicator-config.c
index 8ce56a7..b32d4d1 100644
--- a/panel-plugin/indicator-config.c
+++ b/panel-plugin/indicator-config.c
@@ -47,6 +47,7 @@
#define DEFAULT_SINGLE_ROW FALSE
#define DEFAULT_ALIGN_LEFT FALSE
+#define DEFAULT_SQUARE_ICONS FALSE
#define DEFAULT_EXCLUDED_MODULES NULL
#define DEFAULT_ORIENTATION GTK_ORIENTATION_HORIZONTAL
#define DEFAULT_PANEL_ORIENTATION GTK_ORIENTATION_HORIZONTAL
@@ -79,6 +80,7 @@ struct _IndicatorConfig
gboolean single_row;
gboolean align_left;
+ gboolean square_icons;
gboolean mode_whitelist;
GHashTable *blacklist;
GHashTable *whitelist;
@@ -100,6 +102,7 @@ enum
PROP_0,
PROP_SINGLE_ROW,
PROP_ALIGN_LEFT,
+ PROP_SQUARE_ICONS,
PROP_MODE_WHITELIST,
PROP_BLACKLIST,
PROP_WHITELIST,
@@ -166,6 +169,13 @@ indicator_config_class_init (IndicatorConfigClass *klass)
G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class,
+ PROP_SQUARE_ICONS,
+ g_param_spec_boolean ("square-icons", NULL, NULL,
+ DEFAULT_ALIGN_LEFT,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (gobject_class,
PROP_MODE_WHITELIST,
g_param_spec_boolean ("mode-whitelist", NULL, NULL,
DEFAULT_MODE_WHITELIST,
@@ -222,6 +232,7 @@ indicator_config_init (IndicatorConfig *config)
{
config->single_row = DEFAULT_SINGLE_ROW;
config->align_left = DEFAULT_ALIGN_LEFT;
+ config->square_icons = DEFAULT_SQUARE_ICONS;
config->mode_whitelist = DEFAULT_MODE_WHITELIST;
config->blacklist = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
config->whitelist = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
@@ -299,6 +310,10 @@ indicator_config_get_property (GObject *object,
g_value_set_boolean (value, config->align_left);
break;
+ case PROP_SQUARE_ICONS:
+ g_value_set_boolean (value, config->square_icons);
+ break;
+
case PROP_MODE_WHITELIST:
g_value_set_boolean (value, config->mode_whitelist);
break;
@@ -371,6 +386,15 @@ indicator_config_set_property (GObject *object,
}
break;
+ case PROP_SQUARE_ICONS:
+ val = g_value_get_boolean (value);
+ if (config->square_icons != val)
+ {
+ config->square_icons = val;
+ g_signal_emit (G_OBJECT (config), indicator_config_signals [CONFIGURATION_CHANGED], 0);
+ }
+ break;
+
case PROP_MODE_WHITELIST:
val = g_value_get_boolean (value);
if (config->mode_whitelist != val)
@@ -460,6 +484,17 @@ indicator_config_get_align_left (IndicatorConfig *config)
+gboolean
+indicator_config_get_square_icons (IndicatorConfig *config)
+{
+ g_return_val_if_fail (XFCE_IS_INDICATOR_CONFIG (config), DEFAULT_SQUARE_ICONS);
+
+ return config->square_icons;
+}
+
+
+
+
void
indicator_config_set_orientation (IndicatorConfig *config,
GtkOrientation panel_orientation,
@@ -774,6 +809,10 @@ indicator_config_new (const gchar *property_base)
xfconf_g_property_bind (channel, property, G_TYPE_BOOLEAN, config, "align-left");
g_free (property);
+ property = g_strconcat (property_base, "/square-icons", NULL);
+ xfconf_g_property_bind (channel, property, G_TYPE_BOOLEAN, config, "square-icons");
+ g_free (property);
+
property = g_strconcat (property_base, "/mode-whitelist", NULL);
xfconf_g_property_bind (channel, property, G_TYPE_BOOLEAN, config, "mode-whitelist");
g_free (property);
diff --git a/panel-plugin/indicator-config.h b/panel-plugin/indicator-config.h
index 46624e4..a6be4bb 100644
--- a/panel-plugin/indicator-config.h
+++ b/panel-plugin/indicator-config.h
@@ -80,6 +80,9 @@ void indicator_config_blacklist_set (IndicatorConfig
gboolean indicator_config_is_whitelisted (IndicatorConfig *config,
const gchar *name);
+gboolean indicator_config_get_square_icons (IndicatorConfig *config);
+
+
void indicator_config_whitelist_set (IndicatorConfig *config,
const gchar *name,
gboolean add);
diff --git a/panel-plugin/indicator-dialog.c b/panel-plugin/indicator-dialog.c
index d4ae152..d204f5c 100644
--- a/panel-plugin/indicator-dialog.c
+++ b/panel-plugin/indicator-dialog.c
@@ -495,16 +495,18 @@ indicator_dialog_build (IndicatorDialog *dialog)
object = gtk_builder_get_object (builder, "checkbutton-align-left");
g_return_if_fail (GTK_IS_WIDGET (object));
- //exo_mutual_binding_new (G_OBJECT (dialog->config), "align-left",
- // G_OBJECT (object), "active");
g_object_bind_property (G_OBJECT (dialog->config), "align-left",
G_OBJECT (object), "active",
G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
+ object = gtk_builder_get_object (builder, "checkbutton-square-icons");
+ g_return_if_fail (GTK_IS_WIDGET (object));
+ g_object_bind_property (G_OBJECT (dialog->config), "square-icons",
+ G_OBJECT (object), "active",
+ G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
+
object = gtk_builder_get_object (builder, "checkbutton-whitelist");
g_return_if_fail (GTK_IS_WIDGET (object));
- //exo_mutual_binding_new (G_OBJECT (dialog->config), "mode-whitelist",
- // G_OBJECT (object), "active");
g_object_bind_property (G_OBJECT (dialog->config), "mode-whitelist",
G_OBJECT (object), "active",
G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL);
diff --git a/panel-plugin/indicator-dialog.glade b/panel-plugin/indicator-dialog.glade
index d1a4c5a..a7f6b0c 100644
--- a/panel-plugin/indicator-dialog.glade
+++ b/panel-plugin/indicator-dialog.glade
@@ -114,6 +114,22 @@
<property name="position">1</property>
</packing>
</child>
+ <child>
+ <object class="GtkCheckButton" id="checkbutton-square-icons">
+ <property name="label" translatable="yes">Square icons</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="tooltip_text" translatable="yes">Indicator buttons will take a square when it's possible.</property>
+ <property name="use_action_appearance">False</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
</object>
</child>
</object>
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list