2005-09-22 16:33:50 +00:00
|
|
|
/* gtkcellrendereraccel.h
|
2005-09-11 05:43:19 +00:00
|
|
|
* 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
|
2012-02-27 13:01:10 +00:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2005-09-11 05:43:19 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
2010-09-14 01:33:06 +00:00
|
|
|
|
|
|
|
#include "gtkcellrendereraccel.h"
|
|
|
|
|
2005-09-11 05:43:19 +00:00
|
|
|
#include "gtkintl.h"
|
|
|
|
#include "gtkaccelgroup.h"
|
|
|
|
#include "gtkmarshalers.h"
|
|
|
|
#include "gtklabel.h"
|
2009-09-03 02:14:47 +00:00
|
|
|
#include "gtkmain.h"
|
2010-09-14 01:33:06 +00:00
|
|
|
#include "gtksizerequest.h"
|
2011-01-04 19:51:19 +00:00
|
|
|
#include "gtktypebuiltins.h"
|
2005-09-11 05:43:19 +00:00
|
|
|
#include "gtkprivate.h"
|
|
|
|
|
2014-09-06 20:04:41 +00:00
|
|
|
|
2011-04-11 02:00:24 +00:00
|
|
|
/**
|
|
|
|
* SECTION:gtkcellrendereraccel
|
|
|
|
* @Short_description: Renders a keyboard accelerator in a cell
|
|
|
|
* @Title: GtkCellRendererAccel
|
|
|
|
*
|
2014-09-06 22:23:37 +00:00
|
|
|
* #GtkCellRendererAccel displays a keyboard accelerator (i.e. a key
|
|
|
|
* combination like `Control + a`). If the cell renderer is editable,
|
|
|
|
* the accelerator can be changed by simply typing the new combination.
|
2011-04-11 02:00:24 +00:00
|
|
|
*
|
|
|
|
* The #GtkCellRendererAccel cell renderer was added in GTK+ 2.10.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2005-09-22 16:33:50 +00:00
|
|
|
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);
|
2012-02-28 20:04:31 +00:00
|
|
|
static void gtk_cell_renderer_accel_get_preferred_width
|
|
|
|
(GtkCellRenderer *cell,
|
|
|
|
GtkWidget *widget,
|
|
|
|
gint *minimum_size,
|
|
|
|
gint *natural_size);
|
2007-03-07 14:18:53 +00:00
|
|
|
static GtkCellEditable *
|
2010-10-04 14:22:09 +00:00
|
|
|
gtk_cell_renderer_accel_start_editing (GtkCellRenderer *cell,
|
|
|
|
GdkEvent *event,
|
|
|
|
GtkWidget *widget,
|
|
|
|
const gchar *path,
|
|
|
|
const GdkRectangle *background_area,
|
|
|
|
const GdkRectangle *cell_area,
|
|
|
|
GtkCellRendererState flags);
|
2008-10-13 12:54:39 +00:00
|
|
|
static gchar *convert_keysym_state_to_string (GtkCellRendererAccel *accel,
|
|
|
|
guint keysym,
|
|
|
|
GdkModifierType mask,
|
|
|
|
guint keycode);
|
2017-08-02 12:49:36 +00:00
|
|
|
static GtkWidget *gtk_cell_editable_widget_new (GtkCellRenderer *cell,
|
2014-09-06 22:23:37 +00:00
|
|
|
GtkCellRendererAccelMode mode,
|
|
|
|
const gchar *path);
|
2005-09-11 05:43:19 +00:00
|
|
|
|
|
|
|
enum {
|
|
|
|
ACCEL_EDITED,
|
|
|
|
ACCEL_CLEARED,
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
2014-09-06 22:23:37 +00:00
|
|
|
PROP_ACCEL_KEY = 1,
|
2005-09-11 05:43:19 +00:00
|
|
|
PROP_ACCEL_MODS,
|
|
|
|
PROP_KEYCODE,
|
|
|
|
PROP_ACCEL_MODE
|
|
|
|
};
|
|
|
|
|
2014-09-06 22:23:37 +00:00
|
|
|
static guint signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
2010-08-26 17:15:37 +00:00
|
|
|
struct _GtkCellRendererAccelPrivate
|
2010-05-25 22:38:44 +00:00
|
|
|
{
|
2010-05-30 20:00:31 +00:00
|
|
|
GtkWidget *sizing_label;
|
|
|
|
|
2011-04-12 16:30:04 +00:00
|
|
|
GtkCellRendererAccelMode accel_mode;
|
2010-05-30 20:00:31 +00:00
|
|
|
GdkModifierType accel_mods;
|
|
|
|
guint accel_key;
|
|
|
|
guint keycode;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
2014-09-06 22:23:37 +00:00
|
|
|
GdkDevice *grab_pointer;
|
|
|
|
};
|
2005-09-11 05:43:19 +00:00
|
|
|
|
2013-06-27 19:02:52 +00:00
|
|
|
G_DEFINE_TYPE_WITH_PRIVATE (GtkCellRendererAccel, gtk_cell_renderer_accel, GTK_TYPE_CELL_RENDERER_TEXT)
|
2005-09-11 05:43:19 +00:00
|
|
|
|
|
|
|
static void
|
2005-09-22 16:33:50 +00:00
|
|
|
gtk_cell_renderer_accel_init (GtkCellRendererAccel *cell_accel)
|
2005-09-11 05:43:19 +00:00
|
|
|
{
|
2008-10-13 12:54:39 +00:00
|
|
|
gchar *text;
|
|
|
|
|
2013-06-27 19:02:52 +00:00
|
|
|
cell_accel->priv = gtk_cell_renderer_accel_get_instance_private (cell_accel);
|
2010-05-30 20:00:31 +00:00
|
|
|
|
2008-10-13 12:54:39 +00:00
|
|
|
text = convert_keysym_state_to_string (cell_accel, 0, 0, 0);
|
|
|
|
g_object_set (cell_accel, "text", text, NULL);
|
|
|
|
g_free (text);
|
2005-09-11 05:43:19 +00:00
|
|
|
}
|
|
|
|
|
2018-02-06 10:49:23 +00:00
|
|
|
static void
|
|
|
|
gtk_cell_renderer_accel_dispose (GObject *object)
|
|
|
|
{
|
|
|
|
GtkCellRendererAccelPrivate *priv = GTK_CELL_RENDERER_ACCEL (object)->priv;
|
|
|
|
|
|
|
|
g_clear_object (&priv->sizing_label);
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (gtk_cell_renderer_accel_parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
2005-09-11 05:43:19 +00:00
|
|
|
static void
|
2005-09-22 16:33:50 +00:00
|
|
|
gtk_cell_renderer_accel_class_init (GtkCellRendererAccelClass *cell_accel_class)
|
2005-09-11 05:43:19 +00:00
|
|
|
{
|
|
|
|
GObjectClass *object_class;
|
|
|
|
GtkCellRendererClass *cell_renderer_class;
|
|
|
|
|
2005-09-22 16:33:50 +00:00
|
|
|
object_class = G_OBJECT_CLASS (cell_accel_class);
|
|
|
|
cell_renderer_class = GTK_CELL_RENDERER_CLASS (cell_accel_class);
|
2005-09-11 05:43:19 +00:00
|
|
|
|
2005-09-22 16:33:50 +00:00
|
|
|
object_class->set_property = gtk_cell_renderer_accel_set_property;
|
|
|
|
object_class->get_property = gtk_cell_renderer_accel_get_property;
|
2018-02-06 10:49:23 +00:00
|
|
|
object_class->dispose = gtk_cell_renderer_accel_dispose;
|
2005-09-11 05:43:19 +00:00
|
|
|
|
2012-02-28 20:04:31 +00:00
|
|
|
cell_renderer_class->get_preferred_width = gtk_cell_renderer_accel_get_preferred_width;
|
2007-03-07 14:18:53 +00:00
|
|
|
cell_renderer_class->start_editing = gtk_cell_renderer_accel_start_editing;
|
2005-09-11 05:43:19 +00:00
|
|
|
|
|
|
|
/**
|
2005-09-22 16:33:50 +00:00
|
|
|
* GtkCellRendererAccel:accel-key:
|
2005-09-11 05:43:19 +00:00
|
|
|
*
|
|
|
|
* The keyval of the accelerator.
|
|
|
|
*/
|
|
|
|
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,
|
2014-06-07 15:46:22 +00:00
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
|
2005-09-11 05:43:19 +00:00
|
|
|
|
|
|
|
/**
|
2005-09-22 16:33:50 +00:00
|
|
|
* GtkCellRendererAccel:accel-mods:
|
2005-09-11 05:43:19 +00:00
|
|
|
*
|
|
|
|
* The modifier mask of the accelerator.
|
|
|
|
*/
|
|
|
|
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,
|
2014-06-07 15:46:22 +00:00
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
|
2005-09-11 05:43:19 +00:00
|
|
|
|
|
|
|
/**
|
2005-09-22 16:33:50 +00:00
|
|
|
* GtkCellRendererAccel:keycode:
|
2005-09-11 05:43:19 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
g_object_class_install_property (object_class,
|
2011-01-15 01:24:26 +00:00
|
|
|
PROP_KEYCODE,
|
|
|
|
g_param_spec_uint ("keycode",
|
|
|
|
P_("Accelerator keycode"),
|
|
|
|
P_("The hardware keycode of the accelerator"),
|
|
|
|
0,
|
|
|
|
G_MAXINT,
|
|
|
|
0,
|
2014-06-07 15:46:22 +00:00
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
|
2005-09-11 05:43:19 +00:00
|
|
|
|
|
|
|
/**
|
2005-09-22 16:33:50 +00:00
|
|
|
* GtkCellRendererAccel:accel-mode:
|
2005-09-11 05:43:19 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
PROP_ACCEL_MODE,
|
|
|
|
g_param_spec_enum ("accel-mode",
|
2011-01-15 01:24:26 +00:00
|
|
|
P_("Accelerator Mode"),
|
|
|
|
P_("The type of accelerators"),
|
|
|
|
GTK_TYPE_CELL_RENDERER_ACCEL_MODE,
|
|
|
|
GTK_CELL_RENDERER_ACCEL_MODE_GTK,
|
2014-06-07 15:46:22 +00:00
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
|
2005-09-11 05:43:19 +00:00
|
|
|
|
|
|
|
/**
|
2005-09-22 16:33:50 +00:00
|
|
|
* GtkCellRendererAccel::accel-edited:
|
|
|
|
* @accel: the object reveiving the signal
|
2005-09-11 05:43:19 +00:00
|
|
|
* @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.
|
|
|
|
*/
|
|
|
|
signals[ACCEL_EDITED] = g_signal_new (I_("accel-edited"),
|
2011-01-15 01:24:26 +00:00
|
|
|
GTK_TYPE_CELL_RENDERER_ACCEL,
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (GtkCellRendererAccelClass, 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);
|
2005-09-11 05:43:19 +00:00
|
|
|
|
|
|
|
/**
|
2005-09-22 16:33:50 +00:00
|
|
|
* GtkCellRendererAccel::accel-cleared:
|
|
|
|
* @accel: the object reveiving the signal
|
2005-09-11 05:43:19 +00:00
|
|
|
* @path_string: the path identifying the row of the edited cell
|
|
|
|
*
|
|
|
|
* Gets emitted when the user has removed the accelerator.
|
|
|
|
*/
|
|
|
|
signals[ACCEL_CLEARED] = g_signal_new (I_("accel-cleared"),
|
2011-01-15 01:24:26 +00:00
|
|
|
GTK_TYPE_CELL_RENDERER_ACCEL,
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (GtkCellRendererAccelClass, accel_cleared),
|
|
|
|
NULL, NULL,
|
|
|
|
g_cclosure_marshal_VOID__STRING,
|
|
|
|
G_TYPE_NONE, 1,
|
|
|
|
G_TYPE_STRING);
|
2005-09-11 05:43:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2005-09-22 16:33:50 +00:00
|
|
|
* gtk_cell_renderer_accel_new:
|
2005-09-11 05:43:19 +00:00
|
|
|
*
|
2005-09-22 16:33:50 +00:00
|
|
|
* Creates a new #GtkCellRendererAccel.
|
2005-09-11 05:43:19 +00:00
|
|
|
*
|
|
|
|
* Returns: the new cell renderer
|
|
|
|
*/
|
|
|
|
GtkCellRenderer *
|
2005-09-22 16:33:50 +00:00
|
|
|
gtk_cell_renderer_accel_new (void)
|
2005-09-11 05:43:19 +00:00
|
|
|
{
|
2007-03-07 14:18:53 +00:00
|
|
|
return g_object_new (GTK_TYPE_CELL_RENDERER_ACCEL, NULL);
|
2005-09-11 05:43:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gchar *
|
2005-09-22 16:33:50 +00:00
|
|
|
convert_keysym_state_to_string (GtkCellRendererAccel *accel,
|
2011-01-15 01:24:26 +00:00
|
|
|
guint keysym,
|
2005-09-22 16:33:50 +00:00
|
|
|
GdkModifierType mask,
|
2011-01-15 01:24:26 +00:00
|
|
|
guint keycode)
|
2005-09-11 05:43:19 +00:00
|
|
|
{
|
2010-08-26 17:15:37 +00:00
|
|
|
GtkCellRendererAccelPrivate *priv = accel->priv;
|
2010-05-30 20:00:31 +00:00
|
|
|
|
2005-09-11 05:43:19 +00:00
|
|
|
if (keysym == 0 && keycode == 0)
|
|
|
|
/* This label is displayed in a treeview cell displaying
|
2008-10-27 01:42:28 +00:00
|
|
|
* a disabled accelerator key combination.
|
2005-09-11 05:43:19 +00:00
|
|
|
*/
|
2008-10-27 01:42:28 +00:00
|
|
|
return g_strdup (C_("Accelerator", "Disabled"));
|
2005-09-11 05:43:19 +00:00
|
|
|
else
|
|
|
|
{
|
2010-05-30 20:00:31 +00:00
|
|
|
if (priv->accel_mode == GTK_CELL_RENDERER_ACCEL_MODE_GTK)
|
2009-04-08 17:18:44 +00:00
|
|
|
{
|
|
|
|
if (!gtk_accelerator_valid (keysym, mask))
|
|
|
|
/* This label is displayed in a treeview cell displaying
|
|
|
|
* an accelerator key combination that is not valid according
|
|
|
|
* to gtk_accelerator_valid().
|
|
|
|
*/
|
|
|
|
return g_strdup (C_("Accelerator", "Invalid"));
|
|
|
|
|
|
|
|
return gtk_accelerator_get_label (keysym, mask);
|
|
|
|
}
|
2005-09-11 05:43:19 +00:00
|
|
|
else
|
2011-01-15 01:24:26 +00:00
|
|
|
{
|
|
|
|
gchar *name;
|
2005-09-11 05:43:19 +00:00
|
|
|
|
2011-11-10 10:58:37 +00:00
|
|
|
name = gtk_accelerator_get_label_with_keycode (NULL, keysym, keycode, mask);
|
2011-01-15 01:24:26 +00:00
|
|
|
if (name == NULL)
|
2011-11-10 10:58:37 +00:00
|
|
|
name = gtk_accelerator_name_with_keycode (NULL, keysym, keycode, mask);
|
2005-09-11 05:43:19 +00:00
|
|
|
|
2011-01-15 01:24:26 +00:00
|
|
|
return name;
|
|
|
|
}
|
2005-09-11 05:43:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-09-06 22:23:37 +00:00
|
|
|
gtk_cell_renderer_accel_get_property (GObject *object,
|
|
|
|
guint param_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
2005-09-11 05:43:19 +00:00
|
|
|
{
|
2010-08-26 17:15:37 +00:00
|
|
|
GtkCellRendererAccelPrivate *priv = GTK_CELL_RENDERER_ACCEL (object)->priv;
|
2005-09-11 05:43:19 +00:00
|
|
|
|
|
|
|
switch (param_id)
|
|
|
|
{
|
|
|
|
case PROP_ACCEL_KEY:
|
2010-05-30 20:00:31 +00:00
|
|
|
g_value_set_uint (value, priv->accel_key);
|
2005-09-11 05:43:19 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_ACCEL_MODS:
|
2010-05-30 20:00:31 +00:00
|
|
|
g_value_set_flags (value, priv->accel_mods);
|
2005-09-11 05:43:19 +00:00
|
|
|
break;
|
|
|
|
|
2007-09-13 22:37:02 +00:00
|
|
|
case PROP_KEYCODE:
|
2010-05-30 20:00:31 +00:00
|
|
|
g_value_set_uint (value, priv->keycode);
|
2007-09-13 22:37:02 +00:00
|
|
|
break;
|
|
|
|
|
2005-09-11 05:43:19 +00:00
|
|
|
case PROP_ACCEL_MODE:
|
2010-05-30 20:00:31 +00:00
|
|
|
g_value_set_enum (value, priv->accel_mode);
|
2005-09-11 05:43:19 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-09-06 22:23:37 +00:00
|
|
|
gtk_cell_renderer_accel_set_property (GObject *object,
|
|
|
|
guint param_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
2005-09-11 05:43:19 +00:00
|
|
|
{
|
2007-03-07 14:18:53 +00:00
|
|
|
GtkCellRendererAccel *accel = GTK_CELL_RENDERER_ACCEL (object);
|
2010-08-26 17:15:37 +00:00
|
|
|
GtkCellRendererAccelPrivate *priv = accel->priv;
|
2005-09-11 05:43:19 +00:00
|
|
|
gboolean changed = FALSE;
|
|
|
|
|
|
|
|
switch (param_id)
|
|
|
|
{
|
|
|
|
case PROP_ACCEL_KEY:
|
|
|
|
{
|
2011-01-15 01:24:26 +00:00
|
|
|
guint accel_key = g_value_get_uint (value);
|
2005-09-11 05:43:19 +00:00
|
|
|
|
2011-01-15 01:24:26 +00:00
|
|
|
if (priv->accel_key != accel_key)
|
|
|
|
{
|
|
|
|
priv->accel_key = accel_key;
|
|
|
|
changed = TRUE;
|
2014-06-07 15:46:22 +00:00
|
|
|
g_object_notify (object, "accel-key");
|
2011-01-15 01:24:26 +00:00
|
|
|
}
|
2005-09-11 05:43:19 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_ACCEL_MODS:
|
|
|
|
{
|
2011-01-15 01:24:26 +00:00
|
|
|
guint accel_mods = g_value_get_flags (value);
|
2005-09-11 05:43:19 +00:00
|
|
|
|
2011-01-15 01:24:26 +00:00
|
|
|
if (priv->accel_mods != accel_mods)
|
|
|
|
{
|
|
|
|
priv->accel_mods = accel_mods;
|
|
|
|
changed = TRUE;
|
2014-06-07 15:46:22 +00:00
|
|
|
g_object_notify (object, "accel-mods");
|
2011-01-15 01:24:26 +00:00
|
|
|
}
|
2005-09-11 05:43:19 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PROP_KEYCODE:
|
|
|
|
{
|
2011-01-15 01:24:26 +00:00
|
|
|
guint keycode = g_value_get_uint (value);
|
2005-09-11 05:43:19 +00:00
|
|
|
|
2011-01-15 01:24:26 +00:00
|
|
|
if (priv->keycode != keycode)
|
|
|
|
{
|
|
|
|
priv->keycode = keycode;
|
|
|
|
changed = TRUE;
|
2014-06-07 15:46:22 +00:00
|
|
|
g_object_notify (object, "keycode");
|
2011-01-15 01:24:26 +00:00
|
|
|
}
|
2005-09-11 05:43:19 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_ACCEL_MODE:
|
2014-06-07 15:46:22 +00:00
|
|
|
if (priv->accel_mode != g_value_get_enum (value))
|
|
|
|
{
|
|
|
|
priv->accel_mode = g_value_get_enum (value);
|
|
|
|
g_object_notify (object, "accel-mode");
|
|
|
|
}
|
2005-09-11 05:43:19 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (changed)
|
|
|
|
{
|
|
|
|
gchar *text;
|
|
|
|
|
2010-05-30 20:00:31 +00:00
|
|
|
text = convert_keysym_state_to_string (accel, priv->accel_key, priv->accel_mods, priv->keycode);
|
2005-09-22 16:33:50 +00:00
|
|
|
g_object_set (accel, "text", text, NULL);
|
2005-09-11 05:43:19 +00:00
|
|
|
g_free (text);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-09-06 22:23:37 +00:00
|
|
|
gtk_cell_renderer_accel_get_preferred_width (GtkCellRenderer *cell,
|
|
|
|
GtkWidget *widget,
|
|
|
|
gint *minimum_size,
|
|
|
|
gint *natural_size)
|
2005-09-11 05:43:19 +00:00
|
|
|
|
|
|
|
{
|
2010-08-26 17:15:37 +00:00
|
|
|
GtkCellRendererAccelPrivate *priv = GTK_CELL_RENDERER_ACCEL (cell)->priv;
|
2012-02-28 20:04:31 +00:00
|
|
|
GtkRequisition min_req, nat_req;
|
2005-09-11 05:43:19 +00:00
|
|
|
|
2010-05-30 20:00:31 +00:00
|
|
|
if (priv->sizing_label == NULL)
|
2018-02-06 10:49:23 +00:00
|
|
|
{
|
|
|
|
priv->sizing_label = gtk_label_new (_("New accelerator…"));
|
|
|
|
g_object_ref_sink (priv->sizing_label);
|
|
|
|
}
|
2005-09-11 05:43:19 +00:00
|
|
|
|
2012-02-28 20:04:31 +00:00
|
|
|
gtk_widget_get_preferred_size (priv->sizing_label, &min_req, &nat_req);
|
2007-03-07 14:18:53 +00:00
|
|
|
|
2012-02-28 20:04:31 +00:00
|
|
|
GTK_CELL_RENDERER_CLASS (gtk_cell_renderer_accel_parent_class)->get_preferred_width (cell, widget,
|
|
|
|
minimum_size, natural_size);
|
2007-03-07 14:18:53 +00:00
|
|
|
|
2005-09-11 05:43:19 +00:00
|
|
|
/* FIXME: need to take the cell_area et al. into account */
|
2012-02-28 20:04:31 +00:00
|
|
|
if (minimum_size)
|
|
|
|
*minimum_size = MAX (*minimum_size, min_req.width);
|
|
|
|
if (natural_size)
|
|
|
|
*natural_size = MAX (*natural_size, nat_req.width);
|
2005-09-11 05:43:19 +00:00
|
|
|
}
|
|
|
|
|
2014-09-06 22:23:37 +00:00
|
|
|
static GtkCellEditable *
|
|
|
|
gtk_cell_renderer_accel_start_editing (GtkCellRenderer *cell,
|
|
|
|
GdkEvent *event,
|
|
|
|
GtkWidget *widget,
|
|
|
|
const gchar *path,
|
|
|
|
const GdkRectangle *background_area,
|
|
|
|
const GdkRectangle *cell_area,
|
|
|
|
GtkCellRendererState flags)
|
|
|
|
{
|
|
|
|
GtkCellRendererAccelPrivate *priv;
|
|
|
|
GtkCellRendererText *celltext;
|
|
|
|
GtkCellRendererAccel *accel;
|
|
|
|
GtkWidget *label;
|
2017-08-02 12:49:36 +00:00
|
|
|
GtkWidget *editable;
|
|
|
|
gboolean is_editable;
|
2015-11-26 18:54:31 +00:00
|
|
|
GdkDevice *device, *pointer;
|
2018-03-21 10:49:14 +00:00
|
|
|
GdkSurface *surface;
|
2014-09-06 22:23:37 +00:00
|
|
|
|
|
|
|
celltext = GTK_CELL_RENDERER_TEXT (cell);
|
|
|
|
accel = GTK_CELL_RENDERER_ACCEL (cell);
|
|
|
|
priv = accel->priv;
|
|
|
|
|
|
|
|
/* If the cell isn't editable we return NULL. */
|
2017-08-02 12:49:36 +00:00
|
|
|
g_object_get (celltext, "editable", &is_editable, NULL);
|
|
|
|
if (!is_editable)
|
2014-09-06 22:23:37 +00:00
|
|
|
return NULL;
|
|
|
|
|
2018-03-21 10:49:14 +00:00
|
|
|
surface = gtk_widget_get_surface (gtk_widget_get_toplevel (widget));
|
2014-09-06 22:23:37 +00:00
|
|
|
|
|
|
|
if (event)
|
|
|
|
device = gdk_event_get_device (event);
|
|
|
|
else
|
|
|
|
device = gtk_get_current_event_device ();
|
|
|
|
|
2018-03-21 10:49:14 +00:00
|
|
|
if (!device || !surface)
|
2014-09-06 22:23:37 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
|
2015-11-26 18:54:31 +00:00
|
|
|
pointer = gdk_device_get_associated_device (device);
|
2014-09-06 22:23:37 +00:00
|
|
|
else
|
2015-11-26 18:54:31 +00:00
|
|
|
pointer = device;
|
2014-09-06 22:23:37 +00:00
|
|
|
|
2018-03-21 10:49:14 +00:00
|
|
|
if (gdk_seat_grab (gdk_device_get_seat (pointer), surface,
|
2015-11-26 18:54:31 +00:00
|
|
|
GDK_SEAT_CAPABILITY_ALL, FALSE,
|
|
|
|
NULL, event, NULL, NULL) != GDK_GRAB_SUCCESS)
|
2014-09-06 22:23:37 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
priv->grab_pointer = pointer;
|
|
|
|
|
2017-08-02 12:49:36 +00:00
|
|
|
editable = gtk_cell_editable_widget_new (cell, priv->accel_mode, path);
|
2014-09-06 22:23:37 +00:00
|
|
|
|
|
|
|
label = gtk_label_new (NULL);
|
|
|
|
gtk_widget_set_halign (label, GTK_ALIGN_START);
|
|
|
|
gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
|
|
|
|
|
2015-12-07 12:04:43 +00:00
|
|
|
gtk_widget_set_state_flags (label, GTK_STATE_FLAG_SELECTED, TRUE);
|
2014-09-06 22:23:37 +00:00
|
|
|
|
2014-10-02 04:37:52 +00:00
|
|
|
/* This label is displayed in a treeview cell displaying an accelerator
|
|
|
|
* when the cell is clicked to change the acelerator.
|
2014-09-06 22:23:37 +00:00
|
|
|
*/
|
|
|
|
gtk_label_set_text (GTK_LABEL (label), _("New accelerator…"));
|
|
|
|
|
2017-08-02 12:49:36 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (editable), label);
|
2014-09-06 22:23:37 +00:00
|
|
|
|
2017-08-02 12:49:36 +00:00
|
|
|
gtk_grab_add (editable);
|
2014-09-06 22:23:37 +00:00
|
|
|
|
2017-08-02 12:49:36 +00:00
|
|
|
return GTK_CELL_EDITABLE (editable);
|
2014-09-06 22:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_cell_renderer_accel_ungrab (GtkCellRendererAccel *accel)
|
2005-09-11 05:43:19 +00:00
|
|
|
{
|
2010-08-26 17:15:37 +00:00
|
|
|
GtkCellRendererAccelPrivate *priv = accel->priv;
|
2014-09-06 22:23:37 +00:00
|
|
|
|
2015-11-26 18:54:31 +00:00
|
|
|
if (priv->grab_pointer)
|
2014-09-06 22:23:37 +00:00
|
|
|
{
|
2015-11-26 18:54:31 +00:00
|
|
|
gdk_seat_ungrab (gdk_device_get_seat (priv->grab_pointer));
|
2014-09-06 22:23:37 +00:00
|
|
|
priv->grab_pointer = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------- */
|
|
|
|
|
2017-08-02 12:49:36 +00:00
|
|
|
typedef struct _GtkCellEditableWidget GtkCellEditableWidget;
|
|
|
|
typedef GtkWidgetClass GtkCellEditableWidgetClass;
|
2014-09-06 22:23:37 +00:00
|
|
|
|
2017-08-02 12:49:36 +00:00
|
|
|
struct _GtkCellEditableWidget
|
2014-09-06 22:23:37 +00:00
|
|
|
{
|
2017-08-02 12:49:36 +00:00
|
|
|
GtkWidget parent;
|
|
|
|
|
2014-09-06 22:23:37 +00:00
|
|
|
gboolean editing_canceled;
|
|
|
|
GtkCellRendererAccelMode accel_mode;
|
|
|
|
gchar *path;
|
|
|
|
GtkCellRenderer *cell;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
PROP_EDITING_CANCELED = 1,
|
|
|
|
PROP_MODE,
|
|
|
|
PROP_PATH
|
|
|
|
};
|
|
|
|
|
2017-08-02 12:49:36 +00:00
|
|
|
GType gtk_cell_editable_widget_get_type (void);
|
|
|
|
static void gtk_cell_editable_widget_cell_editable_init (GtkCellEditableIface *iface);
|
2014-09-06 22:23:37 +00:00
|
|
|
|
2017-08-02 12:49:36 +00:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (GtkCellEditableWidget, gtk_cell_editable_widget, GTK_TYPE_WIDGET,
|
|
|
|
G_IMPLEMENT_INTERFACE (GTK_TYPE_CELL_EDITABLE, gtk_cell_editable_widget_cell_editable_init))
|
2014-09-06 22:23:37 +00:00
|
|
|
|
|
|
|
static void
|
2017-08-02 12:49:36 +00:00
|
|
|
gtk_cell_editable_widget_start_editing (GtkCellEditable *cell_editable,
|
|
|
|
GdkEvent *event)
|
2014-09-06 22:23:37 +00:00
|
|
|
{
|
|
|
|
/* do nothing, because we are pointless */
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2017-08-02 12:49:36 +00:00
|
|
|
gtk_cell_editable_widget_cell_editable_init (GtkCellEditableIface *iface)
|
2014-09-06 22:23:37 +00:00
|
|
|
{
|
2017-08-02 12:49:36 +00:00
|
|
|
iface->start_editing = gtk_cell_editable_widget_start_editing;
|
2014-09-06 22:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2017-08-02 12:49:36 +00:00
|
|
|
gtk_cell_editable_widget_key_press_event (GtkWidget *widget,
|
|
|
|
GdkEventKey *event)
|
2014-09-06 22:23:37 +00:00
|
|
|
{
|
2017-08-02 12:49:36 +00:00
|
|
|
GtkCellEditableWidget *box = (GtkCellEditableWidget*)widget;
|
2005-09-11 05:43:19 +00:00
|
|
|
GdkModifierType accel_mods = 0;
|
|
|
|
guint accel_key;
|
2017-08-26 02:51:37 +00:00
|
|
|
guint keyval = 0;
|
2005-09-11 05:43:19 +00:00
|
|
|
gboolean edited;
|
|
|
|
gboolean cleared;
|
2007-03-07 14:18:53 +00:00
|
|
|
GdkModifierType consumed_modifiers;
|
2005-09-11 05:43:19 +00:00
|
|
|
GdkDisplay *display;
|
2017-08-26 02:51:37 +00:00
|
|
|
gboolean is_modifier = FALSE;
|
|
|
|
guint16 keycode = 0;
|
|
|
|
guint group = 0;
|
|
|
|
GdkModifierType state = 0;
|
2005-09-11 05:43:19 +00:00
|
|
|
|
|
|
|
display = gtk_widget_get_display (widget);
|
2007-03-07 14:18:53 +00:00
|
|
|
|
2017-08-26 02:51:37 +00:00
|
|
|
gdk_event_get_state ((GdkEvent *)event, &state);
|
|
|
|
gdk_event_get_keyval ((GdkEvent *)event, &keyval);
|
|
|
|
gdk_event_get_keycode ((GdkEvent *)event, &keycode);
|
|
|
|
gdk_event_get_key_group ((GdkEvent *)event, &group);
|
|
|
|
gdk_event_get_key_is_modifier ((GdkEvent *)event, &is_modifier);
|
|
|
|
|
|
|
|
if (is_modifier)
|
2005-09-11 05:43:19 +00:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
edited = FALSE;
|
|
|
|
cleared = FALSE;
|
|
|
|
|
2017-08-26 02:51:37 +00:00
|
|
|
accel_mods = state;
|
2011-11-18 11:25:03 +00:00
|
|
|
|
2017-08-26 02:51:37 +00:00
|
|
|
if (keyval == GDK_KEY_Sys_Req &&
|
2012-02-28 20:36:32 +00:00
|
|
|
(accel_mods & GDK_MOD1_MASK) != 0)
|
|
|
|
{
|
|
|
|
/* HACK: we don't want to use SysRq as a keybinding (but we do
|
|
|
|
* want Alt+Print), so we avoid translation from Alt+Print to SysRq
|
|
|
|
*/
|
|
|
|
keyval = GDK_KEY_Print;
|
|
|
|
consumed_modifiers = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-12-15 12:44:58 +00:00
|
|
|
_gtk_translate_keyboard_accel_state (gdk_display_get_keymap (display),
|
2017-08-26 02:51:37 +00:00
|
|
|
keycode,
|
|
|
|
state,
|
2012-02-28 20:36:32 +00:00
|
|
|
gtk_accelerator_get_default_mod_mask (),
|
2017-08-26 02:51:37 +00:00
|
|
|
group,
|
2012-02-28 20:36:32 +00:00
|
|
|
&keyval, NULL, NULL, &consumed_modifiers);
|
|
|
|
}
|
2005-09-11 05:43:19 +00:00
|
|
|
|
2011-11-18 11:25:03 +00:00
|
|
|
accel_key = gdk_keyval_to_lower (keyval);
|
2017-08-26 02:51:37 +00:00
|
|
|
if (accel_key == GDK_KEY_ISO_Left_Tab)
|
2010-09-08 17:35:51 +00:00
|
|
|
accel_key = GDK_KEY_Tab;
|
2005-09-11 05:43:19 +00:00
|
|
|
|
2011-09-16 13:39:23 +00:00
|
|
|
accel_mods &= gtk_accelerator_get_default_mod_mask ();
|
2005-09-11 05:43:19 +00:00
|
|
|
|
2017-08-26 02:51:37 +00:00
|
|
|
/* Filter consumed modifiers */
|
2014-09-06 22:23:37 +00:00
|
|
|
if (box->accel_mode == GTK_CELL_RENDERER_ACCEL_MODE_GTK)
|
2005-09-11 05:43:19 +00:00
|
|
|
accel_mods &= ~consumed_modifiers;
|
2017-08-26 02:51:37 +00:00
|
|
|
|
|
|
|
/* Put shift back if it changed the case of the key, not otherwise. */
|
2011-11-18 11:25:03 +00:00
|
|
|
if (accel_key != keyval)
|
2005-09-11 05:43:19 +00:00
|
|
|
accel_mods |= GDK_SHIFT_MASK;
|
2017-08-26 02:51:37 +00:00
|
|
|
|
2005-09-11 05:43:19 +00:00
|
|
|
if (accel_mods == 0)
|
|
|
|
{
|
2011-11-18 11:25:03 +00:00
|
|
|
switch (keyval)
|
|
|
|
{
|
|
|
|
case GDK_KEY_BackSpace:
|
|
|
|
cleared = TRUE;
|
2014-09-06 22:23:37 +00:00
|
|
|
/* fall thru */
|
|
|
|
case GDK_KEY_Escape:
|
2011-11-18 11:25:03 +00:00
|
|
|
goto out;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2005-09-11 05:43:19 +00:00
|
|
|
}
|
|
|
|
|
2014-09-06 22:23:37 +00:00
|
|
|
if (box->accel_mode == GTK_CELL_RENDERER_ACCEL_MODE_GTK &&
|
|
|
|
!gtk_accelerator_valid (accel_key, accel_mods))
|
2005-09-11 05:43:19 +00:00
|
|
|
{
|
2014-09-06 22:23:37 +00:00
|
|
|
gtk_widget_error_bell (widget);
|
|
|
|
return TRUE;
|
2005-09-11 05:43:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
edited = TRUE;
|
|
|
|
|
|
|
|
out:
|
2014-09-07 01:28:31 +00:00
|
|
|
gtk_grab_remove (widget);
|
2014-09-06 22:23:37 +00:00
|
|
|
gtk_cell_renderer_accel_ungrab (GTK_CELL_RENDERER_ACCEL (box->cell));
|
|
|
|
gtk_cell_editable_editing_done (GTK_CELL_EDITABLE (widget));
|
|
|
|
gtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (widget));
|
2010-05-25 22:38:44 +00:00
|
|
|
|
2005-09-11 05:43:19 +00:00
|
|
|
if (edited)
|
2014-09-06 22:23:37 +00:00
|
|
|
g_signal_emit (box->cell, signals[ACCEL_EDITED], 0, box->path,
|
2017-08-26 02:51:37 +00:00
|
|
|
accel_key, accel_mods, keycode);
|
2005-09-11 05:43:19 +00:00
|
|
|
else if (cleared)
|
2014-09-06 22:23:37 +00:00
|
|
|
g_signal_emit (box->cell, signals[ACCEL_CLEARED], 0, box->path);
|
2005-09-11 05:43:19 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2017-08-02 12:49:36 +00:00
|
|
|
gtk_cell_editable_widget_unrealize (GtkWidget *widget)
|
2005-09-11 05:43:19 +00:00
|
|
|
{
|
2017-08-02 12:49:36 +00:00
|
|
|
GtkCellEditableWidget *box = (GtkCellEditableWidget*)widget;
|
2005-09-11 05:43:19 +00:00
|
|
|
|
2014-09-07 01:28:31 +00:00
|
|
|
gtk_grab_remove (widget);
|
2014-09-06 22:23:37 +00:00
|
|
|
gtk_cell_renderer_accel_ungrab (GTK_CELL_RENDERER_ACCEL (box->cell));
|
|
|
|
|
2017-08-02 12:49:36 +00:00
|
|
|
GTK_WIDGET_CLASS (gtk_cell_editable_widget_parent_class)->unrealize (widget);
|
2005-09-11 05:43:19 +00:00
|
|
|
}
|
|
|
|
|
2011-01-15 01:24:26 +00:00
|
|
|
static void
|
2017-08-02 12:49:36 +00:00
|
|
|
gtk_cell_editable_widget_set_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
2011-01-15 01:24:26 +00:00
|
|
|
{
|
2017-08-02 12:49:36 +00:00
|
|
|
GtkCellEditableWidget *box = (GtkCellEditableWidget*)object;
|
2011-01-15 01:24:26 +00:00
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_EDITING_CANCELED:
|
|
|
|
box->editing_canceled = g_value_get_boolean (value);
|
|
|
|
break;
|
2014-09-06 22:23:37 +00:00
|
|
|
case PROP_MODE:
|
|
|
|
box->accel_mode = g_value_get_enum (value);
|
|
|
|
break;
|
|
|
|
case PROP_PATH:
|
|
|
|
box->path = g_value_dup_string (value);
|
|
|
|
break;
|
2011-01-15 01:24:26 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2017-08-02 12:49:36 +00:00
|
|
|
gtk_cell_editable_widget_get_property (GObject *object,
|
2011-01-15 01:24:26 +00:00
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
2017-08-02 12:49:36 +00:00
|
|
|
GtkCellEditableWidget *box = (GtkCellEditableWidget*)object;
|
2011-01-15 01:24:26 +00:00
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_EDITING_CANCELED:
|
|
|
|
g_value_set_boolean (value, box->editing_canceled);
|
|
|
|
break;
|
2014-09-06 22:23:37 +00:00
|
|
|
case PROP_MODE:
|
|
|
|
g_value_set_enum (value, box->accel_mode);
|
|
|
|
break;
|
|
|
|
case PROP_PATH:
|
|
|
|
g_value_set_string (value, box->path);
|
|
|
|
break;
|
2011-01-15 01:24:26 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2005-09-11 05:43:19 +00:00
|
|
|
|
|
|
|
static void
|
2017-08-02 12:49:36 +00:00
|
|
|
gtk_cell_editable_widget_finalize (GObject *object)
|
2005-09-11 05:43:19 +00:00
|
|
|
{
|
2017-08-02 12:49:36 +00:00
|
|
|
GtkCellEditableWidget *box = (GtkCellEditableWidget*)object;
|
2011-01-15 01:24:26 +00:00
|
|
|
|
2014-09-06 22:23:37 +00:00
|
|
|
g_free (box->path);
|
2011-01-15 01:24:26 +00:00
|
|
|
|
2017-08-02 12:49:36 +00:00
|
|
|
G_OBJECT_CLASS (gtk_cell_editable_widget_parent_class)->finalize (object);
|
2005-09-11 05:43:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2017-08-02 12:49:36 +00:00
|
|
|
gtk_cell_editable_widget_class_init (GtkCellEditableWidgetClass *class)
|
2005-09-11 05:43:19 +00:00
|
|
|
{
|
2014-09-06 22:23:37 +00:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
|
|
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
2017-08-02 12:49:36 +00:00
|
|
|
object_class->finalize = gtk_cell_editable_widget_finalize;
|
|
|
|
object_class->set_property = gtk_cell_editable_widget_set_property;
|
|
|
|
object_class->get_property = gtk_cell_editable_widget_get_property;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
2017-08-02 12:49:36 +00:00
|
|
|
widget_class->key_press_event = gtk_cell_editable_widget_key_press_event;
|
|
|
|
widget_class->unrealize = gtk_cell_editable_widget_unrealize;
|
2005-09-11 05:43:19 +00:00
|
|
|
|
2014-09-06 22:23:37 +00:00
|
|
|
g_object_class_override_property (object_class,
|
|
|
|
PROP_EDITING_CANCELED,
|
|
|
|
"editing-canceled");
|
2005-09-11 05:43:19 +00:00
|
|
|
|
2014-09-06 22:23:37 +00:00
|
|
|
g_object_class_install_property (object_class, PROP_MODE,
|
|
|
|
g_param_spec_enum ("accel-mode", NULL, NULL,
|
|
|
|
GTK_TYPE_CELL_RENDERER_ACCEL_MODE,
|
|
|
|
GTK_CELL_RENDERER_ACCEL_MODE_GTK,
|
|
|
|
GTK_PARAM_READWRITE));
|
2010-08-11 21:17:05 +00:00
|
|
|
|
2014-09-06 22:23:37 +00:00
|
|
|
g_object_class_install_property (object_class, PROP_PATH,
|
|
|
|
g_param_spec_string ("path", NULL, NULL,
|
|
|
|
NULL, GTK_PARAM_READWRITE));
|
2016-03-30 21:08:02 +00:00
|
|
|
|
2017-11-18 03:49:57 +00:00
|
|
|
gtk_widget_class_set_css_name (widget_class, I_("acceleditor"));
|
2014-09-06 22:23:37 +00:00
|
|
|
}
|
2005-09-11 05:43:19 +00:00
|
|
|
|
2014-09-06 22:23:37 +00:00
|
|
|
static void
|
2017-08-02 12:49:36 +00:00
|
|
|
gtk_cell_editable_widget_init (GtkCellEditableWidget *box)
|
2014-09-06 22:23:37 +00:00
|
|
|
{
|
|
|
|
gtk_widget_set_can_focus (GTK_WIDGET (box), TRUE);
|
|
|
|
}
|
2010-08-11 21:17:05 +00:00
|
|
|
|
2014-09-06 22:23:37 +00:00
|
|
|
static GtkWidget *
|
2017-08-02 12:49:36 +00:00
|
|
|
gtk_cell_editable_widget_new (GtkCellRenderer *cell,
|
|
|
|
GtkCellRendererAccelMode mode,
|
|
|
|
const gchar *path)
|
2014-09-06 22:23:37 +00:00
|
|
|
{
|
2017-08-02 12:49:36 +00:00
|
|
|
GtkCellEditableWidget *box;
|
2005-09-11 05:43:19 +00:00
|
|
|
|
2017-08-02 12:49:36 +00:00
|
|
|
box = g_object_new (gtk_cell_editable_widget_get_type (),
|
2014-09-06 22:23:37 +00:00
|
|
|
"accel-mode", mode,
|
|
|
|
"path", path,
|
|
|
|
NULL);
|
|
|
|
box->cell = cell;
|
2005-09-11 05:43:19 +00:00
|
|
|
|
2014-09-06 22:23:37 +00:00
|
|
|
return GTK_WIDGET (box);
|
2005-09-11 05:43:19 +00:00
|
|
|
}
|