Commit 7313fc9a authored by Tristan Van Berkom's avatar Tristan Van Berkom
Browse files

Added some important fixes


svn path=/trunk/; revision=2076
parent 7eb3b729
2009-01-05 Tristan Van Berkom <tvb@gnome.org>
* gladeui/glade-base-editor.c: s/glade_widget_set_name()/glade_command_set_name()
(Pavel Kostyuchenko - bug 533471).
Treeview editor revamp, few crashers fixed, need to come back and note...
2008-12-29 Tristan Van Berkom <tvb@gnome.org>
* plugins/gtk+/glade-cell-renderer-button.c: Made it possible
......
......@@ -513,8 +513,7 @@ on_project_selection_changed_cb (GladeProject *project, GladeApp *app)
num = g_list_length (list);
if (num == 1 && !GLADE_IS_PLACEHOLDER (list->data))
glade_editor_load_widget (app->priv->editor,
glade_widget_get_from_gobject
(G_OBJECT (list->data)));
glade_widget_get_from_gobject (list->data));
else
glade_editor_load_widget (app->priv->editor, NULL);
}
......@@ -1121,7 +1120,7 @@ glade_app_command_copy (void)
for (list = glade_app_get_selection ();
list && list->data; list = list->next)
{
widget = glade_widget_get_from_gobject (GTK_WIDGET (list->data));
widget = glade_widget_get_from_gobject (list->data);
widgets = g_list_prepend (widgets, widget);
}
......@@ -1162,7 +1161,7 @@ glade_app_command_cut (void)
for (list = glade_app_get_selection ();
list && list->data; list = list->next)
{
widget = glade_widget_get_from_gobject (GTK_WIDGET (list->data));
widget = glade_widget_get_from_gobject (list->data);
widgets = g_list_prepend (widgets, widget);
}
......@@ -1272,7 +1271,8 @@ glade_app_command_paste (GladePlaceholder *placeholder)
/* A GladeFixed that doesnt use placeholders can only paste one
* at a time
*/
if (GTK_WIDGET_TOPLEVEL (widget->object) == FALSE &&
if (GTK_IS_WIDGET (widget->object) &&
GTK_WIDGET_TOPLEVEL (widget->object) == FALSE &&
parent && fixed && !GWA_USE_PLACEHOLDERS (parent->adaptor) &&
g_list_length (clipboard->selection) != 1)
{
......
......@@ -1353,7 +1353,7 @@ glade_base_editor_change_type (GladeBaseEditor *editor,
}
/* Set the name */
glade_widget_set_name (gchild_new, name);
glade_command_set_name (gchild_new, name);
if (GTK_IS_WIDGET (child_new))
gtk_widget_show_all (GTK_WIDGET (child_new));
......
......@@ -1300,7 +1300,8 @@ glade_command_add_execute (GladeCommandAddRemove *me)
* otherwise prioritize packing defaults.
*/
saved_props =
glade_widget_dup_properties (cdata->widget->packing_properties,
glade_widget_dup_properties (cdata->widget,
cdata->widget->packing_properties,
FALSE, FALSE, FALSE);
glade_widget_set_packing_properties (cdata->widget, cdata->parent);
......
......@@ -2440,6 +2440,18 @@ glade_project_add_object (GladeProject *project,
if (glade_project_has_object (project, object))
return;
if (old_project &&
glade_project_has_object (old_project, object))
{
g_critical ("Trying to add object %s to a project but its already in another project",
gwidget->name);
return;
}
/* set the project */
if (gwidget->project != project)
glade_widget_set_project (gwidget, project);
/* Create a name context for newly added toplevels... */
if (!gwidget->parent)
{
......
......@@ -547,6 +547,7 @@ glade_widget_build_object (GladeWidget *widget,
/**
* glade_widget_dup_properties:
* @dest_widget: the widget we are copying properties for
* @template_props: the #GladeProperty list to copy
* @as_load: whether to behave as if loading the project
* @copy_parentless: whether to copy reffed widgets at all
......@@ -558,7 +559,7 @@ glade_widget_build_object (GladeWidget *widget,
* Returns: A newly allocated #GList of new #GladeProperty objects.
*/
GList *
glade_widget_dup_properties (GList *template_props, gboolean as_load,
glade_widget_dup_properties (GladeWidget *dest_widget, GList *template_props, gboolean as_load,
gboolean copy_parentless, gboolean exact)
{
GList *list, *properties = NULL;
......@@ -577,17 +578,19 @@ glade_widget_dup_properties (GList *template_props, gboolean as_load,
GladeWidget *parentless;
glade_property_get (prop, &object);
prop = glade_property_dup (prop, NULL);
if (object)
{
parentless = glade_widget_get_from_gobject (object);
parentless = glade_widget_dup (parentless, exact);
prop = glade_property_dup (prop, NULL);
glade_widget_set_project (parentless, dest_widget->project);
glade_property_set (prop, parentless->object);
}
else
prop = glade_property_dup (prop, NULL);
}
else
prop = glade_property_dup (prop, NULL);
......@@ -715,7 +718,7 @@ glade_widget_constructor (GType type,
if (gwidget->construct_template)
{
properties = glade_widget_dup_properties
(gwidget->construct_template->properties, FALSE, TRUE, gwidget->construct_exact);
(gwidget, gwidget->construct_template->properties, FALSE, TRUE, gwidget->construct_exact);
glade_widget_set_properties (gwidget, properties);
}
......@@ -1472,7 +1475,7 @@ glade_widget_dup_internal (GladeWidget *parent,
if (gwidget->packing_properties == NULL)
gwidget->packing_properties =
glade_widget_dup_properties (template_widget->packing_properties, FALSE, FALSE, FALSE);
glade_widget_dup_properties (gwidget, template_widget->packing_properties, FALSE, FALSE, FALSE);
/* If custom properties are still at thier
* default value, they need to be synced.
......@@ -1539,7 +1542,7 @@ glade_widget_extract_children (GladeWidget *gwidget)
extract->internal_name = g_strdup (gchild->internal);
extract->internal_list = glade_widget_extract_children (gchild);
extract->properties =
glade_widget_dup_properties (gchild->properties, TRUE, FALSE, FALSE);
glade_widget_dup_properties (gchild, gchild->properties, TRUE, FALSE, FALSE);
extract_list = g_list_prepend (extract_list, extract);
......@@ -1556,7 +1559,7 @@ glade_widget_extract_children (GladeWidget *gwidget)
*/
extract->properties =
glade_widget_dup_properties
(gchild->packing_properties, TRUE, FALSE, FALSE);
(gchild, gchild->packing_properties, TRUE, FALSE, FALSE);
glade_widget_remove_child (gwidget, gchild);
}
......@@ -2206,6 +2209,8 @@ glade_widget_copy_properties (GladeWidget *widget,
parentless = glade_widget_get_from_gobject (object);
parentless = glade_widget_dup (parentless, exact);
glade_widget_set_project (parentless, widget->project);
glade_property_set (widget_prop, parentless->object);
}
else
......
......@@ -176,7 +176,8 @@ GladeProperty *glade_widget_get_property (GladeWidget *w
GladeProperty *glade_widget_get_pack_property (GladeWidget *widget,
const gchar *id_property);
GList *glade_widget_dup_properties (GList *template_props,
GList *glade_widget_dup_properties (GladeWidget *dest_widget,
GList *template_props,
gboolean as_load,
gboolean copy_parentless,
gboolean exact);
......
......@@ -150,9 +150,9 @@ glade_cell_renderer_editor_load (GladeEditable *editable,
if (use_attr)
{
gtk_widget_show (tab->use_attr_label);
// gtk_widget_show (tab->use_attr_label);
gtk_widget_show (tab->use_attr_eprop);
gtk_widget_hide (tab->use_prop_label);
//gtk_widget_hide (tab->use_prop_label);
gtk_widget_hide (tab->use_prop_eprop);
}
else
......@@ -422,41 +422,47 @@ glade_cell_renderer_editor_new (GladeWidgetAdaptor *adaptor,
/* Label appearance... */
hbox = gtk_hbox_new (FALSE, 0);
str = g_strdup_printf (_("Retrieve <b>%s</b> from model (type %s)"),
pclass->name, g_type_name (pclass->pspec->value_type));
label = gtk_label_new (str);
g_free (str);
/* str = g_strdup_printf (_("Retrieve <b>%s</b> from model (type %s)"), */
/* pclass->name, g_type_name (pclass->pspec->value_type)); */
/* label = gtk_label_new (str); */
/* g_free (str); */
gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
gtk_label_set_line_wrap (GTK_LABEL(label), TRUE);
gtk_label_set_line_wrap_mode (GTK_LABEL(label), PANGO_WRAP_WORD_CHAR);
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
/* gtk_label_set_use_markup (GTK_LABEL (label), TRUE); */
/* gtk_label_set_line_wrap (GTK_LABEL(label), TRUE); */
/* gtk_label_set_line_wrap_mode (GTK_LABEL(label), PANGO_WRAP_WORD_CHAR); */
/* gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); */
tab->attributes_check = gtk_check_button_new ();
str = g_strdup_printf (_("Retrieve %s from model (type %s)"),
pclass->name, g_type_name (pclass->pspec->value_type));
gtk_widget_set_tooltip_text (tab->attributes_check, str);
g_free (str);
gtk_box_pack_start (GTK_BOX (hbox), tab->attributes_check, FALSE, FALSE, 4);
gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 4);
//gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 4);
gtk_box_pack_start (GTK_BOX (renderer_editor), hbox, FALSE, FALSE, 0);
/* A Hack so that PANGO_WRAP_WORD_CHAR works nicely */
g_object_set_data (G_OBJECT (hbox), "attributes-check", tab->attributes_check);
g_signal_connect (G_OBJECT (hbox), "size-request",
G_CALLBACK (label_size_request), NULL);
g_signal_connect_after (G_OBJECT (hbox), "size-allocate",
G_CALLBACK (label_size_allocate_after), label);
/* g_signal_connect (G_OBJECT (hbox), "size-request", */
/* G_CALLBACK (label_size_request), NULL); */
/* g_signal_connect_after (G_OBJECT (hbox), "size-allocate", */
/* G_CALLBACK (label_size_allocate_after), label); */
alignment = gtk_alignment_new (1.0F, 1.0F, 1.0F, 1.0F);
gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 12, 0);
gtk_box_pack_start (GTK_BOX (renderer_editor), alignment, FALSE, FALSE, 0);
/* alignment = gtk_alignment_new (1.0F, 1.0F, 1.0F, 1.0F); */
/* gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 12, 0); */
/* gtk_box_pack_start (GTK_BOX (renderer_editor), alignment, FALSE, FALSE, 0); */
table = gtk_table_new (0, 0, FALSE);
gtk_container_add (GTK_CONTAINER (alignment), table);
/* table = gtk_table_new (0, 0, FALSE); */
/* gtk_container_add (GTK_CONTAINER (alignment), table); */
/* Edit property */
eprop = glade_widget_adaptor_create_eprop (adaptor, pclass, TRUE);
table_attach (table, eprop->item_label, 0, rows);
table_attach (table, GTK_WIDGET (eprop), 1, rows++);
gtk_box_pack_start (GTK_BOX (hbox), eprop->item_label, TRUE, TRUE, 4);
gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (eprop), FALSE, FALSE, 4);
/* table_attach (table, eprop->item_label, 0, rows); */
/* table_attach (table, GTK_WIDGET (eprop), 1, rows++); */
renderer_editor->properties = g_list_prepend (renderer_editor->properties, eprop);
tab->use_prop_label = eprop->item_label;
......@@ -464,8 +470,9 @@ glade_cell_renderer_editor_new (GladeWidgetAdaptor *adaptor,
/* Edit attribute */
eprop = glade_widget_adaptor_create_eprop (adaptor, attr_pclass, TRUE);
table_attach (table, eprop->item_label, 0, rows);
table_attach (table, GTK_WIDGET (eprop), 1, rows++);
gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (eprop), FALSE, FALSE, 4);
/* table_attach (table, eprop->item_label, 0, rows); */
/* table_attach (table, GTK_WIDGET (eprop), 1, rows++); */
renderer_editor->properties = g_list_prepend (renderer_editor->properties, eprop);
tab->use_attr_label = eprop->item_label;
......
......@@ -1273,7 +1273,7 @@ glade_gtk_widget_action_activate (GladeWidgetAdaptor *adaptor,
adaptor->title, gwidget->name);
/* Record packing properties */
saved_props = glade_widget_dup_properties (gwidget->packing_properties, FALSE, FALSE, FALSE);
saved_props = glade_widget_dup_properties (gwidget, gwidget->packing_properties, FALSE, FALSE, FALSE);
/* Remove "this" widget */
this_widget.data = gwidget;
......
......@@ -791,7 +791,8 @@ enum_flags_format_cell_data (GtkCellLayout *cell_layout,
string = glade_utils_string_from_value (&value, GLADE_PROJECT_FORMAT_GTKBUILDER);
g_object_set (cell, "text", glade_get_displayable_value (G_VALUE_TYPE (&value), string), NULL);
g_object_set (cell, "text", string && string[0] ?
glade_get_displayable_value (G_VALUE_TYPE (&value), string) : "", NULL);
g_free (string);
......
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