void gimp_container_tree_view_real_drop_viewable (GimpContainerTreeView *tree_view, GimpViewable *src_viewable, GimpViewable *dest_viewable, GtkTreeViewDropPosition drop_pos) { GimpContainerView *view = GIMP_CONTAINER_VIEW (tree_view); GimpContainer *container = gimp_container_view_get_container (view); gint src_index; gint dest_index; src_index = gimp_container_get_child_index (container, GIMP_OBJECT (src_viewable)); dest_index = gimp_container_get_child_index (container, GIMP_OBJECT (dest_viewable)); if (drop_pos == GTK_TREE_VIEW_DROP_AFTER && src_index > dest_index) { dest_index++; } else if (drop_pos == GTK_TREE_VIEW_DROP_BEFORE && src_index < dest_index) { dest_index--; } gimp_container_reorder (container, GIMP_OBJECT (src_viewable), dest_index); }
void tools_reset_cmd_callback (GtkAction *action, gpointer data) { GimpContext *context; GimpContainer *container; GList *list; gint i = 0; return_if_no_context (context, data); container = context->gimp->tool_info_list; for (list = gimp_tools_get_default_order (context->gimp); list; list = g_list_next (list)) { GimpObject *object = gimp_container_get_child_by_name (container, list->data); if (object) { gboolean visible; gimp_container_reorder (container, object, i); visible = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (object), "gimp-tool-default-visible")); g_object_set (object, "visible", visible, NULL); i++; } } }
static void gimp_controller_list_down_clicked (GtkWidget *button, GimpControllerList *list) { GimpContainer *container; gint index; container = gimp_controllers_get_list (list->gimp); index = gimp_container_get_child_index (container, GIMP_OBJECT (list->dest_info)); if (index < gimp_container_get_n_children (container) - 1) gimp_container_reorder (container, GIMP_OBJECT (list->dest_info), index + 1); }
static void gimp_list_object_renamed (GimpObject *object, GimpList *list) { if (list->unique_names) { g_signal_handlers_block_by_func (object, gimp_list_object_renamed, list); gimp_list_uniquefy_name (list, object); g_signal_handlers_unblock_by_func (object, gimp_list_object_renamed, list); } if (list->sort_func) { GList *glist; gint old_index; gint new_index = 0; old_index = g_list_index (list->list, object); for (glist = list->list; glist; glist = g_list_next (glist)) { GimpObject *object2 = GIMP_OBJECT (glist->data); if (object == object2) continue; if (list->sort_func (object, object2) > 0) new_index++; else break; } if (new_index != old_index) gimp_container_reorder (GIMP_CONTAINER (list), object, new_index); } }
void tools_lower_to_bottom_cmd_callback (GtkAction *action, gpointer data) { GimpContext *context; GimpToolInfo *tool_info; return_if_no_context (context, data); tool_info = gimp_context_get_tool (context); if (tool_info) { GimpContainer *container; gint index; container = context->gimp->tool_info_list; index = gimp_container_num_children (container) - 1; index = index >= 0 ? index : 0; gimp_container_reorder (container, GIMP_OBJECT (tool_info), index); } }
void tools_raise_to_top_cmd_callback (GtkAction *action, gpointer data) { GimpContext *context; GimpToolInfo *tool_info; return_if_no_context (context, data); tool_info = gimp_context_get_tool (context); if (tool_info) { GimpContainer *container; gint index; container = context->gimp->tool_info_list; index = gimp_container_get_child_index (container, GIMP_OBJECT (tool_info)); if (index > 0) gimp_container_reorder (container, GIMP_OBJECT (tool_info), 0); } }
void gimp_tools_restore (Gimp *gimp) { GimpContainer *gimp_list; GimpObject *object; GFile *file; GList *list; GError *error = NULL; g_return_if_fail (GIMP_IS_GIMP (gimp)); gimp_list = gimp_list_new (GIMP_TYPE_TOOL_INFO, FALSE); file = gimp_directory_file ("toolrc", NULL); if (gimp->be_verbose) g_print ("Parsing '%s'\n", gimp_file_get_utf8_name (file)); if (gimp_config_deserialize_gfile (GIMP_CONFIG (gimp_list), file, NULL, NULL)) { gint n = gimp_container_get_n_children (gimp->tool_info_list); gint i; gimp_list_reverse (GIMP_LIST (gimp_list)); for (list = GIMP_LIST (gimp_list)->list, i = 0; list; list = g_list_next (list), i++) { const gchar *name; name = gimp_object_get_name (list->data); object = gimp_container_get_child_by_name (gimp->tool_info_list, name); if (object) { g_object_set (object, "visible", GIMP_TOOL_INFO (list->data)->visible, NULL); gimp_container_reorder (gimp->tool_info_list, object, MIN (i, n - 1)); } } } g_object_unref (file); g_object_unref (gimp_list); /* make the generic operation tool invisible by default */ object = gimp_container_get_child_by_name (gimp->tool_info_list, "gimp-operation-tool"); if (object) g_object_set (object, "visible", FALSE, NULL); for (list = gimp_get_tool_info_iter (gimp); list; list = g_list_next (list)) { GimpToolInfo *tool_info = GIMP_TOOL_INFO (list->data); /* get default values from prefs (see bug #120832) */ gimp_config_reset (GIMP_CONFIG (tool_info->tool_options)); } if (! gimp_contexts_load (gimp, &error)) { gimp_message_literal (gimp, NULL, GIMP_MESSAGE_WARNING, error->message); g_clear_error (&error); } /* make sure there is always a tool active, so broken config files * can't leave us with no initial tool */ if (! gimp_context_get_tool (gimp_get_user_context (gimp))) { gimp_context_set_tool (gimp_get_user_context (gimp), gimp_get_tool_info_iter (gimp)->data); } for (list = gimp_get_tool_info_iter (gimp); list; list = g_list_next (list)) { GimpToolInfo *tool_info = GIMP_TOOL_INFO (list->data); GimpToolOptionsGUIFunc options_gui_func; GtkWidget *options_gui; /* copy all context properties except those the tool actually * uses, because the subsequent deserialize() on the tool * options will only set the properties that were set to * non-default values at the time of saving, and we want to * keep these default values as if they have been saved. * (see bug #541586). */ gimp_context_copy_properties (gimp_get_user_context (gimp), GIMP_CONTEXT (tool_info->tool_options), GIMP_CONTEXT_PROP_MASK_ALL &~ (tool_info->context_props | GIMP_CONTEXT_PROP_MASK_TOOL | GIMP_CONTEXT_PROP_MASK_PAINT_INFO)); gimp_tool_options_deserialize (tool_info->tool_options, NULL); options_gui_func = g_object_get_data (G_OBJECT (tool_info), "gimp-tool-options-gui-func"); if (options_gui_func) { options_gui = (* options_gui_func) (tool_info->tool_options); } else { GtkWidget *label; options_gui = gimp_tool_options_gui (tool_info->tool_options); label = gtk_label_new (_("This tool has\nno options.")); gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_CENTER); gimp_label_set_attributes (GTK_LABEL (label), PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC, -1); gtk_box_pack_start (GTK_BOX (options_gui), label, FALSE, FALSE, 6); gtk_widget_show (label); } gimp_tools_set_tool_options_gui (tool_info->tool_options, g_object_ref_sink (options_gui)); } }