mirror of https://github.com/GNOME/gimp.git
app: add "response" signal to GimpToolGui
and connect to it instead of to gimp_tool_gui_get_dialog()'s signal. One more step towards on-the-fly embedding/detaching.
This commit is contained in:
parent
e7bb2805c2
commit
ad8d12ed69
|
@ -28,6 +28,7 @@
|
|||
#include "display-types.h"
|
||||
|
||||
#include "core/gimpcontext.h"
|
||||
#include "core/gimpmarshal.h"
|
||||
#include "core/gimptoolinfo.h"
|
||||
|
||||
#include "widgets/gimpdialogfactory.h"
|
||||
|
@ -39,6 +40,13 @@
|
|||
#include "gimptoolgui.h"
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
RESPONSE,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
|
||||
typedef struct _ResponseEntry ResponseEntry;
|
||||
|
||||
struct _ResponseEntry
|
||||
|
@ -80,6 +88,10 @@ static void gimp_tool_gui_update_buttons (GimpToolGui *gui);
|
|||
static void gimp_tool_gui_update_shell (GimpToolGui *gui);
|
||||
static void gimp_tool_gui_update_viewable (GimpToolGui *gui);
|
||||
|
||||
static void gimp_tool_gui_dialog_response (GtkWidget *dialog,
|
||||
gint response_id,
|
||||
GimpToolGui *gui);
|
||||
|
||||
static ResponseEntry * response_entry_new (gint response_id,
|
||||
const gchar *stock_id);
|
||||
static void response_entry_free (ResponseEntry *entry);
|
||||
|
@ -89,6 +101,10 @@ static ResponseEntry * response_entry_find (GList *entries,
|
|||
|
||||
G_DEFINE_TYPE (GimpToolGui, gimp_tool_gui, GIMP_TYPE_OBJECT)
|
||||
|
||||
static guint signals[LAST_SIGNAL] = { 0, };
|
||||
|
||||
#define parent_class gimp_tool_gui_parent_class
|
||||
|
||||
|
||||
static void
|
||||
gimp_tool_gui_class_init (GimpToolGuiClass *klass)
|
||||
|
@ -98,6 +114,16 @@ gimp_tool_gui_class_init (GimpToolGuiClass *klass)
|
|||
object_class->dispose = gimp_tool_gui_dispose;
|
||||
object_class->finalize = gimp_tool_gui_finalize;
|
||||
|
||||
signals[RESPONSE] =
|
||||
g_signal_new ("response",
|
||||
G_OBJECT_CLASS_TYPE (klass),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (GimpToolGuiClass, response),
|
||||
NULL, NULL,
|
||||
gimp_marshal_VOID__INT,
|
||||
G_TYPE_NONE, 1,
|
||||
G_TYPE_INT);
|
||||
|
||||
g_type_class_add_private (klass, sizeof (GimpToolGuiPrivate));
|
||||
}
|
||||
|
||||
|
@ -142,7 +168,7 @@ gimp_tool_gui_dispose (GObject *object)
|
|||
private->dialog = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (gimp_tool_gui_parent_class)->dispose (object);
|
||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -163,7 +189,7 @@ gimp_tool_gui_finalize (GObject *object)
|
|||
private->response_entries = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (gimp_tool_gui_parent_class)->finalize (object);
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
|
||||
|
@ -533,6 +559,10 @@ gimp_tool_gui_create_dialog (GimpToolGui *gui)
|
|||
|
||||
if (private->viewable)
|
||||
gimp_tool_gui_update_viewable (gui);
|
||||
|
||||
g_signal_connect_object (private->dialog, "response",
|
||||
G_CALLBACK (gimp_tool_gui_dialog_response),
|
||||
G_OBJECT (gui), 0);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -598,6 +628,15 @@ gimp_tool_gui_update_viewable (GimpToolGui *gui)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_tool_gui_dialog_response (GtkWidget *dialog,
|
||||
gint response_id,
|
||||
GimpToolGui *gui)
|
||||
{
|
||||
g_signal_emit (gui, signals[RESPONSE], 0,
|
||||
response_id);
|
||||
}
|
||||
|
||||
static ResponseEntry *
|
||||
response_entry_new (gint response_id,
|
||||
const gchar *stock_id)
|
||||
|
|
|
@ -43,6 +43,10 @@ struct _GimpToolGui
|
|||
struct _GimpToolGuiClass
|
||||
{
|
||||
GimpObjectClass parent_instance;
|
||||
|
||||
void (* response) (GimpToolGui *gui,
|
||||
gint response_id);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ static void gimp_color_picker_tool_picked (GimpColorTool *color_t
|
|||
gint color_index);
|
||||
|
||||
static void gimp_color_picker_tool_info_create (GimpColorPickerTool *picker_tool);
|
||||
static void gimp_color_picker_tool_info_response (GtkWidget *widget,
|
||||
static void gimp_color_picker_tool_info_response (GimpToolGui *gui,
|
||||
gint response_id,
|
||||
GimpColorPickerTool *picker_tool);
|
||||
static void gimp_color_picker_tool_info_update (GimpColorPickerTool *picker_tool,
|
||||
|
@ -327,7 +327,7 @@ gimp_color_picker_tool_info_create (GimpColorPickerTool *picker_tool)
|
|||
gimp_tool_gui_set_viewable (picker_tool->gui,
|
||||
GIMP_VIEWABLE (tool->drawable));
|
||||
|
||||
g_signal_connect (dialog, "response",
|
||||
g_signal_connect (picker_tool->gui, "response",
|
||||
G_CALLBACK (gimp_color_picker_tool_info_response),
|
||||
picker_tool);
|
||||
|
||||
|
@ -368,7 +368,7 @@ gimp_color_picker_tool_info_create (GimpColorPickerTool *picker_tool)
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_color_picker_tool_info_response (GtkWidget *widget,
|
||||
gimp_color_picker_tool_info_response (GimpToolGui *gui,
|
||||
gint response_id,
|
||||
GimpColorPickerTool *picker_tool)
|
||||
{
|
||||
|
|
|
@ -117,7 +117,7 @@ static void gimp_image_map_tool_config_notify (GObject *object,
|
|||
const GParamSpec *pspec,
|
||||
GimpImageMapTool *im_tool);
|
||||
|
||||
static void gimp_image_map_tool_response (GtkWidget *widget,
|
||||
static void gimp_image_map_tool_response (GimpToolGui *gui,
|
||||
gint response_id,
|
||||
GimpImageMapTool *im_tool);
|
||||
|
||||
|
@ -316,7 +316,6 @@ gimp_image_map_tool_initialize (GimpTool *tool,
|
|||
if (! image_map_tool->gui)
|
||||
{
|
||||
GimpImageMapToolClass *klass;
|
||||
GtkWidget *dialog;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *toggle;
|
||||
|
||||
|
@ -344,10 +343,9 @@ gimp_image_map_tool_initialize (GimpTool *tool,
|
|||
GTK_RESPONSE_CANCEL,
|
||||
-1);
|
||||
|
||||
dialog = gimp_tool_gui_get_dialog (image_map_tool->gui);
|
||||
vbox = gimp_tool_gui_get_vbox (image_map_tool->gui);
|
||||
vbox = gimp_tool_gui_get_vbox (image_map_tool->gui);
|
||||
|
||||
g_signal_connect_object (dialog, "response",
|
||||
g_signal_connect_object (image_map_tool->gui, "response",
|
||||
G_CALLBACK (gimp_image_map_tool_response),
|
||||
G_OBJECT (image_map_tool), 0);
|
||||
|
||||
|
@ -448,26 +446,24 @@ gimp_image_map_tool_key_press (GimpTool *tool,
|
|||
|
||||
if (image_map_tool->gui && display == tool->display)
|
||||
{
|
||||
GtkWidget *dialog = gimp_tool_gui_get_dialog (image_map_tool->gui);
|
||||
|
||||
switch (kevent->keyval)
|
||||
{
|
||||
case GDK_KEY_Return:
|
||||
case GDK_KEY_KP_Enter:
|
||||
case GDK_KEY_ISO_Enter:
|
||||
gimp_image_map_tool_response (dialog,
|
||||
gimp_image_map_tool_response (image_map_tool->gui,
|
||||
GTK_RESPONSE_OK,
|
||||
image_map_tool);
|
||||
return TRUE;
|
||||
|
||||
case GDK_KEY_BackSpace:
|
||||
gimp_image_map_tool_response (dialog,
|
||||
gimp_image_map_tool_response (image_map_tool->gui,
|
||||
RESPONSE_RESET,
|
||||
image_map_tool);
|
||||
return TRUE;
|
||||
|
||||
case GDK_KEY_Escape:
|
||||
gimp_image_map_tool_response (dialog,
|
||||
gimp_image_map_tool_response (image_map_tool->gui,
|
||||
GTK_RESPONSE_CANCEL,
|
||||
image_map_tool);
|
||||
return TRUE;
|
||||
|
@ -651,7 +647,7 @@ gimp_image_map_tool_config_notify (GObject *object,
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_image_map_tool_response (GtkWidget *widget,
|
||||
gimp_image_map_tool_response (GimpToolGui *gui,
|
||||
gint response_id,
|
||||
GimpImageMapTool *image_map_tool)
|
||||
{
|
||||
|
|
|
@ -1058,9 +1058,9 @@ gimp_measure_tool_dialog_new (GimpMeasureTool *measure)
|
|||
if (GTK_IS_DIALOG (dialog))
|
||||
gtk_window_set_focus_on_map (GTK_WINDOW (dialog), FALSE);
|
||||
|
||||
g_signal_connect_swapped (dialog, "response",
|
||||
G_CALLBACK (g_object_unref),
|
||||
gui);
|
||||
g_signal_connect (gui, "response",
|
||||
G_CALLBACK (g_object_unref),
|
||||
NULL);
|
||||
|
||||
table = gtk_table_new (4, 5, TRUE);
|
||||
gtk_table_set_col_spacings (GTK_TABLE (table), 6);
|
||||
|
|
|
@ -162,7 +162,7 @@ static void gimp_transform_tool_handles_recalc (GimpTransformTool
|
|||
GimpDisplay *display,
|
||||
gint *handle_w,
|
||||
gint *handle_h);
|
||||
static void gimp_transform_tool_response (GtkWidget *widget,
|
||||
static void gimp_transform_tool_response (GimpToolGui *gui,
|
||||
gint response_id,
|
||||
GimpTransformTool *tr_tool);
|
||||
|
||||
|
@ -1709,7 +1709,7 @@ gimp_transform_tool_dialog (GimpTransformTool *tr_tool)
|
|||
GTK_RESPONSE_CANCEL,
|
||||
-1);
|
||||
|
||||
g_signal_connect (gimp_tool_gui_get_dialog (tr_tool->gui), "response",
|
||||
g_signal_connect (tr_tool->gui, "response",
|
||||
G_CALLBACK (gimp_transform_tool_response),
|
||||
tr_tool);
|
||||
|
||||
|
@ -1750,7 +1750,7 @@ gimp_transform_tool_recalc_matrix (GimpTransformTool *tr_tool)
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_transform_tool_response (GtkWidget *widget,
|
||||
gimp_transform_tool_response (GimpToolGui *gui,
|
||||
gint response_id,
|
||||
GimpTransformTool *tr_tool)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue