mirror of
https://gitlab.gnome.org/GNOME/glade.git
synced 2025-10-09 00:07:00 -04:00
Bye bye GladeWidget->children, GladeWidget->parent.
This commit is contained in:
parent
4043756d49
commit
db87c89b9f
13
ChangeLog
13
ChangeLog
@ -1,3 +1,16 @@
|
|||||||
|
2003-08-21 Paolo Borelli <pborelli@katamail.com>
|
||||||
|
|
||||||
|
* src/glade-widget.[ch]: remove the tree structure (GladeWidget->parent
|
||||||
|
and GladeWidget->children) from struct GladeWidget: gtk holds that info
|
||||||
|
for us.
|
||||||
|
* src/glade-project.[ch]: adapt for the above, it allows to simplify
|
||||||
|
add_widget and remove_widget.
|
||||||
|
* src/glade-command.c: adapt for the above changes.
|
||||||
|
* src/glade-project-view.c: ditto.
|
||||||
|
* src/glade-popuc.c: ditto.
|
||||||
|
* src/glade-editor.c: ditto.
|
||||||
|
* src/glade-gtk.c: ditto.
|
||||||
|
|
||||||
2003-08-20 Paolo Borelli <pborelli@katamail.com>
|
2003-08-20 Paolo Borelli <pborelli@katamail.com>
|
||||||
|
|
||||||
* src/glade-project-view.c (glade_project_view_add_columns): new
|
* src/glade-project-view.c (glade_project_view_add_columns): new
|
||||||
|
@ -573,13 +573,13 @@ glade_command_create_execute (GladeCommandCreateDelete *me)
|
|||||||
GladeWidget *widget = me->widget;
|
GladeWidget *widget = me->widget;
|
||||||
GladePlaceholder *placeholder = me->placeholder;
|
GladePlaceholder *placeholder = me->placeholder;
|
||||||
|
|
||||||
glade_project_add_widget (widget->project, widget, widget->parent);
|
|
||||||
glade_project_selection_set (widget->project, widget->widget, TRUE);
|
|
||||||
|
|
||||||
if (!GLADE_WIDGET_IS_TOPLEVEL (widget)) {
|
if (!GLADE_WIDGET_IS_TOPLEVEL (widget)) {
|
||||||
glade_placeholder_replace_with_widget (placeholder, widget);
|
glade_placeholder_replace_with_widget (placeholder, widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glade_project_add_widget (widget->project, widget->widget);
|
||||||
|
glade_project_selection_set (widget->project, widget->widget, TRUE);
|
||||||
|
|
||||||
if (GTK_IS_WIDGET (widget->widget))
|
if (GTK_IS_WIDGET (widget->widget))
|
||||||
gtk_widget_show_all (widget->widget);
|
gtk_widget_show_all (widget->widget);
|
||||||
|
|
||||||
@ -590,12 +590,14 @@ static gboolean
|
|||||||
glade_command_delete_execute (GladeCommandCreateDelete *me)
|
glade_command_delete_execute (GladeCommandCreateDelete *me)
|
||||||
{
|
{
|
||||||
GladeWidget *widget = me->widget;
|
GladeWidget *widget = me->widget;
|
||||||
|
GladeWidget *parent;
|
||||||
|
|
||||||
g_return_val_if_fail (widget != NULL, TRUE);
|
g_return_val_if_fail (widget != NULL, TRUE);
|
||||||
|
|
||||||
if (widget->parent) {
|
parent = glade_widget_get_parent (widget);
|
||||||
|
if (parent) {
|
||||||
if (me->placeholder == NULL) {
|
if (me->placeholder == NULL) {
|
||||||
me->placeholder = glade_placeholder_new (widget->parent);
|
me->placeholder = glade_placeholder_new ();
|
||||||
g_object_ref (G_OBJECT (me->placeholder));
|
g_object_ref (G_OBJECT (me->placeholder));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -604,7 +606,7 @@ glade_command_delete_execute (GladeCommandCreateDelete *me)
|
|||||||
|
|
||||||
gtk_widget_hide (widget->widget);
|
gtk_widget_hide (widget->widget);
|
||||||
|
|
||||||
glade_project_remove_widget (widget);
|
glade_project_remove_widget (widget->project, widget->widget);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -779,7 +781,7 @@ glade_command_paste_execute (GladeCommandCutPaste *me)
|
|||||||
glade_placeholder_replace_with_widget (placeholder, widget);
|
glade_placeholder_replace_with_widget (placeholder, widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
glade_project_add_widget (project, widget, parent);
|
glade_project_add_widget (project, widget->widget);
|
||||||
glade_project_selection_set (widget->project, widget->widget, TRUE);
|
glade_project_selection_set (widget->project, widget->widget, TRUE);
|
||||||
|
|
||||||
if (GTK_IS_WIDGET (widget->widget))
|
if (GTK_IS_WIDGET (widget->widget))
|
||||||
@ -794,14 +796,16 @@ static gboolean
|
|||||||
glade_command_cut_execute (GladeCommandCutPaste *me)
|
glade_command_cut_execute (GladeCommandCutPaste *me)
|
||||||
{
|
{
|
||||||
GladeWidget *widget = me->widget;
|
GladeWidget *widget = me->widget;
|
||||||
|
GladeWidget *parent;
|
||||||
|
|
||||||
g_return_val_if_fail (widget != NULL, TRUE);
|
g_return_val_if_fail (widget != NULL, TRUE);
|
||||||
|
|
||||||
glade_clipboard_add (me->clipboard, widget);
|
glade_clipboard_add (me->clipboard, widget);
|
||||||
|
|
||||||
if (widget->parent) {
|
parent = glade_widget_get_parent (widget);
|
||||||
|
if (parent) {
|
||||||
if (me->placeholder == NULL) {
|
if (me->placeholder == NULL) {
|
||||||
me->placeholder = glade_placeholder_new (widget->parent);
|
me->placeholder = glade_placeholder_new ();
|
||||||
g_object_ref (G_OBJECT (me->placeholder));
|
g_object_ref (G_OBJECT (me->placeholder));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -810,7 +814,7 @@ glade_command_cut_execute (GladeCommandCutPaste *me)
|
|||||||
|
|
||||||
gtk_widget_hide (widget->widget);
|
gtk_widget_hide (widget->widget);
|
||||||
|
|
||||||
glade_project_remove_widget (widget);
|
glade_project_remove_widget (widget->project, widget->widget);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -1365,6 +1365,7 @@ glade_editor_load_packing_page (GladeEditor *editor, GladeWidget *widget)
|
|||||||
GladeEditorProperty *editor_property;
|
GladeEditorProperty *editor_property;
|
||||||
GladeEditorTable *table;
|
GladeEditorTable *table;
|
||||||
GladePropertyClass *property_class;
|
GladePropertyClass *property_class;
|
||||||
|
GladeWidget *parent;
|
||||||
GtkContainer *container;
|
GtkContainer *container;
|
||||||
GList *list;
|
GList *list;
|
||||||
|
|
||||||
@ -1389,7 +1390,8 @@ glade_editor_load_packing_page (GladeEditor *editor, GladeWidget *widget)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/* if the widget is a toplevel there are no packing properties */
|
/* if the widget is a toplevel there are no packing properties */
|
||||||
if (!widget->parent)
|
parent = glade_widget_get_parent (widget);
|
||||||
|
if (!parent)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Now add the new properties */
|
/* Now add the new properties */
|
||||||
@ -1398,8 +1400,7 @@ glade_editor_load_packing_page (GladeEditor *editor, GladeWidget *widget)
|
|||||||
table->common = FALSE;
|
table->common = FALSE;
|
||||||
table->packing = TRUE;
|
table->packing = TRUE;
|
||||||
|
|
||||||
list = widget->parent->class->child_properties;
|
for (list = parent->class->child_properties; list; list = list->next) {
|
||||||
for (; list; list = list->next) {
|
|
||||||
property_class = list->data;
|
property_class = list->data;
|
||||||
g_assert (property_class->packing == TRUE);
|
g_assert (property_class->packing == TRUE);
|
||||||
editor_property = glade_editor_table_append_item (table, property_class);
|
editor_property = glade_editor_table_append_item (table, property_class);
|
||||||
|
@ -226,7 +226,7 @@ glade_gtk_box_set_size (GObject *object, GValue *value)
|
|||||||
|
|
||||||
glade_widget = glade_widget_get_from_gtk_widget (child_widget);
|
glade_widget = glade_widget_get_from_gtk_widget (child_widget);
|
||||||
if (glade_widget) /* it may be NULL, e.g a placeholder */
|
if (glade_widget) /* it may be NULL, e.g a placeholder */
|
||||||
glade_project_remove_widget (glade_widget);
|
glade_project_remove_widget (glade_widget->project, child_widget);
|
||||||
|
|
||||||
gtk_container_remove (GTK_CONTAINER (box), child_widget);
|
gtk_container_remove (GTK_CONTAINER (box), child_widget);
|
||||||
|
|
||||||
@ -299,9 +299,8 @@ glade_gtk_notebook_set_n_pages (GObject *object, GValue *value)
|
|||||||
* If we got it, and its not a placeholder, remove it
|
* If we got it, and its not a placeholder, remove it
|
||||||
* from project.
|
* from project.
|
||||||
*/
|
*/
|
||||||
if (child_gwidget) {
|
if (child_gwidget)
|
||||||
glade_project_remove_widget (child_gwidget);
|
glade_project_remove_widget (child_gwidget->project, child_widget);
|
||||||
}
|
|
||||||
|
|
||||||
gtk_notebook_remove_page (notebook, old_size-1);
|
gtk_notebook_remove_page (notebook, old_size-1);
|
||||||
old_size--;
|
old_size--;
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
#include "glade.h"
|
#include "glade.h"
|
||||||
#include "glade-widget.h"
|
#include "glade-widget.h"
|
||||||
|
#include "glade-widget-class.h"
|
||||||
#include "glade-popup.h"
|
#include "glade-popup.h"
|
||||||
#include "glade-placeholder.h"
|
#include "glade-placeholder.h"
|
||||||
#include "glade-clipboard.h"
|
#include "glade-clipboard.h"
|
||||||
@ -130,7 +131,7 @@ glade_popup_populate_childs(GtkWidget* popup_menu, GladeWidget* parent)
|
|||||||
gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu),
|
gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu),
|
||||||
child);
|
child);
|
||||||
|
|
||||||
parent = parent->parent;
|
parent = glade_widget_get_parent (parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,8 +153,11 @@ glade_popup_create_menu (GladeWidget *widget, gboolean add_childs)
|
|||||||
glade_popup_append_item (popup_menu, GTK_STOCK_DELETE, NULL, TRUE,
|
glade_popup_append_item (popup_menu, GTK_STOCK_DELETE, NULL, TRUE,
|
||||||
glade_popup_delete_cb, widget);
|
glade_popup_delete_cb, widget);
|
||||||
|
|
||||||
if (add_childs && widget->parent)
|
if (add_childs && !GLADE_WIDGET_IS_TOPLEVEL (widget)) {
|
||||||
glade_popup_populate_childs(popup_menu, widget->parent);
|
GladeWidget *parent = glade_widget_get_parent (widget);
|
||||||
|
g_return_val_if_fail (GLADE_IS_WIDGET (parent), popup_menu);
|
||||||
|
glade_popup_populate_childs(popup_menu, parent);
|
||||||
|
}
|
||||||
|
|
||||||
return popup_menu;
|
return popup_menu;
|
||||||
}
|
}
|
||||||
|
@ -218,6 +218,7 @@ glade_project_view_add_item (GladeProjectView *view,
|
|||||||
GladeWidget *widget)
|
GladeWidget *widget)
|
||||||
{
|
{
|
||||||
GladeWidgetClass *class;
|
GladeWidgetClass *class;
|
||||||
|
GladeWidget *parent;
|
||||||
GtkTreeStore *model;
|
GtkTreeStore *model;
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
GtkTreeIter *parent_iter = NULL;
|
GtkTreeIter *parent_iter = NULL;
|
||||||
@ -231,10 +232,11 @@ glade_project_view_add_item (GladeProjectView *view,
|
|||||||
|
|
||||||
model = view->model;
|
model = view->model;
|
||||||
|
|
||||||
if (widget->parent != NULL)
|
parent = glade_widget_get_parent (widget);
|
||||||
|
if (parent)
|
||||||
parent_iter = glade_project_view_find_iter_by_widget (GTK_TREE_MODEL (model),
|
parent_iter = glade_project_view_find_iter_by_widget (GTK_TREE_MODEL (model),
|
||||||
widget->parent);
|
parent);
|
||||||
|
|
||||||
gtk_tree_store_append (model, &iter, parent_iter);
|
gtk_tree_store_append (model, &iter, parent_iter);
|
||||||
gtk_tree_store_set (model, &iter,
|
gtk_tree_store_set (model, &iter,
|
||||||
WIDGET_COLUMN, widget,
|
WIDGET_COLUMN, widget,
|
||||||
|
@ -164,12 +164,21 @@ glade_project_selection_changed (GladeProject *project)
|
|||||||
0);
|
0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
/**
|
||||||
glade_project_add_widget_real (GladeProject *project,
|
* glade_project_add_widget:
|
||||||
GtkWidget *widget)
|
* @project: the project the widget is added to
|
||||||
|
* @widget: the GtkWidget to add
|
||||||
|
*
|
||||||
|
* Adds a widget to the project.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
glade_project_add_widget (GladeProject *project, GtkWidget *widget)
|
||||||
{
|
{
|
||||||
GladeWidget *gwidget;
|
GladeWidget *gwidget;
|
||||||
|
|
||||||
|
g_return_if_fail (GLADE_IS_PROJECT (project));
|
||||||
|
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||||
|
|
||||||
/* We don't list placeholders */
|
/* We don't list placeholders */
|
||||||
if (GLADE_IS_PLACEHOLDER (widget))
|
if (GLADE_IS_PLACEHOLDER (widget))
|
||||||
return;
|
return;
|
||||||
@ -182,7 +191,7 @@ glade_project_add_widget_real (GladeProject *project,
|
|||||||
list = gtk_container_get_children (GTK_CONTAINER (widget));
|
list = gtk_container_get_children (GTK_CONTAINER (widget));
|
||||||
for (; list; list = list->next) {
|
for (; list; list = list->next) {
|
||||||
child = list->data;
|
child = list->data;
|
||||||
glade_project_add_widget_real (project, child);
|
glade_project_add_widget (project, child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,6 +211,7 @@ glade_project_add_widget_real (GladeProject *project,
|
|||||||
gwidget->project = project;
|
gwidget->project = project;
|
||||||
|
|
||||||
project->widgets = g_list_prepend (project->widgets, widget);
|
project->widgets = g_list_prepend (project->widgets, widget);
|
||||||
|
project->changed = TRUE;
|
||||||
g_signal_emit (G_OBJECT (project),
|
g_signal_emit (G_OBJECT (project),
|
||||||
glade_project_signals [ADD_WIDGET],
|
glade_project_signals [ADD_WIDGET],
|
||||||
0,
|
0,
|
||||||
@ -209,46 +219,23 @@ glade_project_add_widget_real (GladeProject *project,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* glade_project_add_widget:
|
* glade_project_remove_widget:
|
||||||
* @project: the project the widget is added to
|
* @project: the project the widget is removed from
|
||||||
* @widget: the GladeWidget to add
|
* @widget: the GtkWidget to remove
|
||||||
* @parent: the GladeWidget @widget is reparented to
|
|
||||||
*
|
*
|
||||||
* Adds a widget to the project. Parent should be NULL for toplevels.
|
* Remove a widget from the project.
|
||||||
*/
|
|
||||||
void
|
|
||||||
glade_project_add_widget (GladeProject *project,
|
|
||||||
GladeWidget *widget,
|
|
||||||
GladeWidget *parent)
|
|
||||||
{
|
|
||||||
g_return_if_fail (GLADE_IS_PROJECT (project));
|
|
||||||
g_return_if_fail (GLADE_IS_WIDGET (widget));
|
|
||||||
|
|
||||||
glade_project_add_widget_real (project, widget->widget);
|
|
||||||
|
|
||||||
/* reparent */
|
|
||||||
widget->parent = parent;
|
|
||||||
if (parent) {
|
|
||||||
g_return_if_fail (GLADE_IS_WIDGET (parent));
|
|
||||||
|
|
||||||
widget->parent = parent;
|
|
||||||
parent->children = g_list_append (parent->children, widget);
|
|
||||||
}
|
|
||||||
|
|
||||||
project->changed = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Note that when removing the GtkWidget from the project we
|
* Note that when removing the GtkWidget from the project we
|
||||||
* don't change ->project in the associated GladeWidget, this
|
* don't change ->project in the associated GladeWidget, this
|
||||||
* way UNDO works.
|
* way UNDO works.
|
||||||
*/
|
*/
|
||||||
static void
|
void
|
||||||
glade_project_remove_widget_real (GladeProject *project,
|
glade_project_remove_widget (GladeProject *project, GtkWidget *widget)
|
||||||
GtkWidget *widget)
|
|
||||||
{
|
{
|
||||||
GladeWidget *gwidget;
|
GladeWidget *gwidget;
|
||||||
|
|
||||||
|
g_return_if_fail (GLADE_IS_PROJECT (project));
|
||||||
|
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||||
|
|
||||||
if (GLADE_IS_PLACEHOLDER (widget))
|
if (GLADE_IS_PLACEHOLDER (widget))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -260,7 +247,7 @@ glade_project_remove_widget_real (GladeProject *project,
|
|||||||
list = gtk_container_get_children (GTK_CONTAINER (widget));
|
list = gtk_container_get_children (GTK_CONTAINER (widget));
|
||||||
for (; list; list = list->next) {
|
for (; list; list = list->next) {
|
||||||
child = list->data;
|
child = list->data;
|
||||||
glade_project_remove_widget_real (project, child);
|
glade_project_remove_widget (project, child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,38 +259,13 @@ glade_project_remove_widget_real (GladeProject *project,
|
|||||||
glade_project_selection_changed (project);
|
glade_project_selection_changed (project);
|
||||||
|
|
||||||
project->widgets = g_list_remove (project->widgets, widget);
|
project->widgets = g_list_remove (project->widgets, widget);
|
||||||
|
project->changed = TRUE;
|
||||||
g_signal_emit (G_OBJECT (project),
|
g_signal_emit (G_OBJECT (project),
|
||||||
glade_project_signals [REMOVE_WIDGET],
|
glade_project_signals [REMOVE_WIDGET],
|
||||||
0,
|
0,
|
||||||
gwidget);
|
gwidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* glade_project_remove_widget:
|
|
||||||
* @widget: the GladeWidget to remove
|
|
||||||
*
|
|
||||||
* Remove a widget from the project.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
glade_project_remove_widget (GladeWidget *widget)
|
|
||||||
{
|
|
||||||
GladeWidget *parent;
|
|
||||||
|
|
||||||
g_return_if_fail (GLADE_IS_WIDGET (widget));
|
|
||||||
|
|
||||||
glade_project_remove_widget_real (widget->project, widget->widget);
|
|
||||||
|
|
||||||
/* remove from the parent's children list */
|
|
||||||
parent = widget->parent;
|
|
||||||
if (parent) {
|
|
||||||
g_return_if_fail (GLADE_IS_WIDGET (parent));
|
|
||||||
|
|
||||||
parent->children = g_list_remove (parent->children, widget);
|
|
||||||
}
|
|
||||||
|
|
||||||
widget->project->changed = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
glade_project_widget_name_changed (GladeProject *project,
|
glade_project_widget_name_changed (GladeProject *project,
|
||||||
GladeWidget *widget)
|
GladeWidget *widget)
|
||||||
|
@ -70,11 +70,8 @@ GladeProject *glade_project_new (gboolean untitled);
|
|||||||
GladeProject *glade_project_open (const gchar *path);
|
GladeProject *glade_project_open (const gchar *path);
|
||||||
gboolean glade_project_save (GladeProject *project, const gchar *path);
|
gboolean glade_project_save (GladeProject *project, const gchar *path);
|
||||||
|
|
||||||
/* Widget related stuff */
|
void glade_project_add_widget (GladeProject *project, GtkWidget *widget);
|
||||||
void glade_project_remove_widget (GladeWidget *widget);
|
void glade_project_remove_widget (GladeProject *project, GtkWidget *widget);
|
||||||
void glade_project_add_widget (GladeProject *project,
|
|
||||||
GladeWidget *widget,
|
|
||||||
GladeWidget *parent);
|
|
||||||
|
|
||||||
GladeWidget *glade_project_get_widget_by_name (GladeProject *project, const char *name);
|
GladeWidget *glade_project_get_widget_by_name (GladeProject *project, const char *name);
|
||||||
char *glade_project_new_widget_name (GladeProject *project, const char *base_name);
|
char *glade_project_new_widget_name (GladeProject *project, const char *base_name);
|
||||||
|
@ -192,7 +192,8 @@ static void
|
|||||||
glade_property_set_property (GladeProperty *property, const GValue *value)
|
glade_property_set_property (GladeProperty *property, const GValue *value)
|
||||||
{
|
{
|
||||||
if (property->class->packing) {
|
if (property->class->packing) {
|
||||||
GtkContainer *container = GTK_CONTAINER (property->widget->parent->widget);
|
GladeWidget *parent = glade_widget_get_parent (property->widget);
|
||||||
|
GtkContainer *container = GTK_CONTAINER (parent->widget);
|
||||||
GtkWidget *child = property->widget->widget;
|
GtkWidget *child = property->widget->widget;
|
||||||
gtk_container_child_set_property (container, child, property->class->id, value);
|
gtk_container_child_set_property (container, child, property->class->id, value);
|
||||||
} else {
|
} else {
|
||||||
|
@ -104,8 +104,6 @@ glade_widget_new (GladeWidgetClass *class)
|
|||||||
/* we don't have packing properties until we container add the widget */
|
/* we don't have packing properties until we container add the widget */
|
||||||
widget->packing_properties = NULL;
|
widget->packing_properties = NULL;
|
||||||
widget->signals = NULL;
|
widget->signals = NULL;
|
||||||
widget->parent = NULL;
|
|
||||||
widget->children = NULL;
|
|
||||||
|
|
||||||
return widget;
|
return widget;
|
||||||
}
|
}
|
||||||
@ -129,6 +127,34 @@ glade_widget_get_from_gtk_widget (GtkWidget *widget)
|
|||||||
return glade_widget;
|
return glade_widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* glade_widget_get_parent:
|
||||||
|
* @widget
|
||||||
|
*
|
||||||
|
* Convenience function to retrieve the GladeWidget associated
|
||||||
|
* to the parent of @widget.
|
||||||
|
* Returns NULL if it is a toplevel.
|
||||||
|
**/
|
||||||
|
GladeWidget *
|
||||||
|
glade_widget_get_parent (GladeWidget *widget)
|
||||||
|
{
|
||||||
|
GladeWidget *parent = NULL;
|
||||||
|
GtkWidget *parent_widget;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
|
||||||
|
|
||||||
|
if (GLADE_WIDGET_IS_TOPLEVEL (widget))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
parent_widget = gtk_widget_get_parent (widget->widget);
|
||||||
|
g_return_val_if_fail (parent_widget != NULL, NULL);
|
||||||
|
|
||||||
|
parent = glade_widget_get_from_gtk_widget (parent_widget);
|
||||||
|
g_return_val_if_fail (GLADE_IS_WIDGET (parent), NULL);
|
||||||
|
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
|
||||||
/* A temp data struct that we use when looking for a widget inside a container
|
/* A temp data struct that we use when looking for a widget inside a container
|
||||||
* we need a struct, because the forall can only pass one pointer
|
* we need a struct, because the forall can only pass one pointer
|
||||||
*/
|
*/
|
||||||
@ -529,7 +555,6 @@ glade_widget_free (GladeWidget *widget)
|
|||||||
widget->class = NULL;
|
widget->class = NULL;
|
||||||
widget->project = NULL;
|
widget->project = NULL;
|
||||||
widget->widget = NULL;
|
widget->widget = NULL;
|
||||||
widget->parent = NULL;
|
|
||||||
|
|
||||||
if (widget->name)
|
if (widget->name)
|
||||||
g_free (widget->name);
|
g_free (widget->name);
|
||||||
@ -636,7 +661,6 @@ glade_widget_new_full (GladeWidgetClass *class,
|
|||||||
|
|
||||||
widget = glade_widget_new (class);
|
widget = glade_widget_new (class);
|
||||||
widget->name = glade_widget_new_name (project, class);
|
widget->name = glade_widget_new_name (project, class);
|
||||||
widget->parent = parent;
|
|
||||||
widget->project = project;
|
widget->project = project;
|
||||||
|
|
||||||
widget->widget = glade_widget_create_gtk_widget (class);
|
widget->widget = glade_widget_create_gtk_widget (class);
|
||||||
@ -1037,15 +1061,12 @@ glade_widget_replace_with_placeholder (GladeWidget *widget,
|
|||||||
g_return_if_fail (GLADE_IS_WIDGET (widget));
|
g_return_if_fail (GLADE_IS_WIDGET (widget));
|
||||||
g_return_if_fail (GLADE_IS_PLACEHOLDER (placeholder));
|
g_return_if_fail (GLADE_IS_PLACEHOLDER (placeholder));
|
||||||
|
|
||||||
parent = widget->parent;
|
parent = glade_widget_get_parent (widget);
|
||||||
|
|
||||||
if (parent->class->placeholder_replace) {
|
if (parent->class->placeholder_replace) {
|
||||||
parent->class->placeholder_replace (widget->widget,
|
parent->class->placeholder_replace (widget->widget,
|
||||||
GTK_WIDGET (placeholder),
|
GTK_WIDGET (placeholder),
|
||||||
parent->widget);
|
parent->widget);
|
||||||
|
|
||||||
/* Remove it from the parent's child list */
|
|
||||||
widget->parent->children = g_list_remove (widget->parent->children, widget);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1403,7 +1424,7 @@ glade_widget_new_child_from_node (GladeXmlNode *node,
|
|||||||
/* is it a placeholder? */
|
/* is it a placeholder? */
|
||||||
child_node = glade_xml_search_child (node, GLADE_XML_TAG_PLACEHOLDER);
|
child_node = glade_xml_search_child (node, GLADE_XML_TAG_PLACEHOLDER);
|
||||||
if (child_node) {
|
if (child_node) {
|
||||||
child_widget = glade_placeholder_new (parent);
|
child_widget = glade_placeholder_new ();
|
||||||
gtk_container_add (GTK_CONTAINER (parent->widget), child_widget);
|
gtk_container_add (GTK_CONTAINER (parent->widget), child_widget);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -8,10 +8,9 @@ G_BEGIN_DECLS
|
|||||||
#define GLADE_WIDGET(w) ((GladeWidget *)w)
|
#define GLADE_WIDGET(w) ((GladeWidget *)w)
|
||||||
#define GLADE_IS_WIDGET(w) (w != NULL)
|
#define GLADE_IS_WIDGET(w) (w != NULL)
|
||||||
|
|
||||||
/* A GladeWidget is an instance of a GladeWidgetClass. For every widget
|
/* A GladeWidget is an instance of a GladeWidgetClass.
|
||||||
* in the project there is a GladeWidget
|
* Each GtkWidget in the project has an associated GladeWidget.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct _GladeWidget
|
struct _GladeWidget
|
||||||
{
|
{
|
||||||
GladeWidgetClass *class; /* The class of the widget.
|
GladeWidgetClass *class; /* The class of the widget.
|
||||||
@ -52,33 +51,28 @@ struct _GladeWidget
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
GList *signals; /* A list of GladeSignals */
|
GList *signals; /* A list of GladeSignals */
|
||||||
|
|
||||||
/* Tree Structure */
|
|
||||||
GladeWidget *parent; /* The parent of this widget, NULL if this is a
|
|
||||||
* toplevel widget.
|
|
||||||
*/
|
|
||||||
GList *children; /* A list of GladeWidget childrens of this widget.
|
|
||||||
*/
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
gchar * glade_widget_new_name (GladeProject *project, GladeWidgetClass *class);
|
gchar *glade_widget_new_name (GladeProject *project, GladeWidgetClass *class);
|
||||||
void glade_widget_set_contents (GladeWidget *widget);
|
void glade_widget_set_contents (GladeWidget *widget);
|
||||||
void glade_widget_connect_signals (GladeWidget *widget);
|
void glade_widget_connect_signals (GladeWidget *widget);
|
||||||
|
|
||||||
void glade_widget_set_packing_properties (GladeWidget *widget,
|
void glade_widget_set_packing_properties (GladeWidget *widget,
|
||||||
GladeWidgetClass *container_class);
|
GladeWidgetClass *container_class);
|
||||||
|
|
||||||
GladeWidget * glade_widget_new_from_class (GladeWidgetClass *class,
|
GladeWidget *glade_widget_new_from_class (GladeWidgetClass *class,
|
||||||
GladeProject *project,
|
GladeProject *project,
|
||||||
GladeWidget *parent);
|
GladeWidget *parent);
|
||||||
|
|
||||||
void glade_widget_set_default_packing_options (GladeWidget *widget);
|
void glade_widget_set_default_packing_options (GladeWidget *widget);
|
||||||
|
|
||||||
const gchar * glade_widget_get_name (GladeWidget *widget);
|
const gchar *glade_widget_get_name (GladeWidget *widget);
|
||||||
GladeWidgetClass * glade_widget_get_class (GladeWidget *widget);
|
|
||||||
GladeProperty * glade_widget_get_property_from_class (GladeWidget *widget,
|
GladeWidgetClass *glade_widget_get_class (GladeWidget *widget);
|
||||||
GladePropertyClass *property_class);
|
|
||||||
|
GladeProperty *glade_widget_get_property_from_class (GladeWidget *widget,
|
||||||
|
GladePropertyClass *property_class);
|
||||||
|
|
||||||
void glade_widget_set_name (GladeWidget *widget, const gchar *name);
|
void glade_widget_set_name (GladeWidget *widget, const gchar *name);
|
||||||
|
|
||||||
@ -89,6 +83,8 @@ void glade_widget_replace_with_placeholder (GladeWidget *widget,
|
|||||||
|
|
||||||
GladeWidget *glade_widget_get_from_gtk_widget (GtkWidget *widget);
|
GladeWidget *glade_widget_get_from_gtk_widget (GtkWidget *widget);
|
||||||
|
|
||||||
|
GladeWidget *glade_widget_get_parent (GladeWidget *widget);
|
||||||
|
|
||||||
/* Widget signal*/
|
/* Widget signal*/
|
||||||
GList *glade_widget_find_signal (GladeWidget *widget, GladeSignal *signal);
|
GList *glade_widget_find_signal (GladeWidget *widget, GladeSignal *signal);
|
||||||
void glade_widget_add_signal (GladeWidget *widget, GladeSignal *signal);
|
void glade_widget_add_signal (GladeWidget *widget, GladeSignal *signal);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user