Commit 3e54b226 authored by Tristan Van Berkom's avatar Tristan Van Berkom

Fixed adjustments when values are null in libglade mode


	* gladeui/glade-editor-property.c: Fixed adjustments when values are null in
	libglade mode

	* plugins/gtk+/gtk+.xml.in: Reorganized groups, added some more metadatas

	* plugins/gtk+/glade-convert.c: 
	  - Convert "text" property of TextView to a textbuffer and text property 
	    in builder format.
	  - Convert "tooltip" <--> "tooltip-text"
	
	* gladeui/glade-popup.c, gladeui/glade-inspector.c: enhanced menu for 
	inspector empty spots (paste toplevels)

	* gladeui/glade-editor-property.c: Adjustments in libglade had bugs, hardcoded
	default values here and made sure object is NULL on default.

	* gladeui/glade-widget.[ch]: Removed glade_widget_project_notify()

	* gladeui/glade-command.c: 
	  - glade_command_remove() implicitly makes commands to unset any properties 
	    reffering to the object being removed from the project.
	  - project conversions now cleanup unsupported widgets/properties

	* gladeui/glade-palette.c, gladeui/glade-app.c: Moved toplevel widget creation
	code from gladeapp to gladepalette.


svn path=/trunk/; revision=1955
parent ff13e3b8
2008-09-22 Tristan Van Berkom <tvb@gnome.org>
* gladeui/glade-editor-property.c: Fixed adjustments when values are null in
libglade mode
* plugins/gtk+/gtk+.xml.in: Reorganized groups, added some more metadatas
* plugins/gtk+/glade-convert.c:
- Convert "text" property of TextView to a textbuffer and text property
in builder format.
- Convert "tooltip" <--> "tooltip-text"
* gladeui/glade-popup.c, gladeui/glade-inspector.c: enhanced menu for
inspector empty spots (paste toplevels)
* gladeui/glade-editor-property.c: Adjustments in libglade had bugs, hardcoded
default values here and made sure object is NULL on default.
* gladeui/glade-widget.[ch]: Removed glade_widget_project_notify()
* gladeui/glade-command.c:
- glade_command_remove() implicitly makes commands to unset any properties
reffering to the object being removed from the project.
- project conversions now cleanup unsupported widgets/properties
* gladeui/glade-palette.c, gladeui/glade-app.c: Moved toplevel widget creation
code from gladeapp to gladepalette.
2008-09-21 Tristan Van Berkom <tvb@gnome.org>
* plugins/gtk+/glade-gtk.c: Set sizegroup_add action sensitive/insensitive
......
......@@ -288,29 +288,6 @@ glade_app_update_ui_default (GladeApp *app)
glade_app_refresh_undo_redo_button (app, list->data, FALSE);
}
static void
on_palette_button_clicked (GladePalette *palette, GladeApp *app)
{
GladeWidgetAdaptor *adaptor;
GladeWidget *widget;
g_return_if_fail (GLADE_IS_PALETTE (palette));
adaptor = glade_palette_get_current_item (palette);
/* class may be NULL if the selector was pressed */
if (adaptor && GWA_IS_TOPLEVEL (adaptor))
{
widget = glade_palette_create_root_widget (palette, adaptor);
/* if this is a top level widget set the accel group */
if (widget && app->priv->accel_group && GTK_IS_WINDOW (widget->object))
{
gtk_window_add_accel_group (GTK_WINDOW (widget->object),
app->priv->accel_group);
}
}
}
static gboolean
clipboard_view_on_delete_cb (GtkWidget *clipboard_view, GdkEvent *e, GladeApp *app)
{
......@@ -441,9 +418,6 @@ glade_app_init (GladeApp *app)
app->priv->palette = (GladePalette *) glade_palette_new (app->priv->catalogs);
g_object_ref_sink (app->priv->palette);
g_signal_connect (G_OBJECT (app->priv->palette), "toggled",
G_CALLBACK (on_palette_button_clicked), app);
/* Create Editor */
app->priv->editor = GLADE_EDITOR (glade_editor_new ());
g_object_ref_sink (GTK_OBJECT (app->priv->editor));
......@@ -1259,11 +1233,19 @@ glade_app_command_paste (GladePlaceholder *placeholder)
clipboard = glade_app_get_clipboard ();
/* If there is a selection, paste in to the selected widget, otherwise
* paste into the placeholder's parent.
* paste into the placeholder's parent, or at the toplevel
*/
parent = list ? glade_widget_get_from_gobject (list->data) :
(placeholder) ? glade_placeholder_get_parent (placeholder) : NULL;
widget = clipboard->selection ? clipboard->selection->data : NULL;
/* Ignore parent argument if we are pasting a toplevel
*/
if (g_list_length (clipboard->selection) == 1 &&
widget && GWA_IS_TOPLEVEL (widget->adaptor))
parent = NULL;
if (parent && GLADE_IS_FIXED (parent)) fixed = GLADE_FIXED (parent);
/* Check if parent is actually a container of any sort */
......@@ -1483,6 +1465,12 @@ glade_app_set_accel_group (GtkAccelGroup *accel_group)
app->priv->accel_group = accel_group;
}
GtkAccelGroup *
glade_app_get_accel_group (void)
{
return glade_app_get()->priv->accel_group;
}
static gboolean
glade_app_undo_button_destroyed (GtkWidget *button, GladeApp *app)
{
......
......@@ -45,8 +45,6 @@ G_BEGIN_DECLS
typedef struct _GladeApp GladeApp;
typedef struct _GladeAppPrivate GladeAppPrivate;
typedef struct _GladeAppClass GladeAppClass;
typedef enum _GladePointerMode GladePointerMode;
/**
* GladePointerMode:
......@@ -63,6 +61,8 @@ enum _GladePointerMode
GLADE_POINTER_ADD_WIDGET,
GLADE_POINTER_DRAG_RESIZE
};
typedef enum _GladePointerMode GladePointerMode;
struct _GladeApp
{
......@@ -162,6 +162,8 @@ void glade_app_set_transient_parent (GtkWindow *parent);
GtkWindow *glade_app_get_transient_parent (void);
void glade_app_set_accel_group (GtkAccelGroup *accel_group);
GtkAccelGroup *glade_app_get_accel_group (void);
void glade_app_update_instance_count (GladeProject *project);
......
......@@ -1043,6 +1043,21 @@ glade_command_add (GList *widgets,
} /* end of glade_command_add() */
static void
glade_command_delete_prop_refs (GladeWidget *widget)
{
GladeProperty *property;
while (widget->prop_refs)
{
property = GLADE_PROPERTY (widget->prop_refs->data);
glade_command_set_property (property, NULL);
}
}
/**
* glade_command_remove:
* @widgets: a #GList of #GladeWidgets
......@@ -1058,6 +1073,7 @@ glade_command_remove (GList *widgets)
CommandData *cdata;
GtkWidget *placeholder;
GList *list, *l;
gchar *desc;
g_return_if_fail (widgets != NULL);
......@@ -1079,6 +1095,16 @@ glade_command_remove (GList *widgets)
}
me->project = glade_widget_get_project (widget);
GLADE_COMMAND (me)->description = g_strdup ("dummy");
if (g_list_length (widgets) == 1)
desc = g_strdup_printf (_("Remove %s"),
GLADE_WIDGET (widgets->data)->name);
else
desc = g_strdup_printf (_("Remove multiple"));
glade_command_push_group (desc);
g_free (desc);
for (list = widgets; list && list->data; list = list->next)
{
......@@ -1088,6 +1114,9 @@ glade_command_remove (GList *widgets)
cdata->widget = g_object_ref (G_OBJECT (widget));
cdata->parent = glade_widget_get_parent (widget);
cdata->project = glade_widget_get_project (widget);
/* Undoably unset any object properties that may point to the removed object */
glade_command_delete_prop_refs (widget);
if (widget->internal)
g_critical ("Internal widget in Remove");
......@@ -1118,14 +1147,6 @@ glade_command_remove (GList *widgets)
}
}
if (g_list_length (widgets) == 1)
GLADE_COMMAND (me)->description =
g_strdup_printf (_("Remove %s"),
GLADE_WIDGET (widgets->data)->name);
else
GLADE_COMMAND (me)->description =
g_strdup_printf (_("Remove multiple"));
g_assert (widget);
glade_command_check_group (GLADE_COMMAND (me));
......@@ -1135,6 +1156,7 @@ glade_command_remove (GList *widgets)
else
g_object_unref (G_OBJECT (me));
glade_command_pop_group ();
} /* end of glade_command_remove() */
static void
......@@ -1192,13 +1214,10 @@ glade_command_add_execute (GladeCommandAddRemove *me)
g_strdup (cdata->special_type),
g_free);
}
}
/* Only transfer properties when they are from the clipboard,
* otherwise prioritize packing defaults.
*/
if (me->from_clipboard)
{
/* Only transfer properties when they are from the clipboard,
* otherwise prioritize packing defaults.
*/
saved_props =
glade_widget_dup_properties (cdata->widget->packing_properties, FALSE);
......@@ -2173,6 +2192,73 @@ glade_command_set_format_collapse (GladeCommand *this_cmd, GladeCommand *other_c
/* no unify/collapse */
}
static void
glade_command_convert_cleanup_props (GList *properties,
GladeProjectFormat fmt)
{
GladeProperty *property;
GList *list;
for (list = properties; list; list = list->next)
{
property = list->data;
if (glade_property_original_default (property))
continue;
/* Reset any unsupported properties to thier defaults */
if ((fmt == GLADE_PROJECT_FORMAT_GTKBUILDER &&
property->klass->libglade_only) ||
(fmt == GLADE_PROJECT_FORMAT_LIBGLADE &&
property->klass->libglade_unsupported))
{
GValue value = { 0, };
glade_property_get_default (property, &value);
glade_command_set_property (property, &value);
g_value_unset (&value);
}
}
}
static void
glade_command_convert_cleanup (GladeProject *project,
GladeProjectFormat fmt)
{
GladeWidget *widget;
const GList *objects;
for (objects = glade_project_get_objects (project); objects; objects = objects->next)
{
widget = glade_widget_get_from_gobject (objects->data);
/* If libglade-only widget going in builder format ... */
if ((fmt == GLADE_PROJECT_FORMAT_GTKBUILDER &&
GWA_LIBGLADE_ONLY (widget->adaptor)) ||
/* If going in libglade format... */
(fmt == GLADE_PROJECT_FORMAT_LIBGLADE &&
/* ... and widget is unsupported by libglade */
(GWA_LIBGLADE_UNSUPPORTED (widget->adaptor) ||
/* ... and widget is a non GtkWidget object */
!GTK_IS_WIDGET (widget->object) ||
/* ... and its a non-window toplevel */
(!widget->parent && !GTK_IS_WINDOW (widget->object)))))
{
GList delete = { 0, };
delete.data = widget;
glade_command_delete (&delete);
}
else
{
glade_command_convert_cleanup_props (widget->properties, fmt);
glade_command_convert_cleanup_props (widget->packing_properties, fmt);
}
}
}
/**
* glade_command_set_project_format:
* @project: a #GladeProject
......@@ -2219,6 +2305,8 @@ glade_command_set_project_format (GladeProject *project,
catalog = glade_app_get_catalog (cat_name);
glade_catalog_convert_project (catalog, project, fmt);
glade_command_convert_cleanup (project, fmt);
g_free (cat_name);
}
......
......@@ -2630,10 +2630,13 @@ glade_eprop_object_show_dialog (GtkWidget *dialog_button,
project = glade_widget_get_project (eprop->property->widget);
parent = gtk_widget_get_toplevel (GTK_WIDGET (eprop));
if (eprop->property->klass->create_type)
create_adaptor = glade_widget_adaptor_get_by_name (eprop->property->klass->create_type);
if (!create_adaptor)
create_adaptor = glade_widget_adaptor_get_by_type (eprop->klass->pspec->value_type);
if (glade_project_get_format (project) != GLADE_PROJECT_FORMAT_LIBGLADE)
{
if (eprop->property->klass->create_type)
create_adaptor = glade_widget_adaptor_get_by_name (eprop->property->klass->create_type);
if (!create_adaptor)
create_adaptor = glade_widget_adaptor_get_by_type (eprop->klass->pspec->value_type);
}
if (create_adaptor)
{
......@@ -3128,8 +3131,8 @@ glade_eprop_adjustment_load (GladeEditorProperty *eprop, GladeProperty *property
GladeEPropAdjustment *eprop_adj = GLADE_EPROP_ADJUSTMENT (eprop);
GladeProjectFormat fmt;
GObject *object;
GtkAdjustment *adj;
GtkAdjustment *adj = NULL;
/* Chain up first */
editor_property_class->load (eprop, property);
......@@ -3140,9 +3143,9 @@ glade_eprop_adjustment_load (GladeEditorProperty *eprop, GladeProperty *property
if (fmt == GLADE_PROJECT_FORMAT_LIBGLADE)
{
object = g_value_get_object (property->value);
if (object == NULL) return;
adj = GTK_ADJUSTMENT (object);
if (object)
adj = GTK_ADJUSTMENT (object);
/* Keep track of external adjustment changes */
g_signal_connect (object, "value-changed",
......@@ -3150,11 +3153,12 @@ glade_eprop_adjustment_load (GladeEditorProperty *eprop, GladeProperty *property
eprop);
/* Update adjustment's values */
eprop_adj->value_adj->lower = adj->lower;
eprop_adj->value_adj->upper = adj->upper;
eprop_adj->value_adj->step_increment = adj->step_increment;
eprop_adj->value_adj->page_increment = adj->page_increment;
eprop_adj->value_adj->page_size = adj->page_size;
eprop_adj->value_adj->value = adj ? adj->value : 0.0;
eprop_adj->value_adj->lower = adj ? adj->lower : 0.0;
eprop_adj->value_adj->upper = adj ? adj->upper : 100.0;
eprop_adj->value_adj->step_increment = adj ? adj->step_increment : 1;
eprop_adj->value_adj->page_increment = adj ? adj->page_increment : 10;
eprop_adj->value_adj->page_size = adj ? adj->page_size : 10;
/* Block Handlers */
g_signal_handler_block (eprop_adj->value, eprop_adj->ids.value);
......@@ -3165,12 +3169,14 @@ glade_eprop_adjustment_load (GladeEditorProperty *eprop, GladeProperty *property
g_signal_handler_block (eprop_adj->page_size, eprop_adj->ids.page_size);
/* Update spinbuttons values */
gtk_spin_button_set_value (GTK_SPIN_BUTTON (eprop_adj->value), adj->value);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (eprop_adj->lower), adj->lower);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (eprop_adj->upper), adj->upper);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (eprop_adj->step_increment), adj->step_increment);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (eprop_adj->page_increment), adj->page_increment);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (eprop_adj->page_size), adj->page_size);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (eprop_adj->value), eprop_adj->value_adj->value);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (eprop_adj->lower), eprop_adj->value_adj->lower);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (eprop_adj->upper), eprop_adj->value_adj->upper);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (eprop_adj->step_increment),
eprop_adj->value_adj->step_increment);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (eprop_adj->page_increment),
eprop_adj->value_adj->page_increment);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (eprop_adj->page_size), eprop_adj->value_adj->page_size);
/* Unblock Handlers */
g_signal_handler_unblock (eprop_adj->value, eprop_adj->ids.value);
......@@ -3180,9 +3186,8 @@ glade_eprop_adjustment_load (GladeEditorProperty *eprop, GladeProperty *property
g_signal_handler_unblock (eprop_adj->page_increment, eprop_adj->ids.page_increment);
g_signal_handler_unblock (eprop_adj->page_size, eprop_adj->ids.page_size);
gtk_notebook_set_page (GTK_NOTEBOOK (eprop_adj->notebook), 0);
gtk_widget_show (eprop_adj->libglade);
gtk_notebook_set_page (GTK_NOTEBOOK (eprop_adj->notebook), 0);
}
else
{
......@@ -3214,7 +3219,9 @@ glade_eprop_adjustment_dup_adj (GladeEditorProperty *eprop)
GObject *object;
object = g_value_get_object (eprop->property->value);
if (object == NULL) return NULL;
if (object == NULL)
return GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 100.0,
1.0, 10.0, 10.0));
adj = GTK_ADJUSTMENT (object);
......@@ -3233,8 +3240,20 @@ glade_eprop_adjustment_prop_changed_common (GladeEditorProperty *eprop,
GValue value = {0, };
g_value_init (&value, GTK_TYPE_ADJUSTMENT);
g_value_set_object (&value, G_OBJECT (adjustment));
if (adjustment->value == 0.00 &&
adjustment->lower == 0.00 &&
adjustment->upper == 100.00 &&
adjustment->step_increment == 1.00 &&
adjustment->page_increment == 10.00 &&
adjustment->page_size == 10.00)
{
gtk_object_destroy (GTK_OBJECT (adjustment));
g_value_set_object (&value, NULL);
}
else
g_value_set_object (&value, G_OBJECT (adjustment));
glade_editor_property_commit_no_callback (eprop, &value);
g_value_unset (&value);
......
......@@ -544,7 +544,8 @@ button_press_cb (GtkWidget *widget,
GtkTreePath *path = NULL;
gboolean handled = FALSE;
if (event->window == gtk_tree_view_get_bin_window (view))
if (event->button == 3 &&
event->window == gtk_tree_view_get_bin_window (view))
{
if (gtk_tree_view_get_path_at_pos (view, (gint) event->x, (gint) event->y,
&path, NULL,
......@@ -559,16 +560,21 @@ button_press_cb (GtkWidget *widget,
*/
gtk_tree_model_get (GTK_TREE_MODEL (inspector->priv->model), &iter,
WIDGET_COLUMN, &widget, -1);
if (widget != NULL && event->button == 3)
{
glade_popup_widget_pop (widget, event, FALSE);
if (widget != NULL)
glade_popup_widget_pop (widget, event, FALSE);
else
glade_popup_simple_pop (event);
handled = TRUE;
}
gtk_tree_path_free (path);
}
}
else
{
glade_popup_simple_pop (event);
handled = TRUE;
}
}
return handled;
}
......
......@@ -30,9 +30,7 @@
#include <gtk/gtkvbox.h>
/* forward declaration */
/* btw, this makes gtkdoc list GladeProject twice in gladeui-sections.txt wich gives a warning. */
struct GladeProject;
#include <gladeui/glade-xml-utils.h>
G_BEGIN_DECLS
......
......@@ -322,6 +322,33 @@ glade_palette_finalize (GObject *object)
G_OBJECT_CLASS (glade_palette_parent_class)->finalize (object);
}
static void
glade_palette_toggled (GladePalette *palette)
{
GladeProject *project;
GladeWidgetAdaptor *adaptor;
GladeWidget *widget;
g_return_if_fail (GLADE_IS_PALETTE (palette));
adaptor = glade_palette_get_current_item (palette);
/* class may be NULL if the selector was pressed */
if (adaptor && GWA_IS_TOPLEVEL (adaptor))
{
/* Inappropriate toplevel classes for libglade are
* disabled so no chance of creating a non-window toplevel here
*/
widget = glade_palette_create_root_widget (palette, adaptor);
/* if this is a top level widget set the accel group */
if (widget && glade_app_get_accel_group () && GTK_IS_WINDOW (widget->object))
{
gtk_window_add_accel_group (GTK_WINDOW (widget->object),
glade_app_get_accel_group ());
}
}
}
static void
glade_palette_class_init (GladePaletteClass *klass)
{
......@@ -331,7 +358,7 @@ glade_palette_class_init (GladePaletteClass *klass)
object_class = G_OBJECT_CLASS (klass);
widget_class = GTK_WIDGET_CLASS (klass);
klass->toggled = NULL;
klass->toggled = glade_palette_toggled;
object_class->get_property = glade_palette_get_property;
object_class->set_property = glade_palette_set_property;
......@@ -475,6 +502,7 @@ glade_palette_on_button_toggled (GtkWidget *button, GladePalette *palette)
g_signal_emit (G_OBJECT (palette), glade_palette_signals[TOGGLED], 0);
}
static GtkWidget*
glade_palette_new_item (GladePalette *palette, GladeWidgetAdaptor *adaptor)
{
......
......@@ -144,7 +144,10 @@ glade_popup_paste_cb (GtkMenuItem *item, GladeWidget *widget)
glade_util_clear_selection ();
/* The selected widget is the paste destination */
glade_app_selection_set (glade_widget_get_object (widget), FALSE);
if (widget)
glade_app_selection_set (glade_widget_get_object (widget), FALSE);
else
glade_app_selection_clear (FALSE);
glade_app_command_paste (NULL);
}
......@@ -412,15 +415,22 @@ glade_popup_create_menu (GladeWidget *widget,
GladePlaceholder *placeholder,
gboolean packing)
{
GladeProjectFormat fmt;
GladeProject *project;
GtkWidget *popup_menu;
gboolean sensitive;
GtkWidget *separator;
GList *list;
gboolean sensitive, non_window;
GladePlaceholder *tmp_placeholder;
gchar *book;
sensitive = glade_palette_get_current_item (glade_app_get_palette ()) != NULL;
if (!sensitive && !widget)
return NULL;
/* Resolve project format first... */
project = widget ? glade_widget_get_project (widget) :
placeholder ? glade_placeholder_get_project (placeholder) : glade_app_get_project ();
fmt = glade_project_get_format (project);
popup_menu = gtk_menu_new ();
......@@ -431,44 +441,53 @@ glade_popup_create_menu (GladeWidget *widget,
tmp_placeholder = find_placeholder (glade_widget_get_object (widget));
glade_popup_append_item (popup_menu, NULL, _("_Add widget here"), NULL, tmp_placeholder != NULL,
glade_popup_placeholder_add_cb, tmp_placeholder);
glade_popup_append_item (popup_menu, NULL, _("Add widget as _toplevel"), NULL, TRUE,
glade_popup_append_item (popup_menu, NULL, _("Add widget as _toplevel"), NULL,
fmt != GLADE_PROJECT_FORMAT_LIBGLADE,
glade_popup_root_add_cb, NULL);
}
if (!widget)
return popup_menu;
if (sensitive)
{
GtkWidget *separator = gtk_menu_item_new ();
separator = gtk_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), separator);
gtk_widget_show (separator);
}
glade_popup_append_item (popup_menu, NULL, _("_Select"), NULL, TRUE,
sensitive = (widget != NULL);
glade_popup_append_item (popup_menu, NULL, _("_Select"), NULL, sensitive,
glade_popup_select_cb, widget);
glade_popup_append_item (popup_menu, GTK_STOCK_CUT, NULL, NULL, TRUE,
glade_popup_append_item (popup_menu, GTK_STOCK_CUT, NULL, NULL, sensitive,
glade_popup_cut_cb, widget);
glade_popup_append_item (popup_menu, GTK_STOCK_COPY, NULL, NULL, TRUE,
glade_popup_append_item (popup_menu, GTK_STOCK_COPY, NULL, NULL, sensitive,
glade_popup_copy_cb, widget);
/* paste is placholder specific when the popup is on a placeholder */
sensitive = glade_clipboard_get_has_selection (glade_app_get_clipboard ());
non_window = FALSE;
for (list = glade_app_get_clipboard ()->selection; list; list = list->next)
if (!GTK_IS_WINDOW (GLADE_WIDGET (list->data)->object))
non_window = TRUE;
if (placeholder)
glade_popup_append_item (popup_menu, GTK_STOCK_PASTE, NULL, NULL, sensitive,
glade_popup_placeholder_paste_cb, placeholder);
else
else if (widget)
glade_popup_append_item (popup_menu, GTK_STOCK_PASTE, NULL, NULL, sensitive,
glade_popup_paste_cb, widget);
else
/* No toplevel non-GtkWindow pastes in libglade */
glade_popup_append_item (popup_menu, GTK_STOCK_PASTE, NULL, NULL,
sensitive && !(non_window && (fmt == GLADE_PROJECT_FORMAT_LIBGLADE)),
glade_popup_paste_cb, NULL);
glade_popup_append_item (popup_menu, GTK_STOCK_DELETE, NULL, NULL, TRUE,
glade_popup_append_item (popup_menu, GTK_STOCK_DELETE, NULL, NULL, (widget != NULL),
glade_popup_delete_cb, widget);
/* packing actions are a little different on placholders */
if (placeholder)
{
if (widget->actions)
if (widget && widget->actions)
{
GtkWidget *separator = gtk_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), separator);
......@@ -496,7 +515,7 @@ glade_popup_create_menu (GladeWidget *widget,
placeholder);
}
}
else if (widget->actions || (packing && widget->packing_actions))
else if (widget && (widget->actions || (packing && widget->packing_actions)))
{
GtkWidget *separator = gtk_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), separator);
......@@ -505,20 +524,21 @@ glade_popup_create_menu (GladeWidget *widget,
glade_popup_action_populate_menu (popup_menu, widget, NULL, packing);
}
g_object_get (widget->adaptor, "book", &book, NULL);
if (book)
if (widget)
{
GtkWidget *icon = glade_util_get_devhelp_icon (GTK_ICON_SIZE_MENU);
GtkWidget *separator = gtk_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), separator);
gtk_widget_show (separator);
glade_popup_append_item (popup_menu, NULL, _("Read _documentation"), icon, TRUE,
glade_popup_docs_cb, widget->adaptor);
g_object_get (widget->adaptor, "book", &book, NULL);
if (book)
{
GtkWidget *icon = glade_util_get_devhelp_icon (GTK_ICON_SIZE_MENU);
GtkWidget *separator = gtk_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), separator);
gtk_widget_show (separator);
glade_popup_append_item (popup_menu, NULL, _("Read _documentation"), icon, TRUE,
glade_popup_docs_cb, widget->adaptor);
}
g_free (book);
}
g_free (book);
return popup_menu;
}
......@@ -631,6 +651,8 @@ void
glade_popup_palette_pop (GladeWidgetAdaptor *adaptor,
GdkEventButton *event)
{
GladeProjectFormat fmt;
GladeProject *project;
GtkWidget *popup_menu;
gchar *book = NULL;
gint button;
......@@ -639,11 +661,14 @@ glade_popup_palette_pop (GladeWidgetAdaptor *adaptor,
g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor));
popup_menu = gtk_menu_new ();
project = glade_app_get_project ();
fmt = glade_project_get_format (project);
glade_popup_append_item (popup_menu, NULL, _("Add widget as _toplevel"), NULL, TRUE,
glade_popup_append_item (popup_menu, NULL, _("Add widget as _toplevel"), NULL,
(fmt != GLADE_PROJECT_FORMAT_LIBGLADE),
glade_popup_root_add_cb, adaptor);
g_object_get (adaptor, "book", &book, NULL);
if (book)
{
......
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2001 Ximian, Inc.
* Copyright (C) 2008 Tristan Van Berkom
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
......@@ -18,6 +19,7 @@
*
* Authors:
* Chema Celorio <chema@celorio.com>
* Tristan Van Berkom <tvb@gnome.org>
*/
#include <config.h>
......@@ -1661,13 +1663,14 @@ glade_project_verify_properties_internal (GladeWidget *widget,
glade_project_verify_property (widget->project, property, path_name, string, forwidget);
}
for (list = widget->packing_properties; list; list = list->next)
/* Sometimes widgets on the clipboard have packing props with no parent */
if (widget->parent)
{
property = list->data;
g_assert (widget->parent);
property = list->data;
glade_project_verify_property (widget->project, property, path_name, string, forwidget);
for (list = widget->packing_properties; list; list = list->next)
{
property = list->data;
glade_project_verify_property (widget->project, property, path_name, string, forwidget);