glade3 r2008 - in trunk: . gladeui plugins/gtk+
- From: tvb svn gnome org
- To: svn-commits-list gnome org
- Subject: glade3 r2008 - in trunk: . gladeui plugins/gtk+
- Date: Tue, 28 Oct 2008 16:17:40 +0000 (UTC)
Author: tvb
Date: Tue Oct 28 16:17:40 2008
New Revision: 2008
URL: http://svn.gnome.org/viewvc/glade3?rev=2008&view=rev
Log:
* plugins/gtk+/glade-icon-factory-editor.[ch], plugins/gtk+/Makefile.am,
plugins/gtk+/gtk+.xml.in, plugins/gtk+/glade-gtk.c:
Added icon factory editor widget (only to better format the "sources" property
so that it takes the whole width with the treeview.
Added:
trunk/plugins/gtk+/glade-icon-factory-editor.c
trunk/plugins/gtk+/glade-icon-factory-editor.h
Modified:
trunk/ChangeLog
trunk/gladeui/glade-editor-property.c
trunk/plugins/gtk+/Makefile.am
trunk/plugins/gtk+/glade-gtk.c
trunk/plugins/gtk+/glade-icon-sources.c
trunk/plugins/gtk+/gtk+.xml.in
Modified: trunk/gladeui/glade-editor-property.c
==============================================================================
--- trunk/gladeui/glade-editor-property.c (original)
+++ trunk/gladeui/glade-editor-property.c Tue Oct 28 16:17:40 2008
@@ -333,7 +333,7 @@
gtk_label_set_line_wrap (GTK_LABEL(eprop->label), TRUE);
gtk_label_set_line_wrap_mode (GTK_LABEL(eprop->label), PANGO_WRAP_WORD_CHAR);
- /* A Hack to that PANGO_WRAP_WORD_CHAR works nicely */
+ /* A Hack so that PANGO_WRAP_WORD_CHAR works nicely */
g_signal_connect (G_OBJECT (eprop->item_label), "size-request",
G_CALLBACK (eprop_item_label_size_request), eprop);
g_signal_connect_after (G_OBJECT (eprop->item_label), "size-allocate",
Modified: trunk/plugins/gtk+/Makefile.am
==============================================================================
--- trunk/plugins/gtk+/Makefile.am (original)
+++ trunk/plugins/gtk+/Makefile.am Tue Oct 28 16:17:40 2008
@@ -26,7 +26,7 @@
libgladegtk_la_SOURCES = glade-gtk.c glade-accels.c glade-attributes.c glade-convert.c fixed-bg.xpm \
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-image-item-editor.c
+ glade-image-item-editor.c glade-icon-factory-editor.c
libgladegtk_la_LDFLAGS = -module -avoid-version $(AM_LDFLAGS)
libgladegtk_la_LIBADD = $(libgladeui) $(GTK_LIBS)
@@ -34,7 +34,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 \
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-tool-button-editor.h glade-image-editor.h glade-image-item-editor.h glade-icon-factory-editor.h
if PLATFORM_WIN32
libgladegtk_la_LDFLAGS += -no-undefined
Modified: trunk/plugins/gtk+/glade-gtk.c
==============================================================================
--- trunk/plugins/gtk+/glade-gtk.c (original)
+++ trunk/plugins/gtk+/glade-gtk.c Tue Oct 28 16:17:40 2008
@@ -35,6 +35,7 @@
#include "glade-tool-button-editor.h"
#include "glade-image-editor.h"
#include "glade-image-item-editor.h"
+#include "glade-icon-factory-editor.h"
#include <gladeui/glade-editor-property.h>
#include <gladeui/glade-base-editor.h>
@@ -6232,7 +6233,7 @@
{
glade_widget_property_get (widget, "stock", &stock);
glade_property_set (label_prop, stock);
- glade_property_set_i18n_translatable (label_prop, FALSE);
+ glade_property_i18n_set_translatable (label_prop, FALSE);
}
glade_property_write (label_prop, context, node);
g_object_unref (G_OBJECT (label_prop));
@@ -9471,3 +9472,18 @@
use_command);
return eprop;
}
+
+GladeEditable *
+glade_gtk_icon_factory_create_editable (GladeWidgetAdaptor *adaptor,
+ GladeEditorPageType type)
+{
+ GladeEditable *editable;
+
+ /* Get base editable */
+ editable = GWA_GET_CLASS (G_TYPE_OBJECT)->create_editable (adaptor, type);
+
+ if (type == GLADE_PAGE_GENERAL)
+ return (GladeEditable *)glade_icon_factory_editor_new (adaptor, editable);
+
+ return editable;
+}
Added: trunk/plugins/gtk+/glade-icon-factory-editor.c
==============================================================================
--- (empty file)
+++ trunk/plugins/gtk+/glade-icon-factory-editor.c Tue Oct 28 16:17:40 2008
@@ -0,0 +1,208 @@
+/* -*- 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-icon-factory-editor.h"
+
+
+static void glade_icon_factory_editor_finalize (GObject *object);
+
+static void glade_icon_factory_editor_editable_init (GladeEditableIface *iface);
+
+static void glade_icon_factory_editor_grab_focus (GtkWidget *widget);
+
+
+G_DEFINE_TYPE_WITH_CODE (GladeIconFactoryEditor, glade_icon_factory_editor, GTK_TYPE_VBOX,
+ G_IMPLEMENT_INTERFACE (GLADE_TYPE_EDITABLE,
+ glade_icon_factory_editor_editable_init));
+
+
+static void
+glade_icon_factory_editor_class_init (GladeIconFactoryEditorClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ object_class->finalize = glade_icon_factory_editor_finalize;
+ widget_class->grab_focus = glade_icon_factory_editor_grab_focus;
+}
+
+static void
+glade_icon_factory_editor_init (GladeIconFactoryEditor *self)
+{
+}
+
+static void
+project_changed (GladeProject *project,
+ GladeCommand *command,
+ gboolean execute,
+ GladeIconFactoryEditor *factory_editor)
+{
+ if (!GTK_WIDGET_MAPPED (factory_editor))
+ return;
+
+ /* Reload on all commands */
+ glade_editable_load (GLADE_EDITABLE (factory_editor), factory_editor->loaded_widget);
+}
+
+
+static void
+project_finalized (GladeIconFactoryEditor *factory_editor,
+ GladeProject *where_project_was)
+{
+ factory_editor->loaded_widget = NULL;
+
+ glade_editable_load (GLADE_EDITABLE (factory_editor), NULL);
+}
+
+static void
+glade_icon_factory_editor_load (GladeEditable *editable,
+ GladeWidget *widget)
+{
+ GladeIconFactoryEditor *factory_editor = GLADE_ICON_FACTORY_EDITOR (editable);
+ GList *l;
+
+ /* Since we watch the project*/
+ if (factory_editor->loaded_widget)
+ {
+ g_signal_handlers_disconnect_by_func (G_OBJECT (factory_editor->loaded_widget->project),
+ G_CALLBACK (project_changed), factory_editor);
+
+ /* The widget could die unexpectedly... */
+ g_object_weak_unref (G_OBJECT (factory_editor->loaded_widget->project),
+ (GWeakNotify)project_finalized,
+ factory_editor);
+ }
+
+ /* Mark our widget... */
+ factory_editor->loaded_widget = widget;
+
+ if (factory_editor->loaded_widget)
+ {
+ /* This fires for undo/redo */
+ g_signal_connect (G_OBJECT (factory_editor->loaded_widget->project), "changed",
+ G_CALLBACK (project_changed), factory_editor);
+
+ /* The widget/project could die unexpectedly... */
+ g_object_weak_ref (G_OBJECT (factory_editor->loaded_widget->project),
+ (GWeakNotify)project_finalized,
+ factory_editor);
+ }
+
+ /* load the embedded editable... */
+ if (factory_editor->embed)
+ glade_editable_load (GLADE_EDITABLE (factory_editor->embed), widget);
+
+ for (l = factory_editor->properties; l; l = l->next)
+ glade_editor_property_load_by_widget (GLADE_EDITOR_PROPERTY (l->data), widget);
+}
+
+static void
+glade_icon_factory_editor_set_show_name (GladeEditable *editable,
+ gboolean show_name)
+{
+ GladeIconFactoryEditor *factory_editor = GLADE_ICON_FACTORY_EDITOR (editable);
+
+ glade_editable_set_show_name (GLADE_EDITABLE (factory_editor->embed), show_name);
+}
+
+static void
+glade_icon_factory_editor_editable_init (GladeEditableIface *iface)
+{
+ iface->load = glade_icon_factory_editor_load;
+ iface->set_show_name = glade_icon_factory_editor_set_show_name;
+}
+
+static void
+glade_icon_factory_editor_finalize (GObject *object)
+{
+ GladeIconFactoryEditor *factory_editor = GLADE_ICON_FACTORY_EDITOR (object);
+
+ if (factory_editor->properties)
+ g_list_free (factory_editor->properties);
+ factory_editor->properties = NULL;
+ factory_editor->embed = NULL;
+
+ glade_editable_load (GLADE_EDITABLE (object), NULL);
+
+ G_OBJECT_CLASS (glade_icon_factory_editor_parent_class)->finalize (object);
+}
+
+static void
+glade_icon_factory_editor_grab_focus (GtkWidget *widget)
+{
+ GladeIconFactoryEditor *factory_editor = GLADE_ICON_FACTORY_EDITOR (widget);
+
+ gtk_widget_grab_focus (factory_editor->embed);
+}
+
+
+GtkWidget *
+glade_icon_factory_editor_new (GladeWidgetAdaptor *adaptor,
+ GladeEditable *embed)
+{
+ GladeIconFactoryEditor *factory_editor;
+ GladeEditorProperty *eprop;
+ GtkWidget *label, *alignment, *frame, *vbox;
+
+ g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
+ g_return_val_if_fail (GLADE_IS_EDITABLE (embed), NULL);
+
+ factory_editor = g_object_new (GLADE_TYPE_ICON_FACTORY_EDITOR, NULL);
+ factory_editor->embed = GTK_WIDGET (embed);
+
+ /* Pack the parent on top... */
+ gtk_box_pack_start (GTK_BOX (factory_editor), GTK_WIDGET (embed), FALSE, FALSE, 0);
+
+ /* Label item in frame label widget on top... */
+ eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, "sources", FALSE, TRUE);
+ factory_editor->properties = g_list_prepend (factory_editor->properties, eprop);
+ frame = gtk_frame_new (NULL);
+ gtk_frame_set_label_widget (GTK_FRAME (frame), eprop->item_label);
+ gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
+ gtk_box_pack_start (GTK_BOX (factory_editor), frame, FALSE, FALSE, 12);
+
+ /* Alignment/Vbox in frame... */
+ 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_vbox_new (FALSE, 0);
+ gtk_container_add (GTK_CONTAINER (alignment), vbox);
+
+ /* Add descriptive label */
+ label = gtk_label_new (_("First add a stock name in the entry below, "
+ "then add and define sources for that icon "
+ "in the treeview."));
+ gtk_label_set_line_wrap (GTK_LABEL(label), TRUE);
+ gtk_label_set_line_wrap_mode (GTK_LABEL(label), PANGO_WRAP_WORD);
+ gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 8);
+
+ gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (eprop), FALSE, FALSE, 8);
+
+ gtk_widget_show_all (GTK_WIDGET (factory_editor));
+
+ return GTK_WIDGET (factory_editor);
+}
Added: trunk/plugins/gtk+/glade-icon-factory-editor.h
==============================================================================
--- (empty file)
+++ trunk/plugins/gtk+/glade-icon-factory-editor.h Tue Oct 28 16:17:40 2008
@@ -0,0 +1,61 @@
+/* -*- 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_ICON_BUTTON_EDITOR_H_
+#define _GLADE_ICON_BUTTON_EDITOR_H_
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GLADE_TYPE_ICON_FACTORY_EDITOR (glade_icon_factory_editor_get_type ())
+#define GLADE_ICON_FACTORY_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GLADE_TYPE_ICON_FACTORY_EDITOR, GladeIconFactoryEditor))
+#define GLADE_ICON_FACTORY_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GLADE_TYPE_ICON_FACTORY_EDITOR, GladeIconFactoryEditorClass))
+#define GLADE_IS_ICON_FACTORY_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_ICON_FACTORY_EDITOR))
+#define GLADE_IS_ICON_FACTORY_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_ICON_FACTORY_EDITOR))
+#define GLADE_ICON_FACTORY_EDITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GLADE_TYPE_ICON_FACTORY_EDITOR, GladeIconFactoryEditorClass))
+
+typedef struct _GladeIconFactoryEditor GladeIconFactoryEditor;
+typedef struct _GladeIconFactoryEditorClass GladeIconFactoryEditorClass;
+
+struct _GladeIconFactoryEditor
+{
+ GtkVBox parent;
+
+ GladeWidget *loaded_widget; /* A handy pointer to the loaded widget ... */
+
+ GtkWidget *embed; /* Embedded parent class editor */
+
+ GList *properties; /* A list of eprops to update at load() time */
+};
+
+struct _GladeIconFactoryEditorClass
+{
+ GtkVBoxClass parent;
+};
+
+GType glade_icon_factory_editor_get_type (void);
+GtkWidget *glade_icon_factory_editor_new (GladeWidgetAdaptor *adaptor,
+ GladeEditable *editable);
+
+G_END_DECLS
+
+#endif /* _GLADE_ICON_FACTORY_EDITOR_H_ */
Modified: trunk/plugins/gtk+/glade-icon-sources.c
==============================================================================
--- trunk/plugins/gtk+/glade-icon-sources.c (original)
+++ trunk/plugins/gtk+/glade-icon-sources.c Tue Oct 28 16:17:40 2008
@@ -353,7 +353,7 @@
GtkTreeIter *parent_iter = NULL, iter, new_parent_iter;
GtkTreePath *new_item_path;
gchar *icon_name;
- gchar *selected_icon_name;
+ gchar *selected_icon_name = NULL;
gint index;
if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (eprop_sources->combo), &iter))
@@ -992,20 +992,9 @@
glade_eprop_icon_sources_create_input (GladeEditorProperty *eprop)
{
GladeEPropIconSources *eprop_sources = GLADE_EPROP_ICON_SOURCES (eprop);
- GtkWidget *vbox, *hbox, *button, *swin, *label;
- gchar *string;
+ GtkWidget *vbox, *hbox, *button, *swin;
vbox = gtk_vbox_new (FALSE, 2);
-
- /* The label... */
- string = g_strdup_printf ("<b>%s</b>", _("Add and remove icon sources:"));
- label = gtk_label_new (string);
- g_free (string);
- gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
- gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
- gtk_misc_set_padding (GTK_MISC (label), 2, 0);
- gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 0);
-
hbox = gtk_hbox_new (FALSE, 4);
/* hbox with comboboxentry add/remove source buttons on the right... */
Modified: trunk/plugins/gtk+/gtk+.xml.in
==============================================================================
--- trunk/plugins/gtk+/gtk+.xml.in (original)
+++ trunk/plugins/gtk+/gtk+.xml.in Tue Oct 28 16:17:40 2008
@@ -1579,8 +1579,9 @@
<set-property-function>glade_gtk_icon_factory_set_property</set-property-function>
<string-from-value-function>glade_gtk_icon_factory_string_from_value</string-from-value-function>
<create-editor-property-function>glade_gtk_icon_factory_create_eprop</create-editor-property-function>
+ <create-editable-function>glade_gtk_icon_factory_create_editable</create-editable-function>
<properties>
- <property id="sources" _name="Icon Sources" save="False">
+ <property id="sources" _name="Icon Sources" save="False" custom-layout="True">
<_tooltip>A list of sources for this icon factory</_tooltip>
<spec>glade_standard_icon_sources_spec</spec>
</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]