Commit e8cc9d1b authored by Michael Natterer's avatar Michael Natterer 😴

app: turn gimp_image_map_tool_add_settings_gui() into a virtual function

and change it to return the settings ui, not add it.
parent 8e31fdf3
......@@ -58,11 +58,13 @@ static gboolean gimp_image_map_tool_settings_export (GimpSettingsBox *box,
/* public functions */
gboolean
gimp_image_map_tool_add_settings_gui (GimpImageMapTool *image_map_tool)
GtkWidget *
gimp_image_map_tool_real_get_settings_ui (GimpImageMapTool *image_map_tool,
GtkWidget **settings_box)
{
GimpImageMapToolClass *klass;
GimpToolInfo *tool_info;
GtkSizeGroup *label_group;
GtkWidget *hbox;
GtkWidget *label;
GtkWidget *settings_combo;
......@@ -71,41 +73,39 @@ gimp_image_map_tool_add_settings_gui (GimpImageMapTool *image_map_tool)
klass = GIMP_IMAGE_MAP_TOOL_GET_CLASS (image_map_tool);
if (! klass->settings_name)
return NULL;
tool_info = GIMP_TOOL (image_map_tool)->tool_info;
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
gtk_box_pack_start (GTK_BOX (image_map_tool->main_vbox), hbox,
FALSE, FALSE, 0);
gtk_widget_show (hbox);
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);
image_map_tool->label_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
gtk_size_group_add_widget (image_map_tool->label_group, label);
g_object_unref (image_map_tool->label_group);
filename = gimp_tool_info_build_options_filename (tool_info, ".settings");
folder = g_build_filename (gimp_directory (), klass->settings_name, NULL);
image_map_tool->settings_box = gimp_settings_box_new (tool_info->gimp,
image_map_tool->config,
klass->recent_settings,
filename,
klass->import_dialog_title,
klass->export_dialog_title,
tool_info->help_id,
folder,
NULL);
gtk_box_pack_start (GTK_BOX (hbox), image_map_tool->settings_box,
TRUE, TRUE, 0);
gtk_widget_show (image_map_tool->settings_box);
*settings_box = gimp_settings_box_new (tool_info->gimp,
image_map_tool->config,
klass->recent_settings,
filename,
klass->import_dialog_title,
klass->export_dialog_title,
tool_info->help_id,
folder,
NULL);
gtk_box_pack_start (GTK_BOX (hbox), *settings_box, TRUE, TRUE, 0);
gtk_widget_show (*settings_box);
g_free (filename);
g_free (folder);
settings_combo = gimp_settings_box_get_combo (GIMP_SETTINGS_BOX (image_map_tool->settings_box));
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",
......@@ -116,7 +116,7 @@ gimp_image_map_tool_add_settings_gui (GimpImageMapTool *image_map_tool)
G_CALLBACK (gimp_image_map_tool_settings_export),
image_map_tool);
return TRUE;
return hbox;
}
gboolean
......
......@@ -21,14 +21,14 @@
#define __GIMP_IMAGE_MAP_TOOL_SETTINGS_H__
gboolean gimp_image_map_tool_add_settings_gui (GimpImageMapTool *image_map_tool);
gboolean gimp_image_map_tool_real_settings_import (GimpImageMapTool *tool,
const gchar *filename,
GError **error);
gboolean gimp_image_map_tool_real_settings_export (GimpImageMapTool *tool,
const gchar *filename,
GError **error);
GtkWidget * gimp_image_map_tool_real_get_settings_ui (GimpImageMapTool *tool,
GtkWidget **settings_box);
gboolean gimp_image_map_tool_real_settings_import (GimpImageMapTool *tool,
const gchar *filename,
GError **error);
gboolean gimp_image_map_tool_real_settings_export (GimpImageMapTool *tool,
const gchar *filename,
GError **error);
#endif /* __GIMP_IMAGE_MAP_TOOL_SETTINGS_H__ */
......@@ -178,6 +178,7 @@ gimp_image_map_tool_class_init (GimpImageMapToolClass *klass)
klass->map = NULL;
klass->dialog = NULL;
klass->reset = NULL;
klass->get_settings_ui = gimp_image_map_tool_real_get_settings_ui;
klass->settings_import = gimp_image_map_tool_real_settings_import;
klass->settings_export = gimp_image_map_tool_real_settings_export;
}
......@@ -296,6 +297,7 @@ gimp_image_map_tool_initialize (GimpTool *tool,
GtkWidget *dialog;
GtkWidget *vbox;
GtkWidget *toggle;
GtkWidget *settings_ui;
klass = GIMP_IMAGE_MAP_TOOL_GET_CLASS (image_map_tool);
......@@ -353,8 +355,15 @@ gimp_image_map_tool_initialize (GimpTool *tool,
G_CALLBACK (gimp_image_map_tool_response),
G_OBJECT (image_map_tool), 0);
if (klass->settings_name)
gimp_image_map_tool_add_settings_gui (image_map_tool);
settings_ui = klass->get_settings_ui (image_map_tool,
&image_map_tool->settings_box);
if (settings_ui)
{
gtk_box_pack_start (GTK_BOX (image_map_tool->main_vbox), settings_ui,
FALSE, FALSE, 0);
gtk_widget_show (settings_ui);
}
/* The preview toggle */
toggle = gimp_prop_check_button_new (G_OBJECT (tool_info->tool_options),
......@@ -693,6 +702,12 @@ gimp_image_map_tool_dialog_hide (GimpImageMapTool *image_map_tool)
static void
gimp_image_map_tool_dialog_destroy (GimpImageMapTool *image_map_tool)
{
if (image_map_tool->label_group)
{
g_object_unref (image_map_tool->label_group);
image_map_tool->label_group = NULL;
}
if (GTK_IS_DIALOG (image_map_tool->dialog) ||
gtk_widget_get_parent (image_map_tool->dialog))
gtk_widget_destroy (image_map_tool->dialog);
......@@ -702,7 +717,6 @@ gimp_image_map_tool_dialog_destroy (GimpImageMapTool *image_map_tool)
image_map_tool->dialog = NULL;
image_map_tool->main_vbox = NULL;
image_map_tool->settings_box = NULL;
image_map_tool->label_group = NULL;
}
void
......@@ -789,5 +803,8 @@ gimp_image_map_tool_dialog_get_label_group (GimpImageMapTool *tool)
{
g_return_val_if_fail (GIMP_IS_IMAGE_MAP_TOOL (tool), NULL);
if (! tool->label_group)
tool->label_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
return tool->label_group;
}
......@@ -66,18 +66,21 @@ struct _GimpImageMapToolClass
GimpContainer *recent_settings;
/* virtual functions */
GeglNode * (* get_operation) (GimpImageMapTool *image_map_tool,
GObject **config);
void (* map) (GimpImageMapTool *image_map_tool);
void (* dialog) (GimpImageMapTool *image_map_tool);
void (* reset) (GimpImageMapTool *image_map_tool);
gboolean (* settings_import) (GimpImageMapTool *image_map_tool,
const gchar *filename,
GError **error);
gboolean (* settings_export) (GimpImageMapTool *image_map_tool,
const gchar *filename,
GError **error);
GeglNode * (* get_operation) (GimpImageMapTool *image_map_tool,
GObject **config);
void (* map) (GimpImageMapTool *image_map_tool);
void (* dialog) (GimpImageMapTool *image_map_tool);
void (* reset) (GimpImageMapTool *image_map_tool);
GtkWidget * (* get_settings_ui) (GimpImageMapTool *image_map_tool,
GtkWidget **settings_box);
gboolean (* settings_import) (GimpImageMapTool *image_map_tool,
const gchar *filename,
GError **error);
gboolean (* settings_export) (GimpImageMapTool *image_map_tool,
const gchar *filename,
GError **error);
};
......
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