app: turn gimp_image_map_tool_add_settings_gui() into a virtual function
and change it to return the settings ui, not add it.
This commit is contained in:
@ -58,11 +58,13 @@ static gboolean gimp_image_map_tool_settings_export (GimpSettingsBox *box,
|
|||||||
|
|
||||||
/* public functions */
|
/* public functions */
|
||||||
|
|
||||||
gboolean
|
GtkWidget *
|
||||||
gimp_image_map_tool_add_settings_gui (GimpImageMapTool *image_map_tool)
|
gimp_image_map_tool_real_get_settings_ui (GimpImageMapTool *image_map_tool,
|
||||||
|
GtkWidget **settings_box)
|
||||||
{
|
{
|
||||||
GimpImageMapToolClass *klass;
|
GimpImageMapToolClass *klass;
|
||||||
GimpToolInfo *tool_info;
|
GimpToolInfo *tool_info;
|
||||||
|
GtkSizeGroup *label_group;
|
||||||
GtkWidget *hbox;
|
GtkWidget *hbox;
|
||||||
GtkWidget *label;
|
GtkWidget *label;
|
||||||
GtkWidget *settings_combo;
|
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);
|
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;
|
tool_info = GIMP_TOOL (image_map_tool)->tool_info;
|
||||||
|
|
||||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
||||||
gtk_box_pack_start (GTK_BOX (image_map_tool->main_vbox), hbox,
|
|
||||||
FALSE, FALSE, 0);
|
label_group = gimp_image_map_tool_dialog_get_label_group (image_map_tool);
|
||||||
gtk_widget_show (hbox);
|
|
||||||
|
|
||||||
label = gtk_label_new_with_mnemonic (_("Pre_sets:"));
|
label = gtk_label_new_with_mnemonic (_("Pre_sets:"));
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
||||||
|
gtk_size_group_add_widget (label_group, label);
|
||||||
gtk_widget_show (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");
|
filename = gimp_tool_info_build_options_filename (tool_info, ".settings");
|
||||||
folder = g_build_filename (gimp_directory (), klass->settings_name, NULL);
|
folder = g_build_filename (gimp_directory (), klass->settings_name, NULL);
|
||||||
|
|
||||||
image_map_tool->settings_box = gimp_settings_box_new (tool_info->gimp,
|
*settings_box = gimp_settings_box_new (tool_info->gimp,
|
||||||
image_map_tool->config,
|
image_map_tool->config,
|
||||||
klass->recent_settings,
|
klass->recent_settings,
|
||||||
filename,
|
filename,
|
||||||
klass->import_dialog_title,
|
klass->import_dialog_title,
|
||||||
klass->export_dialog_title,
|
klass->export_dialog_title,
|
||||||
tool_info->help_id,
|
tool_info->help_id,
|
||||||
folder,
|
folder,
|
||||||
NULL);
|
NULL);
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), image_map_tool->settings_box,
|
gtk_box_pack_start (GTK_BOX (hbox), *settings_box, TRUE, TRUE, 0);
|
||||||
TRUE, TRUE, 0);
|
gtk_widget_show (*settings_box);
|
||||||
gtk_widget_show (image_map_tool->settings_box);
|
|
||||||
|
|
||||||
g_free (filename);
|
g_free (filename);
|
||||||
g_free (folder);
|
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);
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), settings_combo);
|
||||||
|
|
||||||
g_signal_connect (image_map_tool->settings_box, "import",
|
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),
|
G_CALLBACK (gimp_image_map_tool_settings_export),
|
||||||
image_map_tool);
|
image_map_tool);
|
||||||
|
|
||||||
return TRUE;
|
return hbox;
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
|
@ -21,14 +21,14 @@
|
|||||||
#define __GIMP_IMAGE_MAP_TOOL_SETTINGS_H__
|
#define __GIMP_IMAGE_MAP_TOOL_SETTINGS_H__
|
||||||
|
|
||||||
|
|
||||||
gboolean gimp_image_map_tool_add_settings_gui (GimpImageMapTool *image_map_tool);
|
GtkWidget * gimp_image_map_tool_real_get_settings_ui (GimpImageMapTool *tool,
|
||||||
|
GtkWidget **settings_box);
|
||||||
gboolean gimp_image_map_tool_real_settings_import (GimpImageMapTool *tool,
|
gboolean gimp_image_map_tool_real_settings_import (GimpImageMapTool *tool,
|
||||||
const gchar *filename,
|
const gchar *filename,
|
||||||
GError **error);
|
GError **error);
|
||||||
gboolean gimp_image_map_tool_real_settings_export (GimpImageMapTool *tool,
|
gboolean gimp_image_map_tool_real_settings_export (GimpImageMapTool *tool,
|
||||||
const gchar *filename,
|
const gchar *filename,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
|
|
||||||
#endif /* __GIMP_IMAGE_MAP_TOOL_SETTINGS_H__ */
|
#endif /* __GIMP_IMAGE_MAP_TOOL_SETTINGS_H__ */
|
||||||
|
@ -178,6 +178,7 @@ gimp_image_map_tool_class_init (GimpImageMapToolClass *klass)
|
|||||||
klass->map = NULL;
|
klass->map = NULL;
|
||||||
klass->dialog = NULL;
|
klass->dialog = NULL;
|
||||||
klass->reset = 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_import = gimp_image_map_tool_real_settings_import;
|
||||||
klass->settings_export = gimp_image_map_tool_real_settings_export;
|
klass->settings_export = gimp_image_map_tool_real_settings_export;
|
||||||
}
|
}
|
||||||
@ -296,6 +297,7 @@ gimp_image_map_tool_initialize (GimpTool *tool,
|
|||||||
GtkWidget *dialog;
|
GtkWidget *dialog;
|
||||||
GtkWidget *vbox;
|
GtkWidget *vbox;
|
||||||
GtkWidget *toggle;
|
GtkWidget *toggle;
|
||||||
|
GtkWidget *settings_ui;
|
||||||
|
|
||||||
klass = GIMP_IMAGE_MAP_TOOL_GET_CLASS (image_map_tool);
|
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_CALLBACK (gimp_image_map_tool_response),
|
||||||
G_OBJECT (image_map_tool), 0);
|
G_OBJECT (image_map_tool), 0);
|
||||||
|
|
||||||
if (klass->settings_name)
|
settings_ui = klass->get_settings_ui (image_map_tool,
|
||||||
gimp_image_map_tool_add_settings_gui (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 */
|
/* The preview toggle */
|
||||||
toggle = gimp_prop_check_button_new (G_OBJECT (tool_info->tool_options),
|
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
|
static void
|
||||||
gimp_image_map_tool_dialog_destroy (GimpImageMapTool *image_map_tool)
|
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) ||
|
if (GTK_IS_DIALOG (image_map_tool->dialog) ||
|
||||||
gtk_widget_get_parent (image_map_tool->dialog))
|
gtk_widget_get_parent (image_map_tool->dialog))
|
||||||
gtk_widget_destroy (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->dialog = NULL;
|
||||||
image_map_tool->main_vbox = NULL;
|
image_map_tool->main_vbox = NULL;
|
||||||
image_map_tool->settings_box = NULL;
|
image_map_tool->settings_box = NULL;
|
||||||
image_map_tool->label_group = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
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);
|
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;
|
return tool->label_group;
|
||||||
}
|
}
|
||||||
|
@ -66,18 +66,21 @@ struct _GimpImageMapToolClass
|
|||||||
GimpContainer *recent_settings;
|
GimpContainer *recent_settings;
|
||||||
|
|
||||||
/* virtual functions */
|
/* virtual functions */
|
||||||
GeglNode * (* get_operation) (GimpImageMapTool *image_map_tool,
|
GeglNode * (* get_operation) (GimpImageMapTool *image_map_tool,
|
||||||
GObject **config);
|
GObject **config);
|
||||||
void (* map) (GimpImageMapTool *image_map_tool);
|
void (* map) (GimpImageMapTool *image_map_tool);
|
||||||
void (* dialog) (GimpImageMapTool *image_map_tool);
|
void (* dialog) (GimpImageMapTool *image_map_tool);
|
||||||
void (* reset) (GimpImageMapTool *image_map_tool);
|
void (* reset) (GimpImageMapTool *image_map_tool);
|
||||||
|
|
||||||
gboolean (* settings_import) (GimpImageMapTool *image_map_tool,
|
GtkWidget * (* get_settings_ui) (GimpImageMapTool *image_map_tool,
|
||||||
const gchar *filename,
|
GtkWidget **settings_box);
|
||||||
GError **error);
|
|
||||||
gboolean (* settings_export) (GimpImageMapTool *image_map_tool,
|
gboolean (* settings_import) (GimpImageMapTool *image_map_tool,
|
||||||
const gchar *filename,
|
const gchar *filename,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
gboolean (* settings_export) (GimpImageMapTool *image_map_tool,
|
||||||
|
const gchar *filename,
|
||||||
|
GError **error);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user