mirror of
https://gitlab.gnome.org/GNOME/glade.git
synced 2025-08-10 00:04:29 -04:00
try to fix gettext support. Duno why translations are not working. Feel
2001-08-11 Chema Celorio <chema@celorio.com> * src/glade.h: try to fix gettext support. Duno why translations are not working. Feel free to fix it ;-). * src/glade-widget.c (glade_property_refresh): implement (glade_widget_new): clean widget creation (glade_widget_new_full): ditto (glade_widget_get_from_gtk_widget): ditto (glade_widget_apply_property_from_node): impl. (glade_widget_new_from_node): impl. * src/glade-property.c : port to GValue * src/glade-property.h: ditto * src/glade-property-class.c : port to GValue * src/glade-property-class.h : ditto * src/glade-project.c (glade_project_new_from_node): implement. (glade_project_open_from_file): implement. (glade_project_open): implemnt. * src/glade-project-view.h (struct _GladeProjectViewClass): add a selection_update signal. * src/glade-project-view.c (glade_project_view_populate_model_real): add a add_childs parameter (glade_project_view_selection_update): implment (not yet working) * src/glade-parameter.c (glade_parameter_adjustment_new): port to GValue * src/glade-palette.c (glade_palette_clear): impl. * src/glade-gtk.c: port to GValue from string (glade_gtk_box_set_size): impl. * src/glade-editor.c (glade_editor_property_changed_*): use g_property_set_foo rather than g_property_changed_foo. port to GValues from string * src/glade-choice.c (glade_choice_list_new_from_node): use _TAG_ENUM and not _CHOICES * src/glade-catalog.c: remove <config.h> * src/Makefile.am (SUBDIRS): remove tests
This commit is contained in:
parent
b2a8539ccb
commit
8b9ec7363e
47
ChangeLog
47
ChangeLog
@ -1,3 +1,50 @@
|
||||
2001-08-11 Chema Celorio <chema@celorio.com>
|
||||
|
||||
* src/glade.h: try to fix gettext support. Duno why translations are not
|
||||
working. Feel free to fix it ;-).
|
||||
|
||||
* src/glade-widget.c (glade_property_refresh): implement
|
||||
(glade_widget_new): clean widget creation
|
||||
(glade_widget_new_full): ditto
|
||||
(glade_widget_get_from_gtk_widget): ditto
|
||||
(glade_widget_apply_property_from_node): impl.
|
||||
(glade_widget_new_from_node): impl.
|
||||
|
||||
* src/glade-property.c : port to GValue
|
||||
* src/glade-property.h: ditto
|
||||
|
||||
* src/glade-property-class.c : port to GValue
|
||||
* src/glade-property-class.h : ditto
|
||||
|
||||
* src/glade-project.c (glade_project_new_from_node): implement.
|
||||
(glade_project_open_from_file): implement.
|
||||
(glade_project_open): implemnt.
|
||||
|
||||
* src/glade-project-view.h (struct _GladeProjectViewClass): add a
|
||||
selection_update signal.
|
||||
|
||||
* src/glade-project-view.c (glade_project_view_populate_model_real): add a
|
||||
add_childs parameter
|
||||
(glade_project_view_selection_update): implment (not yet working)
|
||||
|
||||
* src/glade-parameter.c (glade_parameter_adjustment_new): port to GValue
|
||||
|
||||
* src/glade-palette.c (glade_palette_clear): impl.
|
||||
|
||||
* src/glade-gtk.c: port to GValue from string
|
||||
(glade_gtk_box_set_size): impl.
|
||||
|
||||
* src/glade-editor.c (glade_editor_property_changed_*): use g_property_set_foo
|
||||
rather than g_property_changed_foo.
|
||||
port to GValues from string
|
||||
|
||||
* src/glade-choice.c (glade_choice_list_new_from_node): use _TAG_ENUM and
|
||||
not _CHOICES
|
||||
|
||||
* src/glade-catalog.c: remove <config.h>
|
||||
|
||||
* src/Makefile.am (SUBDIRS): remove tests
|
||||
|
||||
2001-08-07 Chema Celorio <chema@celorio.com>
|
||||
|
||||
* src/glade-widget.c (glade_widget_property_changed_cb): add a temp hack to set
|
||||
|
9
TODO
9
TODO
@ -37,6 +37,15 @@ that specifies a file.
|
||||
- Implement the about box.
|
||||
- Adding new widgets
|
||||
|
||||
Short term
|
||||
----------
|
||||
- Finish GValue choices
|
||||
- Implement the -1 spinbutton
|
||||
- Read packing defaults from xml files
|
||||
- Fix SpinButton->adjustment object
|
||||
- cut/copy/paste
|
||||
- undo/redo
|
||||
|
||||
NOT-SO-EASY TO IMPLEMENT ITEMS
|
||||
------------------------------
|
||||
This items may prove tricky to implement if they are "done right"
|
||||
|
@ -26,7 +26,7 @@ dnl ========================================================
|
||||
dnl Check for gtk-2.0
|
||||
dnl ========================================================
|
||||
check_module="gtk+-2.0"
|
||||
check_version="1.3.5"
|
||||
check_version="1.3.7"
|
||||
dnl ====================
|
||||
check_version_num=`echo "$check_version" | awk 'BEGIN { FS = "."; } { printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
|
||||
AC_MSG_CHECKING(for $check_module library => $check_version)
|
||||
@ -157,13 +157,13 @@ AC_SUBST(widgetsdir)
|
||||
|
||||
AC_OUTPUT([
|
||||
Makefile
|
||||
src/Makefile
|
||||
macros/Makefile
|
||||
intl/Makefile
|
||||
pixmaps/Makefile
|
||||
widgets/Makefile
|
||||
po/Makefile.in
|
||||
])
|
||||
src/Makefile
|
||||
],[sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile])
|
||||
|
||||
echo "
|
||||
|
||||
|
159
po/es.po
159
po/es.po
@ -6,7 +6,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2001-07-03 00:13-0500\n"
|
||||
"POT-Creation-Date: 2001-08-11 17:03-0500\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@ -21,3 +21,160 @@ msgstr ""
|
||||
#: glade2.desktop.in.h:2
|
||||
msgid "Glade"
|
||||
msgstr ""
|
||||
|
||||
#: src/main.c:70
|
||||
msgid ""
|
||||
"gmodule support not found. gmodule support is requiered for glade to work"
|
||||
msgstr ""
|
||||
|
||||
#: src/main.c:112
|
||||
msgid "Translate me\n"
|
||||
msgstr "Traduceme"
|
||||
|
||||
#: src/glade-editor.c:140
|
||||
msgid "Properties"
|
||||
msgstr ""
|
||||
|
||||
#: src/glade-editor.c:145
|
||||
msgid "Widget"
|
||||
msgstr ""
|
||||
|
||||
#: src/glade-editor.c:146
|
||||
msgid "Packing"
|
||||
msgstr "Packeoooo"
|
||||
|
||||
#: src/glade-editor.c:147
|
||||
msgid "Common"
|
||||
msgstr ""
|
||||
|
||||
#: src/glade-editor.c:148 src/glade-signal-editor.c:86
|
||||
msgid "Signals"
|
||||
msgstr ""
|
||||
|
||||
#: src/glade-editor.c:553 src/glade-signal-editor.c:234
|
||||
#: src/glade-signal-editor.c:273 src/glade-signal-editor.c:586
|
||||
msgid "No"
|
||||
msgstr ""
|
||||
|
||||
#. Name
|
||||
#: src/glade-editor.c:657
|
||||
msgid "Name :"
|
||||
msgstr "Nombre :"
|
||||
|
||||
#. Class
|
||||
#: src/glade-editor.c:670
|
||||
msgid "Class :"
|
||||
msgstr ""
|
||||
|
||||
#: src/glade-palette.c:269
|
||||
msgid "Palette"
|
||||
msgstr ""
|
||||
|
||||
#: src/glade-popup.c:79
|
||||
msgid "Select"
|
||||
msgstr ""
|
||||
|
||||
#: src/glade-popup.c:81
|
||||
msgid "Cut"
|
||||
msgstr ""
|
||||
|
||||
#: src/glade-popup.c:83
|
||||
msgid "Copy"
|
||||
msgstr ""
|
||||
|
||||
#: src/glade-popup.c:85
|
||||
msgid "Paste"
|
||||
msgstr ""
|
||||
|
||||
#: src/glade-popup.c:88 src/glade-signal-editor.c:637
|
||||
msgid "Delete"
|
||||
msgstr ""
|
||||
|
||||
#: src/glade-project-window.c:356
|
||||
msgid "Widget Tree"
|
||||
msgstr ""
|
||||
|
||||
#: src/glade-project.c:544
|
||||
msgid "Save ..."
|
||||
msgstr ""
|
||||
|
||||
#: src/glade-project.c:547
|
||||
msgid "Invalid file name"
|
||||
msgstr ""
|
||||
|
||||
#: src/glade-project.c:570
|
||||
msgid "Open ..."
|
||||
msgstr "Abrir ..."
|
||||
|
||||
#: src/glade-project.c:578
|
||||
msgid "Could not open project."
|
||||
msgstr ""
|
||||
|
||||
#: src/glade-property-class.c:589 src/glade-widget-class.c:173
|
||||
#, c-format
|
||||
msgid "We could not find the symbol \"%s\" while trying to load \"%s\""
|
||||
msgstr ""
|
||||
|
||||
#: src/glade-signal-editor.c:106
|
||||
msgid "Select signal"
|
||||
msgstr ""
|
||||
|
||||
#: src/glade-signal-editor.c:232 src/glade-signal-editor.c:257
|
||||
#: src/glade-signal-editor.c:271 src/glade-signal-editor.c:369
|
||||
msgid "Yes"
|
||||
msgstr ""
|
||||
|
||||
#: src/glade-signal-editor.c:294 src/glade-signal-editor.c:315
|
||||
msgid "Please enter a valid signal name"
|
||||
msgstr ""
|
||||
|
||||
#: src/glade-signal-editor.c:328
|
||||
msgid "Please enter a signal handler"
|
||||
msgstr ""
|
||||
|
||||
#: src/glade-signal-editor.c:520
|
||||
msgid "Signal"
|
||||
msgstr ""
|
||||
|
||||
#: src/glade-signal-editor.c:521
|
||||
msgid "Handler"
|
||||
msgstr ""
|
||||
|
||||
#: src/glade-signal-editor.c:522
|
||||
msgid "After"
|
||||
msgstr ""
|
||||
|
||||
#: src/glade-signal-editor.c:565
|
||||
msgid "Signal :"
|
||||
msgstr ""
|
||||
|
||||
#: src/glade-signal-editor.c:566
|
||||
msgid "Handler :"
|
||||
msgstr ""
|
||||
|
||||
#: src/glade-signal-editor.c:567
|
||||
msgid "After :"
|
||||
msgstr ""
|
||||
|
||||
#: src/glade-signal-editor.c:635
|
||||
msgid "Add"
|
||||
msgstr ""
|
||||
|
||||
#: src/glade-signal-editor.c:636
|
||||
msgid "Update"
|
||||
msgstr ""
|
||||
|
||||
#: src/glade-signal-editor.c:638
|
||||
msgid "Clear"
|
||||
msgstr ""
|
||||
|
||||
#: src/glade-widget-class.c:182
|
||||
#, c-format
|
||||
msgid "Could not get the type from \"%s\" while trying to load \"%s\""
|
||||
msgstr ""
|
||||
|
||||
#: src/glade-widget-class.c:190
|
||||
#, c-format
|
||||
msgid "The loaded type is not a GtkWidget, while trying to load \"%s\""
|
||||
msgstr ""
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
## Process this file with automake to produce Makefile.in
|
||||
SUBDIRS=tests
|
||||
SUBDIRS=
|
||||
|
||||
bin_PROGRAMS = glade2
|
||||
|
||||
|
@ -21,7 +21,6 @@
|
||||
*/
|
||||
|
||||
|
||||
#include <config.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "glade.h"
|
||||
|
@ -12,12 +12,12 @@ G_BEGIN_DECLS
|
||||
struct _GladeCatalog
|
||||
{
|
||||
GList *names; /* Contains the list of names that we are going
|
||||
* to try to load. This is basically a memory
|
||||
* representation of catalog.xml
|
||||
*/
|
||||
* to try to load. This is basically a memory
|
||||
* representation of catalog.xml
|
||||
*/
|
||||
GList *widgets; /* Contains the list of GladeWidgetClass objects
|
||||
* that where successfully loaded from disk
|
||||
*/
|
||||
* that where successfully loaded from disk
|
||||
*/
|
||||
};
|
||||
|
||||
GladeCatalog * glade_catalog_load (void);
|
||||
|
@ -148,7 +148,7 @@ glade_choice_list_new_from_node (GladeXmlNode *node)
|
||||
GladeChoice *choice;
|
||||
GList *list;
|
||||
|
||||
if (!glade_xml_node_verify (node, GLADE_TAG_CHOICES))
|
||||
if (!glade_xml_node_verify (node, GLADE_TAG_ENUM))
|
||||
return NULL;
|
||||
|
||||
list = NULL;
|
||||
|
@ -28,24 +28,24 @@ G_BEGIN_DECLS
|
||||
struct _GladeChoice {
|
||||
|
||||
gchar *name; /* Name of the choice to be used in the gui. This
|
||||
* field is translated. Like "Top Level" or "Ok"
|
||||
* (for GTK_WINDOW_TOPLEVEL & GNOME_STOCK_BUTTON_OK
|
||||
*/
|
||||
* field is translated. Like "Top Level" or "Ok"
|
||||
* (for GTK_WINDOW_TOPLEVEL & GNOME_STOCK_BUTTON_OK
|
||||
*/
|
||||
gchar *symbol; /* Symbol for the choice. Like GTK_WINDOW_TOPLEVEL (which
|
||||
* is an integer) or GNOME_STOCK_BUTTON_FOO (which is
|
||||
* not an integer). For integers which are enum'ed values
|
||||
* this symbol is converted to its value
|
||||
*/
|
||||
|
||||
* is an integer) or GNOME_STOCK_BUTTON_FOO (which is
|
||||
* not an integer). For integers which are enum'ed values
|
||||
* this symbol is converted to its value
|
||||
*/
|
||||
|
||||
gint value; /* The enum value of the symbol. The symbol GTK_WINDOW_
|
||||
* TOPLEVEL will be 0 and GTK_WINDOW_POPUP will be 1
|
||||
*/
|
||||
* TOPLEVEL will be 0 and GTK_WINDOW_POPUP will be 1
|
||||
*/
|
||||
|
||||
const gchar *string; /* For non-integer values like GNOME_STOCK_BUTTON_OK
|
||||
* it points to a string inside the librarry that
|
||||
* contains it.
|
||||
* See glade-choice.c#glade_string_from_sring
|
||||
*/
|
||||
* it points to a string inside the librarry that
|
||||
* contains it.
|
||||
* See glade-choice.c#glade_string_from_sring
|
||||
*/
|
||||
};
|
||||
|
||||
|
||||
|
@ -228,7 +228,7 @@ glade_editor_table_new (GladeWidgetClass *class)
|
||||
static void
|
||||
glade_editor_property_changed_text_common (GladeProperty *property, const gchar *text)
|
||||
{
|
||||
glade_property_changed_text (property, text);
|
||||
glade_property_set_string (property, text);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -245,7 +245,7 @@ glade_editor_property_changed_text (GtkWidget *entry,
|
||||
text = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1);
|
||||
|
||||
glade_editor_property_changed_text_common (property->property, text);
|
||||
|
||||
|
||||
g_free (text);
|
||||
}
|
||||
|
||||
@ -288,7 +288,7 @@ glade_editor_property_changed_choice (GtkWidget *menu_item,
|
||||
GLADE_CHOICE_DATA_TAG);
|
||||
g_return_if_fail (choice != NULL);
|
||||
|
||||
glade_property_changed_choice (property->property, choice);
|
||||
glade_property_set_choice (property->property, choice);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -348,15 +348,15 @@ glade_editor_property_changed_numeric (GtkWidget *spin,
|
||||
switch (numeric_type) {
|
||||
case GLADE_EDITOR_INTEGER:
|
||||
integer_val = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (spin));
|
||||
glade_property_changed_integer (property->property, integer_val);
|
||||
glade_property_set_integer (property->property, integer_val);
|
||||
break;
|
||||
case GLADE_EDITOR_FLOAT:
|
||||
float_val = gtk_spin_button_get_value_as_float (GTK_SPIN_BUTTON (spin));
|
||||
glade_property_changed_float (property->property, float_val);
|
||||
glade_property_set_float (property->property, float_val);
|
||||
break;
|
||||
case GLADE_EDITOR_DOUBLE:
|
||||
double_val = (gdouble) gtk_spin_button_get_value_as_float (GTK_SPIN_BUTTON (spin));
|
||||
glade_property_changed_double (property->property, double_val);
|
||||
glade_property_set_double (property->property, double_val);
|
||||
break;
|
||||
default:
|
||||
g_warning ("Invalid numeric_type %i\n", numeric_type);
|
||||
@ -380,7 +380,7 @@ glade_editor_property_changed_boolean (GtkWidget *button,
|
||||
label = GTK_BIN (button)->child;
|
||||
gtk_label_set_text (GTK_LABEL (label), text [state]);
|
||||
|
||||
glade_property_changed_boolean (property->property, state);
|
||||
glade_property_set_boolean (property->property, state);
|
||||
}
|
||||
|
||||
|
||||
@ -481,7 +481,7 @@ glade_editor_create_input_text (GladeEditorProperty *property)
|
||||
|
||||
static GtkWidget *
|
||||
glade_editor_create_input_numeric (GladeEditorProperty *property,
|
||||
GladeEditorNumericType numeric_type)
|
||||
GladeEditorNumericType numeric_type)
|
||||
{
|
||||
GladePropertyClass *class;
|
||||
GtkAdjustment *adjustment;
|
||||
@ -494,7 +494,7 @@ glade_editor_create_input_numeric (GladeEditorProperty *property,
|
||||
adjustment = glade_parameter_adjustment_new (class->parameters, class->def);
|
||||
|
||||
spin = gtk_spin_button_new (adjustment, 10,
|
||||
numeric_type == GLADE_EDITOR_INTEGER ? 0 : 2);
|
||||
numeric_type == GLADE_EDITOR_INTEGER ? 0 : 2);
|
||||
|
||||
gtk_object_set_data (GTK_OBJECT (spin), "NumericType", GINT_TO_POINTER (numeric_type));
|
||||
gtk_signal_connect (GTK_OBJECT (spin), "changed",
|
||||
@ -590,10 +590,10 @@ glade_editor_append_item_real (GladeEditorTable *table, GladeEditorProperty *pro
|
||||
case GLADE_PROPERTY_TYPE_DOUBLE:
|
||||
input = glade_editor_create_input_double (property);
|
||||
break;
|
||||
case GLADE_PROPERTY_TYPE_TEXT:
|
||||
case GLADE_PROPERTY_TYPE_STRING:
|
||||
input = glade_editor_create_input_text (property);
|
||||
break;
|
||||
case GLADE_PROPERTY_TYPE_CHOICE:
|
||||
case GLADE_PROPERTY_TYPE_ENUM:
|
||||
input = glade_editor_create_input_choice (property);
|
||||
break;
|
||||
case GLADE_PROPERTY_TYPE_OTHER_WIDGETS:
|
||||
@ -909,7 +909,12 @@ glade_editor_property_load_integer (GladeEditorProperty *property)
|
||||
spin = property->input;
|
||||
}
|
||||
|
||||
val = atof (property->property->value);
|
||||
|
||||
if (property->property->value->g_type == G_TYPE_INT)
|
||||
val = (gfloat) g_value_get_int (property->property->value);
|
||||
else
|
||||
val = g_value_get_float (property->property->value);
|
||||
|
||||
gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), val);
|
||||
gtk_object_set_user_data (GTK_OBJECT (spin), property);
|
||||
}
|
||||
@ -940,6 +945,7 @@ glade_editor_property_load_double (GladeEditorProperty *property)
|
||||
static void
|
||||
glade_editor_property_load_choice (GladeEditorProperty *property)
|
||||
{
|
||||
#if 0
|
||||
GladePropertyClass *pclass;
|
||||
GladeChoice *choice;
|
||||
GList *list;
|
||||
@ -951,7 +957,7 @@ glade_editor_property_load_choice (GladeEditorProperty *property)
|
||||
g_return_if_fail (property->input != NULL);
|
||||
|
||||
pclass = property->property->class;
|
||||
|
||||
|
||||
list = pclass->choices;
|
||||
for (; list != NULL; list = list->next) {
|
||||
choice = (GladeChoice *)list->data;
|
||||
@ -970,7 +976,7 @@ glade_editor_property_load_choice (GladeEditorProperty *property)
|
||||
GtkMenuItem *menu_item = list->data;
|
||||
gtk_object_set_user_data (GTK_OBJECT (menu_item), property);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
@ -997,16 +1003,7 @@ glade_editor_property_load_boolean (GladeEditorProperty *property)
|
||||
g_return_if_fail (property->input != NULL);
|
||||
g_return_if_fail (GTK_IS_TOGGLE_BUTTON (property->input));
|
||||
|
||||
if (strcmp (property->property->value, GLADE_TAG_TRUE) == 0)
|
||||
state = TRUE;
|
||||
else if (strcmp (property->property->value, GLADE_TAG_FALSE) == 0)
|
||||
state = FALSE;
|
||||
else {
|
||||
g_warning ("Invalid boolean settings %s [%s],%s,%s)\n",
|
||||
property->property->value, property->property->class->name,
|
||||
GLADE_TAG_TRUE, GLADE_TAG_FALSE);
|
||||
state = FALSE;
|
||||
}
|
||||
state = g_value_get_boolean (property->property->value);
|
||||
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (property->input), state);
|
||||
label = GTK_BIN (property->input)->child;
|
||||
@ -1027,22 +1024,27 @@ glade_editor_property_load_text (GladeEditorProperty *property)
|
||||
if (GTK_IS_EDITABLE (property->input)) {
|
||||
GtkEditable *editable = GTK_EDITABLE (property->input);
|
||||
gint pos, insert_pos = 0;
|
||||
const gchar *text;
|
||||
text = g_value_get_string (property->property->value);
|
||||
pos = gtk_editable_get_position (editable);
|
||||
gtk_editable_delete_text (editable, 0, -1);
|
||||
gtk_editable_insert_text (editable,
|
||||
property->property->value,
|
||||
strlen (property->property->value),
|
||||
&insert_pos);
|
||||
if (text)
|
||||
gtk_editable_insert_text (editable,
|
||||
text,
|
||||
strlen (text),
|
||||
&insert_pos);
|
||||
gtk_editable_set_position (editable, pos);
|
||||
} else if (GTK_IS_TEXT_VIEW (property->input)) {
|
||||
GtkTextBuffer *buffer;
|
||||
const gchar *text;
|
||||
|
||||
text = g_value_get_string (property->property->value);
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (property->input));
|
||||
|
||||
/* FIXME !!! Will not work with mulitybyte languajes !!. Chema */
|
||||
gtk_text_buffer_set_text (buffer,
|
||||
property->property->value,
|
||||
strlen (property->property->value));
|
||||
text,
|
||||
strlen (text));
|
||||
} else {
|
||||
g_warning ("Invalid Text Widget type.");
|
||||
}
|
||||
@ -1083,7 +1085,7 @@ glade_editor_property_load (GladeEditorProperty *property, GladeWidget *widget)
|
||||
property->property->loading = TRUE;
|
||||
|
||||
switch (class->type) {
|
||||
case GLADE_PROPERTY_TYPE_TEXT:
|
||||
case GLADE_PROPERTY_TYPE_STRING:
|
||||
glade_editor_property_load_text (property);
|
||||
break;
|
||||
case GLADE_PROPERTY_TYPE_BOOLEAN:
|
||||
@ -1098,7 +1100,7 @@ glade_editor_property_load (GladeEditorProperty *property, GladeWidget *widget)
|
||||
case GLADE_PROPERTY_TYPE_INTEGER:
|
||||
glade_editor_property_load_integer (property);
|
||||
break;
|
||||
case GLADE_PROPERTY_TYPE_CHOICE:
|
||||
case GLADE_PROPERTY_TYPE_ENUM:
|
||||
glade_editor_property_load_choice (property);
|
||||
break;
|
||||
case GLADE_PROPERTY_TYPE_OTHER_WIDGETS:
|
||||
@ -1181,7 +1183,7 @@ glade_editor_property_changed_cb (GladeProperty *property,
|
||||
GladeEditorProperty *editor_property)
|
||||
{
|
||||
g_return_if_fail (property == editor_property->property);
|
||||
|
||||
|
||||
glade_editor_property_load (editor_property, property->widget);
|
||||
}
|
||||
|
||||
@ -1204,13 +1206,13 @@ glade_editor_load_item (GladeEditor *editor, GladeWidget *item)
|
||||
GladeEditorTable *table;
|
||||
GList *list;
|
||||
|
||||
editor->loaded_widget = item;
|
||||
|
||||
/* Load the GladeWidgetClass */
|
||||
class = item ? item->class : NULL;
|
||||
if (editor->loaded_class != class)
|
||||
glade_editor_load_class (editor, class);
|
||||
|
||||
editor->loaded_widget = item;
|
||||
|
||||
glade_editor_load_packing_page (editor, item);
|
||||
|
||||
glade_signal_editor_load_widget (editor->signal_editor, item);
|
||||
@ -1261,8 +1263,8 @@ glade_editor_load_item (GladeEditor *editor, GladeWidget *item)
|
||||
static void
|
||||
glade_editor_select_item_real (GladeEditor *editor, GladeWidget *widget)
|
||||
{
|
||||
GladeEditorTable *table;
|
||||
|
||||
GladeEditorTable *table;
|
||||
|
||||
if (editor->loaded_widget == widget)
|
||||
return;
|
||||
|
||||
|
165
src/glade-gtk.c
165
src/glade-gtk.c
@ -24,15 +24,17 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "glade.h"
|
||||
#include "glade-widget.h"
|
||||
#include "glade-placeholder.h"
|
||||
#include "glade-property-class.h"
|
||||
|
||||
|
||||
static void
|
||||
glade_gtk_entry_set_text (GObject *object, const gchar *string)
|
||||
glade_gtk_entry_set_text (GObject *object, GValue *value)
|
||||
{
|
||||
GtkEditable *editable = GTK_EDITABLE (object);
|
||||
gint pos;
|
||||
gint insert_pos = 0;
|
||||
const gchar *text = g_value_get_string (value);
|
||||
|
||||
g_return_if_fail (GTK_IS_EDITABLE (object));
|
||||
|
||||
@ -40,33 +42,40 @@ glade_gtk_entry_set_text (GObject *object, const gchar *string)
|
||||
gtk_editable_delete_text (editable, 0, -1);
|
||||
/* FIXME: will not work with multibyte languages (strlen) */
|
||||
gtk_editable_insert_text (editable,
|
||||
string,
|
||||
strlen (string),
|
||||
text,
|
||||
strlen (text),
|
||||
&insert_pos);
|
||||
gtk_editable_set_position (editable, pos);
|
||||
}
|
||||
|
||||
static gchar *
|
||||
glade_gtk_entry_get_text (GObject *object)
|
||||
static void
|
||||
glade_gtk_entry_get_text (GObject *object, GValue *value)
|
||||
{
|
||||
GtkEntry *entry = GTK_ENTRY (object);
|
||||
|
||||
const gchar *text;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_ENTRY (entry), NULL);
|
||||
g_return_if_fail (GTK_IS_ENTRY (entry));
|
||||
|
||||
text = gtk_entry_get_text (entry);
|
||||
|
||||
return g_strdup (text);
|
||||
g_value_set_string (value, text);
|
||||
}
|
||||
|
||||
static void
|
||||
glade_gtk_option_menu_set_items (GObject *object, const gchar *items)
|
||||
glade_gtk_option_menu_set_items (GObject *object, GValue *value)
|
||||
/*const gchar *items)*/
|
||||
{
|
||||
GtkOptionMenu *option_menu;
|
||||
GtkWidget *menu;
|
||||
const gchar *pos = items;
|
||||
const gchar *items_end = &items[strlen (items)];
|
||||
const gchar *items;
|
||||
const gchar *pos;
|
||||
const gchar *items_end;
|
||||
|
||||
items = g_value_get_string (value);
|
||||
pos = items;
|
||||
items_end = &items[strlen (items)];
|
||||
|
||||
option_menu = GTK_OPTION_MENU (object);
|
||||
g_return_if_fail (GTK_IS_OPTION_MENU (option_menu));
|
||||
menu = gtk_option_menu_get_menu (option_menu);
|
||||
@ -94,9 +103,10 @@ glade_gtk_option_menu_set_items (GObject *object, const gchar *items)
|
||||
|
||||
|
||||
static void
|
||||
glade_gtk_progress_bar_set_format (GObject *object, const gchar *format)
|
||||
glade_gtk_progress_bar_set_format (GObject *object, GValue *value)
|
||||
{
|
||||
GtkProgressBar *bar;
|
||||
const gchar *format = g_value_get_string (value);
|
||||
|
||||
bar = GTK_PROGRESS_BAR (object);
|
||||
g_return_if_fail (GTK_IS_PROGRESS_BAR (bar));
|
||||
@ -105,86 +115,111 @@ glade_gtk_progress_bar_set_format (GObject *object, const gchar *format)
|
||||
}
|
||||
|
||||
static void
|
||||
glade_gtk_adjustment_set_max (GObject *object, const gchar *string)
|
||||
glade_gtk_adjustment_set_max (GObject *object, GValue *value)
|
||||
{
|
||||
GtkAdjustment *adjustment;
|
||||
gfloat val;
|
||||
|
||||
val = atof (string);
|
||||
|
||||
adjustment = GTK_ADJUSTMENT (object);
|
||||
|
||||
adjustment->upper = val;
|
||||
adjustment->upper = g_value_get_float (value);
|
||||
gtk_adjustment_changed (adjustment);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
glade_gtk_adjustment_set_min (GObject *object, const gchar *string)
|
||||
glade_gtk_adjustment_set_min (GObject *object, GValue *value)
|
||||
{
|
||||
GtkAdjustment *adjustment;
|
||||
gfloat val;
|
||||
|
||||
val = atof (string);
|
||||
|
||||
adjustment = GTK_ADJUSTMENT (object);
|
||||
|
||||
adjustment->lower = val;
|
||||
adjustment->lower = g_value_get_float (value);
|
||||
gtk_adjustment_changed (adjustment);
|
||||
}
|
||||
|
||||
static void
|
||||
glade_gtk_adjustment_set_step_increment (GObject *object, const gchar *string)
|
||||
glade_gtk_adjustment_set_step_increment (GObject *object, GValue *value)
|
||||
{
|
||||
GtkAdjustment *adjustment;
|
||||
gfloat val;
|
||||
|
||||
val = atof (string);
|
||||
|
||||
adjustment = GTK_ADJUSTMENT (object);
|
||||
|
||||
adjustment->step_increment = val;
|
||||
gtk_adjustment_changed (adjustment);
|
||||
}
|
||||
static void
|
||||
glade_gtk_adjustment_set_page_increment (GObject *object, const gchar *string)
|
||||
{
|
||||
GtkAdjustment *adjustment;
|
||||
gfloat val;
|
||||
|
||||
val = atof (string);
|
||||
|
||||
adjustment = GTK_ADJUSTMENT (object);
|
||||
|
||||
adjustment->page_increment = val;
|
||||
adjustment->step_increment = g_value_get_float (value);
|
||||
gtk_adjustment_changed (adjustment);
|
||||
}
|
||||
|
||||
static void
|
||||
glade_gtk_adjustment_set_page_size (GObject *object, const gchar *string)
|
||||
glade_gtk_adjustment_set_page_increment (GObject *object, GValue *value)
|
||||
{
|
||||
GtkAdjustment *adjustment;
|
||||
gfloat val;
|
||||
|
||||
val = atof (string);
|
||||
|
||||
adjustment = GTK_ADJUSTMENT (object);
|
||||
|
||||
adjustment->page_size = val;
|
||||
adjustment->page_increment = g_value_get_float (value);
|
||||
gtk_adjustment_changed (adjustment);
|
||||
}
|
||||
|
||||
static void
|
||||
glade_gtk_adjustment_set_page_size (GObject *object, GValue *value)
|
||||
{
|
||||
GtkAdjustment *adjustment;
|
||||
|
||||
adjustment = GTK_ADJUSTMENT (object);
|
||||
|
||||
adjustment->page_size = g_value_get_float (value);
|
||||
gtk_adjustment_changed (adjustment);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
glade_gtk_vbox_get_size (GObject *object, const gchar *string)
|
||||
glade_gtk_box_get_size (GObject *object, GValue *value)
|
||||
{
|
||||
glade_implement_me ();
|
||||
GtkBox *box;
|
||||
|
||||
g_value_reset (value);
|
||||
|
||||
box = GTK_BOX (object);
|
||||
g_return_if_fail (GTK_IS_BOX (box));
|
||||
|
||||
g_value_set_int (value, g_list_length (box->children));
|
||||
}
|
||||
|
||||
static void
|
||||
glade_gtk_vbox_set_size (GObject *object, const gchar *string)
|
||||
glade_gtk_box_set_size (GObject *object, GValue *value)
|
||||
{
|
||||
GladeWidget *widget;
|
||||
GtkBox *box;
|
||||
gint new_size;
|
||||
gint old_size;
|
||||
|
||||
box = GTK_BOX (object);
|
||||
g_return_if_fail (GTK_IS_BOX (box));
|
||||
|
||||
new_size = g_value_get_int (value);
|
||||
old_size = g_list_length (box->children);
|
||||
|
||||
if (new_size == old_size)
|
||||
return;
|
||||
|
||||
widget = glade_widget_get_from_gtk_widget (GTK_WIDGET (box));
|
||||
g_return_if_fail (widget != NULL);
|
||||
|
||||
if (new_size > old_size) {
|
||||
int i = new_size - old_size;
|
||||
for (; i > 0; i--) {
|
||||
GladePlaceholder *placeholder;
|
||||
placeholder = glade_placeholder_new (widget);
|
||||
gtk_box_pack_start_defaults (box,
|
||||
GTK_WIDGET (placeholder));
|
||||
}
|
||||
} else {
|
||||
glade_implement_me ();
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
empty (GObject *object, GValue *value)
|
||||
{
|
||||
glade_implement_me ();
|
||||
}
|
||||
|
||||
/* ================ Temp hack =================== */
|
||||
@ -196,21 +231,29 @@ typedef struct _GladeGtkFunction GladeGtkFunction;
|
||||
|
||||
struct _GladeGtkFunction {
|
||||
const gchar *name;
|
||||
gpointer function;
|
||||
void (* function) (GObject *object, GValue *value);
|
||||
};
|
||||
|
||||
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_vbox_set_size", &glade_gtk_vbox_set_size},
|
||||
{"glade_gtk_vbox_get_size", &glade_gtk_vbox_get_size},
|
||||
{"glade_gtk_adjustment_set_max", &glade_gtk_adjustment_set_max},
|
||||
{"glade_gtk_adjustment_set_min", &glade_gtk_adjustment_set_min},
|
||||
{"glade_gtk_adjustment_set_step_increment", &glade_gtk_adjustment_set_step_increment},
|
||||
{"glade_gtk_adjustment_set_page_increment", &glade_gtk_adjustment_set_page_increment},
|
||||
{"glade_gtk_adjustment_set_page_size", &glade_gtk_adjustment_set_page_size},
|
||||
{"glade_gtk_entry_get_text", glade_gtk_entry_get_text},
|
||||
{"glade_gtk_box_get_size", glade_gtk_box_get_size},
|
||||
{"glade_gtk_widget_get_tooltip", empty},
|
||||
|
||||
{"glade_gtk_entry_set_text", glade_gtk_entry_set_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_box_set_size", glade_gtk_box_set_size},
|
||||
{"glade_gtk_widget_set_tooltip", empty},
|
||||
{"ignore", empty}, /* For example for gtkwindow::modal, we want to ignore the set */
|
||||
|
||||
{"glade_gtk_adjustment_set_max", glade_gtk_adjustment_set_max},
|
||||
{"glade_gtk_adjustment_set_min", glade_gtk_adjustment_set_min},
|
||||
{"glade_gtk_adjustment_set_step_increment", glade_gtk_adjustment_set_step_increment},
|
||||
{"glade_gtk_adjustment_set_page_increment", glade_gtk_adjustment_set_page_increment},
|
||||
{"glade_gtk_adjustment_set_page_size", glade_gtk_adjustment_set_page_size},
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
static gpointer
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "glade-packing.h"
|
||||
#include "glade-property-class.h"
|
||||
#include "glade-property.h"
|
||||
#include "glade-property-class.h"
|
||||
#include "glade-widget-class.h"
|
||||
#include "glade-widget.h"
|
||||
|
||||
@ -100,12 +101,11 @@ glade_packing_container_set_boolean (GtkContainer *container,
|
||||
|
||||
/* ---------------------------------------- Table ---------------------------*/
|
||||
static void
|
||||
glade_packing_table_set_flag (GObject *object, const gchar *value, const gchar *prop, guint flag)
|
||||
glade_packing_table_set_flag (GObject *object, const GValue *value, const gchar *prop, guint flag)
|
||||
{
|
||||
GladeWidget *glade_widget;
|
||||
GtkWidget *widget;
|
||||
GtkTable *table;
|
||||
gboolean val;
|
||||
|
||||
g_return_if_fail (value != NULL);
|
||||
widget = GTK_WIDGET (object);
|
||||
@ -116,19 +116,16 @@ glade_packing_table_set_flag (GObject *object, const gchar *value, const gchar *
|
||||
|
||||
g_return_if_fail (GTK_IS_TABLE (table));
|
||||
|
||||
val = (strcmp (value, GLADE_TAG_TRUE) == 0) ? TRUE : FALSE;
|
||||
|
||||
glade_packing_container_set_flag (GTK_CONTAINER (table), widget,
|
||||
val, prop, flag);
|
||||
g_value_get_boolean (value), prop, flag);
|
||||
}
|
||||
|
||||
static void
|
||||
glade_packing_table_set_integer (GObject *object, const gchar *value, const gchar *prop)
|
||||
glade_packing_table_set_integer (GObject *object, const GValue *value, const gchar *prop)
|
||||
{
|
||||
GladeWidget *glade_widget;
|
||||
GtkWidget *widget;
|
||||
GtkTable *table;
|
||||
gboolean val;
|
||||
|
||||
g_return_if_fail (value != NULL);
|
||||
widget = GTK_WIDGET (object);
|
||||
@ -139,93 +136,90 @@ glade_packing_table_set_integer (GObject *object, const gchar *value, const gcha
|
||||
|
||||
g_return_if_fail (GTK_IS_TABLE (table));
|
||||
|
||||
val = atoi (value);
|
||||
|
||||
glade_packing_container_set_integer (GTK_CONTAINER (table), widget,
|
||||
val, prop);
|
||||
g_value_get_int (value), prop);
|
||||
}
|
||||
|
||||
static void
|
||||
glade_packing_table_x_expand_set (GObject *object, const gchar *value)
|
||||
glade_packing_table_x_expand_set (GObject *object, const GValue *value)
|
||||
{
|
||||
glade_packing_table_set_flag (object, value, "x_options", GTK_EXPAND);
|
||||
}
|
||||
|
||||
static void
|
||||
glade_packing_table_y_expand_set (GObject *object, const gchar *value)
|
||||
glade_packing_table_y_expand_set (GObject *object, const GValue *value)
|
||||
{
|
||||
glade_packing_table_set_flag (object, value, "y_options", GTK_EXPAND);
|
||||
}
|
||||
|
||||
static void
|
||||
glade_packing_table_x_shrink_set (GObject *object, const gchar *value)
|
||||
glade_packing_table_x_shrink_set (GObject *object, const GValue *value)
|
||||
{
|
||||
glade_packing_table_set_flag (object, value, "x_options", GTK_SHRINK);
|
||||
}
|
||||
|
||||
static void
|
||||
glade_packing_table_y_shrink_set (GObject *object, const gchar *value)
|
||||
glade_packing_table_y_shrink_set (GObject *object, const GValue *value)
|
||||
{
|
||||
glade_packing_table_set_flag (object, value, "y_options", GTK_SHRINK);
|
||||
}
|
||||
|
||||
static void
|
||||
glade_packing_table_x_fill_set (GObject *object, const gchar *value)
|
||||
glade_packing_table_x_fill_set (GObject *object, const GValue *value)
|
||||
{
|
||||
glade_packing_table_set_flag (object, value, "x_options", GTK_FILL);
|
||||
}
|
||||
|
||||
static void
|
||||
glade_packing_table_y_fill_set (GObject *object, const gchar *value)
|
||||
glade_packing_table_y_fill_set (GObject *object, const GValue *value)
|
||||
{
|
||||
glade_packing_table_set_flag (object, value, "y_options", GTK_FILL);
|
||||
}
|
||||
|
||||
static void
|
||||
glade_packing_table_padding_h_set (GObject *object, const gchar *value)
|
||||
glade_packing_table_padding_h_set (GObject *object, const GValue *value)
|
||||
{
|
||||
glade_packing_table_set_integer (object, value, "x_padding");
|
||||
}
|
||||
|
||||
static void
|
||||
glade_packing_table_padding_v_set (GObject *object, const gchar *value)
|
||||
glade_packing_table_padding_v_set (GObject *object, const GValue *value)
|
||||
{
|
||||
glade_packing_table_set_integer (object, value, "y_padding");
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
glade_packing_table_cell_x_set (GObject *object, const gchar *value)
|
||||
glade_packing_table_cell_x_set (GObject *object, const GValue *value)
|
||||
{
|
||||
glade_implement_me ();
|
||||
}
|
||||
|
||||
static void
|
||||
glade_packing_table_cell_y_set (GObject *object, const gchar *value)
|
||||
glade_packing_table_cell_y_set (GObject *object, const GValue *value)
|
||||
{
|
||||
glade_implement_me ();
|
||||
}
|
||||
|
||||
static void
|
||||
glade_packing_table_span_x_set (GObject *object, const gchar *value)
|
||||
glade_packing_table_span_x_set (GObject *object, const GValue *value)
|
||||
{
|
||||
glade_implement_me ();
|
||||
}
|
||||
|
||||
static void
|
||||
glade_packing_table_span_y_set (GObject *object, const gchar *value)
|
||||
glade_packing_table_span_y_set (GObject *object, const GValue *value)
|
||||
{
|
||||
glade_implement_me ();
|
||||
}
|
||||
/* --------------------- box ----------------------------------- */
|
||||
static void
|
||||
glade_packing_box_set_boolean (GObject *object, const gchar *value, const gchar *property)
|
||||
glade_packing_box_set_boolean (GObject *object, gboolean value, const gchar *property)
|
||||
{
|
||||
GladeWidget *glade_widget;
|
||||
GtkWidget *widget;
|
||||
GtkBox *box;
|
||||
gboolean val;
|
||||
|
||||
|
||||
widget = GTK_WIDGET (object);
|
||||
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||
glade_widget = glade_widget_get_from_gtk_widget (widget);
|
||||
@ -234,22 +228,19 @@ glade_packing_box_set_boolean (GObject *object, const gchar *value, const gchar
|
||||
|
||||
g_return_if_fail (GTK_IS_BOX (box));
|
||||
|
||||
val = (strcmp (value, GLADE_TAG_TRUE) == 0) ? TRUE : FALSE;
|
||||
|
||||
glade_packing_container_set_boolean (GTK_CONTAINER (box),
|
||||
widget,
|
||||
val,
|
||||
value,
|
||||
property);
|
||||
}
|
||||
|
||||
static void
|
||||
glade_packing_box_set_integer (GObject *object, const gchar *value,
|
||||
glade_packing_box_set_integer (GObject *object, const GValue *value,
|
||||
const gchar *property)
|
||||
{
|
||||
GladeWidget *glade_widget;
|
||||
GtkBox *box;
|
||||
GtkWidget *widget;
|
||||
gint val;
|
||||
GtkBox *box;
|
||||
|
||||
widget = GTK_WIDGET (object);
|
||||
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||
@ -259,11 +250,9 @@ glade_packing_box_set_integer (GObject *object, const gchar *value,
|
||||
|
||||
g_return_if_fail (GTK_IS_BOX (box));
|
||||
|
||||
val = atoi (value);
|
||||
|
||||
glade_packing_container_set_integer (GTK_CONTAINER (box),
|
||||
widget,
|
||||
val,
|
||||
g_value_get_int (value),
|
||||
property);
|
||||
}
|
||||
|
||||
@ -275,9 +264,10 @@ glade_packing_box_set_integer (GObject *object, const gchar *value,
|
||||
* Sets the expand property of a widget inside a Gtk[HV]Box
|
||||
**/
|
||||
static void
|
||||
glade_packing_box_expand_set (GObject *object, const gchar *value)
|
||||
glade_packing_box_expand_set (GObject *object, const GValue *value)
|
||||
{
|
||||
glade_packing_box_set_boolean (object, value, "expand");
|
||||
glade_packing_box_set_boolean (object, g_value_get_boolean (value),
|
||||
"expand");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -288,9 +278,10 @@ glade_packing_box_expand_set (GObject *object, const gchar *value)
|
||||
* Sets the fill property of a widget inside a Gtk[VH]Box
|
||||
**/
|
||||
static void
|
||||
glade_packing_box_fill_set (GObject *object, const gchar *value)
|
||||
glade_packing_box_fill_set (GObject *object, const GValue *value)
|
||||
{
|
||||
glade_packing_box_set_boolean (object, value, "fill");
|
||||
glade_packing_box_set_boolean (object, g_value_get_boolean (value),
|
||||
"fill");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -301,21 +292,12 @@ glade_packing_box_fill_set (GObject *object, const gchar *value)
|
||||
* Sets the pack_start property for a widget inside a Gtk[HV]Box
|
||||
**/
|
||||
static void
|
||||
glade_packing_box_pack_start_set (GObject *object, const gchar *value)
|
||||
glade_packing_box_pack_start_set (GObject *object, const GValue *value)
|
||||
{
|
||||
gchar *temp;
|
||||
|
||||
/* Reverse value, because pack start is an enum, not a boolean.
|
||||
* Chema
|
||||
*/
|
||||
if (strcmp (value, GLADE_TAG_TRUE) == 0)
|
||||
temp = g_strdup (GLADE_TAG_FALSE);
|
||||
else
|
||||
temp = g_strdup (GLADE_TAG_TRUE);
|
||||
|
||||
glade_packing_box_set_boolean (object, temp, "pack_type");
|
||||
|
||||
g_free (temp);
|
||||
glade_packing_box_set_boolean (object, !g_value_get_boolean (value), "pack_type");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -326,13 +308,13 @@ glade_packing_box_pack_start_set (GObject *object, const gchar *value)
|
||||
* Sets the padding for widgets inside a GtkVBox or GtkHBox
|
||||
**/
|
||||
static void
|
||||
glade_packing_box_padding_set (GObject *object, const gchar *value)
|
||||
glade_packing_box_padding_set (GObject *object, const GValue *value)
|
||||
{
|
||||
glade_packing_box_set_integer (object, value, "padding");
|
||||
}
|
||||
|
||||
static gchar *
|
||||
glade_packing_box_position_get (GObject *object)
|
||||
static void
|
||||
glade_packing_box_position_get (GObject *object, GValue *value)
|
||||
{
|
||||
GladeWidget *glade_widget;
|
||||
GtkBoxChild *box_child = NULL;
|
||||
@ -340,13 +322,15 @@ glade_packing_box_position_get (GObject *object)
|
||||
GtkBox *box;
|
||||
GList *list;
|
||||
gint i;
|
||||
|
||||
g_value_reset (value);
|
||||
|
||||
widget = GTK_WIDGET (object);
|
||||
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
|
||||
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||
glade_widget = glade_widget_get_from_gtk_widget (widget);
|
||||
g_return_val_if_fail (GLADE_IS_WIDGET (glade_widget), NULL);
|
||||
g_return_if_fail (GLADE_IS_WIDGET (glade_widget));
|
||||
box = GTK_BOX (glade_widget->parent->widget);
|
||||
g_return_val_if_fail (GTK_IS_BOX (box), NULL);
|
||||
g_return_if_fail (GTK_IS_BOX (box));
|
||||
|
||||
list = box->children;
|
||||
for (; list; list = list->next) {
|
||||
@ -356,16 +340,16 @@ glade_packing_box_position_get (GObject *object)
|
||||
}
|
||||
if (list == NULL) {
|
||||
g_warning ("Could not find the position in the GtkBox");
|
||||
return g_strdup ("Error");
|
||||
return;
|
||||
}
|
||||
|
||||
i = g_list_index (box->children, box_child);
|
||||
|
||||
return g_strdup_printf ("%d", i);
|
||||
|
||||
g_value_set_int (value, i);
|
||||
}
|
||||
|
||||
static void
|
||||
glade_packing_box_position_set (GObject *object, const gchar *value)
|
||||
glade_packing_box_position_set (GObject *object, const GValue *value)
|
||||
{
|
||||
GladeWidget *glade_widget;
|
||||
GladeWidget *glade_widget_child;
|
||||
@ -379,7 +363,7 @@ glade_packing_box_position_set (GObject *object, const gchar *value)
|
||||
g_return_if_fail (GLADE_IS_WIDGET (glade_widget));
|
||||
box = GTK_BOX (glade_widget->parent->widget);
|
||||
|
||||
gtk_box_reorder_child (box, widget, atoi (value));
|
||||
gtk_box_reorder_child (box, widget, g_value_get_int (value));
|
||||
|
||||
/* This all works fine, but we need to update the position property
|
||||
* of the other children in this box since it has changed.
|
||||
@ -403,10 +387,8 @@ glade_packing_box_position_set (GObject *object, const gchar *value)
|
||||
"position");
|
||||
|
||||
/* If we have a placeholder in the Box the property will not be found */
|
||||
if (property) {
|
||||
g_free (property->value);
|
||||
property->value = glade_packing_box_position_get (G_OBJECT (child));
|
||||
}
|
||||
if (property)
|
||||
glade_packing_box_position_get (G_OBJECT (child), property->value);
|
||||
|
||||
/* We should pass a FALSE argument so that this property is not added to the
|
||||
* undo stack
|
||||
@ -414,6 +396,7 @@ glade_packing_box_position_set (GObject *object, const gchar *value)
|
||||
* but it shuold be done with a generic fuction
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
typedef struct _GladePackingProperty GladePackingProperty;
|
||||
@ -421,36 +404,37 @@ struct _GladePackingProperty
|
||||
{
|
||||
const gchar *name;
|
||||
const gchar *id;
|
||||
void (*set_function) (GObject *object, const gchar *value);
|
||||
gchar * (*get_function) (GObject *object);
|
||||
void (*set_function) (GObject *object, const GValue *value);
|
||||
void (*get_function) (GObject *object, GValue *value);
|
||||
GladePropertyType type;
|
||||
const gchar *def;
|
||||
gboolean get_default; /* see g-property-class.h ->get_default */
|
||||
};
|
||||
|
||||
GladePackingProperty table_props[] =
|
||||
{
|
||||
{"Cell X", "cell_x", glade_packing_table_cell_x_set, NULL, GLADE_PROPERTY_TYPE_INTEGER, "0"},
|
||||
{"Cell Y", "cell_y", glade_packing_table_cell_y_set, NULL, GLADE_PROPERTY_TYPE_INTEGER, "0"},
|
||||
{"Col Span", "col_span", glade_packing_table_span_x_set, NULL, GLADE_PROPERTY_TYPE_INTEGER, "0"},
|
||||
{"Row Span", "row_span", glade_packing_table_span_y_set, NULL, GLADE_PROPERTY_TYPE_INTEGER, "0"},
|
||||
{"H Padding", "h_padding", glade_packing_table_padding_h_set, NULL, GLADE_PROPERTY_TYPE_INTEGER, "0"},
|
||||
{"V Padding", "v_padding", glade_packing_table_padding_v_set, NULL, GLADE_PROPERTY_TYPE_INTEGER, "0"},
|
||||
{"Cell X", "cell_x", glade_packing_table_cell_x_set, NULL, GLADE_PROPERTY_TYPE_INTEGER, "0", FALSE},
|
||||
{"Cell Y", "cell_y", glade_packing_table_cell_y_set, NULL, GLADE_PROPERTY_TYPE_INTEGER, "0", FALSE},
|
||||
{"Col Span", "col_span", glade_packing_table_span_x_set, NULL, GLADE_PROPERTY_TYPE_INTEGER, "0", FALSE},
|
||||
{"Row Span", "row_span", glade_packing_table_span_y_set, NULL, GLADE_PROPERTY_TYPE_INTEGER, "0", FALSE},
|
||||
{"H Padding", "h_padding", glade_packing_table_padding_h_set, NULL, GLADE_PROPERTY_TYPE_INTEGER, "0", FALSE},
|
||||
{"V Padding", "v_padding", glade_packing_table_padding_v_set, NULL, GLADE_PROPERTY_TYPE_INTEGER, "0", FALSE},
|
||||
|
||||
{"X Expand", "xexpand", glade_packing_table_x_expand_set, NULL, GLADE_PROPERTY_TYPE_BOOLEAN, NULL},
|
||||
{"Y Expand", "yexpand", glade_packing_table_y_expand_set, NULL, GLADE_PROPERTY_TYPE_BOOLEAN, NULL},
|
||||
{"X Shrink", "xshrink", glade_packing_table_x_shrink_set, NULL, GLADE_PROPERTY_TYPE_BOOLEAN, NULL},
|
||||
{"Y Shrink", "yshrink", glade_packing_table_y_shrink_set, NULL, GLADE_PROPERTY_TYPE_BOOLEAN, NULL},
|
||||
{"X Fill", "xfill", glade_packing_table_x_fill_set, NULL, GLADE_PROPERTY_TYPE_BOOLEAN, NULL},
|
||||
{"Y Fill", "yfill", glade_packing_table_y_fill_set, NULL, GLADE_PROPERTY_TYPE_BOOLEAN, NULL},
|
||||
{"X Expand", "xexpand", glade_packing_table_x_expand_set, NULL, GLADE_PROPERTY_TYPE_BOOLEAN, NULL, FALSE},
|
||||
{"Y Expand", "yexpand", glade_packing_table_y_expand_set, NULL, GLADE_PROPERTY_TYPE_BOOLEAN, NULL, FALSE},
|
||||
{"X Shrink", "xshrink", glade_packing_table_x_shrink_set, NULL, GLADE_PROPERTY_TYPE_BOOLEAN, NULL, FALSE},
|
||||
{"Y Shrink", "yshrink", glade_packing_table_y_shrink_set, NULL, GLADE_PROPERTY_TYPE_BOOLEAN, NULL, FALSE},
|
||||
{"X Fill", "xfill", glade_packing_table_x_fill_set, NULL, GLADE_PROPERTY_TYPE_BOOLEAN, NULL, FALSE},
|
||||
{"Y Fill", "yfill", glade_packing_table_y_fill_set, NULL, GLADE_PROPERTY_TYPE_BOOLEAN, NULL, FALSE},
|
||||
};
|
||||
|
||||
GladePackingProperty box_props[] =
|
||||
{
|
||||
{"Position", "position", glade_packing_box_position_set, glade_packing_box_position_get, GLADE_PROPERTY_TYPE_INTEGER, GLADE_GET_DEFAULT_FROM_WIDGET},
|
||||
{"Padding", "padding", glade_packing_box_padding_set, NULL, GLADE_PROPERTY_TYPE_INTEGER, "0"},
|
||||
{"Expand", "expand", glade_packing_box_expand_set, NULL, GLADE_PROPERTY_TYPE_BOOLEAN, GLADE_TAG_TRUE},
|
||||
{"Fill", "fill", glade_packing_box_fill_set, NULL, GLADE_PROPERTY_TYPE_BOOLEAN, GLADE_TAG_TRUE},
|
||||
{"Pack Start", "packstart", glade_packing_box_pack_start_set, NULL, GLADE_PROPERTY_TYPE_BOOLEAN, GLADE_TAG_TRUE},
|
||||
{"Position", "position", glade_packing_box_position_set, glade_packing_box_position_get, GLADE_PROPERTY_TYPE_INTEGER, NULL, TRUE},
|
||||
{"Padding", "padding", glade_packing_box_padding_set, NULL, GLADE_PROPERTY_TYPE_INTEGER, "0", FALSE},
|
||||
{"Expand", "expand", glade_packing_box_expand_set, NULL, GLADE_PROPERTY_TYPE_BOOLEAN, GLADE_TAG_TRUE, FALSE},
|
||||
{"Fill", "fill", glade_packing_box_fill_set, NULL, GLADE_PROPERTY_TYPE_BOOLEAN, GLADE_TAG_TRUE, FALSE},
|
||||
{"Pack Start", "packstart", glade_packing_box_pack_start_set, NULL, GLADE_PROPERTY_TYPE_BOOLEAN, GLADE_TAG_TRUE, FALSE},
|
||||
};
|
||||
|
||||
/**
|
||||
@ -474,7 +458,8 @@ glade_packing_add_property (GList **list, GladePackingProperty prop)
|
||||
class->set_function = prop.set_function;
|
||||
class->get_function = prop.get_function;
|
||||
if (prop.def)
|
||||
class->def = g_strdup (prop.def);
|
||||
class->def = glade_property_class_make_gvalue_from_string (prop.type, prop.def);
|
||||
class->get_default = prop.get_default;
|
||||
|
||||
*list = g_list_prepend (*list, class);
|
||||
}
|
||||
|
@ -21,7 +21,6 @@
|
||||
*/
|
||||
|
||||
|
||||
#include <config.h>
|
||||
#include "glade.h"
|
||||
|
||||
#include "glade-palette.h"
|
||||
@ -341,3 +340,17 @@ glade_palette_create (GladeProjectWindow *gpw)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
glade_palette_clear (GladeProjectWindow *gpw)
|
||||
{
|
||||
GladePalette *palette;
|
||||
|
||||
palette = gpw->palette;
|
||||
|
||||
if (!GLADE_IS_PALETTE (palette))
|
||||
return;
|
||||
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (palette->dummy_button),
|
||||
TRUE);
|
||||
}
|
||||
|
@ -69,8 +69,9 @@ struct _GladePaletteClass
|
||||
|
||||
};
|
||||
|
||||
void glade_palette_create (GladeProjectWindow *gpw);
|
||||
void glade_palette_show (GladeProjectWindow *gpw);
|
||||
void glade_palette_create (GladeProjectWindow *gpw);
|
||||
void glade_palette_show (GladeProjectWindow *gpw);
|
||||
void glade_palette_clear (GladeProjectWindow *gpw);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -208,7 +208,7 @@ glade_parameter_list_new_from_node (GList *list, GladeXmlNode *node)
|
||||
* Return Value: A newly created GtkAdjustment
|
||||
**/
|
||||
GtkAdjustment *
|
||||
glade_parameter_adjustment_new (GList *parameters, const gchar *def)
|
||||
glade_parameter_adjustment_new (GList *parameters, const GValue *def)
|
||||
{
|
||||
GtkAdjustment *adjustment;
|
||||
gfloat value = 1;
|
||||
@ -219,11 +219,20 @@ glade_parameter_adjustment_new (GList *parameters, const gchar *def)
|
||||
gfloat page_increment = 265;
|
||||
gfloat climb_rate = 1;
|
||||
|
||||
if (def)
|
||||
value = atof (def);
|
||||
else
|
||||
glade_parameter_get_float (parameters, "Default", &value);
|
||||
|
||||
if (def) {
|
||||
switch (def->g_type) {
|
||||
case G_TYPE_FLOAT:
|
||||
value = g_value_get_float (def);
|
||||
break;
|
||||
case G_TYPE_INT:
|
||||
value = (float) g_value_get_int (def);
|
||||
break;
|
||||
case G_TYPE_DOUBLE:
|
||||
value = (float) g_value_get_double (def);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
glade_parameter_get_float (parameters, "Min", &lower);
|
||||
glade_parameter_get_float (parameters, "Max", &upper);
|
||||
glade_parameter_get_float (parameters, "StepIncrement", &step_increment);
|
||||
|
@ -42,7 +42,7 @@ void glade_parameter_get_string (GList *parameters, const gchar *key, gchar **v
|
||||
GList * glade_parameter_list_new_from_node (GList *list, GladeXmlNode *node);
|
||||
|
||||
/* Convenience functions */
|
||||
GtkAdjustment * glade_parameter_adjustment_new (GList *parameters, const gchar *def);
|
||||
GtkAdjustment * glade_parameter_adjustment_new (GList *parameters, const GValue *def);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -20,7 +20,6 @@
|
||||
* Chema Celorio <chema@celorio.com>
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "glade.h"
|
||||
@ -45,7 +44,7 @@ glade_placeholder_replace_box (GtkWidget *current,
|
||||
GtkWidget *child;
|
||||
GtkBox *box;
|
||||
GList *list;
|
||||
|
||||
|
||||
box = GTK_BOX (container);
|
||||
|
||||
list = box->children;
|
||||
@ -201,7 +200,7 @@ glade_placeholder_on_button_press_event (GladePlaceholder *placeholder, GdkEvent
|
||||
|
||||
if (event->button == 1 && event->type == GDK_BUTTON_PRESS && gpw->add_class != NULL) {
|
||||
glade_placeholder_replace_widget (placeholder, gpw->add_class, project);
|
||||
gpw->add_class = NULL;
|
||||
glade_project_window_set_add_class (gpw, NULL);
|
||||
}
|
||||
|
||||
}
|
||||
@ -347,8 +346,10 @@ glade_placeholder_add (GladeWidgetClass *class,
|
||||
gint size;
|
||||
|
||||
glade_property_query_result_get_int (result, "size", &size);
|
||||
g_print ("Size is %d\n", size);
|
||||
|
||||
for (i = 0; i < size; i++) {
|
||||
g_print ("Add placeholder %d\n", size);
|
||||
placeholder = glade_placeholder_new (widget);
|
||||
gtk_box_pack_start_defaults (GTK_BOX (widget->widget),
|
||||
GTK_WIDGET (placeholder));
|
||||
|
@ -30,14 +30,7 @@ static void
|
||||
glade_popup_menu_detach (GtkWidget *attach_widget,
|
||||
GtkMenu *menu)
|
||||
{
|
||||
/* We don't need a detach function. do we ? Chema. */
|
||||
#if 0
|
||||
GladeWidget *widget;
|
||||
gtk_widget_destroy (GTK_WIDGET (menu));
|
||||
|
||||
widget = glade_widget_get_from_gtk_widget (attach_widget);
|
||||
widget->popup_menu = NULL;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -33,6 +33,8 @@ glade_project_ui_delete_event_cb (GtkWidget *selector, GdkEventAny *event)
|
||||
gtk_main_quit ();
|
||||
|
||||
gtk_object_set_user_data (GTK_OBJECT (selector), NULL);
|
||||
|
||||
gtk_widget_hide (selector);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -57,11 +59,11 @@ glade_project_ui_selector_clicked (GtkWidget *button, GtkWidget *selector)
|
||||
}
|
||||
|
||||
gchar *
|
||||
glade_project_ui_save_get_name (GladeProject *project)
|
||||
glade_project_ui_get_path (const gchar *title)
|
||||
{
|
||||
GtkWidget *selector;
|
||||
|
||||
selector = gtk_file_selection_new (_("Save ..."));
|
||||
selector = gtk_file_selection_new (title);
|
||||
|
||||
gtk_window_set_modal (GTK_WINDOW (selector), TRUE);
|
||||
|
||||
@ -87,7 +89,7 @@ glade_project_ui_save_get_name (GladeProject *project)
|
||||
|
||||
|
||||
void
|
||||
glade_project_ui_warn (GladeProject *project, const gchar *warning)
|
||||
glade_project_ui_warn (const gchar *warning)
|
||||
{
|
||||
/* This are warnings to the users, use a nice dialog and stuff */
|
||||
|
||||
|
@ -4,8 +4,8 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
gchar * glade_project_ui_save_get_name (GladeProject *project);
|
||||
void glade_project_ui_warn (GladeProject *project, const gchar *warning);
|
||||
gchar * glade_project_ui_get_path (const gchar *title);
|
||||
void glade_project_ui_warn (const gchar *warning);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -151,7 +151,8 @@ glade_project_view_widget_name_changed (GladeProjectView *view,
|
||||
static void
|
||||
glade_project_view_populate_model_real (GtkTreeStore *model,
|
||||
GList *widgets,
|
||||
GtkTreeIter *parent_iter)
|
||||
GtkTreeIter *parent_iter,
|
||||
gboolean add_childs)
|
||||
{
|
||||
GladeWidget *widget;
|
||||
GList *list;
|
||||
@ -166,14 +167,16 @@ glade_project_view_populate_model_real (GtkTreeStore *model,
|
||||
gtk_tree_store_set (model, &iter,
|
||||
WIDGET_COLUMN, widget,
|
||||
-1);
|
||||
if (widget->children != NULL) {
|
||||
if (add_childs && widget->children != NULL) {
|
||||
copy = gtk_tree_iter_copy (&iter);
|
||||
glade_project_view_populate_model_real (model,
|
||||
widget->children,
|
||||
copy);
|
||||
copy,
|
||||
TRUE);
|
||||
gtk_tree_iter_free (copy);
|
||||
}
|
||||
}
|
||||
g_list_free (list);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -198,7 +201,8 @@ glade_project_view_populate_model (GtkTreeStore *model,
|
||||
}
|
||||
|
||||
/* add the widgets and recurse */
|
||||
glade_project_view_populate_model_real (model, toplevels, NULL);
|
||||
glade_project_view_populate_model_real (model, toplevels,
|
||||
NULL, !view->is_list);
|
||||
|
||||
g_list_free (toplevels);
|
||||
}
|
||||
@ -231,7 +235,9 @@ glade_project_view_add_item (GladeProjectView *view,
|
||||
WIDGET_COLUMN, widget,
|
||||
-1);
|
||||
|
||||
view->updating_selection = TRUE;
|
||||
glade_project_selection_set (widget, TRUE);
|
||||
view->updating_selection = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -263,6 +269,60 @@ glade_project_view_remove_item (GladeProjectView *view,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* glade_project_view_selection_update:
|
||||
* @view:
|
||||
* @widget:
|
||||
*
|
||||
* The project selection has changed, update our state to reflect the changes.
|
||||
**/
|
||||
static void
|
||||
glade_project_view_selection_update (GladeProjectView *view,
|
||||
GladeProject *project)
|
||||
{
|
||||
#if 0
|
||||
GtkTreeSelection *selection;
|
||||
#endif
|
||||
GList *list;
|
||||
|
||||
g_return_if_fail (GLADE_IS_PROJECT_VIEW (view));
|
||||
g_return_if_fail (GLADE_IS_PROJECT (project));
|
||||
g_return_if_fail (view->project == project);
|
||||
|
||||
list = glade_project_selection_get (project);
|
||||
|
||||
#if 0
|
||||
g_ print ("Update dude\n");
|
||||
|
||||
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view->widget));
|
||||
|
||||
g_return_if_fail (GTK_IS_TREE_SELECTION (selection));
|
||||
|
||||
GladeWidgetClass *class;
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter *iter;
|
||||
|
||||
class = glade_widget_get_class (widget);
|
||||
|
||||
if (view->is_list && !GLADE_WIDGET_CLASS_TOPLEVEL (class))
|
||||
return;
|
||||
|
||||
model = GTK_TREE_MODEL (view->model);
|
||||
|
||||
iter = glade_project_view_find_iter_by_widget (model,
|
||||
widget);
|
||||
|
||||
if (iter) {
|
||||
static gboolean warned = FALSE;
|
||||
if (!warned)
|
||||
g_print ("Update the cell. BUT HOW ??\n");
|
||||
warned = TRUE;
|
||||
}
|
||||
|
||||
gtk_tree_store_remove (view->model, iter);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
glade_project_view_class_init (GladeProjectViewClass * gpv_class)
|
||||
{
|
||||
@ -276,6 +336,7 @@ glade_project_view_class_init (GladeProjectViewClass * gpv_class)
|
||||
gpv_class->remove_item = glade_project_view_remove_item;
|
||||
gpv_class->set_project = glade_project_view_set_project;
|
||||
gpv_class->widget_name_changed = glade_project_view_widget_name_changed;
|
||||
gpv_class->selection_update = glade_project_view_selection_update;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -309,6 +370,7 @@ glade_project_view_cell_function (GtkTreeViewColumn *tree_column,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
glade_project_view_selection_changed_cb (GtkTreeSelection *selection,
|
||||
GladeProjectView *view)
|
||||
@ -318,6 +380,9 @@ glade_project_view_selection_changed_cb (GtkTreeSelection *selection,
|
||||
GtkTreeView *tree_view;
|
||||
GtkTreeIter iter;
|
||||
|
||||
if (!view->project)
|
||||
return TRUE;
|
||||
|
||||
g_return_val_if_fail (GTK_IS_TREE_SELECTION (selection), FALSE);
|
||||
g_return_val_if_fail (GLADE_IS_PROJECT_VIEW (view), FALSE);
|
||||
|
||||
@ -335,7 +400,9 @@ glade_project_view_selection_changed_cb (GtkTreeSelection *selection,
|
||||
if (widget == NULL)
|
||||
return TRUE;
|
||||
|
||||
view->updating_selection = TRUE;
|
||||
glade_project_selection_set (widget, TRUE);
|
||||
view->updating_selection = FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -348,22 +415,29 @@ glade_project_view_button_press_cb (GtkTreeView *view, GdkEventButton *event)
|
||||
model = gtk_tree_view_get_model (view);
|
||||
|
||||
if (event->type == GDK_2BUTTON_PRESS) {
|
||||
GtkTreePath * path = gtk_tree_path_new ();
|
||||
GtkTreePath *path = gtk_tree_path_new ();
|
||||
GtkTreeIter iter;
|
||||
GladeWidget *widget;
|
||||
|
||||
g_print ("Double click\n");
|
||||
if (!gtk_tree_view_get_path_at_pos (view,
|
||||
event->window,
|
||||
event->x, event->y,
|
||||
&path, NULL, NULL, NULL))
|
||||
return FALSE;
|
||||
if (!gtk_tree_model_get_iter (model, &iter, path))
|
||||
return FALSE;
|
||||
&path, NULL, NULL, NULL)) {
|
||||
g_print ("Could not get path at pos\n");
|
||||
return FALSE;
|
||||
}
|
||||
if (!gtk_tree_model_get_iter (model, &iter, path)) {
|
||||
g_print ("could not get iter\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gtk_tree_model_get (model, &iter, WIDGET_COLUMN, &widget, -1);
|
||||
gtk_tree_path_free (path);
|
||||
if (!widget)
|
||||
if (!widget) {
|
||||
g_print ("Could not get widget\n");
|
||||
return FALSE;
|
||||
}
|
||||
gtk_widget_show (widget->widget);
|
||||
}
|
||||
|
||||
@ -390,7 +464,7 @@ glade_project_view_create_widget (GladeProjectView *view)
|
||||
NULL, NULL, 0);
|
||||
|
||||
cell = gtk_cell_renderer_text_pixbuf_new ();
|
||||
column = gtk_tree_view_column_new_with_attributes ("Widget", cell, NULL);
|
||||
column = gtk_tree_view_column_new_with_attributes (_("Widget"), cell, NULL);
|
||||
gtk_tree_view_column_set_cell_data_func (column, cell, glade_project_view_cell_function, NULL, NULL);
|
||||
gtk_tree_view_append_column (GTK_TREE_VIEW (widget), column);
|
||||
|
||||
@ -423,16 +497,21 @@ glade_project_view_init (GladeProjectView * view)
|
||||
view->add_widget_signal_id = 0;
|
||||
|
||||
view->widget = glade_project_view_create_widget (view);
|
||||
view->updating_selection = FALSE;
|
||||
gtk_widget_show (view->widget);
|
||||
}
|
||||
|
||||
#if 0
|
||||
void
|
||||
glade_project_view_selection_changed (GladeProjectView *view, GladeWidget *item)
|
||||
{
|
||||
#warning FIGURE IT OUT
|
||||
view->updating_selection = TRUE;
|
||||
glade_project_selection_clear (view->project, FALSE);
|
||||
view->updating_selection = FALSE;
|
||||
|
||||
glade_implement_me ();
|
||||
#if 0
|
||||
#if 1
|
||||
if (view->selected_widget == item)
|
||||
return;
|
||||
|
||||
@ -442,6 +521,7 @@ glade_project_view_selection_changed (GladeProjectView *view, GladeWidget *item)
|
||||
glade_project_view_signals [ITEM_SELECTED], item);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static void
|
||||
@ -468,6 +548,18 @@ glade_project_view_widget_name_changed_cb (GladeProject *project,
|
||||
GLADE_PROJECT_VIEW_CLASS (GTK_OBJECT_GET_CLASS(view))->widget_name_changed (view, widget);
|
||||
}
|
||||
|
||||
static void
|
||||
glade_project_view_selection_update_cb (GladeProject *project,
|
||||
GladeProjectView *view)
|
||||
{
|
||||
/* This view caused this selection change in the project, since we
|
||||
* already know about it we don't need updating. Chema
|
||||
*/
|
||||
if (view->updating_selection)
|
||||
return;
|
||||
|
||||
GLADE_PROJECT_VIEW_CLASS (GTK_OBJECT_GET_CLASS(view))->selection_update (view, project);
|
||||
}
|
||||
|
||||
/**
|
||||
* glade_project_view_new:
|
||||
@ -515,30 +607,41 @@ glade_project_view_set_project (GladeProjectView *view,
|
||||
gtk_signal_disconnect (GTK_OBJECT (view->project), view->add_widget_signal_id);
|
||||
gtk_signal_disconnect (GTK_OBJECT (view->project), view->remove_widget_signal_id);
|
||||
gtk_signal_disconnect (GTK_OBJECT (view->project), view->widget_name_changed_signal_id);
|
||||
gtk_signal_disconnect (GTK_OBJECT (view->project), view->selection_changed_signal_id);
|
||||
}
|
||||
|
||||
view->project = project;
|
||||
|
||||
model = GTK_TREE_MODEL (view->model);
|
||||
|
||||
/* Set to null while we remove all the items from the store, because we are going to trigger
|
||||
* selection_changed signal emisions on the View. By setting the project to NULL, _selection_changed_cb
|
||||
* will just return. Chema
|
||||
*/
|
||||
view->project = NULL;
|
||||
|
||||
while (gtk_tree_model_get_iter_root (model, &iter))
|
||||
gtk_tree_store_remove (view->model, &iter);
|
||||
|
||||
view->project = project;
|
||||
|
||||
glade_project_view_populate_model (view->model, view);
|
||||
|
||||
/* Here we connect to all the signals of the project that interests us */
|
||||
view->add_widget_signal_id =
|
||||
gtk_signal_connect (GTK_OBJECT (project), "add_widget",
|
||||
GTK_SIGNAL_FUNC (glade_project_view_add_widget_cb),
|
||||
view);
|
||||
GTK_SIGNAL_FUNC (glade_project_view_add_widget_cb),
|
||||
view);
|
||||
view->remove_widget_signal_id =
|
||||
gtk_signal_connect (GTK_OBJECT (project), "remove_widget",
|
||||
GTK_SIGNAL_FUNC (glade_project_view_remove_widget_cb),
|
||||
view);
|
||||
GTK_SIGNAL_FUNC (glade_project_view_remove_widget_cb),
|
||||
view);
|
||||
view->widget_name_changed_signal_id =
|
||||
gtk_signal_connect (GTK_OBJECT (project), "widget_name_changed",
|
||||
GTK_SIGNAL_FUNC (glade_project_view_widget_name_changed_cb),
|
||||
view);
|
||||
GTK_SIGNAL_FUNC (glade_project_view_widget_name_changed_cb),
|
||||
view);
|
||||
view->selection_changed_signal_id =
|
||||
gtk_signal_connect (GTK_OBJECT (project), "selection_changed",
|
||||
GTK_SIGNAL_FUNC (glade_project_view_selection_update_cb),
|
||||
view);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -21,6 +21,7 @@ struct _GladeProjectView
|
||||
GObject parent;
|
||||
|
||||
GtkWidget *widget;
|
||||
GtkTreeView *tree_view;
|
||||
|
||||
GladeProject *project; /* A pointer so that we can get back to the
|
||||
* project that we are a view for
|
||||
@ -37,8 +38,8 @@ struct _GladeProjectView
|
||||
* we stop listening to the old project
|
||||
*/
|
||||
gulong remove_widget_signal_id;
|
||||
|
||||
gulong widget_name_changed_signal_id;
|
||||
gulong selection_changed_signal_id;
|
||||
|
||||
|
||||
GtkTreeStore *model; /* Model */
|
||||
@ -46,6 +47,14 @@ struct _GladeProjectView
|
||||
gboolean is_list; /* If true the view is a list, if false the view
|
||||
* is a tree
|
||||
*/
|
||||
|
||||
gboolean updating_selection; /* True when we are going to set the
|
||||
* project selction. So that we don't
|
||||
* recurse cause we are also listening
|
||||
* for the project changed selection
|
||||
* signal
|
||||
*/
|
||||
|
||||
};
|
||||
|
||||
struct _GladeProjectViewClass
|
||||
@ -64,9 +73,15 @@ struct _GladeProjectViewClass
|
||||
GladeWidget *widget);
|
||||
void (*widget_name_changed) (GladeProjectView *view,
|
||||
GladeWidget *widget);
|
||||
|
||||
void (*set_project) (GladeProjectView *view,
|
||||
GladeProject *project);
|
||||
/* Selection update is when the project changes the selection
|
||||
* and we need to update our state, selection changed functions
|
||||
* are the other way arround, the selection in the view changed
|
||||
* and we need to let the project know about it. Chema
|
||||
*/
|
||||
void (*selection_update) (GladeProjectView *view,
|
||||
GladeProject *project);
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
|
@ -51,7 +51,7 @@ static void gpw_about_cb (void) {};
|
||||
static void
|
||||
gpw_open_cb (void)
|
||||
{
|
||||
glade_implement_me ();
|
||||
glade_project_open ();
|
||||
}
|
||||
|
||||
static void
|
||||
@ -96,7 +96,7 @@ gpw_new_cb (void)
|
||||
GladeProjectWindow *gpw;
|
||||
GladeProject *project;
|
||||
|
||||
project = glade_project_new ();
|
||||
project = glade_project_new (TRUE);
|
||||
gpw = glade_project_window_get ();
|
||||
glade_project_window_add_project (gpw, project);
|
||||
}
|
||||
@ -427,6 +427,12 @@ glade_project_window_set_project (GladeProjectWindow *gpw, GladeProject *project
|
||||
GladeProjectView *view;
|
||||
GList *list;
|
||||
gchar *title;
|
||||
|
||||
if (g_list_find (gpw->projects, project) == NULL) {
|
||||
g_warning ("Could not set project because it could not "
|
||||
" be found in the gpw->project list\n");
|
||||
return;
|
||||
}
|
||||
|
||||
gpw->project = project;
|
||||
if (project) {
|
||||
@ -447,6 +453,8 @@ glade_project_window_set_project (GladeProjectWindow *gpw, GladeProject *project
|
||||
gtk_signal_connect (GTK_OBJECT (project), "selection_changed",
|
||||
GTK_SIGNAL_FUNC (glade_project_window_selection_changed_cb),
|
||||
gpw);
|
||||
|
||||
glade_project_selection_changed (project);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -486,6 +494,10 @@ void
|
||||
glade_project_window_set_add_class (GladeProjectWindow *gpw, GladeWidgetClass *class)
|
||||
{
|
||||
gpw->add_class = class;
|
||||
|
||||
if (!class && gpw->palette)
|
||||
glade_palette_clear (gpw);
|
||||
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
@ -570,6 +582,7 @@ glade_project_window_query_properties (GladeWidgetClass *class,
|
||||
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
|
||||
GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
|
||||
NULL);
|
||||
gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
|
||||
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
|
||||
|
||||
vbox = GTK_DIALOG (dialog)->vbox;
|
||||
|
@ -138,13 +138,15 @@ glade_project_destroy (GtkObject *object)
|
||||
}
|
||||
|
||||
GladeProject *
|
||||
glade_project_new (void)
|
||||
glade_project_new (gboolean untitled)
|
||||
{
|
||||
GladeProject *project;
|
||||
static gint i = 1;
|
||||
|
||||
project = GLADE_PROJECT (gtk_type_new (glade_project_get_type ()));
|
||||
project->name = g_strdup_printf ("Untitled %i", i++);
|
||||
|
||||
if (untitled)
|
||||
project->name = g_strdup_printf ("Untitled %i", i++);
|
||||
|
||||
return project;
|
||||
}
|
||||
@ -164,8 +166,8 @@ glade_project_selection_changed (GladeProject *project)
|
||||
|
||||
|
||||
void
|
||||
glade_project_add_widget (GladeProject *project,
|
||||
GladeWidget *widget)
|
||||
glade_project_add_widget (GladeProject *project,
|
||||
GladeWidget *widget)
|
||||
{
|
||||
g_return_if_fail (GLADE_IS_PROJECT (project));
|
||||
g_return_if_fail (GTK_IS_OBJECT (project));
|
||||
@ -360,11 +362,10 @@ glade_project_selection_set (GladeWidget *widget,
|
||||
|
||||
project = widget->project;
|
||||
g_return_if_fail (GLADE_IS_PROJECT (project));
|
||||
|
||||
|
||||
list = project->selection;
|
||||
/* Check if the selection is different than what we have */
|
||||
if ((list) && (list->next == NULL) && (list->data == widget))
|
||||
return;
|
||||
return;
|
||||
|
||||
glade_project_selection_clear (project, FALSE);
|
||||
glade_project_selection_add (widget, emit_signal);
|
||||
@ -475,6 +476,56 @@ glade_project_save_to_file (GladeProject *project,
|
||||
}
|
||||
|
||||
|
||||
static GladeProject *
|
||||
glade_project_new_from_node (GladeXmlNode *node)
|
||||
{
|
||||
GladeProject *project;
|
||||
GladeXmlNode *child;
|
||||
GladeWidget *widget;
|
||||
|
||||
if (!glade_xml_node_verify (node, GLADE_XML_TAG_PROJECT))
|
||||
return NULL;
|
||||
|
||||
project = glade_project_new (FALSE);
|
||||
project->name = g_strdup ("Fixme");
|
||||
project->changed = FALSE;
|
||||
project->selection = NULL;
|
||||
project->widgets = NULL;
|
||||
|
||||
child = glade_xml_node_get_children (node);
|
||||
for (; child != NULL; child = glade_xml_node_next (child)) {
|
||||
if (!glade_xml_node_verify (child, GLADE_XML_TAG_WIDGET))
|
||||
return NULL;
|
||||
widget = glade_widget_new_from_node (child, project);
|
||||
if (widget == NULL)
|
||||
return NULL;
|
||||
}
|
||||
project->widgets = g_list_reverse (project->widgets);
|
||||
|
||||
return project;
|
||||
}
|
||||
|
||||
GladeProject *
|
||||
glade_project_open_from_file (const gchar *path)
|
||||
{
|
||||
GladeXmlContext *context;
|
||||
GladeXmlDoc *doc;
|
||||
GladeProject *project;
|
||||
|
||||
context = glade_xml_context_new_from_path (path, NULL, GLADE_XML_TAG_PROJECT);
|
||||
if (context == NULL)
|
||||
return NULL;
|
||||
doc = glade_xml_context_get_doc (context);
|
||||
project = glade_project_new_from_node (glade_xml_doc_get_root (doc));
|
||||
glade_xml_context_free (context);
|
||||
|
||||
if (project)
|
||||
project->path = g_strdup_printf ("%s", path);
|
||||
|
||||
return project;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* glade_project_save:
|
||||
* @project:
|
||||
@ -490,13 +541,50 @@ glade_project_save (GladeProject *project)
|
||||
g_return_val_if_fail (GLADE_IS_PROJECT (project), FALSE);
|
||||
|
||||
if (project->path == NULL)
|
||||
project->path = glade_project_ui_save_get_name (project);
|
||||
project->path = glade_project_ui_get_path (_("Save ..."));
|
||||
|
||||
if (!glade_project_save_to_file (project, project->path)) {
|
||||
glade_project_ui_warn (project, _("Invalid file name"));
|
||||
glade_project_ui_warn (_("Invalid file name"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* glade_project_open:
|
||||
* @:
|
||||
*
|
||||
* Open a project. Launches a file selector
|
||||
*
|
||||
* Return Value: TRUE on success false on error.
|
||||
**/
|
||||
gboolean
|
||||
glade_project_open (void)
|
||||
{
|
||||
GladeProjectWindow *gpw;
|
||||
GladeProject *project;
|
||||
gchar *path;
|
||||
|
||||
path = glade_project_ui_get_path (_("Open ..."));
|
||||
|
||||
if (!path)
|
||||
return FALSE;
|
||||
|
||||
project = glade_project_open_from_file (path);
|
||||
|
||||
if (!project) {
|
||||
glade_project_ui_warn (_("Could not open project."));
|
||||
g_free (path);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gpw = glade_project_window_get ();
|
||||
glade_project_window_add_project (gpw, project);
|
||||
g_free (path);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
@ -54,11 +54,14 @@ struct _GladeProjectClass
|
||||
guint glade_project_get_type (void);
|
||||
|
||||
GladeProject * glade_project_get_active (void);
|
||||
GladeProject * glade_project_new (void);
|
||||
GladeProject * glade_project_new (gboolean untitled);
|
||||
|
||||
|
||||
/* Project operations */
|
||||
gboolean glade_project_save (GladeProject *project);
|
||||
gboolean glade_project_open ();
|
||||
GladeProject * glade_project_open_from_file (const gchar *path);
|
||||
|
||||
|
||||
/* Widget related stuff */
|
||||
void glade_project_remove_widget (GladeWidget *widget);
|
||||
@ -71,10 +74,11 @@ void glade_project_widget_name_changed (GladeProject *project,
|
||||
GladeWidget *widget);
|
||||
|
||||
/* Selection */
|
||||
void glade_project_selection_set (GladeWidget *widget, gboolean emit_signal);
|
||||
void glade_project_selection_add (GladeWidget *widget, gboolean emit_signal);
|
||||
void glade_project_selection_remove (GladeWidget *widget, gboolean emit_signal);
|
||||
void glade_project_selection_clear (GladeProject *project, gboolean emit_signal);
|
||||
void glade_project_selection_set (GladeWidget *widget, gboolean emit_signal);
|
||||
void glade_project_selection_add (GladeWidget *widget, gboolean emit_signal);
|
||||
void glade_project_selection_remove (GladeWidget *widget, gboolean emit_signal);
|
||||
void glade_project_selection_clear (GladeProject *project, gboolean emit_signal);
|
||||
void glade_project_selection_changed (GladeProject *project);
|
||||
|
||||
GList * glade_project_selection_get (GladeProject *project);
|
||||
|
||||
|
@ -32,13 +32,14 @@
|
||||
#include "glade-gtk.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <gmodule.h>
|
||||
|
||||
GladePropertyType
|
||||
glade_property_type_str_to_enum (const gchar *str)
|
||||
{
|
||||
if (strcmp (str, GLADE_TAG_TEXT) == 0)
|
||||
return GLADE_PROPERTY_TYPE_TEXT;
|
||||
if (strcmp (str, GLADE_TAG_STRING) == 0)
|
||||
return GLADE_PROPERTY_TYPE_STRING;
|
||||
if (strcmp (str, GLADE_TAG_BOOLEAN) == 0)
|
||||
return GLADE_PROPERTY_TYPE_BOOLEAN;
|
||||
if (strcmp (str, GLADE_TAG_FLOAT) == 0)
|
||||
@ -46,7 +47,7 @@ glade_property_type_str_to_enum (const gchar *str)
|
||||
if (strcmp (str, GLADE_TAG_INTEGER) == 0)
|
||||
return GLADE_PROPERTY_TYPE_INTEGER;
|
||||
if (strcmp (str, GLADE_TAG_CHOICE) == 0)
|
||||
return GLADE_PROPERTY_TYPE_CHOICE;
|
||||
return GLADE_PROPERTY_TYPE_ENUM;
|
||||
if (strcmp (str, GLADE_TAG_OTHER_WIDGETS) == 0)
|
||||
return GLADE_PROPERTY_TYPE_OTHER_WIDGETS;
|
||||
if (strcmp (str, GLADE_TAG_OBJECT) == 0)
|
||||
@ -61,8 +62,8 @@ gchar *
|
||||
glade_property_type_enum_to_string (GladePropertyType type)
|
||||
{
|
||||
switch (type) {
|
||||
case GLADE_PROPERTY_TYPE_TEXT:
|
||||
return GLADE_TAG_TEXT;
|
||||
case GLADE_PROPERTY_TYPE_STRING:
|
||||
return GLADE_TAG_STRING;
|
||||
case GLADE_PROPERTY_TYPE_BOOLEAN:
|
||||
return GLADE_TAG_BOOLEAN;
|
||||
case GLADE_PROPERTY_TYPE_FLOAT:
|
||||
@ -71,8 +72,8 @@ glade_property_type_enum_to_string (GladePropertyType type)
|
||||
return GLADE_TAG_INTEGER;
|
||||
case GLADE_PROPERTY_TYPE_DOUBLE:
|
||||
return GLADE_TAG_DOUBLE;
|
||||
case GLADE_PROPERTY_TYPE_CHOICE:
|
||||
return GLADE_TAG_CHOICE;
|
||||
case GLADE_PROPERTY_TYPE_ENUM:
|
||||
return GLADE_TAG_ENUM;
|
||||
case GLADE_PROPERTY_TYPE_OTHER_WIDGETS:
|
||||
return GLADE_TAG_OTHER_WIDGETS;
|
||||
case GLADE_PROPERTY_TYPE_OBJECT:
|
||||
@ -132,6 +133,8 @@ glade_property_class_new (void)
|
||||
property_class->optional = FALSE;
|
||||
property_class->common = FALSE;
|
||||
property_class->packing = FALSE;
|
||||
property_class->get_default = FALSE;
|
||||
property_class->apply_first_time = FALSE;
|
||||
property_class->query = NULL;
|
||||
property_class->set_function = NULL;
|
||||
|
||||
@ -139,7 +142,6 @@ glade_property_class_new (void)
|
||||
}
|
||||
|
||||
#define MY_FREE(foo) if(foo) g_free(foo); foo = NULL
|
||||
|
||||
static void
|
||||
glade_widget_property_class_free (GladePropertyClass *class)
|
||||
{
|
||||
@ -164,9 +166,9 @@ glade_property_class_get_type_from_spec (GParamSpec *spec)
|
||||
case G_TYPE_PARAM_BOOLEAN:
|
||||
return GLADE_PROPERTY_TYPE_BOOLEAN;
|
||||
case G_TYPE_PARAM_STRING:
|
||||
return GLADE_PROPERTY_TYPE_TEXT;
|
||||
return GLADE_PROPERTY_TYPE_STRING;
|
||||
case G_TYPE_PARAM_ENUM:
|
||||
return GLADE_PROPERTY_TYPE_CHOICE;
|
||||
return GLADE_PROPERTY_TYPE_ENUM;
|
||||
case G_TYPE_PARAM_DOUBLE:
|
||||
return GLADE_PROPERTY_TYPE_DOUBLE;
|
||||
case G_TYPE_PARAM_LONG:
|
||||
@ -222,53 +224,10 @@ glade_property_class_get_choices_from_spec (GParamSpec *spec)
|
||||
return list;
|
||||
}
|
||||
|
||||
static gchar *
|
||||
glade_property_get_default_boolean (GParamSpec *spec,
|
||||
GladePropertyClass *class)
|
||||
{
|
||||
gint def;
|
||||
|
||||
g_return_val_if_fail (G_IS_PARAM_SPEC_BOOLEAN (spec), NULL);
|
||||
|
||||
def = (gint) G_PARAM_SPEC_BOOLEAN (spec)->default_value;
|
||||
|
||||
return def ? g_strdup (GLADE_TAG_TRUE) : g_strdup (GLADE_TAG_FALSE);
|
||||
}
|
||||
|
||||
static gchar *
|
||||
glade_property_get_parameter_numeric_default (GParamSpec *spec)
|
||||
{
|
||||
gchar *value = NULL;
|
||||
|
||||
if (G_IS_PARAM_SPEC_INT (spec))
|
||||
value = g_strdup_printf ("%d", G_PARAM_SPEC_INT (spec)->default_value);
|
||||
else if (G_IS_PARAM_SPEC_UINT (spec))
|
||||
value = g_strdup_printf ("%u", G_PARAM_SPEC_UINT (spec)->default_value);
|
||||
else if (G_IS_PARAM_SPEC_FLOAT (spec))
|
||||
value = g_strdup_printf ("%g", G_PARAM_SPEC_FLOAT (spec)->default_value);
|
||||
else if (G_IS_PARAM_SPEC_DOUBLE (spec))
|
||||
value = g_strdup_printf ("%g", G_PARAM_SPEC_DOUBLE (spec)->default_value);
|
||||
else
|
||||
g_warning ("glade_propery_get_parameter_numeric_item invalid ParamSpec (default)\n");
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
static gchar *
|
||||
glade_property_get_default_text (GParamSpec *spec,
|
||||
GladePropertyClass *class)
|
||||
{
|
||||
g_return_val_if_fail (G_IS_PARAM_SPEC_STRING (spec), NULL);
|
||||
|
||||
if (G_PARAM_SPEC_STRING (spec)->default_value != NULL)
|
||||
return g_strdup (G_PARAM_SPEC_STRING (spec)->default_value);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static gchar *
|
||||
glade_property_get_default_choice (GParamSpec *spec,
|
||||
GladePropertyClass *class)
|
||||
GladePropertyClass *class)
|
||||
{
|
||||
GladeChoice *choice = NULL;
|
||||
GList *list;
|
||||
@ -293,41 +252,120 @@ glade_property_get_default_choice (GParamSpec *spec,
|
||||
|
||||
return g_strdup (choice->symbol);
|
||||
}
|
||||
#endif
|
||||
|
||||
static gchar *
|
||||
glade_property_get_default_numeric (GParamSpec *spec,
|
||||
GladePropertyClass *class)
|
||||
gchar *
|
||||
glade_property_class_make_string_from_gvalue (GladePropertyType type,
|
||||
const GValue *value)
|
||||
{
|
||||
g_return_val_if_fail (G_IS_PARAM_SPEC_INT (spec) |
|
||||
G_IS_PARAM_SPEC_UINT (spec) |
|
||||
G_IS_PARAM_SPEC_FLOAT (spec) |
|
||||
G_IS_PARAM_SPEC_DOUBLE (spec), NULL);
|
||||
gchar *string = NULL;
|
||||
|
||||
return glade_property_get_parameter_numeric_default (spec);
|
||||
switch (type) {
|
||||
case GLADE_PROPERTY_TYPE_INTEGER:
|
||||
string = g_strdup_printf ("%d", g_value_get_int (value));
|
||||
break;
|
||||
case GLADE_PROPERTY_TYPE_FLOAT:
|
||||
string = g_strdup_printf ("%f", g_value_get_float (value));
|
||||
break;
|
||||
case GLADE_PROPERTY_TYPE_DOUBLE:
|
||||
string = g_strdup_printf ("%g", g_value_get_double (value));
|
||||
break;
|
||||
case GLADE_PROPERTY_TYPE_BOOLEAN:
|
||||
string = g_strdup_printf ("%s", g_value_get_boolean (value) ?
|
||||
GLADE_TAG_TRUE : GLADE_TAG_FALSE);
|
||||
break;
|
||||
case GLADE_PROPERTY_TYPE_STRING:
|
||||
string = g_strdup (g_value_get_string (value));
|
||||
break;
|
||||
default:
|
||||
g_warning ("Could not make string from gvalue for type %s\n",
|
||||
glade_property_type_enum_to_string (type));
|
||||
}
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
GValue *
|
||||
glade_property_class_make_gvalue_from_string (GladePropertyType type,
|
||||
const gchar *string)
|
||||
{
|
||||
GValue *value = g_new0 (GValue, 1);
|
||||
|
||||
switch (type) {
|
||||
case GLADE_PROPERTY_TYPE_INTEGER:
|
||||
g_value_init (value, G_TYPE_INT);
|
||||
g_value_set_int (value, atoi (string));
|
||||
break;
|
||||
case GLADE_PROPERTY_TYPE_FLOAT:
|
||||
g_value_init (value, G_TYPE_FLOAT);
|
||||
g_value_set_float (value, atof (string));
|
||||
break;
|
||||
case GLADE_PROPERTY_TYPE_BOOLEAN:
|
||||
g_value_init (value, G_TYPE_BOOLEAN);
|
||||
if (strcmp (string, GLADE_TAG_TRUE) == 0)
|
||||
g_value_set_boolean (value, TRUE);
|
||||
else
|
||||
g_value_set_boolean (value, FALSE);
|
||||
break;
|
||||
case GLADE_PROPERTY_TYPE_DOUBLE:
|
||||
g_value_init (value, G_TYPE_DOUBLE);
|
||||
g_value_set_double (value, atof (string));
|
||||
break;
|
||||
case GLADE_PROPERTY_TYPE_STRING:
|
||||
g_value_init (value, G_TYPE_STRING);
|
||||
g_value_set_string (value, string);
|
||||
break;
|
||||
default:
|
||||
g_warning ("Could not make gvalue from string %s and type %s\n",
|
||||
string,
|
||||
glade_property_type_enum_to_string (type));
|
||||
g_free (value);
|
||||
value = NULL;
|
||||
}
|
||||
|
||||
static gchar *
|
||||
return value;
|
||||
}
|
||||
|
||||
static GValue *
|
||||
glade_property_class_get_default_from_spec (GParamSpec *spec,
|
||||
GladePropertyClass *class,
|
||||
GladeXmlNode *node)
|
||||
{
|
||||
gchar *def = NULL;
|
||||
GValue *value;
|
||||
|
||||
value = g_new0 (GValue, 1);
|
||||
|
||||
switch (class->type) {
|
||||
case GLADE_PROPERTY_TYPE_CHOICE:
|
||||
def = glade_property_get_default_choice (spec, class);
|
||||
case GLADE_PROPERTY_TYPE_ENUM:
|
||||
#if 0
|
||||
g_value_init (value, G_TYPE_ENUM);
|
||||
if (!G_VALUE_HOLDS_ENUM (value))
|
||||
g_print ("Error\n");
|
||||
g_value_set_enum (value, G_PARAM_SPEC_ENUM (spec)->default_value);
|
||||
#endif
|
||||
break;
|
||||
case GLADE_PROPERTY_TYPE_TEXT:
|
||||
def = glade_property_get_default_text (spec, class);
|
||||
case GLADE_PROPERTY_TYPE_STRING:
|
||||
g_value_init (value, G_TYPE_STRING);
|
||||
g_value_set_string (value, G_PARAM_SPEC_STRING (spec)->default_value);
|
||||
break;
|
||||
case GLADE_PROPERTY_TYPE_INTEGER:
|
||||
g_value_init (value, G_TYPE_INT);
|
||||
if (G_IS_PARAM_SPEC_INT (spec))
|
||||
g_value_set_int (value, G_PARAM_SPEC_INT (spec)->default_value);
|
||||
else
|
||||
g_value_set_int (value, G_PARAM_SPEC_UINT (spec)->default_value);
|
||||
break;
|
||||
case GLADE_PROPERTY_TYPE_FLOAT:
|
||||
g_value_init (value, G_TYPE_FLOAT);
|
||||
g_value_set_float (value, G_PARAM_SPEC_FLOAT (spec)->default_value);
|
||||
break;
|
||||
case GLADE_PROPERTY_TYPE_DOUBLE:
|
||||
def = glade_property_get_default_numeric (spec, class);
|
||||
g_value_init (value, G_TYPE_DOUBLE);
|
||||
g_value_set_double (value, G_PARAM_SPEC_DOUBLE (spec)->default_value);
|
||||
break;
|
||||
case GLADE_PROPERTY_TYPE_BOOLEAN:
|
||||
def = glade_property_get_default_boolean (spec, class);
|
||||
g_value_init (value, G_TYPE_BOOLEAN);
|
||||
g_value_set_boolean (value, G_PARAM_SPEC_BOOLEAN (spec)->default_value);
|
||||
break;
|
||||
case GLADE_PROPERTY_TYPE_OTHER_WIDGETS:
|
||||
break;
|
||||
@ -337,7 +375,7 @@ glade_property_class_get_default_from_spec (GParamSpec *spec,
|
||||
break;
|
||||
}
|
||||
|
||||
return def;
|
||||
return value;
|
||||
}
|
||||
|
||||
static gchar *
|
||||
@ -417,9 +455,9 @@ glade_property_class_get_parameters_from_spec (GParamSpec *spec,
|
||||
GladeXmlNode *child;
|
||||
|
||||
switch (class->type) {
|
||||
case GLADE_PROPERTY_TYPE_CHOICE:
|
||||
case GLADE_PROPERTY_TYPE_ENUM:
|
||||
break;
|
||||
case GLADE_PROPERTY_TYPE_TEXT:
|
||||
case GLADE_PROPERTY_TYPE_STRING:
|
||||
break;
|
||||
case GLADE_PROPERTY_TYPE_INTEGER:
|
||||
case GLADE_PROPERTY_TYPE_FLOAT:
|
||||
@ -448,6 +486,25 @@ glade_property_class_get_parameters_from_spec (GParamSpec *spec,
|
||||
return parameters;
|
||||
}
|
||||
|
||||
static GValue *
|
||||
glade_property_class_get_default (GladeXmlNode *node, GladePropertyType type)
|
||||
{
|
||||
GValue *value;
|
||||
gchar *temp;
|
||||
|
||||
value = g_new0 (GValue, 1);
|
||||
temp = glade_xml_get_property_string (node, GLADE_TAG_DEFAULT);
|
||||
|
||||
if (!temp)
|
||||
return NULL;
|
||||
|
||||
value = glade_property_class_make_gvalue_from_string (type, temp);
|
||||
|
||||
g_free (temp);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* glade_property_class_load_from_param_spec:
|
||||
@ -467,6 +524,7 @@ glade_property_class_load_from_param_spec (const gchar *name,
|
||||
GladeXmlNode *node)
|
||||
{
|
||||
GParamSpec *spec;
|
||||
gchar *def;
|
||||
|
||||
spec = glade_widget_class_find_spec (widget_class, name);
|
||||
|
||||
@ -487,14 +545,19 @@ glade_property_class_load_from_param_spec (const gchar *name,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (class->type == GLADE_PROPERTY_TYPE_CHOICE)
|
||||
if (class->type == GLADE_PROPERTY_TYPE_ENUM)
|
||||
class->choices = glade_property_class_get_choices_from_spec (spec);
|
||||
|
||||
/* We want to use the parm spec default only when the xml files do not provide a
|
||||
* default value
|
||||
*/
|
||||
if (class->def == NULL)
|
||||
class->def = glade_property_class_get_default_from_spec (spec, class, node);
|
||||
def = glade_xml_get_property_string (node, GLADE_TAG_DEFAULT);
|
||||
if (def) {
|
||||
class->def = glade_property_class_get_default (node, class->type);
|
||||
g_free (def);
|
||||
} else {
|
||||
class->def = glade_property_class_get_default_from_spec (spec, class, node);
|
||||
}
|
||||
class->parameters = glade_property_class_get_parameters_from_spec (spec, class, node);
|
||||
|
||||
return TRUE;
|
||||
@ -559,7 +622,6 @@ glade_xml_read_list (GladeXmlNode *node, const gchar *list_tag, const gchar *ite
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
static GladePropertyClass *
|
||||
glade_property_class_new_from_node (GladeXmlNode *node, GladeWidgetClass *widget_class)
|
||||
{
|
||||
@ -587,14 +649,37 @@ glade_property_class_new_from_node (GladeXmlNode *node, GladeWidgetClass *widget
|
||||
|
||||
|
||||
/* Will this property go in the common tab ? */
|
||||
property_class->common = glade_xml_property_get_boolean (node, GLADE_TAG_COMMON, FALSE);
|
||||
property_class->def = glade_xml_get_property_string (node, GLADE_TAG_DEFAULT);
|
||||
property_class->common = glade_xml_property_get_boolean (node, GLADE_TAG_COMMON, FALSE);
|
||||
property_class->optional = glade_xml_property_get_boolean (node, GLADE_TAG_OPTIONAL, FALSE);
|
||||
if (property_class->optional) {
|
||||
property_class->optional_default = glade_xml_property_get_boolean (node, GLADE_TAG_OPTIONAL_DEFAULT, FALSE);
|
||||
property_class->apply_first_time = glade_xml_property_get_boolean (node, GLADE_TAG_APPLY_FIRST_TIME, FALSE);
|
||||
}
|
||||
|
||||
/* 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);
|
||||
|
||||
/* If this property can't be set with g_object_set, get the workarround
|
||||
* function
|
||||
*/
|
||||
child = glade_xml_search_child (node, GLADE_TAG_SET_FUNCTION);
|
||||
if (child != NULL) {
|
||||
gchar * content = glade_xml_get_content (child);
|
||||
glade_property_class_get_set_function (property_class, content);
|
||||
g_free (content);
|
||||
}
|
||||
/* If this property can't be get 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);
|
||||
}
|
||||
|
||||
|
||||
/* Should we load this property from the ParamSpec ?
|
||||
* We can have a property like ... ParamSpec="TRUE">
|
||||
@ -639,8 +724,8 @@ glade_property_class_new_from_node (GladeXmlNode *node, GladeWidgetClass *widget
|
||||
glade_parameter_get_boolean (property_class->parameters, "Optional", &property_class->optional);
|
||||
|
||||
/* Get the choices */
|
||||
if (property_class->type == GLADE_PROPERTY_TYPE_CHOICE) {
|
||||
child = glade_xml_search_child_required (node, GLADE_TAG_CHOICES);
|
||||
if (property_class->type == GLADE_PROPERTY_TYPE_ENUM) {
|
||||
child = glade_xml_search_child_required (node, GLADE_TAG_ENUM);
|
||||
if (child == NULL)
|
||||
return NULL;
|
||||
property_class->choices = glade_choice_list_new_from_node (child);
|
||||
@ -654,25 +739,10 @@ glade_property_class_new_from_node (GladeXmlNode *node, GladeWidgetClass *widget
|
||||
property_class->child = glade_widget_class_new_from_node (child);
|
||||
}
|
||||
|
||||
/* If this property can't be set with g_object_set, get the workarround
|
||||
* function
|
||||
*/
|
||||
child = glade_xml_search_child (node, GLADE_TAG_SET_FUNCTION);
|
||||
if (child != NULL) {
|
||||
gchar * content = glade_xml_get_content (child);
|
||||
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);
|
||||
}
|
||||
/* Get the default value */
|
||||
property_class->def = glade_property_class_get_default (node, property_class->type);
|
||||
|
||||
|
||||
return property_class;
|
||||
}
|
||||
|
||||
|
@ -11,8 +11,8 @@ typedef enum {
|
||||
GLADE_PROPERTY_TYPE_FLOAT,
|
||||
GLADE_PROPERTY_TYPE_INTEGER,
|
||||
GLADE_PROPERTY_TYPE_DOUBLE,
|
||||
GLADE_PROPERTY_TYPE_TEXT,
|
||||
GLADE_PROPERTY_TYPE_CHOICE,
|
||||
GLADE_PROPERTY_TYPE_STRING,
|
||||
GLADE_PROPERTY_TYPE_ENUM,
|
||||
GLADE_PROPERTY_TYPE_OTHER_WIDGETS,
|
||||
GLADE_PROPERTY_TYPE_OBJECT,
|
||||
GLADE_PROPERTY_TYPE_ERROR
|
||||
@ -113,7 +113,8 @@ struct _GladePropertyClass {
|
||||
gchar *tooltip; /* The tooltip. Currently unimplemented. Not sure if
|
||||
* it should go here
|
||||
*/
|
||||
gchar *def; /* The default value for this property */
|
||||
|
||||
GValue *def; /* The default value for this property */
|
||||
|
||||
GList *parameters; /* list of GladeParameter objects. This list
|
||||
* provides with an extra set of key-value
|
||||
@ -134,6 +135,7 @@ struct _GladePropertyClass {
|
||||
* default property has a check box in the
|
||||
* left that enables/disables de input
|
||||
*/
|
||||
gboolean optional_default; /* For optional values, what the default is */
|
||||
|
||||
GladePropertyQuery *query; /* Some widgets require us to query the user
|
||||
* before creating the widget. Like a vbox will
|
||||
@ -159,15 +161,23 @@ struct _GladePropertyClass {
|
||||
|
||||
gboolean common; /* Common properties go in the common tab */
|
||||
gboolean packing; /* Packing properties go in the packing tab */
|
||||
gboolean apply_first_time; /* Temp hack */
|
||||
gboolean get_default; /* If true, when the default property is applied it is queried
|
||||
* from the GtkWidget rather than setting it to some value. We need
|
||||
* this for example for the packing position in a gtkbox, we container
|
||||
* add the widget, then we query the property to get the position it
|
||||
* was added into.
|
||||
*/
|
||||
|
||||
void (*set_function) (GObject *object,
|
||||
const gchar *value);
|
||||
const GValue *value);
|
||||
/* If this property can't be set with g_object_set 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
|
||||
*/
|
||||
gchar * (*get_function) (GObject *object);
|
||||
void (*get_function) (GObject *object,
|
||||
GValue *value);
|
||||
/* 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
|
||||
@ -185,6 +195,10 @@ GParamSpec * glade_property_class_find_spec (GladeWidgetClass *class, const gcha
|
||||
|
||||
gchar * glade_property_type_enum_to_string (GladePropertyType type);
|
||||
|
||||
GValue * glade_property_class_make_gvalue_from_string (GladePropertyType type, const gchar *string);
|
||||
gchar * glade_property_class_make_string_from_gvalue (GladePropertyType type,
|
||||
const GValue *value);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GLADE_PROPERTY_CLASS_H__ */
|
||||
|
@ -99,7 +99,7 @@ glade_property_init (GladeProperty *property)
|
||||
{
|
||||
|
||||
property->class = NULL;
|
||||
property->value = NULL;
|
||||
property->value = g_new0 (GValue, 1);
|
||||
property->enabled = TRUE;
|
||||
property->child = NULL;
|
||||
}
|
||||
@ -130,80 +130,28 @@ GladeProperty *
|
||||
glade_property_new_from_class (GladePropertyClass *class, GladeWidget *widget)
|
||||
{
|
||||
GladeProperty *property;
|
||||
gchar *value = NULL;
|
||||
gfloat float_val;
|
||||
gint int_val;
|
||||
gchar *string = class->def;
|
||||
|
||||
/* move somewhere else */
|
||||
GladeChoice *choice;
|
||||
GList *list;
|
||||
|
||||
|
||||
property = glade_property_new ();
|
||||
|
||||
property->class = class;
|
||||
|
||||
/* For some properties, we don't know its value utill we add the widget and
|
||||
* pack it in a container. For example for a "pos" packing property we need
|
||||
* to pack the property first, the query the property to know the value
|
||||
*/
|
||||
if (string && strcmp (string, GLADE_GET_DEFAULT_FROM_WIDGET) == 0) {
|
||||
property->value = g_strdup (string);
|
||||
if (!class->def) {
|
||||
property->value = glade_property_class_make_gvalue_from_string (class->type, "");
|
||||
return property;
|
||||
}
|
||||
|
||||
|
||||
switch (class->type) {
|
||||
case GLADE_PROPERTY_TYPE_BOOLEAN:
|
||||
if (string == NULL)
|
||||
value = g_strdup (GLADE_TAG_FALSE);
|
||||
else if (strcmp (string, GLADE_TAG_TRUE) == 0)
|
||||
value = g_strdup (GLADE_TAG_TRUE);
|
||||
else if (strcmp (string, GLADE_TAG_FALSE) == 0)
|
||||
value = g_strdup (GLADE_TAG_FALSE);
|
||||
else {
|
||||
g_warning ("Invalid default tag for boolean %s (%s/%s)",
|
||||
string, GLADE_TAG_TRUE, GLADE_TAG_FALSE);
|
||||
value = g_strdup (GLADE_TAG_FALSE);
|
||||
}
|
||||
break;
|
||||
case GLADE_PROPERTY_TYPE_FLOAT:
|
||||
if (string)
|
||||
float_val = atof (string);
|
||||
else
|
||||
float_val = 0;
|
||||
value = g_strdup_printf ("%g", float_val);
|
||||
glade_parameter_get_boolean (class->parameters,
|
||||
"OptionalDefault",
|
||||
&property->enabled);
|
||||
break;
|
||||
case GLADE_PROPERTY_TYPE_DOUBLE:
|
||||
if (string)
|
||||
float_val = atof (string);
|
||||
else
|
||||
float_val = 0;
|
||||
value = g_strdup_printf ("%g", float_val);
|
||||
glade_parameter_get_boolean (class->parameters,
|
||||
"OptionalDefault",
|
||||
&property->enabled);
|
||||
break;
|
||||
case GLADE_PROPERTY_TYPE_INTEGER:
|
||||
if (string)
|
||||
int_val = atoi (string);
|
||||
else
|
||||
int_val = 0;
|
||||
value = g_strdup_printf ("%i", int_val);
|
||||
glade_parameter_get_boolean (class->parameters,
|
||||
"OptionalDefault",
|
||||
&property->enabled);
|
||||
case GLADE_PROPERTY_TYPE_FLOAT:
|
||||
property->enabled = class->optional_default;
|
||||
/* Fall thru */
|
||||
case GLADE_PROPERTY_TYPE_BOOLEAN:
|
||||
case GLADE_PROPERTY_TYPE_STRING:
|
||||
g_value_init (property->value, class->def->g_type);
|
||||
g_value_copy (class->def, property->value);
|
||||
break;
|
||||
case GLADE_PROPERTY_TYPE_TEXT:
|
||||
if (string)
|
||||
value = g_strdup (string);
|
||||
else
|
||||
value = g_strdup ("");
|
||||
break;
|
||||
case GLADE_PROPERTY_TYPE_CHOICE:
|
||||
case GLADE_PROPERTY_TYPE_ENUM:
|
||||
#if 0
|
||||
list = class->choices;
|
||||
if (string != NULL) {
|
||||
for (;list != NULL; list = list->next) {
|
||||
@ -227,22 +175,25 @@ glade_property_new_from_class (GladePropertyClass *class, GladeWidget *widget)
|
||||
choice->name, class->id,
|
||||
choice->symbol, string);
|
||||
value = g_strdup (choice->symbol);
|
||||
#endif
|
||||
break;
|
||||
case GLADE_PROPERTY_TYPE_OTHER_WIDGETS:
|
||||
#if 0
|
||||
value = g_strdup ("");
|
||||
#endif
|
||||
break;
|
||||
case GLADE_PROPERTY_TYPE_OBJECT:
|
||||
#if 0
|
||||
value = NULL;
|
||||
property->child = glade_widget_new_from_class (class->child,
|
||||
widget);
|
||||
#endif
|
||||
break;
|
||||
case GLADE_PROPERTY_TYPE_ERROR:
|
||||
g_warning ("Invalid Glade property type (%d)\n", class->type);
|
||||
break;
|
||||
}
|
||||
|
||||
property->value = value;
|
||||
|
||||
return property;
|
||||
}
|
||||
|
||||
@ -303,17 +254,6 @@ glade_property_get_from_id (GList *settings_list, const gchar *id)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static void
|
||||
glade_property_emit_changed (GladeProperty *property)
|
||||
{
|
||||
@ -322,107 +262,96 @@ glade_property_emit_changed (GladeProperty *property)
|
||||
}
|
||||
|
||||
void
|
||||
glade_property_changed_text (GladeProperty *property,
|
||||
const gchar *text)
|
||||
glade_property_set_string (GladeProperty *property,
|
||||
const gchar *text)
|
||||
{
|
||||
gchar *temp;
|
||||
|
||||
g_return_if_fail (property != NULL);
|
||||
g_return_if_fail (property->value != NULL);
|
||||
g_return_if_fail (property->widget != NULL);
|
||||
g_return_if_fail (property->widget->widget != NULL);
|
||||
|
||||
temp = property->value;
|
||||
property->value = g_strdup (text);
|
||||
g_free (temp);
|
||||
if (strcmp (text, g_value_get_string) != 0)
|
||||
g_value_set_string (property->value, text);
|
||||
|
||||
#if 0
|
||||
/* Why is this here ????? Chema */
|
||||
if (property->class->id == NULL)
|
||||
return;
|
||||
#endif
|
||||
|
||||
property->loading = TRUE;
|
||||
if (property->class->set_function == NULL)
|
||||
gtk_object_set (GTK_OBJECT (property->widget->widget),
|
||||
property->class->id,
|
||||
property->value, NULL);
|
||||
else
|
||||
(*property->class->set_function) (G_OBJECT (property->widget->widget),
|
||||
property->value);
|
||||
property->loading = FALSE;
|
||||
if (property->enabled) {
|
||||
property->loading = TRUE;
|
||||
if (property->class->set_function == NULL)
|
||||
g_object_set (G_OBJECT (property->widget->widget),
|
||||
property->class->id,
|
||||
g_value_get_string (property->value), NULL);
|
||||
else
|
||||
(*property->class->set_function) (G_OBJECT (property->widget->widget),
|
||||
property->value);
|
||||
property->loading = FALSE;
|
||||
}
|
||||
|
||||
glade_property_emit_changed (property);
|
||||
}
|
||||
|
||||
void
|
||||
glade_property_changed_integer (GladeProperty *property, gint val)
|
||||
glade_property_set_integer (GladeProperty *property, gint val)
|
||||
{
|
||||
g_return_if_fail (property != NULL);
|
||||
g_return_if_fail (property->value != NULL);
|
||||
|
||||
g_free (property->value);
|
||||
property->value = g_strdup_printf ("%i", val);
|
||||
g_value_set_int (property->value, val);
|
||||
|
||||
property->loading = TRUE;
|
||||
if (property->class->set_function == NULL)
|
||||
gtk_object_set (GTK_OBJECT (property->widget->widget),
|
||||
property->class->id, val, NULL);
|
||||
else
|
||||
(*property->class->set_function) (G_OBJECT (property->widget->widget),
|
||||
property->value);
|
||||
property->loading = FALSE;
|
||||
if (property->enabled) {
|
||||
property->loading = TRUE;
|
||||
if (property->class->set_function == NULL)
|
||||
gtk_object_set (GTK_OBJECT (property->widget->widget),
|
||||
property->class->id, val, NULL);
|
||||
else
|
||||
(*property->class->set_function) (G_OBJECT (property->widget->widget),
|
||||
property->value);
|
||||
property->loading = FALSE;
|
||||
}
|
||||
|
||||
glade_property_emit_changed (property);
|
||||
}
|
||||
|
||||
void
|
||||
glade_property_changed_float (GladeProperty *property, gfloat val)
|
||||
glade_property_set_float (GladeProperty *property, gfloat val)
|
||||
{
|
||||
g_return_if_fail (property != NULL);
|
||||
g_return_if_fail (property->value != NULL);
|
||||
|
||||
g_free (property->value);
|
||||
property->value = g_strdup_printf ("%g", val);
|
||||
|
||||
property->loading = TRUE;
|
||||
if (property->class->set_function == NULL)
|
||||
gtk_object_set (GTK_OBJECT (property->widget->widget),
|
||||
property->class->id, val, NULL);
|
||||
else
|
||||
(*property->class->set_function) (G_OBJECT (property->widget->widget),
|
||||
property->value);
|
||||
property->loading = FALSE;
|
||||
|
||||
g_value_set_float (property->value, val);
|
||||
|
||||
if (property->enabled) {
|
||||
property->loading = TRUE;
|
||||
if (property->class->set_function == NULL)
|
||||
gtk_object_set (GTK_OBJECT (property->widget->widget),
|
||||
property->class->id, val, NULL);
|
||||
else
|
||||
(*property->class->set_function) (G_OBJECT (property->widget->widget),
|
||||
property->value);
|
||||
property->loading = FALSE;
|
||||
}
|
||||
|
||||
glade_property_emit_changed (property);
|
||||
}
|
||||
|
||||
void
|
||||
glade_property_changed_double (GladeProperty *property, gdouble val)
|
||||
glade_property_set_double (GladeProperty *property, gdouble val)
|
||||
{
|
||||
#if 0
|
||||
GValue *gvalue = g_new0 (GValue, 1);
|
||||
#endif
|
||||
|
||||
g_return_if_fail (property != NULL);
|
||||
g_return_if_fail (property->value != NULL);
|
||||
|
||||
g_free (property->value);
|
||||
property->value = g_strdup_printf ("%g", val);
|
||||
g_value_set_double (property->value, val);
|
||||
|
||||
#if 0
|
||||
gvalue = g_value_init (gvalue, G_TYPE_DOUBLE);
|
||||
g_value_set_double (gvalue, val);
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
g_debug ("Changed double to %g \"%s\" -->%s<-- but using gvalue @%d\n",
|
||||
val,
|
||||
property->value,
|
||||
property->class->gtk_arg,
|
||||
GPOINTER_TO_INT (gvalue));
|
||||
#endif
|
||||
|
||||
g_object_set (G_OBJECT (property->widget->widget),
|
||||
property->class->id, val, NULL);
|
||||
if (property->enabled) {
|
||||
property->loading = TRUE;
|
||||
if (property->class->set_function == NULL)
|
||||
gtk_object_set (GTK_OBJECT (property->widget->widget),
|
||||
property->class->id, val, NULL);
|
||||
else
|
||||
(*property->class->set_function) (G_OBJECT (property->widget->widget),
|
||||
property->value);
|
||||
property->loading = FALSE;
|
||||
}
|
||||
|
||||
glade_property_emit_changed (property);
|
||||
#ifdef DEBUG
|
||||
if (GTK_IS_SPIN_BUTTON (property->widget->widget)) {
|
||||
g_debug ("It is spin button\n");
|
||||
@ -434,66 +363,75 @@ glade_property_changed_double (GladeProperty *property, gdouble val)
|
||||
333.22);
|
||||
}
|
||||
#endif
|
||||
#if 0
|
||||
g_object_set (G_OBJECT (property->widget->widget),
|
||||
property->class->gtk_arg,
|
||||
gvalue, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
glade_property_changed_boolean (GladeProperty *property, gboolean val)
|
||||
glade_property_set_boolean (GladeProperty *property, gboolean val)
|
||||
{
|
||||
g_return_if_fail (property != NULL);
|
||||
g_return_if_fail (property->value != NULL);
|
||||
g_return_if_fail (property->widget != NULL);
|
||||
g_return_if_fail (property->widget->widget != NULL);
|
||||
|
||||
g_free (property->value);
|
||||
property->value = g_strdup_printf ("%s", val ? GLADE_TAG_TRUE : GLADE_TAG_FALSE);
|
||||
g_value_set_boolean (property->value, val);
|
||||
|
||||
property->loading = TRUE;
|
||||
if (property->class->set_function == NULL)
|
||||
gtk_object_set (GTK_OBJECT (property->widget->widget),
|
||||
property->class->id,
|
||||
val,
|
||||
NULL);
|
||||
else
|
||||
(*property->class->set_function) (G_OBJECT (property->widget->widget),
|
||||
property->value);
|
||||
property->loading = FALSE;
|
||||
if (property->enabled) {
|
||||
property->loading = TRUE;
|
||||
if (property->class->set_function == NULL) {
|
||||
if (GTK_IS_TABLE (property->widget->widget)) {
|
||||
g_print ("Is table \n");
|
||||
gtk_widget_queue_resize (GTK_WIDGET (property->widget->widget));
|
||||
#if 0
|
||||
gtk_table_set_homogeneous (property->widget->widget, val);
|
||||
#endif
|
||||
} else {
|
||||
gtk_object_set (GTK_OBJECT (property->widget->widget),
|
||||
property->class->id,
|
||||
val,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
else
|
||||
(*property->class->set_function) (G_OBJECT (property->widget->widget),
|
||||
property->value);
|
||||
property->loading = FALSE;
|
||||
}
|
||||
|
||||
glade_property_emit_changed (property);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
glade_property_changed_choice (GladeProperty *property, GladeChoice *choice)
|
||||
glade_property_set_choice (GladeProperty *property, GladeChoice *choice)
|
||||
{
|
||||
#if 0
|
||||
g_return_if_fail (property != NULL);
|
||||
g_return_if_fail (property->value != NULL);
|
||||
g_return_if_fail (choice != NULL);
|
||||
|
||||
g_free (property->value);
|
||||
property->value = g_strdup_printf ("%s", choice->symbol);
|
||||
g_value_set_enum (property->value, 0);
|
||||
|
||||
property->loading = TRUE;
|
||||
if (property->class->set_function == NULL)
|
||||
gtk_object_set (GTK_OBJECT (property->widget->widget),
|
||||
property->class->id, choice->value, NULL);
|
||||
else
|
||||
(*property->class->set_function) (G_OBJECT (property->widget->widget),
|
||||
property->value);
|
||||
property->loading = FALSE;
|
||||
|
||||
glade_property_emit_changed (property);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
const gchar *
|
||||
glade_property_get_text (GladeProperty *property)
|
||||
glade_property_get_string (GladeProperty *property)
|
||||
{
|
||||
g_return_val_if_fail (property != NULL, NULL);
|
||||
g_return_val_if_fail (property->value != NULL, NULL);
|
||||
|
||||
return property->value;
|
||||
return g_value_get_string (property->value);
|
||||
}
|
||||
|
||||
gint
|
||||
@ -501,17 +439,18 @@ glade_property_get_integer (GladeProperty *property)
|
||||
{
|
||||
g_return_val_if_fail (property != NULL, 0);
|
||||
g_return_val_if_fail (property->value != NULL, 0);
|
||||
|
||||
return atoi (property->value);
|
||||
|
||||
return g_value_get_int (property->value);
|
||||
}
|
||||
|
||||
gfloat
|
||||
glade_property_get_float (GladeProperty *property)
|
||||
{
|
||||
gfloat resp;
|
||||
g_return_val_if_fail (property != NULL, 0.0);
|
||||
g_return_val_if_fail (property->value != NULL, 0.0);
|
||||
|
||||
return atof (property->value);
|
||||
resp = g_value_get_float (property->value);
|
||||
return resp;
|
||||
}
|
||||
|
||||
gdouble
|
||||
@ -520,7 +459,7 @@ glade_property_get_double (GladeProperty *property)
|
||||
g_return_val_if_fail (property != NULL, 0.0);
|
||||
g_return_val_if_fail (property->value != NULL, 0.0);
|
||||
|
||||
return (gdouble) atof (property->value);
|
||||
return g_value_get_double (property->value);
|
||||
}
|
||||
|
||||
gboolean
|
||||
@ -529,18 +468,20 @@ glade_property_get_boolean (GladeProperty *property)
|
||||
g_return_val_if_fail (property != NULL, FALSE);
|
||||
g_return_val_if_fail (property->value != NULL, FALSE);
|
||||
|
||||
return (strcmp (property->value, GLADE_TAG_TRUE) == 0);
|
||||
return g_value_get_boolean (property->value);
|
||||
}
|
||||
|
||||
GladeChoice *
|
||||
glade_property_get_choice (GladeProperty *property)
|
||||
{
|
||||
GladeChoice *choice = NULL;
|
||||
#if 0
|
||||
GList *list;
|
||||
#endif
|
||||
|
||||
g_return_val_if_fail (property != NULL, NULL);
|
||||
g_return_val_if_fail (property->value != NULL, NULL);
|
||||
|
||||
#if 0
|
||||
list = property->class->choices;
|
||||
for (; list != NULL; list = list->next) {
|
||||
choice = list->data;
|
||||
@ -549,6 +490,7 @@ glade_property_get_choice (GladeProperty *property)
|
||||
}
|
||||
if (list == NULL)
|
||||
g_warning ("Cant find the GladePropertyChoice selected\n");
|
||||
#endif
|
||||
|
||||
return choice;
|
||||
}
|
||||
@ -603,10 +545,17 @@ GladeXmlNode *
|
||||
glade_property_write (GladeXmlContext *context, GladeProperty *property)
|
||||
{
|
||||
GladeXmlNode *node;
|
||||
gchar *temp;
|
||||
|
||||
if (!property->enabled)
|
||||
return NULL;
|
||||
|
||||
node = glade_xml_node_new (context, GLADE_XML_TAG_PROPERTY);
|
||||
glade_xml_node_set_property_string (node, GLADE_XML_TAG_NAME, property->class->id);
|
||||
glade_xml_set_content (node, property->value);
|
||||
temp = glade_property_class_make_string_from_gvalue (property->class->type,
|
||||
property->value);
|
||||
glade_xml_set_content (node, temp);
|
||||
g_free (temp);
|
||||
|
||||
return node;
|
||||
}
|
||||
@ -625,3 +574,29 @@ glade_property_free (GladeProperty *property)
|
||||
|
||||
g_free (property);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
glade_property_get_from_widget (GladeProperty *property)
|
||||
{
|
||||
gboolean bool = FALSE;
|
||||
|
||||
g_value_reset (property->value);
|
||||
|
||||
if (property->class->get_function)
|
||||
(*property->class->get_function) (G_OBJECT (property->widget->widget), property->value);
|
||||
else {
|
||||
switch (property->class->type) {
|
||||
case GLADE_PROPERTY_TYPE_BOOLEAN:
|
||||
gtk_object_get (GTK_OBJECT (property->widget->widget),
|
||||
property->class->id,
|
||||
&bool,
|
||||
NULL);
|
||||
g_value_set_boolean (property->value, bool);
|
||||
break;
|
||||
default:
|
||||
glade_implement_me ();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,11 +24,14 @@ struct _GladeProperty {
|
||||
GladeWidget *widget; /* A pointer to the GladeWidget that this
|
||||
* GladeProperty is modifying
|
||||
*/
|
||||
|
||||
|
||||
GValue *value;
|
||||
#if 0
|
||||
gchar *value; /* A string representation of the value. Depending
|
||||
* on the property->type it can contain an integer
|
||||
* a "False" or "True" string or a string itself
|
||||
*/
|
||||
#endif
|
||||
|
||||
gboolean enabled; /* Enables is a flag that is used for GladeProperties
|
||||
* that have the optional flag set to let us know
|
||||
@ -70,14 +73,14 @@ GList * glade_property_list_new_from_widget_class (GladeWidgetClass *class,
|
||||
GladeProperty * glade_property_new_from_class (GladePropertyClass *class, GladeWidget *widget);
|
||||
void glade_property_free (GladeProperty *property);
|
||||
|
||||
void glade_property_changed_text (GladeProperty *property, const gchar *text);
|
||||
void glade_property_changed_integer (GladeProperty *property, gint val);
|
||||
void glade_property_changed_float (GladeProperty *property, gfloat val);
|
||||
void glade_property_changed_double (GladeProperty *property, gdouble val);
|
||||
void glade_property_changed_boolean (GladeProperty *property, gboolean val);
|
||||
void glade_property_changed_choice (GladeProperty *property, GladeChoice *choice);
|
||||
void glade_property_set_string (GladeProperty *property, const gchar *text);
|
||||
void glade_property_set_integer (GladeProperty *property, gint val);
|
||||
void glade_property_set_float (GladeProperty *property, gfloat val);
|
||||
void glade_property_set_double (GladeProperty *property, gdouble val);
|
||||
void glade_property_set_boolean (GladeProperty *property, gboolean val);
|
||||
void glade_property_set_choice (GladeProperty *property, GladeChoice *choice);
|
||||
|
||||
const gchar * glade_property_get_text (GladeProperty *property);
|
||||
const gchar * glade_property_get_string (GladeProperty *property);
|
||||
gint glade_property_get_integer (GladeProperty *property);
|
||||
gfloat glade_property_get_float (GladeProperty *property);
|
||||
gdouble glade_property_get_double (GladeProperty *property);
|
||||
@ -85,6 +88,8 @@ gboolean glade_property_get_boolean (GladeProperty *property);
|
||||
GladeChoice * glade_property_get_choice (GladeProperty *property);
|
||||
|
||||
|
||||
void glade_property_get_from_widget (GladeProperty *property);
|
||||
|
||||
/* Get a GladeProperty */
|
||||
GladeProperty * glade_property_get_from_id (GList *settings_list,
|
||||
const gchar *id);
|
||||
|
@ -13,7 +13,6 @@ G_BEGIN_DECLS
|
||||
|
||||
gboolean glade_util_path_is_writable (const gchar *full_path);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GLADE_UTILS_H__ */
|
||||
|
@ -26,8 +26,6 @@
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "glade.h"
|
||||
#include "glade-xml-utils.h"
|
||||
|
||||
@ -181,7 +179,8 @@ glade_widget_class_set_type (GladeWidgetClass *class, const gchar *init_function
|
||||
type = get_type ();
|
||||
|
||||
if (type == 0) {
|
||||
g_warning(_("Could not get the type from \"%s\" while trying to load \"%s\""), class->name);
|
||||
g_warning(_("Could not get the type from \"%s\" while trying to load \"%s\""),
|
||||
init_function_name, class->name);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -74,17 +74,17 @@ glade_widget_new_name (GladeProject *project, GladeWidgetClass *class)
|
||||
* Return Value:
|
||||
**/
|
||||
static GladeWidget *
|
||||
glade_widget_new (GladeProject *project, GladeWidgetClass *class, GtkWidget *gtk_widget, const gchar *name)
|
||||
glade_widget_new (GladeWidgetClass *class)
|
||||
{
|
||||
GladeWidget *widget;
|
||||
|
||||
widget = g_new0 (GladeWidget, 1);
|
||||
widget->name = g_strdup (name);
|
||||
widget->widget = gtk_widget;
|
||||
widget->project = project;
|
||||
widget->class = class;
|
||||
widget->name = NULL;
|
||||
widget->widget = NULL;
|
||||
widget->project = NULL;
|
||||
widget->class = class;
|
||||
widget->properties = glade_property_list_new_from_widget_class (class, widget);
|
||||
widget->parent = NULL;
|
||||
widget->parent = NULL;
|
||||
widget->children = NULL;
|
||||
widget->selected = FALSE;
|
||||
|
||||
@ -309,6 +309,56 @@ glade_widget_button_release (GtkWidget *widget, GdkEventButton *event, gpointer
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
glade_property_refresh (GladeProperty *property)
|
||||
{
|
||||
switch (property->class->type) {
|
||||
case GLADE_PROPERTY_TYPE_BOOLEAN:
|
||||
glade_property_set_boolean (property,
|
||||
glade_property_get_boolean (property));
|
||||
break;
|
||||
case GLADE_PROPERTY_TYPE_FLOAT:
|
||||
glade_property_set_float (property,
|
||||
glade_property_get_float (property));
|
||||
break;
|
||||
case GLADE_PROPERTY_TYPE_INTEGER:
|
||||
glade_property_set_integer (property,
|
||||
glade_property_get_integer (property));
|
||||
break;
|
||||
case GLADE_PROPERTY_TYPE_DOUBLE:
|
||||
glade_property_set_double (property,
|
||||
glade_property_get_double (property));
|
||||
break;
|
||||
case GLADE_PROPERTY_TYPE_STRING:
|
||||
glade_property_set_string (property,
|
||||
glade_property_get_string (property));
|
||||
break;
|
||||
case GLADE_PROPERTY_TYPE_ENUM:
|
||||
glade_property_set_choice (property,
|
||||
glade_property_get_choice (property));
|
||||
break;
|
||||
case GLADE_PROPERTY_TYPE_OBJECT:
|
||||
g_print ("Set adjustment\n");
|
||||
#if 1
|
||||
g_print ("Set directly \n");
|
||||
#if 0
|
||||
glade_widget_set_default_options_real (property->child, packing);
|
||||
#endif
|
||||
gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON (property->widget->widget),
|
||||
GTK_ADJUSTMENT (property->child));
|
||||
#else
|
||||
gtk_object_set (GTK_OBJECT (property->widget->widget),
|
||||
property->class->id,
|
||||
property->child, NULL);
|
||||
#endif
|
||||
g_print ("Adjustment has been set\n");
|
||||
break;
|
||||
default:
|
||||
g_warning ("Implement set default for this type [%s]\n", property->class->name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* glade_widget_set_default_options:
|
||||
* @widget:
|
||||
@ -329,69 +379,27 @@ glade_widget_set_default_options_real (GladeWidget *widget, gboolean packing)
|
||||
continue;
|
||||
|
||||
/* For some properties, we get the value from the GtkWidget, for example the
|
||||
* "position" packing property
|
||||
* "position" packing property. See g-p-class.h ->get_default. Chema
|
||||
*/
|
||||
if (property->value && (strcmp (property->value, GLADE_GET_DEFAULT_FROM_WIDGET) == 0)) {
|
||||
gchar *temp;
|
||||
if (!property->class->get_function) {
|
||||
g_warning ("Class %s is get_default_from_widget but no get function specified",
|
||||
property->class->name);
|
||||
temp = g_strdup ("Error");
|
||||
} else
|
||||
temp = (*property->class->get_function) (G_OBJECT (widget->widget));
|
||||
g_free (property->value);
|
||||
property->value = temp;
|
||||
if (property->class->get_default) {
|
||||
glade_property_get_from_widget (property);
|
||||
continue;
|
||||
}
|
||||
|
||||
property->loading = TRUE;
|
||||
|
||||
switch (property->class->type) {
|
||||
case GLADE_PROPERTY_TYPE_BOOLEAN:
|
||||
glade_property_changed_boolean (property,
|
||||
glade_property_get_boolean (property));
|
||||
break;
|
||||
case GLADE_PROPERTY_TYPE_FLOAT:
|
||||
glade_property_changed_float (property,
|
||||
glade_property_get_float (property));
|
||||
break;
|
||||
case GLADE_PROPERTY_TYPE_INTEGER:
|
||||
glade_property_changed_integer (property,
|
||||
glade_property_get_integer (property));
|
||||
break;
|
||||
case GLADE_PROPERTY_TYPE_DOUBLE:
|
||||
glade_property_changed_double (property,
|
||||
glade_property_get_double (property));
|
||||
break;
|
||||
case GLADE_PROPERTY_TYPE_TEXT:
|
||||
glade_property_changed_text (property,
|
||||
glade_property_get_text (property));
|
||||
break;
|
||||
case GLADE_PROPERTY_TYPE_CHOICE:
|
||||
glade_property_changed_choice (property,
|
||||
glade_property_get_choice (property));
|
||||
break;
|
||||
case GLADE_PROPERTY_TYPE_OBJECT:
|
||||
g_print ("Set adjustment\n");
|
||||
#if 1
|
||||
g_print ("Set directly \n");
|
||||
glade_widget_set_default_options_real (property->child, packing);
|
||||
gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON (property->widget->widget),
|
||||
GTK_ADJUSTMENT (property->child));
|
||||
#else
|
||||
gtk_object_set (GTK_OBJECT (property->widget->widget),
|
||||
property->class->id,
|
||||
property->child, NULL);
|
||||
#endif
|
||||
g_print ("Adjustment has been set\n");
|
||||
break;
|
||||
default:
|
||||
g_warning ("Implement set default for this type [%s]\n", property->class->name);
|
||||
break;
|
||||
if (property->class->apply_first_time && !property->enabled) {
|
||||
property->enabled = TRUE;
|
||||
property->loading = TRUE;
|
||||
glade_property_refresh (property);
|
||||
property->loading = FALSE;
|
||||
property->enabled = FALSE;
|
||||
}
|
||||
|
||||
property->loading = TRUE;
|
||||
glade_property_refresh (property);
|
||||
property->loading = FALSE;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
@ -415,25 +423,6 @@ glade_widget_set_default_packing_options (GladeWidget *widget)
|
||||
glade_widget_set_default_options_real (widget, TRUE);
|
||||
}
|
||||
|
||||
static GladeWidget *
|
||||
glade_widget_register (GladeProject *project, GladeWidgetClass *class, GtkWidget *gtk_widget, const gchar *name, GladeWidget *parent)
|
||||
{
|
||||
GladeWidget *glade_widget;
|
||||
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
g_return_val_if_fail (GLADE_IS_PROJECT (project), NULL);
|
||||
|
||||
glade_widget = glade_widget_new (project, class, gtk_widget, name);
|
||||
glade_widget->parent = parent;
|
||||
|
||||
glade_packing_add_properties (glade_widget);
|
||||
|
||||
if (parent)
|
||||
parent->children = g_list_prepend (parent->children, glade_widget);
|
||||
|
||||
return glade_widget;
|
||||
}
|
||||
|
||||
static GdkWindow*
|
||||
glade_widget_get_window (GladeWidget *widget, GtkWidget **paint_widget)
|
||||
{
|
||||
@ -574,36 +563,7 @@ glade_widget_set_contents (GladeWidget *widget)
|
||||
property = glade_property_get_from_id (widget->properties,
|
||||
"title");
|
||||
if (property != NULL)
|
||||
glade_property_changed_text (property, widget->name);
|
||||
}
|
||||
|
||||
static gchar *
|
||||
glade_property_get (GladeProperty *property)
|
||||
{
|
||||
gchar *resp;
|
||||
|
||||
if (property->class->get_function)
|
||||
resp = (*property->class->get_function)
|
||||
(G_OBJECT (property->widget->widget));
|
||||
else {
|
||||
gboolean bool;
|
||||
switch (property->class->type) {
|
||||
case GLADE_PROPERTY_TYPE_BOOLEAN:
|
||||
gtk_object_get (GTK_OBJECT (property->widget->widget),
|
||||
property->class->id,
|
||||
&bool,
|
||||
NULL);
|
||||
resp = bool ?
|
||||
g_strdup (GLADE_TAG_TRUE) :
|
||||
g_strdup (GLADE_TAG_FALSE);
|
||||
break;
|
||||
default:
|
||||
resp = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return resp;
|
||||
glade_property_set_string (property, widget->name);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -611,8 +571,7 @@ glade_widget_property_changed_cb (GtkWidget *w)
|
||||
{
|
||||
GladeProperty *property;
|
||||
GladeWidget *widget;
|
||||
gchar *new = NULL;
|
||||
|
||||
|
||||
widget = glade_widget_get_from_gtk_widget (w);
|
||||
g_return_if_fail (GLADE_IS_WIDGET (widget));
|
||||
property = gtk_object_get_data (GTK_OBJECT (w),
|
||||
@ -622,23 +581,9 @@ glade_widget_property_changed_cb (GtkWidget *w)
|
||||
if (property->loading)
|
||||
return;
|
||||
|
||||
new = glade_property_get (property);
|
||||
|
||||
switch (property->class->type) {
|
||||
case GLADE_PROPERTY_TYPE_TEXT:
|
||||
glade_property_changed_text (property, new);
|
||||
break;
|
||||
case GLADE_PROPERTY_TYPE_BOOLEAN:
|
||||
if (new && strcmp (new, GLADE_TAG_TRUE) == 0)
|
||||
glade_property_changed_boolean (property, TRUE);
|
||||
else
|
||||
glade_property_changed_boolean (property, FALSE);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
g_free (new);
|
||||
glade_property_get_from_widget (property);
|
||||
|
||||
glade_property_refresh (property);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -696,59 +641,80 @@ glade_widget_connect_other_signals (GladeWidget *widget)
|
||||
}
|
||||
}
|
||||
|
||||
static GladeWidget *
|
||||
glade_widget_create_gtk_widget (GladeProject *project,
|
||||
GladeWidgetClass *class,
|
||||
GladeWidget *parent)
|
||||
static gboolean
|
||||
glade_widget_create_gtk_widget (GladeWidget *glade_widget)
|
||||
{
|
||||
GladeWidget *glade_widget;
|
||||
GType type;
|
||||
GladeWidgetClass *class;
|
||||
GtkWidget *widget;
|
||||
gchar *name;
|
||||
|
||||
GType type;
|
||||
|
||||
class = glade_widget->class;
|
||||
type = g_type_from_name (class->name);
|
||||
if (! g_type_is_a (type, G_TYPE_OBJECT)) {
|
||||
|
||||
if (!g_type_is_a (type, G_TYPE_OBJECT)) {
|
||||
gchar *text;
|
||||
g_warning ("Unknown type %s read from glade file.", class->name);
|
||||
text = g_strdup_printf ("Error, class_new_widget not implemented [%s]\n", class->name);
|
||||
widget = gtk_label_new (text);
|
||||
g_free (text);
|
||||
return FALSE;
|
||||
} else {
|
||||
if (g_type_is_a (type, GTK_TYPE_WIDGET))
|
||||
widget = gtk_widget_new (type, NULL);
|
||||
else
|
||||
widget = g_object_new (type, NULL);
|
||||
}
|
||||
|
||||
name = glade_widget_new_name (project, class);
|
||||
glade_widget = glade_widget_register (project, class, widget, name, parent);
|
||||
g_free (name);
|
||||
|
||||
glade_widget->widget = widget;
|
||||
|
||||
gtk_object_set_data (GTK_OBJECT (glade_widget->widget), GLADE_WIDGET_DATA_TAG, glade_widget);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
glade_project_add_widget (project, glade_widget);
|
||||
static void
|
||||
glade_widget_connect_signals (GladeWidget *widget)
|
||||
{
|
||||
/* We can be a GtkObject. For example an adjustment. */
|
||||
if (!GTK_IS_WIDGET (widget->widget))
|
||||
return;
|
||||
|
||||
glade_widget_connect_mouse_signals (widget);
|
||||
glade_widget_connect_draw_signals (widget);
|
||||
glade_widget_connect_edit_signals (widget);
|
||||
glade_widget_connect_other_signals (widget);
|
||||
}
|
||||
|
||||
/* We can be a GtkObject for example, like an adjustment */
|
||||
if (!g_type_is_a (type, GTK_TYPE_WIDGET))
|
||||
return glade_widget;
|
||||
|
||||
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);
|
||||
glade_widget_connect_other_signals (glade_widget);
|
||||
static GladeWidget *
|
||||
glade_widget_new_full (GladeProject *project,
|
||||
GladeWidgetClass *class,
|
||||
GladeWidget *parent)
|
||||
{
|
||||
GladeWidget *widget;
|
||||
|
||||
if (GTK_IS_TABLE (glade_widget->widget)) {
|
||||
g_print ("Is table\n");
|
||||
gtk_table_set_homogeneous (GTK_TABLE (glade_widget->widget),
|
||||
FALSE);
|
||||
}
|
||||
return glade_widget;
|
||||
g_return_val_if_fail (GLADE_IS_PROJECT (project), NULL);
|
||||
g_return_val_if_fail (GLADE_IS_WIDGET_CLASS (class), NULL);
|
||||
|
||||
widget = glade_widget_new (class);
|
||||
widget->project = project;
|
||||
widget->name = glade_widget_new_name (project, class);
|
||||
widget->parent = parent;
|
||||
|
||||
glade_packing_add_properties (widget);
|
||||
glade_widget_create_gtk_widget (widget);
|
||||
glade_project_add_widget (project, widget);
|
||||
|
||||
if (parent)
|
||||
parent->children = g_list_prepend (parent->children, widget);
|
||||
|
||||
glade_widget_set_contents (widget);
|
||||
glade_widget_connect_signals (widget);
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
||||
/**
|
||||
* glade_widget_new_from_class:
|
||||
* glade_widget_new_from_class_full:
|
||||
* @project:
|
||||
* @class:
|
||||
* @parent: the parent of the new widget, should be NULL for toplevel widgets
|
||||
@ -763,7 +729,7 @@ static GladeWidget *
|
||||
glade_widget_new_from_class_full (GladeWidgetClass *class, GladeProject *project, GladeWidget *parent)
|
||||
{
|
||||
GladePropertyQueryResult *result = NULL;
|
||||
GladeWidget *glade_widget;
|
||||
GladeWidget *widget;
|
||||
|
||||
g_return_val_if_fail (GLADE_IS_WIDGET_CLASS (class), NULL);
|
||||
g_return_val_if_fail (GLADE_IS_PROJECT (project), NULL);
|
||||
@ -774,22 +740,24 @@ glade_widget_new_from_class_full (GladeWidgetClass *class, GladeProject *project
|
||||
return NULL;
|
||||
}
|
||||
|
||||
glade_widget = glade_widget_create_gtk_widget (project, class, parent);
|
||||
widget = glade_widget_new_full (project, class, parent);
|
||||
|
||||
/* IF we are a container, add the placeholders */
|
||||
if (GLADE_WIDGET_CLASS_ADD_PLACEHOLDER (class))
|
||||
glade_placeholder_add (class, glade_widget, result);
|
||||
/* If we are a container, add the placeholders */
|
||||
if (GLADE_WIDGET_CLASS_ADD_PLACEHOLDER (class)) {
|
||||
g_print ("Add placeholder \n");
|
||||
glade_placeholder_add (class, widget, result);
|
||||
}
|
||||
|
||||
/* ->widget sometimes contains GtkObjects like a GtkAdjustment for example */
|
||||
if (GTK_IS_WIDGET (glade_widget->widget))
|
||||
gtk_widget_show (glade_widget->widget);
|
||||
|
||||
if (result)
|
||||
glade_property_query_result_destroy (result);
|
||||
|
||||
glade_widget_set_default_options (glade_widget);
|
||||
glade_widget_set_default_options (widget);
|
||||
|
||||
/* ->widget sometimes contains GtkObjects like a GtkAdjustment for example */
|
||||
if (GTK_IS_WIDGET (widget->widget))
|
||||
gtk_widget_show (widget->widget);
|
||||
|
||||
return glade_widget;
|
||||
return widget;
|
||||
}
|
||||
|
||||
GladeWidget *
|
||||
@ -834,6 +802,17 @@ glade_widget_get_class (GladeWidget *widget)
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* glade_widget_get_property_from_list:
|
||||
* @list: The list of GladeProperty
|
||||
* @class: The Class that we are trying to match with GladePropery
|
||||
* @silent: True if we shuold warn when a property is not included in the list
|
||||
*
|
||||
* Give a list of GladeProperties find the one that has ->class = to @class.
|
||||
* This function recurses into child objects if needed.
|
||||
*
|
||||
* Return Value:
|
||||
**/
|
||||
static GladeProperty *
|
||||
glade_widget_get_property_from_list (GList *list, GladePropertyClass *class, gboolean silent)
|
||||
{
|
||||
@ -1069,7 +1048,7 @@ glade_widget_write (GladeXmlContext *context, GladeWidget *widget)
|
||||
GladeSignal *signal;
|
||||
GList *list;
|
||||
GList *list2;
|
||||
|
||||
|
||||
g_return_val_if_fail (GLADE_XML_IS_CONTEXT (context), NULL);
|
||||
g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
|
||||
|
||||
@ -1086,7 +1065,7 @@ glade_widget_write (GladeXmlContext *context, GladeWidget *widget)
|
||||
continue;
|
||||
child = glade_property_write (context, property);
|
||||
if (child == NULL)
|
||||
return NULL;
|
||||
continue;
|
||||
glade_xml_append_child (node, child);
|
||||
}
|
||||
|
||||
@ -1104,13 +1083,15 @@ glade_widget_write (GladeXmlContext *context, GladeWidget *widget)
|
||||
list = widget->children;
|
||||
for (; list != NULL; list = list->next) {
|
||||
child_widget = list->data;
|
||||
child_tag = glade_xml_node_new (context, GLADE_XML_TAG_CHILD);
|
||||
glade_xml_append_child (node, child_tag);
|
||||
|
||||
/* write the widget */
|
||||
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);
|
||||
|
||||
|
||||
/* Append the packing properties */
|
||||
packing = glade_xml_node_new (context, GLADE_XML_TAG_PACKING);
|
||||
list2 = child_widget->properties;
|
||||
@ -1121,14 +1102,83 @@ glade_widget_write (GladeXmlContext *context, GladeWidget *widget)
|
||||
continue;
|
||||
packing_property = glade_property_write (context, property);
|
||||
if (packing_property == NULL)
|
||||
return NULL;
|
||||
continue;
|
||||
glade_xml_append_child (packing, packing_property);
|
||||
}
|
||||
glade_xml_append_child (child_tag, packing);
|
||||
/* */
|
||||
|
||||
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
glade_widget_apply_property_from_node (GladeXmlNode *node, GladeWidget *widget)
|
||||
{
|
||||
GladeProperty *property;
|
||||
gchar *value;
|
||||
gchar *id;
|
||||
|
||||
id = glade_xml_get_property_string_required (node, GLADE_XML_TAG_NAME, NULL);
|
||||
value = glade_xml_get_content (node);
|
||||
|
||||
if (!value || !id)
|
||||
return FALSE;
|
||||
|
||||
property = glade_property_get_from_id (widget->properties,
|
||||
id);
|
||||
|
||||
g_print ("Apply %s with %s\n", id, value);
|
||||
|
||||
g_free (id);
|
||||
g_free (value);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
glade_widget_load_child_from_node (GladeXmlNode *node)
|
||||
{
|
||||
g_print ("Foo\n");
|
||||
}
|
||||
|
||||
GladeWidget *
|
||||
glade_widget_new_from_node (GladeXmlNode *node, GladeProject *project)
|
||||
{
|
||||
GladeWidgetClass *class;
|
||||
GladeXmlNode *child;
|
||||
GladeWidget *widget;
|
||||
gchar *class_name;
|
||||
|
||||
if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
|
||||
return NULL;
|
||||
|
||||
class_name = glade_xml_get_property_string_required (node, GLADE_XML_TAG_CLASS, NULL);
|
||||
if (!class_name)
|
||||
return NULL;
|
||||
class = glade_widget_class_get_by_name (class_name);
|
||||
if (!class)
|
||||
return NULL;
|
||||
|
||||
widget = glade_widget_new_full (project,
|
||||
class,
|
||||
NULL);
|
||||
|
||||
g_print ("The %s widget has %d properties\n", widget->name,
|
||||
g_list_length (widget->properties));
|
||||
|
||||
child = glade_xml_node_get_children (node);
|
||||
for (; child != NULL; child = glade_xml_node_next (child)) {
|
||||
if (!(glade_xml_node_verify_silent (child, GLADE_XML_TAG_CHILD) ||
|
||||
glade_xml_node_verify (child, GLADE_XML_TAG_PROPERTY)))
|
||||
return NULL;
|
||||
if (glade_xml_node_verify_silent (child, GLADE_XML_TAG_CHILD))
|
||||
glade_widget_load_child_from_node (child);
|
||||
else
|
||||
glade_widget_apply_property_from_node (child, widget);
|
||||
}
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ GladeWidget * glade_widget_get_from_gtk_widget (GtkWidget *widget);
|
||||
|
||||
/* Xml saving & reading */
|
||||
GladeXmlNode * glade_widget_write (GladeXmlContext *context, GladeWidget *widget);
|
||||
|
||||
GladeWidget * glade_widget_new_from_node (GladeXmlNode *node, GladeProject *project);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -120,7 +120,7 @@ glade_xml_get_value (xmlNodePtr node, const char *name)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gboolean
|
||||
glade_xml_node_verify_silent (GladeXmlNode *node_in, const gchar *name)
|
||||
{
|
||||
xmlNodePtr node = (xmlNodePtr) node_in;
|
||||
@ -471,44 +471,6 @@ glade_xml_utils_new_hash_from_node (GladeXmlNode *node_in, const gchar *hash_typ
|
||||
return hash;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void
|
||||
glade_xml_utils_hash_item_write (gpointer key_in, gpointer value_in, gpointer data)
|
||||
{
|
||||
GladeXmlNode *item;
|
||||
GladeXmlNode *node;
|
||||
gchar *key;
|
||||
gchar *value;
|
||||
|
||||
key = (gchar *) key_in;
|
||||
value = (gchar *) value_in;
|
||||
node = (GladeXmlNode *) data;
|
||||
|
||||
item = xmlNewChild (node, NULL, key, value);
|
||||
|
||||
if (item == NULL)
|
||||
g_warning ("Could not add the key \"%s\" with value \"%s\" to the tree",
|
||||
key, value);
|
||||
}
|
||||
|
||||
GladeXmlNode *
|
||||
glade_xml_utils_hash_write (GladeXmlContext *context, GHashTable *hash, const gchar *name)
|
||||
{
|
||||
GladeXmlNode *node;
|
||||
|
||||
g_return_val_if_fail (context != NULL, NULL);
|
||||
g_return_val_if_fail (hash != NULL, NULL);
|
||||
|
||||
node = glade_xml_node_new (context, name)
|
||||
|
||||
g_hash_table_foreach (hash,
|
||||
glade_xml_utils_hash_item_write,
|
||||
node);
|
||||
|
||||
return node;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* --------------------------- Parse Context ----------------------------*/
|
||||
GladeXmlContext *
|
||||
glade_xml_context_new_real (GladeXmlDoc *doc, xmlNsPtr ns)
|
||||
|
@ -1,5 +1,4 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
|
||||
|
||||
/* TODO : s/glade_xml_get_/glade_xml_node_get/g */
|
||||
#ifndef __GLADE_XML_UTILS_H__
|
||||
#define __GLADE_XML_UTILS_H__
|
||||
@ -30,6 +29,7 @@ GladeXmlNode * glade_xml_search_child (GladeXmlNode * node, const cha
|
||||
GladeXmlNode * glade_xml_search_child_required (GladeXmlNode * tree, const gchar* name);
|
||||
|
||||
gboolean glade_xml_node_verify (GladeXmlNode * node, const gchar *name);
|
||||
gboolean glade_xml_node_verify_silent (GladeXmlNode *node_in, const gchar *name);
|
||||
void glade_xml_set_value (GladeXmlNode * node, const char *name, const char *val);
|
||||
|
||||
/* Properties */
|
||||
|
43
src/glade.h
43
src/glade.h
@ -1,11 +1,37 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
|
||||
#if 0
|
||||
#include <gnome.h>
|
||||
#else
|
||||
#ifndef __GLADE_H__
|
||||
#define __GLADE_H__
|
||||
|
||||
#include <config.h>
|
||||
#include <gtk/gtk.h>
|
||||
gchar * _ (gchar * name);
|
||||
#include <libintl.h>
|
||||
|
||||
/* Borrow from libgnome/libgnome.h */
|
||||
#ifdef ENABLE_NLS
|
||||
# include <libintl.h>
|
||||
# ifdef GNOME_EXPLICIT_TRANSLATION_DOMAIN
|
||||
# undef _
|
||||
# define _(String) dgettext (GNOME_EXPLICIT_TRANSLATION_DOMAIN, String)
|
||||
# else
|
||||
# define _(String) gettext (String)
|
||||
# endif
|
||||
# ifdef gettext_noop
|
||||
# define N_(String) gettext_noop (String)
|
||||
# else
|
||||
# define N_(String) (String)
|
||||
# endif
|
||||
#else
|
||||
/* Stubs that do something close enough. */
|
||||
# define textdomain(String) (String)
|
||||
# define gettext(String) (String)
|
||||
# define dgettext(Domain,Message) (Message)
|
||||
# define dcgettext(Domain,Message,Type) (Message)
|
||||
# define bindtextdomain(Domain,Directory) (Domain)
|
||||
# define _(String) (String)
|
||||
# define N_(String) (String)
|
||||
#endif
|
||||
|
||||
|
||||
#define g_ok_print g_print
|
||||
/* I always grep for g_print to find left over debuging print's
|
||||
* so for now, use g_ok_print on the code that is ment to do a g_print
|
||||
@ -29,19 +55,22 @@ gchar * _ (gchar * name);
|
||||
#define GLADE_TAG_PROPERTIES "Properties"
|
||||
#define GLADE_TAG_PROPERTY "Property"
|
||||
#define GLADE_TAG_COMMON "Common"
|
||||
#define GLADE_TAG_OPTIONAL "Optional"
|
||||
#define GLADE_TAG_OPTIONAL_DEFAULT "OptionalDefault"
|
||||
#define GLADE_TAG_APPLY_FIRST_TIME "ApplyFirstTime"
|
||||
#define GLADE_TAG_TYPE "Type"
|
||||
#define GLADE_TAG_TOOLTIP "Tooltip"
|
||||
#define GLADE_TAG_GTKARG "GtkArg"
|
||||
#define GLADE_TAG_PARAMETERS "Parameters"
|
||||
#define GLADE_TAG_PARAMETER "Parameter"
|
||||
#define GLADE_TAG_SYMBOL "Symbol"
|
||||
#define GLADE_TAG_CHOICES "Choices"
|
||||
#define GLADE_TAG_ENUM "Enum"
|
||||
#define GLADE_TAG_CHOICE "Choice"
|
||||
#define GLADE_TAG_FALSE "False"
|
||||
#define GLADE_TAG_TRUE "True"
|
||||
#define GLADE_TAG_YES "Yes"
|
||||
#define GLADE_TAG_NO "No"
|
||||
#define GLADE_TAG_TEXT "Text"
|
||||
#define GLADE_TAG_STRING "String"
|
||||
#define GLADE_TAG_BOOLEAN "Boolean"
|
||||
#define GLADE_TAG_FLOAT "Float"
|
||||
#define GLADE_TAG_INTEGER "Integer"
|
||||
@ -66,7 +95,6 @@ gchar * _ (gchar * name);
|
||||
|
||||
#define GLADE_WIDGET_DATA_TAG "GladeWidgetDataTag"
|
||||
|
||||
#define GLADE_GET_DEFAULT_FROM_WIDGET "GladeGetDefaultFromWidget"
|
||||
#define GLADE_MODIFY_PROPERTY_DATA "GladeModifyPropertyData"
|
||||
|
||||
#define GLADE_XML_TAG_PROJECT "glade-interface"
|
||||
@ -83,3 +111,4 @@ gchar * _ (gchar * name);
|
||||
#define GLADE_XML_TAG_PACKING "packing"
|
||||
|
||||
|
||||
#endif /* __GLADE_H__ */
|
||||
|
66
src/main.c
66
src/main.c
@ -20,8 +20,6 @@
|
||||
* Chema Celorio <chema@celorio.com>
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "glade.h"
|
||||
#include "glade-widget-class.h"
|
||||
#include "glade-editor.h"
|
||||
@ -36,7 +34,7 @@
|
||||
#include <gmodule.h>
|
||||
#include <popt.h>
|
||||
|
||||
static void parse_command_line (poptContext);
|
||||
static GList * parse_command_line (poptContext);
|
||||
|
||||
gchar * widget_name = NULL;
|
||||
|
||||
@ -65,7 +63,6 @@ static gint
|
||||
glade_init ()
|
||||
{
|
||||
GladeProjectWindow *project_window;
|
||||
GladeProject *project;
|
||||
GladeCatalog *catalog;
|
||||
|
||||
if (!g_module_supported ()) {
|
||||
@ -87,60 +84,66 @@ glade_init ()
|
||||
if (catalog == NULL)
|
||||
return FALSE;
|
||||
|
||||
project = glade_project_new ();
|
||||
|
||||
project_window = glade_project_window_new (catalog);
|
||||
glade_project_window_add_project (project_window, project);
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
poptContext pctx = poptGetContext ("Glade2", argc, (const char **) argv, options, 0);
|
||||
GladeProjectWindow *gpw;
|
||||
GladeProject *project;
|
||||
poptContext popt_context;
|
||||
GList *files;
|
||||
|
||||
popt_context = poptGetContext ("Glade2", argc, (const char **) argv, options, 0);
|
||||
files = parse_command_line (popt_context);
|
||||
poptFreeContext (popt_context);
|
||||
|
||||
#if 0
|
||||
#if 1
|
||||
gnome_init_with_popt_table ("Glade2", VERSION, argc, argv, options, 0, &pctx);
|
||||
#else
|
||||
gnome_program_init ("Glade2", VERSION, &libgnomeui_module_info,
|
||||
argc, argv, NULL);
|
||||
#endif
|
||||
#else
|
||||
gtk_init (&argc, &argv);
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#ifdef ENABLE_NLS
|
||||
bindtextdomain (PACKAGE, GLADE_LOCALE_DIR);
|
||||
textdomain (PACKAGE);
|
||||
#if 0
|
||||
g_print ("textdomain %s\n", PACKAGE);
|
||||
g_print ("localedir %s\n", GLADE_LOCALE_DIR);
|
||||
g_print (_("Translate me\n"));
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (!glade_init ())
|
||||
return -1;
|
||||
|
||||
parse_command_line (pctx);
|
||||
poptFreeContext (pctx);
|
||||
|
||||
if (widget_name == NULL) {
|
||||
GladeProjectWindow *gpw;
|
||||
gpw = glade_project_window_get ();
|
||||
glade_project_window_show_all (gpw);
|
||||
gtk_main ();
|
||||
} else {
|
||||
if (widget_name != NULL) {
|
||||
GladeWidgetClass *class;
|
||||
class = glade_widget_class_get_by_name (widget_name);
|
||||
if (class)
|
||||
glade_widget_class_dump_param_specs (class);
|
||||
return 0;
|
||||
}
|
||||
|
||||
gpw = glade_project_window_get ();
|
||||
glade_project_window_show_all (gpw);
|
||||
|
||||
if (files) {
|
||||
for (; files != NULL; files = files->next) {
|
||||
project = glade_project_open_from_file (files->data);
|
||||
glade_project_window_add_project (gpw, project);
|
||||
}
|
||||
} else {
|
||||
project = glade_project_new (TRUE);
|
||||
glade_project_window_add_project (gpw, project);
|
||||
}
|
||||
|
||||
gtk_main ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
static GList *
|
||||
parse_command_line (poptContext pctx)
|
||||
{
|
||||
const gchar **args;
|
||||
@ -157,7 +160,6 @@ parse_command_line (poptContext pctx)
|
||||
|
||||
files = g_list_reverse (files);
|
||||
|
||||
return files;
|
||||
}
|
||||
|
||||
gchar * _ (gchar * name) { return name;};
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
<Property Id="max-length"/>
|
||||
|
||||
<Property ParamSpec="FALSE" Id="text" Name="Text">
|
||||
<Type>Text</Type>
|
||||
<Type>String</Type>
|
||||
<Tooltip>Initial Contents of the entry</Tooltip>
|
||||
<SetFunction>glade_gtk_entry_set_text</SetFunction>
|
||||
<GetFunction>glade_gtk_entry_get_text</GetFunction>
|
||||
|
@ -20,6 +20,8 @@
|
||||
<WindowTitle>New horizontal box</WindowTitle>
|
||||
<Question>Number of columns</Question>
|
||||
</Query>
|
||||
<SetFunction>glade_gtk_box_set_size</SetFunction>
|
||||
<GetFunction>glade_gtk_box_get_size</GetFunction>
|
||||
</Property>
|
||||
|
||||
<Property Id="spacing"/>
|
||||
|
@ -18,19 +18,17 @@
|
||||
<Property Id="xpad"/>
|
||||
<Property Id="ypad"/>
|
||||
|
||||
<Property Common="TRUE" Id="x"/>
|
||||
<Property Common="TRUE" Id="y"/>
|
||||
<Property Common="TRUE" Id="width"/>
|
||||
<Property Common="TRUE" Id="height"/>
|
||||
<Property Common="TRUE" Id="visible" Default="True"/>
|
||||
<Property Common="TRUE" Id="sensitive"/>
|
||||
<Property Common="TRUE" Id="can-default"/>
|
||||
<Property Common="TRUE" Id="has-default"/>
|
||||
<Property Common="TRUE" Id="can-focus"/>
|
||||
<Property Common="True" Id="width-request"/>
|
||||
<Property Common="True" Id="height-request"/>
|
||||
<Property Common="True" Id="visible" Default="True"/>
|
||||
<Property Common="True" Id="sensitive"/>
|
||||
<Property Common="True" Id="can-default"/>
|
||||
<Property Common="True" Id="has-default"/>
|
||||
<Property Common="True" Id="can-focus"/>
|
||||
<!-- Not yet implemented
|
||||
<Property Common="TRUE" Id="events"/>
|
||||
<Property Common="True" Id="events"/>
|
||||
-->
|
||||
<Property Common="TRUE" Id="extension-events"/>
|
||||
<Property Common="True" Id="extension-events"/>
|
||||
|
||||
</Properties>
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
<Property Id="border-width"/>
|
||||
<Property ParamSpec="FALSE" Id="items" Name="Items">
|
||||
<Type>Text</Type>
|
||||
<Type>String</Type>
|
||||
<SetFunction>glade_gtk_option_menu_set_items</SetFunction>
|
||||
<Parameters>
|
||||
<Parameter Key="VisibleLines" Value="2"/>
|
||||
|
@ -22,8 +22,8 @@
|
||||
<WindowTitle>New vertical box</WindowTitle>
|
||||
<Question>Number of rows</Question>
|
||||
</Query>
|
||||
<SetFunction>glade_gtk_vbox_set_size</SetFunction>
|
||||
<GetFunction>glade_gtk_vbox_get_size</GetFunction>
|
||||
<SetFunction>glade_gtk_box_set_size</SetFunction>
|
||||
<GetFunction>glade_gtk_box_get_size</GetFunction>
|
||||
</Property>
|
||||
|
||||
<Property Id="spacing"/>
|
||||
|
@ -6,29 +6,36 @@
|
||||
|
||||
<Properties>
|
||||
|
||||
<Property Id="border-width"/>
|
||||
<Property Id="title"/>
|
||||
<Property Id="type"/>
|
||||
<Property Id="window-position"/>
|
||||
<Property Id="modal"/>
|
||||
<Property Id="default-width" Default="440"/>
|
||||
<Property Id="default-height" Default="250"/>
|
||||
<Property Id="auto-shrink"/>
|
||||
<Property Id="modal">
|
||||
<SetFunction>ignore</SetFunction>
|
||||
</Property>
|
||||
<Property Id="default-width" Default="440" Optional="True" OptionalDefault="False" ApplyFirstTime="True"/>
|
||||
<Property Id="default-height" Default="250" Optional="True" OptionalDefault="False" ApplyFirstTime="True"/>
|
||||
<Property Id="allow-grow"/>
|
||||
<Property Id="auto-shrink"/>
|
||||
<Property Id="allow-shrink"/>
|
||||
|
||||
<Property Common="TRUE" Id="x"/>
|
||||
<Property Common="TRUE" Id="y"/>
|
||||
<Property Common="TRUE" Id="width"/>
|
||||
<Property Common="TRUE" Id="height"/>
|
||||
<Property Common="TRUE" Id="visible" Default="True"/>
|
||||
<Property Common="TRUE" Id="sensitive"/>
|
||||
<Property Common="TRUE" Id="can-default"/>
|
||||
<Property Common="TRUE" Id="has-default"/>
|
||||
<Property Common="TRUE" Id="can-focus"/>
|
||||
<Property Common="True" Optional="True" OptioanlDefault="False" Default="0" Id="width-request"/>
|
||||
<Property Common="True" Optional="True" OptioanlDefault="False" Default="0" Id="height-request"/>
|
||||
<Property Common="True" Id="visible" Default="True">
|
||||
<SetFunction>ignore</SetFunction>
|
||||
</Property>
|
||||
<Property Common="True" Id="sensitive"/>
|
||||
<Property Common="True" Id="tooltip" ParamSpec="False" Name="Tooltip">
|
||||
<Type>String</Type>
|
||||
<SetFunction>glade_gtk_widget_set_tooltip</SetFunction>
|
||||
<GetFunction>glade_gtk_widget_get_tooltip</GetFunction>
|
||||
</Property>
|
||||
<Property Common="True" Id="can-default"/>
|
||||
<Property Common="True" Id="has-default"/>
|
||||
<Property Common="True" Id="can-focus"/>
|
||||
<!-- Not yet implemented
|
||||
<Property Common="TRUE" Id="events"/>
|
||||
<Property Common="True" Id="events"/>
|
||||
-->
|
||||
<Property Common="TRUE" Id="extension-events"/>
|
||||
<Property Common="True" Id="extension-events"/>
|
||||
|
||||
</Properties>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user