glade3 r1981 - in trunk: . plugins/gtk+
- From: tvb svn gnome org
- To: svn-commits-list gnome org
- Subject: glade3 r1981 - in trunk: . plugins/gtk+
- Date: Mon, 20 Oct 2008 01:02:47 +0000 (UTC)
Author: tvb
Date: Mon Oct 20 01:02:47 2008
New Revision: 1981
URL: http://svn.gnome.org/viewvc/glade3?rev=1981&view=rev
Log:
* plugins/gtk+/glade-cell-renderer-button.[ch], plugins/gtk+/glade-text-button.[ch],
plugins/gtk+/glade-model-data.c: Added i18n support to string values in datastores.
Added:
trunk/plugins/gtk+/glade-cell-renderer-button.c
trunk/plugins/gtk+/glade-cell-renderer-button.h
trunk/plugins/gtk+/glade-text-button.c
trunk/plugins/gtk+/glade-text-button.h
Modified:
trunk/ChangeLog
trunk/plugins/gtk+/Makefile.am
trunk/plugins/gtk+/glade-model-data.c
Modified: trunk/plugins/gtk+/Makefile.am
==============================================================================
--- trunk/plugins/gtk+/Makefile.am (original)
+++ trunk/plugins/gtk+/Makefile.am Mon Oct 20 01:02:47 2008
@@ -24,12 +24,14 @@
$(AM_CFLAGS)
libgladegtk_la_SOURCES = glade-gtk.c glade-accels.c glade-attributes.c glade-convert.c fixed-bg.xpm \
- glade-column-types.c glade-column-types.h glade-model-data.c glade-model-data.h
+ glade-column-types.c glade-model-data.c glade-text-button.c glade-cell-renderer-button.c
+
libgladegtk_la_LDFLAGS = -module -avoid-version $(AM_LDFLAGS)
libgladegtk_la_LIBADD = $(libgladeui) $(GTK_LIBS)
libgladegtkincludedir= $(includedir)/libgladeui-1.0/gladeui
-libgladegtkinclude_HEADERS = glade-gtk.h glade-accels.h glade-attributes.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
if PLATFORM_WIN32
libgladegtk_la_LDFLAGS += -no-undefined
Added: trunk/plugins/gtk+/glade-cell-renderer-button.c
==============================================================================
--- (empty file)
+++ trunk/plugins/gtk+/glade-cell-renderer-button.c Mon Oct 20 01:02:47 2008
@@ -0,0 +1,290 @@
+/* -*- 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 "glade-cell-renderer-button.h"
+#include "glade-text-button.h"
+
+
+#define GLADE_CELL_RENDERER_BUTTON_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GLADE_TYPE_CELL_RENDERER_BUTTON, GladeCellRendererButtonPrivate))
+
+typedef struct
+{
+ gchar *button_text;
+} GladeCellRendererButtonPrivate;
+
+static void glade_cell_renderer_button_finalize (GObject *object);
+
+static void glade_cell_renderer_button_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *spec);
+static void glade_cell_renderer_button_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *spec);
+
+static GtkCellEditable * glade_cell_renderer_button_start_editing (GtkCellRenderer *cell,
+ GdkEvent *event,
+ GtkWidget *widget,
+ const gchar *path,
+ GdkRectangle *background_area,
+ GdkRectangle *cell_area,
+ GtkCellRendererState flags);
+enum {
+ PROP_0,
+ PROP_BUTTON_TEXT
+};
+
+
+enum {
+ CLICKED,
+ LAST_SIGNAL
+};
+
+static guint glade_cell_renderer_signals [LAST_SIGNAL];
+
+G_DEFINE_TYPE (GladeCellRendererButton, glade_cell_renderer_button, GTK_TYPE_CELL_RENDERER_TEXT)
+
+#define GLADE_CELL_RENDERER_BUTTON_PATH "glade-cell-renderer-button-path"
+
+static void
+glade_cell_renderer_button_class_init (GladeCellRendererButtonClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS (klass);
+
+ object_class->finalize = glade_cell_renderer_button_finalize;
+ object_class->get_property = glade_cell_renderer_button_get_property;
+ object_class->set_property = glade_cell_renderer_button_set_property;
+
+ cell_class->start_editing = glade_cell_renderer_button_start_editing;
+
+ g_object_class_install_property (object_class,
+ PROP_BUTTON_TEXT,
+ g_param_spec_string ("button-text",
+ _("Button Text"),
+ _("The text to display in the button"),
+ NULL,
+ G_PARAM_READWRITE));
+
+ glade_cell_renderer_signals[CLICKED] =
+ g_signal_new ("clicked",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GladeCellRendererButtonClass, clicked),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, 1, G_TYPE_STRING);
+
+ g_type_class_add_private (object_class, sizeof (GladeCellRendererButtonPrivate));
+}
+
+static void
+glade_cell_renderer_button_init (GladeCellRendererButton *self)
+{
+ GladeCellRendererButtonPrivate *priv;
+
+ priv = GLADE_CELL_RENDERER_BUTTON_GET_PRIVATE (self);
+
+ priv->button_text = NULL;
+}
+
+static void
+glade_cell_renderer_button_finalize (GObject *object)
+{
+ GladeCellRendererButtonPrivate *priv;
+
+ priv = GLADE_CELL_RENDERER_BUTTON_GET_PRIVATE (object);
+
+ if (priv)
+ {
+ g_free (priv->button_text);
+ }
+ G_OBJECT_CLASS (glade_cell_renderer_button_parent_class)->finalize (object);
+}
+
+static void
+glade_cell_renderer_button_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GladeCellRendererButton *renderer;
+ GladeCellRendererButtonPrivate *priv;
+
+ renderer = GLADE_CELL_RENDERER_BUTTON (object);
+ priv = GLADE_CELL_RENDERER_BUTTON_GET_PRIVATE (renderer);
+
+ switch (prop_id)
+ {
+ case PROP_BUTTON_TEXT:
+ g_value_set_string (value, priv->button_text);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+glade_cell_renderer_button_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GladeCellRendererButton *renderer;
+ GladeCellRendererButtonPrivate *priv;
+
+ renderer = GLADE_CELL_RENDERER_BUTTON (object);
+ priv = GLADE_CELL_RENDERER_BUTTON_GET_PRIVATE (renderer);
+
+ switch (prop_id)
+ {
+ case PROP_BUTTON_TEXT:
+ if (priv->button_text)
+ g_free (priv->button_text);
+ priv->button_text = g_value_dup_string (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+glade_cell_renderer_button_clicked (GtkButton *button,
+ GladeCellRendererButton *self)
+{
+ gchar *path = g_object_get_data (G_OBJECT (button), GLADE_CELL_RENDERER_BUTTON_PATH);
+
+ g_signal_emit (self, glade_cell_renderer_signals[CLICKED], 0, path);
+}
+
+static gboolean
+glade_cell_renderer_button_focus_out_event (GtkWidget *entry,
+ GdkEvent *event,
+ GtkCellRendererText *cell_text)
+{
+ GladeCellRendererButtonPrivate *priv;
+
+ priv = GLADE_CELL_RENDERER_BUTTON_GET_PRIVATE (cell_text);
+
+ GTK_ENTRY (entry)->editing_canceled = TRUE;
+ gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (entry));
+ gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (entry));
+
+ /* entry needs focus-out-event */
+ return FALSE;
+}
+
+
+static void
+glade_cell_renderer_button_activate (GtkCellEditable *entry,
+ GtkCellRendererText *cell_text)
+{
+ const gchar *path;
+ const gchar *new_text;
+ GladeCellRendererButtonPrivate *priv;
+
+ priv = GLADE_CELL_RENDERER_BUTTON_GET_PRIVATE (cell_text);
+
+ g_signal_handlers_disconnect_by_func (entry, glade_cell_renderer_button_focus_out_event, cell_text);
+
+ gtk_cell_renderer_stop_editing (GTK_CELL_RENDERER (cell_text),
+ GTK_ENTRY (entry)->editing_canceled);
+
+ if (GTK_ENTRY (entry)->editing_canceled)
+ return;
+
+ path = g_object_get_data (G_OBJECT (entry), GLADE_CELL_RENDERER_BUTTON_PATH);
+ new_text = gtk_entry_get_text (GTK_ENTRY (entry));
+
+ g_signal_emit_by_name (cell_text, "edited", path, new_text);
+}
+
+static GtkCellEditable *
+glade_cell_renderer_button_start_editing (GtkCellRenderer *cell,
+ GdkEvent *event,
+ GtkWidget *widget,
+ const gchar *path,
+ GdkRectangle *background_area,
+ GdkRectangle *cell_area,
+ GtkCellRendererState flags)
+{
+ GladeCellRendererButtonPrivate *priv;
+ GtkCellRendererText *cell_text;
+ GladeTextButton *text_button;
+
+ cell_text = GTK_CELL_RENDERER_TEXT (cell);
+ priv = GLADE_CELL_RENDERER_BUTTON_GET_PRIVATE (cell);
+
+ if (cell_text->editable == FALSE)
+ return NULL;
+
+ text_button = (GladeTextButton *)glade_text_button_new ();
+ gtk_entry_set_text (GTK_ENTRY (text_button->entry), cell_text->text);
+ gtk_button_set_label (GTK_BUTTON (text_button->button), priv->button_text);
+
+ g_object_set (text_button->entry,
+ "has-frame", FALSE,
+ "xalign", cell->xalign,
+ NULL);
+
+ g_object_set_data_full (G_OBJECT (text_button->entry), GLADE_CELL_RENDERER_BUTTON_PATH,
+ g_strdup (path), g_free);
+ g_object_set_data_full (G_OBJECT (text_button->button), GLADE_CELL_RENDERER_BUTTON_PATH,
+ g_strdup (path), g_free);
+
+ g_signal_connect (G_OBJECT (text_button->button), "clicked",
+ G_CALLBACK (glade_cell_renderer_button_clicked),
+ cell);
+
+ g_signal_connect (G_OBJECT (text_button->entry), "activate",
+ G_CALLBACK (glade_cell_renderer_button_activate),
+ cell);
+
+ g_signal_connect_after (text_button->entry, "focus-out-event",
+ G_CALLBACK (glade_cell_renderer_button_focus_out_event),
+ cell);
+
+ gtk_widget_show_all (GTK_WIDGET (text_button));
+ return GTK_CELL_EDITABLE (text_button);
+}
+
+/**
+ * glade_cell_renderer_button_new:
+ *
+ * Creates a new #GladeCellRendererButton.
+ *
+ * Returns: a new #GladeCellRendererButton
+ *
+ */
+GtkCellRenderer *
+glade_cell_renderer_button_new (void)
+{
+ return g_object_new (GLADE_TYPE_CELL_RENDERER_BUTTON, NULL);
+}
+
Added: trunk/plugins/gtk+/glade-cell-renderer-button.h
==============================================================================
--- (empty file)
+++ trunk/plugins/gtk+/glade-cell-renderer-button.h Mon Oct 20 01:02:47 2008
@@ -0,0 +1,57 @@
+/* -*- 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_CELL_RENDERER_BUTTON_H_
+#define _GLADE_CELL_RENDERER_BUTTON_H_
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GLADE_TYPE_CELL_RENDERER_BUTTON (glade_cell_renderer_button_get_type ())
+#define GLADE_CELL_RENDERER_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GLADE_TYPE_CELL_RENDERER_BUTTON, GladeCellRendererButton))
+#define GLADE_CELL_RENDERER_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST \
+ ((klass), GLADE_TYPE_CELL_RENDERER_BUTTON, GladeCellRendererButtonClass))
+#define GLADE_IS_CELL_RENDERER_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_CELL_RENDERER_BUTTON))
+#define GLADE_IS_CELL_RENDERER_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_CELL_RENDERER_BUTTON))
+#define GLADE_CELL_RENDERER_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GLADE_TYPE_CELL_RENDERER_BUTTON, GladeCellRendererTextClass))
+
+typedef struct _GladeCellRendererButton GladeCellRendererButton;
+typedef struct _GladeCellRendererButtonClass GladeCellRendererButtonClass;
+
+struct _GladeCellRendererButton
+{
+ GtkCellRendererText parent;
+};
+
+struct _GladeCellRendererButtonClass
+{
+ GtkCellRendererTextClass parent;
+
+ void (*clicked) (GladeCellRendererButton *, const gchar *);
+};
+
+GType glade_cell_renderer_button_get_type (void);
+GtkCellRenderer *glade_cell_renderer_button_new (void);
+
+G_END_DECLS
+
+#endif /* _GLADE_CELL_RENDERER_BUTTON_H_ */
Modified: trunk/plugins/gtk+/glade-model-data.c
==============================================================================
--- trunk/plugins/gtk+/glade-model-data.c (original)
+++ trunk/plugins/gtk+/glade-model-data.c Mon Oct 20 01:02:47 2008
@@ -29,6 +29,7 @@
#include "glade-model-data.h"
#include "glade-column-types.h"
+#include "glade-cell-renderer-button.h"
GladeModelData *
glade_model_data_new (GType type, const gchar *column_name)
@@ -593,6 +594,58 @@
g_idle_add ((GSourceFunc)update_data_tree_idle, eprop);
}
+static void
+value_i18n_clicked (GladeCellRendererButton *cell,
+ const gchar *path,
+ GladeEditorProperty *eprop)
+{
+ GladeEPropModelData *eprop_data = GLADE_EPROP_MODEL_DATA (eprop);
+ GtkTreeIter iter;
+ gint colnum = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cell), "column-number"));
+ gint row;
+ GNode *data_tree = NULL;
+ GladeModelData *data;
+ gchar *new_text;
+ gboolean has_context_dummy;
+
+ if (!gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (eprop_data->store), &iter, path))
+ return;
+
+
+ gtk_tree_model_get (GTK_TREE_MODEL (eprop_data->store), &iter,
+ COLUMN_ROW, &row,
+ -1);
+
+ glade_property_get (eprop->property, &data_tree);
+
+ /* if we are editing, then there is data in the datatree */
+ g_assert (data_tree);
+
+ data_tree = glade_model_data_tree_copy (data_tree);
+
+ data = glade_model_data_tree_get_data (data_tree, row, colnum);
+ g_assert (G_VALUE_TYPE (&data->value) == G_TYPE_STRING);
+
+ new_text = g_value_dup_string (&data->value);
+
+ if (glade_editor_property_show_i18n_dialog (NULL,
+ GLADE_PROJECT_FORMAT_GTKBUILDER,
+ &new_text,
+ &data->i18n_context,
+ &data->i18n_comment,
+ &has_context_dummy,
+ &data->i18n_translatable))
+ {
+ g_value_set_string (&data->value, new_text);
+
+ if (eprop_data->pending_data_tree)
+ glade_model_data_tree_free (eprop_data->pending_data_tree);
+
+ eprop_data->pending_data_tree = data_tree;
+ g_idle_add ((GSourceFunc)update_data_tree_idle, eprop);
+ }
+ g_free (new_text);
+}
static void
value_text_edited (GtkCellRendererText *cell,
@@ -674,6 +727,7 @@
GType type = G_VALUE_TYPE (&data->value);
gtk_tree_view_column_set_title (column, data->name);
+ gtk_tree_view_column_set_resizable (column, TRUE);
/* Support enum and flag types, and a hardcoded list of fundamental types */
if (type == G_TYPE_CHAR ||
@@ -681,7 +735,14 @@
type == G_TYPE_STRING)
{
/* Text renderer */
- renderer = gtk_cell_renderer_text_new ();
+ if (type == G_TYPE_STRING)
+ {
+ renderer = glade_cell_renderer_button_new ();
+ g_object_set (renderer, "button-text", "\342\200\246", NULL);
+ }
+ else
+ renderer = gtk_cell_renderer_text_new ();
+
g_object_set (G_OBJECT (renderer),
"editable", TRUE,
NULL);
@@ -699,9 +760,13 @@
g_signal_connect (G_OBJECT (renderer), "edited",
G_CALLBACK (value_text_edited), eprop);
- /* Trigger i18n dialog from here somehow ! */
-/* g_signal_connect (G_OBJECT (renderer), "editing-started", */
-/* G_CALLBACK (value_text_editing_started), eprop); */
+ /* Trigger i18n dialog from here */
+ if (type == G_TYPE_STRING)
+ {
+ g_signal_connect (G_OBJECT (renderer), "clicked",
+ G_CALLBACK (value_i18n_clicked), eprop);
+ }
+
}
/* Text renderer single char */
Added: trunk/plugins/gtk+/glade-text-button.c
==============================================================================
--- (empty file)
+++ trunk/plugins/gtk+/glade-text-button.c Mon Oct 20 01:02:47 2008
@@ -0,0 +1,151 @@
+/* -*- 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-text-button.h"
+
+
+#define GLADE_CELL_RENDERER_BUTTON_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GLADE_TYPE_CELL_RENDERER_BUTTON, GladeCellRendererButtonPrivate))
+
+typedef struct
+{
+ gchar *button_text;
+} GladeCellRendererButtonPrivate;
+
+static void glade_text_button_finalize (GObject *object);
+
+static void glade_text_button_cell_editable_init (GtkCellEditableIface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (GladeTextButton, glade_text_button, GTK_TYPE_ALIGNMENT,
+ G_IMPLEMENT_INTERFACE (GTK_TYPE_CELL_EDITABLE,
+ glade_text_button_cell_editable_init));
+
+
+static void
+glade_text_button_class_init (GladeTextButtonClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = glade_text_button_finalize;
+}
+
+static void
+glade_text_button_init (GladeTextButton *self)
+{
+ gtk_alignment_set_padding (GTK_ALIGNMENT (self), 1, 1, 2, 2);
+
+ self->hbox = gtk_hbox_new (FALSE, 2);
+
+ gtk_container_add (GTK_CONTAINER (self), self->hbox);
+
+ self->entry = gtk_entry_new ();
+ gtk_box_pack_start (GTK_BOX (self->hbox), self->entry, TRUE, TRUE, 0);
+
+ self->button = gtk_button_new ();
+ gtk_box_pack_start (GTK_BOX (self->hbox), self->button, FALSE, FALSE, 0);
+
+}
+
+static void
+glade_text_button_clicked (GtkWidget *widget,
+ GladeTextButton *button)
+{
+ gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (button));
+ gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (button));
+}
+
+
+/* GtkCellEditable method implementations
+ */
+static void
+glade_text_button_entry_activated (GtkEntry *entry, GladeTextButton *button)
+{
+ gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (button));
+ gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (button));
+}
+
+static gboolean
+glade_text_button_key_press_event (GtkEntry *entry,
+ GdkEventKey *key_event,
+ GladeTextButton *button)
+{
+ if (key_event->keyval == GDK_Escape)
+ {
+ entry->editing_canceled = TRUE;
+ gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (button));
+ gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (button));
+
+ return TRUE;
+ }
+
+ /* override focus */
+ if (key_event->keyval == GDK_Up || key_event->keyval == GDK_Down)
+ {
+ gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (button));
+ gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (button));
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+static void
+glade_text_button_start_editing (GtkCellEditable *cell_editable,
+ GdkEvent *event)
+{
+ g_signal_connect (GLADE_TEXT_BUTTON (cell_editable)->button, "clicked",
+ G_CALLBACK (glade_text_button_clicked), cell_editable);
+ g_signal_connect (GLADE_TEXT_BUTTON (cell_editable)->entry, "activate",
+ G_CALLBACK (glade_text_button_entry_activated), cell_editable);
+ g_signal_connect (cell_editable, "key-press-event",
+ G_CALLBACK (glade_text_button_key_press_event), cell_editable);
+}
+
+static void
+glade_text_button_cell_editable_init (GtkCellEditableIface *iface)
+{
+ iface->start_editing = glade_text_button_start_editing;
+}
+
+static void
+glade_text_button_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (glade_text_button_parent_class)->finalize (object);
+}
+
+/**
+ * glade_text_button_new:
+ *
+ * Creates a new #GladeTextButton.
+ *
+ * Returns: a new #GladeTextButton
+ *
+ */
+GtkWidget *
+glade_text_button_new (void)
+{
+ return g_object_new (GLADE_TYPE_TEXT_BUTTON, NULL);
+}
Added: trunk/plugins/gtk+/glade-text-button.h
==============================================================================
--- (empty file)
+++ trunk/plugins/gtk+/glade-text-button.h Mon Oct 20 01:02:47 2008
@@ -0,0 +1,60 @@
+/* -*- 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_TEXT_BUTTON_H_
+#define _GLADE_TEXT_BUTTON_H_
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GLADE_TYPE_TEXT_BUTTON (glade_text_button_get_type ())
+#define GLADE_TEXT_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GLADE_TYPE_TEXT_BUTTON, GladeTextButton))
+#define GLADE_TEXT_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GLADE_TYPE_TEXT_BUTTON, GladeTextButtonClass))
+#define GLADE_IS_TEXT_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_TEXT_BUTTON))
+#define GLADE_IS_TEXT_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_TEXT_BUTTON))
+#define GLADE_TEXT_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GLADE_TYPE_TEXT_BUTTON, GladeTextTextClass))
+
+typedef struct _GladeTextButton GladeTextButton;
+typedef struct _GladeTextButtonClass GladeTextButtonClass;
+
+struct _GladeTextButton
+{
+ GtkAlignment alignment;
+
+ GtkWidget *hbox;
+ GtkWidget *entry;
+ GtkWidget *button;
+};
+
+struct _GladeTextButtonClass
+{
+ GtkAlignmentClass parent;
+
+ void (*clicked) (GladeTextButton *);
+};
+
+GType glade_text_button_get_type (void);
+GtkWidget *glade_text_button_new (void);
+
+G_END_DECLS
+
+#endif /* _GLADE_TEXT_BUTTON_H_ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]