[glade/ui-incubator: 5/11] Set minimun and maximun GladeEditorTable property name labels char width. minimun is set to the aver
- From: Juan Pablo Ugarte <jpu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glade/ui-incubator: 5/11] Set minimun and maximun GladeEditorTable property name labels char width. minimun is set to the aver
- Date: Thu, 17 Jan 2013 22:16:01 +0000 (UTC)
commit 3a6c53b5e905663bc89dbf4f8ef4fff243eee013
Author: Juan Pablo Ugarte <juanpablougarte gmail com>
Date: Wed Oct 31 12:48:09 2012 -0700
Set minimun and maximun GladeEditorTable property name labels char width.
minimun is set to the average and max is the average plus a third of the difference with the longest name.
Added new function glade_editor_property_label_set_width_chars()
gladeui/glade-editor-property.c | 13 +++++++++++++
gladeui/glade-editor-property.h | 4 ++++
gladeui/glade-editor-table.c | 29 +++++++++++++++++++++++++++++
3 files changed, 46 insertions(+), 0 deletions(-)
---
diff --git a/gladeui/glade-editor-property.c b/gladeui/glade-editor-property.c
index 453d82c..c7b868f 100644
--- a/gladeui/glade-editor-property.c
+++ b/gladeui/glade-editor-property.c
@@ -177,6 +177,18 @@ glade_editor_property_loading (GladeEditorProperty *eprop)
return eprop->priv->loading;
}
+
+void
+glade_editor_property_label_set_width_chars (GladeEditorProperty *eprop,
+ gint width,
+ gint max_width)
+{
+ g_return_if_fail (GLADE_IS_EDITOR_PROPERTY (eprop));
+
+ gtk_label_set_width_chars (GTK_LABEL (eprop->priv->label), width);
+ gtk_label_set_max_width_chars (GTK_LABEL (eprop->priv->label), max_width);
+}
+
static void
glade_editor_property_tooltip_cb (GladeProperty *property,
const gchar *tooltip,
@@ -354,6 +366,7 @@ glade_editor_property_constructor (GType type,
gtk_label_set_line_wrap (GTK_LABEL (eprop->priv->label), TRUE);
gtk_label_set_width_chars (GTK_LABEL (eprop->priv->label), 10);
+ gtk_widget_set_halign (eprop->priv->label, GTK_ALIGN_START);
gtk_label_set_line_wrap_mode (GTK_LABEL (eprop->priv->label), PANGO_WRAP_WORD_CHAR);
gtk_misc_set_alignment (GTK_MISC (eprop->priv->label), 0.0, 0.5);
diff --git a/gladeui/glade-editor-property.h b/gladeui/glade-editor-property.h
index d1678ae..0793a34 100644
--- a/gladeui/glade-editor-property.h
+++ b/gladeui/glade-editor-property.h
@@ -116,6 +116,10 @@ GladePropertyClass *glade_editor_property_get_pclass (GladeEditorProperty
GladeProperty *glade_editor_property_get_property (GladeEditorProperty *eprop);
gboolean glade_editor_property_loading (GladeEditorProperty *eprop);
+void glade_editor_property_label_set_width_chars (GladeEditorProperty *eprop,
+ gint width,
+ gint max_width);
+
gboolean glade_editor_property_show_i18n_dialog (GtkWidget *parent,
gchar **text,
gchar **context,
diff --git a/gladeui/glade-editor-table.c b/gladeui/glade-editor-table.c
index a82a29c..c6e2538 100644
--- a/gladeui/glade-editor-table.c
+++ b/gladeui/glade-editor-table.c
@@ -268,6 +268,33 @@ glade_editor_table_update_show_template (GladeEditable *editable, gboolean load)
}
static void
+refresh_names_width (GladeEditorTable *table)
+{
+ GladeEditorTablePrivate *priv = table->priv;
+ gint i, width = 0, widthest = 0;
+ GList *l;
+
+ for (i = 0, l = priv->properties; l; l = g_list_next (l), i++)
+ {
+ GladePropertyClass *pclass = glade_editor_property_get_pclass (l->data);
+ gint w;
+
+ w = strlen (glade_property_class_get_name (pclass));
+ if (w > widthest) widthest = w;
+ width += w;
+ }
+
+ if (priv->properties)
+ {
+ gint average = width / i;
+ gint max = (widthest-average)/3 + average;
+
+ for (l = priv->properties; l; l = g_list_next (l))
+ glade_editor_property_label_set_width_chars (l->data, average, max);
+ }
+}
+
+static void
glade_editor_table_load (GladeEditable * editable, GladeWidget * widget)
{
GladeEditorTable *table = GLADE_EDITOR_TABLE (editable);
@@ -279,6 +306,8 @@ glade_editor_table_load (GladeEditable * editable, GladeWidget * widget)
if (priv->loaded_widget == widget)
return;
+ refresh_names_width (table);
+
if (priv->loaded_widget)
{
g_signal_handlers_disconnect_by_func (G_OBJECT (priv->loaded_widget),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]