Commit 54bb92c3 authored by Chema Celorio's avatar Chema Celorio Committed by Jose Maria Celorio

save signals and child widgets too

2001-07-25  Chema Celorio  <chema@celorio.com>

	* src/glade-widget.c (glade_widget_write): save signals and child widgets too

	* src/glade-signal.c (glade_signal_write): new file, implement. We need to
	move stuff from glade-signal-editor into here.

	* src/glade-xml-utils.c (glade_xml_node_set_property_boolean): implement.
parent bbec1dc1
......@@ -41,6 +41,7 @@ glade2_SOURCES = \
glade-editor.c \
glade-gtk.c \
glade-utils.c \
glade-signal.c \
glade-signal-editor.c
noinst_HEADERS = \
......@@ -65,4 +66,5 @@ noinst_HEADERS = \
glade-gtk.h \
glade-catalog.h \
glade-utils.h \
glade-signal.h \
glade-xml-utils.h
......@@ -22,7 +22,6 @@
#include <string.h>
#include <string.h>
#include "glade.h"
#include "glade-project.h"
#include "glade-project-ui.h"
......
......@@ -27,6 +27,7 @@
#include "glade-widget.h"
#include "glade-widget-class.h"
#include "glade-signal.h"
#include "glade-signal-editor.h"
......@@ -205,7 +206,7 @@ glade_signal_editor_dialog_cb (GtkButton *button, GladeSignalEditor *editor)
* update the item at position 'iter' to the value of 'signal'
*/
static void
glade_signal_editor_update_signal (GladeSignalEditor *editor, GladeWidgetSignal *signal,
glade_signal_editor_update_signal (GladeSignalEditor *editor, GladeSignal *signal,
GtkTreeIter *iter)
{
GtkTreeStore *lst_model;
......@@ -344,14 +345,14 @@ glade_signal_editor_clear_entries (GladeSignalEditor *editor)
(editor->signal_after_button), FALSE);
}
static GladeWidgetSignal *
static GladeSignal *
glade_signal_editor_get_signal_at_iter (GladeSignalEditor *editor, GtkTreeIter *iter)
{
GladeWidgetSignal *signal;
GladeSignal *signal;
GtkTreeModel *model;
GValue *label;
signal = g_new0 (GladeWidgetSignal, 1);
signal = g_new0 (GladeSignal, 1);
model = gtk_tree_view_get_model (GTK_TREE_VIEW (editor->signals_list));
label = g_new0 (GValue, 1);
......@@ -378,20 +379,20 @@ glade_signal_editor_get_signal_at_iter (GladeSignalEditor *editor, GtkTreeIter *
* is appended to the list, however if a signal is supplied as old_signal,
* the func will find that signal and update it rather than add a new signal
*/
static GladeWidgetSignal *
static GladeSignal *
glade_signal_editor_update_widget_signal (GladeSignalEditor *editor,
GladeWidgetSignal *old_signal)
GladeSignal *old_signal)
{
GladeWidgetSignal *signal = NULL;
GladeWidgetSignal *sigtmp;
GladeSignal *signal = NULL;
GladeSignal *sigtmp;
GList *list;
if (old_signal == NULL) {
signal = g_new0 (GladeWidgetSignal, 1);
signal = g_new0 (GladeSignal, 1);
editor->widget->signals = g_list_append (editor->widget->signals, signal);
} else {
for (list = editor->widget->signals; list != NULL; list = list->next) {
sigtmp = (GladeWidgetSignal *) list->data;
sigtmp = (GladeSignal *) list->data;
if (!strcmp (sigtmp->name, old_signal->name) &&
!strcmp (sigtmp->handler, old_signal->handler) &&
sigtmp->after == old_signal->after) {
......@@ -416,7 +417,7 @@ glade_signal_editor_update_widget_signal (GladeSignalEditor *editor,
static void
glade_signal_editor_add_cb (GladeSignalEditor *editor)
{
GladeWidgetSignal *signal;
GladeSignal *signal;
g_return_if_fail (editor != NULL);
g_return_if_fail (editor->widget != NULL);
......@@ -436,8 +437,8 @@ glade_signal_editor_update_cb (GladeSignalEditor *editor)
GtkTreeIter iter;
GtkTreeSelection *select;
GtkTreeModel *model;
GladeWidgetSignal *old_sig;
GladeWidgetSignal *new_sig;
GladeSignal *old_sig;
GladeSignal *new_sig;
g_return_if_fail (editor != NULL);
g_return_if_fail (editor->widget != NULL);
......@@ -462,8 +463,8 @@ glade_signal_editor_delete_cb (GladeSignalEditor *editor)
GtkTreeIter iter;
GtkTreeSelection *select;
GtkTreeModel *model;
GladeWidgetSignal *signal;
GladeWidgetSignal *sig;
GladeSignal *signal;
GladeSignal *sig;
GList *list;
g_return_if_fail (editor != NULL);
......@@ -479,7 +480,7 @@ glade_signal_editor_delete_cb (GladeSignalEditor *editor)
list = editor->widget->signals;
for ( ; list != NULL; list = list->next) {
sig = (GladeWidgetSignal *) list->data;
sig = (GladeSignal *) list->data;
if (!strcmp (sig->name, signal->name) &&
!strcmp (sig->handler, signal->handler) &&
sig->after == signal->after) {
......@@ -693,7 +694,7 @@ glade_signal_editor_new (void)
void
glade_signal_editor_load_widget (GladeSignalEditor *editor, GladeWidget *widget)
{
GladeWidgetSignal *signal;
GladeSignal *signal;
GtkTreeStore *model;
GList *list;
......
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2001 Ximian, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* Authors:
* Chema Celorio <chema@celorio.com>
*/
/* TODO : code from glade-signal-editor shuold really be here , not there */
#include <string.h>
#include "glade.h"
#include "glade-signal.h"
GladeXmlNode *
glade_signal_write (GladeXmlContext *context, GladeSignal *signal)
{
GladeXmlNode *node;
node = glade_xml_node_new (context, GLADE_XML_TAG_SIGNAL);
glade_xml_node_set_property_string (node, GLADE_XML_TAG_NAME, signal->name);
glade_xml_node_set_property_string (node, GLADE_XML_TAG_HANDLER, signal->handler);
glade_xml_node_set_property_boolean (node, GLADE_XML_TAG_AFTER, signal->after);
return node;
}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
#ifndef __GLADE_SIGNAL_H__
#define __GLADE_SIGNAL_H__
G_BEGIN_DECLS
#define GLADE_SIGNAL(s) ((GladeSignal *)s)
#define GLADE_IS_SIGNAL(s) (s != NULL)
struct _GladeSignal {
gchar *name; /* Signal name eg "clicked" */
gchar *handler; /* Handler function eg "gtk_main_quit" */
gboolean after; /* Connect after TRUE or FALSE */
};
GladeXmlNode * glade_signal_write (GladeXmlContext *context, GladeSignal *signal);
G_END_DECLS
#endif /* __GLADE_SIGNAL_H__ */
......@@ -2,11 +2,11 @@ typedef struct _GladePaletteSection GladePaletteSection;
typedef struct _GladePalette GladePalette;
typedef struct _GladeEditor GladeEditor;
typedef struct _GladeSignalEditor GladeSignalEditor;
typedef struct _GladeSignal GladeSignal;
typedef struct _GladeSignalEditor GladeSignalEditor;
typedef struct _GladeProject GladeProject;
typedef struct _GladeWidget GladeWidget;
typedef struct _GladeWidgetSignal GladeWidgetSignal;
typedef struct _GladeWidgetClass GladeWidgetClass;
typedef struct _GladeWidgetClassSignal GladeWidgetClassSignal;
......
......@@ -32,6 +32,7 @@
#include "glade-property-class.h"
#include "glade-popup.h"
#include "glade-placeholder.h"
#include "glade-signal.h"
#define GLADE_WIDGET_SELECTION_NODE_SIZE 7
......@@ -820,7 +821,10 @@ glade_widget_write (GladeXmlContext *context, GladeWidget *widget)
{
GladeProperty *property;
GladeXmlNode *node;
GladeXmlNode *child;
GladeXmlNode *child; /* This is the <widget name="foo" ..> tag */
GladeXmlNode *child_tag; /* This is the <child> tag */
GladeWidget *child_widget;
GladeSignal *signal;
GList *list;
g_return_val_if_fail (GLADE_XML_IS_CONTEXT (context), NULL);
......@@ -840,6 +844,26 @@ glade_widget_write (GladeXmlContext *context, GladeWidget *widget)
glade_xml_append_child (node, child);
}
list = widget->signals;
for (; list != NULL; list = list->next) {
signal = list->data;
child = glade_signal_write (context, signal);
if (child == NULL)
return NULL;
glade_xml_append_child (node, child);
}
list = widget->children;
for (; list != NULL; list = list->next) {
child_widget = list->data;
child = glade_widget_write (context, child_widget);
if (child == NULL)
return NULL;
child_tag = glade_xml_node_new (context, GLADE_XML_TAG_CHILD);
glade_xml_append_child (node, child_tag);
glade_xml_append_child (child_tag, child);
}
return node;
}
......
......@@ -288,6 +288,17 @@ glade_xml_property_get_boolean (GladeXmlNode *node_in, const char *name)
return ret;
}
void
glade_xml_node_set_property_boolean (GladeXmlNode *node_in, const gchar *name, gboolean value)
{
xmlNodePtr node = (xmlNodePtr) node_in;
if (value)
glade_xml_set_property (node, name, GLADE_TAG_TRUE);
else
glade_xml_set_property (node, name, GLADE_TAG_FALSE);
}
#undef GLADE_TAG_TRUE
#undef GLADE_TAG_FALSE
......
......@@ -38,6 +38,7 @@ gchar * glade_xml_get_property_string_required (GladeXmlNode *node_in, const cha
gchar * glade_xml_get_property_string (GladeXmlNode *node_in, const gchar *name);
gboolean glade_xml_property_get_boolean (GladeXmlNode *node_in, const char *name);
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);
/* Parse Context */
GladeXmlContext * glade_xml_context_new (GladeXmlDoc *doc, const gchar *name_space);
......
......@@ -68,3 +68,5 @@ gchar * _ (gchar * name);
#define GLADE_XML_TAG_HANDLER "handler"
#define GLADE_XML_TAG_NAME "name"
#define GLADE_XML_TAG_CHILD "child"
#define GLADE_XML_TAG_SIGNAL "signal"
#define GLADE_XML_TAG_AFTER "after"
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