mirror of https://github.com/GNOME/gimp.git
app: add a "detach" button to all on-canvas tool dialogs
which turns them from being automatically attached/detached (depending on canvas size) into always being a separate window.
This commit is contained in:
parent
34c788d34e
commit
072cb068b2
|
@ -810,8 +810,19 @@ gimp_tool_gui_dialog_response (GtkWidget *dialog,
|
|||
gint response_id,
|
||||
GimpToolGui *gui)
|
||||
{
|
||||
g_signal_emit (gui, signals[RESPONSE], 0,
|
||||
response_id);
|
||||
if (response_id == GIMP_RESPONSE_DETACH)
|
||||
{
|
||||
gimp_tool_gui_set_auto_overlay (gui, FALSE);
|
||||
gimp_tool_gui_set_overlay (gui,
|
||||
gtk_widget_get_screen (dialog),
|
||||
gimp_widget_get_monitor (dialog),
|
||||
FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_signal_emit (gui, signals[RESPONSE], 0,
|
||||
response_id);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
|
||||
#include "gimpoverlaydialog.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -44,6 +46,7 @@ enum
|
|||
enum
|
||||
{
|
||||
RESPONSE,
|
||||
DETACH,
|
||||
CLOSE,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
@ -79,6 +82,9 @@ static void gimp_overlay_dialog_forall (GtkContainer *containe
|
|||
GtkCallback callback,
|
||||
gpointer callback_data);
|
||||
|
||||
static void gimp_overlay_dialog_detach (GimpOverlayDialog *dialog);
|
||||
static void gimp_overlay_dialog_real_detach (GimpOverlayDialog *dialog);
|
||||
|
||||
static void gimp_overlay_dialog_close (GimpOverlayDialog *dialog);
|
||||
static void gimp_overlay_dialog_real_close (GimpOverlayDialog *dialog);
|
||||
|
||||
|
@ -112,6 +118,7 @@ gimp_overlay_dialog_class_init (GimpOverlayDialogClass *klass)
|
|||
|
||||
container_class->forall = gimp_overlay_dialog_forall;
|
||||
|
||||
klass->detach = gimp_overlay_dialog_real_detach;
|
||||
klass->close = gimp_overlay_dialog_real_close;
|
||||
|
||||
g_object_class_install_property (object_class, PROP_TITLE,
|
||||
|
@ -138,6 +145,15 @@ gimp_overlay_dialog_class_init (GimpOverlayDialogClass *klass)
|
|||
G_TYPE_NONE, 1,
|
||||
G_TYPE_INT);
|
||||
|
||||
signals[DETACH] =
|
||||
g_signal_new ("detach",
|
||||
G_OBJECT_CLASS_TYPE (klass),
|
||||
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
|
||||
G_STRUCT_OFFSET (GimpOverlayDialogClass, detach),
|
||||
NULL, NULL,
|
||||
gimp_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
signals[CLOSE] =
|
||||
g_signal_new ("close",
|
||||
G_OBJECT_CLASS_TYPE (klass),
|
||||
|
@ -202,6 +218,26 @@ gimp_overlay_dialog_constructed (GObject *object)
|
|||
G_CALLBACK (gimp_overlay_dialog_close),
|
||||
G_OBJECT (dialog),
|
||||
G_CONNECT_SWAPPED);
|
||||
|
||||
dialog->detach_button = button = gtk_button_new ();
|
||||
gtk_widget_set_can_focus (button, FALSE);
|
||||
gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
|
||||
gtk_box_pack_end (GTK_BOX (dialog->header), button, FALSE, FALSE, 0);
|
||||
gtk_widget_show (button);
|
||||
|
||||
gimp_help_set_help_data (dialog->close_button,
|
||||
_("Detach dialog from canvas"), NULL);
|
||||
|
||||
image = gtk_image_new_from_icon_name (GIMP_STOCK_MENU_LEFT,
|
||||
GTK_ICON_SIZE_MENU);
|
||||
gtk_image_set_pixel_size (GTK_IMAGE (image), 12);
|
||||
gtk_container_add (GTK_CONTAINER (button), image);
|
||||
gtk_widget_show (image);
|
||||
|
||||
g_signal_connect_object (button, "clicked",
|
||||
G_CALLBACK (gimp_overlay_dialog_detach),
|
||||
G_OBJECT (dialog),
|
||||
G_CONNECT_SWAPPED);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -410,6 +446,18 @@ gimp_overlay_dialog_forall (GtkContainer *container,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_overlay_dialog_detach (GimpOverlayDialog *dialog)
|
||||
{
|
||||
g_signal_emit (dialog, signals[DETACH], 0);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_overlay_dialog_real_detach (GimpOverlayDialog *dialog)
|
||||
{
|
||||
gimp_overlay_dialog_response (dialog, GIMP_RESPONSE_DETACH);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_overlay_dialog_close (GimpOverlayDialog *dialog)
|
||||
{
|
||||
|
@ -497,7 +545,8 @@ gimp_overlay_dialog_add_button (GimpOverlayDialog *dialog,
|
|||
g_return_val_if_fail (button_text != NULL, NULL);
|
||||
|
||||
if (response_id == GTK_RESPONSE_CANCEL ||
|
||||
response_id == GTK_RESPONSE_CLOSE)
|
||||
response_id == GTK_RESPONSE_CLOSE ||
|
||||
response_id == GIMP_RESPONSE_DETACH)
|
||||
return NULL;
|
||||
|
||||
button = gtk_button_new_from_stock (button_text);
|
||||
|
@ -557,6 +606,11 @@ gimp_overlay_dialog_set_response_sensitive (GimpOverlayDialog *overlay,
|
|||
gtk_widget_set_sensitive (overlay->close_button, sensitive);
|
||||
}
|
||||
|
||||
if (response_id == GIMP_RESPONSE_DETACH)
|
||||
{
|
||||
gtk_widget_set_sensitive (overlay->detach_button, sensitive);
|
||||
}
|
||||
|
||||
children = gtk_container_get_children (GTK_CONTAINER (overlay->action_area));
|
||||
|
||||
for (list = children; list; list = g_list_next (list))
|
||||
|
|
|
@ -25,6 +25,9 @@
|
|||
#include "gimpoverlayframe.h"
|
||||
|
||||
|
||||
#define GIMP_RESPONSE_DETACH 100
|
||||
|
||||
|
||||
#define GIMP_TYPE_OVERLAY_DIALOG (gimp_overlay_dialog_get_type ())
|
||||
#define GIMP_OVERLAY_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_OVERLAY_DIALOG, GimpOverlayDialog))
|
||||
#define GIMP_OVERLAY_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_OVERLAY_DIALOG, GimpOverlayDialogClass))
|
||||
|
@ -46,6 +49,7 @@ struct _GimpOverlayDialog
|
|||
GtkWidget *header;
|
||||
GtkWidget *icon_image;
|
||||
GtkWidget *title_label;
|
||||
GtkWidget *detach_button;
|
||||
GtkWidget *close_button;
|
||||
GtkWidget *action_area;
|
||||
};
|
||||
|
@ -57,6 +61,7 @@ struct _GimpOverlayDialogClass
|
|||
void (* response) (GimpOverlayDialog *overlay,
|
||||
gint response_id);
|
||||
|
||||
void (* detach) (GimpOverlayDialog *overlay);
|
||||
void (* close) (GimpOverlayDialog *overlay);
|
||||
};
|
||||
|
||||
|
|
|
@ -489,6 +489,7 @@ app/widgets/gimplanguagestore-parser.c
|
|||
app/widgets/gimplayertreeview.c
|
||||
app/widgets/gimpmenudock.c
|
||||
app/widgets/gimpmessagebox.c
|
||||
app/widgets/gimpoverlaydialog.c
|
||||
app/widgets/gimppaletteeditor.c
|
||||
app/widgets/gimppanedbox.c
|
||||
app/widgets/gimppdbdialog.c
|
||||
|
|
Loading…
Reference in New Issue