mirror of https://github.com/GNOME/gimp.git
app: add gimp_container_get_neighbor_of() to GimpContainer
instead of gimp_container_get_neighbor_of_active() in gimp-utils.c. Move the additional GimpContext logic of the old function into the callers, but use the new function in more places.
This commit is contained in:
parent
183e1e9aae
commit
8184296b3c
|
@ -24,7 +24,6 @@
|
|||
#include "actions-types.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimp-utils.h"
|
||||
#include "core/gimpcontainer.h"
|
||||
#include "core/gimpcontext.h"
|
||||
#include "core/gimpdata.h"
|
||||
|
@ -324,14 +323,22 @@ data_delete_confirm_response (GtkWidget *dialog,
|
|||
|
||||
if (response_id == GTK_RESPONSE_OK)
|
||||
{
|
||||
GimpDataFactory *factory = gimp_data_factory_view_get_data_factory (delete_data->view);
|
||||
GimpDataFactory *factory;
|
||||
GimpContainer *container;
|
||||
GimpData *data = delete_data->data;
|
||||
GimpObject *new_active;
|
||||
GimpObject *new_active = NULL;
|
||||
GError *error = NULL;
|
||||
|
||||
new_active = gimp_container_get_neighbor_of_active (gimp_data_factory_get_container (factory),
|
||||
delete_data->context,
|
||||
GIMP_OBJECT (data));
|
||||
factory = gimp_data_factory_view_get_data_factory (delete_data->view);
|
||||
container = gimp_data_factory_get_container (factory);
|
||||
|
||||
if (GIMP_OBJECT (data) ==
|
||||
gimp_context_get_by_type (delete_data->context,
|
||||
gimp_container_get_children_type (container)))
|
||||
{
|
||||
new_active = gimp_container_get_neighbor_of (container,
|
||||
GIMP_OBJECT (data));
|
||||
}
|
||||
|
||||
if (! gimp_data_factory_data_delete (factory, data, TRUE, &error))
|
||||
{
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#include "config/gimpcoreconfig.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimp-utils.h"
|
||||
#include "core/gimpcontainer.h"
|
||||
#include "core/gimpcontext.h"
|
||||
#include "core/gimpimage-new.h"
|
||||
|
@ -292,11 +291,14 @@ templates_delete_response (GtkWidget *dialog,
|
|||
{
|
||||
if (response_id == GTK_RESPONSE_OK)
|
||||
{
|
||||
GimpObject *new_active;
|
||||
GimpObject *new_active = NULL;
|
||||
|
||||
new_active = gimp_container_get_neighbor_of_active (delete_data->container,
|
||||
delete_data->context,
|
||||
GIMP_OBJECT (delete_data->template));
|
||||
if (delete_data->template ==
|
||||
gimp_context_get_template (delete_data->context))
|
||||
{
|
||||
new_active = gimp_container_get_neighbor_of (delete_data->container,
|
||||
GIMP_OBJECT (delete_data->template));
|
||||
}
|
||||
|
||||
if (gimp_container_have (delete_data->container,
|
||||
GIMP_OBJECT (delete_data->template)))
|
||||
|
|
|
@ -499,36 +499,6 @@ gimp_get_temp_filename (Gimp *gimp,
|
|||
return filename;
|
||||
}
|
||||
|
||||
GimpObject *
|
||||
gimp_container_get_neighbor_of_active (GimpContainer *container,
|
||||
GimpContext *context,
|
||||
GimpObject *active)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_CONTAINER (container), NULL);
|
||||
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
|
||||
g_return_val_if_fail (GIMP_IS_OBJECT (active), NULL);
|
||||
|
||||
if (active == gimp_context_get_by_type (context,
|
||||
gimp_container_get_children_type (container)))
|
||||
{
|
||||
gint index = gimp_container_get_child_index (container, active);
|
||||
|
||||
if (index != -1)
|
||||
{
|
||||
GimpObject *new;
|
||||
|
||||
new = gimp_container_get_child_by_index (container, index + 1);
|
||||
|
||||
if (! new && index > 0)
|
||||
new = gimp_container_get_child_by_index (container, index - 1);
|
||||
|
||||
return new;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* markup unescape code stolen and adapted from gmarkup.c
|
||||
*/
|
||||
static gchar *
|
||||
|
|
|
@ -72,10 +72,6 @@ void gimp_value_array_truncate (GValueArray *args,
|
|||
gchar * gimp_get_temp_filename (Gimp *gimp,
|
||||
const gchar *extension);
|
||||
|
||||
GimpObject * gimp_container_get_neighbor_of_active (GimpContainer *container,
|
||||
GimpContext *context,
|
||||
GimpObject *active);
|
||||
|
||||
gchar * gimp_markup_extract_text (const gchar *markup);
|
||||
|
||||
const gchar* gimp_enum_get_value_name (GType enum_type,
|
||||
|
|
|
@ -886,6 +886,32 @@ gimp_container_get_child_index (const GimpContainer *container,
|
|||
object);
|
||||
}
|
||||
|
||||
GimpObject *
|
||||
gimp_container_get_neighbor_of (const GimpContainer *container,
|
||||
const GimpObject *object)
|
||||
{
|
||||
gint index;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_CONTAINER (container), NULL);
|
||||
g_return_val_if_fail (GIMP_IS_OBJECT (object), NULL);
|
||||
|
||||
index = gimp_container_get_child_index (container, object);
|
||||
|
||||
if (index != -1)
|
||||
{
|
||||
GimpObject *new;
|
||||
|
||||
new = gimp_container_get_child_by_index (container, index + 1);
|
||||
|
||||
if (! new && index > 0)
|
||||
new = gimp_container_get_child_by_index (container, index - 1);
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_container_get_name_array_foreach_func (GimpObject *object,
|
||||
gchar ***iter)
|
||||
|
|
|
@ -112,6 +112,9 @@ GimpObject * gimp_container_get_last_child (const GimpContainer *container);
|
|||
gint gimp_container_get_child_index (const GimpContainer *container,
|
||||
const GimpObject *object);
|
||||
|
||||
GimpObject * gimp_container_get_neighbor_of (const GimpContainer *container,
|
||||
const GimpObject *object);
|
||||
|
||||
gchar ** gimp_container_get_name_array (const GimpContainer *container,
|
||||
gint *length);
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
|
||||
#include "widgets-types.h"
|
||||
|
||||
#include "core/gimp-utils.h"
|
||||
#include "core/gimpcontainer.h"
|
||||
#include "core/gimpcontext.h"
|
||||
|
||||
|
@ -70,21 +69,21 @@ gimp_container_view_remove_active (GimpContainerView *view)
|
|||
|
||||
if (context && container)
|
||||
{
|
||||
GType children_type;
|
||||
GimpObject *active;
|
||||
|
||||
active = gimp_context_get_by_type (context, gimp_container_get_children_type (container));
|
||||
children_type = gimp_container_get_children_type (container);
|
||||
|
||||
active = gimp_context_get_by_type (context, children_type);
|
||||
|
||||
if (active)
|
||||
{
|
||||
GimpObject *new;
|
||||
|
||||
new = gimp_container_get_neighbor_of_active (container, context,
|
||||
active);
|
||||
new = gimp_container_get_neighbor_of (container, active);
|
||||
|
||||
if (new)
|
||||
gimp_context_set_by_type (context,
|
||||
gimp_container_get_children_type (container),
|
||||
new);
|
||||
gimp_context_set_by_type (context, children_type, new);
|
||||
|
||||
gimp_container_remove (container, active);
|
||||
}
|
||||
|
|
|
@ -347,25 +347,14 @@ gimp_settings_editor_delete_clicked (GtkWidget *widget,
|
|||
|
||||
if (private->selected_setting)
|
||||
{
|
||||
GimpObject *new = NULL;
|
||||
gint index;
|
||||
GimpObject *new;
|
||||
|
||||
index = gimp_container_get_child_index (private->container,
|
||||
GIMP_OBJECT (private->selected_setting));
|
||||
new = gimp_container_get_neighbor_of (private->container,
|
||||
GIMP_OBJECT (private->selected_setting));
|
||||
|
||||
if (index != -1)
|
||||
{
|
||||
new = gimp_container_get_child_by_index (private->container,
|
||||
index + 1);
|
||||
|
||||
if (! new && index > 0)
|
||||
new = gimp_container_get_child_by_index (private->container,
|
||||
index - 1);
|
||||
|
||||
/* don't select the separator */
|
||||
if (new && ! gimp_object_get_name (new))
|
||||
new = NULL;
|
||||
}
|
||||
/* don't select the separator */
|
||||
if (new && ! gimp_object_get_name (new))
|
||||
new = NULL;
|
||||
|
||||
gimp_container_remove (private->container,
|
||||
GIMP_OBJECT (private->selected_setting));
|
||||
|
|
Loading…
Reference in New Issue