예제 #1
0
int
clip_GTK_ACCELMAPUNLOCKPATH(ClipMachine * ClipMachineMemory)
{
   gchar    *accel_path = _clip_parc(ClipMachineMemory, 1);

   CHECKARG(1, CHARACTER_type_of_ClipVarType);

   gtk_accel_map_unlock_path(accel_path);

   return 0;
 err:
   return 1;
}
예제 #2
0
static void
keys_change_notify (GSettings *settings,
                    const gchar *key,
                    gpointer user_data)
{
	GVariant *val;
	KeyEntry *key_entry;
	GdkModifierType mask;
	guint keyval;

	_terminal_debug_print (TERMINAL_DEBUG_ACCELS,
	                       "key %s changed\n",
	                       key);

	val = g_settings_get_value (settings, key);

#ifdef MATE_ENABLE_DEBUG
	_TERMINAL_DEBUG_IF (TERMINAL_DEBUG_ACCELS)
	{
		if (val == NULL)
			_terminal_debug_print (TERMINAL_DEBUG_ACCELS, " changed to be unset\n");
		else if (!g_variant_is_of_type (val, G_VARIANT_TYPE_STRING))
			_terminal_debug_print (TERMINAL_DEBUG_ACCELS, " changed to non-string value\n");
		else
			_terminal_debug_print (TERMINAL_DEBUG_ACCELS,
			                       " changed to \"%s\"\n",
			                       g_variant_get_string (val, NULL));
	}
#endif

	key_entry = g_hash_table_lookup (gsettings_key_to_entry, key);
	if (!key_entry)
	{
		/* shouldn't really happen, but let's be safe */
		_terminal_debug_print (TERMINAL_DEBUG_ACCELS,
		                       "  WARNING: KeyEntry for changed key not found, bailing out\n");
		return;
	}

	if (!binding_from_value (val, &keyval, &mask))
	{
		const char *str = g_variant_is_of_type (val, G_VARIANT_TYPE_STRING) ? g_variant_get_string (val, NULL) : NULL;
		g_printerr ("The value \"%s\" of configuration key %s is not a valid accelerator\n",
		            str ? str : "(null)",
		            key_entry->gsettings_key);
		return;
	}
	key_entry->gsettings_keyval = keyval;
	key_entry->gsettings_mask = mask;

	/* Unlock the path, so we can change its accel */
	if (!key_entry->accel_path_unlocked)
		gtk_accel_map_unlock_path (key_entry->accel_path);

	/* sync over to GTK */
	_terminal_debug_print (TERMINAL_DEBUG_ACCELS,
	                       "changing path %s to %s\n",
	                       key_entry->accel_path,
	                       binding_name (keyval, mask)); /* memleak */
	inside_gsettings_notify += 1;
	/* Note that this may return FALSE, e.g. when the entry was already set correctly. */
	gtk_accel_map_change_entry (key_entry->accel_path,
	                            keyval, mask,
	                            TRUE);
	inside_gsettings_notify -= 1;

	/* Lock the path if the GSettings key isn't writable */
	key_entry->accel_path_unlocked = g_settings_is_writable (settings, key);
	if (!key_entry->accel_path_unlocked)
		gtk_accel_map_lock_path (key_entry->accel_path);

	/* This seems necessary to update the tree model, since sometimes the
	 * notification on the notification_group seems not to be emitted correctly.
	 * Without this change, when trying to set an accel to e.g. Alt-T (while the main
	 * menu in the terminal windows is _Terminal with Alt-T mnemonic) only displays
	 * the accel change after a re-expose of the row.
	 * FIXME: Find out *why* the accel-changed signal is wrong here!
	 */
	if (edit_keys_store)
		gtk_tree_model_foreach (GTK_TREE_MODEL (edit_keys_store), update_model_foreach, key_entry);

	g_variant_unref(val);
}