app: GimpActionEditor now keeps a Gimp object instead of GimpUIManager.
This commit is contained in:
parent
68d862b3c2
commit
3f85fee2e7
8 changed files with 56 additions and 66 deletions
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
#include "widgets/gimpactioneditor.h"
|
||||
#include "widgets/gimphelp-ids.h"
|
||||
#include "widgets/gimpuimanager.h"
|
||||
|
||||
#include "menus/menus.h"
|
||||
|
||||
|
|
@ -81,8 +80,7 @@ keyboard_shortcuts_dialog_new (Gimp *gimp)
|
|||
vbox, TRUE, TRUE, 0);
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
editor = gimp_action_editor_new (gimp_ui_managers_from_name ("<Image>")->data,
|
||||
NULL, TRUE);
|
||||
editor = gimp_action_editor_new (gimp, NULL, TRUE);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), editor, TRUE, TRUE, 0);
|
||||
gtk_widget_show (editor);
|
||||
|
||||
|
|
|
|||
|
|
@ -3052,7 +3052,8 @@ prefs_dialog_new (Gimp *gimp,
|
|||
&top_iter,
|
||||
&child_iter);
|
||||
|
||||
vbox2 = gimp_modifiers_editor_new (GIMP_MODIFIERS_MANAGER (display_config->modifiers_manager));
|
||||
vbox2 = gimp_modifiers_editor_new (GIMP_MODIFIERS_MANAGER (display_config->modifiers_manager),
|
||||
gimp);
|
||||
gtk_widget_show (vbox2);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), vbox2, FALSE, FALSE, 0);
|
||||
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ static void gimp_display_shell_untransform_event_coords (GimpDisplayShell
|
|||
GimpCoords *image_coords,
|
||||
gboolean *update_software_cursor);
|
||||
|
||||
static void gimp_display_shell_activate_action (GimpUIManager *manager,
|
||||
static void gimp_display_shell_activate_action (Gimp *gimp,
|
||||
const gchar *action_desc,
|
||||
GVariant *value);
|
||||
|
||||
|
|
@ -725,12 +725,6 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
|
|||
}
|
||||
else
|
||||
{
|
||||
GimpImageWindow *window;
|
||||
GimpUIManager *manager;
|
||||
|
||||
window = gimp_display_shell_get_window (shell);
|
||||
manager = gimp_image_window_get_ui_manager (window);
|
||||
|
||||
switch (shell->mod_action)
|
||||
{
|
||||
case GIMP_MODIFIER_ACTION_MENU:
|
||||
|
|
@ -752,7 +746,7 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
|
|||
gimp_display_shell_stop_scrolling (shell, event);
|
||||
break;
|
||||
case GIMP_MODIFIER_ACTION_ACTION:
|
||||
gimp_display_shell_activate_action (manager, shell->mod_action_desc, NULL);
|
||||
gimp_display_shell_activate_action (gimp, shell->mod_action_desc, NULL);
|
||||
g_clear_pointer (&shell->mod_action_desc, g_free);
|
||||
break;
|
||||
case GIMP_MODIFIER_ACTION_NONE:
|
||||
|
|
@ -1890,10 +1884,7 @@ gimp_display_shell_handle_scrolling (GimpDisplayShell *shell,
|
|||
action = gimp_tool_control_get_action_pixel_size (active_tool->control);
|
||||
if (action)
|
||||
{
|
||||
GimpImageWindow *window = gimp_display_shell_get_window (shell);
|
||||
GimpUIManager *manager = gimp_image_window_get_ui_manager (window);
|
||||
|
||||
gimp_display_shell_activate_action (manager, action,
|
||||
gimp_display_shell_activate_action (gimp, action,
|
||||
g_variant_new_double ((gdouble) size * size_multiplier));
|
||||
|
||||
if (size_update_pos)
|
||||
|
|
@ -1915,14 +1906,11 @@ gimp_display_shell_handle_scrolling (GimpDisplayShell *shell,
|
|||
|
||||
if (action)
|
||||
{
|
||||
GimpImageWindow *window = gimp_display_shell_get_window (shell);
|
||||
GimpUIManager *manager = gimp_image_window_get_ui_manager (window);
|
||||
|
||||
/* Special trick with these enum actions. If using any
|
||||
* positive value, we get the GIMP_ACTION_SELECT_SET behavior
|
||||
* which sets to the given value.
|
||||
*/
|
||||
gimp_display_shell_activate_action (manager, action,
|
||||
gimp_display_shell_activate_action (gimp, action,
|
||||
g_variant_new_int32 (size));
|
||||
}
|
||||
}
|
||||
|
|
@ -1946,14 +1934,11 @@ gimp_display_shell_handle_scrolling (GimpDisplayShell *shell,
|
|||
|
||||
if (action)
|
||||
{
|
||||
GimpImageWindow *window = gimp_display_shell_get_window (shell);
|
||||
GimpUIManager *manager = gimp_image_window_get_ui_manager (window);
|
||||
|
||||
/* Special trick with these enum actions. If using any
|
||||
* positive value, we get the GIMP_ACTION_SELECT_SET behavior
|
||||
* which sets to the given value.
|
||||
*/
|
||||
gimp_display_shell_activate_action (manager, action,
|
||||
gimp_display_shell_activate_action (gimp, action,
|
||||
g_variant_new_int32 (size));
|
||||
}
|
||||
}
|
||||
|
|
@ -2402,42 +2387,37 @@ gimp_display_shell_untransform_event_coords (GimpDisplayShell *shell,
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_display_shell_activate_action (GimpUIManager *manager,
|
||||
const gchar *action_desc,
|
||||
GVariant *value)
|
||||
gimp_display_shell_activate_action (Gimp *gimp,
|
||||
const gchar *action_name,
|
||||
GVariant *value)
|
||||
{
|
||||
gchar *group_name;
|
||||
gchar *action_name;
|
||||
|
||||
g_return_if_fail (action_desc != NULL);
|
||||
|
||||
group_name = g_strdup (action_desc);
|
||||
action_name = strchr (group_name, '/');
|
||||
g_return_if_fail (action_name != NULL);
|
||||
|
||||
if (action_name)
|
||||
{
|
||||
GimpAction *action;
|
||||
GAction *action;
|
||||
|
||||
*action_name++ = '\0';
|
||||
action = g_action_map_lookup_action (G_ACTION_MAP (gimp->app), action_name);
|
||||
|
||||
action = gimp_ui_manager_find_action (manager, group_name, action_name);
|
||||
|
||||
if (GIMP_IS_ENUM_ACTION (action) &&
|
||||
GIMP_ENUM_ACTION (action)->value_variable)
|
||||
if (action == NULL)
|
||||
{
|
||||
gimp_action_emit_activate (action, value);
|
||||
g_printerr ("%s: ignoring unknown action '%s'.\n",
|
||||
G_STRFUNC, action_name);
|
||||
}
|
||||
else if (GIMP_IS_ENUM_ACTION (action) &&
|
||||
GIMP_ENUM_ACTION (action)->value_variable)
|
||||
{
|
||||
gimp_action_emit_activate (GIMP_ACTION (action), value);
|
||||
}
|
||||
else if (GIMP_IS_DOUBLE_ACTION (action))
|
||||
{
|
||||
gimp_action_emit_activate (action, value);
|
||||
gimp_action_emit_activate (GIMP_ACTION (action), value);
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_action_activate (action);
|
||||
gimp_action_activate (GIMP_ACTION (action));
|
||||
}
|
||||
}
|
||||
|
||||
g_free (group_name);
|
||||
}
|
||||
|
||||
/* Replace gdk_event_triggers_context_menu() as we don't want to trigger
|
||||
|
|
|
|||
|
|
@ -27,9 +27,10 @@
|
|||
|
||||
#include "widgets-types.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
|
||||
#include "gimpactioneditor.h"
|
||||
#include "gimpactionview.h"
|
||||
#include "gimpuimanager.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
|
@ -93,14 +94,14 @@ gimp_action_editor_init (GimpActionEditor *editor)
|
|||
}
|
||||
|
||||
GtkWidget *
|
||||
gimp_action_editor_new (GimpUIManager *manager,
|
||||
const gchar *select_action,
|
||||
gboolean show_shortcuts)
|
||||
gimp_action_editor_new (Gimp *gimp,
|
||||
const gchar *select_action,
|
||||
gboolean show_shortcuts)
|
||||
{
|
||||
GimpActionEditor *editor;
|
||||
GtkWidget *scrolled_window;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_UI_MANAGER (manager), NULL);
|
||||
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
||||
|
||||
editor = g_object_new (GIMP_TYPE_ACTION_EDITOR, NULL);
|
||||
|
||||
|
|
@ -112,7 +113,7 @@ gimp_action_editor_new (GimpUIManager *manager,
|
|||
gtk_box_pack_start (GTK_BOX (editor), scrolled_window, TRUE, TRUE, 0);
|
||||
gtk_widget_show (scrolled_window);
|
||||
|
||||
editor->view = gimp_action_view_new (manager->gimp, select_action, show_shortcuts);
|
||||
editor->view = gimp_action_view_new (gimp, select_action, show_shortcuts);
|
||||
gtk_widget_set_size_request (editor->view, 300, 400);
|
||||
gtk_container_add (GTK_CONTAINER (scrolled_window), editor->view);
|
||||
gtk_widget_show (editor->view);
|
||||
|
|
|
|||
|
|
@ -47,9 +47,9 @@ struct _GimpActionEditorClass
|
|||
|
||||
GType gimp_action_editor_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget * gimp_action_editor_new (GimpUIManager *manager,
|
||||
const gchar *select_action,
|
||||
gboolean show_shortcuts);
|
||||
GtkWidget * gimp_action_editor_new (Gimp *gimp,
|
||||
const gchar *select_action,
|
||||
gboolean show_shortcuts);
|
||||
|
||||
|
||||
#endif /* __GIMP_ACTION_EDITOR_H__ */
|
||||
|
|
|
|||
|
|
@ -682,7 +682,7 @@ gimp_controller_editor_edit_clicked (GtkWidget *button,
|
|||
G_CALLBACK (gimp_controller_editor_edit_response),
|
||||
editor);
|
||||
|
||||
view = gimp_action_editor_new (gimp_ui_managers_from_name ("<Image>")->data,
|
||||
view = gimp_action_editor_new (editor->context->gimp,
|
||||
action_name, FALSE);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (view), 12);
|
||||
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (editor->edit_dialog))),
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@
|
|||
|
||||
#include "widgets-types.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
|
||||
#include "display/display-types.h"
|
||||
#include "display/gimpmodifiersmanager.h"
|
||||
|
||||
|
|
@ -47,6 +49,7 @@ enum
|
|||
{
|
||||
PROP_0,
|
||||
PROP_MANAGER,
|
||||
PROP_GIMP,
|
||||
};
|
||||
|
||||
struct _GimpModifiersEditorPrivate
|
||||
|
|
@ -68,6 +71,7 @@ struct _GimpModifiersEditorPrivate
|
|||
GtkSizeGroup *minus_size_group;
|
||||
|
||||
GimpModifiersManager *manager;
|
||||
Gimp *gimp;
|
||||
GHashTable *rows;
|
||||
|
||||
GtkTreeSelection *action_selection;
|
||||
|
|
@ -146,6 +150,12 @@ gimp_modifiers_editor_class_init (GimpModifiersEditorClass *klass)
|
|||
GIMP_TYPE_MODIFIERS_MANAGER,
|
||||
GIMP_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY));
|
||||
g_object_class_install_property (object_class, PROP_GIMP,
|
||||
g_param_spec_object ("gimp",
|
||||
NULL, NULL,
|
||||
GIMP_TYPE_GIMP,
|
||||
GIMP_PARAM_WRITABLE |
|
||||
G_PARAM_CONSTRUCT_ONLY));
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -256,7 +266,9 @@ gimp_modifiers_editor_set_property (GObject *object,
|
|||
case PROP_MANAGER:
|
||||
editor->priv->manager = g_value_get_object (value);
|
||||
break;
|
||||
|
||||
case PROP_GIMP:
|
||||
editor->priv->gimp = g_value_get_object (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
|
|
@ -287,7 +299,8 @@ gimp_modifiers_editor_get_property (GObject *object,
|
|||
/* public functions */
|
||||
|
||||
GtkWidget *
|
||||
gimp_modifiers_editor_new (GimpModifiersManager *manager)
|
||||
gimp_modifiers_editor_new (GimpModifiersManager *manager,
|
||||
Gimp *gimp)
|
||||
{
|
||||
GimpModifiersEditor *editor;
|
||||
|
||||
|
|
@ -295,6 +308,7 @@ gimp_modifiers_editor_new (GimpModifiersManager *manager)
|
|||
|
||||
editor = g_object_new (GIMP_TYPE_MODIFIERS_EDITOR,
|
||||
"manager", manager,
|
||||
"gimp", gimp,
|
||||
NULL);
|
||||
|
||||
return GTK_WIDGET (editor);
|
||||
|
|
@ -475,7 +489,7 @@ gimp_modifiers_editor_add_mapping (GimpModifiersEditor *editor,
|
|||
if (action_name)
|
||||
action_name++;
|
||||
|
||||
if (strlen (action_name) > 0)
|
||||
if (action_name && strlen (action_name) > 0)
|
||||
action_button = gtk_button_new_with_label (action_name);
|
||||
}
|
||||
|
||||
|
|
@ -619,8 +633,6 @@ gimp_modifiers_editor_search_clicked (GtkWidget *button,
|
|||
GimpModifiersEditor *editor)
|
||||
{
|
||||
gchar *accel_name = NULL;
|
||||
gchar *action_name = "action name";
|
||||
|
||||
GtkWidget *shortcut;
|
||||
GdkModifierType modifiers;
|
||||
|
||||
|
|
@ -691,8 +703,7 @@ gimp_modifiers_editor_search_clicked (GtkWidget *button,
|
|||
G_CALLBACK (gimp_modifiers_editor_search_response),
|
||||
editor);
|
||||
|
||||
view = gimp_action_editor_new (gimp_ui_managers_from_name ("<Image>")->data,
|
||||
action_name, FALSE);
|
||||
view = gimp_action_editor_new (editor->priv->gimp, NULL, FALSE);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (view), 12);
|
||||
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (edit_dialog))),
|
||||
view, TRUE, TRUE, 0);
|
||||
|
|
@ -760,9 +771,7 @@ gimp_modifiers_editor_search_response (GtkWidget *dialog,
|
|||
gimp_shortcut_button_get_keys (GIMP_SHORTCUT_BUTTON (shortcut), NULL, &modifiers);
|
||||
|
||||
action_button = g_object_get_data (G_OBJECT (dialog), "shortcut-action-action");
|
||||
action_desc = g_strdup_printf ("%s/%s",
|
||||
gtk_action_group_get_name (group),
|
||||
gimp_action_get_name (action));
|
||||
action_desc = g_strdup (gimp_action_get_name (action));
|
||||
|
||||
g_object_set_data_full (G_OBJECT (action_button), "shortcut-action-desc",
|
||||
action_desc, g_free);
|
||||
|
|
|
|||
|
|
@ -48,7 +48,8 @@ struct _GimpModifiersEditorClass
|
|||
|
||||
GType gimp_modifiers_editor_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget * gimp_modifiers_editor_new (GimpModifiersManager *manager);
|
||||
GtkWidget * gimp_modifiers_editor_new (GimpModifiersManager *manager,
|
||||
Gimp *gimp);
|
||||
|
||||
void gimp_modifiers_editor_clear (GimpModifiersEditor *editor);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue