New editor to group the treeview and model together in the base editor

* plugins/gtk+/Makefile.am, plugins/gtk+/glade-treeview-editor.[ch]: New editor to group
	  the treeview and model together in the base editor treeview editor

	* gladeui/glade-editor-table.c: 
	  - Load propertes up a realize time (some sizes need negotiation when loaded editables
	    are going into dialogs that are not yet on screen).


svn path=/trunk/; revision=2041
This commit is contained in:
Tristan Van Berkom 2008-11-22 22:17:16 +00:00
parent 735576a9c2
commit 6d8d9fadf6
10 changed files with 414 additions and 16 deletions

View File

@ -5,8 +5,14 @@
- Added glade_base_editor_append_types(), glade_base_editor_new() now - Added glade_base_editor_append_types(), glade_base_editor_new() now
only adds types supported by the container object, use _append_types() to only adds types supported by the container object, use _append_types() to
define hierarcic type relations for children. define hierarcic type relations for children.
- Added "main_editable" optional argument to glade_base_editor_new(), the editor
now contains a main page with the provided editable, or creates a general editable
for the container for the general page.
* gladeui/glade-editor-table.c: Fixed a warning hiding a never built label * gladeui/glade-editor-table.c:
- Fixed a warning hiding a never built label
- Load propertes up a realize time (some sizes need negotiation when loaded editables
are going into dialogs that are not yet on screen).
* plugins/gtk+/gtk+.xml.in, plugins/gtk+/glade-gtk.c: * plugins/gtk+/gtk+.xml.in, plugins/gtk+/glade-gtk.c:
- Now the toolbar editor can add menus and edit menus inside the gtkmenutoolbutton - Now the toolbar editor can add menus and edit menus inside the gtkmenutoolbutton
@ -15,6 +21,9 @@
hierarchy and do it all in the editor, added position packing property to treeview hierarchy and do it all in the editor, added position packing property to treeview
column for this (treeview column still implemented generically as a cell layout). column for this (treeview column still implemented generically as a cell layout).
* plugins/gtk+/Makefile.am, plugins/gtk+/glade-treeview-editor.[ch]: New editor to group
the treeview and model together in the base editor treeview editor
2008-11-20 Tristan Van Berkom <tvb@gnome.org> 2008-11-20 Tristan Van Berkom <tvb@gnome.org>
* plugins/gtk+/gtk+.xml.in: Added all remaining metadatas for cell renderers * plugins/gtk+/gtk+.xml.in: Added all remaining metadatas for cell renderers

View File

