Commit 2ed3859b authored by Michael Natterer's avatar Michael Natterer 😴

app: some cleanup in tool_manager and gimp-tool-options-manager

parent 584a2d18
......@@ -30,7 +30,6 @@
#include "config/gimpcoreconfig.h"
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "core/gimptoolinfo.h"
#include "paint/gimppaintoptions.h"
......@@ -50,9 +49,6 @@ struct _GimpToolOptionsManager
};
static GQuark manager_quark = 0;
/* local function prototypes */
static GimpContextPropMask
......@@ -77,6 +73,9 @@ static void tool_options_manager_tool_changed (GimpContext *user_c
GimpToolOptionsManager *manager);
static GQuark manager_quark = 0;
/* public functions */
void
......@@ -84,7 +83,6 @@ gimp_tool_options_manager_init (Gimp *gimp)
{
GimpToolOptionsManager *manager;
GimpContext *user_context;
GimpCoreConfig *config;
GList *list;
g_return_if_fail (GIMP_IS_GIMP (gimp));
......@@ -92,10 +90,10 @@ gimp_tool_options_manager_init (Gimp *gimp)
manager_quark = g_quark_from_static_string ("gimp-tool-options-manager");
config = gimp->config;
manager = g_slice_new0 (GimpToolOptionsManager);
g_object_set_qdata (G_OBJECT (gimp), manager_quark, manager);
manager->gimp = gimp;
manager->global_paint_options =
......@@ -104,9 +102,7 @@ gimp_tool_options_manager_init (Gimp *gimp)
"name", "tool-options-manager-global-paint-options",
NULL);
manager->global_props = tool_options_manager_get_global_props (config);
g_object_set_qdata (G_OBJECT (gimp), manager_quark, manager);
manager->global_props = tool_options_manager_get_global_props (gimp->config);
user_context = gimp_get_user_context (gimp);
......@@ -405,7 +401,7 @@ tool_options_manager_tool_changed (GimpContext *user_context,
/* FIXME: gimp_busy HACK
* the tool manager will stop the emission, so simply return
*/
if (user_context->gimp->busy)
if (manager->gimp->busy)
return;
if (manager->active_tool)
......
......@@ -29,8 +29,7 @@
#include "config/gimpcoreconfig.h"
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "core/gimplist.h"
#include "core/gimpcontainer.h"
#include "core/gimpimage.h"
#include "core/gimptoolinfo.h"
#include "core/gimptoolpreset.h"
......@@ -61,8 +60,7 @@ struct _GimpToolManager
/* local function prototypes */
static GimpToolManager * tool_manager_get (Gimp *gimp);
static void tool_manager_set (Gimp *gimp,
GimpToolManager *tool_manager);
static void tool_manager_select_tool (Gimp *gimp,
GimpTool *tool);
static void tool_manager_tool_changed (GimpContext *user_context,
......@@ -78,6 +76,9 @@ static void tool_manager_image_clean_dirty (GimpImage *image,
static void tool_manager_cast_spell (GimpToolInfo *tool_info);
static GQuark tool_manager_quark = 0;
/* public functions */
void
......@@ -87,15 +88,13 @@ tool_manager_init (Gimp *gimp)
GimpContext *user_context;
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (tool_manager_quark == 0);
tool_manager = g_slice_new0 (GimpToolManager);
tool_manager_quark = g_quark_from_static_string ("gimp-tool-manager");
tool_manager->active_tool = NULL;
tool_manager->tool_stack = NULL;
tool_manager->image_clean_handler_id = 0;
tool_manager->image_dirty_handler_id = 0;
tool_manager = g_slice_new0 (GimpToolManager);
tool_manager_set (gimp, tool_manager);
g_object_set_qdata (G_OBJECT (gimp), tool_manager_quark, tool_manager);
tool_manager->image_clean_handler_id =
gimp_container_add_handler (gimp->images, "clean",
......@@ -130,7 +129,8 @@ tool_manager_exit (Gimp *gimp)
g_return_if_fail (GIMP_IS_GIMP (gimp));
tool_manager = tool_manager_get (gimp);
tool_manager_set (gimp, NULL);
g_return_if_fail (tool_manager != NULL);
user_context = gimp_get_user_context (gimp);
......@@ -149,6 +149,8 @@ tool_manager_exit (Gimp *gimp)
g_clear_object (&tool_manager->active_tool);
g_slice_free (GimpToolManager, tool_manager);
g_object_set_qdata (G_OBJECT (gimp), tool_manager_quark, NULL);
}
GimpTool *
......@@ -577,27 +579,12 @@ tool_manager_get_popup_active (Gimp *gimp,
/* private functions */
static GQuark tool_manager_quark = 0;
static GimpToolManager *
tool_manager_get (Gimp *gimp)
{
if (! tool_manager_quark)
tool_manager_quark = g_quark_from_static_string ("gimp-tool-manager");
return g_object_get_qdata (G_OBJECT (gimp), tool_manager_quark);
}
static void
tool_manager_set (Gimp *gimp,
GimpToolManager *tool_manager)
{
if (! tool_manager_quark)
tool_manager_quark = g_quark_from_static_string ("gimp-tool-manager");
g_object_set_qdata (G_OBJECT (gimp), tool_manager_quark, tool_manager);
}
static void
tool_manager_select_tool (Gimp *gimp,
GimpTool *tool)
......@@ -748,8 +735,7 @@ tool_manager_preset_changed (GimpContext *user_context,
/* copy various data objects' additional tool options again
* manually, they might have been overwritten by e.g. the "link
* brush stuff to brush defaults" logic in
* gimptooloptions-gui.c
* brush stuff to brush defaults" logic in gimptooloptions.c
*/
if (preset->use_brush)
prop_mask |= GIMP_CONTEXT_PROP_MASK_BRUSH;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment