diff --git a/ChangeLog b/ChangeLog index 2bfeb75b25..a3a1a96cb9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2005-09-09 Matthias Clasen + + * 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 Make it possible to determine if a key event is for a diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 2bfeb75b25..a3a1a96cb9 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,16 @@ +2005-09-09 Matthias Clasen + + * 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 Make it possible to determine if a key event is for a diff --git a/docs/reference/gtk/gtk-docs.sgml b/docs/reference/gtk/gtk-docs.sgml index 79eefce340..1185d83a6c 100644 --- a/docs/reference/gtk/gtk-docs.sgml +++ b/docs/reference/gtk/gtk-docs.sgml @@ -133,6 +133,7 @@ + @@ -404,6 +405,7 @@ that is, GUI components such as GtkButton or &GtkCellRenderer; &GtkCellEditable; &GtkCellRendererCombo; + &GtkCellRendererKeys; &GtkCellRendererPixbuf; &GtkCellRendererProgress; &GtkCellRendererText; diff --git a/docs/reference/gtk/gtk-sections.txt b/docs/reference/gtk/gtk-sections.txt index ed4d89ed25..fc1052c68b 100644 --- a/docs/reference/gtk/gtk-sections.txt +++ b/docs/reference/gtk/gtk-sections.txt @@ -4354,6 +4354,23 @@ gtk_cell_renderer_progress_get_type GtkCellRendererProgressPrivate +
+gtkcellrendererkeys +GtkCellRendererKeys +GtkCellRendererKeys +gtk_cell_renderer_keys_new + + +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 + +gtk_cell_renderer_keys_get_type +
+
gtkliststore GtkListStore diff --git a/gtk/Makefile.am b/gtk/Makefile.am index 5b371996a7..dab3ad75d8 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -132,6 +132,7 @@ gtk_public_h_sources = \ gtkcelllayout.h \ gtkcellrenderer.h \ gtkcellrenderercombo.h \ + gtkcellrendererkeys.h \ gtkcellrendererpixbuf.h \ gtkcellrendererprogress.h \ gtkcellrenderertext.h \ @@ -346,6 +347,7 @@ gtk_c_sources = \ gtkcelllayout.c \ gtkcellrenderer.c \ gtkcellrenderercombo.c \ + gtkcellrendererkeys.c \ gtkcellrendererpixbuf.c \ gtkcellrendererprogress.c \ gtkcellrenderertext.c \ diff --git a/gtk/gtk.h b/gtk/gtk.h index 174333fc0f..c7a66a4f3f 100644 --- a/gtk/gtk.h +++ b/gtk/gtk.h @@ -49,6 +49,7 @@ #include #include #include +#include #include #include #include diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols index 1c1a24fbff..de5d8a3764 100644 --- a/gtk/gtk.symbols +++ b/gtk/gtk.symbols @@ -473,6 +473,13 @@ 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 diff --git a/tests/Makefile.am b/tests/Makefile.am index c54663a99c..a2bc7e7935 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -42,6 +42,7 @@ noinst_PROGRAMS = \ testicontheme \ testimage \ testinput \ + testkeys \ testmenus \ testmenubars \ testmultidisplay \ @@ -87,6 +88,7 @@ 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) @@ -126,6 +128,7 @@ testicontheme_LDADD = $(LDADDS) testiconview_LDADD = $(LDADDS) testinput_LDADD = $(LDADDS) testimage_LDADD = $(LDADDS) +testkeys_LDADD = $(LDADDS) testmenus_LDADD = $(LDADDS) testmenubars_LDADD = $(LDADDS) testmultidisplay_LDADD = $(LDADDS) diff --git a/tests/testaccel.c b/tests/testaccel.c new file mode 100644 index 0000000000..d92d5d69d0 --- /dev/null +++ b/tests/testaccel.c @@ -0,0 +1,109 @@ +/* gtkcellrendererkeys.h + * Copyright (C) 2000 Red Hat, Inc., Jonathan Blandford + * + * 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 +#include + +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; +} diff --git a/tests/testkeys.c b/tests/testkeys.c new file mode 100644 index 0000000000..d92d5d69d0 --- /dev/null +++ b/tests/testkeys.c @@ -0,0 +1,109 @@ +/* gtkcellrendererkeys.h + * Copyright (C) 2000 Red Hat, Inc., Jonathan Blandford + * + * 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 +#include + +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; +}