@ -67,7 +67,7 @@ struct _GladeBaseEditorPrivate
GladeWidget *gcontainer; /* The container we are editing */ GladeWidget *gcontainer; /* The container we are editing */
/* Editor UI */ /* Editor UI */
GtkWidget *paned, *table, *treeview; GtkWidget *paned, *table, *treeview, *main_scroll, *notebook;
GtkWidget *remove_button, *signal_editor_w; GtkWidget *remove_button, *signal_editor_w;
GladeSignalEditor *signal_editor; GladeSignalEditor *signal_editor;
@ -1571,16 +1571,39 @@ glade_base_editor_init (GladeBaseEditor *editor)
GladeBaseEditorPrivate *e; GladeBaseEditorPrivate *e;
GtkCellRenderer *renderer; GtkCellRenderer *renderer;
GtkTreeViewColumn *column; GtkTreeViewColumn *column;
GtkWidget *paned, *hbox, *vbox, *tree_vbox, *scroll, *button_table, *button; GtkWidget *paned, *hbox, *vbox, *tree_vbox, *scroll, *button_table, *button, *label;
gtk_box_set_spacing (GTK_BOX (editor), 8); gtk_box_set_spacing (GTK_BOX (editor), 8);
e = editor->priv = g_new0(GladeBaseEditorPrivate, 1); e = editor->priv = g_new0(GladeBaseEditorPrivate, 1);
/* Notebook */
e->notebook = gtk_notebook_new ();
gtk_widget_show (e->notebook);
gtk_box_pack_start (GTK_BOX (editor), e->notebook, TRUE, TRUE, 0);
/* Properties Vbox */
vbox = gtk_vbox_new (FALSE, 8);
gtk_widget_show (vbox);
/* ScrolledWindow */
e->main_scroll = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_show (e->main_scroll);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (e->main_scroll), GTK_SHADOW_NONE);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (e->main_scroll), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
gtk_box_pack_start (GTK_BOX (vbox), e->main_scroll, TRUE, TRUE, 0);
label = gtk_label_new (_("General"));
gtk_widget_show (label);
gtk_notebook_append_page (GTK_NOTEBOOK (e->notebook), vbox, label);
/* Paned */ /* Paned */
e->paned = paned = gtk_vpaned_new (); e->paned = paned = gtk_vpaned_new ();
gtk_widget_show (paned); gtk_widget_show (paned);
gtk_box_pack_start (GTK_BOX (editor), paned, TRUE, TRUE, 0);
label = gtk_label_new (_("Hierarchy"));
gtk_widget_show (label);
gtk_notebook_append_page (GTK_NOTEBOOK (e->notebook), e->paned, label);
/* Hbox */ /* Hbox */
hbox = gtk_hbox_new (FALSE, 8); hbox = gtk_hbox_new (FALSE, 8);
@ -1595,7 +1618,7 @@ glade_base_editor_init (GladeBaseEditor *editor)
/* ScrolledWindow */ /* ScrolledWindow */
scroll = gtk_scrolled_window_new (NULL, NULL); scroll = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_show (scroll); gtk_widget_show (scroll);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll), GTK_SHADOW_IN); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll), GTK_SHADOW_NONE);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
gtk_box_pack_start (GTK_BOX (tree_vbox), scroll, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (tree_vbox), scroll, TRUE, TRUE, 0);
@ -1717,7 +1740,8 @@ glade_base_editor_get_type ()
/** /**
* glade_base_editor_new: * glade_base_editor_new:
* @container: the container this new editor will edit. * @container: a container this new editor will edit.
* @main_editable: the custom #GladeEditable for @container, or %NULL
* @... A NULL terminated list of gchar *, GType * @... A NULL terminated list of gchar *, GType
* *
* Creates a new GladeBaseEditor with @container toplevel * Creates a new GladeBaseEditor with @container toplevel
@ -1729,9 +1753,12 @@ glade_base_editor_get_type ()
* Returns: a new GladeBaseEditor. * Returns: a new GladeBaseEditor.
*/ */
GladeBaseEditor * GladeBaseEditor *
glade_base_editor_new (GObject *container, ...) glade_base_editor_new (GObject *container,
GladeEditable *main_editable,
...)
{ {
ChildTypeTab *child_type; ChildTypeTab *child_type;
GladeWidget *gcontainer;
GladeBaseEditor *editor; GladeBaseEditor *editor;
GladeBaseEditorPrivate *e; GladeBaseEditorPrivate *e;
GtkTreeIter iter; GtkTreeIter iter;
@ -1740,6 +1767,10 @@ glade_base_editor_new (GObject *container, ...)
va_list args; va_list args;
g_return_val_if_fail (GTK_IS_CONTAINER (container), NULL); g_return_val_if_fail (GTK_IS_CONTAINER (container), NULL);
gcontainer = glade_widget_get_from_gobject (container);
g_return_val_if_fail (GLADE_IS_WIDGET (gcontainer), NULL);
editor = GLADE_BASE_EDITOR (g_object_new (GLADE_TYPE_BASE_EDITOR, NULL)); editor = GLADE_BASE_EDITOR (g_object_new (GLADE_TYPE_BASE_EDITOR, NULL));
e = editor->priv; e = editor->priv;
@ -1759,12 +1790,20 @@ glade_base_editor_new (GObject *container, ...)
G_CALLBACK (glade_base_editor_row_inserted), G_CALLBACK (glade_base_editor_row_inserted),
editor); editor);
/* Invent one if not provided */
if (!main_editable)
main_editable = glade_widget_adaptor_create_editable (gcontainer->adaptor, GLADE_PAGE_GENERAL);
glade_editable_load (main_editable, gcontainer);
gtk_widget_show (GTK_WIDGET (main_editable));
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (e->main_scroll), GTK_WIDGET (main_editable));
child_type = g_new0 (ChildTypeTab, 1); child_type = g_new0 (ChildTypeTab, 1);
child_type->parent_type = G_OBJECT_TYPE (container); child_type->parent_type = G_OBJECT_TYPE (container);
child_type->children = (GtkTreeModel *)gtk_list_store_new (GLADE_BASE_EDITOR_TYPES_N_COLUMNS, child_type->children = (GtkTreeModel *)gtk_list_store_new (GLADE_BASE_EDITOR_TYPES_N_COLUMNS,
G_TYPE_GTYPE, G_TYPE_STRING); G_TYPE_GTYPE, G_TYPE_STRING);
va_start (args, container); va_start (args, main_editable);
while ((name = va_arg (args, gchar *))) while ((name = va_arg (args, gchar *)))
{ {
iter_type = va_arg (args, GType); iter_type = va_arg (args, GType);
@ -2105,6 +2144,7 @@ glade_base_editor_pack_new_window (GladeBaseEditor *editor,
G_CALLBACK (glade_utils_hijack_key_press), NULL); G_CALLBACK (glade_utils_hijack_key_press), NULL);
} }
gtk_widget_show_all (GTK_WIDGET (editor));
gtk_container_set_border_width (GTK_CONTAINER (editor), 6); gtk_container_set_border_width (GTK_CONTAINER (editor), 6);
gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (editor)); gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (editor));

