summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Pablo Ugarte <juanpablougarte@gmail.com>2012-10-31 12:48:09 -0700
committerJuan Pablo Ugarte <juanpablougarte@gmail.com>2013-01-18 19:56:04 -0300
commit12a9441d5e1d66cf9bd6a1a2c033baf052c6ea3a (patch)
tree32f979955702e0e347bfc22985a655d827c9e397
parent7e0d65bdd6e294eb4247f2690bd4dc2283ad10b0 (diff)
downloadglade-12a9441d5e1d66cf9bd6a1a2c033baf052c6ea3a.tar.gz
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()
-rw-r--r--gladeui/glade-editor-property.c13
-rw-r--r--gladeui/glade-editor-property.h4
-rw-r--r--gladeui/glade-editor-table.c29
3 files changed, 46 insertions, 0 deletions
diff --git a/gladeui/glade-editor-property.c b/gladeui/glade-editor-property.c
index 79186f11..bf3cd3f8 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 d1678ae5..0793a344 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 a82a29c5..c6e25385 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),