forked from AuroraMiddleware/gtk
Merge branch 'matthiasc/for-master' into 'master'
Matthiasc/for master See merge request GNOME/gtk!1589
This commit is contained in:
commit
f3e826f4d6
@ -531,6 +531,8 @@ gtk_builder_get_parameters (GtkBuilder *builder,
|
||||
(G_PARAM_SPEC_VALUE_TYPE (prop->pspec) != GDK_TYPE_PIXBUF) &&
|
||||
(G_PARAM_SPEC_VALUE_TYPE (prop->pspec) != GDK_TYPE_TEXTURE) &&
|
||||
(G_PARAM_SPEC_VALUE_TYPE (prop->pspec) != GDK_TYPE_PAINTABLE) &&
|
||||
(G_PARAM_SPEC_VALUE_TYPE (prop->pspec) != GTK_TYPE_SHORTCUT_TRIGGER) &&
|
||||
(G_PARAM_SPEC_VALUE_TYPE (prop->pspec) != GTK_TYPE_SHORTCUT_ACTION) &&
|
||||
(G_PARAM_SPEC_VALUE_TYPE (prop->pspec) != G_TYPE_FILE))
|
||||
{
|
||||
GObject *object = g_hash_table_lookup (priv->objects,
|
||||
@ -2097,29 +2099,6 @@ gtk_builder_value_from_string_type (GtkBuilder *builder,
|
||||
ret = FALSE;
|
||||
}
|
||||
}
|
||||
else if (G_VALUE_HOLDS (value, GTK_TYPE_SHORTCUT_TRIGGER))
|
||||
{
|
||||
GtkShortcutTrigger *trigger = gtk_shortcut_trigger_parse_string (string);
|
||||
|
||||
if (trigger)
|
||||
g_value_take_object (value, trigger);
|
||||
else
|
||||
{
|
||||
g_set_error (error,
|
||||
GTK_BUILDER_ERROR,
|
||||
GTK_BUILDER_ERROR_INVALID_VALUE,
|
||||
"Could not parse shortcut trigger '%s'",
|
||||
string);
|
||||
ret = FALSE;
|
||||
}
|
||||
}
|
||||
else if (G_VALUE_HOLDS (value, GTK_TYPE_SHORTCUT_ACTION))
|
||||
{
|
||||
GtkShortcutAction *action = gtk_shortcut_action_parse_builder (builder, string, error);
|
||||
|
||||
/* Works for success and failure (NULL) case */
|
||||
g_value_take_object (value, action);
|
||||
}
|
||||
else if (G_VALUE_HOLDS (value, G_TYPE_STRV))
|
||||
{
|
||||
gchar **vector = g_strsplit (string, "\n", 0);
|
||||
@ -2237,6 +2216,29 @@ gtk_builder_value_from_string_type (GtkBuilder *builder,
|
||||
|
||||
ret = TRUE;
|
||||
}
|
||||
else if (G_VALUE_HOLDS (value, GTK_TYPE_SHORTCUT_TRIGGER))
|
||||
{
|
||||
GtkShortcutTrigger *trigger = gtk_shortcut_trigger_parse_string (string);
|
||||
|
||||
if (trigger)
|
||||
g_value_take_object (value, trigger);
|
||||
else
|
||||
{
|
||||
g_set_error (error,
|
||||
GTK_BUILDER_ERROR,
|
||||
GTK_BUILDER_ERROR_INVALID_VALUE,
|
||||
"Could not parse shortcut trigger '%s'",
|
||||
string);
|
||||
ret = FALSE;
|
||||
}
|
||||
}
|
||||
else if (G_VALUE_HOLDS (value, GTK_TYPE_SHORTCUT_ACTION))
|
||||
{
|
||||
GtkShortcutAction *action = gtk_shortcut_action_parse_builder (builder, string, error);
|
||||
|
||||
/* Works for success and failure (NULL) case */
|
||||
g_value_take_object (value, action);
|
||||
}
|
||||
else
|
||||
{
|
||||
GObject *object = g_hash_table_lookup (priv->objects, string);
|
||||
|
@ -36,6 +36,28 @@
|
||||
*
|
||||
* #GtkShortcutController implements #GListModel for querying the shortcuts that
|
||||
* have been added to it.
|
||||
*
|
||||
* # GtkShortcutController as a GtkBuildable
|
||||
*
|
||||
* GtkShortcutControllers can be creates in ui files to set up shortcuts
|
||||
* in the same place as the widgets.
|
||||
*
|
||||
* An example of a UI definition fragment with GtkShortcutController:
|
||||
* |[
|
||||
* <object class='GtkButton'>
|
||||
* <child>
|
||||
* <object class='GtkShortcutController'>
|
||||
* <property name='scope'>managed</property>
|
||||
* <child>
|
||||
* <object class='GtkShortcut'>
|
||||
* <property name='trigger'><Control>k</property>
|
||||
* <property name='action'>activate</property>
|
||||
* </object>
|
||||
* </child>
|
||||
* </object>
|
||||
* </child>
|
||||
* </object>
|
||||
* ]|
|
||||
**/
|
||||
|
||||
#include "config.h"
|
||||
@ -127,7 +149,7 @@ gtk_shortcut_controller_buildable_add_child (GtkBuildable *buildable,
|
||||
}
|
||||
if (GTK_IS_SHORTCUT (child))
|
||||
{
|
||||
gtk_shortcut_controller_add_shortcut (GTK_SHORTCUT_CONTROLLER (buildable), GTK_SHORTCUT (child));
|
||||
gtk_shortcut_controller_add_shortcut (GTK_SHORTCUT_CONTROLLER (buildable), g_object_ref (GTK_SHORTCUT (child)));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2418,6 +2418,35 @@ test_file_filter (void)
|
||||
g_object_unref (builder);
|
||||
}
|
||||
|
||||
static void
|
||||
test_shortcuts (void)
|
||||
{
|
||||
GtkBuilder *builder;
|
||||
GObject *obj;
|
||||
|
||||
const char buffer[] =
|
||||
"<interface>"
|
||||
" <object class='GtkBox' id='box'>"
|
||||
" <child>"
|
||||
" <object class='GtkShortcutController' id='controller'>"
|
||||
" <property name='scope'>managed</property>"
|
||||
" <child>"
|
||||
" <object class='GtkShortcut'>"
|
||||
" <property name='trigger'><Control>k</property>"
|
||||
" <property name='action'>activate</property>"
|
||||
" </object>"
|
||||
" </child>"
|
||||
" </object>"
|
||||
" </child>"
|
||||
" </object>"
|
||||
"</interface>";
|
||||
|
||||
builder = builder_new_from_string (buffer, -1, NULL);
|
||||
obj = gtk_builder_get_object (builder, "controller");
|
||||
g_assert (GTK_IS_SHORTCUT_CONTROLLER (obj));
|
||||
g_object_unref (builder);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
@ -2462,6 +2491,7 @@ main (int argc, char **argv)
|
||||
g_test_add_func ("/Builder/Property Bindings", test_property_bindings);
|
||||
g_test_add_func ("/Builder/anaconda-signal", test_anaconda_signal);
|
||||
g_test_add_func ("/Builder/FileFilter", test_file_filter);
|
||||
g_test_add_func ("/Builder/Shortcuts", test_shortcuts);
|
||||
|
||||
return g_test_run();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user