forked from AuroraMiddleware/gtk
Renamed GtkCellRendererKeys to GtkCellRendererAccel to be consistent with
2005-09-22 Michael Natterer <mitch@imendio.com> Renamed GtkCellRendererKeys to GtkCellRendererAccel to be consistent with GTK+ terminology: * gtk/gtkcellrendererkeys.[ch] * tests/testkeys.c: removed... * gtk/gtkcellrendereraccel.[ch] * tests/testaccel.c: ...and added. * gtk/Makefile.am * gtk/gtk.h * gtk/gtk.symbols * tests/Makefile.am: changed accordingly.
This commit is contained in:
parent
155cfe3e9e
commit
080889e074
16
ChangeLog
16
ChangeLog
@ -1,3 +1,19 @@
|
||||
2005-09-22 Michael Natterer <mitch@imendio.com>
|
||||
|
||||
Renamed GtkCellRendererKeys to GtkCellRendererAccel to be
|
||||
consistent with GTK+ terminology:
|
||||
|
||||
* gtk/gtkcellrendererkeys.[ch]
|
||||
* tests/testkeys.c: removed...
|
||||
|
||||
* gtk/gtkcellrendereraccel.[ch]
|
||||
* tests/testaccel.c: ...and added.
|
||||
|
||||
* gtk/Makefile.am
|
||||
* gtk/gtk.h
|
||||
* gtk/gtk.symbols
|
||||
* tests/Makefile.am: changed accordingly.
|
||||
|
||||
2005-09-22 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* gtk/gtkwidget.c (gtk_widget_class_init): Fix the documentation
|
||||
|
@ -1,3 +1,19 @@
|
||||
2005-09-22 Michael Natterer <mitch@imendio.com>
|
||||
|
||||
Renamed GtkCellRendererKeys to GtkCellRendererAccel to be
|
||||
consistent with GTK+ terminology:
|
||||
|
||||
* gtk/gtkcellrendererkeys.[ch]
|
||||
* tests/testkeys.c: removed...
|
||||
|
||||
* gtk/gtkcellrendereraccel.[ch]
|
||||
* tests/testaccel.c: ...and added.
|
||||
|
||||
* gtk/Makefile.am
|
||||
* gtk/gtk.h
|
||||
* gtk/gtk.symbols
|
||||
* tests/Makefile.am: changed accordingly.
|
||||
|
||||
2005-09-22 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* gtk/gtkwidget.c (gtk_widget_class_init): Fix the documentation
|
||||
|
@ -131,8 +131,8 @@ gtk_public_h_sources = \
|
||||
gtkcelleditable.h \
|
||||
gtkcelllayout.h \
|
||||
gtkcellrenderer.h \
|
||||
gtkcellrendereraccel.h \
|
||||
gtkcellrenderercombo.h \
|
||||
gtkcellrendererkeys.h \
|
||||
gtkcellrendererpixbuf.h \
|
||||
gtkcellrendererprogress.h \
|
||||
gtkcellrenderertext.h \
|
||||
@ -346,8 +346,8 @@ gtk_c_sources = \
|
||||
gtkcelleditable.c \
|
||||
gtkcelllayout.c \
|
||||
gtkcellrenderer.c \
|
||||
gtkcellrendereraccel.c \
|
||||
gtkcellrenderercombo.c \
|
||||
gtkcellrendererkeys.c \
|
||||
gtkcellrendererpixbuf.c \
|
||||
gtkcellrendererprogress.c \
|
||||
gtkcellrenderertext.c \
|
||||
|
@ -48,8 +48,8 @@
|
||||
#include <gtk/gtkcalendar.h>
|
||||
#include <gtk/gtkcelllayout.h>
|
||||
#include <gtk/gtkcellrenderer.h>
|
||||
#include <gtk/gtkcellrendereraccel.h>
|
||||
#include <gtk/gtkcellrenderercombo.h>
|
||||
#include <gtk/gtkcellrendererkeys.h>
|
||||
#include <gtk/gtkcellrendererpixbuf.h>
|
||||
#include <gtk/gtkcellrendererprogress.h>
|
||||
#include <gtk/gtkcellrenderertext.h>
|
||||
|
@ -466,6 +466,13 @@ gtk_cell_renderer_stop_editing
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if IN_HEADER(__GTK_CELL_RENDERER_ACCEL_H__)
|
||||
#if IN_FILE(__GTK_CELL_RENDERER_ACCEL_C__)
|
||||
gtk_cell_renderer_accel_get_type G_GNUC_CONST
|
||||
gtk_cell_renderer_accel_new
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if IN_HEADER(__GTK_CELL_RENDERER_COMBO_H__)
|
||||
#if IN_FILE(__GTK_CELL_RENDERER_COMBO_C__)
|
||||
gtk_cell_renderer_combo_get_type G_GNUC_CONST
|
||||
@ -473,13 +480,6 @@ gtk_cell_renderer_combo_new
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if IN_HEADER(__GTK_CELL_RENDERER_KEYS_H__)
|
||||
#if IN_FILE(__GTK_CELL_RENDERER_KEYS_C__)
|
||||
gtk_cell_renderer_keys_get_type G_GNUC_CONST
|
||||
gtk_cell_renderer_keys_new
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if IN_HEADER(__GTK_CELL_RENDERER_PIXBUF_H__)
|
||||
#if IN_FILE(__GTK_CELL_RENDERER_PIXBUF_C__)
|
||||
gtk_cell_renderer_pixbuf_get_type G_GNUC_CONST
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* gtkcellrendererkeys.h
|
||||
/* gtkcellrendereraccel.h
|
||||
* Copyright (C) 2000 Red Hat, Inc., Jonathan Blandford <jrb@redhat.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
@ -21,7 +21,7 @@
|
||||
#include "gtkintl.h"
|
||||
#include "gtkaccelgroup.h"
|
||||
#include "gtkmarshalers.h"
|
||||
#include "gtkcellrendererkeys.h"
|
||||
#include "gtkcellrendereraccel.h"
|
||||
#include "gtklabel.h"
|
||||
#include "gtkeventbox.h"
|
||||
#include "gtkprivate.h"
|
||||
@ -29,30 +29,30 @@
|
||||
#include "gtkalias.h"
|
||||
|
||||
|
||||
static void gtk_cell_renderer_keys_finalize (GObject *object);
|
||||
static GtkCellEditable *gtk_cell_renderer_keys_start_editing (GtkCellRenderer *cell,
|
||||
GdkEvent *event,
|
||||
GtkWidget *widget,
|
||||
const gchar *path,
|
||||
GdkRectangle *background_area,
|
||||
GdkRectangle *cell_area,
|
||||
GtkCellRendererState flags);
|
||||
static void gtk_cell_renderer_accel_finalize (GObject *object);
|
||||
static GtkCellEditable *gtk_cell_renderer_accel_start_editing (GtkCellRenderer *cell,
|
||||
GdkEvent *event,
|
||||
GtkWidget *widget,
|
||||
const gchar *path,
|
||||
GdkRectangle *background_area,
|
||||
GdkRectangle *cell_area,
|
||||
GtkCellRendererState flags);
|
||||
|
||||
static void gtk_cell_renderer_keys_get_property (GObject *object,
|
||||
guint param_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_cell_renderer_keys_set_property (GObject *object,
|
||||
guint param_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_cell_renderer_keys_get_size (GtkCellRenderer *cell,
|
||||
GtkWidget *widget,
|
||||
GdkRectangle *cell_area,
|
||||
gint *x_offset,
|
||||
gint *y_offset,
|
||||
gint *width,
|
||||
gint *height);
|
||||
static void gtk_cell_renderer_accel_get_property (GObject *object,
|
||||
guint param_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_cell_renderer_accel_set_property (GObject *object,
|
||||
guint param_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_cell_renderer_accel_get_size (GtkCellRenderer *cell,
|
||||
GtkWidget *widget,
|
||||
GdkRectangle *cell_area,
|
||||
gint *x_offset,
|
||||
gint *y_offset,
|
||||
gint *width,
|
||||
gint *height);
|
||||
|
||||
enum {
|
||||
ACCEL_EDITED,
|
||||
@ -70,32 +70,32 @@ enum {
|
||||
|
||||
static guint signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
G_DEFINE_TYPE (GtkCellRendererKeys, gtk_cell_renderer_keys, GTK_TYPE_CELL_RENDERER_TEXT);
|
||||
G_DEFINE_TYPE (GtkCellRendererAccel, gtk_cell_renderer_accel, GTK_TYPE_CELL_RENDERER_TEXT);
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_keys_init (GtkCellRendererKeys *cell_keys)
|
||||
gtk_cell_renderer_accel_init (GtkCellRendererAccel *cell_accel)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_keys_class_init (GtkCellRendererKeysClass *cell_keys_class)
|
||||
gtk_cell_renderer_accel_class_init (GtkCellRendererAccelClass *cell_accel_class)
|
||||
{
|
||||
GObjectClass *object_class;
|
||||
GtkCellRendererClass *cell_renderer_class;
|
||||
|
||||
object_class = G_OBJECT_CLASS (cell_keys_class);
|
||||
cell_renderer_class = GTK_CELL_RENDERER_CLASS (cell_keys_class);
|
||||
object_class = G_OBJECT_CLASS (cell_accel_class);
|
||||
cell_renderer_class = GTK_CELL_RENDERER_CLASS (cell_accel_class);
|
||||
|
||||
GTK_CELL_RENDERER_CLASS (cell_keys_class)->start_editing = gtk_cell_renderer_keys_start_editing;
|
||||
GTK_CELL_RENDERER_CLASS (cell_accel_class)->start_editing = gtk_cell_renderer_accel_start_editing;
|
||||
|
||||
object_class->set_property = gtk_cell_renderer_keys_set_property;
|
||||
object_class->get_property = gtk_cell_renderer_keys_get_property;
|
||||
cell_renderer_class->get_size = gtk_cell_renderer_keys_get_size;
|
||||
object_class->set_property = gtk_cell_renderer_accel_set_property;
|
||||
object_class->get_property = gtk_cell_renderer_accel_get_property;
|
||||
cell_renderer_class->get_size = gtk_cell_renderer_accel_get_size;
|
||||
|
||||
object_class->finalize = gtk_cell_renderer_keys_finalize;
|
||||
object_class->finalize = gtk_cell_renderer_accel_finalize;
|
||||
|
||||
/**
|
||||
* GtkCellRendererKeys:accel-key:
|
||||
* GtkCellRendererAccel:accel-key:
|
||||
*
|
||||
* The keyval of the accelerator.
|
||||
*
|
||||
@ -112,7 +112,7 @@ gtk_cell_renderer_keys_class_init (GtkCellRendererKeysClass *cell_keys_class)
|
||||
GTK_PARAM_READWRITE));
|
||||
|
||||
/**
|
||||
* GtkCellRendererKeys:accel-mods:
|
||||
* GtkCellRendererAccel:accel-mods:
|
||||
*
|
||||
* The modifier mask of the accelerator.
|
||||
*
|
||||
@ -128,7 +128,7 @@ gtk_cell_renderer_keys_class_init (GtkCellRendererKeysClass *cell_keys_class)
|
||||
GTK_PARAM_READWRITE));
|
||||
|
||||
/**
|
||||
* GtkCellRendererKeys:keycode:
|
||||
* GtkCellRendererAccel:keycode:
|
||||
*
|
||||
* The hardware keycode of the accelerator. Note that the hardware keycode is
|
||||
* only relevant if the key does not have a keyval. Normally, the keyboard
|
||||
@ -147,7 +147,7 @@ gtk_cell_renderer_keys_class_init (GtkCellRendererKeysClass *cell_keys_class)
|
||||
GTK_PARAM_READWRITE));
|
||||
|
||||
/**
|
||||
* GtkCellRendererKeys:accel-mode:
|
||||
* GtkCellRendererAccel:accel-mode:
|
||||
*
|
||||
* Determines if the edited accelerators are GTK+ accelerators. If
|
||||
* they are, consumed modifiers are suppressed, only accelerators
|
||||
@ -161,13 +161,13 @@ gtk_cell_renderer_keys_class_init (GtkCellRendererKeysClass *cell_keys_class)
|
||||
g_param_spec_enum ("accel-mode",
|
||||
P_("Accelerator Mode"),
|
||||
P_("The type of accelerators"),
|
||||
GTK_TYPE_CELL_RENDERER_KEYS_MODE,
|
||||
GTK_CELL_RENDERER_KEYS_MODE_GTK,
|
||||
GTK_TYPE_CELL_RENDERER_ACCEL_MODE,
|
||||
GTK_CELL_RENDERER_ACCEL_MODE_GTK,
|
||||
GTK_PARAM_READWRITE));
|
||||
|
||||
/**
|
||||
* GtkCellRendererKeys::accel-edited:
|
||||
* @keys: the object reveiving the signal
|
||||
* GtkCellRendererAccel::accel-edited:
|
||||
* @accel: the object reveiving the signal
|
||||
* @path_string: the path identifying the row of the edited cell
|
||||
* @accel_key: the new accelerator keyval
|
||||
* @accel_mods: the new acclerator modifier mask
|
||||
@ -178,9 +178,9 @@ gtk_cell_renderer_keys_class_init (GtkCellRendererKeysClass *cell_keys_class)
|
||||
* Since: 2.10
|
||||
*/
|
||||
signals[ACCEL_EDITED] = g_signal_new (I_("accel-edited"),
|
||||
GTK_TYPE_CELL_RENDERER_KEYS,
|
||||
GTK_TYPE_CELL_RENDERER_ACCEL,
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (GtkCellRendererKeysClass, accel_edited),
|
||||
G_STRUCT_OFFSET (GtkCellRendererAccelClass, accel_edited),
|
||||
NULL, NULL,
|
||||
_gtk_marshal_VOID__STRING_UINT_FLAGS_UINT,
|
||||
G_TYPE_NONE, 4,
|
||||
@ -190,8 +190,8 @@ gtk_cell_renderer_keys_class_init (GtkCellRendererKeysClass *cell_keys_class)
|
||||
G_TYPE_UINT);
|
||||
|
||||
/**
|
||||
* GtkCellRendererKeys::accel-cleared:
|
||||
* @keys: the object reveiving the signal
|
||||
* GtkCellRendererAccel::accel-cleared:
|
||||
* @accel: the object reveiving the signal
|
||||
* @path_string: the path identifying the row of the edited cell
|
||||
*
|
||||
* Gets emitted when the user has removed the accelerator.
|
||||
@ -199,9 +199,9 @@ gtk_cell_renderer_keys_class_init (GtkCellRendererKeysClass *cell_keys_class)
|
||||
* Since: 2.10
|
||||
*/
|
||||
signals[ACCEL_CLEARED] = g_signal_new (I_("accel-cleared"),
|
||||
GTK_TYPE_CELL_RENDERER_KEYS,
|
||||
GTK_TYPE_CELL_RENDERER_ACCEL,
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (GtkCellRendererKeysClass, accel_cleared),
|
||||
G_STRUCT_OFFSET (GtkCellRendererAccelClass, accel_cleared),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__STRING,
|
||||
G_TYPE_NONE, 1,
|
||||
@ -210,32 +210,32 @@ gtk_cell_renderer_keys_class_init (GtkCellRendererKeysClass *cell_keys_class)
|
||||
|
||||
|
||||
/**
|
||||
* gtk_cell_renderer_keys_new:
|
||||
* gtk_cell_renderer_accel_new:
|
||||
*
|
||||
* Creates a new #GtkCellRendererKeys.
|
||||
* Creates a new #GtkCellRendererAccel.
|
||||
*
|
||||
* Returns: the new cell renderer
|
||||
*
|
||||
* Since: 2.10
|
||||
*/
|
||||
GtkCellRenderer *
|
||||
gtk_cell_renderer_keys_new (void)
|
||||
gtk_cell_renderer_accel_new (void)
|
||||
{
|
||||
return GTK_CELL_RENDERER (g_object_new (GTK_TYPE_CELL_RENDERER_KEYS, NULL));
|
||||
return GTK_CELL_RENDERER (g_object_new (GTK_TYPE_CELL_RENDERER_ACCEL, NULL));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_keys_finalize (GObject *object)
|
||||
gtk_cell_renderer_accel_finalize (GObject *object)
|
||||
{
|
||||
|
||||
(* G_OBJECT_CLASS (gtk_cell_renderer_keys_parent_class)->finalize) (object);
|
||||
(* G_OBJECT_CLASS (gtk_cell_renderer_accel_parent_class)->finalize) (object);
|
||||
}
|
||||
|
||||
static gchar *
|
||||
convert_keysym_state_to_string (GtkCellRendererKeys *keys,
|
||||
guint keysym,
|
||||
GdkModifierType mask,
|
||||
guint keycode)
|
||||
convert_keysym_state_to_string (GtkCellRendererAccel *accel,
|
||||
guint keysym,
|
||||
GdkModifierType mask,
|
||||
guint keycode)
|
||||
{
|
||||
if (keysym == 0 && keycode == 0)
|
||||
/* This label is displayed in a treeview cell displaying
|
||||
@ -245,7 +245,7 @@ convert_keysym_state_to_string (GtkCellRendererKeys *keys,
|
||||
return g_strdup (Q_("Accelerator|Disabled"));
|
||||
else
|
||||
{
|
||||
if (keys->accel_mode == GTK_CELL_RENDERER_KEYS_MODE_GTK)
|
||||
if (accel->accel_mode == GTK_CELL_RENDERER_ACCEL_MODE_GTK)
|
||||
return gtk_accelerator_get_label (keysym, mask);
|
||||
else
|
||||
{
|
||||
@ -267,29 +267,29 @@ convert_keysym_state_to_string (GtkCellRendererKeys *keys,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_keys_get_property (GObject *object,
|
||||
guint param_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
gtk_cell_renderer_accel_get_property (GObject *object,
|
||||
guint param_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkCellRendererKeys *keys;
|
||||
GtkCellRendererAccel *accel;
|
||||
|
||||
g_return_if_fail (GTK_IS_CELL_RENDERER_KEYS (object));
|
||||
g_return_if_fail (GTK_IS_CELL_RENDERER_ACCEL (object));
|
||||
|
||||
keys = GTK_CELL_RENDERER_KEYS (object);
|
||||
accel = GTK_CELL_RENDERER_ACCEL (object);
|
||||
|
||||
switch (param_id)
|
||||
{
|
||||
case PROP_ACCEL_KEY:
|
||||
g_value_set_uint (value, keys->accel_key);
|
||||
g_value_set_uint (value, accel->accel_key);
|
||||
break;
|
||||
|
||||
case PROP_ACCEL_MODS:
|
||||
g_value_set_flags (value, keys->accel_mods);
|
||||
g_value_set_flags (value, accel->accel_mods);
|
||||
break;
|
||||
|
||||
case PROP_ACCEL_MODE:
|
||||
g_value_set_enum (value, keys->accel_mode);
|
||||
g_value_set_enum (value, accel->accel_mode);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -298,17 +298,17 @@ gtk_cell_renderer_keys_get_property (GObject *object,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_keys_set_property (GObject *object,
|
||||
guint param_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
gtk_cell_renderer_accel_set_property (GObject *object,
|
||||
guint param_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkCellRendererKeys *keys;
|
||||
GtkCellRendererAccel *accel;
|
||||
gboolean changed = FALSE;
|
||||
|
||||
g_return_if_fail (GTK_IS_CELL_RENDERER_KEYS (object));
|
||||
g_return_if_fail (GTK_IS_CELL_RENDERER_ACCEL (object));
|
||||
|
||||
keys = GTK_CELL_RENDERER_KEYS (object);
|
||||
accel = GTK_CELL_RENDERER_ACCEL (object);
|
||||
|
||||
switch (param_id)
|
||||
{
|
||||
@ -316,9 +316,9 @@ gtk_cell_renderer_keys_set_property (GObject *object,
|
||||
{
|
||||
guint accel_key = g_value_get_uint (value);
|
||||
|
||||
if (keys->accel_key != accel_key)
|
||||
if (accel->accel_key != accel_key)
|
||||
{
|
||||
keys->accel_key = accel_key;
|
||||
accel->accel_key = accel_key;
|
||||
changed = TRUE;
|
||||
}
|
||||
}
|
||||
@ -328,9 +328,9 @@ gtk_cell_renderer_keys_set_property (GObject *object,
|
||||
{
|
||||
guint accel_mods = g_value_get_flags (value);
|
||||
|
||||
if (keys->accel_mods != accel_mods)
|
||||
if (accel->accel_mods != accel_mods)
|
||||
{
|
||||
keys->accel_mods = accel_mods;
|
||||
accel->accel_mods = accel_mods;
|
||||
changed = TRUE;
|
||||
}
|
||||
}
|
||||
@ -339,16 +339,16 @@ gtk_cell_renderer_keys_set_property (GObject *object,
|
||||
{
|
||||
guint keycode = g_value_get_uint (value);
|
||||
|
||||
if (keys->keycode != keycode)
|
||||
if (accel->keycode != keycode)
|
||||
{
|
||||
keys->keycode = keycode;
|
||||
accel->keycode = keycode;
|
||||
changed = TRUE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_ACCEL_MODE:
|
||||
keys->accel_mode = g_value_get_enum (value);
|
||||
accel->accel_mode = g_value_get_enum (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -360,32 +360,32 @@ gtk_cell_renderer_keys_set_property (GObject *object,
|
||||
GtkCellRendererText *celltext;
|
||||
gchar *text;
|
||||
|
||||
celltext = GTK_CELL_RENDERER_TEXT (keys);
|
||||
text = convert_keysym_state_to_string (keys, keys->accel_key, keys->accel_mods, keys->keycode);
|
||||
g_object_set (keys, "text", text, NULL);
|
||||
celltext = GTK_CELL_RENDERER_TEXT (accel);
|
||||
text = convert_keysym_state_to_string (accel, accel->accel_key, accel->accel_mods, accel->keycode);
|
||||
g_object_set (accel, "text", text, NULL);
|
||||
g_free (text);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_keys_get_size (GtkCellRenderer *cell,
|
||||
GtkWidget *widget,
|
||||
GdkRectangle *cell_area,
|
||||
gint *x_offset,
|
||||
gint *y_offset,
|
||||
gint *width,
|
||||
gint *height)
|
||||
gtk_cell_renderer_accel_get_size (GtkCellRenderer *cell,
|
||||
GtkWidget *widget,
|
||||
GdkRectangle *cell_area,
|
||||
gint *x_offset,
|
||||
gint *y_offset,
|
||||
gint *width,
|
||||
gint *height)
|
||||
|
||||
{
|
||||
GtkCellRendererKeys *keys = (GtkCellRendererKeys *) cell;
|
||||
GtkCellRendererAccel *accel = (GtkCellRendererAccel *) cell;
|
||||
GtkRequisition requisition;
|
||||
|
||||
if (keys->sizing_label == NULL)
|
||||
keys->sizing_label = gtk_label_new (_("New accelerator..."));
|
||||
if (accel->sizing_label == NULL)
|
||||
accel->sizing_label = gtk_label_new (_("New accelerator..."));
|
||||
|
||||
gtk_widget_size_request (keys->sizing_label, &requisition);
|
||||
(* GTK_CELL_RENDERER_CLASS (gtk_cell_renderer_keys_parent_class)->get_size) (cell, widget, cell_area,
|
||||
x_offset, y_offset, width, height);
|
||||
gtk_widget_size_request (accel->sizing_label, &requisition);
|
||||
(* GTK_CELL_RENDERER_CLASS (gtk_cell_renderer_accel_parent_class)->get_size) (cell, widget, cell_area,
|
||||
x_offset, y_offset, width, height);
|
||||
/* FIXME: need to take the cell_area et al. into account */
|
||||
if (width)
|
||||
*width = MAX (*width, requisition.width);
|
||||
@ -400,14 +400,14 @@ grab_key_callback (GtkWidget *widget,
|
||||
{
|
||||
GdkModifierType accel_mods = 0;
|
||||
guint accel_key;
|
||||
GtkCellRendererKeys *keys;
|
||||
GtkCellRendererAccel *accel;
|
||||
char *path;
|
||||
gboolean edited;
|
||||
gboolean cleared;
|
||||
GdkModifierType consumed_modifiers;
|
||||
GdkDisplay *display;
|
||||
|
||||
keys = GTK_CELL_RENDERER_KEYS (data);
|
||||
accel = GTK_CELL_RENDERER_ACCEL (data);
|
||||
|
||||
display = gtk_widget_get_display (widget);
|
||||
|
||||
@ -431,7 +431,7 @@ grab_key_callback (GtkWidget *widget,
|
||||
|
||||
/* Filter consumed modifiers
|
||||
*/
|
||||
if (keys->accel_mode == GTK_CELL_RENDERER_KEYS_MODE_GTK)
|
||||
if (accel->accel_mode == GTK_CELL_RENDERER_ACCEL_MODE_GTK)
|
||||
accel_mods &= ~consumed_modifiers;
|
||||
|
||||
/* Put shift back if it changed the case of the key, not otherwise.
|
||||
@ -454,7 +454,7 @@ grab_key_callback (GtkWidget *widget,
|
||||
}
|
||||
}
|
||||
|
||||
if (keys->accel_mode == GTK_CELL_RENDERER_KEYS_MODE_GTK)
|
||||
if (accel->accel_mode == GTK_CELL_RENDERER_ACCEL_MODE_GTK)
|
||||
{
|
||||
if (!gtk_accelerator_valid (accel_key, accel_mods))
|
||||
{
|
||||
@ -470,18 +470,18 @@ grab_key_callback (GtkWidget *widget,
|
||||
gdk_keyboard_ungrab (event->time);
|
||||
gdk_pointer_ungrab (event->time);
|
||||
|
||||
path = g_strdup (g_object_get_data (G_OBJECT (keys->edit_widget), "gtk-cell-renderer-text"));
|
||||
path = g_strdup (g_object_get_data (G_OBJECT (accel->edit_widget), "gtk-cell-renderer-text"));
|
||||
|
||||
gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (keys->edit_widget));
|
||||
gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (keys->edit_widget));
|
||||
keys->edit_widget = NULL;
|
||||
keys->grab_widget = NULL;
|
||||
gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (accel->edit_widget));
|
||||
gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (accel->edit_widget));
|
||||
accel->edit_widget = NULL;
|
||||
accel->grab_widget = NULL;
|
||||
|
||||
if (edited)
|
||||
g_signal_emit (keys, signals[ACCEL_EDITED], 0, path,
|
||||
g_signal_emit (accel, signals[ACCEL_EDITED], 0, path,
|
||||
accel_key, accel_mods, event->hardware_keycode);
|
||||
else if (cleared)
|
||||
g_signal_emit (keys, signals[ACCEL_CLEARED], 0, path);
|
||||
g_signal_emit (accel, signals[ACCEL_CLEARED], 0, path);
|
||||
|
||||
g_free (path);
|
||||
|
||||
@ -489,14 +489,15 @@ grab_key_callback (GtkWidget *widget,
|
||||
}
|
||||
|
||||
static void
|
||||
ungrab_stuff (GtkWidget *widget, gpointer data)
|
||||
ungrab_stuff (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
GtkCellRendererKeys *keys = GTK_CELL_RENDERER_KEYS (data);
|
||||
GtkCellRendererAccel *accel = GTK_CELL_RENDERER_ACCEL (data);
|
||||
|
||||
gdk_keyboard_ungrab (GDK_CURRENT_TIME);
|
||||
gdk_pointer_ungrab (GDK_CURRENT_TIME);
|
||||
|
||||
g_signal_handlers_disconnect_by_func (G_OBJECT (keys->grab_widget),
|
||||
g_signal_handlers_disconnect_by_func (G_OBJECT (accel->grab_widget),
|
||||
G_CALLBACK (grab_key_callback), data);
|
||||
}
|
||||
|
||||
@ -532,21 +533,21 @@ _gtk_cell_editable_event_box_init (GtkCellEditableEventBox *box)
|
||||
}
|
||||
|
||||
static GtkCellEditable *
|
||||
gtk_cell_renderer_keys_start_editing (GtkCellRenderer *cell,
|
||||
GdkEvent *event,
|
||||
GtkWidget *widget,
|
||||
const gchar *path,
|
||||
GdkRectangle *background_area,
|
||||
GdkRectangle *cell_area,
|
||||
GtkCellRendererState flags)
|
||||
gtk_cell_renderer_accel_start_editing (GtkCellRenderer *cell,
|
||||
GdkEvent *event,
|
||||
GtkWidget *widget,
|
||||
const gchar *path,
|
||||
GdkRectangle *background_area,
|
||||
GdkRectangle *cell_area,
|
||||
GtkCellRendererState flags)
|
||||
{
|
||||
GtkCellRendererText *celltext;
|
||||
GtkCellRendererKeys *keys;
|
||||
GtkCellRendererAccel *accel;
|
||||
GtkWidget *label;
|
||||
GtkWidget *eventbox;
|
||||
|
||||
celltext = GTK_CELL_RENDERER_TEXT (cell);
|
||||
keys = GTK_CELL_RENDERER_KEYS (cell);
|
||||
accel = GTK_CELL_RENDERER_ACCEL (cell);
|
||||
|
||||
/* If the cell isn't editable we return NULL. */
|
||||
if (celltext->editable == FALSE)
|
||||
@ -567,16 +568,16 @@ gtk_cell_renderer_keys_start_editing (GtkCellRenderer *cell,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
keys->grab_widget = widget;
|
||||
accel->grab_widget = widget;
|
||||
|
||||
g_signal_connect (G_OBJECT (widget), "key_press_event",
|
||||
G_CALLBACK (grab_key_callback),
|
||||
keys);
|
||||
accel);
|
||||
|
||||
eventbox = g_object_new (_gtk_cell_editable_event_box_get_type (), NULL);
|
||||
keys->edit_widget = eventbox;
|
||||
g_object_add_weak_pointer (G_OBJECT (keys->edit_widget),
|
||||
(void**) &keys->edit_widget);
|
||||
accel->edit_widget = eventbox;
|
||||
g_object_add_weak_pointer (G_OBJECT (accel->edit_widget),
|
||||
(void**) &accel->edit_widget);
|
||||
|
||||
label = gtk_label_new (NULL);
|
||||
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
||||
@ -595,17 +596,17 @@ gtk_cell_renderer_keys_start_editing (GtkCellRenderer *cell,
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (eventbox), label);
|
||||
|
||||
g_object_set_data_full (G_OBJECT (keys->edit_widget), "gtk-cell-renderer-text",
|
||||
g_object_set_data_full (G_OBJECT (accel->edit_widget), "gtk-cell-renderer-text",
|
||||
g_strdup (path), g_free);
|
||||
|
||||
gtk_widget_show_all (keys->edit_widget);
|
||||
gtk_widget_show_all (accel->edit_widget);
|
||||
|
||||
g_signal_connect (G_OBJECT (keys->edit_widget), "unrealize",
|
||||
G_CALLBACK (ungrab_stuff), keys);
|
||||
g_signal_connect (G_OBJECT (accel->edit_widget), "unrealize",
|
||||
G_CALLBACK (ungrab_stuff), accel);
|
||||
|
||||
return GTK_CELL_EDITABLE (keys->edit_widget);
|
||||
return GTK_CELL_EDITABLE (accel->edit_widget);
|
||||
}
|
||||
|
||||
|
||||
#define __GTK_CELL_RENDERER_KEYS_C__
|
||||
#define __GTK_CELL_RENDERER_ACCEL_C__
|
||||
#include "gtkaliasdef.c"
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* gtkcellrendererkeys.h
|
||||
/* gtkcellrendereraccel.h
|
||||
* Copyright (C) 2000 Red Hat, Inc., Jonathan Blandford <jrb@redhat.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
@ -17,32 +17,32 @@
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GTK_CELL_RENDERER_KEYS_H__
|
||||
#define __GTK_CELL_RENDERER_KEYS_H__
|
||||
#ifndef __GTK_CELL_RENDERER_ACCEL_H__
|
||||
#define __GTK_CELL_RENDERER_ACCEL_H__
|
||||
|
||||
#include "gtkcellrenderertext.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_CELL_RENDERER_KEYS (gtk_cell_renderer_keys_get_type ())
|
||||
#define GTK_CELL_RENDERER_KEYS(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_CELL_RENDERER_KEYS, GtkCellRendererKeys))
|
||||
#define GTK_CELL_RENDERER_KEYS_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_CELL_RENDERER_KEYS, GtkCellRendererKeysClass))
|
||||
#define GTK_IS_CELL_RENDERER_KEYS(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_CELL_RENDERER_KEYS))
|
||||
#define GTK_IS_CELL_RENDERER_KEYS_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_CELL_RENDERER_KEYS))
|
||||
#define GTK_CELL_RENDERER_KEYS_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_CELL_RENDERER_KEYS, GtkCellRendererKeysClass))
|
||||
#define GTK_TYPE_CELL_RENDERER_ACCEL (gtk_cell_renderer_accel_get_type ())
|
||||
#define GTK_CELL_RENDERER_ACCEL(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_CELL_RENDERER_ACCEL, GtkCellRendererAccel))
|
||||
#define GTK_CELL_RENDERER_ACCEL_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_CELL_RENDERER_ACCEL, GtkCellRendererAccelClass))
|
||||
#define GTK_IS_CELL_RENDERER_ACCEL(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_CELL_RENDERER_ACCEL))
|
||||
#define GTK_IS_CELL_RENDERER_ACCEL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_CELL_RENDERER_ACCEL))
|
||||
#define GTK_CELL_RENDERER_ACCEL_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_CELL_RENDERER_ACCEL, GtkCellRendererAccelClass))
|
||||
|
||||
typedef struct _GtkCellRendererKeys GtkCellRendererKeys;
|
||||
typedef struct _GtkCellRendererKeysClass GtkCellRendererKeysClass;
|
||||
typedef struct _GtkCellRendererAccel GtkCellRendererAccel;
|
||||
typedef struct _GtkCellRendererAccelClass GtkCellRendererAccelClass;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GTK_CELL_RENDERER_KEYS_MODE_GTK,
|
||||
GTK_CELL_RENDERER_KEYS_MODE_OTHER
|
||||
} GtkCellRendererKeysMode;
|
||||
GTK_CELL_RENDERER_ACCEL_MODE_GTK,
|
||||
GTK_CELL_RENDERER_ACCEL_MODE_OTHER
|
||||
} GtkCellRendererAccelMode;
|
||||
|
||||
|
||||
struct _GtkCellRendererKeys
|
||||
struct _GtkCellRendererAccel
|
||||
{
|
||||
GtkCellRendererText parent;
|
||||
|
||||
@ -50,25 +50,25 @@ struct _GtkCellRendererKeys
|
||||
guint accel_key;
|
||||
GdkModifierType accel_mods;
|
||||
guint keycode;
|
||||
GtkCellRendererKeysMode accel_mode;
|
||||
GtkCellRendererAccelMode accel_mode;
|
||||
|
||||
GtkWidget *edit_widget;
|
||||
GtkWidget *grab_widget;
|
||||
GtkWidget *sizing_label;
|
||||
};
|
||||
|
||||
struct _GtkCellRendererKeysClass
|
||||
struct _GtkCellRendererAccelClass
|
||||
{
|
||||
GtkCellRendererTextClass parent_class;
|
||||
|
||||
void (* accel_edited) (GtkCellRendererKeys *keys,
|
||||
const gchar *path_string,
|
||||
guint accel_key,
|
||||
GdkModifierType accel_mods,
|
||||
guint hardware_keycode);
|
||||
void (* accel_edited) (GtkCellRendererAccel *accel,
|
||||
const gchar *path_string,
|
||||
guint accel_key,
|
||||
GdkModifierType accel_mods,
|
||||
guint hardware_keycode);
|
||||
|
||||
void (* accel_cleared) (GtkCellRendererKeys *keys,
|
||||
const gchar *path_string);
|
||||
void (* accel_cleared) (GtkCellRendererAccel *accel,
|
||||
const gchar *path_string);
|
||||
|
||||
/* Padding for future expansion */
|
||||
void (*_gtk_reserved0) (void);
|
||||
@ -78,11 +78,11 @@ struct _GtkCellRendererKeysClass
|
||||
void (*_gtk_reserved4) (void);
|
||||
};
|
||||
|
||||
GType gtk_cell_renderer_keys_get_type (void) G_GNUC_CONST;
|
||||
GtkCellRenderer *gtk_cell_renderer_keys_new (void);
|
||||
GType gtk_cell_renderer_accel_get_type (void) G_GNUC_CONST;
|
||||
GtkCellRenderer *gtk_cell_renderer_accel_new (void);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
#endif /* __GTK_CELL_RENDERER_KEYS_H__ */
|
||||
#endif /* __GTK_CELL_RENDERER_ACCEL_H__ */
|
||||
|
@ -1,611 +0,0 @@
|
||||
/* gtkcellrendererkeys.h
|
||||
* Copyright (C) 2000 Red Hat, Inc., Jonathan Blandford <jrb@redhat.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "gtkintl.h"
|
||||
#include "gtkaccelgroup.h"
|
||||
#include "gtkmarshalers.h"
|
||||
#include "gtkcellrendererkeys.h"
|
||||
#include "gtklabel.h"
|
||||
#include "gtkeventbox.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gdk/gdkkeysyms.h"
|
||||
#include "gtkalias.h"
|
||||
|
||||
|
||||
static void gtk_cell_renderer_keys_finalize (GObject *object);
|
||||
static GtkCellEditable *gtk_cell_renderer_keys_start_editing (GtkCellRenderer *cell,
|
||||
GdkEvent *event,
|
||||
GtkWidget *widget,
|
||||
const gchar *path,
|
||||
GdkRectangle *background_area,
|
||||
GdkRectangle *cell_area,
|
||||
GtkCellRendererState flags);
|
||||
|
||||
static void gtk_cell_renderer_keys_get_property (GObject *object,
|
||||
guint param_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_cell_renderer_keys_set_property (GObject *object,
|
||||
guint param_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_cell_renderer_keys_get_size (GtkCellRenderer *cell,
|
||||
GtkWidget *widget,
|
||||
GdkRectangle *cell_area,
|
||||
gint *x_offset,
|
||||
gint *y_offset,
|
||||
gint *width,
|
||||
gint *height);
|
||||
|
||||
enum {
|
||||
ACCEL_EDITED,
|
||||
ACCEL_CLEARED,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_ACCEL_KEY,
|
||||
PROP_ACCEL_MODS,
|
||||
PROP_KEYCODE,
|
||||
PROP_ACCEL_MODE
|
||||
};
|
||||
|
||||
static guint signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
G_DEFINE_TYPE (GtkCellRendererKeys, gtk_cell_renderer_keys, GTK_TYPE_CELL_RENDERER_TEXT);
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_keys_init (GtkCellRendererKeys *cell_keys)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_keys_class_init (GtkCellRendererKeysClass *cell_keys_class)
|
||||
{
|
||||
GObjectClass *object_class;
|
||||
GtkCellRendererClass *cell_renderer_class;
|
||||
|
||||
object_class = G_OBJECT_CLASS (cell_keys_class);
|
||||
cell_renderer_class = GTK_CELL_RENDERER_CLASS (cell_keys_class);
|
||||
|
||||
GTK_CELL_RENDERER_CLASS (cell_keys_class)->start_editing = gtk_cell_renderer_keys_start_editing;
|
||||
|
||||
object_class->set_property = gtk_cell_renderer_keys_set_property;
|
||||
object_class->get_property = gtk_cell_renderer_keys_get_property;
|
||||
cell_renderer_class->get_size = gtk_cell_renderer_keys_get_size;
|
||||
|
||||
object_class->finalize = gtk_cell_renderer_keys_finalize;
|
||||
|
||||
/**
|
||||
* GtkCellRendererKeys:accel-key:
|
||||
*
|
||||
* The keyval of the accelerator.
|
||||
*
|
||||
* Since: 2.10
|
||||
*/
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_ACCEL_KEY,
|
||||
g_param_spec_uint ("accel-key",
|
||||
P_("Accelerator key"),
|
||||
P_("The keyval of the accelerator"),
|
||||
0,
|
||||
G_MAXINT,
|
||||
0,
|
||||
GTK_PARAM_READWRITE));
|
||||
|
||||
/**
|
||||
* GtkCellRendererKeys:accel-mods:
|
||||
*
|
||||
* The modifier mask of the accelerator.
|
||||
*
|
||||
* Since: 2.10
|
||||
*/
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_ACCEL_MODS,
|
||||
g_param_spec_flags ("accel-mods",
|
||||
P_("Accelerator modifiers"),
|
||||
P_("The modifier mask of the accelerator"),
|
||||
GDK_TYPE_MODIFIER_TYPE,
|
||||
0,
|
||||
GTK_PARAM_READWRITE));
|
||||
|
||||
/**
|
||||
* GtkCellRendererKeys:keycode:
|
||||
*
|
||||
* The hardware keycode of the accelerator. Note that the hardware keycode is
|
||||
* only relevant if the key does not have a keyval. Normally, the keyboard
|
||||
* configuration should assign keyvals to all keys.
|
||||
*
|
||||
* Since: 2.10
|
||||
*/
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_KEYCODE,
|
||||
g_param_spec_uint ("keycode",
|
||||
P_("Accelerator keycode"),
|
||||
P_("The hardware keycode of the accelerator"),
|
||||
0,
|
||||
G_MAXINT,
|
||||
0,
|
||||
GTK_PARAM_READWRITE));
|
||||
|
||||
/**
|
||||
* GtkCellRendererKeys:accel-mode:
|
||||
*
|
||||
* Determines if the edited accelerators are GTK+ accelerators. If
|
||||
* they are, consumed modifiers are suppressed, only accelerators
|
||||
* accepted by GTK+ are allowed, and the accelerators are rendered
|
||||
* in the same way as they are in menus.
|
||||
*
|
||||
* Since: 2.10
|
||||
*/
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_ACCEL_MODE,
|
||||
g_param_spec_enum ("accel-mode",
|
||||
P_("Accelerator Mode"),
|
||||
P_("The type of accelerators"),
|
||||
GTK_TYPE_CELL_RENDERER_KEYS_MODE,
|
||||
GTK_CELL_RENDERER_KEYS_MODE_GTK,
|
||||
GTK_PARAM_READWRITE));
|
||||
|
||||
/**
|
||||
* GtkCellRendererKeys::accel-edited:
|
||||
* @keys: the object reveiving the signal
|
||||
* @path_string: the path identifying the row of the edited cell
|
||||
* @accel_key: the new accelerator keyval
|
||||
* @accel_mods: the new acclerator modifier mask
|
||||
* @hardware_keycode: the keycode of the new accelerator
|
||||
*
|
||||
* Gets emitted when the user has selected a new accelerator.
|
||||
*
|
||||
* Since: 2.10
|
||||
*/
|
||||
signals[ACCEL_EDITED] = g_signal_new (I_("accel-edited"),
|
||||
GTK_TYPE_CELL_RENDERER_KEYS,
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (GtkCellRendererKeysClass, accel_edited),
|
||||
NULL, NULL,
|
||||
_gtk_marshal_VOID__STRING_UINT_FLAGS_UINT,
|
||||
G_TYPE_NONE, 4,
|
||||
G_TYPE_STRING,
|
||||
G_TYPE_UINT,
|
||||
GDK_TYPE_MODIFIER_TYPE,
|
||||
G_TYPE_UINT);
|
||||
|
||||
/**
|
||||
* GtkCellRendererKeys::accel-cleared:
|
||||
* @keys: the object reveiving the signal
|
||||
* @path_string: the path identifying the row of the edited cell
|
||||
*
|
||||
* Gets emitted when the user has removed the accelerator.
|
||||
*
|
||||
* Since: 2.10
|
||||
*/
|
||||
signals[ACCEL_CLEARED] = g_signal_new (I_("accel-cleared"),
|
||||
GTK_TYPE_CELL_RENDERER_KEYS,
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (GtkCellRendererKeysClass, accel_cleared),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__STRING,
|
||||
G_TYPE_NONE, 1,
|
||||
G_TYPE_STRING);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gtk_cell_renderer_keys_new:
|
||||
*
|
||||
* Creates a new #GtkCellRendererKeys.
|
||||
*
|
||||
* Returns: the new cell renderer
|
||||
*
|
||||
* Since: 2.10
|
||||
*/
|
||||
GtkCellRenderer *
|
||||
gtk_cell_renderer_keys_new (void)
|
||||
{
|
||||
return GTK_CELL_RENDERER (g_object_new (GTK_TYPE_CELL_RENDERER_KEYS, NULL));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_keys_finalize (GObject *object)
|
||||
{
|
||||
|
||||
(* G_OBJECT_CLASS (gtk_cell_renderer_keys_parent_class)->finalize) (object);
|
||||
}
|
||||
|
||||
static gchar *
|
||||
convert_keysym_state_to_string (GtkCellRendererKeys *keys,
|
||||
guint keysym,
|
||||
GdkModifierType mask,
|
||||
guint keycode)
|
||||
{
|
||||
if (keysym == 0 && keycode == 0)
|
||||
/* This label is displayed in a treeview cell displaying
|
||||
* a disabled accelerator key combination. Only include
|
||||
* the text after the | in the translation.
|
||||
*/
|
||||
return g_strdup (Q_("Accelerator|Disabled"));
|
||||
else
|
||||
{
|
||||
if (keys->accel_mode == GTK_CELL_RENDERER_KEYS_MODE_GTK)
|
||||
return gtk_accelerator_get_label (keysym, mask);
|
||||
else
|
||||
{
|
||||
gchar *name;
|
||||
|
||||
name = gtk_accelerator_name (keysym, mask);
|
||||
if (keysym == 0)
|
||||
{
|
||||
gchar *tmp;
|
||||
|
||||
tmp = name;
|
||||
name = g_strdup_printf ("%s0x%02x", tmp, keycode);
|
||||
g_free (tmp);
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_keys_get_property (GObject *object,
|
||||
guint param_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkCellRendererKeys *keys;
|
||||
|
||||
g_return_if_fail (GTK_IS_CELL_RENDERER_KEYS (object));
|
||||
|
||||
keys = GTK_CELL_RENDERER_KEYS (object);
|
||||
|
||||
switch (param_id)
|
||||
{
|
||||
case PROP_ACCEL_KEY:
|
||||
g_value_set_uint (value, keys->accel_key);
|
||||
break;
|
||||
|
||||
case PROP_ACCEL_MODS:
|
||||
g_value_set_flags (value, keys->accel_mods);
|
||||
break;
|
||||
|
||||
case PROP_ACCEL_MODE:
|
||||
g_value_set_enum (value, keys->accel_mode);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_keys_set_property (GObject *object,
|
||||
guint param_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkCellRendererKeys *keys;
|
||||
gboolean changed = FALSE;
|
||||
|
||||
g_return_if_fail (GTK_IS_CELL_RENDERER_KEYS (object));
|
||||
|
||||
keys = GTK_CELL_RENDERER_KEYS (object);
|
||||
|
||||
switch (param_id)
|
||||
{
|
||||
case PROP_ACCEL_KEY:
|
||||
{
|
||||
guint accel_key = g_value_get_uint (value);
|
||||
|
||||
if (keys->accel_key != accel_key)
|
||||
{
|
||||
keys->accel_key = accel_key;
|
||||
changed = TRUE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_ACCEL_MODS:
|
||||
{
|
||||
guint accel_mods = g_value_get_flags (value);
|
||||
|
||||
if (keys->accel_mods != accel_mods)
|
||||
{
|
||||
keys->accel_mods = accel_mods;
|
||||
changed = TRUE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PROP_KEYCODE:
|
||||
{
|
||||
guint keycode = g_value_get_uint (value);
|
||||
|
||||
if (keys->keycode != keycode)
|
||||
{
|
||||
keys->keycode = keycode;
|
||||
changed = TRUE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case PROP_ACCEL_MODE:
|
||||
keys->accel_mode = g_value_get_enum (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
||||
}
|
||||
|
||||
if (changed)
|
||||
{
|
||||
GtkCellRendererText *celltext;
|
||||
gchar *text;
|
||||
|
||||
celltext = GTK_CELL_RENDERER_TEXT (keys);
|
||||
text = convert_keysym_state_to_string (keys, keys->accel_key, keys->accel_mods, keys->keycode);
|
||||
g_object_set (keys, "text", text, NULL);
|
||||
g_free (text);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_cell_renderer_keys_get_size (GtkCellRenderer *cell,
|
||||
GtkWidget *widget,
|
||||
GdkRectangle *cell_area,
|
||||
gint *x_offset,
|
||||
gint *y_offset,
|
||||
gint *width,
|
||||
gint *height)
|
||||
|
||||
{
|
||||
GtkCellRendererKeys *keys = (GtkCellRendererKeys *) cell;
|
||||
GtkRequisition requisition;
|
||||
|
||||
if (keys->sizing_label == NULL)
|
||||
keys->sizing_label = gtk_label_new (_("New accelerator..."));
|
||||
|
||||
gtk_widget_size_request (keys->sizing_label, &requisition);
|
||||
(* GTK_CELL_RENDERER_CLASS (gtk_cell_renderer_keys_parent_class)->get_size) (cell, widget, cell_area,
|
||||
x_offset, y_offset, width, height);
|
||||
/* FIXME: need to take the cell_area et al. into account */
|
||||
if (width)
|
||||
*width = MAX (*width, requisition.width);
|
||||
if (height)
|
||||
*height = MAX (*height, requisition.height);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
grab_key_callback (GtkWidget *widget,
|
||||
GdkEventKey *event,
|
||||
void *data)
|
||||
{
|
||||
GdkModifierType accel_mods = 0;
|
||||
guint accel_key;
|
||||
GtkCellRendererKeys *keys;
|
||||
char *path;
|
||||
gboolean edited;
|
||||
gboolean cleared;
|
||||
GdkModifierType consumed_modifiers;
|
||||
GdkDisplay *display;
|
||||
|
||||
keys = GTK_CELL_RENDERER_KEYS (data);
|
||||
|
||||
display = gtk_widget_get_display (widget);
|
||||
|
||||
if (event->is_modifier)
|
||||
return TRUE;
|
||||
|
||||
edited = FALSE;
|
||||
cleared = FALSE;
|
||||
|
||||
gdk_keymap_translate_keyboard_state (gdk_keymap_get_for_display (display),
|
||||
event->hardware_keycode,
|
||||
event->state,
|
||||
event->group,
|
||||
NULL, NULL, NULL, &consumed_modifiers);
|
||||
|
||||
accel_key = gdk_keyval_to_lower (event->keyval);
|
||||
if (accel_key == GDK_ISO_Left_Tab)
|
||||
accel_key = GDK_Tab;
|
||||
|
||||
accel_mods = event->state & gtk_accelerator_get_default_mod_mask ();
|
||||
|
||||
/* Filter consumed modifiers
|
||||
*/
|
||||
if (keys->accel_mode == GTK_CELL_RENDERER_KEYS_MODE_GTK)
|
||||
accel_mods &= ~consumed_modifiers;
|
||||
|
||||
/* Put shift back if it changed the case of the key, not otherwise.
|
||||
*/
|
||||
if (accel_key != event->keyval)
|
||||
accel_mods |= GDK_SHIFT_MASK;
|
||||
|
||||
if (accel_mods == 0)
|
||||
{
|
||||
switch (event->keyval)
|
||||
{
|
||||
case GDK_Escape:
|
||||
goto out; /* cancel */
|
||||
case GDK_BackSpace:
|
||||
/* clear the accelerator on Backspace */
|
||||
cleared = TRUE;
|
||||
goto out;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (keys->accel_mode == GTK_CELL_RENDERER_KEYS_MODE_GTK)
|
||||
{
|
||||
if (!gtk_accelerator_valid (accel_key, accel_mods))
|
||||
{
|
||||
gdk_display_beep (display);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
edited = TRUE;
|
||||
|
||||
out:
|
||||
gdk_keyboard_ungrab (event->time);
|
||||
gdk_pointer_ungrab (event->time);
|
||||
|
||||
path = g_strdup (g_object_get_data (G_OBJECT (keys->edit_widget), "gtk-cell-renderer-text"));
|
||||
|
||||
gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (keys->edit_widget));
|
||||
gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (keys->edit_widget));
|
||||
keys->edit_widget = NULL;
|
||||
keys->grab_widget = NULL;
|
||||
|
||||
if (edited)
|
||||
g_signal_emit (keys, signals[ACCEL_EDITED], 0, path,
|
||||
accel_key, accel_mods, event->hardware_keycode);
|
||||
else if (cleared)
|
||||
g_signal_emit (keys, signals[ACCEL_CLEARED], 0, path);
|
||||
|
||||
g_free (path);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
ungrab_stuff (GtkWidget *widget, gpointer data)
|
||||
{
|
||||
GtkCellRendererKeys *keys = GTK_CELL_RENDERER_KEYS (data);
|
||||
|
||||
gdk_keyboard_ungrab (GDK_CURRENT_TIME);
|
||||
gdk_pointer_ungrab (GDK_CURRENT_TIME);
|
||||
|
||||
g_signal_handlers_disconnect_by_func (G_OBJECT (keys->grab_widget),
|
||||
G_CALLBACK (grab_key_callback), data);
|
||||
}
|
||||
|
||||
static void
|
||||
_gtk_cell_editable_event_box_start_editing (GtkCellEditable *cell_editable,
|
||||
GdkEvent *event)
|
||||
{
|
||||
/* do nothing, because we are pointless */
|
||||
}
|
||||
|
||||
static void
|
||||
_gtk_cell_editable_event_box_cell_editable_init (GtkCellEditableIface *iface)
|
||||
{
|
||||
iface->start_editing = _gtk_cell_editable_event_box_start_editing;
|
||||
}
|
||||
|
||||
typedef GtkEventBox GtkCellEditableEventBox;
|
||||
typedef GtkEventBoxClass GtkCellEditableEventBoxClass;
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GtkCellEditableEventBox, _gtk_cell_editable_event_box, GTK_TYPE_EVENT_BOX, { \
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_CELL_EDITABLE, _gtk_cell_editable_event_box_cell_editable_init) \
|
||||
});
|
||||
|
||||
|
||||
static void
|
||||
_gtk_cell_editable_event_box_class_init (GtkCellEditableEventBoxClass *class)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
_gtk_cell_editable_event_box_init (GtkCellEditableEventBox *box)
|
||||
{
|
||||
}
|
||||
|
||||
static GtkCellEditable *
|
||||
gtk_cell_renderer_keys_start_editing (GtkCellRenderer *cell,
|
||||
GdkEvent *event,
|
||||
GtkWidget *widget,
|
||||
const gchar *path,
|
||||
GdkRectangle *background_area,
|
||||
GdkRectangle *cell_area,
|
||||
GtkCellRendererState flags)
|
||||
{
|
||||
GtkCellRendererText *celltext;
|
||||
GtkCellRendererKeys *keys;
|
||||
GtkWidget *label;
|
||||
GtkWidget *eventbox;
|
||||
|
||||
celltext = GTK_CELL_RENDERER_TEXT (cell);
|
||||
keys = GTK_CELL_RENDERER_KEYS (cell);
|
||||
|
||||
/* If the cell isn't editable we return NULL. */
|
||||
if (celltext->editable == FALSE)
|
||||
return NULL;
|
||||
|
||||
g_return_val_if_fail (widget->window != NULL, NULL);
|
||||
|
||||
if (gdk_keyboard_grab (widget->window, FALSE,
|
||||
gdk_event_get_time (event)) != GDK_GRAB_SUCCESS)
|
||||
return NULL;
|
||||
|
||||
if (gdk_pointer_grab (widget->window, FALSE,
|
||||
GDK_BUTTON_PRESS_MASK,
|
||||
NULL, NULL,
|
||||
gdk_event_get_time (event)) != GDK_GRAB_SUCCESS)
|
||||
{
|
||||
gdk_keyboard_ungrab (gdk_event_get_time (event));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
keys->grab_widget = widget;
|
||||
|
||||
g_signal_connect (G_OBJECT (widget), "key_press_event",
|
||||
G_CALLBACK (grab_key_callback),
|
||||
keys);
|
||||
|
||||
eventbox = g_object_new (_gtk_cell_editable_event_box_get_type (), NULL);
|
||||
keys->edit_widget = eventbox;
|
||||
g_object_add_weak_pointer (G_OBJECT (keys->edit_widget),
|
||||
(void**) &keys->edit_widget);
|
||||
|
||||
label = gtk_label_new (NULL);
|
||||
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
||||
|
||||
gtk_widget_modify_bg (eventbox, GTK_STATE_NORMAL,
|
||||
&widget->style->bg[GTK_STATE_SELECTED]);
|
||||
|
||||
gtk_widget_modify_fg (label, GTK_STATE_NORMAL,
|
||||
&widget->style->fg[GTK_STATE_SELECTED]);
|
||||
|
||||
/* This label is displayed in a treeview cell displaying
|
||||
* an accelerator when the cell is clicked to change the
|
||||
* acelerator.
|
||||
*/
|
||||
gtk_label_set_text (GTK_LABEL (label), _("New accelerator..."));
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (eventbox), label);
|
||||
|
||||
g_object_set_data_full (G_OBJECT (keys->edit_widget), "gtk-cell-renderer-text",
|
||||
g_strdup (path), g_free);
|
||||
|
||||
gtk_widget_show_all (keys->edit_widget);
|
||||
|
||||
g_signal_connect (G_OBJECT (keys->edit_widget), "unrealize",
|
||||
G_CALLBACK (ungrab_stuff), keys);
|
||||
|
||||
return GTK_CELL_EDITABLE (keys->edit_widget);
|
||||
}
|
||||
|
||||
|
||||
#define __GTK_CELL_RENDERER_KEYS_C__
|
||||
#include "gtkaliasdef.c"
|
@ -1,88 +0,0 @@
|
||||
/* gtkcellrendererkeys.h
|
||||
* Copyright (C) 2000 Red Hat, Inc., Jonathan Blandford <jrb@redhat.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GTK_CELL_RENDERER_KEYS_H__
|
||||
#define __GTK_CELL_RENDERER_KEYS_H__
|
||||
|
||||
#include "gtkcellrenderertext.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_CELL_RENDERER_KEYS (gtk_cell_renderer_keys_get_type ())
|
||||
#define GTK_CELL_RENDERER_KEYS(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_CELL_RENDERER_KEYS, GtkCellRendererKeys))
|
||||
#define GTK_CELL_RENDERER_KEYS_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_CELL_RENDERER_KEYS, GtkCellRendererKeysClass))
|
||||
#define GTK_IS_CELL_RENDERER_KEYS(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_CELL_RENDERER_KEYS))
|
||||
#define GTK_IS_CELL_RENDERER_KEYS_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_CELL_RENDERER_KEYS))
|
||||
#define GTK_CELL_RENDERER_KEYS_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_CELL_RENDERER_KEYS, GtkCellRendererKeysClass))
|
||||
|
||||
typedef struct _GtkCellRendererKeys GtkCellRendererKeys;
|
||||
typedef struct _GtkCellRendererKeysClass GtkCellRendererKeysClass;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GTK_CELL_RENDERER_KEYS_MODE_GTK,
|
||||
GTK_CELL_RENDERER_KEYS_MODE_OTHER
|
||||
} GtkCellRendererKeysMode;
|
||||
|
||||
|
||||
struct _GtkCellRendererKeys
|
||||
{
|
||||
GtkCellRendererText parent;
|
||||
|
||||
/*< private >*/
|
||||
guint accel_key;
|
||||
GdkModifierType accel_mods;
|
||||
guint keycode;
|
||||
GtkCellRendererKeysMode accel_mode;
|
||||
|
||||
GtkWidget *edit_widget;
|
||||
GtkWidget *grab_widget;
|
||||
GtkWidget *sizing_label;
|
||||
};
|
||||
|
||||
struct _GtkCellRendererKeysClass
|
||||
{
|
||||
GtkCellRendererTextClass parent_class;
|
||||
|
||||
void (* accel_edited) (GtkCellRendererKeys *keys,
|
||||
const gchar *path_string,
|
||||
guint accel_key,
|
||||
GdkModifierType accel_mods,
|
||||
guint hardware_keycode);
|
||||
|
||||
void (* accel_cleared) (GtkCellRendererKeys *keys,
|
||||
const gchar *path_string);
|
||||
|
||||
/* Padding for future expansion */
|
||||
void (*_gtk_reserved0) (void);
|
||||
void (*_gtk_reserved1) (void);
|
||||
void (*_gtk_reserved2) (void);
|
||||
void (*_gtk_reserved3) (void);
|
||||
void (*_gtk_reserved4) (void);
|
||||
};
|
||||
|
||||
GType gtk_cell_renderer_keys_get_type (void) G_GNUC_CONST;
|
||||
GtkCellRenderer *gtk_cell_renderer_keys_new (void);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
#endif /* __GTK_CELL_RENDERER_KEYS_H__ */
|
@ -29,6 +29,7 @@ endif
|
||||
noinst_PROGRAMS = \
|
||||
autotestfilechooser \
|
||||
simple \
|
||||
testaccel \
|
||||
testcairo \
|
||||
testcalendar \
|
||||
testcombo \
|
||||
@ -43,7 +44,6 @@ noinst_PROGRAMS = \
|
||||
testicontheme \
|
||||
testimage \
|
||||
testinput \
|
||||
testkeys \
|
||||
testmenus \
|
||||
testmenubars \
|
||||
testmultidisplay \
|
||||
@ -78,6 +78,7 @@ autotestfilechooser_DEPENDENCIES = $(TEST_DEPS)
|
||||
simple_DEPENDENCIES = $(TEST_DEPS)
|
||||
testicontheme_DEPENDENCIES = $(TEST_DEPS)
|
||||
testiconview_DEPENDENCIES = $(TEST_DEPS)
|
||||
testaccel_DEPENDENCIES = $(TEST_DEPS)
|
||||
testcairo_DEPENDENCIES = $(TEST_DEPS)
|
||||
testcalendar_DEPENDENCIES = $(TEST_DEPS)
|
||||
testcombo_DEPENDENCIES = $(TEST_DEPS)
|
||||
@ -90,7 +91,6 @@ testfilechooserbutton_DEPENDENCIES = $(TEST_DEPS)
|
||||
testgtk_DEPENDENCIES = $(TEST_DEPS)
|
||||
testinput_DEPENDENCIES = $(TEST_DEPS)
|
||||
testimage_DEPENDENCIES = $(TEST_DEPS)
|
||||
testkeys_DEPENDENCIES = $(TEST_DEPS)
|
||||
testmenus_DEPENDENCIES = $(TEST_DEPS)
|
||||
testmenubars_DEPENDENCIES = $(TEST_DEPS)
|
||||
testmultidisplay_DEPENDENCIES = $(TEST_DEPS)
|
||||
@ -117,6 +117,7 @@ testactions_DEPENDENCIES = $(TEST_DEPS)
|
||||
|
||||
autotestfilechooser_LDADD = $(LDADDS)
|
||||
simple_LDADD = $(LDADDS)
|
||||
testaccel_LDADD = $(LDADDS)
|
||||
testcairo_LDADD = $(LDADDS)
|
||||
testcalendar_LDADD = $(LDADDS)
|
||||
testcombo_LDADD = $(LDADDS)
|
||||
@ -131,7 +132,6 @@ testicontheme_LDADD = $(LDADDS)
|
||||
testiconview_LDADD = $(LDADDS)
|
||||
testinput_LDADD = $(LDADDS)
|
||||
testimage_LDADD = $(LDADDS)
|
||||
testkeys_LDADD = $(LDADDS)
|
||||
testmenus_LDADD = $(LDADDS)
|
||||
testmenubars_LDADD = $(LDADDS)
|
||||
testmultidisplay_LDADD = $(LDADDS)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* gtkcellrendererkeys.h
|
||||
/* gtkcellrendereraccel.h
|
||||
* Copyright (C) 2000 Red Hat, Inc., Jonathan Blandford <jrb@redhat.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
@ -63,9 +63,9 @@ key_test (void)
|
||||
tv = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
|
||||
gtk_container_add (GTK_CONTAINER (sw), tv);
|
||||
column = gtk_tree_view_column_new ();
|
||||
rend = gtk_cell_renderer_keys_new ();
|
||||
rend = gtk_cell_renderer_accel_new ();
|
||||
g_object_set (G_OBJECT (rend),
|
||||
"accel-mode", GTK_CELL_RENDERER_KEYS_MODE_GTK,
|
||||
"accel-mode", GTK_CELL_RENDERER_ACCEL_MODE_GTK,
|
||||
"editable", TRUE,
|
||||
NULL);
|
||||
g_signal_connect (G_OBJECT (rend),
|
||||
|
109
tests/testkeys.c
109
tests/testkeys.c
@ -1,109 +0,0 @@
|
||||
/* gtkcellrendererkeys.h
|
||||
* Copyright (C) 2000 Red Hat, Inc., Jonathan Blandford <jrb@redhat.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
|
||||
static void
|
||||
accel_edited_callback (GtkCellRendererText *cell,
|
||||
const char *path_string,
|
||||
guint keyval,
|
||||
GdkModifierType mask,
|
||||
guint hardware_keycode,
|
||||
gpointer data)
|
||||
{
|
||||
GtkTreeModel *model = (GtkTreeModel *)data;
|
||||
GtkTreePath *path = gtk_tree_path_new_from_string (path_string);
|
||||
GtkTreeIter iter;
|
||||
|
||||
gtk_tree_model_get_iter (model, &iter, path);
|
||||
|
||||
g_print ("%u %d %u\n", keyval, mask, hardware_keycode);
|
||||
|
||||
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
|
||||
0, (gint)mask,
|
||||
1, keyval,
|
||||
-1);
|
||||
gtk_tree_path_free (path);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
key_test (void)
|
||||
{
|
||||
GtkWidget *window, *sw, *tv;
|
||||
GtkListStore *store;
|
||||
GtkTreeViewColumn *column;
|
||||
GtkCellRenderer *rend;
|
||||
gint i;
|
||||
|
||||
/* create window */
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
|
||||
|
||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_container_add (GTK_CONTAINER (window), sw);
|
||||
|
||||
store = gtk_list_store_new (2, G_TYPE_INT, G_TYPE_UINT);
|
||||
tv = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
|
||||
gtk_container_add (GTK_CONTAINER (sw), tv);
|
||||
column = gtk_tree_view_column_new ();
|
||||
rend = gtk_cell_renderer_keys_new ();
|
||||
g_object_set (G_OBJECT (rend),
|
||||
"accel-mode", GTK_CELL_RENDERER_KEYS_MODE_GTK,
|
||||
"editable", TRUE,
|
||||
NULL);
|
||||
g_signal_connect (G_OBJECT (rend),
|
||||
"accel-edited",
|
||||
G_CALLBACK (accel_edited_callback),
|
||||
store);
|
||||
|
||||
gtk_tree_view_column_pack_start (column, rend,
|
||||
TRUE);
|
||||
gtk_tree_view_column_set_attributes (column, rend,
|
||||
"accel-mods", 0,
|
||||
"accel-key", 1,
|
||||
NULL);
|
||||
gtk_tree_view_append_column (GTK_TREE_VIEW (tv), column);
|
||||
|
||||
for (i = 0; i < 10; i++) {
|
||||
GtkTreeIter iter;
|
||||
|
||||
gtk_list_store_append (store, &iter);
|
||||
}
|
||||
|
||||
/* done */
|
||||
|
||||
return window;
|
||||
}
|
||||
|
||||
gint
|
||||
main (gint argc, gchar **argv)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
|
||||
gtk_init (&argc, &argv);
|
||||
|
||||
dialog = key_test ();
|
||||
|
||||
gtk_widget_show_all (dialog);
|
||||
|
||||
gtk_main ();
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user