mirror of
https://gitlab.gnome.org/GNOME/glade.git
synced 2025-09-24 00:04:33 -04:00
o Added new member weight. o glade_property_class_get_displayable_value()
* src/glade-property-class.[ch]: o Added new member weight. o glade_property_class_get_displayable_value() returns is now const. * src/glade-editor-property.c: adapted to the new glade_property_class_get_displayable_value() declaration. * src/glade-editor.c: Fixed bug 345893. "Need to order properties in the editor and widget-groups in the palette" * src/glade-widget-class.c: added glade_widget_class_properties_set_weight(). * src/glade-xml-utils.[ch]: added glade_xml_get_property_double(). * src/glade.h: added new tag GLADE_TAG_WEIGHT. * widgets/gtk+.xml.in: set weight in several properties. GtkWidget's tooltip, GtkBox packing properties, GtkButton GtkImage
This commit is contained in:
parent
4dfa2e80a4
commit
68f51c5bfd
22
ChangeLog
22
ChangeLog
@ -1,3 +1,25 @@
|
||||
2006-09-18 Juan Pablo Ugarte <juanpablougarte@gmail.com>
|
||||
|
||||
* src/glade-property-class.[ch]:
|
||||
o Added new member weight.
|
||||
o glade_property_class_get_displayable_value() returns is now const.
|
||||
|
||||
* src/glade-editor-property.c: adapted to the new
|
||||
glade_property_class_get_displayable_value() declaration.
|
||||
|
||||
* src/glade-editor.c: Fixed bug 345893. "Need to order
|
||||
properties in the editor and widget-groups in the palette"
|
||||
|
||||
* src/glade-widget-class.c:
|
||||
added glade_widget_class_properties_set_weight().
|
||||
|
||||
* src/glade-xml-utils.[ch]: added glade_xml_get_property_double().
|
||||
|
||||
* src/glade.h: added new tag GLADE_TAG_WEIGHT.
|
||||
|
||||
* widgets/gtk+.xml.in: set weight in several properties.
|
||||
GtkWidget's tooltip, GtkBox packing properties, GtkButton GtkImage
|
||||
|
||||
2006-09-14 David Lodge <dave@cirt.net>
|
||||
|
||||
* configure.in: Addedd en_GB to ALL_LINGUAS
|
||||
|
@ -862,9 +862,9 @@ glade_eprop_enum_create_input (GladeEditorProperty *eprop)
|
||||
|
||||
for (i = 0; i < eclass->n_values; i++)
|
||||
{
|
||||
gchar *value_name =
|
||||
const gchar *value_name =
|
||||
glade_property_class_get_displayable_value
|
||||
(class, eclass->values[i].value);
|
||||
(class, eclass->values[i].value);
|
||||
if (value_name == NULL) value_name = eclass->values[i].value_name;
|
||||
|
||||
if (stock && strcmp (eclass->values[i].value_nick, "glade-none"))
|
||||
@ -943,7 +943,7 @@ glade_eprop_flags_load (GladeEditorProperty *eprop, GladeProperty *property)
|
||||
GtkTreeIter iter;
|
||||
guint mask;
|
||||
gboolean setting;
|
||||
gchar *value_name;
|
||||
const gchar *value_name;
|
||||
|
||||
mask = class->values[flag_num].value;
|
||||
setting = ((value & mask) == mask) ? TRUE : FALSE;
|
||||
|
@ -518,6 +518,46 @@ glade_editor_table_append_class_field (GladeEditorTable *table)
|
||||
table->rows++;
|
||||
}
|
||||
|
||||
static gint
|
||||
glade_editor_property_class_comp (gconstpointer a, gconstpointer b)
|
||||
{
|
||||
const GladePropertyClass *ca = a, *cb = b;
|
||||
|
||||
if (ca->pspec->owner_type == cb->pspec->owner_type)
|
||||
{
|
||||
gdouble result = ca->weight - cb->weight;
|
||||
/* Avoid cast to int */
|
||||
if (result < 0.0) return -1;
|
||||
else if (result > 0.0) return 1;
|
||||
else return 0;
|
||||
}
|
||||
else
|
||||
return (ca->common || ca->packing) ?
|
||||
ca->pspec->owner_type - cb->pspec->owner_type :
|
||||
cb->pspec->owner_type - ca->pspec->owner_type;
|
||||
}
|
||||
|
||||
static GList *
|
||||
glade_editor_widget_class_get_sorted_properties (GladeWidgetClass *class)
|
||||
{
|
||||
GList *l, *a = NULL, *b = NULL;
|
||||
|
||||
for (l = class->properties; l && l->data; l = g_list_next (l))
|
||||
{
|
||||
GladePropertyClass *class = l->data;
|
||||
|
||||
if (class->common || class->packing)
|
||||
a = g_list_prepend (a, class);
|
||||
else
|
||||
b = g_list_prepend (b, class);
|
||||
}
|
||||
|
||||
a = g_list_sort (a, glade_editor_property_class_comp);
|
||||
b = g_list_sort (b, glade_editor_property_class_comp);
|
||||
|
||||
return g_list_concat (a, b);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
glade_editor_table_append_items (GladeEditorTable *table,
|
||||
GladeWidgetClass *class,
|
||||
@ -525,9 +565,11 @@ glade_editor_table_append_items (GladeEditorTable *table,
|
||||
{
|
||||
GladeEditorProperty *property;
|
||||
GladePropertyClass *property_class;
|
||||
GList *list;
|
||||
GList *list, *sorted_list;
|
||||
|
||||
for (list = class->properties; list != NULL; list = list->next)
|
||||
sorted_list = glade_editor_widget_class_get_sorted_properties (class);
|
||||
|
||||
for (list = sorted_list; list != NULL; list = list->next)
|
||||
{
|
||||
property_class = (GladePropertyClass *) list->data;
|
||||
|
||||
@ -552,6 +594,9 @@ glade_editor_table_append_items (GladeEditorTable *table,
|
||||
type == TABLE_TYPE_QUERY);
|
||||
table->properties = g_list_prepend (table->properties, property);
|
||||
}
|
||||
|
||||
g_list_free (sorted_list);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -738,13 +783,20 @@ glade_editor_load_widget_class (GladeEditor *editor, GladeWidgetClass *class)
|
||||
editor->loaded_class = class;
|
||||
}
|
||||
|
||||
static gint
|
||||
glade_editor_property_comp (gconstpointer a, gconstpointer b)
|
||||
{
|
||||
const GladeProperty *prop_a = a, *prop_b = b;
|
||||
return glade_editor_property_class_comp (prop_a->class, prop_b->class);
|
||||
}
|
||||
|
||||
static void
|
||||
glade_editor_load_packing_page (GladeEditor *editor, GladeWidget *widget)
|
||||
{
|
||||
GladeEditorProperty *editor_property;
|
||||
GladeProperty *property;
|
||||
GladeWidget *parent;
|
||||
GList *list;
|
||||
GList *list, *sorted_list;
|
||||
GtkWidget *child;
|
||||
|
||||
/* Remove the old properties */
|
||||
@ -771,7 +823,11 @@ glade_editor_load_packing_page (GladeEditor *editor, GladeWidget *widget)
|
||||
editor->packing_etable->editor = editor;
|
||||
editor->packing_etable->type = TABLE_TYPE_PACKING;
|
||||
|
||||
for (list = widget->packing_properties; list && list->data; list = list->next)
|
||||
/* Sort packing properties by weight */
|
||||
sorted_list = g_list_copy (widget->packing_properties);
|
||||
sorted_list = g_list_sort (sorted_list, glade_editor_property_comp);
|
||||
|
||||
for (list = sorted_list; list && list->data; list = list->next)
|
||||
{
|
||||
property = GLADE_PROPERTY (list->data);
|
||||
|
||||
@ -784,6 +840,8 @@ glade_editor_load_packing_page (GladeEditor *editor, GladeWidget *widget)
|
||||
glade_editor_property_load (editor_property, property);
|
||||
}
|
||||
|
||||
g_list_free (sorted_list);
|
||||
|
||||
gtk_widget_show (editor->packing_etable->table_widget);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (editor->page_packing),
|
||||
|
@ -172,6 +172,7 @@ glade_property_class_new (gpointer handle)
|
||||
property_class->type = GPC_NORMAL;
|
||||
property_class->virtual = TRUE;
|
||||
property_class->transfer_on_paste = FALSE;
|
||||
property_class->weight = -1.0;
|
||||
|
||||
return property_class;
|
||||
}
|
||||
@ -293,10 +294,10 @@ glade_property_class_free (GladePropertyClass *property_class)
|
||||
{
|
||||
gchar *name, *nick;
|
||||
|
||||
name = g_array_index(disp_val, GEnumValue, i).value_name;
|
||||
name = (gchar *) g_array_index (disp_val, GEnumValue, i).value_name;
|
||||
if (name) g_free(name);
|
||||
|
||||
nick = g_array_index(disp_val, GEnumValue, i).value_nick;
|
||||
nick = (gchar *) g_array_index (disp_val, GEnumValue, i).value_nick;
|
||||
if (nick) g_free(nick);
|
||||
}
|
||||
|
||||
@ -352,7 +353,7 @@ glade_property_class_make_string_from_flags (GladePropertyClass *class, guint fv
|
||||
|
||||
while ((fvalue = g_flags_get_first_value(fclass, fvals)) != NULL)
|
||||
{
|
||||
gchar *val_str = NULL;
|
||||
const gchar *val_str = NULL;
|
||||
|
||||
fvals &= ~fvalue->value;
|
||||
|
||||
@ -362,7 +363,7 @@ glade_property_class_make_string_from_flags (GladePropertyClass *class, guint fv
|
||||
if (string->str[0])
|
||||
g_string_append(string, " | ");
|
||||
|
||||
g_string_append(string, (val_str) ? val_str : fvalue->value_name);
|
||||
g_string_append (string, (val_str) ? val_str : fvalue->value_name);
|
||||
|
||||
/* If one of the flags value is 0 this loop become infinite :) */
|
||||
if (fvalue->value == 0) break;
|
||||
@ -1337,7 +1338,7 @@ glade_property_class_is_object (GladePropertyClass *class)
|
||||
*
|
||||
* Returns: a (gchar *) if a diplayable value was found, otherwise NULL.
|
||||
*/
|
||||
gchar *
|
||||
const gchar *
|
||||
glade_property_class_get_displayable_value(GladePropertyClass *class, gint value)
|
||||
{
|
||||
gint i, len;
|
||||
@ -1663,6 +1664,7 @@ glade_property_class_update_from_node (GladeXmlNode *node,
|
||||
class->visible = glade_xml_get_property_boolean (node, GLADE_TAG_VISIBLE, class->visible);
|
||||
class->ignore = glade_xml_get_property_boolean (node, GLADE_TAG_IGNORE, class->ignore);
|
||||
class->resource = glade_xml_get_property_boolean (node, GLADE_TAG_RESOURCE, class->resource);
|
||||
class->weight = glade_xml_get_property_double (node, GLADE_TAG_WEIGHT, class->weight);
|
||||
class->transfer_on_paste = glade_xml_get_property_boolean (node, GLADE_TAG_TRANSFER_ON_PASTE, class->transfer_on_paste);
|
||||
|
||||
/* No atk introspection here.
|
||||
|
@ -178,6 +178,10 @@ struct _GladePropertyClass
|
||||
* wether we should transfer it on paste.
|
||||
*/
|
||||
|
||||
gdouble weight; /* This will determine the position of this property in
|
||||
* the editor.
|
||||
*/
|
||||
|
||||
/* Delagate to verify if this is a valid value for this property,
|
||||
* if this function exists and returns FALSE, then glade_property_set
|
||||
* will abort before making any changes
|
||||
@ -252,8 +256,8 @@ gboolean glade_property_class_update_from_node (GladeXmlNode
|
||||
GladePropertyClass **property_class,
|
||||
const gchar *domain);
|
||||
LIBGLADEUI_API
|
||||
gchar *glade_property_class_get_displayable_value (GladePropertyClass *class,
|
||||
gint value);
|
||||
G_CONST_RETURN gchar *glade_property_class_get_displayable_value (GladePropertyClass *class,
|
||||
gint value);
|
||||
LIBGLADEUI_API
|
||||
GtkAdjustment *glade_property_class_make_adjustment (GladePropertyClass *property_class);
|
||||
LIBGLADEUI_API
|
||||
|
@ -185,6 +185,42 @@ glade_widget_class_list_properties (GladeWidgetClass *class)
|
||||
return g_list_concat (list, atk_list);
|
||||
}
|
||||
|
||||
/*
|
||||
This function assignes "weight" to each property in its natural order staring from 1.
|
||||
If @parent is 0 weight will be set for every GladePropertyClass in the list.
|
||||
This function will not override weight if it is already set (weight >= 0.0)
|
||||
*/
|
||||
static void
|
||||
glade_widget_class_properties_set_weight (GList **properties, GType parent)
|
||||
{
|
||||
gint normal = 0, common = 0, packing = 0;
|
||||
GList *l;
|
||||
|
||||
for (l = *properties; l && l->data; l = g_list_next (l))
|
||||
{
|
||||
GladePropertyClass *class = l->data;
|
||||
GPCType type = class->type;
|
||||
|
||||
if (class->visible &&
|
||||
(parent) ? parent == class->pspec->owner_type : TRUE &&
|
||||
(type == GPC_NORMAL || type == GPC_ACCEL_PROPERTY))
|
||||
{
|
||||
/* Use a different counter for each tab (common, packing and normal) */
|
||||
if (class->common) common++;
|
||||
else if (class->packing) packing++;
|
||||
else normal++;
|
||||
|
||||
/* Skip if it is already set */
|
||||
if (class->weight >= 0.0) continue;
|
||||
|
||||
/* Special-casing weight of properties for seperate tabs */
|
||||
if (class->common) class->weight = common;
|
||||
else if (class->packing) class->weight = packing;
|
||||
else class->weight = normal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static GList *
|
||||
glade_widget_class_list_child_properties (GladeWidgetClass *class)
|
||||
{
|
||||
@ -224,6 +260,10 @@ glade_widget_class_list_child_properties (GladeWidgetClass *class)
|
||||
property_class = l->data;
|
||||
property_class->packing = TRUE;
|
||||
}
|
||||
|
||||
/* Set default weight on packing properties */
|
||||
glade_widget_class_properties_set_weight (&list, 0);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@ -1175,9 +1215,8 @@ glade_widget_class_new (GladeXmlNode *class_node,
|
||||
parent_name = g_type_name (parent_type);
|
||||
parent_class = glade_widget_class_get_by_name (parent_name);
|
||||
|
||||
if (parent_class) {
|
||||
if (parent_class)
|
||||
glade_widget_class_merge (widget_class, parent_class);
|
||||
}
|
||||
}
|
||||
|
||||
glade_widget_class_extend_with_node (widget_class, class_node, domain);
|
||||
@ -1189,6 +1228,13 @@ glade_widget_class_new (GladeXmlNode *class_node,
|
||||
if (!widget_classes)
|
||||
widget_classes = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
g_hash_table_insert (widget_classes, widget_class->name, widget_class);
|
||||
|
||||
/* Set default weight on properties */
|
||||
for (parent_type = widget_class->type;
|
||||
parent_type != 0;
|
||||
parent_type = g_type_parent (parent_type))
|
||||
glade_widget_class_properties_set_weight (&widget_class->properties,
|
||||
parent_type);
|
||||
|
||||
return widget_class;
|
||||
}
|
||||
@ -1742,7 +1788,7 @@ glade_widget_class_create_widget_real (gboolean query,
|
||||
g_critical ("No class found in glade_widget_class_create_widget_real args");
|
||||
va_end (vl_copy);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (widget_class->fixed)
|
||||
gwidget_type = GLADE_TYPE_FIXED;
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <glib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "glade-xml-utils.h"
|
||||
|
||||
@ -344,6 +344,32 @@ glade_xml_get_property_boolean (GladeXmlNode *node_in,
|
||||
return ret;
|
||||
}
|
||||
|
||||
gdouble
|
||||
glade_xml_get_property_double (GladeXmlNode *node_in,
|
||||
const gchar *name,
|
||||
gdouble _default)
|
||||
{
|
||||
xmlNodePtr node = (xmlNodePtr) node_in;
|
||||
gdouble retval;
|
||||
gchar *value;
|
||||
|
||||
if ((value = glade_xml_get_property (node, name)) == NULL)
|
||||
return _default;
|
||||
|
||||
retval = g_ascii_strtod (value, NULL);
|
||||
|
||||
if (errno)
|
||||
{
|
||||
g_free (value);
|
||||
return _default;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_free (value);
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
glade_xml_node_set_property_boolean (GladeXmlNode *node_in,
|
||||
const gchar *name,
|
||||
|
@ -40,6 +40,7 @@ void glade_xml_set_value (GladeXmlNode * node_in, const gchar *name, con
|
||||
gchar * glade_xml_get_property_string_required (GladeXmlNode *node_in, const gchar *name, const gchar *xtra);
|
||||
gchar * glade_xml_get_property_string (GladeXmlNode *node_in, const gchar *name);
|
||||
gboolean glade_xml_get_property_boolean (GladeXmlNode *node_in, const gchar *name, gboolean _default);
|
||||
gdouble glade_xml_get_property_double (GladeXmlNode *node_in, const gchar *name, gdouble _default);
|
||||
|
||||
void glade_xml_node_set_property_string (GladeXmlNode *node_in, const gchar *name, const gchar *string);
|
||||
void glade_xml_node_set_property_boolean (GladeXmlNode *node_in, const gchar *name, gboolean value);
|
||||
|
@ -137,6 +137,7 @@ typedef enum _GladeItemAppearance GladeItemAppearance;
|
||||
#define GLADE_TAG_ATK_PROPERTY "atk-property"
|
||||
#define GLADE_TAG_FIXED "fixed"
|
||||
#define GLADE_TAG_TRANSFER_ON_PASTE "transfer-on-paste"
|
||||
#define GLADE_TAG_WEIGHT "weight"
|
||||
|
||||
#define GLADE_NUMERICAL_STEP_INCREMENT 1
|
||||
#define GLADE_FLOATING_STEP_INCREMENT 0.01F
|
||||
|
@ -7,7 +7,7 @@
|
||||
<property id="width-request" common="True" optional="True" optional-default="False" default="0"/>
|
||||
<property id="height-request" common="True" optional="True" optional-default="False" default="0"/>
|
||||
|
||||
<property common="True" id="tooltip" _name="Tooltip" default="" translatable="True">
|
||||
<property common="True" id="tooltip" _name="Tooltip" default="" translatable="True" weight="4.5">
|
||||
<spec>glade_standard_string_spec</spec>
|
||||
<_tooltip>A tooltip text for this widget</_tooltip>
|
||||
<set-function>glade_gtk_widget_set_tooltip</set-function>
|
||||
@ -114,6 +114,8 @@
|
||||
<remove-child-function>glade_gtk_box_remove_child</remove-child-function>
|
||||
<child-set-property-function>glade_gtk_box_set_child_property</child-set-property-function>
|
||||
<properties>
|
||||
<property id="position" weight="0"/>
|
||||
<property id="padding" transfer-on-paste="True" weight="0.5"/>
|
||||
<property id="expand" transfer-on-paste="True"/>
|
||||
<property id="fill" transfer-on-paste="True"/>
|
||||
<property id="pack-type" transfer-on-paste="True">
|
||||
@ -122,7 +124,6 @@
|
||||
<value id="GTK_PACK_END" _name="End"/>
|
||||
</displayable-values>
|
||||
</property>
|
||||
<property id="padding" transfer-on-paste="True"/>
|
||||
</properties>
|
||||
</child>
|
||||
</children>
|
||||
@ -507,13 +508,15 @@
|
||||
<visible-lines>2</visible-lines>
|
||||
</property>
|
||||
|
||||
<property id="stock" _name="Stock Button" save="False">
|
||||
<property id="use-underline" weight="1.5"/>
|
||||
|
||||
<property id="stock" _name="Stock Button" save="False" weight="1.6">
|
||||
<spec>glade_standard_stock_spec</spec>
|
||||
<_tooltip>The stock item for this button</_tooltip>
|
||||
<set-function>glade_gtk_button_set_stock</set-function>
|
||||
</property>
|
||||
|
||||
<property id="glade-type" _name="Edit Type" save="False">
|
||||
<property id="glade-type" _name="Edit Type" save="False" weight="0">
|
||||
<spec>glade_gtk_button_type_spec</spec>
|
||||
<set-function>glade_gtk_button_set_type</set-function>
|
||||
</property>
|
||||
@ -719,7 +722,7 @@
|
||||
<property id="stock" visible="False">
|
||||
<set-function>glade_gtk_image_set_stock</set-function>
|
||||
</property>
|
||||
<property id="glade-type" _name="Edit Type" save="False">
|
||||
<property id="glade-type" _name="Edit Type" save="False" weight="0">
|
||||
<spec>glade_gtk_image_type_spec</spec>
|
||||
<set-function>glade_gtk_image_set_type</set-function>
|
||||
</property>
|
||||
@ -729,13 +732,13 @@
|
||||
<property id="image" disabled="True"/>
|
||||
<property id="mask" disabled="True"/>
|
||||
<property id="pixbuf" _name="File Name"/>
|
||||
<property id="glade-stock" _name="Stock Image" save="False">
|
||||
<property id="glade-stock" _name="Stock Image" save="False" weight="1.5">
|
||||
<_tooltip>A builtin stock image</_tooltip>
|
||||
<spec>glade_standard_stock_spec</spec>
|
||||
<_tooltip>The stock item for this image</_tooltip>
|
||||
<set-function>glade_gtk_image_set_glade_stock</set-function>
|
||||
</property>
|
||||
<property id="icon-name" _name="Icon Name">
|
||||
<property id="icon-name" _name="Icon Name" weight="1.6">
|
||||
<set-function>glade_gtk_image_set_icon_name</set-function>
|
||||
</property>
|
||||
</properties>
|
||||
|
Loading…
x
Reference in New Issue
Block a user