View File

@ -62,6 +62,7 @@ struct _GladeBaseEditorClass
GType glade_base_editor_get_type (void); GType glade_base_editor_get_type (void);
GladeBaseEditor *glade_base_editor_new (GObject *container, GladeBaseEditor *glade_base_editor_new (GObject *container,
GladeEditable *main_editable,
...); ...);
void glade_base_editor_append_types (GladeBaseEditor *editor, void glade_base_editor_append_types (GladeBaseEditor *editor,

View File

@ -3168,6 +3168,8 @@ glade_eprop_adjustment_load (GladeEditorProperty *eprop, GladeProperty *property
fmt = glade_project_get_format (property->widget->project); fmt = glade_project_get_format (property->widget->project);
gtk_widget_hide (eprop_adj->libglade);
if (fmt == GLADE_PROJECT_FORMAT_LIBGLADE) if (fmt == GLADE_PROJECT_FORMAT_LIBGLADE)
{ {
object = g_value_get_object (property->value); object = g_value_get_object (property->value);
@ -3234,7 +3236,6 @@ glade_eprop_adjustment_load (GladeEditorProperty *eprop, GladeProperty *property
gtk_entry_set_text (GTK_ENTRY (eprop_adj->entry), ""); gtk_entry_set_text (GTK_ENTRY (eprop_adj->entry), "");
gtk_notebook_set_page (GTK_NOTEBOOK (eprop_adj->notebook), 1); gtk_notebook_set_page (GTK_NOTEBOOK (eprop_adj->notebook), 1);
gtk_widget_hide (eprop_adj->libglade);
} }
gtk_widget_queue_resize (eprop_adj->notebook); gtk_widget_queue_resize (eprop_adj->notebook);

View File

@ -30,6 +30,7 @@ static void glade_editor_table_init (GladeEditorTable *s
static void glade_editor_table_class_init (GladeEditorTableClass *klass); static void glade_editor_table_class_init (GladeEditorTableClass *klass);
static void glade_editor_table_dispose (GObject *object); static void glade_editor_table_dispose (GObject *object);
static void glade_editor_table_editable_init (GladeEditableIface *iface); static void glade_editor_table_editable_init (GladeEditableIface *iface);
static void glade_editor_table_realize (GtkWidget *widget);
static void glade_editor_table_grab_focus (GtkWidget *widget); static void glade_editor_table_grab_focus (GtkWidget *widget);
G_DEFINE_TYPE_WITH_CODE (GladeEditorTable, glade_editor_table, GTK_TYPE_TABLE, G_DEFINE_TYPE_WITH_CODE (GladeEditorTable, glade_editor_table, GTK_TYPE_TABLE,
@ -43,6 +44,7 @@ glade_editor_table_class_init (GladeEditorTableClass *klass)
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->dispose = glade_editor_table_dispose; object_class->dispose = glade_editor_table_dispose;
widget_class->realize = glade_editor_table_realize;
widget_class->grab_focus = glade_editor_table_grab_focus; widget_class->grab_focus = glade_editor_table_grab_focus;
} }
@ -71,6 +73,23 @@ glade_editor_table_dispose (GObject *object)
} }
static void
glade_editor_table_realize (GtkWidget *widget)
{
GladeEditorTable *table = GLADE_EDITOR_TABLE (widget);
GList *list;
GladeEditorProperty *property;
GTK_WIDGET_CLASS (glade_editor_table_parent_class)->realize (widget);
/* Sync up properties, even if widget is NULL */
for (list = table->properties; list; list = list->next)
{
property = list->data;
glade_editor_property_load_by_widget (property, table->loaded_widget);
}
}
static void static void
glade_editor_table_grab_focus (GtkWidget *widget) glade_editor_table_grab_focus (GtkWidget *widget)
{ {
@ -201,7 +220,7 @@ glade_editor_table_attach (GladeEditorTable *table,
gtk_table_attach (GTK_TABLE (table), child, gtk_table_attach (GTK_TABLE (table), child,
pos, pos+1, row, row +1, pos, pos+1, row, row +1,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL,
GTK_EXPAND | GTK_FILL, 0,
3, 1); 3, 1);
} }

View File

@ -27,7 +27,7 @@ libgladegtk_la_SOURCES = glade-gtk.c glade-accels.c glade-attributes.c glade
glade-column-types.c glade-model-data.c glade-text-button.c glade-cell-renderer-button.c \ glade-column-types.c glade-model-data.c glade-text-button.c glade-cell-renderer-button.c \
glade-icon-sources.c glade-button-editor.c glade-tool-button-editor.c glade-image-editor.c \ glade-icon-sources.c glade-button-editor.c glade-tool-button-editor.c glade-image-editor.c \
glade-image-item-editor.c glade-icon-factory-editor.c glade-store-editor.c glade-label-editor.c \ glade-image-item-editor.c glade-icon-factory-editor.c glade-store-editor.c glade-label-editor.c \
glade-cell-renderer-editor.c glade-cell-renderer-editor.c glade-treeview-editor.c
libgladegtk_la_LDFLAGS = -module -avoid-version $(AM_LDFLAGS) libgladegtk_la_LDFLAGS = -module -avoid-version $(AM_LDFLAGS)
libgladegtk_la_LIBADD = $(libgladeui) $(GTK_LIBS) libgladegtk_la_LIBADD = $(libgladeui) $(GTK_LIBS)
@ -36,7 +36,7 @@ libgladegtkincludedir= $(includedir)/libgladeui-1.0/gladeui
libgladegtkinclude_HEADERS = glade-gtk.h glade-accels.h glade-attributes.h glade-column-types.h glade-model-data.h \ libgladegtkinclude_HEADERS = glade-gtk.h glade-accels.h glade-attributes.h glade-column-types.h glade-model-data.h \
glade-text-button.h glade-cell-renderer-button.h glade-icon-sources.h glade-button-editor.h \ glade-text-button.h glade-cell-renderer-button.h glade-icon-sources.h glade-button-editor.h \
glade-tool-button-editor.h glade-image-editor.h glade-image-item-editor.h glade-icon-factory-editor.h \ glade-tool-button-editor.h glade-image-editor.h glade-image-item-editor.h glade-icon-factory-editor.h \
glade-store-editor.h glade-label-editor.h glade-cell-renderer-editor.h glade-store-editor.h glade-label-editor.h glade-cell-renderer-editor.h glade-treeview-editor.h
if PLATFORM_WIN32 if PLATFORM_WIN32
libgladegtk_la_LDFLAGS += -no-undefined libgladegtk_la_LDFLAGS += -no-undefined

View File

@ -39,6 +39,7 @@
#include "glade-store-editor.h" #include "glade-store-editor.h"
#include "glade-label-editor.h" #include "glade-label-editor.h"
#include "glade-cell-renderer-editor.h" #include "glade-cell-renderer-editor.h"
#include "glade-treeview-editor.h"
#include <gladeui/glade-editor-property.h> #include <gladeui/glade-editor-property.h>
#include <gladeui/glade-base-editor.h> #include <gladeui/glade-base-editor.h>
@ -5998,7 +5999,7 @@ glade_gtk_menu_shell_launch_editor (GObject *object, gchar *title)
GtkWidget *window; GtkWidget *window;
/* Editor */ /* Editor */
editor = glade_base_editor_new (object, editor = glade_base_editor_new (object, NULL,
_("Normal item"), GTK_TYPE_MENU_ITEM, _("Normal item"), GTK_TYPE_MENU_ITEM,
_("Image item"), GTK_TYPE_IMAGE_MENU_ITEM, _("Image item"), GTK_TYPE_IMAGE_MENU_ITEM,
_("Check item"), GTK_TYPE_CHECK_MENU_ITEM, _("Check item"), GTK_TYPE_CHECK_MENU_ITEM,
@ -6956,7 +6957,7 @@ glade_gtk_toolbar_launch_editor (GladeWidgetAdaptor *adaptor,
GtkWidget *window; GtkWidget *window;
/* Editor */ /* Editor */
editor = glade_base_editor_new (toolbar, editor = glade_base_editor_new (toolbar, NULL,
_("Button"), GTK_TYPE_TOOL_BUTTON, _("Button"), GTK_TYPE_TOOL_BUTTON,
_("Toggle"), GTK_TYPE_TOGGLE_TOOL_BUTTON, _("Toggle"), GTK_TYPE_TOGGLE_TOOL_BUTTON,
_("Radio"), GTK_TYPE_RADIO_TOOL_BUTTON, _("Radio"), GTK_TYPE_RADIO_TOOL_BUTTON,
@ -9452,11 +9453,17 @@ glade_gtk_treeview_move_child (GladeBaseEditor *editor,
static void static void
glade_gtk_treeview_launch_editor (GObject *treeview) glade_gtk_treeview_launch_editor (GObject *treeview)
{ {
GladeWidget *widget = glade_widget_get_from_gobject (treeview);
GladeBaseEditor *editor; GladeBaseEditor *editor;
GladeEditable *treeview_editor;
GtkWidget *window; GtkWidget *window;
treeview_editor = glade_widget_adaptor_create_editable (widget->adaptor, GLADE_PAGE_GENERAL);
treeview_editor = (GladeEditable *)glade_tree_view_editor_new (widget->adaptor, treeview_editor);
/* Editor */ /* Editor */
editor = glade_base_editor_new (treeview, editor = glade_base_editor_new (treeview, treeview_editor,
_("Column"), GTK_TYPE_TREE_VIEW_COLUMN, _("Column"), GTK_TYPE_TREE_VIEW_COLUMN,
NULL); NULL);
@ -10073,7 +10080,7 @@ glade_gtk_cell_layout_set_child_property (GladeWidgetAdaptor *adaptor,
if (strcmp (property_name, "position") == 0) if (strcmp (property_name, "position") == 0)
{ {
/* Need verify on position property !!! XXX */ /* Need verify on position property !!! XXX */
gtk_cell_layout_reorder (GTK_CELL_LAYOUT (container), child, gtk_cell_layout_reorder (GTK_CELL_LAYOUT (container), GTK_CELL_RENDERER (child),
g_value_get_int (value)); g_value_get_int (value));
} }
else else

View File

@ -0,0 +1,258 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2008 Tristan Van Berkom.
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Authors:
* Tristan Van Berkom <tvb@gnome.org>
*/
#include <config.h>
#include <gladeui/glade.h>
#include <glib/gi18n-lib.h>
#include <gdk/gdkkeysyms.h>
#include "glade-treeview-editor.h"
static void glade_tree_view_editor_finalize (GObject *object);
static void glade_tree_view_editor_editable_init (GladeEditableIface *iface);
static void glade_tree_view_editor_realize (GtkWidget *widget);
static void glade_tree_view_editor_grab_focus (GtkWidget *widget);
G_DEFINE_TYPE_WITH_CODE (GladeTreeViewEditor, glade_tree_view_editor, GTK_TYPE_HBOX,
G_IMPLEMENT_INTERFACE (GLADE_TYPE_EDITABLE,
glade_tree_view_editor_editable_init));
static void
glade_tree_view_editor_class_init (GladeTreeViewEditorClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->finalize = glade_tree_view_editor_finalize;
widget_class->realize = glade_tree_view_editor_realize;
widget_class->grab_focus = glade_tree_view_editor_grab_focus;
}
static void
glade_tree_view_editor_init (GladeTreeViewEditor *self)
{
}
static void
project_changed (GladeProject *project,
GladeCommand *command,
gboolean execute,
GladeTreeViewEditor *view_editor)
{
if (!GTK_WIDGET_MAPPED (view_editor))
return;
/* Reload on all commands */
glade_editable_load (GLADE_EDITABLE (view_editor), view_editor->loaded_widget);
}
static void
project_finalized (GladeTreeViewEditor *view_editor,
GladeProject *where_project_was)
{
view_editor->loaded_widget = NULL;
glade_editable_load (GLADE_EDITABLE (view_editor), NULL);
}
static GladeWidget *
get_model_widget (GladeWidget *view)
{
GtkTreeView *treeview = GTK_TREE_VIEW (view->object);
GtkTreeModel *model = gtk_tree_view_get_model (treeview);
if (model)
return glade_widget_get_from_gobject (model);
return NULL;
}
static void
glade_tree_view_editor_load (GladeEditable *editable,
GladeWidget *widget)
{
GladeTreeViewEditor *view_editor = GLADE_TREE_VIEW_EDITOR (editable);
GladeWidget *model_widget;
/* Since we watch the project*/
if (view_editor->loaded_widget)
{
g_signal_handlers_disconnect_by_func (G_OBJECT (view_editor->loaded_widget->project),
G_CALLBACK (project_changed), view_editor);
/* The widget could die unexpectedly... */
g_object_weak_unref (G_OBJECT (view_editor->loaded_widget->project),
(GWeakNotify)project_finalized,
view_editor);
}
/* Mark our widget... */
view_editor->loaded_widget = widget;
if (view_editor->loaded_widget)
{
/* This fires for undo/redo */
g_signal_connect (G_OBJECT (view_editor->loaded_widget->project), "changed",
G_CALLBACK (project_changed), view_editor);
/* The widget/project could die unexpectedly... */
g_object_weak_ref (G_OBJECT (view_editor->loaded_widget->project),
(GWeakNotify)project_finalized,
view_editor);
}
/* load the embedded editable... */
if (view_editor->embed)
glade_editable_load (GLADE_EDITABLE (view_editor->embed), widget);
if (view_editor->embed_list_store && view_editor->embed_tree_store)
{
gtk_widget_hide (view_editor->no_model_message);
gtk_widget_hide (view_editor->embed_list_store);
gtk_widget_hide (view_editor->embed_tree_store);
glade_editable_load (GLADE_EDITABLE (view_editor->embed_list_store), NULL);
glade_editable_load (GLADE_EDITABLE (view_editor->embed_tree_store), NULL);
/* Finalize safe code here... */
if (widget && (model_widget = get_model_widget (widget)))
{
if (GTK_IS_LIST_STORE (model_widget->object))
{
gtk_widget_show (view_editor->embed_list_store);
glade_editable_load (GLADE_EDITABLE (view_editor->embed_list_store), model_widget);
}
else if (GTK_IS_TREE_STORE (model_widget->object))
{
gtk_widget_show (view_editor->embed_tree_store);
glade_editable_load (GLADE_EDITABLE (view_editor->embed_tree_store), model_widget);
}
else
gtk_widget_show (view_editor->no_model_message);
}
else
gtk_widget_show (view_editor->no_model_message);
}
}
static void
glade_tree_view_editor_set_show_name (GladeEditable *editable,
gboolean show_name)
{
GladeTreeViewEditor *view_editor = GLADE_TREE_VIEW_EDITOR (editable);
glade_editable_set_show_name (GLADE_EDITABLE (view_editor->embed), show_name);
}
static void
glade_tree_view_editor_editable_init (GladeEditableIface *iface)
{
iface->load = glade_tree_view_editor_load;
iface->set_show_name = glade_tree_view_editor_set_show_name;
}
static void
glade_tree_view_editor_finalize (GObject *object)
{
GladeTreeViewEditor *view_editor = GLADE_TREE_VIEW_EDITOR (object);
view_editor->embed_tree_store = NULL;
view_editor->embed_list_store = NULL;
view_editor->embed = NULL;
glade_editable_load (GLADE_EDITABLE (object), NULL);
G_OBJECT_CLASS (glade_tree_view_editor_parent_class)->finalize (object);
}
static void
glade_tree_view_editor_realize (GtkWidget *widget)
{
GladeTreeViewEditor *view_editor = GLADE_TREE_VIEW_EDITOR (widget);
GTK_WIDGET_CLASS (glade_tree_view_editor_parent_class)->realize (widget);
glade_editable_load (GLADE_EDITABLE (view_editor), view_editor->loaded_widget);
}
static void
glade_tree_view_editor_grab_focus (GtkWidget *widget)
{
GladeTreeViewEditor *view_editor = GLADE_TREE_VIEW_EDITOR (widget);
gtk_widget_grab_focus (view_editor->embed);
}
GtkWidget *
glade_tree_view_editor_new (GladeWidgetAdaptor *adaptor,
GladeEditable *embed)
{
GladeTreeViewEditor *view_editor;
GtkWidget *vbox, *separator;
gchar *str;
g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
g_return_val_if_fail (GLADE_IS_EDITABLE (embed), NULL);
view_editor = g_object_new (GLADE_TYPE_TREE_VIEW_EDITOR, NULL);
view_editor->embed = GTK_WIDGET (embed);
/* Pack the parent on the left... */
gtk_box_pack_start (GTK_BOX (view_editor), GTK_WIDGET (embed), TRUE, TRUE, 8);
separator = gtk_vseparator_new ();
gtk_box_pack_start (GTK_BOX (view_editor), separator, FALSE, FALSE, 0);
/* ...and the vbox with datastore/label on the right */
vbox = gtk_vbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (view_editor), vbox, FALSE, FALSE, 8);
str = g_strdup_printf ("<b>%s</b>", _("Choose a Tree Model and define some\n"
"columns in the data store first"));
view_editor->no_model_message = gtk_label_new (str);
gtk_label_set_use_markup (GTK_LABEL (view_editor->no_model_message), TRUE);
gtk_label_set_justify (GTK_LABEL (view_editor->no_model_message), GTK_JUSTIFY_CENTER);
g_free (str);
gtk_box_pack_start (GTK_BOX (vbox), view_editor->no_model_message, TRUE, TRUE, 0);
view_editor->embed_list_store = (GtkWidget *)glade_widget_adaptor_create_editable
(glade_widget_adaptor_get_by_type (GTK_TYPE_LIST_STORE), GLADE_PAGE_GENERAL);
glade_editable_set_show_name (GLADE_EDITABLE (view_editor->embed_list_store), FALSE);
gtk_box_pack_start (GTK_BOX (vbox), view_editor->embed_list_store, TRUE, TRUE, 0);
view_editor->embed_tree_store = (GtkWidget *)glade_widget_adaptor_create_editable
(glade_widget_adaptor_get_by_type (GTK_TYPE_TREE_STORE), GLADE_PAGE_GENERAL);
glade_editable_set_show_name (GLADE_EDITABLE (view_editor->embed_tree_store), FALSE);
gtk_box_pack_start (GTK_BOX (vbox), view_editor->embed_tree_store, TRUE, TRUE, 0);
gtk_widget_show_all (GTK_WIDGET (view_editor));
return GTK_WIDGET (view_editor);
}

View File

@ -0,0 +1,62 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2008 Tristan Van Berkom.
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Authors:
* Tristan Van Berkom <tvb@gnome.org>
*/
#ifndef _GLADE_TREE_VIEW_EDITOR_H_
#define _GLADE_TREE_VIEW_EDITOR_H_
#include <gtk/gtk.h>
G_BEGIN_DECLS
#define GLADE_TYPE_TREE_VIEW_EDITOR (glade_tree_view_editor_get_type ())
#define GLADE_TREE_VIEW_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GLADE_TYPE_TREE_VIEW_EDITOR, GladeTreeViewEditor))
#define GLADE_TREE_VIEW_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GLADE_TYPE_TREE_VIEW_EDITOR, GladeTreeViewEditorClass))
#define GLADE_IS_TREE_VIEW_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_TREE_VIEW_EDITOR))
#define GLADE_IS_TREE_VIEW_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_TREE_VIEW_EDITOR))
#define GLADE_TREE_VIEW_EDITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GLADE_TYPE_TREE_VIEW_EDITOR, GladeTreeViewEditorClass))
typedef struct _GladeTreeViewEditor GladeTreeViewEditor;
typedef struct _GladeTreeViewEditorClass GladeTreeViewEditorClass;
struct _GladeTreeViewEditor
{
GtkHBox parent;
GladeWidget *loaded_widget; /* A handy pointer to the loaded widget ... */
GtkWidget *embed;
GtkWidget *embed_list_store;
GtkWidget *embed_tree_store;
GtkWidget *no_model_message;
};
struct _GladeTreeViewEditorClass
{
GtkVBoxClass parent;
};
GType glade_tree_view_editor_get_type (void) G_GNUC_CONST;
GtkWidget *glade_tree_view_editor_new (GladeWidgetAdaptor *adaptor,
GladeEditable *editable);
G_END_DECLS
#endif /* _GLADE_TREE_VIEW_EDITOR_H_ */

View File

@ -59,6 +59,7 @@ plugins/gtk+/glade-icon-factory-editor.c
plugins/gtk+/glade-store-editor.c plugins/gtk+/glade-store-editor.c
plugins/gtk+/glade-label-editor.c plugins/gtk+/glade-label-editor.c
plugins/gtk+/glade-cell-renderer-editor.c plugins/gtk+/glade-cell-renderer-editor.c
plugins/gtk+/glade-treeview-editor.c
# gnome plugin backend # gnome plugin backend
plugins/gnome/glade-gnome.c plugins/gnome/glade-gnome.c