Commit 9f649f5b authored by Chema Celorio's avatar Chema Celorio Committed by Jose Maria Celorio

impl. (glade_widget_connect_edit_signals): impl.

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

	* src/glade-widget.c (glade_widget_connect_edit_signals_with_class): impl.
	(glade_widget_connect_edit_signals): impl.

	* src/glade-property-class.h: add ->update_signals and ->get_function

	* src/glade-property-class.c (glade_xml_read_list): implement. Keep here for now
	but should go into xml utils.

	* src/glade-gtk.c (glade_gtk_get_set_function_hack): implement.
parent c7a59572
2001-07-16 Chema Celorio <chema@celorio.com>
* src/glade-widget.c (glade_widget_connect_edit_signals_with_class): impl.
(glade_widget_connect_edit_signals): impl.
* src/glade-property-class.h: add ->update_signals and ->get_function
* src/glade-property-class.c (glade_xml_read_list): implement. Keep here for now
but should go into xml utils.
* src/glade-gtk.c (glade_gtk_get_set_function_hack): implement.
2001-07-15 Chema Celorio <chema@celorio.com>
* src/glade-widget-class.c (glade_widget_class_new_from_node): init_function is
......
......@@ -14,8 +14,6 @@ TODO
TAKEN ITEMS (someone is already working on)
-----------
- File loading and saving
- Cleaning and adding new .xml descriptions for widgets
- Signal editor
- Common part of the editor
OPEN ITEMS [PLease let me know before starting working on any of this]
......@@ -45,6 +43,15 @@ that specifies a file.
\__ D
When hiding the childs of "A" and showingt htem again, the state of B and its
childs is lost, this should go into gtk+.
- Implement the about box.
- Adding new widgets
NOT-SO-EASY TO IMPLEMENT ITEMS
------------------------------
This items may prove tricky to implement if they are "done right"
- The packing tab of the editor
- Undo/Redo
- Copy/Cut/Paste
DONE [just as a reference]
--------------------------
......@@ -56,14 +63,9 @@ DONE [just as a reference]
This does not allow checkbuttons to be set/unset or buttons to be pressed.
- Fix multiple lines GladeEditor text entries. See glade-editor.c,
function : glade_editor_create_input_text.
(Shane)
- Signal editor
NOT-SO-EASY TO IMPLEMENT ITEMS
------------------------------
This items may prove tricky to implement if they are "done right"
- The packing tab of the editor
- Undo/Redo
- Copy/Cut/Paste
NOT YET (Items that we need to do, but are not a priority right now)
-------
- Implement the custom widget
......@@ -36,6 +36,12 @@ glade_gtk_entry_set_text (GObject *object, const gchar *text)
gtk_entry_set_text (GTK_ENTRY (object), text);
}
static void
glade_gtk_entry_get_text (GObject *object)
{
g_print ("IMplement get text functikon\n");
}
static void
glade_gtk_option_menu_set_items (GObject *object, const gchar *items)
{
......@@ -158,9 +164,9 @@ struct _GladeGtkFunction {
gpointer function;
};
GladeGtkFunction functions [] = {
{"glade_gtk_entry_set_text", &glade_gtk_entry_set_text},
{"glade_gtk_entry_get_text", &glade_gtk_entry_get_text},
{"glade_gtk_option_menu_set_items", &glade_gtk_option_menu_set_items},
{"glade_gtk_progress_bar_set_format", &glade_gtk_progress_bar_set_format},
{"glade_gtk_adjustment_set_max", &glade_gtk_adjustment_set_max},
......@@ -169,25 +175,39 @@ GladeGtkFunction functions [] = {
{"glade_gtk_adjustment_set_page_increment", &glade_gtk_adjustment_set_page_increment},
{"glade_gtk_adjustment_set_page_size", &glade_gtk_adjustment_set_page_size},
};
gboolean
glade_gtk_get_set_function_hack (GladePropertyClass *class, const gchar *function_name)
static gpointer
glade_gtk_get_function (const gchar *name)
{
gint num;
gint i;
num = sizeof (functions) / sizeof (GladeGtkFunction);
for (i = 0; i < num; i++) {
if (strcmp (function_name, functions[i].name) == 0)
if (strcmp (name, functions[i].name) == 0)
break;
}
if (i == num) {
g_warning ("Could not find the function %s for %s\n",
function_name, class->name);
return FALSE;
g_warning ("Could not find the function %s\n",
name);
return NULL;
}
class->set_function = functions[i].function;
return functions[i].function;
}
gboolean
glade_gtk_get_set_function_hack (GladePropertyClass *class, const gchar *name)
{
class->get_function = glade_gtk_get_function (name);
return TRUE;
}
gboolean
glade_gtk_get_get_function_hack (GladePropertyClass *class, const gchar *name)
{
class->set_function = glade_gtk_get_function (name);
return TRUE;
}
......
......@@ -4,7 +4,8 @@
G_BEGIN_DECLS
gboolean glade_gtk_get_set_function_hack (GladePropertyClass *class, const gchar *function_name);
gboolean glade_gtk_get_set_function_hack (GladePropertyClass *class, const gchar *name);
gboolean glade_gtk_get_get_function_hack (GladePropertyClass *class, const gchar *name);
G_END_DECLS
......
......@@ -44,8 +44,8 @@ static void gpw_show_editor_cb (void);
static void gpw_show_widget_tree_cb (void);
static void gpw_show_clipboard_cb (void) {};
static void gpw_undo_cb (void) {};
static void gpw_redo_cb (void) {};
static void gpw_undo_cb (void);
static void gpw_redo_cb (void);
static void gpw_delete_cb (void) {};
static void gpw_about_cb (void) {};
......@@ -102,6 +102,18 @@ gpw_paste_cb (void)
g_print ("Paste !\n");
}
static void
gpw_undo_cb (void)
{
g_print ("Undo\n");
}
static void
gpw_redo_cb (void)
{
g_print ("Redo\n");
}
static void
gpw_delete_event (GtkWindow *w, gpointer not_used)
{
......
......@@ -453,7 +453,13 @@ glade_property_class_new_from_param_spec (const gchar *name,
return class;
}
static gboolean
glade_property_class_get_get_function (GladePropertyClass *class, const gchar *function_name)
{
return glade_gtk_get_get_function_hack (class, function_name);
}
static gboolean
glade_property_class_get_set_function (GladePropertyClass *class, const gchar *function_name)
{
......@@ -481,6 +487,35 @@ glade_property_class_get_set_function (GladePropertyClass *class, const gchar *f
return TRUE;
}
static GList *
glade_xml_read_list (xmlNodePtr node, const gchar *list_tag, const gchar *item_tag)
{
xmlNodePtr child;
GList *list = NULL;
gchar *item;
child = glade_xml_search_child (node, list_tag);
if (child == NULL)
return NULL;
child = child->children;
while (child != NULL) {
skip_text (child);
if (!glade_xml_node_verify (child, item_tag))
return NULL;
item = glade_xml_get_content (child);
if (item != NULL)
list = g_list_prepend (list, item);
child = child->next;
}
list = g_list_reverse (list);
return list;
}
static GladePropertyClass *
glade_property_class_new_from_node (xmlNodePtr node, GladeWidgetClass *widget_class)
{
......@@ -568,11 +603,24 @@ glade_property_class_new_from_node (xmlNodePtr node, GladeWidgetClass *widget_cl
glade_property_class_get_set_function (property_class, content);
g_free (content);
}
/* If this property can't be set with g_object_get, get the workarround
* function
*/
child = glade_xml_search_child (node, GLADE_TAG_GET_FUNCTION);
if (child != NULL) {
gchar * content = glade_xml_get_content (child);
glade_property_class_get_get_function (property_class, content);
g_free (content);
}
/* Now get the list of signals that we should listen to */
property_class->update_signals = glade_xml_read_list (node,
GLADE_TAG_UPDATE_SIGNALS,
GLADE_TAG_SIGNAL_NAME);
return property_class;
}
GList *
glade_property_class_list_new_from_node (xmlNodePtr node, GladeWidgetClass *class)
{
......
......@@ -144,6 +144,15 @@ struct _GladePropertyClass {
* the type is object.
*/
GList *update_signals; /* A list of gchar * that contains the signal names that
* this property should be listening to update itself.
* For example the gtkentry wants to listen to the "change"
* signal so that the "content" of the entry is updated and
* stored when it is changed. A toggle button should listen to
* the "toggled" signal to get the state of the property
* from the real widget
*/
void (*set_function) (GObject *object,
const gchar *value);
/* If this property can't be set with g_object_set then
......@@ -151,6 +160,12 @@ struct _GladePropertyClass {
* to the function that can set this property. The functions
* to work arround this problems are inside glade-gtk.c
*/
void (*get_function) (GObject *object);
/* If this property can't be get with g_object_get then
* we need to implement it inside glade. This is a pointer
* to the function that can set this property. The functions
* to work arround this problems are inside glade-gtk.c
*/
};
GtkWidget * glade_property_class_create_label (GladePropertyClass *pclass);
......
......@@ -4,6 +4,10 @@
G_BEGIN_DECLS
#define GLADE_PROPERTY(p) ((GladeProperty *)p)
#define GLADE_IS_PROPERTY(p) (p != NULL)
/* A GladeProperty is an instance of a GladePropertyClass.
* There will be one GladePropertyClass for "GtkLabel->label" but one
* GladeProperty for each GtkLabel in the GladeProject.
......
......@@ -206,7 +206,7 @@ glade_signal_editor_dialog_cb (GtkButton *button, GladeSignalEditor *editor)
*/
static void
glade_signal_editor_update_signal (GladeSignalEditor *editor, GladeWidgetSignal *signal,
GtkTreeIter *iter)
GtkTreeIter *iter)
{
GtkTreeStore *lst_model;
GValue *label;
......@@ -236,7 +236,7 @@ glade_signal_editor_update_signal (GladeSignalEditor *editor, GladeWidgetSignal
static gboolean
glade_signal_editor_list_select_cb (GtkTreeSelection *lst_select,
GtkTreeModel *lst_model, GtkTreePath *lst_path, GladeSignalEditor *editor)
GtkTreeModel *lst_model, GtkTreePath *lst_path, GladeSignalEditor *editor)
{
GtkTreeIter iter;
GValue *label;
......@@ -364,6 +364,7 @@ glade_signal_editor_get_signal_at_iter (GladeSignalEditor *editor, GtkTreeIter *
label = g_new0 (GValue, 1);
gtk_tree_model_get_value (GTK_TREE_MODEL (model), iter, 2, label);
if (!strcmp ((gchar *) label->data[0].v_pointer, _("Yes")))
signal->after = TRUE;
else
......
......@@ -525,6 +525,45 @@ glade_widget_set_contents (GladeWidget *widget)
glade_property_changed_text (property, widget->name);
}
static void
foo (GtkWidget *w)
{
g_print ("Foo\n");
}
static void
glade_widget_connect_edit_signals_with_class (GladeWidget *widget,
GladePropertyClass *class)
{
GladeProperty *property;
GList *list;
property = glade_widget_get_property_from_class (widget, class);
g_return_if_fail (GLADE_IS_PROPERTY (property));
list = class->update_signals;
for (; list != NULL; list = list->next) {
gtk_signal_connect (GTK_OBJECT (widget->widget), list->data,
GTK_SIGNAL_FUNC (foo), property);
}
}
static void
glade_widget_connect_edit_signals (GladeWidget *widget)
{
GladePropertyClass *class;
GList *list;
list = widget->class->properties;
for (; list != NULL; list = list->next) {
class = list->data;
if (class->update_signals)
glade_widget_connect_edit_signals_with_class (widget,
class);
}
}
static GladeWidget *
glade_widget_create_gtk_widget (GladeProject *project,
GladeWidgetClass *class,
......@@ -568,6 +607,7 @@ glade_widget_create_gtk_widget (GladeProject *project,
glade_widget_set_contents (glade_widget);
glade_widget_connect_mouse_signals (glade_widget);
glade_widget_connect_draw_signals (glade_widget);
glade_widget_connect_edit_signals (glade_widget);
return glade_widget;
......
......@@ -43,12 +43,15 @@ gchar * _ (gchar * name);
#define GLADE_TAG_OTHER_WIDGETS "OtherWidgets"
#define GLADE_TAG_OBJECT "Object"
#define GLADE_TAG_SET_FUNCTION "SetFunction"
#define GLADE_TAG_GET_FUNCTION "GetFunction"
#define GLADE_TAG_QUERY "Query"
#define GLADE_TAG_WINDOW_TITLE "WindowTitle"
#define GLADE_TAG_QUESTION "Question"
#define GLADE_TAG_PARAM_SPEC "ParamSpec"
#define GLADE_TAG_VISIBLE_LINES "VisibleLines"
#define GLADE_CHOICE_DATA_TAG "GladeChoiceDataTag"
#define GLADE_TAG_UPDATE_SIGNALS "UpdateSignals"
#define GLADE_TAG_SIGNAL_NAME "SignalName"
#define GLADE_TAG_CATALOG "GladeCatalog"
#define GLADE_TAG_GLADE_WIDGET "GladeWidget"
......
......@@ -14,6 +14,10 @@
<Type>Text</Type>
<Tooltip>Initial Contents of the entry</Tooltip>
<SetFunction>glade_gtk_entry_set_text</SetFunction>
<GetFunction>glade_gtk_entry_get_text</GetFunction>
<UpdateSignals>
<SignalName>changed</SignalName>
</UpdateSignals>
</Property>
</Properties>
......
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