From cb6e33a0c1c2211b8fdb5efbc0013b8dfd149edf Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 21 Nov 2015 12:32:02 -0500 Subject: Support GtkShortCutsWindow Add support for GtkShortcutsWindow and its constituents. This requires fixes and API changes on the GTK+ side. --- plugins/gtk+/Makefile.am | 12 + plugins/gtk+/glade-accels.c | 4 +- plugins/gtk+/glade-gtk-resources.gresource.xml | 3 + plugins/gtk+/glade-gtk-shortcutsgroup.c | 255 ++++++++++++++ plugins/gtk+/glade-gtk-shortcutssection.c | 257 ++++++++++++++ plugins/gtk+/glade-gtk-shortcutswindow.c | 377 +++++++++++++++++++++ plugins/gtk+/glade-shortcutsgroup-editor.c | 68 ++++ plugins/gtk+/glade-shortcutsgroup-editor.h | 56 +++ plugins/gtk+/glade-shortcutsgroup-editor.ui | 108 ++++++ plugins/gtk+/glade-shortcutssection-editor.c | 68 ++++ plugins/gtk+/glade-shortcutssection-editor.h | 56 +++ plugins/gtk+/glade-shortcutssection-editor.ui | 108 ++++++ plugins/gtk+/glade-shortcutswindow-editor.c | 68 ++++ plugins/gtk+/glade-shortcutswindow-editor.h | 56 +++ plugins/gtk+/glade-shortcutswindow-editor.ui | 108 ++++++ plugins/gtk+/glade-widget-editor.ui | 4 +- plugins/gtk+/gtk+.xml.in | 178 +++++++++- plugins/gtk+/icons/16x16/Makefile.am | 3 + .../icons/16x16/widget-gtk-shortcutsgesture.png | Bin 0 -> 447 bytes .../icons/16x16/widget-gtk-shortcutsshortcut.png | Bin 0 -> 579 bytes .../icons/16x16/widget-gtk-shortcutswindow.png | Bin 0 -> 303 bytes plugins/gtk+/icons/22x22/Makefile.am | 3 + .../icons/22x22/widget-gtk-shortcutsgesture.png | Bin 0 -> 569 bytes .../icons/22x22/widget-gtk-shortcutsshortcut.png | Bin 0 -> 726 bytes .../icons/22x22/widget-gtk-shortcutswindow.png | Bin 0 -> 387 bytes 25 files changed, 1779 insertions(+), 13 deletions(-) create mode 100644 plugins/gtk+/glade-gtk-shortcutsgroup.c create mode 100644 plugins/gtk+/glade-gtk-shortcutssection.c create mode 100644 plugins/gtk+/glade-gtk-shortcutswindow.c create mode 100644 plugins/gtk+/glade-shortcutsgroup-editor.c create mode 100644 plugins/gtk+/glade-shortcutsgroup-editor.h create mode 100644 plugins/gtk+/glade-shortcutsgroup-editor.ui create mode 100644 plugins/gtk+/glade-shortcutssection-editor.c create mode 100644 plugins/gtk+/glade-shortcutssection-editor.h create mode 100644 plugins/gtk+/glade-shortcutssection-editor.ui create mode 100644 plugins/gtk+/glade-shortcutswindow-editor.c create mode 100644 plugins/gtk+/glade-shortcutswindow-editor.h create mode 100644 plugins/gtk+/glade-shortcutswindow-editor.ui create mode 100644 plugins/gtk+/icons/16x16/widget-gtk-shortcutsgesture.png create mode 100644 plugins/gtk+/icons/16x16/widget-gtk-shortcutsshortcut.png create mode 100644 plugins/gtk+/icons/16x16/widget-gtk-shortcutswindow.png create mode 100644 plugins/gtk+/icons/22x22/widget-gtk-shortcutsgesture.png create mode 100644 plugins/gtk+/icons/22x22/widget-gtk-shortcutsshortcut.png create mode 100644 plugins/gtk+/icons/22x22/widget-gtk-shortcutswindow.png diff --git a/plugins/gtk+/Makefile.am b/plugins/gtk+/Makefile.am index 4fff22b2..af198776 100644 --- a/plugins/gtk+/Makefile.am +++ b/plugins/gtk+/Makefile.am @@ -102,6 +102,9 @@ libgladegtk_la_SOURCES = \ glade-gtk-scrollbar.c \ glade-gtk-scrolled-window.c \ glade-gtk-searchbar.c \ + glade-gtk-shortcutswindow.c \ + glade-gtk-shortcutssection.c \ + glade-gtk-shortcutsgroup.c \ glade-gtk-size-group.c \ glade-gtk-spin-button.c \ glade-gtk-stack.c \ @@ -146,6 +149,9 @@ libgladegtk_la_SOURCES = \ glade-scrollable-editor.c \ glade-scrollbar-editor.c \ glade-scrolled-window-editor.c \ + glade-shortcutswindow-editor.c \ + glade-shortcutssection-editor.c \ + glade-shortcutsgroup-editor.c \ glade-spin-button-editor.c \ glade-stack-editor.c \ glade-stack-switcher-editor.c \ @@ -225,6 +231,9 @@ noinst_HEADERS = \ glade-scrollable-editor.h \ glade-scrollbar-editor.h \ glade-scrolled-window-editor.h \ + glade-shortcutswindow-editor.h \ + glade-shortcutssection-editor.h \ + glade-shortcutsgroup-editor.h \ glade-spin-button-editor.h \ glade-stack-editor.h \ glade-stack-switcher-editor.h \ @@ -302,6 +311,9 @@ UI_FILES = \ glade-scrollable-editor.ui \ glade-scrollbar-editor.ui \ glade-scrolled-window-editor.ui \ + glade-shortcutswindow-editor.ui \ + glade-shortcutssection-editor.ui \ + glade-shortcutsgroup-editor.ui \ glade-spin-button-editor.ui \ glade-stack-editor.ui \ glade-stack-switcher-editor.ui \ diff --git a/plugins/gtk+/glade-accels.c b/plugins/gtk+/glade-accels.c index d5615105..b48bbe1e 100644 --- a/plugins/gtk+/glade-accels.c +++ b/plugins/gtk+/glade-accels.c @@ -893,7 +893,7 @@ glade_gtk_read_accels (GladeWidget * widget, g_value_init (value, GLADE_TYPE_ACCEL_GLIST); g_value_take_boxed (value, accels); - property = glade_widget_get_property (widget, "accelerator"); + property = glade_widget_get_property (widget, "accelerators"); glade_property_set_value (property, value); g_value_unset (value); @@ -911,7 +911,7 @@ glade_gtk_write_accels (GladeWidget * widget, GList *list; /* Some child widgets may have disabled the property */ - if (!(property = glade_widget_get_property (widget, "accelerator"))) + if (!(property = glade_widget_get_property (widget, "accelerators"))) return; for (list = g_value_get_boxed (glade_property_inline_value (property)); list; list = list->next) diff --git a/plugins/gtk+/glade-gtk-resources.gresource.xml b/plugins/gtk+/glade-gtk-resources.gresource.xml index e9e5d020..42f090a4 100644 --- a/plugins/gtk+/glade-gtk-resources.gresource.xml +++ b/plugins/gtk+/glade-gtk-resources.gresource.xml @@ -42,6 +42,9 @@ glade-scrollable-editor.ui glade-scrollbar-editor.ui glade-scrolled-window-editor.ui + glade-shortcutsgroup-editor.ui + glade-shortcutssection-editor.ui + glade-shortcutswindow-editor.ui glade-spin-button-editor.ui glade-stack-editor.ui glade-stack-switcher-editor.ui diff --git a/plugins/gtk+/glade-gtk-shortcutsgroup.c b/plugins/gtk+/glade-gtk-shortcutsgroup.c new file mode 100644 index 00000000..b5c8bbfc --- /dev/null +++ b/plugins/gtk+/glade-gtk-shortcutsgroup.c @@ -0,0 +1,255 @@ +/* + * glade-gtk-shortcutsgroup.c - GladeWidgetAdaptor for GtkShortcutsGroup + * + * Copyright (C) 2015 Red Hat, Inc + * + * Authors: + * Matthias Clasen + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#include +#include +#include +#include "glade-gtk.h" +#include "glade-fixed.h" +#include "glade-shortcutsgroup-editor.h" + +static gboolean +glade_gtk_shortcutsgroup_configure_child (GladeFixed *fixed, + GladeWidget *child, + GdkRectangle *rect, + GtkWidget *group) +{ + return TRUE; +} + +void +glade_gtk_shortcutsgroup_post_create (GladeWidgetAdaptor *adaptor, + GObject *container, + GladeCreateReason reason) +{ + GladeWidget *gwidget = glade_widget_get_from_gobject (container); + + g_signal_connect (G_OBJECT (gwidget), "configure-child", + G_CALLBACK (glade_gtk_shortcutsgroup_configure_child), container); + + if (reason == GLADE_CREATE_USER) + { + GladeWidgetAdaptor *shortcut_adaptor = glade_widget_adaptor_get_by_type (GTK_TYPE_SHORTCUTS_SHORTCUT); + GladeWidget *shortcut; + + shortcut = glade_widget_adaptor_create_widget (shortcut_adaptor, FALSE, + "parent", gwidget, + "project", glade_widget_get_project (gwidget), + NULL); + glade_widget_add_child (gwidget, shortcut, FALSE); + } +} + +gboolean +glade_gtk_shortcutsgroup_add_verify (GladeWidgetAdaptor *adaptor, + GtkWidget *container, + GtkWidget *child, + gboolean user_feedback) +{ + if (!GTK_IS_SHORTCUTS_SHORTCUT (child)) + { + if (user_feedback) + { + GladeWidgetAdaptor *tool_item_adaptor = + glade_widget_adaptor_get_by_type (GTK_TYPE_SHORTCUTS_SHORTCUT); + + glade_util_ui_message (glade_app_get_window (), + GLADE_UI_INFO, NULL, + ONLY_THIS_GOES_IN_THAT_MSG, + glade_widget_adaptor_get_title (tool_item_adaptor), + glade_widget_adaptor_get_title (adaptor)); + } + + return FALSE; + } + + return TRUE; +} + +static void +add_new_shortcut (GObject *object) +{ + GladeWidgetAdaptor *adaptor = glade_widget_adaptor_get_by_type (GTK_TYPE_SHORTCUTS_SHORTCUT); + GladeWidget *gparent = glade_widget_get_from_gobject (object); + GladeProject *project = glade_widget_get_project (gparent); + + glade_command_push_group (_("Adding a shortcut to %s"), glade_widget_get_name (gparent)); + glade_command_create (adaptor, gparent, NULL, project); + glade_project_selection_set (project, object, TRUE); + glade_command_pop_group (); +} + +GladeEditable * +glade_gtk_shortcutsgroup_create_editable (GladeWidgetAdaptor * adaptor, + GladeEditorPageType type) +{ + if (type == GLADE_PAGE_GENERAL) + return (GladeEditable *) glade_shortcutsgroup_editor_new (); + + return GWA_GET_CLASS (GTK_TYPE_CONTAINER)->create_editable (adaptor, type); +} + +typedef struct { + gint size; +} ChildData; + +static void +count_child (GtkWidget *child, gpointer data) +{ + ChildData *cdata = data; + + cdata->size++; +} + +static gint +glade_gtk_shortcutsgroup_get_n_shortcuts (GObject *object) +{ + ChildData data; + + data.size = 0; + gtk_container_foreach (GTK_CONTAINER (object), count_child, &data); + return data.size; +} + +static void +glade_gtk_shortcutsgroup_set_n_shortcuts (GObject *object, + const GValue *value) +{ + gint old_size; + gint new_size; + gint i; + GList *children, *l, *list; + + new_size = g_value_get_int (value); + old_size = glade_gtk_shortcutsgroup_get_n_shortcuts (object); + + if (old_size == new_size) + return; + + for (i = old_size; i < new_size; i++) + add_new_shortcut (object); + + list = NULL; + children = gtk_container_get_children (GTK_CONTAINER (object)); + for (i = old_size, l = g_list_last (children); i > 0; i--, l = l->prev) + { + if (old_size <= new_size) + break; + + list = g_list_append (list, glade_widget_get_from_gobject (G_OBJECT (l->data))); + } + g_list_free (children); + + if (list) + { + glade_command_delete (list); + g_list_free (list); + } +} + +void +glade_gtk_shortcutsgroup_set_property (GladeWidgetAdaptor * adaptor, + GObject * object, + const gchar * id, + const GValue * value) +{ + if (!strcmp (id, "shortcuts")) + glade_gtk_shortcutsgroup_set_n_shortcuts (object, value); + else + GWA_GET_CLASS (GTK_TYPE_CONTAINER)->set_property (adaptor, object, id, value); +} + +void +glade_gtk_shortcutsgroup_get_property (GladeWidgetAdaptor * adaptor, + GObject * object, + const gchar * id, + GValue * value) +{ + if (!strcmp (id, "shortcuts")) + { + g_value_reset (value); + g_value_set_int (value, glade_gtk_shortcutsgroup_get_n_shortcuts (object)); + } + else + GWA_GET_CLASS (GTK_TYPE_CONTAINER)->get_property (adaptor, object, id, value); +} + +void +glade_gtk_shortcutsgroup_action_activate (GladeWidgetAdaptor * adaptor, + GObject * object, + const gchar * action_path) +{ + if (strcmp (action_path, "add_shortcut") == 0) + { + GladeWidget *gwidget = glade_widget_get_from_gobject (object); + GladeProperty *property; + gint shortcuts; + + shortcuts = glade_gtk_shortcutsgroup_get_n_shortcuts (object); + property = glade_widget_get_property (gwidget, "shortcuts"); + glade_command_set_property (property, shortcuts + 1); + } + else + GWA_GET_CLASS (GTK_TYPE_CONTAINER)->action_activate (adaptor, + object, action_path); +} + +void +glade_gtk_shortcutsgroup_add_child (GladeWidgetAdaptor * adaptor, + GObject * object, + GObject * child) +{ + GladeWidget *gwidget = glade_widget_get_from_gobject (object); + GladeProperty *property; + gint shortcuts; + + gtk_container_add (GTK_CONTAINER (object), GTK_WIDGET (child)); + + shortcuts = glade_gtk_shortcutsgroup_get_n_shortcuts (object); + property = glade_widget_get_property (gwidget, "shortcuts"); + glade_command_set_property (property, shortcuts); +} + +void +glade_gtk_shortcutsgroup_remove_child (GladeWidgetAdaptor * adaptor, + GObject * object, + GObject * child) +{ + GladeWidget *gwidget = glade_widget_get_from_gobject (object); + GladeProperty *property; + gint shortcuts; + + gtk_container_remove (GTK_CONTAINER (object), GTK_WIDGET (child)); + + shortcuts = glade_gtk_shortcutsgroup_get_n_shortcuts (object); + property = glade_widget_get_property (gwidget, "shortcuts"); + glade_command_set_property (property, shortcuts); +} + +void +glade_gtk_shortcutsgroup_replace_child (GladeWidgetAdaptor * adaptor, + GObject * container, + GObject * current, + GObject * new_widget) +{ + GWA_GET_CLASS (GTK_TYPE_CONTAINER)->replace_child (adaptor, container, current, new_widget); +} diff --git a/plugins/gtk+/glade-gtk-shortcutssection.c b/plugins/gtk+/glade-gtk-shortcutssection.c new file mode 100644 index 00000000..53adac86 --- /dev/null +++ b/plugins/gtk+/glade-gtk-shortcutssection.c @@ -0,0 +1,257 @@ +/* + * glade-gtk-shortcutssection.c - GladeWidgetAdaptor for GtkShortcutsSection + * + * Copyright (C) 2015 Red Hat, Inc + * + * Authors: + * Matthias Clasen + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#include +#include +#include +#include "glade-gtk.h" +#include "glade-shortcutssection-editor.h" + +void +glade_gtk_shortcutssection_post_create (GladeWidgetAdaptor *adaptor, + GObject *container, + GladeCreateReason reason) +{ + GladeWidget *gwidget = glade_widget_get_from_gobject (container); + + if (reason == GLADE_CREATE_USER) + { + GladeWidgetAdaptor *group_adaptor = glade_widget_adaptor_get_by_type (GTK_TYPE_SHORTCUTS_GROUP); + GladeWidget *group; + + group = glade_widget_adaptor_create_widget (group_adaptor, FALSE, + "parent", gwidget, + "project", glade_widget_get_project (gwidget), + NULL); + glade_widget_property_set (group, "title", "Group"); + glade_widget_add_child (gwidget, group, FALSE); + } +} + +gboolean +glade_gtk_shortcutssection_add_verify (GladeWidgetAdaptor *adaptor, + GtkWidget *container, + GtkWidget *child, + gboolean user_feedback) +{ + if (!GTK_IS_SHORTCUTS_GROUP (child)) + { + if (user_feedback) + { + GladeWidgetAdaptor *tool_item_adaptor = + glade_widget_adaptor_get_by_type (GTK_TYPE_SHORTCUTS_GROUP); + + glade_util_ui_message (glade_app_get_window (), + GLADE_UI_INFO, NULL, + ONLY_THIS_GOES_IN_THAT_MSG, + glade_widget_adaptor_get_title (tool_item_adaptor), + glade_widget_adaptor_get_title (adaptor)); + } + + return FALSE; + } + + return TRUE; +} + +static void +add_new_group (GObject *object) +{ + GladeWidgetAdaptor *adaptor = glade_widget_adaptor_get_by_type (GTK_TYPE_SHORTCUTS_GROUP); + GladeWidget *gparent = glade_widget_get_from_gobject (object); + GladeWidget *gchild; + GladeProject *project = glade_widget_get_project (gparent); + GladeProperty *property; + + glade_command_push_group (_("Adding a group to %s"), glade_widget_get_name (gparent)); + gchild = glade_command_create (adaptor, gparent, NULL, project); + property = glade_widget_get_property (gchild, "title"); + glade_command_set_property (property, _("Group")); + glade_project_selection_set (project, object, TRUE); + glade_command_pop_group (); +} + +GladeEditable * +glade_gtk_shortcutssection_create_editable (GladeWidgetAdaptor * adaptor, + GladeEditorPageType type) +{ + if (type == GLADE_PAGE_GENERAL) + return (GladeEditable *) glade_shortcutssection_editor_new (); + + return GWA_GET_CLASS (GTK_TYPE_CONTAINER)->create_editable (adaptor, type); +} + +typedef struct { + gint size; +} ChildData; + +static void +count_child (GtkWidget *child, gpointer data) +{ + ChildData *cdata = data; + + cdata->size++; +} + +static gint +glade_gtk_shortcutssection_get_n_groups (GObject *object) +{ + ChildData data; + + data.size = 0; + gtk_container_foreach (GTK_CONTAINER (object), count_child, &data); + return data.size; +} + +static void +glade_gtk_shortcutssection_set_n_groups (GObject *object, + gint new_size) +{ + gint old_size; + gint i; + + old_size = glade_gtk_shortcutssection_get_n_groups (object); + + if (old_size == new_size) + return; + + for (i = old_size; i < new_size; i++) + add_new_group (object); + + /* We never remove children here, they have to be explicitly deleted */ +} + +static gboolean +glade_gtk_shortcutswindow_verify_groups (GObject *object, + gint new_size) +{ + GList *children; + gint old_size; + + children = gtk_container_get_children (GTK_CONTAINER (object)); + old_size = g_list_length (children); + g_list_free (children); + + return new_size >= old_size; +} + +void +glade_gtk_shortcutssection_set_property (GladeWidgetAdaptor * adaptor, + GObject * object, + const gchar * id, + const GValue * value) +{ + if (!strcmp (id, "groups")) + glade_gtk_shortcutssection_set_n_groups (object, g_value_get_int (value)); + else + GWA_GET_CLASS (GTK_TYPE_CONTAINER)->set_property (adaptor, object, id, value); +} + +void +glade_gtk_shortcutssection_get_property (GladeWidgetAdaptor * adaptor, + GObject * object, + const gchar * id, + GValue * value) +{ + if (!strcmp (id, "groups")) + { + g_value_reset (value); + g_value_set_int (value, glade_gtk_shortcutssection_get_n_groups (object)); + } + else + GWA_GET_CLASS (GTK_TYPE_CONTAINER)->get_property (adaptor, object, id, value); +} + +gboolean +glade_gtk_shortcutssection_verify_property (GladeWidgetAdaptor * adaptor, + GObject * object, + const gchar * id, const GValue * value) +{ + if (!strcmp (id, "groups")) + return glade_gtk_shortcutswindow_verify_groups (object, g_value_get_int (value)); + else if (GWA_GET_CLASS (GTK_TYPE_CONTAINER)->verify_property) + return GWA_GET_CLASS (GTK_TYPE_CONTAINER)->verify_property (adaptor, object, + id, value); + + return TRUE; +} + +void +glade_gtk_shortcutssection_action_activate (GladeWidgetAdaptor * adaptor, + GObject * object, + const gchar * action_path) +{ + if (strcmp (action_path, "add_group") == 0) + { + GladeWidget *gwidget = glade_widget_get_from_gobject (object); + GladeProperty *property; + gint groups; + + groups = glade_gtk_shortcutssection_get_n_groups (object); + property = glade_widget_get_property (gwidget, "groups"); + glade_command_set_property (property, groups + 1); + } + else + GWA_GET_CLASS (GTK_TYPE_CONTAINER)->action_activate (adaptor, + object, action_path); +} + +void +glade_gtk_shortcutssection_add_child (GladeWidgetAdaptor * adaptor, + GObject * object, + GObject * child) +{ + GladeWidget *gwidget = glade_widget_get_from_gobject (object); + GladeProperty *property; + gint groups; + + gtk_container_add (GTK_CONTAINER (object), GTK_WIDGET (child)); + + groups = glade_gtk_shortcutssection_get_n_groups (object); + property = glade_widget_get_property (gwidget, "groups"); + glade_command_set_property (property, groups); +} + +void +glade_gtk_shortcutssection_remove_child (GladeWidgetAdaptor * adaptor, + GObject * object, + GObject * child) +{ + GladeWidget *gwidget = glade_widget_get_from_gobject (object); + GladeProperty *property; + gint groups; + + gtk_container_remove (GTK_CONTAINER (object), GTK_WIDGET (child)); + + groups = glade_gtk_shortcutssection_get_n_groups (object); + property = glade_widget_get_property (gwidget, "groups"); + glade_command_set_property (property, groups); +} + +void +glade_gtk_shortcutssection_replace_child (GladeWidgetAdaptor * adaptor, + GObject * container, + GObject * current, + GObject * new_widget) +{ + GWA_GET_CLASS (GTK_TYPE_CONTAINER)->replace_child (adaptor, container, current, new_widget); +} diff --git a/plugins/gtk+/glade-gtk-shortcutswindow.c b/plugins/gtk+/glade-gtk-shortcutswindow.c new file mode 100644 index 00000000..bdf07dbf --- /dev/null +++ b/plugins/gtk+/glade-gtk-shortcutswindow.c @@ -0,0 +1,377 @@ +/* + * glade-gtk-shortcutswindow.c - GladeWidgetAdaptor for GtkShortcutsWindow + * + * Copyright (C) 2015 Red Hat, Inc + * + * Authors: + * Matthias Clasen + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#include +#include +#include +#include "glade-gtk.h" +#include "glade-shortcutswindow-editor.h" + + +static void +glade_gtk_shortcutswindow_selection_changed (GladeProject * project, + GladeWidget * gwidget) +{ + GList *list; + GtkWidget *child, *sel_widget; + GtkWidget *window = GTK_WIDGET (glade_widget_get_object (gwidget)); + gint position; + + if ((list = glade_project_selection_get (project)) != NULL && + g_list_length (list) == 1) + { + sel_widget = list->data; + + if (GTK_IS_SHORTCUTS_SECTION (sel_widget) && + gtk_widget_is_ancestor (sel_widget, window)) + { + GList *children, *l; + + children = gtk_container_get_children (GTK_CONTAINER (window)); + for (l = children, position = 0; l; l = l->next, position++) + { + child = l->data; + if (sel_widget == child || + gtk_widget_is_ancestor (sel_widget, child)) + { + glade_widget_property_set (gwidget, "section", position); + break; + } + } + g_list_free (children); + } + } +} + +static void +glade_gtk_shortcutswindow_project_changed (GladeWidget * gwidget, + GParamSpec * pspec, + gpointer userdata) +{ + GladeProject * project = glade_widget_get_project (gwidget); + GladeProject * old_project = g_object_get_data (G_OBJECT (gwidget), "shortcutswindow-project-ptr"); + + if (old_project) + g_signal_handlers_disconnect_by_func (G_OBJECT (old_project), + G_CALLBACK (glade_gtk_shortcutswindow_selection_changed), + gwidget); + + if (project) + g_signal_connect (G_OBJECT (project), "selection-changed", + G_CALLBACK (glade_gtk_shortcutswindow_selection_changed), + gwidget); + + g_object_set_data (G_OBJECT (gwidget), "shortcutswindow-project-ptr", project); +} + +void +glade_gtk_shortcutswindow_post_create (GladeWidgetAdaptor *adaptor, + GObject *container, + GladeCreateReason reason) +{ + GladeWidget *gwidget = glade_widget_get_from_gobject (container); + + if (reason == GLADE_CREATE_USER) + { + GladeWidgetAdaptor *section_adaptor = glade_widget_adaptor_get_by_type (GTK_TYPE_SHORTCUTS_SECTION); + GladeWidget *section; + + section = glade_widget_adaptor_create_widget (section_adaptor, FALSE, + "parent", gwidget, + "project", glade_widget_get_project (gwidget), + NULL); + glade_widget_property_set (section, "title", "Shortcuts"); + glade_widget_property_set (section, "section-name", "shortcuts"); + glade_widget_add_child (gwidget, section, FALSE); + } + + g_signal_connect (G_OBJECT (gwidget), "notify::project", + G_CALLBACK (glade_gtk_shortcutswindow_project_changed), NULL); + + glade_gtk_shortcutswindow_project_changed (gwidget, NULL, NULL); +} + +gboolean +glade_gtk_shortcutswindow_add_verify (GladeWidgetAdaptor *adaptor, + GtkWidget *container, + GtkWidget *child, + gboolean user_feedback) +{ + if (!GTK_IS_SHORTCUTS_SECTION (child)) + { + if (user_feedback) + { + GladeWidgetAdaptor *tool_item_adaptor = + glade_widget_adaptor_get_by_type (GTK_TYPE_SHORTCUTS_SECTION); + + glade_util_ui_message (glade_app_get_window (), + GLADE_UI_INFO, NULL, + ONLY_THIS_GOES_IN_THAT_MSG, + glade_widget_adaptor_get_title (tool_item_adaptor), + glade_widget_adaptor_get_title (adaptor)); + } + + return FALSE; + } + + return TRUE; +} + +static gchar * +get_unused_name (GObject *object) +{ + GList *children, *l; + gchar *name; + gchar *n; + gint i; + gboolean found; + + children = gtk_container_get_children (GTK_CONTAINER (object)); + + for (i = 1; i < 100; i++) + { + name = g_strdup_printf ("shortcuts%d", i); + found = FALSE; + for (l = children; l && !found; l = l->next) + { + g_object_get (l->data, "section-name", &n, NULL); + if (g_strcmp0 (n, name) == 0) + found = TRUE; + g_free (n); + } + if (!found) + break; + g_free (name); + name = NULL; + } + g_list_free (children); + + return name; +} + +static void +add_new_section (GObject *object) +{ + GladeWidgetAdaptor *section_adaptor = glade_widget_adaptor_get_by_type (GTK_TYPE_SHORTCUTS_SECTION); + GladeWidget *gparent = glade_widget_get_from_gobject (object); + GladeProject *project = glade_widget_get_project (gparent); + GladeWidget *section; + + section = glade_command_create (section_adaptor, gparent, NULL, project); + glade_widget_property_set (section, "title", "Shortcuts"); + glade_widget_property_set (section, "section-name", get_unused_name (object)); +} + +GladeEditable * +glade_gtk_shortcutswindow_create_editable (GladeWidgetAdaptor * adaptor, + GladeEditorPageType type) +{ + if (type == GLADE_PAGE_GENERAL) + return (GladeEditable *) glade_shortcutswindow_editor_new (); + + return GWA_GET_CLASS (GTK_TYPE_CONTAINER)->create_editable (adaptor, type); +} + +typedef struct { + gint size; +} ChildData; + +static void +count_child (GtkWidget *child, gpointer data) +{ + ChildData *cdata = data; + + cdata->size++; +} + +static gint +glade_gtk_shortcutswindow_get_n_sections (GObject *object) +{ + ChildData data; + + data.size = 0; + gtk_container_foreach (GTK_CONTAINER (object), count_child, &data); + return data.size; +} + +static void +glade_gtk_shortcutswindow_set_n_sections (GObject *object, + gint new_size) +{ + gint old_size, i; + + old_size = glade_gtk_shortcutswindow_get_n_sections (object); + + if (old_size == new_size) + return; + + for (i = old_size; i < new_size; i++) + add_new_section (object); + + /* We never remove children here, they have to be explicitly deleted */ +} + +static void +glade_gtk_shortcutswindow_set_section (GObject *object, + const GValue *value) +{ + gint new_section; + GList *children; + GtkWidget *child; + + new_section = g_value_get_int (value); + children = gtk_container_get_children (GTK_CONTAINER (object)); + child = g_list_nth_data (children, new_section); + + if (child) + { + gchar *n; + + g_object_get (child, "section-name", &n, NULL); + g_object_set (object, "section-name", n, NULL); + g_free (n); + } + + g_list_free (children); +} + +static gint +glade_gtk_shortcutswindow_get_section (GObject *object) +{ + gchar *name, *n; + gint section; + gboolean found; + GList *children, *l; + + g_object_get (object, "section-name", &name, NULL); + children = gtk_container_get_children (GTK_CONTAINER (object)); + found = FALSE; + for (l = children, section = 0; l && !found; l = l->next, section++) + { + g_object_get (l->data, "section-name", &n, NULL); + found = strcmp (name, n) == 0; + g_free (n); + } + g_list_free (children); + g_free (name); + + return section; +} + +void +glade_gtk_shortcutswindow_set_property (GladeWidgetAdaptor * adaptor, + GObject * object, + const gchar * id, + const GValue * value) +{ + if (!strcmp (id, "section")) + glade_gtk_shortcutswindow_set_section (object, value); + else + GWA_GET_CLASS (GTK_TYPE_WINDOW)->set_property (adaptor, object, id, value); +} + +static gboolean +glade_gtk_shortcutswindow_verify_section (GObject *object, const GValue *value) +{ + GList *children; + gint section, size; + + section = g_value_get_int (value); + + children = gtk_container_get_children (GTK_CONTAINER (object)); + size = g_list_length (children); + g_list_free (children); + + return 0 <= section && section < size; +} + +gboolean +glade_gtk_shortcutswindow_verify_property (GladeWidgetAdaptor * adaptor, + GObject * object, + const gchar * id, const GValue * value) +{ + if (!strcmp (id, "section")) + return glade_gtk_shortcutswindow_verify_section (object, value); + else if (GWA_GET_CLASS (GTK_TYPE_CONTAINER)->verify_property) + return GWA_GET_CLASS (GTK_TYPE_CONTAINER)->verify_property (adaptor, object, + id, value); + + return TRUE; +} + + +void +glade_gtk_shortcutswindow_get_property (GladeWidgetAdaptor * adaptor, + GObject * object, + const gchar * id, + GValue * value) +{ + if (!strcmp (id, "section")) + { + g_value_reset (value); + g_value_set_int (value, glade_gtk_shortcutswindow_get_section (object)); + } + else + GWA_GET_CLASS (GTK_TYPE_CONTAINER)->get_property (adaptor, object, id, value); +} + +void +glade_gtk_shortcutswindow_action_activate (GladeWidgetAdaptor * adaptor, + GObject * object, + const gchar * action_path) +{ + if (strcmp (action_path, "add_section") == 0) + { + gint sections; + + sections = glade_gtk_shortcutswindow_get_n_sections (object); + glade_gtk_shortcutswindow_set_n_sections (object, sections + 1); + } + else + GWA_GET_CLASS (GTK_TYPE_CONTAINER)->action_activate (adaptor, + object, action_path); +} + +void +glade_gtk_shortcutswindow_add_child (GladeWidgetAdaptor * adaptor, + GObject * object, + GObject * child) +{ + gtk_container_add (GTK_CONTAINER (object), GTK_WIDGET (child)); +} + +void +glade_gtk_shortcutswindow_remove_child (GladeWidgetAdaptor * adaptor, + GObject * object, + GObject * child) +{ + gtk_container_remove (GTK_CONTAINER (object), GTK_WIDGET (child)); +} + +void +glade_gtk_shortcutswindow_replace_child (GladeWidgetAdaptor * adaptor, + GObject * container, + GObject * current, + GObject * new_widget) +{ + GWA_GET_CLASS (GTK_TYPE_CONTAINER)->replace_child (adaptor, container, current, new_widget); +} diff --git a/plugins/gtk+/glade-shortcutsgroup-editor.c b/plugins/gtk+/glade-shortcutsgroup-editor.c new file mode 100644 index 00000000..d171c2eb --- /dev/null +++ b/plugins/gtk+/glade-shortcutsgroup-editor.c @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2015 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Authors: + * Matthias Clasen + */ + +#include +#include +#include + +#include "glade-shortcutsgroup-editor.h" + +static void glade_shortcutsgroup_editor_grab_focus (GtkWidget * widget); + +struct _GladeShortcutsGroupEditorPrivate +{ + GtkWidget *embed; +}; + +G_DEFINE_TYPE_WITH_PRIVATE (GladeShortcutsGroupEditor, glade_shortcutsgroup_editor, GLADE_TYPE_EDITOR_SKELETON) + +static void +glade_shortcutsgroup_editor_class_init (GladeShortcutsGroupEditorClass * klass) +{ + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + + widget_class->grab_focus = glade_shortcutsgroup_editor_grab_focus; + + gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/gladegtk/glade-shortcutsgroup-editor.ui"); + gtk_widget_class_bind_template_child_private (widget_class, GladeShortcutsGroupEditor, embed); +} + +static void +glade_shortcutsgroup_editor_init (GladeShortcutsGroupEditor * self) +{ + self->priv = glade_shortcutsgroup_editor_get_instance_private (self); + + gtk_widget_init_template (GTK_WIDGET (self)); +} + +static void +glade_shortcutsgroup_editor_grab_focus (GtkWidget * widget) +{ + GladeShortcutsGroupEditor *editor = GLADE_SHORTCUTSGROUP_EDITOR (widget); + + gtk_widget_grab_focus (editor->priv->embed); +} + +GtkWidget * +glade_shortcutsgroup_editor_new (void) +{ + return g_object_new (GLADE_TYPE_SHORTCUTSGROUP_EDITOR, NULL); +} diff --git a/plugins/gtk+/glade-shortcutsgroup-editor.h b/plugins/gtk+/glade-shortcutsgroup-editor.h new file mode 100644 index 00000000..c38d1615 --- /dev/null +++ b/plugins/gtk+/glade-shortcutsgroup-editor.h @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2015 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Authors: + * Matthias Clasen + */ +#ifndef _GLADE_SHORTCUTSGROUP_EDITOR_H_ +#define _GLADE_SHORTCUTSGROUP_EDITOR_H_ + +#include + +G_BEGIN_DECLS + +#define GLADE_TYPE_SHORTCUTSGROUP_EDITOR (glade_shortcutsgroup_editor_get_type ()) +#define GLADE_SHORTCUTSGROUP_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GLADE_TYPE_SHORTCUTSGROUP_EDITOR, GladeShortcutsGroupEditor)) +#define GLADE_SHORTCUTSGROUP_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GLADE_TYPE_SHORTCUTSGROUP_EDITOR, GladeShortcutsGroupEditorClass)) +#define GLADE_IS_SHORTCUTSGROUP_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_SHORTCUTSGROUP_EDITOR)) +#define GLADE_IS_SHORTCUTSGROUP_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_SHORTCUTSGROUP_EDITOR)) +#define GLADE_SHORTCUTSGROUP_EDITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GLADE_TYPE_SHORTCUTSGROUP_EDITOR, GladeShortcutsGroupEditorClass)) + +typedef struct _GladeShortcutsGroupEditor GladeShortcutsGroupEditor; +typedef struct _GladeShortcutsGroupEditorClass GladeShortcutsGroupEditorClass; +typedef struct _GladeShortcutsGroupEditorPrivate GladeShortcutsGroupEditorPrivate; + +struct _GladeShortcutsGroupEditor +{ + GladeEditorSkeleton parent; + + GladeShortcutsGroupEditorPrivate *priv; +}; + +struct _GladeShortcutsGroupEditorClass +{ + GladeEditorSkeletonClass parent; +}; + +GType glade_shortcutsgroup_editor_get_type (void) G_GNUC_CONST; +GtkWidget *glade_shortcutsgroup_editor_new (void); + +G_END_DECLS + +#endif /* _GLADE_SHORTCUTSGROUP_EDITOR_H_ */ diff --git a/plugins/gtk+/glade-shortcutsgroup-editor.ui b/plugins/gtk+/glade-shortcutsgroup-editor.ui new file mode 100644 index 00000000..6e987803 --- /dev/null +++ b/plugins/gtk+/glade-shortcutsgroup-editor.ui @@ -0,0 +1,108 @@ + + + + + + + diff --git a/plugins/gtk+/glade-shortcutssection-editor.c b/plugins/gtk+/glade-shortcutssection-editor.c new file mode 100644 index 00000000..d83208f7 --- /dev/null +++ b/plugins/gtk+/glade-shortcutssection-editor.c @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2015 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Authors: + * Matthias Clasen + */ + +#include +#include +#include + +#include "glade-shortcutssection-editor.h" + +static void glade_shortcutssection_editor_grab_focus (GtkWidget * widget); + +struct _GladeShortcutsSectionEditorPrivate +{ + GtkWidget *embed; +}; + +G_DEFINE_TYPE_WITH_PRIVATE (GladeShortcutsSectionEditor, glade_shortcutssection_editor, GLADE_TYPE_EDITOR_SKELETON) + +static void +glade_shortcutssection_editor_class_init (GladeShortcutsSectionEditorClass * klass) +{ + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + + widget_class->grab_focus = glade_shortcutssection_editor_grab_focus; + + gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/gladegtk/glade-shortcutssection-editor.ui"); + gtk_widget_class_bind_template_child_private (widget_class, GladeShortcutsSectionEditor, embed); +} + +static void +glade_shortcutssection_editor_init (GladeShortcutsSectionEditor * self) +{ + self->priv = glade_shortcutssection_editor_get_instance_private (self); + + gtk_widget_init_template (GTK_WIDGET (self)); +} + +static void +glade_shortcutssection_editor_grab_focus (GtkWidget * widget) +{ + GladeShortcutsSectionEditor *editor = GLADE_SHORTCUTSSECTION_EDITOR (widget); + + gtk_widget_grab_focus (editor->priv->embed); +} + +GtkWidget * +glade_shortcutssection_editor_new (void) +{ + return g_object_new (GLADE_TYPE_SHORTCUTSSECTION_EDITOR, NULL); +} diff --git a/plugins/gtk+/glade-shortcutssection-editor.h b/plugins/gtk+/glade-shortcutssection-editor.h new file mode 100644 index 00000000..d1bf8966 --- /dev/null +++ b/plugins/gtk+/glade-shortcutssection-editor.h @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2015 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Authors: + * Matthias Clasen + */ +#ifndef _GLADE_SHORTCUTSSECTION_EDITOR_H_ +#define _GLADE_SHORTCUTSSECTION_EDITOR_H_ + +#include + +G_BEGIN_DECLS + +#define GLADE_TYPE_SHORTCUTSSECTION_EDITOR (glade_shortcutssection_editor_get_type ()) +#define GLADE_SHORTCUTSSECTION_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GLADE_TYPE_SHORTCUTSSECTION_EDITOR, GladeShortcutsSectionEditor)) +#define GLADE_SHORTCUTSSECTION_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GLADE_TYPE_SHORTCUTSSECTION_EDITOR, GladeShortcutsSectionEditorClass)) +#define GLADE_IS_SHORTCUTSSECTION_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_SHORTCUTSSECTION_EDITOR)) +#define GLADE_IS_SHORTCUTSSECTION_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_SHORTCUTSSECTION_EDITOR)) +#define GLADE_SHORTCUTSSECTION_EDITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GLADE_TYPE_SHORTCUTSSECTION_EDITOR, GladeShortcutsSectionEditorClass)) + +typedef struct _GladeShortcutsSectionEditor GladeShortcutsSectionEditor; +typedef struct _GladeShortcutsSectionEditorClass GladeShortcutsSectionEditorClass; +typedef struct _GladeShortcutsSectionEditorPrivate GladeShortcutsSectionEditorPrivate; + +struct _GladeShortcutsSectionEditor +{ + GladeEditorSkeleton parent; + + GladeShortcutsSectionEditorPrivate *priv; +}; + +struct _GladeShortcutsSectionEditorClass +{ + GladeEditorSkeletonClass parent; +}; + +GType glade_shortcutssection_editor_get_type (void) G_GNUC_CONST; +GtkWidget *glade_shortcutssection_editor_new (void); + +G_END_DECLS + +#endif /* _GLADE_SHORTCUTSSECTION_EDITOR_H_ */ diff --git a/plugins/gtk+/glade-shortcutssection-editor.ui b/plugins/gtk+/glade-shortcutssection-editor.ui new file mode 100644 index 00000000..5df3c5aa --- /dev/null +++ b/plugins/gtk+/glade-shortcutssection-editor.ui @@ -0,0 +1,108 @@ + + + + + + + diff --git a/plugins/gtk+/glade-shortcutswindow-editor.c b/plugins/gtk+/glade-shortcutswindow-editor.c new file mode 100644 index 00000000..8798ed6a --- /dev/null +++ b/plugins/gtk+/glade-shortcutswindow-editor.c @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2015 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Authors: + * Matthias Clasen + */ + +#include +#include +#include + +#include "glade-shortcutswindow-editor.h" + +static void glade_shortcutswindow_editor_grab_focus (GtkWidget * widget); + +struct _GladeShortcutsWindowEditorPrivate +{ + GtkWidget *embed; +}; + +G_DEFINE_TYPE_WITH_PRIVATE (GladeShortcutsWindowEditor, glade_shortcutswindow_editor, GLADE_TYPE_EDITOR_SKELETON) + +static void +glade_shortcutswindow_editor_class_init (GladeShortcutsWindowEditorClass * klass) +{ + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + + widget_class->grab_focus = glade_shortcutswindow_editor_grab_focus; + + gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/gladegtk/glade-shortcutswindow-editor.ui"); + gtk_widget_class_bind_template_child_private (widget_class, GladeShortcutsWindowEditor, embed); +} + +static void +glade_shortcutswindow_editor_init (GladeShortcutsWindowEditor * self) +{ + self->priv = glade_shortcutswindow_editor_get_instance_private (self); + + gtk_widget_init_template (GTK_WIDGET (self)); +} + +static void +glade_shortcutswindow_editor_grab_focus (GtkWidget * widget) +{ + GladeShortcutsWindowEditor *editor = GLADE_SHORTCUTSWINDOW_EDITOR (widget); + + gtk_widget_grab_focus (editor->priv->embed); +} + +GtkWidget * +glade_shortcutswindow_editor_new (void) +{ + return g_object_new (GLADE_TYPE_SHORTCUTSWINDOW_EDITOR, NULL); +} diff --git a/plugins/gtk+/glade-shortcutswindow-editor.h b/plugins/gtk+/glade-shortcutswindow-editor.h new file mode 100644 index 00000000..49b3da13 --- /dev/null +++ b/plugins/gtk+/glade-shortcutswindow-editor.h @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2015 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Authors: + * Matthias Clasen + */ +#ifndef _GLADE_SHORTCUTSWINDOW_EDITOR_H_ +#define _GLADE_SHORTCUTSWINDOW_EDITOR_H_ + +#include + +G_BEGIN_DECLS + +#define GLADE_TYPE_SHORTCUTSWINDOW_EDITOR (glade_shortcutswindow_editor_get_type ()) +#define GLADE_SHORTCUTSWINDOW_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GLADE_TYPE_SHORTCUTSWINDOW_EDITOR, GladeShortcutsWindowEditor)) +#define GLADE_SHORTCUTSWINDOW_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GLADE_TYPE_SHORTCUTSWINDOW_EDITOR, GladeShortcutsWindowEditorClass)) +#define GLADE_IS_SHORTCUTSWINDOW_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_SHORTCUTSWINDOW_EDITOR)) +#define GLADE_IS_SHORTCUTSWINDOW_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_SHORTCUTSWINDOW_EDITOR)) +#define GLADE_SHORTCUTSWINDOW_EDITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GLADE_TYPE_SHORTCUTSWINDOW_EDITOR, GladeShortcutsWindowEditorClass)) + +typedef struct _GladeShortcutsWindowEditor GladeShortcutsWindowEditor; +typedef struct _GladeShortcutsWindowEditorClass GladeShortcutsWindowEditorClass; +typedef struct _GladeShortcutsWindowEditorPrivate GladeShortcutsWindowEditorPrivate; + +struct _GladeShortcutsWindowEditor +{ + GladeEditorSkeleton parent; + + GladeShortcutsWindowEditorPrivate *priv; +}; + +struct _GladeShortcutsWindowEditorClass +{ + GladeEditorSkeletonClass parent; +}; + +GType glade_shortcutswindow_editor_get_type (void) G_GNUC_CONST; +GtkWidget *glade_shortcutswindow_editor_new (void); + +G_END_DECLS + +#endif /* _GLADE_SHORTCUTSWINDOW_EDITOR_H_ */ diff --git a/plugins/gtk+/glade-shortcutswindow-editor.ui b/plugins/gtk+/glade-shortcutswindow-editor.ui new file mode 100644 index 00000000..1e3fb6fe --- /dev/null +++ b/plugins/gtk+/glade-shortcutswindow-editor.ui @@ -0,0 +1,108 @@ + + + + + + + diff --git a/plugins/gtk+/glade-widget-editor.ui b/plugins/gtk+/glade-widget-editor.ui index e6397248..16b3fd7c 100644 --- a/plugins/gtk+/glade-widget-editor.ui +++ b/plugins/gtk+/glade-widget-editor.ui @@ -490,7 +490,7 @@ Author: Tristan Van Berkom False 12 False - accelerator + accelerators 0 @@ -506,7 +506,7 @@ Author: Tristan Van Berkom False False False - accelerator + accelerators 2 diff --git a/plugins/gtk+/gtk+.xml.in b/plugins/gtk+/gtk+.xml.in index be1bb6a9..2b9b0234 100644 --- a/plugins/gtk+/gtk+.xml.in +++ b/plugins/gtk+/gtk+.xml.in @@ -180,7 +180,7 @@ - + GParamBoxed GladeAccelGList @@ -1815,12 +1815,12 @@ - - - - - - + + + + + + @@ -2936,7 +2936,6 @@ glade_gtk_layout_create_editable - glade_gtk_create_fixed_widget glade_gtk_fixed_layout_post_create glade_gtk_fixed_layout_add_child glade_gtk_fixed_layout_remove_child @@ -5301,8 +5300,157 @@ + + glade_gtk_shortcutswindow_post_create + glade_gtk_shortcutswindow_action_activate + glade_gtk_shortcutswindow_add_verify + glade_gtk_shortcutswindow_add_child + glade_gtk_shortcutswindow_remove_child + glade_gtk_shortcutswindow_replace_child + glade_gtk_shortcutswindow_create_editable + glade_gtk_shortcutswindow_get_property + glade_gtk_shortcutswindow_set_property + glade_gtk_shortcutswindow_verify_property + + + + + + + + + + + + + GParamInt + 0 + + <_tooltip>Set the currently active section to edit, this property will not be saved + + + + + + glade_gtk_shortcutssection_action_activate + glade_gtk_shortcutssection_post_create + glade_gtk_shortcutssection_add_verify + glade_gtk_shortcutssection_add_child + glade_gtk_shortcutssection_remove_child + glade_gtk_shortcutssection_replace_child + glade_gtk_shortcutssection_create_editable + glade_gtk_shortcutssection_get_property + glade_gtk_shortcutssection_set_property + glade_gtk_shortcutssection_verify_property + + + + + + + + GParamInt + 0 + + <_tooltip>The number of groups in the section + + + + + + + + + + + + + glade_gtk_shortcutsgroup_action_activate + glade_gtk_shortcutsgroup_post_create + glade_gtk_shortcutsgroup_add_verify + glade_gtk_shortcutsgroup_add_child + glade_gtk_shortcutsgroup_remove_child + glade_gtk_shortcutsgroup_replace_child + glade_gtk_shortcutsgroup_create_editable + glade_gtk_shortcutsgroup_get_property + glade_gtk_shortcutsgroup_set_property + + + + + + + GParamInt + 0 + + <_tooltip>The number of shortcuts in the group + + + + + + + + + + + + + + + + glade_gtk_widget_create_editable + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + glade_gtk_widget_create_editable + + + + + + + + + + + + + + - + @@ -5325,6 +5473,7 @@ + @@ -5446,6 +5595,17 @@ + + + + + + + + + + + diff --git a/plugins/gtk+/icons/16x16/Makefile.am b/plugins/gtk+/icons/16x16/Makefile.am index ab60cf3d..4fa58cac 100644 --- a/plugins/gtk+/icons/16x16/Makefile.am +++ b/plugins/gtk+/icons/16x16/Makefile.am @@ -99,6 +99,9 @@ icons_DATA = \ widget-gtk-separatormenuitem.png \ widget-gtk-separatortoolitem.png \ widget-gtk-stacksidebar.png \ + widget-gtk-shortcutsgesture.png \ + widget-gtk-shortcutsshortcut.png \ + widget-gtk-shortcutswindow.png \ widget-gtk-sizegroup.png \ widget-gtk-spinbutton.png \ widget-gtk-spinner.png \ diff --git a/plugins/gtk+/icons/16x16/widget-gtk-shortcutsgesture.png b/plugins/gtk+/icons/16x16/widget-gtk-shortcutsgesture.png new file mode 100644 index 00000000..9094a7a6 Binary files /dev/null and b/plugins/gtk+/icons/16x16/widget-gtk-shortcutsgesture.png differ diff --git a/plugins/gtk+/icons/16x16/widget-gtk-shortcutsshortcut.png b/plugins/gtk+/icons/16x16/widget-gtk-shortcutsshortcut.png new file mode 100644 index 00000000..777d261c Binary files /dev/null and b/plugins/gtk+/icons/16x16/widget-gtk-shortcutsshortcut.png differ diff --git a/plugins/gtk+/icons/16x16/widget-gtk-shortcutswindow.png b/plugins/gtk+/icons/16x16/widget-gtk-shortcutswindow.png new file mode 100644 index 00000000..8eb38169 Binary files /dev/null and b/plugins/gtk+/icons/16x16/widget-gtk-shortcutswindow.png differ diff --git a/plugins/gtk+/icons/22x22/Makefile.am b/plugins/gtk+/icons/22x22/Makefile.am index cf543d26..fea869ef 100644 --- a/plugins/gtk+/icons/22x22/Makefile.am +++ b/plugins/gtk+/icons/22x22/Makefile.am @@ -98,6 +98,9 @@ icons_DATA = \ widget-gtk-separator.png \ widget-gtk-separatormenuitem.png \ widget-gtk-separatortoolitem.png \ + widget-gtk-shortcutsshortcut.png \ + widget-gtk-shortcutsgesture.png \ + widget-gtk-shortcutswindow.png \ widget-gtk-stacksidebar.png \ widget-gtk-sizegroup.png \ widget-gtk-spinbutton.png \ diff --git a/plugins/gtk+/icons/22x22/widget-gtk-shortcutsgesture.png b/plugins/gtk+/icons/22x22/widget-gtk-shortcutsgesture.png new file mode 100644 index 00000000..953e5bc5 Binary files /dev/null and b/plugins/gtk+/icons/22x22/widget-gtk-shortcutsgesture.png differ diff --git a/plugins/gtk+/icons/22x22/widget-gtk-shortcutsshortcut.png b/plugins/gtk+/icons/22x22/widget-gtk-shortcutsshortcut.png new file mode 100644 index 00000000..1f00539d Binary files /dev/null and b/plugins/gtk+/icons/22x22/widget-gtk-shortcutsshortcut.png differ diff --git a/plugins/gtk+/icons/22x22/widget-gtk-shortcutswindow.png b/plugins/gtk+/icons/22x22/widget-gtk-shortcutswindow.png new file mode 100644 index 00000000..527acfad Binary files /dev/null and b/plugins/gtk+/icons/22x22/widget-gtk-shortcutswindow.png differ -- cgit v1.2.1