forked from AuroraMiddleware/gtk
Add a cell renderer for displaying and editing accelerators, a port of
2005-09-09 Matthias Clasen <mclasen@redhat.com> * gtk/gtkcellrendererkeys.h: * gtk/gtkcellrendererkeys.c: Add a cell renderer for displaying and editing accelerators, a port of EggCellRendererKeys . * gtk/gtk.symbols: * gtk/gtk.h: * gtk/Makefile.am: Add the keys cell renderer. * tests/Makefile.am: * tests/testkeys.c: Test GtkCellRendererKeys
This commit is contained in:
parent
03aea1a3da
commit
07600fb107
13
ChangeLog
13
ChangeLog
@ -1,3 +1,16 @@
|
|||||||
|
2005-09-09 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* gtk/gtkcellrendererkeys.h:
|
||||||
|
* gtk/gtkcellrendererkeys.c: Add a cell renderer for displaying
|
||||||
|
and editing accelerators, a port of EggCellRendererKeys .
|
||||||
|
|
||||||
|
* gtk/gtk.symbols:
|
||||||
|
* gtk/gtk.h:
|
||||||
|
* gtk/Makefile.am: Add the keys cell renderer.
|
||||||
|
|
||||||
|
* tests/Makefile.am:
|
||||||
|
* tests/testkeys.c: Test GtkCellRendererKeys
|
||||||
|
|
||||||
2005-09-09 Matthias Clasen <mclasen@redhat.com>
|
2005-09-09 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
Make it possible to determine if a key event is for a
|
Make it possible to determine if a key event is for a
|
||||||
|
@ -1,3 +1,16 @@
|
|||||||
|
2005-09-09 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* gtk/gtkcellrendererkeys.h:
|
||||||
|
* gtk/gtkcellrendererkeys.c: Add a cell renderer for displaying
|
||||||
|
and editing accelerators, a port of EggCellRendererKeys .
|
||||||
|
|
||||||
|
* gtk/gtk.symbols:
|
||||||
|
* gtk/gtk.h:
|
||||||
|
* gtk/Makefile.am: Add the keys cell renderer.
|
||||||
|
|
||||||
|
* tests/Makefile.am:
|
||||||
|
* tests/testkeys.c: Test GtkCellRendererKeys
|
||||||
|
|
||||||
2005-09-09 Matthias Clasen <mclasen@redhat.com>
|
2005-09-09 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
Make it possible to determine if a key event is for a
|
Make it possible to determine if a key event is for a
|
||||||
|
@ -133,6 +133,7 @@
|
|||||||
<!ENTITY GtkCellLayout SYSTEM "xml/gtkcelllayout.xml">
|
<!ENTITY GtkCellLayout SYSTEM "xml/gtkcelllayout.xml">
|
||||||
<!ENTITY GtkCellRenderer SYSTEM "xml/gtkcellrenderer.xml">
|
<!ENTITY GtkCellRenderer SYSTEM "xml/gtkcellrenderer.xml">
|
||||||
<!ENTITY GtkCellRendererCombo SYSTEM "xml/gtkcellrenderercombo.xml">
|
<!ENTITY GtkCellRendererCombo SYSTEM "xml/gtkcellrenderercombo.xml">
|
||||||
|
<!ENTITY GtkCellRendererKeys SYSTEM "xml/gtkcellrendererkeys.xml">
|
||||||
<!ENTITY GtkCellRendererPixbuf SYSTEM "xml/gtkcellrendererpixbuf.xml">
|
<!ENTITY GtkCellRendererPixbuf SYSTEM "xml/gtkcellrendererpixbuf.xml">
|
||||||
<!ENTITY GtkCellRendererProgress SYSTEM "xml/gtkcellrendererprogress.xml">
|
<!ENTITY GtkCellRendererProgress SYSTEM "xml/gtkcellrendererprogress.xml">
|
||||||
<!ENTITY GtkCellRendererText SYSTEM "xml/gtkcellrenderertext.xml">
|
<!ENTITY GtkCellRendererText SYSTEM "xml/gtkcellrenderertext.xml">
|
||||||
@ -404,6 +405,7 @@ that is, GUI components such as <link linkend="GtkButton">GtkButton</link> or
|
|||||||
&GtkCellRenderer;
|
&GtkCellRenderer;
|
||||||
&GtkCellEditable;
|
&GtkCellEditable;
|
||||||
&GtkCellRendererCombo;
|
&GtkCellRendererCombo;
|
||||||
|
&GtkCellRendererKeys;
|
||||||
&GtkCellRendererPixbuf;
|
&GtkCellRendererPixbuf;
|
||||||
&GtkCellRendererProgress;
|
&GtkCellRendererProgress;
|
||||||
&GtkCellRendererText;
|
&GtkCellRendererText;
|
||||||
|
@ -4354,6 +4354,23 @@ gtk_cell_renderer_progress_get_type
|
|||||||
GtkCellRendererProgressPrivate
|
GtkCellRendererProgressPrivate
|
||||||
</SECTION>
|
</SECTION>
|
||||||
|
|
||||||
|
<SECTION>
|
||||||
|
<FILE>gtkcellrendererkeys</FILE>
|
||||||
|
<TITLE>GtkCellRendererKeys</TITLE>
|
||||||
|
GtkCellRendererKeys
|
||||||
|
gtk_cell_renderer_keys_new
|
||||||
|
|
||||||
|
<SUBSECTION Standard>
|
||||||
|
GTK_TYPE_CELL_RENDERER_KEYS
|
||||||
|
GTK_CELL_RENDERER_KEYS
|
||||||
|
GTK_CELL_RENDERER_KEYS_CLASS
|
||||||
|
GTK_IS_CELL_RENDERER_KEYS
|
||||||
|
GTK_IS_CELL_RENDERER_KEYS_CLASS
|
||||||
|
GTK_CELL_RENDERER_KEYS_GET_CLASS
|
||||||
|
<SUBSECTION Private>
|
||||||
|
gtk_cell_renderer_keys_get_type
|
||||||
|
</SECTION>
|
||||||
|
|
||||||
<SECTION>
|
<SECTION>
|
||||||
<FILE>gtkliststore</FILE>
|
<FILE>gtkliststore</FILE>
|
||||||
<TITLE>GtkListStore</TITLE>
|
<TITLE>GtkListStore</TITLE>
|
||||||
|
@ -132,6 +132,7 @@ gtk_public_h_sources = \
|
|||||||
gtkcelllayout.h \
|
gtkcelllayout.h \
|
||||||
gtkcellrenderer.h \
|
gtkcellrenderer.h \
|
||||||
gtkcellrenderercombo.h \
|
gtkcellrenderercombo.h \
|
||||||
|
gtkcellrendererkeys.h \
|
||||||
gtkcellrendererpixbuf.h \
|
gtkcellrendererpixbuf.h \
|
||||||
gtkcellrendererprogress.h \
|
gtkcellrendererprogress.h \
|
||||||
gtkcellrenderertext.h \
|
gtkcellrenderertext.h \
|
||||||
@ -346,6 +347,7 @@ gtk_c_sources = \
|
|||||||
gtkcelllayout.c \
|
gtkcelllayout.c \
|
||||||
gtkcellrenderer.c \
|
gtkcellrenderer.c \
|
||||||
gtkcellrenderercombo.c \
|
gtkcellrenderercombo.c \
|
||||||
|
gtkcellrendererkeys.c \
|
||||||
gtkcellrendererpixbuf.c \
|
gtkcellrendererpixbuf.c \
|
||||||
gtkcellrendererprogress.c \
|
gtkcellrendererprogress.c \
|
||||||
gtkcellrenderertext.c \
|
gtkcellrenderertext.c \
|
||||||
|
@ -49,6 +49,7 @@
|
|||||||
#include <gtk/gtkcelllayout.h>
|
#include <gtk/gtkcelllayout.h>
|
||||||
#include <gtk/gtkcellrenderer.h>
|
#include <gtk/gtkcellrenderer.h>
|
||||||
#include <gtk/gtkcellrenderercombo.h>
|
#include <gtk/gtkcellrenderercombo.h>
|
||||||
|
#include <gtk/gtkcellrendererkeys.h>
|
||||||
#include <gtk/gtkcellrendererpixbuf.h>
|
#include <gtk/gtkcellrendererpixbuf.h>
|
||||||
#include <gtk/gtkcellrendererprogress.h>
|
#include <gtk/gtkcellrendererprogress.h>
|
||||||
#include <gtk/gtkcellrenderertext.h>
|
#include <gtk/gtkcellrenderertext.h>
|
||||||
|
@ -473,6 +473,13 @@ gtk_cell_renderer_combo_new
|
|||||||
#endif
|
#endif
|
||||||
#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_HEADER(__GTK_CELL_RENDERER_PIXBUF_H__)
|
||||||
#if IN_FILE(__GTK_CELL_RENDERER_PIXBUF_C__)
|
#if IN_FILE(__GTK_CELL_RENDERER_PIXBUF_C__)
|
||||||
gtk_cell_renderer_pixbuf_get_type G_GNUC_CONST
|
gtk_cell_renderer_pixbuf_get_type G_GNUC_CONST
|
||||||
|
@ -42,6 +42,7 @@ noinst_PROGRAMS = \
|
|||||||
testicontheme \
|
testicontheme \
|
||||||
testimage \
|
testimage \
|
||||||
testinput \
|
testinput \
|
||||||
|
testkeys \
|
||||||
testmenus \
|
testmenus \
|
||||||
testmenubars \
|
testmenubars \
|
||||||
testmultidisplay \
|
testmultidisplay \
|
||||||
@ -87,6 +88,7 @@ testfilechooserbutton_DEPENDENCIES = $(TEST_DEPS)
|
|||||||
testgtk_DEPENDENCIES = $(TEST_DEPS)
|
testgtk_DEPENDENCIES = $(TEST_DEPS)
|
||||||
testinput_DEPENDENCIES = $(TEST_DEPS)
|
testinput_DEPENDENCIES = $(TEST_DEPS)
|
||||||
testimage_DEPENDENCIES = $(TEST_DEPS)
|
testimage_DEPENDENCIES = $(TEST_DEPS)
|
||||||
|
testkeys_DEPENDENCIES = $(TEST_DEPS)
|
||||||
testmenus_DEPENDENCIES = $(TEST_DEPS)
|
testmenus_DEPENDENCIES = $(TEST_DEPS)
|
||||||
testmenubars_DEPENDENCIES = $(TEST_DEPS)
|
testmenubars_DEPENDENCIES = $(TEST_DEPS)
|
||||||
testmultidisplay_DEPENDENCIES = $(TEST_DEPS)
|
testmultidisplay_DEPENDENCIES = $(TEST_DEPS)
|
||||||
@ -126,6 +128,7 @@ testicontheme_LDADD = $(LDADDS)
|
|||||||
testiconview_LDADD = $(LDADDS)
|
testiconview_LDADD = $(LDADDS)
|
||||||
testinput_LDADD = $(LDADDS)
|
testinput_LDADD = $(LDADDS)
|
||||||
testimage_LDADD = $(LDADDS)
|
testimage_LDADD = $(LDADDS)
|
||||||
|
testkeys_LDADD = $(LDADDS)
|
||||||
testmenus_LDADD = $(LDADDS)
|
testmenus_LDADD = $(LDADDS)
|
||||||
testmenubars_LDADD = $(LDADDS)
|
testmenubars_LDADD = $(LDADDS)
|
||||||
testmultidisplay_LDADD = $(LDADDS)
|
testmultidisplay_LDADD = $(LDADDS)
|
||||||
|
109
tests/testaccel.c
Normal file
109
tests/testaccel.c
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
/* 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;
|
||||||
|
}
|
109
tests/testkeys.c
Normal file
109
tests/testkeys.c
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
/* 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