aboutsummaryrefslogtreecommitdiff
path: root/libdbusmenu-gtk
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-06-09 20:39:21 -0500
committerTed Gould <ted@gould.cx>2010-06-09 20:39:21 -0500
commit2c464b6b4c16d4dc32090706ecfc7c198d68c84e (patch)
tree71e130f485504384a216138a9c1597f53f9ff735 /libdbusmenu-gtk
parent9c4988079766e6c5398852b8b7f78188b6aee369 (diff)
downloadlibdbusmenu-2c464b6b4c16d4dc32090706ecfc7c198d68c84e.tar.gz
libdbusmenu-2c464b6b4c16d4dc32090706ecfc7c198d68c84e.tar.bz2
libdbusmenu-2c464b6b4c16d4dc32090706ecfc7c198d68c84e.zip
Switching things around to expose the key and modifier more as it's more useful.
Diffstat (limited to 'libdbusmenu-gtk')
-rw-r--r--libdbusmenu-gtk/menuitem.c30
-rw-r--r--libdbusmenu-gtk/menuitem.h6
2 files changed, 22 insertions, 14 deletions
diff --git a/libdbusmenu-gtk/menuitem.c b/libdbusmenu-gtk/menuitem.c
index 1ae4817..0f09483 100644
--- a/libdbusmenu-gtk/menuitem.c
+++ b/libdbusmenu-gtk/menuitem.c
@@ -142,7 +142,7 @@ dbusmenu_menuitem_property_get_image (DbusmenuMenuitem * menuitem, const gchar *
Return value: Whether it was successful at setting the property.
*/
gboolean
-dbusmenu_menuitem_property_set_shortcut (DbusmenuMenuitem * menuitem, const gchar * shortcut)
+dbusmenu_menuitem_property_set_shortcut_string (DbusmenuMenuitem * menuitem, const gchar * shortcut)
{
g_return_val_if_fail(DBUSMENU_IS_MENUITEM(menuitem), FALSE);
g_return_val_if_fail(shortcut != NULL, FALSE);
@@ -157,6 +157,14 @@ dbusmenu_menuitem_property_set_shortcut (DbusmenuMenuitem * menuitem, const gcha
return FALSE;
}
+ return dbusmenu_menuitem_property_set_shortcut(menuitem, key, modifier);
+}
+
+gboolean
+dbusmenu_menuitem_property_set_shortcut (DbusmenuMenuitem * menuitem, guint key, GdkModifierType modifier)
+{
+ g_return_val_if_fail(DBUSMENU_IS_MENUITEM(menuitem), FALSE);
+
GPtrArray * array = g_ptr_array_new();
if (modifier & GDK_CONTROL_MASK) {
@@ -172,8 +180,7 @@ dbusmenu_menuitem_property_set_shortcut (DbusmenuMenuitem * menuitem, const gcha
g_ptr_array_add(array, g_strdup(DBUSMENU_MENUITEM_SHORTCUT_SUPER));
}
- gint len = g_utf8_strlen(shortcut, -1);
- g_ptr_array_add(array, g_strdup(shortcut + len - 1));
+ g_ptr_array_add(array, g_strdup(gdk_keyval_name(key)));
GPtrArray * wrapper = g_ptr_array_new();
g_ptr_array_add(wrapper, array);
@@ -190,17 +197,16 @@ dbusmenu_menuitem_property_set_shortcut (DbusmenuMenuitem * menuitem, const gcha
/**
dbusmenu_menuitem_property_get_shortcut:
@menuitem: The #DbusmenuMenuitem to get the shortcut off
+ @key: Location to put the key value
+ @modifier: Location to put the modifier mask
- This function gets a GTK shortcut string as defined in
- #gtk_accelerator_parse from the data that is transferred
- over DBusmenu.
-
- Return value: Either the string or #NULL if there is none.
+ This function gets a GTK shortcut as a key and a mask
+ for use to set the accelerators.
*/
-gchar *
-dbusmenu_menuitem_property_get_shortcut (DbusmenuMenuitem * menuitem)
+void
+dbusmenu_menuitem_property_get_shortcut (DbusmenuMenuitem * menuitem, guint * key, GdkModifierType * modifier)
{
- g_return_val_if_fail(DBUSMENU_IS_MENUITEM(menuitem), FALSE);
+ g_return_if_fail(DBUSMENU_IS_MENUITEM(menuitem));
- return NULL;
+ return;
}
diff --git a/libdbusmenu-gtk/menuitem.h b/libdbusmenu-gtk/menuitem.h
index aacab42..ba01549 100644
--- a/libdbusmenu-gtk/menuitem.h
+++ b/libdbusmenu-gtk/menuitem.h
@@ -32,11 +32,13 @@ License version 3 and version 2.1 along with this program. If not, see
#include <glib.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <libdbusmenu-glib/menuitem.h>
+#include <gdk/gdk.h>
gboolean dbusmenu_menuitem_property_set_image (DbusmenuMenuitem * menuitem, const gchar * property, const GdkPixbuf * data);
GdkPixbuf * dbusmenu_menuitem_property_get_image (DbusmenuMenuitem * menuitem, const gchar * property);
-gboolean dbusmenu_menuitem_property_set_shortcut (DbusmenuMenuitem * menuitem, const gchar * shortcut);
-gchar * dbusmenu_menuitem_property_get_shortcut (DbusmenuMenuitem * menuitem);
+gboolean dbusmenu_menuitem_property_set_shortcut (DbusmenuMenuitem * menuitem, guint key, GdkModifierType modifier);
+gboolean dbusmenu_menuitem_property_set_shortcut_string (DbusmenuMenuitem * menuitem, const gchar * shortcut);
+void dbusmenu_menuitem_property_get_shortcut (DbusmenuMenuitem * menuitem, guint * key, GdkModifierType * modifiers);
#endif