mirror of https://github.com/GNOME/gimp.git
app: add gimp_tool_gui_add_button()
In GimpToolGui, add gimp_tool_gui_add_button() and gimp_tool_gui_add_buttons_valist(), which allow adding dialog buttons after construction.
This commit is contained in:
parent
31b2b55b28
commit
b23fae86f0
|
@ -84,27 +84,29 @@ struct _GimpToolGuiPrivate
|
||||||
#define GET_PRIVATE(gui) ((GimpToolGuiPrivate *) gimp_tool_gui_get_instance_private ((GimpToolGui *) (gui)))
|
#define GET_PRIVATE(gui) ((GimpToolGuiPrivate *) gimp_tool_gui_get_instance_private ((GimpToolGui *) (gui)))
|
||||||
|
|
||||||
|
|
||||||
static void gimp_tool_gui_dispose (GObject *object);
|
static void gimp_tool_gui_dispose (GObject *object);
|
||||||
static void gimp_tool_gui_finalize (GObject *object);
|
static void gimp_tool_gui_finalize (GObject *object);
|
||||||
|
|
||||||
static void gimp_tool_gui_create_dialog (GimpToolGui *gui,
|
static void gimp_tool_gui_create_dialog (GimpToolGui *gui,
|
||||||
GdkMonitor *monitor);
|
GdkMonitor *monitor);
|
||||||
static void gimp_tool_gui_update_buttons (GimpToolGui *gui);
|
static void gimp_tool_gui_add_dialog_button (GimpToolGui *gui,
|
||||||
static void gimp_tool_gui_update_shell (GimpToolGui *gui);
|
ResponseEntry *entry);
|
||||||
static void gimp_tool_gui_update_viewable (GimpToolGui *gui);
|
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,
|
static void gimp_tool_gui_dialog_response (GtkWidget *dialog,
|
||||||
gint response_id,
|
gint response_id,
|
||||||
GimpToolGui *gui);
|
GimpToolGui *gui);
|
||||||
static void gimp_tool_gui_canvas_resized (GtkWidget *canvas,
|
static void gimp_tool_gui_canvas_resized (GtkWidget *canvas,
|
||||||
GtkAllocation *allocation,
|
GtkAllocation *allocation,
|
||||||
GimpToolGui *gui);
|
GimpToolGui *gui);
|
||||||
|
|
||||||
static ResponseEntry * response_entry_new (gint response_id,
|
static ResponseEntry * response_entry_new (gint response_id,
|
||||||
const gchar *button_text);
|
const gchar *button_text);
|
||||||
static void response_entry_free (ResponseEntry *entry);
|
static void response_entry_free (ResponseEntry *entry);
|
||||||
static ResponseEntry * response_entry_find (GList *entries,
|
static ResponseEntry * response_entry_find (GList *entries,
|
||||||
gint response_id);
|
gint response_id);
|
||||||
|
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_PRIVATE (GimpToolGui, gimp_tool_gui, GIMP_TYPE_OBJECT)
|
G_DEFINE_TYPE_WITH_PRIVATE (GimpToolGui, gimp_tool_gui, GIMP_TYPE_OBJECT)
|
||||||
|
@ -252,16 +254,7 @@ gimp_tool_gui_new (GimpToolInfo *tool_info,
|
||||||
|
|
||||||
va_start (args, overlay);
|
va_start (args, overlay);
|
||||||
|
|
||||||
for (button_text = va_arg (args, const gchar *);
|
gimp_tool_gui_add_buttons_valist (gui, args);
|
||||||
button_text;
|
|
||||||
button_text = va_arg (args, const gchar *))
|
|
||||||
{
|
|
||||||
gint response_id = va_arg (args, gint);
|
|
||||||
|
|
||||||
private->response_entries = g_list_append (private->response_entries,
|
|
||||||
response_entry_new (response_id,
|
|
||||||
button_text));
|
|
||||||
}
|
|
||||||
|
|
||||||
va_end (args);
|
va_end (args);
|
||||||
|
|
||||||
|
@ -634,6 +627,45 @@ gimp_tool_gui_get_focus_on_map (GimpToolGui *gui)
|
||||||
return GET_PRIVATE (gui)->focus_on_map;
|
return GET_PRIVATE (gui)->focus_on_map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gimp_tool_gui_add_buttons_valist (GimpToolGui *gui,
|
||||||
|
va_list args)
|
||||||
|
{
|
||||||
|
const gchar *button_text;
|
||||||
|
gint response_id;
|
||||||
|
|
||||||
|
g_return_if_fail (GIMP_IS_TOOL_GUI (gui));
|
||||||
|
|
||||||
|
while ((button_text = va_arg (args, const gchar *)))
|
||||||
|
{
|
||||||
|
response_id = va_arg (args, gint);
|
||||||
|
|
||||||
|
gimp_tool_gui_add_button (gui, button_text, response_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gimp_tool_gui_add_button (GimpToolGui *gui,
|
||||||
|
const gchar *button_text,
|
||||||
|
gint response_id)
|
||||||
|
{
|
||||||
|
GimpToolGuiPrivate *private;
|
||||||
|
ResponseEntry *entry;
|
||||||
|
|
||||||
|
g_return_if_fail (GIMP_IS_TOOL_GUI (gui));
|
||||||
|
g_return_if_fail (button_text != NULL);
|
||||||
|
|
||||||
|
private = GET_PRIVATE (gui);
|
||||||
|
|
||||||
|
entry = response_entry_new (response_id, button_text);
|
||||||
|
|
||||||
|
private->response_entries = g_list_append (private->response_entries,
|
||||||
|
entry);
|
||||||
|
|
||||||
|
if (private->dialog)
|
||||||
|
gimp_tool_gui_add_dialog_button (gui, entry);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gimp_tool_gui_set_default_response (GimpToolGui *gui,
|
gimp_tool_gui_set_default_response (GimpToolGui *gui,
|
||||||
gint response_id)
|
gint response_id)
|
||||||
|
@ -743,14 +775,7 @@ gimp_tool_gui_create_dialog (GimpToolGui *gui,
|
||||||
{
|
{
|
||||||
ResponseEntry *entry = list->data;
|
ResponseEntry *entry = list->data;
|
||||||
|
|
||||||
gimp_overlay_dialog_add_button (GIMP_OVERLAY_DIALOG (private->dialog),
|
gimp_tool_gui_add_dialog_button (gui, entry);
|
||||||
entry->button_text,
|
|
||||||
entry->response_id);
|
|
||||||
|
|
||||||
if (! entry->sensitive)
|
|
||||||
gimp_overlay_dialog_set_response_sensitive (GIMP_OVERLAY_DIALOG (private->dialog),
|
|
||||||
entry->response_id,
|
|
||||||
FALSE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (private->default_response != -1)
|
if (private->default_response != -1)
|
||||||
|
@ -777,14 +802,7 @@ gimp_tool_gui_create_dialog (GimpToolGui *gui,
|
||||||
{
|
{
|
||||||
ResponseEntry *entry = list->data;
|
ResponseEntry *entry = list->data;
|
||||||
|
|
||||||
gimp_dialog_add_button (GIMP_DIALOG (private->dialog),
|
gimp_tool_gui_add_dialog_button (gui, entry);
|
||||||
entry->button_text,
|
|
||||||
entry->response_id);
|
|
||||||
|
|
||||||
if (! entry->sensitive)
|
|
||||||
gtk_dialog_set_response_sensitive (GTK_DIALOG (private->dialog),
|
|
||||||
entry->response_id,
|
|
||||||
FALSE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (private->default_response != -1)
|
if (private->default_response != -1)
|
||||||
|
@ -813,6 +831,38 @@ gimp_tool_gui_create_dialog (GimpToolGui *gui,
|
||||||
G_OBJECT (gui), 0);
|
G_OBJECT (gui), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_tool_gui_add_dialog_button (GimpToolGui *gui,
|
||||||
|
ResponseEntry *entry)
|
||||||
|
{
|
||||||
|
GimpToolGuiPrivate *private = GET_PRIVATE (gui);
|
||||||
|
|
||||||
|
if (private->overlay)
|
||||||
|
{
|
||||||
|
gimp_overlay_dialog_add_button (GIMP_OVERLAY_DIALOG (private->dialog),
|
||||||
|
entry->button_text,
|
||||||
|
entry->response_id);
|
||||||
|
|
||||||
|
if (! entry->sensitive)
|
||||||
|
{
|
||||||
|
gimp_overlay_dialog_set_response_sensitive (
|
||||||
|
GIMP_OVERLAY_DIALOG (private->dialog),
|
||||||
|
entry->response_id, FALSE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gimp_dialog_add_button (GIMP_DIALOG (private->dialog),
|
||||||
|
entry->button_text,
|
||||||
|
entry->response_id);
|
||||||
|
|
||||||
|
if (! entry->sensitive)
|
||||||
|
gtk_dialog_set_response_sensitive (GTK_DIALOG (private->dialog),
|
||||||
|
entry->response_id,
|
||||||
|
FALSE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_tool_gui_update_buttons (GimpToolGui *gui)
|
gimp_tool_gui_update_buttons (GimpToolGui *gui)
|
||||||
{
|
{
|
||||||
|
|
|
@ -95,6 +95,12 @@ void gimp_tool_gui_set_focus_on_map (GimpToolGui *gui,
|
||||||
gboolean focus_on_map);
|
gboolean focus_on_map);
|
||||||
gboolean gimp_tool_gui_get_focus_on_map (GimpToolGui *gui);
|
gboolean gimp_tool_gui_get_focus_on_map (GimpToolGui *gui);
|
||||||
|
|
||||||
|
|
||||||
|
void gimp_tool_gui_add_buttons_valist (GimpToolGui *gui,
|
||||||
|
va_list args);
|
||||||
|
void gimp_tool_gui_add_button (GimpToolGui *gui,
|
||||||
|
const gchar *button_text,
|
||||||
|
gint response_id);
|
||||||
void gimp_tool_gui_set_default_response (GimpToolGui *gui,
|
void gimp_tool_gui_set_default_response (GimpToolGui *gui,
|
||||||
gint response_id);
|
gint response_id);
|
||||||
void gimp_tool_gui_set_response_sensitive (GimpToolGui *gui,
|
void gimp_tool_gui_set_response_sensitive (GimpToolGui *gui,
|
||||||
|
|
Loading…
Reference in New Issue