2014-02-11 12:16:39 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2014 - Juan Ferrer Toribio
|
|
|
|
*
|
|
|
|
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "glade-db-model-editor.h"
|
|
|
|
|
|
|
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++ GladeModelEditor
|
|
|
|
|
2014-07-09 14:16:30 +00:00
|
|
|
static void glade_model_editor_add_list_eprop (GladeModelEditor * obj,
|
2014-06-20 13:46:39 +00:00
|
|
|
GladeWidgetAdaptor * adaptor, const gchar * name, const gchar * tooltip)
|
2014-02-11 12:16:39 +00:00
|
|
|
{
|
|
|
|
GtkWidget * frame, * alignment, * vbox;
|
2014-06-20 13:46:39 +00:00
|
|
|
GladeEditorProperty * eprop =
|
|
|
|
glade_widget_adaptor_create_eprop_by_name (adaptor, name, FALSE, TRUE);
|
2014-07-07 15:00:21 +00:00
|
|
|
|
2014-02-11 12:16:39 +00:00
|
|
|
obj->props = g_list_prepend (obj->props, eprop);
|
|
|
|
|
|
|
|
frame = gtk_frame_new (NULL);
|
|
|
|
gtk_frame_set_label_widget (GTK_FRAME (frame),
|
|
|
|
glade_editor_property_get_item_label (eprop));
|
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
|
|
|
|
gtk_box_pack_start (GTK_BOX (obj), frame, FALSE, FALSE, 12);
|
|
|
|
|
|
|
|
alignment = gtk_alignment_new (0.5F, 0.5F, 1.0F, 1.0F);
|
|
|
|
gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 12, 0);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), alignment);
|
|
|
|
|
|
|
|
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
|
|
|
gtk_container_add (GTK_CONTAINER (alignment), vbox);
|
|
|
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (eprop), FALSE, FALSE, 4);
|
2014-06-20 13:46:39 +00:00
|
|
|
gtk_widget_set_tooltip_text (vbox, tooltip);
|
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget * glade_model_editor_new (GladeWidgetAdaptor * adaptor,
|
|
|
|
GladeEditable * editable)
|
|
|
|
{
|
|
|
|
GladeModelEditor * obj;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
|
|
|
|
g_return_val_if_fail (GLADE_IS_EDITABLE (editable), NULL);
|
|
|
|
|
|
|
|
obj = g_object_new (GLADE_TYPE_MODEL_EDITOR,
|
|
|
|
"orientation", GTK_ORIENTATION_VERTICAL, NULL);
|
|
|
|
obj->base = GTK_WIDGET (editable);
|
2014-07-09 14:16:30 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (obj), GTK_WIDGET (editable), TRUE, TRUE, 0);
|
2014-06-20 13:46:39 +00:00
|
|
|
|
2014-07-09 14:16:30 +00:00
|
|
|
glade_model_editor_add_list_eprop (obj, adaptor, "links",
|
2014-06-20 13:46:39 +00:00
|
|
|
_("List of parameters linked to the model"));
|
|
|
|
|
2014-07-09 14:16:30 +00:00
|
|
|
glade_model_editor_add_list_eprop (obj, adaptor, "batch",
|
2014-07-07 15:00:21 +00:00
|
|
|
_("List of SqlHolders and identifiers"));
|
2014-02-11 12:16:39 +00:00
|
|
|
|
|
|
|
gtk_widget_show_all (GTK_WIDGET (obj));
|
|
|
|
return GTK_WIDGET (obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void glade_model_editor_load (GladeEditable * editable, GladeWidget * widget)
|
|
|
|
{
|
|
|
|
GList *l;
|
|
|
|
GladeModelEditor * obj = GLADE_MODEL_EDITOR (editable);
|
|
|
|
GladeEditableIface * iface = g_type_default_interface_peek (GLADE_TYPE_EDITABLE);
|
|
|
|
iface->load (editable, widget);
|
|
|
|
|
|
|
|
if (obj->base)
|
|
|
|
glade_editable_load (GLADE_EDITABLE (obj->base), widget);
|
|
|
|
|
|
|
|
for (l = obj->props; l; l = l->next)
|
|
|
|
glade_editor_property_load_by_widget (GLADE_EDITOR_PROPERTY (l->data), widget);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void glade_model_editor_set_show_name (GladeEditable * editable, gboolean show_name)
|
|
|
|
{
|
2014-07-09 14:16:30 +00:00
|
|
|
GladeModelEditor * obj = GLADE_MODEL_EDITOR (editable);
|
|
|
|
glade_editable_set_show_name (GLADE_EDITABLE (obj->base), show_name);
|
2014-02-11 12:16:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void glade_model_editor_finalize (GObject * object)
|
|
|
|
{
|
|
|
|
GladeModelEditor * obj = GLADE_MODEL_EDITOR (object);
|
|
|
|
GObjectClass * parent = g_type_class_peek_parent (GLADE_MODEL_EDITOR_GET_CLASS (obj));
|
|
|
|
|
|
|
|
if (obj->props)
|
|
|
|
g_list_free (obj->props);
|
|
|
|
|
|
|
|
obj->props = NULL;
|
|
|
|
obj->base = NULL;
|
|
|
|
|
|
|
|
glade_editable_load (GLADE_EDITABLE (obj), NULL);
|
|
|
|
|
|
|
|
parent->finalize (G_OBJECT (obj));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void glade_model_editor_class_init (GladeModelEditorClass * k)
|
|
|
|
{
|
|
|
|
GObjectClass * klass = G_OBJECT_CLASS (k);
|
|
|
|
klass->finalize = glade_model_editor_finalize;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void glade_model_editor_init (GladeModelEditor * obj)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void glade_model_editor_editable_init (GladeEditableIface * iface)
|
|
|
|
{
|
|
|
|
iface->load = glade_model_editor_load;
|
|
|
|
iface->set_show_name = glade_model_editor_set_show_name;
|
|
|
|
}
|
|
|
|
|
2014-05-29 08:37:06 +00:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (GladeModelEditor, glade_model_editor, GTK_TYPE_BOX,
|
2014-02-11 12:16:39 +00:00
|
|
|
G_IMPLEMENT_INTERFACE (GLADE_TYPE_EDITABLE, glade_model_editor_editable_init));
|
|
|
|
|
|
|
|
//+++++++++++++++++++++++++++++++++++++++++++++++++++ GladeDbList
|
|
|
|
|
|
|
|
G_DEFINE_BOXED_TYPE (GladeDbList, glade_db_list, glade_db_list_copy, glade_db_list_free);
|
|
|
|
|
|
|
|
void glade_db_list_free (GladeDbList * list)
|
|
|
|
{
|
|
|
|
if (!list)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (list->list)
|
|
|
|
g_object_unref (list->list);
|
|
|
|
|
|
|
|
g_free (list);
|
|
|
|
list = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
GladeDbList * glade_db_list_copy (const GladeDbList * list)
|
|
|
|
{
|
|
|
|
GladeDbList * l = g_new (GladeDbList, 1);
|
|
|
|
l->list = list->list ? g_object_ref (list->list) : NULL;
|
|
|
|
return l;
|
|
|
|
}
|