Commit f25dd18f authored by Chema Celorio's avatar Chema Celorio Committed by Jose Maria Celorio
Browse files

check if g_module_supported is TRUE in here, if it isn't there is no point

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

	* src/main.c (glade_init): check if g_module_supported is TRUE
	in here, if it isn't there is no point in running glade2

	* src/glade.h (GLADE_TAG_SET_FUNCTION): add the new tags beeing
	used in the .xml files

	* src/glade-xml-utils.c (glade_xml_get_boolean): accept
	"TRUE" and "FALSE" as valid (before only "True" & "False")

	* src/glade-widget.c (glade_widget_button_press): return FLASE
	so that the emision continues (fixes clicking over items)
	(glade_widget_button_release): ditto

	* src/glade-widget-class.h: add the spec function prototypes

	* src/glade-widget-class.c (glade_widget_class_get_specs): move
	here from glade_propery_class.
	(glade_widget_class_find_spec): ditto
	(glade_widget_class_dump_param_specs): implement

	* src/glade-property.h: add the headers for the _double functions

	* src/glade-property.c (glade_property_new_from_string): handle
	double type
	(glade_property_changed_double): implement
	(glade_property_get_double): impl.

	* src/glade-property-class.h: add _TYPE_DOUBLE and _TYPE_OBJECT
	remove class->gtk_arg add class->id. Fixed the code all over
	to use ->id and ->name correctly.
	- add children for child objects and set_function to set properties
	that gtk is not exposing

	* src/glade-property-class.c: add frames for handling _TYPE_OBJECT
	no content tho
	(glade_property_get_parameter_numeric_default):
	(glade_property_get_parameter_numeric_min):
	(glade_property_get_parameter_numeric_max): impl.
	(glade_property_get_parameters_numeric): clean
	(glade_property_class_get_set_function): implement but not use yet
	cause I could not get it to work. Use glade_gtk_get_set_function_hack
	for now.
	(glade_property_class_new_from_node): change to reflect new changes
	in .xml format

	* src/glade-project-window.c (glade_project_window_query_properties):
	use ->id and not ->name

	* src/glade-placeholder.c (glade_placeholder_add): s/Size/size
	s/Rows/rows since we use class->id and not class->name

	* src/glade-parameter.c (glade_parameter_adjustment_new): make
	the increment 1 so that integers can be changed if the increment
	is not specified

	* src/glade-palette.c (glade_palette_init): set the policy of the
	pallete (which is a gtkwindow)

	* src/glade-editor.h: add GladeEditorNumericType to share functions
	that interact with numbers

	* src/glade-editor.c (glade_editor_property_changed_numeric): handle
	integers, floats and doubles. rename from _changed_integer
	(glade_editor_create_input): handle double
	(glade_editor_property_load_double): impl.

	* src/Makefile.am: add glade-gtk.[ch]

	* src/glade-property-class.c (glade_property_class_get_set_function):
	implement

	* widgets/gtk*.xml: clean lots of files, changed the format it is now
	a lot better.

	* src/glade-gtk.c (glade_gtk_entry_set_text): implement
	(glade_gtk_get_set_function_hack): implement a temp hack to find
	function pointers at run time, i could not make gmodule work.
