gnc-gtk-utils.c (gnucash-5.0.tar.bz2) | : | gnc-gtk-utils.c (gnucash-5.1.tar.bz2) | ||
---|---|---|---|---|
skipping to change at line 364 | skipping to change at line 364 | |||
g_strfreev (actions); | g_strfreev (actions); | |||
} | } | |||
static void | static void | |||
accel_map_foreach_func (gpointer user_data, const gchar* accel_path, guint accel _key, | accel_map_foreach_func (gpointer user_data, const gchar* accel_path, guint accel _key, | |||
GdkModifierType accel_mods, gboolean changed) | GdkModifierType accel_mods, gboolean changed) | |||
{ | { | |||
GMenuModel *menu_model = user_data; | GMenuModel *menu_model = user_data; | |||
gchar **accel_path_parts = NULL; | gchar **accel_path_parts = NULL; | |||
guint accel_size = 0; | guint accel_size = 0; | |||
gchar *target = NULL; | ||||
gchar *accel_name_tmp = gtk_accelerator_name (accel_key, accel_mods); | gchar *accel_name_tmp = gtk_accelerator_name (accel_key, accel_mods); | |||
gchar *accel_name = g_strescape (accel_name_tmp, NULL); | gchar *accel_name = g_strescape (accel_name_tmp, NULL); | |||
accel_path_parts = g_strsplit (accel_path, "/", -1); | accel_path_parts = g_strsplit (accel_path, "/", -1); | |||
accel_size = g_strv_length (accel_path_parts); | accel_size = g_strv_length (accel_path_parts); | |||
if (accel_size == 3) | if (accel_size == 4) | |||
target = g_strdup (accel_path_parts[3]); | ||||
if (accel_size >=3) | ||||
gnc_menubar_model_update_item (menu_model, accel_path_parts[2], | gnc_menubar_model_update_item (menu_model, accel_path_parts[2], | |||
NULL, accel_name, NULL); | target, NULL, accel_name, NULL); | |||
g_strfreev (accel_path_parts); | g_strfreev (accel_path_parts); | |||
g_free (target); | ||||
g_free (accel_name_tmp); | g_free (accel_name_tmp); | |||
g_free (accel_name); | g_free (accel_name); | |||
} | } | |||
static void | static void | |||
add_accel_for_menu_lookup (GtkWidget *widget, gpointer user_data) | add_accel_for_menu_lookup (GtkWidget *widget, gpointer user_data) | |||
{ | { | |||
if (GTK_IS_MENU_ITEM(widget)) | if (GTK_IS_MENU_ITEM(widget)) | |||
{ | { | |||
GtkMenuItem* menuItem = GTK_MENU_ITEM(widget); | GtkMenuItem* menuItem = GTK_MENU_ITEM(widget); | |||
skipping to change at line 625 | skipping to change at line 630 | |||
gint item, | gint item, | |||
gpointer user_data) | gpointer user_data) | |||
{ | { | |||
GMenuAttributeIter *iter; | GMenuAttributeIter *iter; | |||
const gchar *key; | const gchar *key; | |||
GVariant *value; | GVariant *value; | |||
GncMenuModelSearch *gsm = user_data; | GncMenuModelSearch *gsm = user_data; | |||
const gchar *action = NULL; | const gchar *action = NULL; | |||
const gchar *label = NULL; | const gchar *label = NULL; | |||
const gchar *tooltip = NULL; | const gchar *tooltip = NULL; | |||
const gchar *target_char = NULL; | ||||
gint target_int = -1; | ||||
iter = g_menu_model_iterate_item_attributes (model, item); | iter = g_menu_model_iterate_item_attributes (model, item); | |||
while (g_menu_attribute_iter_get_next (iter, &key, &value)) | while (g_menu_attribute_iter_get_next (iter, &key, &value)) | |||
{ | { | |||
if (g_str_equal (key, GNC_MENU_ATTRIBUTE_TOOLTIP) && | if (g_str_equal (key, GNC_MENU_ATTRIBUTE_TOOLTIP) && | |||
g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) | g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) | |||
tooltip = g_variant_get_string (value, NULL); | tooltip = g_variant_get_string (value, NULL); | |||
else if (g_str_equal (key, G_MENU_ATTRIBUTE_LABEL) && | else if (g_str_equal (key, G_MENU_ATTRIBUTE_LABEL) && | |||
g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) | g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) | |||
label = g_variant_get_string (value, NULL); | label = g_variant_get_string (value, NULL); | |||
else if (g_str_equal (key, G_MENU_ATTRIBUTE_ACTION) && | else if (g_str_equal (key, G_MENU_ATTRIBUTE_ACTION) && | |||
g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) | g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) | |||
action = g_variant_get_string (value, NULL); | action = g_variant_get_string (value, NULL); | |||
else if (g_str_equal (key, G_MENU_ATTRIBUTE_TARGET) && | ||||
g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) | ||||
target_char = g_variant_get_string (value, NULL); | ||||
else if (g_str_equal (key, G_MENU_ATTRIBUTE_TARGET) && | ||||
g_variant_is_of_type (value, G_VARIANT_TYPE_INT32)) | ||||
target_int = g_variant_get_int32 (value); | ||||
g_variant_unref (value); | g_variant_unref (value); | |||
} | } | |||
if (gsm->search_action_target) | ||||
{ | ||||
gboolean target_test = FALSE; | ||||
if (target_int != -1 && target_int == atoi (gsm->search_action_target)) | ||||
target_test = TRUE; | ||||
if (target_char && g_strcmp0 (target_char, gsm->search_action_target) == | ||||
0) | ||||
target_test = TRUE; | ||||
if (!target_test) | ||||
{ | ||||
g_object_unref (iter); | ||||
return; | ||||
} | ||||
} | ||||
if (action && gsm->search_action_name) | if (action && gsm->search_action_name) | |||
{ | { | |||
if (g_str_has_suffix (action, gsm->search_action_name)) | if (g_str_has_suffix (action, gsm->search_action_name)) | |||
{ | { | |||
gsm->model = model; | gsm->model = model; | |||
gsm->index = item; | gsm->index = item; | |||
gsm->tooltip = tooltip; | gsm->tooltip = tooltip; | |||
gsm->search_action_label = label; | gsm->search_action_label = label; | |||
} | } | |||
} | } | |||
skipping to change at line 750 | skipping to change at line 779 | |||
GtkWidget *menu_item = NULL; | GtkWidget *menu_item = NULL; | |||
g_return_val_if_fail (menu_model != NULL, NULL); | g_return_val_if_fail (menu_model != NULL, NULL); | |||
g_return_val_if_fail (menu != NULL, NULL); | g_return_val_if_fail (menu != NULL, NULL); | |||
g_return_val_if_fail (action_name != NULL, NULL); | g_return_val_if_fail (action_name != NULL, NULL); | |||
gsm = g_new0 (GncMenuModelSearch, 1); | gsm = g_new0 (GncMenuModelSearch, 1); | |||
gsm->search_action_label = NULL; | gsm->search_action_label = NULL; | |||
gsm->search_action_name = action_name; | gsm->search_action_name = action_name; | |||
gsm->search_action_target = NULL; | ||||
if (gnc_menubar_model_find_item (menu_model, gsm)) | if (gnc_menubar_model_find_item (menu_model, gsm)) | |||
menu_item = gnc_find_menu_item_by_action_label (menu, gsm->search_action _label); | menu_item = gnc_find_menu_item_by_action_label (menu, gsm->search_action _label); | |||
g_free (gsm); | g_free (gsm); | |||
return menu_item; | return menu_item; | |||
} | } | |||
/** Update the GMenuModel item based on the action name by copying | /** Update the GMenuModel item based on the action name by copying | |||
* existing item, removing it and inserting a new one in same location. | * existing item, removing it and inserting a new one in same location. | |||
* | * | |||
* @param menu_model The GMenuModel of the menu. | * @param menu_model The GMenuModel of the menu. | |||
* | * | |||
* @param action_name The action name to update. | * @param action_name The action name to update. | |||
* | * | |||
* @param target The action target if required, else NULL. | ||||
* | ||||
* @param label The new menu label text. | * @param label The new menu label text. | |||
* | * | |||
* @param accel_name The accelerator string | * @param accel_name The accelerator string | |||
* | * | |||
* @param tooltip The new tooltip text if any. | * @param tooltip The new tooltip text if any. | |||
* | * | |||
* @return TRUE if item found and updated or FALSE if not. | * @return TRUE if item found and updated or FALSE if not. | |||
*/ | */ | |||
gboolean | gboolean | |||
gnc_menubar_model_update_item (GMenuModel *menu_model, const gchar *action_name, | gnc_menubar_model_update_item (GMenuModel *menu_model, const gchar *action_name, | |||
const gchar *label, const gchar *accel_name, | const gchar *target, const gchar *label, | |||
const gchar *tooltip) | const gchar *accel_name, const gchar *tooltip) | |||
{ | { | |||
GncMenuModelSearch *gsm; | GncMenuModelSearch *gsm; | |||
gboolean found = FALSE; | gboolean found = FALSE; | |||
g_return_val_if_fail (menu_model != NULL, FALSE); | g_return_val_if_fail (menu_model != NULL, FALSE); | |||
g_return_val_if_fail (action_name != NULL, FALSE); | g_return_val_if_fail (action_name != NULL, FALSE); | |||
gsm = g_new0 (GncMenuModelSearch, 1); | gsm = g_new0 (GncMenuModelSearch, 1); | |||
gsm->search_action_label = NULL; | gsm->search_action_label = NULL; | |||
gsm->search_action_name = action_name; | gsm->search_action_name = action_name; | |||
gsm->search_action_target = target; | ||||
if (gnc_menubar_model_find_item (menu_model, gsm)) | if (gnc_menubar_model_find_item (menu_model, gsm)) | |||
{ | { | |||
GMenuAttributeIter *iter; | GMenuAttributeIter *iter; | |||
const gchar *key; | const gchar *key; | |||
GVariant *value; | GVariant *value; | |||
GVariant *old_target = NULL; | GVariant *old_target = NULL; | |||
const gchar *old_action = NULL; | const gchar *old_action = NULL; | |||
const gchar *old_temp = NULL; | const gchar *old_temp = NULL; | |||
const gchar *old_accel = NULL; | const gchar *old_accel = NULL; | |||
End of changes. 11 change blocks. | ||||
5 lines changed or deleted | 39 lines changed or added |