Commit 56e032c1 authored by Michael Natterer's avatar Michael Natterer 😴

app: remove gimp_image_map_tool_dialog_get_label_group()

The "Settings:" label should never be aligned with a label in the UI
below, because that suggests that are related. Also consistently
rename all GimpImageMapTool parameters and variables to "im_tool".
parent a4f005ba
......@@ -51,16 +51,16 @@
static gboolean gimp_image_map_tool_settings_import (GimpSettingsBox *box,
GFile *file,
GimpImageMapTool *tool);
GimpImageMapTool *im_tool);
static gboolean gimp_image_map_tool_settings_export (GimpSettingsBox *box,
GFile *file,
GimpImageMapTool *tool);
GimpImageMapTool *im_tool);
/* public functions */
GtkWidget *
gimp_image_map_tool_real_get_settings_ui (GimpImageMapTool *image_map_tool,
gimp_image_map_tool_real_get_settings_ui (GimpImageMapTool *im_tool,
GimpContainer *settings,
GFile *settings_file,
const gchar *import_dialog_title,
......@@ -70,24 +70,20 @@ gimp_image_map_tool_real_get_settings_ui (GimpImageMapTool *image_map_tool,
GtkWidget **settings_box)
{
GimpToolInfo *tool_info;
GtkSizeGroup *label_group;
GtkWidget *hbox;
GtkWidget *label;
GtkWidget *settings_combo;
tool_info = GIMP_TOOL (image_map_tool)->tool_info;
tool_info = GIMP_TOOL (im_tool)->tool_info;
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
label_group = gimp_image_map_tool_dialog_get_label_group (image_map_tool);
label = gtk_label_new_with_mnemonic (_("Pre_sets:"));
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_size_group_add_widget (label_group, label);
gtk_widget_show (label);
*settings_box = gimp_settings_box_new (tool_info->gimp,
image_map_tool->config,
im_tool->config,
settings,
settings_file,
import_dialog_title,
......@@ -101,33 +97,33 @@ gimp_image_map_tool_real_get_settings_ui (GimpImageMapTool *image_map_tool,
settings_combo = gimp_settings_box_get_combo (GIMP_SETTINGS_BOX (*settings_box));
gtk_label_set_mnemonic_widget (GTK_LABEL (label), settings_combo);
g_signal_connect (image_map_tool->settings_box, "import",
g_signal_connect (im_tool->settings_box, "import",
G_CALLBACK (gimp_image_map_tool_settings_import),
image_map_tool);
im_tool);
g_signal_connect (image_map_tool->settings_box, "export",
g_signal_connect (im_tool->settings_box, "export",
G_CALLBACK (gimp_image_map_tool_settings_export),
image_map_tool);
im_tool);
return hbox;
}
gboolean
gimp_image_map_tool_real_settings_import (GimpImageMapTool *tool,
gimp_image_map_tool_real_settings_import (GimpImageMapTool *im_tool,
GInputStream *input,
GError **error)
{
return gimp_config_deserialize_stream (GIMP_CONFIG (tool->config),
return gimp_config_deserialize_stream (GIMP_CONFIG (im_tool->config),
input,
NULL, error);
}
gboolean
gimp_image_map_tool_real_settings_export (GimpImageMapTool *tool,
gimp_image_map_tool_real_settings_export (GimpImageMapTool *im_tool,
GOutputStream *output,
GError **error)
{
GimpImageMapToolClass *klass = GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool);
GimpImageMapToolClass *klass = GIMP_IMAGE_MAP_TOOL_GET_CLASS (im_tool);
gchar *header;
gchar *footer;
gboolean success;
......@@ -135,7 +131,7 @@ gimp_image_map_tool_real_settings_export (GimpImageMapTool *tool,
header = g_strdup_printf ("GIMP %s tool settings", klass->settings_name);
footer = g_strdup_printf ("end of %s tool settings", klass->settings_name);
success = gimp_config_serialize_to_stream (GIMP_CONFIG (tool->config),
success = gimp_config_serialize_to_stream (GIMP_CONFIG (im_tool->config),
output,
header, footer,
NULL, error);
......@@ -152,22 +148,22 @@ gimp_image_map_tool_real_settings_export (GimpImageMapTool *tool,
static gboolean
gimp_image_map_tool_settings_import (GimpSettingsBox *box,
GFile *file,
GimpImageMapTool *tool)
GimpImageMapTool *im_tool)
{
GimpImageMapToolClass *tool_class = GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool);
GimpImageMapToolClass *tool_class = GIMP_IMAGE_MAP_TOOL_GET_CLASS (im_tool);
GInputStream *input;
GError *error = NULL;
g_return_val_if_fail (tool_class->settings_import != NULL, FALSE);
if (GIMP_TOOL (tool)->tool_info->gimp->be_verbose)
if (GIMP_TOOL (im_tool)->tool_info->gimp->be_verbose)
g_print ("Parsing '%s'\n", gimp_file_get_utf8_name (file));
input = G_INPUT_STREAM (g_file_read (file, NULL, &error));
if (! input)
{
gimp_message (GIMP_TOOL (tool)->tool_info->gimp,
G_OBJECT (gimp_tool_gui_get_dialog (tool->gui)),
gimp_message (GIMP_TOOL (im_tool)->tool_info->gimp,
G_OBJECT (gimp_tool_gui_get_dialog (im_tool->gui)),
GIMP_MESSAGE_ERROR,
_("Could not open '%s' for reading: %s"),
gimp_file_get_utf8_name (file),
......@@ -176,10 +172,10 @@ gimp_image_map_tool_settings_import (GimpSettingsBox *box,
return FALSE;
}
if (! tool_class->settings_import (tool, input, &error))
if (! tool_class->settings_import (im_tool, input, &error))
{
gimp_message (GIMP_TOOL (tool)->tool_info->gimp,
G_OBJECT (gimp_tool_gui_get_dialog (tool->gui)),
gimp_message (GIMP_TOOL (im_tool)->tool_info->gimp,
G_OBJECT (gimp_tool_gui_get_dialog (im_tool->gui)),
GIMP_MESSAGE_ERROR,
_("Error reading '%s': %s"),
gimp_file_get_utf8_name (file),
......@@ -191,9 +187,9 @@ gimp_image_map_tool_settings_import (GimpSettingsBox *box,
g_object_unref (input);
gimp_image_map_tool_preview (tool);
gimp_image_map_tool_preview (im_tool);
g_object_set (GIMP_TOOL_GET_OPTIONS (tool),
g_object_set (GIMP_TOOL_GET_OPTIONS (im_tool),
"settings", file,
NULL);
......@@ -203,15 +199,15 @@ gimp_image_map_tool_settings_import (GimpSettingsBox *box,
static gboolean
gimp_image_map_tool_settings_export (GimpSettingsBox *box,
GFile *file,
GimpImageMapTool *tool)
GimpImageMapTool *im_tool)
{
GimpImageMapToolClass *tool_class = GIMP_IMAGE_MAP_TOOL_GET_CLASS (tool);
GimpImageMapToolClass *tool_class = GIMP_IMAGE_MAP_TOOL_GET_CLASS (im_tool);
GOutputStream *output;
GError *error = NULL;
g_return_val_if_fail (tool_class->settings_export != NULL, FALSE);
if (GIMP_TOOL (tool)->tool_info->gimp->be_verbose)
if (GIMP_TOOL (im_tool)->tool_info->gimp->be_verbose)
g_print ("Writing '%s'\n", gimp_file_get_utf8_name (file));
output = G_OUTPUT_STREAM (g_file_replace (file,
......@@ -219,18 +215,18 @@ gimp_image_map_tool_settings_export (GimpSettingsBox *box,
NULL, &error));
if (! output)
{
gimp_message_literal (GIMP_TOOL (tool)->tool_info->gimp,
G_OBJECT (gimp_tool_gui_get_dialog (tool->gui)),
gimp_message_literal (GIMP_TOOL (im_tool)->tool_info->gimp,
G_OBJECT (gimp_tool_gui_get_dialog (im_tool->gui)),
GIMP_MESSAGE_ERROR,
error->message);
g_clear_error (&error);
return FALSE;
}
if (! tool_class->settings_export (tool, output, &error))
if (! tool_class->settings_export (im_tool, output, &error))
{
gimp_message (GIMP_TOOL (tool)->tool_info->gimp,
G_OBJECT (gimp_tool_gui_get_dialog (tool->gui)),
gimp_message (GIMP_TOOL (im_tool)->tool_info->gimp,
G_OBJECT (gimp_tool_gui_get_dialog (im_tool->gui)),
GIMP_MESSAGE_ERROR,
_("Error writing '%s': %s"),
gimp_file_get_utf8_name (file),
......@@ -242,13 +238,13 @@ gimp_image_map_tool_settings_export (GimpSettingsBox *box,
g_object_unref (output);
gimp_message (GIMP_TOOL (tool)->tool_info->gimp,
G_OBJECT (GIMP_TOOL (tool)->display),
gimp_message (GIMP_TOOL (im_tool)->tool_info->gimp,
G_OBJECT (GIMP_TOOL (im_tool)->display),
GIMP_MESSAGE_INFO,
_("Settings saved to '%s'"),
gimp_file_get_utf8_name (file));
g_object_set (GIMP_TOOL_GET_OPTIONS (tool),
g_object_set (GIMP_TOOL_GET_OPTIONS (im_tool),
"settings", file,
NULL);
......
......@@ -21,7 +21,7 @@
#define __GIMP_IMAGE_MAP_TOOL_SETTINGS_H__
GtkWidget * gimp_image_map_tool_real_get_settings_ui (GimpImageMapTool *tool,
GtkWidget * gimp_image_map_tool_real_get_settings_ui (GimpImageMapTool *im_tool,
GimpContainer *settings,
GFile *settings_file,
const gchar *import_dialog_title,
......@@ -29,10 +29,10 @@ GtkWidget * gimp_image_map_tool_real_get_settings_ui (GimpImageMapTool *tool,
const gchar *file_dialog_help_id,
GFile *default_folder,
GtkWidget **settings_box);
gboolean gimp_image_map_tool_real_settings_import (GimpImageMapTool *tool,
gboolean gimp_image_map_tool_real_settings_import (GimpImageMapTool *im_tool,
GInputStream *input,
GError **error);
gboolean gimp_image_map_tool_real_settings_export (GimpImageMapTool *tool,
gboolean gimp_image_map_tool_real_settings_export (GimpImageMapTool *im_tool,
GOutputStream *output,
GError **error);
......
......@@ -202,9 +202,9 @@ gimp_image_map_tool_base_init (GimpImageMapToolClass *klass)
}
static void
gimp_image_map_tool_init (GimpImageMapTool *image_map_tool)
gimp_image_map_tool_init (GimpImageMapTool *im_tool)
{
GimpTool *tool = GIMP_TOOL (image_map_tool);
GimpTool *tool = GIMP_TOOL (im_tool);
gimp_tool_control_set_scroll_lock (tool->control, TRUE);
gimp_tool_control_set_preserve (tool->control, FALSE);
......@@ -219,77 +219,71 @@ gimp_image_map_tool_init (GimpImageMapTool *image_map_tool)
static void
gimp_image_map_tool_constructed (GObject *object)
{
GimpImageMapTool *image_map_tool = GIMP_IMAGE_MAP_TOOL (object);
GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (object);
G_OBJECT_CLASS (parent_class)->constructed (object);
gimp_image_map_tool_get_operation (image_map_tool);
gimp_image_map_tool_get_operation (im_tool);
}
static void
gimp_image_map_tool_finalize (GObject *object)
{
GimpImageMapTool *image_map_tool = GIMP_IMAGE_MAP_TOOL (object);
GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (object);
if (image_map_tool->operation)
{
g_object_unref (image_map_tool->operation);
image_map_tool->operation = NULL;
}
if (image_map_tool->config)
if (im_tool->operation)
{
g_object_unref (image_map_tool->config);
image_map_tool->config = NULL;
g_object_unref (im_tool->operation);
im_tool->operation = NULL;
}
if (image_map_tool->default_config)
if (im_tool->config)
{
g_object_unref (image_map_tool->default_config);
image_map_tool->default_config = NULL;
g_object_unref (im_tool->config);
im_tool->config = NULL;
}
if (image_map_tool->title)
if (im_tool->default_config)
{
g_free (image_map_tool->title);
image_map_tool->title = NULL;
g_object_unref (im_tool->default_config);
im_tool->default_config = NULL;
}
if (image_map_tool->description)
if (im_tool->title)
{
g_free (image_map_tool->description);
image_map_tool->description = NULL;
g_free (im_tool->title);
im_tool->title = NULL;
}
if (image_map_tool->undo_desc)
if (im_tool->description)
{
g_free (image_map_tool->undo_desc);
image_map_tool->undo_desc = NULL;
g_free (im_tool->description);
im_tool->description = NULL;
}
if (image_map_tool->icon_name)
if (im_tool->undo_desc)
{
g_free (image_map_tool->icon_name);
image_map_tool->icon_name = NULL;
g_free (im_tool->undo_desc);
im_tool->undo_desc = NULL;
}
if (image_map_tool->help_id)
if (im_tool->icon_name)
{
g_free (image_map_tool->help_id);
image_map_tool->help_id = NULL;
g_free (im_tool->icon_name);
im_tool->icon_name = NULL;
}
if (image_map_tool->label_group)
if (im_tool->help_id)
{
g_object_unref (image_map_tool->label_group);
image_map_tool->label_group = NULL;
g_free (im_tool->help_id);
im_tool->help_id = NULL;
}
if (image_map_tool->gui)
if (im_tool->gui)
{
g_object_unref (image_map_tool->gui);
image_map_tool->gui = NULL;
image_map_tool->settings_box = NULL;
g_object_unref (im_tool->gui);
im_tool->gui = NULL;
im_tool->settings_box = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
......@@ -297,13 +291,13 @@ gimp_image_map_tool_finalize (GObject *object)
static void
gamma_hack (GtkToggleButton *button,
GimpImageMapTool *image_map_tool)
GimpImageMapTool *im_tool)
{
if (image_map_tool->image_map)
if (im_tool->image_map)
{
gimp_image_map_set_gamma_hack (image_map_tool->image_map,
gimp_image_map_set_gamma_hack (im_tool->image_map,
gtk_toggle_button_get_active (button));
gimp_image_map_tool_preview (image_map_tool);
gimp_image_map_tool_preview (im_tool);
}
}
......@@ -1001,51 +995,40 @@ gimp_image_map_tool_edit_as (GimpImageMapTool *im_tool,
}
GtkWidget *
gimp_image_map_tool_dialog_get_vbox (GimpImageMapTool *tool)
{
g_return_val_if_fail (GIMP_IS_IMAGE_MAP_TOOL (tool), NULL);
return gimp_tool_gui_get_vbox (tool->gui);
}
GtkSizeGroup *
gimp_image_map_tool_dialog_get_label_group (GimpImageMapTool *tool)
gimp_image_map_tool_dialog_get_vbox (GimpImageMapTool *im_tool)
{
g_return_val_if_fail (GIMP_IS_IMAGE_MAP_TOOL (tool), NULL);
g_return_val_if_fail (GIMP_IS_IMAGE_MAP_TOOL (im_tool), NULL);
if (! tool->label_group)
tool->label_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
return tool->label_group;
return gimp_tool_gui_get_vbox (im_tool->gui);
}
static void
gimp_image_map_tool_color_picker_toggled (GtkWidget *widget,
GimpImageMapTool *tool)
GimpImageMapTool *im_tool)
{
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
{
if (tool->active_picker == widget)
if (im_tool->active_picker == widget)
return;
if (tool->active_picker)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tool->active_picker),
if (im_tool->active_picker)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (im_tool->active_picker),
FALSE);
tool->active_picker = widget;
im_tool->active_picker = widget;
gimp_color_tool_enable (GIMP_COLOR_TOOL (tool),
GIMP_COLOR_TOOL_GET_OPTIONS (tool));
gimp_color_tool_enable (GIMP_COLOR_TOOL (im_tool),
GIMP_COLOR_TOOL_GET_OPTIONS (im_tool));
}
else if (tool->active_picker == widget)
else if (im_tool->active_picker == widget)
{
tool->active_picker = NULL;
gimp_color_tool_disable (GIMP_COLOR_TOOL (tool));
im_tool->active_picker = NULL;
gimp_color_tool_disable (GIMP_COLOR_TOOL (im_tool));
}
}
GtkWidget *
gimp_image_map_tool_add_color_picker (GimpImageMapTool *tool,
gimp_image_map_tool_add_color_picker (GimpImageMapTool *im_tool,
gpointer identifier,
const gchar *icon_name,
const gchar *tooltip)
......@@ -1053,7 +1036,7 @@ gimp_image_map_tool_add_color_picker (GimpImageMapTool *tool,
GtkWidget *button;
GtkWidget *image;
g_return_val_if_fail (GIMP_IS_IMAGE_MAP_TOOL (tool), NULL);
g_return_val_if_fail (GIMP_IS_IMAGE_MAP_TOOL (im_tool), NULL);
g_return_val_if_fail (icon_name != NULL, NULL);
button = g_object_new (GTK_TYPE_TOGGLE_BUTTON,
......@@ -1072,7 +1055,7 @@ gimp_image_map_tool_add_color_picker (GimpImageMapTool *tool,
g_signal_connect (button, "toggled",
G_CALLBACK (gimp_image_map_tool_color_picker_toggled),
tool);
im_tool);
return button;
}
......@@ -57,7 +57,6 @@ struct _GimpImageMapTool
GimpToolGui *gui;
GtkWidget *settings_box;
GtkWidget *region_combo;
GtkSizeGroup *label_group;
GtkWidget *active_picker;
};
......@@ -72,7 +71,7 @@ struct _GimpImageMapToolClass
GimpContainer *recent_settings;
/* virtual functions */
gchar * (* get_operation) (GimpImageMapTool *image_map_tool,
gchar * (* get_operation) (GimpImageMapTool *im_tool,
gchar **title,
gchar **description,
gchar **undo_desc,
......@@ -81,7 +80,7 @@ struct _GimpImageMapToolClass
void (* dialog) (GimpImageMapTool *image_map_tool);
void (* reset) (GimpImageMapTool *image_map_tool);
GtkWidget * (* get_settings_ui) (GimpImageMapTool *image_map_tool,
GtkWidget * (* get_settings_ui) (GimpImageMapTool *im_tool,
GimpContainer *settings,
GFile *settings_file,
const gchar *import_dialog_title,
......@@ -90,14 +89,14 @@ struct _GimpImageMapToolClass
GFile *default_folder,
GtkWidget **settings_box);
gboolean (* settings_import) (GimpImageMapTool *image_map_tool,
gboolean (* settings_import) (GimpImageMapTool *im_tool,
GInputStream *input,
GError **error);
gboolean (* settings_export) (GimpImageMapTool *image_map_tool,
gboolean (* settings_export) (GimpImageMapTool *im_tool,
GOutputStream *output,
GError **error);
void (* color_picked) (GimpImageMapTool *image_map_tool,
void (* color_picked) (GimpImageMapTool *im_tool,
gpointer identifier,
gdouble x,
gdouble y,
......@@ -106,24 +105,23 @@ struct _GimpImageMapToolClass
};
GType gimp_image_map_tool_get_type (void) G_GNUC_CONST;
GType gimp_image_map_tool_get_type (void) G_GNUC_CONST;
void gimp_image_map_tool_preview (GimpImageMapTool *image_map_tool);
void gimp_image_map_tool_preview (GimpImageMapTool *im_tool);
void gimp_image_map_tool_get_operation (GimpImageMapTool *image_map_tool);
void gimp_image_map_tool_get_operation (GimpImageMapTool *im_tool);
void gimp_image_map_tool_edit_as (GimpImageMapTool *image_map_tool,
const gchar *new_tool_id,
GimpConfig *config);
void gimp_image_map_tool_edit_as (GimpImageMapTool *im_tool,
const gchar *new_tool_id,
GimpConfig *config);
/* accessors for derived classes */
GtkWidget * gimp_image_map_tool_dialog_get_vbox (GimpImageMapTool *tool);
GtkSizeGroup * gimp_image_map_tool_dialog_get_label_group (GimpImageMapTool *tool);
GtkWidget * gimp_image_map_tool_dialog_get_vbox (GimpImageMapTool *im_tool);
GtkWidget * gimp_image_map_tool_add_color_picker (GimpImageMapTool *tool,
gpointer identifier,
const gchar *icon_name,
const gchar *tooltip);
GtkWidget * gimp_image_map_tool_add_color_picker (GimpImageMapTool *im_tool,
gpointer identifier,
const gchar *icon_name,
const gchar *tooltip);
#endif /* __GIMP_IMAGE_MAP_TOOL_H__ */
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