parent 3358ff35
- Create a window, create a window (2), add a table to window 2 add anything else to the table
\ No newline at end of file
- Create a window, create a window (2), add a table to window 2 add anything else to the table
Missing Properties for gtk :
spinbutton:setvalue does not seem to work
gtkentry:text (or contents) not implemented
gtkadjustment not exposing any properties
\ No newline at end of file
2001-07-09 Chema Celorio <chema@celorio.com>
* src/main.c (glade_init): check if g_module_supported is TRUE
in here, if it isn't there is no point in running glade2
* src/glade.h (GLADE_TAG_SET_FUNCTION): add the new tags beeing
used in the .xml files
* src/glade-xml-utils.c (glade_xml_get_boolean): accept
"TRUE" and "FALSE" as valid (before only "True" & "False")
* src/glade-widget.c (glade_widget_button_press): return FLASE
so that the emision continues (fixes clicking over items)
(glade_widget_button_release): ditto
* src/glade-widget-class.h: add the spec function prototypes
* src/glade-widget-class.c (glade_widget_class_get_specs): move
here from glade_propery_class.
(glade_widget_class_find_spec): ditto
(glade_widget_class_dump_param_specs): implement
* src/glade-property.h: add the headers for the _double functions
* src/glade-property.c (glade_property_new_from_string): handle
double type
(glade_property_changed_double): implement
(glade_property_get_double): impl.
* src/glade-property-class.h: add _TYPE_DOUBLE and _TYPE_OBJECT
remove class->gtk_arg add class->id. Fixed the code all over
to use ->id and ->name correctly.
- add children for child objects and set_function to set properties
that gtk is not exposing
* src/glade-property-class.c: add frames for handling _TYPE_OBJECT
no content tho
(glade_property_get_parameter_numeric_default):
(glade_property_get_parameter_numeric_min):
(glade_property_get_parameter_numeric_max): impl.
(glade_property_get_parameters_numeric): clean
(glade_property_class_get_set_function): implement but not use yet
cause I could not get it to work. Use glade_gtk_get_set_function_hack
for now.
(glade_property_class_new_from_node): change to reflect new changes
in .xml format
* src/glade-project-window.c (glade_project_window_query_properties):
use ->id and not ->name
* src/glade-placeholder.c (glade_placeholder_add): s/Size/size
s/Rows/rows since we use class->id and not class->name
* src/glade-parameter.c (glade_parameter_adjustment_new): make
the increment 1 so that integers can be changed if the increment
is not specified
* src/glade-palette.c (glade_palette_init): set the policy of the
pallete (which is a gtkwindow)
* src/glade-editor.h: add GladeEditorNumericType to share functions
that interact with numbers
* src/glade-editor.c (glade_editor_property_changed_numeric): handle
integers, floats and doubles. rename from _changed_integer
(glade_editor_create_input): handle double
(glade_editor_property_load_double): impl.
* src/Makefile.am: add glade-gtk.[ch]
* src/glade-property-class.c (glade_property_class_get_set_function):
implement
* widgets/gtk*.xml: clean lots of files, changed the format it is now
a lot better.
* src/glade-gtk.c (glade_gtk_entry_set_text): implement
(glade_gtk_get_set_function_hack): implement a temp hack to find
function pointers at run time, i could not make gmodule work.
2001-07-07 Chema Celorio <chema@celorio.com>
* src/glade-widget.c (glade_widget_button_release): return FALSE so that
the propagation continues.
2001-07-05 Chema Celorio <chema@celorio.com>
* src/glade-property-class.c (glade_property_get_parameters_integer):
......
......@@ -38,6 +38,7 @@ glade2_SOURCES = \
glade-catalog.c \
glade-choice.c \
glade-editor.c \
glade-gtk.c \
glade-signal-editor.c
noinst_HEADERS = \
......@@ -58,5 +59,6 @@ noinst_HEADERS = \
glade-property-class.h \
glade-popup.h \
glade-choice.h \
glade-gtk.h \
glade-catalog.h \
glade-xml-utils.h
......@@ -293,33 +293,39 @@ glade_editor_property_changed_enabled (GtkWidget *button,
}
static void
glade_editor_property_changed_integer (GtkWidget *spin,
glade_editor_property_changed_numeric (GtkWidget *spin,
GladeEditorProperty *property)
{
gint val;
g_return_if_fail (property != NULL);
GladeEditorNumericType numeric_type;
gdouble double_val;
gfloat float_val;
gint integer_val;
if (property->loading)
return;
val = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (spin));
glade_property_changed_integer (property->property, val);
}
static void
glade_editor_property_changed_float (GtkWidget *spin,
GladeEditorProperty *property)
{
gfloat val;
g_return_if_fail (property != NULL);
if (property->loading)
return;
val = gtk_spin_button_get_value_as_float (GTK_SPIN_BUTTON (spin));
glade_property_changed_float (property->property, val);
numeric_type = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (spin), "NumericType"));
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);
break;
case GLADE_EDITOR_FLOAT:
g_print ("Changed numeric type float\n\n");
float_val = gtk_spin_button_get_value_as_float (GTK_SPIN_BUTTON (spin));
glade_property_changed_float (property->property, float_val);
break;
case GLADE_EDITOR_DOUBLE:
g_print ("Changed numeric typoe double\n");
double_val = (gdouble) gtk_spin_button_get_value_as_float (GTK_SPIN_BUTTON (spin));
glade_property_changed_double (property->property, double_val);
break;
default:
g_warning ("Invalid numeric_type %i\n", numeric_type);
}
}
static void
......@@ -461,7 +467,7 @@ glade_editor_create_input_text (GladeEditorProperty *property)
static GtkWidget *
glade_editor_create_input_numeric (GladeEditorProperty *property,
gboolean is_integer)
GladeEditorNumericType numeric_type)
{
GladePropertyClass *class;
GtkAdjustment *adjustment;
......@@ -472,18 +478,19 @@ glade_editor_create_input_numeric (GladeEditorProperty *property,
class = property->glade_property_class;
adjustment = glade_parameter_adjustment_new (class->parameters);
spin = gtk_spin_button_new (adjustment, 10, is_integer ? 0 : 2);
if (is_integer)
gtk_signal_connect (GTK_OBJECT (spin), "changed",
GTK_SIGNAL_FUNC (glade_editor_property_changed_integer),
property);
else
gtk_signal_connect (GTK_OBJECT (spin), "changed",
GTK_SIGNAL_FUNC (glade_editor_property_changed_float),
property);
spin = gtk_spin_button_new (adjustment, 10,
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",
GTK_SIGNAL_FUNC (glade_editor_property_changed_numeric),
property);
/* Some numeric types are optional, for example the default window size, so
* they have a toggle button right next to the spin button.
*/
if (class->optional) {
GtkWidget *check;
GtkWidget *hbox;
......@@ -504,13 +511,19 @@ glade_editor_create_input_numeric (GladeEditorProperty *property,
static GtkWidget *
glade_editor_create_input_integer (GladeEditorProperty *property)
{
return glade_editor_create_input_numeric (property, TRUE);
return glade_editor_create_input_numeric (property, GLADE_EDITOR_INTEGER);
}
static GtkWidget *
glade_editor_create_input_float (GladeEditorProperty *property)
{
return glade_editor_create_input_numeric (property, FALSE);
return glade_editor_create_input_numeric (property, GLADE_EDITOR_FLOAT);
}
static GtkWidget *
glade_editor_create_input_double (GladeEditorProperty *property)
{
return glade_editor_create_input_numeric (property, GLADE_EDITOR_DOUBLE);
}
static GtkWidget *
......@@ -531,7 +544,7 @@ glade_editor_create_input_boolean (GladeEditorProperty *property)
return button;
}
GtkWidget *
static GtkWidget *
glade_editor_create_input (GladeEditorProperty *property)
{
GladePropertyType type;
......@@ -551,6 +564,9 @@ glade_editor_create_input (GladeEditorProperty *property)
case GLADE_PROPERTY_TYPE_INTEGER:
input = glade_editor_create_input_integer (property);
break;
case GLADE_PROPERTY_TYPE_DOUBLE:
input = glade_editor_create_input_double (property);
break;
case GLADE_PROPERTY_TYPE_TEXT:
input = glade_editor_create_input_text (property);
break;
......@@ -560,7 +576,11 @@ glade_editor_create_input (GladeEditorProperty *property)
case GLADE_PROPERTY_TYPE_OTHER_WIDGETS:
g_warning ("The widget type %d does not have an input implemented\n", type);
break;
default:
case GLADE_PROPERTY_TYPE_OBJECT:
return gtk_label_new ("Implement object");
case GLADE_PROPERTY_TYPE_ERROR:
return gtk_label_new ("Error !");
}
if (input == NULL) {
......@@ -669,6 +689,10 @@ glade_editor_create_table_from_class (GladeEditor *editor,
GladeEditorProperty *editor_property;
property_class = (GladePropertyClass *) list->data;
/* Special cases */
label = glade_property_class_create_label (property_class);
if (label == NULL)
return NULL;
......@@ -835,7 +859,7 @@ glade_editor_property_load_integer (GladeEditorProperty *property)
spin = property->input;
}
val = atoi (property->property->value);
val = atof (property->property->value);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), val);
gtk_object_set_user_data (GTK_OBJECT (spin), property);
}
......@@ -851,6 +875,17 @@ glade_editor_property_load_float (GladeEditorProperty *property)
glade_editor_property_load_integer (property);
}
static void
glade_editor_property_load_double (GladeEditorProperty *property)
{
g_return_if_fail (property != NULL);
g_return_if_fail (property->property != NULL);
g_return_if_fail (property->property->value != NULL);
g_return_if_fail (property->input != NULL);
glade_editor_property_load_integer (property);
}
static void
glade_editor_property_load_choice (GladeEditorProperty *property)
......@@ -973,6 +1008,9 @@ glade_editor_property_load (GladeEditorProperty *property, GladeWidget *widget)
case GLADE_PROPERTY_TYPE_FLOAT:
glade_editor_property_load_float (property);
break;
case GLADE_PROPERTY_TYPE_DOUBLE:
glade_editor_property_load_double (property);
break;
case GLADE_PROPERTY_TYPE_INTEGER:
glade_editor_property_load_integer (property);
break;
......@@ -982,7 +1020,8 @@ glade_editor_property_load (GladeEditorProperty *property, GladeWidget *widget)
case GLADE_PROPERTY_TYPE_OTHER_WIDGETS:
glade_editor_property_load_other_widgets (property);
break;
default:
case GLADE_PROPERTY_TYPE_OBJECT:
case GLADE_PROPERTY_TYPE_ERROR:
g_warning ("%s : type %i not implemented\n", __FUNCTION__,
property_class->type);
}
......
......@@ -151,7 +151,13 @@ struct _GladeEditorProperty
* really changed, we just loaded a new glade widget
*/
};
typedef enum {
GLADE_EDITOR_INTEGER,
GLADE_EDITOR_FLOAT,
GLADE_EDITOR_DOUBLE,
}GladeEditorNumericType;
void glade_editor_create (GladeProjectWindow *gpw);
void glade_editor_show (GladeProjectWindow *gpw);
void glade_editor_select_widget (GladeEditor *editor, GladeWidget *widget);
......
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2001 Ximian, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* Authors:
* Chema Celorio <chema@celorio.com>
*/
/* This struct is used for a temp hack */
#include "glade.h"
#include "glade-property-class.h"
static void
glade_gtk_entry_set_text (GObject *object, const gchar *text)
{
gtk_entry_set_text (GTK_ENTRY (object), text);
}
/* ================ Temp hack =================== */
typedef struct _GladeGtkFunction GladeGtkFunction;
struct _GladeGtkFunction {
const gchar *name;
gpointer function;
};
GladeGtkFunction functions [] = {
{"glade_gtk_entry_set_text", &glade_gtk_entry_set_text},
{NULL, NULL},
};
gboolean
glade_gtk_get_set_function_hack (GladePropertyClass *class, const gchar *function_name)
{
gint num;
gint i;
num = sizeof (functions) / sizeof (GladeGtkFunction);
for (i = 0; i < num; i++) {
if (strcmp (function_name, functions[i].name) == 0)
break;
}
if (i == num) {
g_warning ("Could not find the function %s for %s\n",
function_name, class->name);
return FALSE;
}
class->set_function = functions[i].function;
return TRUE;
}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
#ifndef __GLADE_GTK_H__
#define __GLADE_GTK_H__
G_BEGIN_DECLS
gboolean glade_gtk_get_set_function_hack (GladePropertyClass *class, const gchar *function_name);
G_END_DECLS
#endif /* __GLADE_GTK_H__ */
......@@ -268,7 +268,11 @@ glade_palette_init (GladePalette * palette)
GtkWidget *widget;
gtk_window_set_title (GTK_WINDOW (palette), _("Palette"));
gtk_window_set_policy (GTK_WINDOW (palette),
TRUE,
FALSE,
TRUE);
palette->tooltips = gtk_tooltips_new ();
palette->widgets_button_group = NULL;
palette->sections_button_group = NULL;
......
......@@ -216,7 +216,7 @@ glade_parameter_adjustment_new (GList *parameters)
gfloat lower = 0;
gfloat upper = 999999;
gfloat step_increment = 0.01;
gfloat step_increment = 1;
gfloat page_increment = 265;
gfloat climb_rate = 1;
......@@ -226,7 +226,7 @@ glade_parameter_adjustment_new (GList *parameters)
glade_parameter_get_float (parameters, "StepIncrement", &step_increment);
glade_parameter_get_float (parameters, "PageIncrement", &page_increment);
glade_parameter_get_float (parameters, "ClimbRate", &climb_rate);
adjustment = GTK_ADJUSTMENT (gtk_adjustment_new (value,
lower,
upper,
......@@ -235,3 +235,4 @@ glade_parameter_adjustment_new (GList *parameters)
climb_rate));
return adjustment;
}
......@@ -284,7 +284,7 @@ glade_placeholder_add (GladeWidgetClass *class,
gint i;
gint size;
glade_property_query_result_get_int (result, "Size", &size);
glade_property_query_result_get_int (result, "size", &size);
for (i = 0; i < size; i++) {
placeholder = glade_placeholder_new (widget);
......@@ -296,10 +296,10 @@ glade_placeholder_add (GladeWidgetClass *class,
if ((strcmp (class->name, "GtkTable") == 0)) {
gint row, col;
gint rows, cols;
glade_property_query_result_get_int (result, "Rows", &rows);
glade_property_query_result_get_int (result, "Columns", &cols);
gint rows = 6, cols = 6;
glade_property_query_result_get_int (result, "rows", &rows);
glade_property_query_result_get_int (result, "columns", &cols);
for (row = 0; row < rows; row++) {
for (col = 0; col < cols; col++) {
......
......@@ -533,7 +533,7 @@ glade_project_window_query_properties (GladeWidgetClass *class,
property_class = list->data;
if (property_class->query) {
spin = glade_project_append_query (table, property_class, row++);
g_hash_table_insert (hash, property_class->name, spin);
g_hash_table_insert (hash, property_class->id, spin);
}
}
if (spin == NULL)
......
......@@ -29,7 +29,10 @@
#include "glade-parameter.h"
#include "glade-property.h"
#include "glade-property-class.h"
#include "glade-gtk.h"
#include <string.h>
#include <gmodule.h>
GladePropertyType
glade_property_type_str_to_enum (const gchar *str)
......@@ -46,14 +49,16 @@ glade_property_type_str_to_enum (const gchar *str)
return GLADE_PROPERTY_TYPE_CHOICE;
if (strcmp (str, GLADE_TAG_OTHER_WIDGETS) == 0)
return GLADE_PROPERTY_TYPE_OTHER_WIDGETS;
if (strcmp (str, GLADE_TAG_OBJECT) == 0)
return GLADE_PROPERTY_TYPE_OBJECT;
g_warning ("Could not determine the property type from *%s*\n", str);
return GLADE_PROPERTY_TYPE_ERROR;
}
const gchar *
glade_property_type_enum_to_str (GladePropertyType type)
gchar *
glade_property_type_enum_to_string (GladePropertyType type)
{
switch (type) {
case GLADE_PROPERTY_TYPE_TEXT:
......@@ -64,12 +69,16 @@ glade_property_type_enum_to_str (GladePropertyType type)
return GLADE_TAG_FLOAT;
case GLADE_PROPERTY_TYPE_INTEGER:
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_OTHER_WIDGETS:
return GLADE_TAG_OTHER_WIDGETS;
default:
break;
case GLADE_PROPERTY_TYPE_OBJECT:
return GLADE_TAG_OBJECT;
case GLADE_PROPERTY_TYPE_ERROR:
return NULL;
}
return NULL;
......@@ -115,72 +124,18 @@ glade_property_class_new (void)
property_class = g_new0 (GladePropertyClass, 1);
property_class->type = GLADE_PROPERTY_TYPE_ERROR;
property_class->id = NULL;
property_class->name = NULL;
property_class->tooltip = NULL;
property_class->gtk_arg = NULL;
property_class->parameters = NULL;
property_class->choices = NULL;
property_class->optional = FALSE;
property_class->query = NULL;
property_class->set_function = NULL;
return property_class;
}
static void
glade_property_class_get_specs (GladeWidgetClass *class, GParamSpec ***specs, gint *n_specs)
{
GObjectClass *object_class;
GType type;
type = glade_widget_class_get_type (class);
g_type_class_ref (type); /* hmm */
/* We count on the fact we have an instance, or else we'd have
* touse g_type_class_ref ();
*/
object_class = g_type_class_peek (type);
if (object_class == NULL) {
g_warning ("Class peek failed\n");
*specs = NULL;
*n_specs = 0;
return;
}
*specs = g_object_class_list_properties (object_class, n_specs);
}
GParamSpec *
glade_property_class_find_spec (GladeWidgetClass *class, const gchar *name)
{
GParamSpec **specs = NULL;
GParamSpec *spec;
gint n_specs = 0;
gint i;
glade_property_class_get_specs (class, &specs, &n_specs);
#if 0
g_print ("Dumping specs for %s\n\n", class->name);
for (i = 0; i < n_specs; i++) {
spec = specs[i];
g_print ("%02d - %s\n", i, spec->name);
}
#endif
for (i = 0; i < n_specs; i++) {
spec = specs[i];
if (!spec || !spec->name) {
g_warning ("Spec does not have a valid name, or invalid spec");
return NULL;
}
if (strcmp (spec->name, name) == 0)
return spec;
}
return NULL;
}
static GladePropertyType
glade_property_class_get_type_from_spec (GParamSpec *spec)
......@@ -199,8 +154,7 @@ glade_property_class_get_type_from_spec (GParamSpec *spec)
case G_TYPE_PARAM_ENUM:
return GLADE_PROPERTY_TYPE_CHOICE;
case G_TYPE_PARAM_DOUBLE:
g_warning ("Double not implemented\n");
break;
return GLADE_PROPERTY_TYPE_DOUBLE;
case G_TYPE_PARAM_LONG:
g_warning ("Long not implemented\n");
break;
......@@ -269,26 +223,95 @@ glade_property_get_parameters_boolean (GParamSpec *spec,
return g_list_prepend (NULL, parameter);
}
static GList *
glade_property_get_parameters_integer (GParamSpec *spec,
GladePropertyClass *class)
static gchar *