Commit c5619eb4 authored by Tristan Van Berkom's avatar Tristan Van Berkom

Use glade-cell-renderer-button for color attributes.


	* plugins/gtk+/glade-attributes.c: Use glade-cell-renderer-button for color attributes.

	* plugins/gtk+/glade-cell-renderer-button.c: no more button-text property

	* plugins/gtk+/glade-text-button.c: Now use a GTK_STOCK_EDIT icon in the cell renderer button


svn path=/trunk/; revision=1986
parent 96a3fe3b
......@@ -19,7 +19,13 @@
* gladeui/glade-project.c: Fixed mem leaks, release widget property references before
destroying all the glade widgets.
* plugins/gtk+/glade-attributes.c: Use glade-cell-renderer-button for color attributes.
* plugins/gtk+/glade-cell-renderer-button.c: no more button-text property
* plugins/gtk+/glade-text-button.c: Now use a GTK_STOCK_EDIT icon in the cell renderer button
2008-10-20 Tristan Van Berkom <tvb@gnome.org>
* plugins/gtk+/glade-cell-renderer-button.[ch], plugins/gtk+/glade-text-button.[ch]:
......
......@@ -1003,7 +1003,6 @@ glade_property_read (GladeProperty *property,
GladeProjectFormat fmt;
GValue *gvalue = NULL;
gchar /* *id, *name, */ *value;
const gchar *search_name;
gint translatable, has_context;
gchar *comment = NULL, *context = NULL;
......
......@@ -767,9 +767,6 @@ glade_widget_dispose (GObject *object)
/* We do not keep a reference to internal widgets */
if (widget->internal == NULL)
{
g_print ("Destroying internal object (gtkobject %d), ref count %d\n",
GTK_IS_OBJECT (widget->object), widget->object->ref_count);
if (GTK_IS_OBJECT (widget->object))
gtk_object_destroy (GTK_OBJECT (widget->object));
else
......@@ -2499,7 +2496,6 @@ glade_widget_get_project (GladeWidget *widget)
GladeProperty *
glade_widget_get_property (GladeWidget *widget, const gchar *id_property)
{
GList *list;
GladeProperty *property;
g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
......@@ -2522,7 +2518,6 @@ glade_widget_get_property (GladeWidget *widget, const gchar *id_property)
GladeProperty *
glade_widget_get_pack_property (GladeWidget *widget, const gchar *id_property)
{
GList *list;
GladeProperty *property;
g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
......
......@@ -32,7 +32,7 @@
#include <glib/gi18n-lib.h>
#include "glade-attributes.h"
#include "glade-cell-renderer-button.h"
#define GLADE_RESPONSE_CLEAR 42
......@@ -212,7 +212,7 @@ enum {
COLUMN_TOGGLE_ACTIVE, /* whether the toggle renderer is being used */
COLUMN_TOGGLE_DOWN, /* whether the toggle should be displayed in "downstate" */
COLUMN_TEXT_ACTIVE, /* whether the bare naked text renderer is being used (to launch dialogs) */
COLUMN_BUTTON_ACTIVE, /* whether the GladeCellRendererButton is to be used (to launch dialogs) */
COLUMN_TEXT, /* text attribute value for all text derived renderers */
COLUMN_TEXT_STYLE, /* whether to make italic */
COLUMN_TEXT_FG, /* forground colour of the text */
......@@ -238,7 +238,7 @@ typedef enum {
#define ACTIVATE_COLUMN_FROM_TYPE(type) \
((type) == EDIT_TOGGLE ? COLUMN_TOGGLE_ACTIVE : \
(type) == EDIT_SPIN ? COLUMN_SPIN_ACTIVE : \
(type) == EDIT_COMBO ? COLUMN_COMBO_ACTIVE: COLUMN_TEXT_ACTIVE)
(type) == EDIT_COMBO ? COLUMN_COMBO_ACTIVE: COLUMN_BUTTON_ACTIVE)
static GtkListStore *
get_enum_model_for_combo (PangoAttrType type)
......@@ -841,10 +841,9 @@ sync_object (GladeEPropAttrs *eprop_attrs,
}
static void
value_text_editing_started (GtkCellRenderer *renderer,
GtkCellEditable *editable,
gchar *path,
GladeEPropAttrs *eprop_attrs)
value_button_clicked (GtkCellRendererToggle *cell_renderer,
gchar *path,
GladeEPropAttrs *eprop_attrs)
{
GtkWidget *dialog;
GtkTreeIter iter;
......@@ -853,9 +852,6 @@ value_text_editing_started (GtkCellRenderer *renderer,
GdkColor color;
gchar *text = NULL, *new_text;
/* stop emission */
g_signal_stop_emission_by_name (G_OBJECT (renderer), "editing-started");
/* Find type etc */
if (!gtk_tree_model_get_iter_from_string (eprop_attrs->model, &iter, path))
return;
......@@ -987,7 +983,7 @@ glade_eprop_attrs_view (GladeEditorProperty *eprop)
/* Editor renderer related */
G_TYPE_BOOLEAN, // COLUMN_TOGGLE_ACTIVE
G_TYPE_BOOLEAN, // COLUMN_TOGGLE_DOWN
G_TYPE_BOOLEAN, // COLUMN_TEXT_ACTIVE
G_TYPE_BOOLEAN, // COLUMN_BUTTON_ACTIVE
G_TYPE_STRING, // COLUMN_TEXT
G_TYPE_INT, // COLUMN_TEXT_STYLE
G_TYPE_STRING, // COLUMN_TEXT_FG
......@@ -1017,7 +1013,6 @@ glade_eprop_attrs_view (GladeEditorProperty *eprop)
gtk_tree_view_column_set_title (column, _("Value"));
/* Toggle renderer */
renderer = gtk_cell_renderer_toggle_new ();
g_object_set (G_OBJECT (renderer), "activatable", TRUE, NULL);
......@@ -1030,17 +1025,21 @@ glade_eprop_attrs_view (GladeEditorProperty *eprop)
G_CALLBACK (value_toggled), eprop);
/* Text renderer */
renderer = gtk_cell_renderer_text_new ();
g_object_set (G_OBJECT (renderer), "editable", TRUE, NULL);
renderer = glade_cell_renderer_button_new ();
g_object_set (G_OBJECT (renderer),
"editable", TRUE,
"entry-editable", FALSE,
NULL);
gtk_tree_view_column_pack_start (column, renderer, FALSE);
gtk_tree_view_column_set_attributes (column, renderer,
"visible", COLUMN_TEXT_ACTIVE,
"visible", COLUMN_BUTTON_ACTIVE,
"text", COLUMN_TEXT,
"style", COLUMN_TEXT_STYLE,
"foreground", COLUMN_TEXT_FG,
NULL);
g_signal_connect (G_OBJECT (renderer), "editing-started",
G_CALLBACK (value_text_editing_started), eprop);
g_signal_connect (G_OBJECT (renderer), "clicked",
G_CALLBACK (value_button_clicked), eprop);
/* Combo renderer */
renderer = gtk_cell_renderer_combo_new ();
......
......@@ -33,7 +33,6 @@
typedef struct
{
gboolean entry_editable;
gchar *button_text;
} GladeCellRendererButtonPrivate;
static void glade_cell_renderer_button_finalize (GObject *object);
......@@ -56,8 +55,7 @@ static GtkCellEditable * glade_cell_renderer_button_start_editing (GtkCellRender
GtkCellRendererState flags);
enum {
PROP_0,
PROP_ENTRY_EDITABLE,
PROP_BUTTON_TEXT
PROP_ENTRY_EDITABLE
};
......@@ -85,21 +83,13 @@ glade_cell_renderer_button_class_init (GladeCellRendererButtonClass *klass)
cell_class->start_editing = glade_cell_renderer_button_start_editing;
g_object_class_install_property (object_class,
PROP_BUTTON_TEXT,
PROP_ENTRY_EDITABLE,
g_param_spec_boolean ("entry-editable",
_("Entry Editable"),
_("Whether the entry is editable"),
TRUE,
G_PARAM_READWRITE));
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),
......@@ -120,7 +110,6 @@ glade_cell_renderer_button_init (GladeCellRendererButton *self)
priv = GLADE_CELL_RENDERER_BUTTON_GET_PRIVATE (self);
priv->entry_editable = TRUE;
priv->button_text = NULL;
}
static void
......@@ -130,10 +119,6 @@ glade_cell_renderer_button_finalize (GObject *object)
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);
}
......@@ -154,9 +139,6 @@ glade_cell_renderer_button_get_property (GObject *object,
case PROP_ENTRY_EDITABLE:
g_value_set_boolean (value, priv->entry_editable);
break;
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;
......@@ -180,11 +162,6 @@ glade_cell_renderer_button_set_property (GObject *object,
case PROP_ENTRY_EDITABLE:
priv->entry_editable = g_value_get_boolean (value);
break;
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;
......@@ -264,7 +241,6 @@ glade_cell_renderer_button_start_editing (GtkCellRenderer *cell,
text_button = (GladeTextButton *)glade_text_button_new ();
gtk_entry_set_text (GTK_ENTRY (text_button->entry), cell_text->text);
gtk_entry_set_editable (GTK_ENTRY (text_button->entry), priv->entry_editable);
gtk_button_set_label (GTK_BUTTON (text_button->button), priv->button_text);
g_object_set (text_button->entry,
"has-frame", FALSE,
......
......@@ -735,10 +735,7 @@ eprop_model_generate_column (GladeEditorProperty *eprop,
{
/* Text renderer */
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 ();
......
......@@ -62,25 +62,32 @@ glade_text_button_class_init (GladeTextButtonClass *klass)
static void
glade_text_button_init (GladeTextButton *self)
{
gtk_alignment_set_padding (GTK_ALIGNMENT (self), 1, 1, 2, 2);
GtkWidget *image;
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);
gtk_alignment_set_padding (GTK_ALIGNMENT (self), 1, 1, 2, 2);
self->button = gtk_button_new ();
gtk_box_pack_start (GTK_BOX (self->hbox), self->button, FALSE, FALSE, 0);
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);
image = gtk_image_new_from_stock (GTK_STOCK_EDIT,
GTK_ICON_SIZE_MENU);
gtk_widget_show (image);
gtk_container_add (GTK_CONTAINER (self->button), image);
}
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));
gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (button));
gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (button));
}
/* GtkCellEditable method implementations
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment