mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-09 18:30:08 +00:00
Dialog widget
This commit is contained in:
parent
99ee206642
commit
c9a3d32f83
@ -1,3 +1,9 @@
|
||||
2000-06-27 Havoc Pennington <hp@redhat.com>
|
||||
|
||||
* gtk/gtkwindow.c (gtk_window_destroy): call
|
||||
set_transient_for(NULL) instead of unset_transient_for()
|
||||
in order to ensure the signal gets emitted.
|
||||
|
||||
2000-06-26 Havoc Pennington <hp@redhat.com>
|
||||
|
||||
* gtk/gtkstock.c: Code to add sample default stock items.
|
||||
|
@ -1,3 +1,9 @@
|
||||
2000-06-27 Havoc Pennington <hp@redhat.com>
|
||||
|
||||
* gtk/gtkwindow.c (gtk_window_destroy): call
|
||||
set_transient_for(NULL) instead of unset_transient_for()
|
||||
in order to ensure the signal gets emitted.
|
||||
|
||||
2000-06-26 Havoc Pennington <hp@redhat.com>
|
||||
|
||||
* gtk/gtkstock.c: Code to add sample default stock items.
|
||||
|
@ -1,3 +1,9 @@
|
||||
2000-06-27 Havoc Pennington <hp@redhat.com>
|
||||
|
||||
* gtk/gtkwindow.c (gtk_window_destroy): call
|
||||
set_transient_for(NULL) instead of unset_transient_for()
|
||||
in order to ensure the signal gets emitted.
|
||||
|
||||
2000-06-26 Havoc Pennington <hp@redhat.com>
|
||||
|
||||
* gtk/gtkstock.c: Code to add sample default stock items.
|
||||
|
@ -1,3 +1,9 @@
|
||||
2000-06-27 Havoc Pennington <hp@redhat.com>
|
||||
|
||||
* gtk/gtkwindow.c (gtk_window_destroy): call
|
||||
set_transient_for(NULL) instead of unset_transient_for()
|
||||
in order to ensure the signal gets emitted.
|
||||
|
||||
2000-06-26 Havoc Pennington <hp@redhat.com>
|
||||
|
||||
* gtk/gtkstock.c: Code to add sample default stock items.
|
||||
|
@ -1,3 +1,9 @@
|
||||
2000-06-27 Havoc Pennington <hp@redhat.com>
|
||||
|
||||
* gtk/gtkwindow.c (gtk_window_destroy): call
|
||||
set_transient_for(NULL) instead of unset_transient_for()
|
||||
in order to ensure the signal gets emitted.
|
||||
|
||||
2000-06-26 Havoc Pennington <hp@redhat.com>
|
||||
|
||||
* gtk/gtkstock.c: Code to add sample default stock items.
|
||||
|
@ -1,3 +1,9 @@
|
||||
2000-06-27 Havoc Pennington <hp@redhat.com>
|
||||
|
||||
* gtk/gtkwindow.c (gtk_window_destroy): call
|
||||
set_transient_for(NULL) instead of unset_transient_for()
|
||||
in order to ensure the signal gets emitted.
|
||||
|
||||
2000-06-26 Havoc Pennington <hp@redhat.com>
|
||||
|
||||
* gtk/gtkstock.c: Code to add sample default stock items.
|
||||
|
@ -1,3 +1,9 @@
|
||||
2000-06-27 Havoc Pennington <hp@redhat.com>
|
||||
|
||||
* gtk/gtkwindow.c (gtk_window_destroy): call
|
||||
set_transient_for(NULL) instead of unset_transient_for()
|
||||
in order to ensure the signal gets emitted.
|
||||
|
||||
2000-06-26 Havoc Pennington <hp@redhat.com>
|
||||
|
||||
* gtk/gtkstock.c: Code to add sample default stock items.
|
||||
|
@ -29,7 +29,9 @@
|
||||
#include "gtklabel.h"
|
||||
#include "gtkmain.h"
|
||||
#include "gtksignal.h"
|
||||
|
||||
#include "gtkimage.h"
|
||||
#include "gtkhbox.h"
|
||||
#include "gtkstock.h"
|
||||
|
||||
#define CHILD_SPACING 1
|
||||
#define DEFAULT_LEFT_POS 4
|
||||
@ -311,6 +313,93 @@ gtk_button_new_with_label (const gchar *label)
|
||||
return button;
|
||||
}
|
||||
|
||||
GtkWidget*
|
||||
gtk_button_new_stock (const gchar *stock_id,
|
||||
GtkAccelGroup *accel_group)
|
||||
{
|
||||
GtkWidget *button;
|
||||
GtkStockItem item;
|
||||
|
||||
if (gtk_stock_lookup (stock_id, &item))
|
||||
{
|
||||
GtkWidget *label;
|
||||
GtkWidget *image;
|
||||
GtkWidget *hbox;
|
||||
guint keyval;
|
||||
|
||||
button = gtk_button_new ();
|
||||
|
||||
label = gtk_label_new ("");
|
||||
keyval = gtk_label_parse_uline (GTK_LABEL (label),
|
||||
item.label);
|
||||
|
||||
if (keyval && accel_group)
|
||||
{
|
||||
gtk_widget_add_accelerator (button,
|
||||
"clicked",
|
||||
accel_group,
|
||||
keyval,
|
||||
GDK_MOD1_MASK,
|
||||
GTK_ACCEL_VISIBLE);
|
||||
}
|
||||
|
||||
/* Also add the stock accelerator if one was specified. */
|
||||
if (item.keyval && accel_group)
|
||||
{
|
||||
gtk_widget_add_accelerator (button,
|
||||
"clicked",
|
||||
accel_group,
|
||||
item.keyval,
|
||||
item.modifier,
|
||||
GTK_ACCEL_VISIBLE);
|
||||
}
|
||||
|
||||
image = gtk_image_new_from_stock (stock_id, GTK_ICON_BUTTON);
|
||||
hbox = gtk_hbox_new (FALSE, 0);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 2);
|
||||
gtk_box_pack_end (GTK_BOX (hbox), label, TRUE, TRUE, 2);
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (button), hbox);
|
||||
gtk_widget_show_all (hbox);
|
||||
}
|
||||
else
|
||||
{
|
||||
button = gtk_button_new_accel (stock_id, accel_group);
|
||||
}
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
GtkWidget*
|
||||
gtk_button_new_accel (const gchar *uline_label,
|
||||
GtkAccelGroup *accel_group)
|
||||
{
|
||||
GtkWidget *button;
|
||||
GtkWidget *label;
|
||||
guint keyval;
|
||||
|
||||
button = gtk_button_new ();
|
||||
|
||||
label = gtk_label_new ("");
|
||||
keyval = gtk_label_parse_uline (GTK_LABEL (label), uline_label);
|
||||
|
||||
if (keyval && accel_group)
|
||||
{
|
||||
gtk_widget_add_accelerator (button,
|
||||
"clicked",
|
||||
accel_group,
|
||||
keyval,
|
||||
GDK_MOD1_MASK,
|
||||
GTK_ACCEL_VISIBLE);
|
||||
}
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (button), label);
|
||||
gtk_widget_show (label);
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_button_pressed (GtkButton *button)
|
||||
{
|
||||
|
@ -75,7 +75,11 @@ struct _GtkButtonClass
|
||||
|
||||
GtkType gtk_button_get_type (void);
|
||||
GtkWidget* gtk_button_new (void);
|
||||
GtkWidget* gtk_button_new_with_label (const gchar *label);
|
||||
GtkWidget* gtk_button_new_with_label (const gchar *label);
|
||||
GtkWidget* gtk_button_new_stock (const gchar *stock_id,
|
||||
GtkAccelGroup *accel_group);
|
||||
GtkWidget* gtk_button_new_accel (const gchar *uline_label,
|
||||
GtkAccelGroup *accel_group);
|
||||
void gtk_button_pressed (GtkButton *button);
|
||||
void gtk_button_released (GtkButton *button);
|
||||
void gtk_button_clicked (GtkButton *button);
|
||||
|
365
gtk/gtkdialog.c
365
gtk/gtkdialog.c
@ -26,14 +26,30 @@
|
||||
|
||||
#include "gtkbutton.h"
|
||||
#include "gtkdialog.h"
|
||||
#include "gtkhbox.h"
|
||||
#include "gtkhbbox.h"
|
||||
#include "gtkhseparator.h"
|
||||
#include "gtkvbox.h"
|
||||
|
||||
#include "gtksignal.h"
|
||||
#include "gdkkeysyms.h"
|
||||
#include "gtkmain.h"
|
||||
|
||||
static void gtk_dialog_class_init (GtkDialogClass *klass);
|
||||
static void gtk_dialog_init (GtkDialog *dialog);
|
||||
static gint gtk_dialog_key_press (GtkWidget *widget,
|
||||
GdkEventKey *key);
|
||||
|
||||
static void gtk_dialog_add_buttons_valist(GtkDialog *dialog,
|
||||
const gchar *first_button_text,
|
||||
gint first_action_id,
|
||||
va_list args);
|
||||
|
||||
enum {
|
||||
ACTION,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
static gpointer parent_class;
|
||||
static guint dialog_signals[LAST_SIGNAL];
|
||||
|
||||
GtkType
|
||||
gtk_dialog_get_type (void)
|
||||
@ -63,6 +79,26 @@ gtk_dialog_get_type (void)
|
||||
static void
|
||||
gtk_dialog_class_init (GtkDialogClass *class)
|
||||
{
|
||||
GtkObjectClass *object_class;
|
||||
GtkWidgetClass *widget_class;
|
||||
|
||||
object_class = (GtkObjectClass*) class;
|
||||
widget_class = (GtkWidgetClass*) class;
|
||||
|
||||
parent_class = g_type_class_peek_parent (class);
|
||||
|
||||
dialog_signals[ACTION] =
|
||||
gtk_signal_new ("action",
|
||||
GTK_RUN_LAST,
|
||||
GTK_CLASS_TYPE (object_class),
|
||||
GTK_SIGNAL_OFFSET (GtkDialogClass, action),
|
||||
gtk_marshal_NONE__INT,
|
||||
GTK_TYPE_NONE, 1,
|
||||
GTK_TYPE_INT);
|
||||
|
||||
gtk_object_class_add_signals (object_class, dialog_signals, LAST_SIGNAL);
|
||||
|
||||
widget_class->key_press_event = gtk_dialog_key_press;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -74,7 +110,7 @@ gtk_dialog_init (GtkDialog *dialog)
|
||||
gtk_container_add (GTK_CONTAINER (dialog), dialog->vbox);
|
||||
gtk_widget_show (dialog->vbox);
|
||||
|
||||
dialog->action_area = gtk_hbox_new (TRUE, 5);
|
||||
dialog->action_area = gtk_hbutton_box_new ();
|
||||
gtk_container_set_border_width (GTK_CONTAINER (dialog->action_area), 10);
|
||||
gtk_box_pack_end (GTK_BOX (dialog->vbox), dialog->action_area, FALSE, TRUE, 0);
|
||||
gtk_widget_show (dialog->action_area);
|
||||
@ -84,8 +120,331 @@ gtk_dialog_init (GtkDialog *dialog)
|
||||
gtk_widget_show (separator);
|
||||
}
|
||||
|
||||
static gint
|
||||
gtk_dialog_key_press (GtkWidget *widget,
|
||||
GdkEventKey *key)
|
||||
{
|
||||
GdkEventAny event = { GDK_DELETE, widget->window, FALSE };
|
||||
|
||||
if (GTK_WIDGET_CLASS (parent_class)->key_press_event (widget, key))
|
||||
return TRUE;
|
||||
|
||||
if (key->keyval != GDK_Escape)
|
||||
return FALSE;
|
||||
|
||||
g_object_ref (G_OBJECT (event.window));
|
||||
|
||||
gtk_main_do_event ((GdkEvent*)&event);
|
||||
|
||||
g_object_unref (G_OBJECT (event.window));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GtkWidget*
|
||||
gtk_dialog_new (void)
|
||||
{
|
||||
return GTK_WIDGET (gtk_type_new (GTK_TYPE_DIALOG));
|
||||
}
|
||||
|
||||
GtkWidget*
|
||||
gtk_dialog_new_empty (const gchar *title,
|
||||
GtkWindow *parent,
|
||||
GtkDialogFlags flags)
|
||||
{
|
||||
GtkDialog *dialog;
|
||||
|
||||
dialog = GTK_DIALOG (g_type_create_instance (GTK_TYPE_DIALOG));
|
||||
|
||||
if (title)
|
||||
gtk_window_set_title (GTK_WINDOW (dialog), title);
|
||||
|
||||
if (parent)
|
||||
gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
|
||||
|
||||
if (flags & GTK_DIALOG_MODAL)
|
||||
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
||||
|
||||
if (flags & GTK_DIALOG_DESTROY_WITH_PARENT)
|
||||
gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
|
||||
|
||||
return GTK_WIDGET (dialog);
|
||||
}
|
||||
|
||||
GtkWidget*
|
||||
gtk_dialog_new_with_buttons (const gchar *title,
|
||||
GtkWindow *parent,
|
||||
GtkDialogFlags flags,
|
||||
const gchar *first_button_text,
|
||||
gint first_action_id,
|
||||
...)
|
||||
{
|
||||
GtkDialog *dialog;
|
||||
va_list args;
|
||||
|
||||
dialog = GTK_DIALOG (gtk_dialog_new_empty (title, parent, flags));
|
||||
|
||||
va_start (args, first_action_id);
|
||||
|
||||
gtk_dialog_add_buttons_valist (dialog,
|
||||
first_button_text, first_action_id,
|
||||
args);
|
||||
|
||||
va_end (args);
|
||||
|
||||
return GTK_WIDGET (dialog);
|
||||
}
|
||||
|
||||
typedef struct _ActionData ActionData;
|
||||
|
||||
struct _ActionData
|
||||
{
|
||||
gint action_id;
|
||||
};
|
||||
|
||||
static ActionData*
|
||||
get_action_data (GtkWidget *widget)
|
||||
{
|
||||
ActionData *ad = gtk_object_get_data (GTK_OBJECT (widget),
|
||||
"___gtk_dialog_action_data");
|
||||
|
||||
if (ad == NULL)
|
||||
{
|
||||
ad = g_new (ActionData, 1);
|
||||
|
||||
gtk_object_set_data_full (GTK_OBJECT (widget),
|
||||
"___gtk_dialog_action_data",
|
||||
ad,
|
||||
g_free);
|
||||
}
|
||||
|
||||
return ad;
|
||||
}
|
||||
|
||||
static void
|
||||
action_widget_activated (GtkWidget *widget, GtkDialog *dialog)
|
||||
{
|
||||
ActionData *ad;
|
||||
gint action_id;
|
||||
|
||||
g_return_if_fail (GTK_IS_DIALOG (dialog));
|
||||
|
||||
action_id = GTK_ACTION_NONE;
|
||||
|
||||
ad = get_action_data (widget);
|
||||
|
||||
if (ad != NULL)
|
||||
action_id = ad->action_id;
|
||||
|
||||
gtk_dialog_action (dialog, action_id);
|
||||
}
|
||||
|
||||
static void
|
||||
connect_action_widget (GtkDialog *dialog, GtkWidget *child)
|
||||
{
|
||||
if (GTK_WIDGET_GET_CLASS (child)->activate_signal != 0)
|
||||
{
|
||||
const gchar* name =
|
||||
gtk_signal_name (GTK_WIDGET_GET_CLASS (child)->activate_signal != 0);
|
||||
|
||||
gtk_signal_connect_while_alive (GTK_OBJECT (child),
|
||||
name,
|
||||
GTK_SIGNAL_FUNC (action_widget_activated),
|
||||
dialog,
|
||||
GTK_OBJECT (dialog));
|
||||
}
|
||||
else
|
||||
g_warning ("Only 'activatable' widgets can be packed into the action area of a GtkDialog");
|
||||
}
|
||||
|
||||
void
|
||||
gtk_dialog_add_action_widget (GtkDialog *dialog,
|
||||
GtkWidget *widget,
|
||||
gint action_id)
|
||||
{
|
||||
ActionData *ad;
|
||||
|
||||
g_return_if_fail (GTK_IS_DIALOG (dialog));
|
||||
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||
|
||||
ad = get_action_data (widget);
|
||||
|
||||
ad->action_id = action_id;
|
||||
|
||||
connect_action_widget (dialog, widget);
|
||||
|
||||
gtk_box_pack_end (GTK_BOX (dialog->action_area),
|
||||
widget,
|
||||
FALSE, TRUE, 5);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_dialog_add_button (GtkDialog *dialog,
|
||||
const gchar *button_text,
|
||||
gint action_id)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_DIALOG (dialog));
|
||||
g_return_if_fail (button_text != NULL);
|
||||
|
||||
gtk_dialog_add_action_widget (dialog,
|
||||
gtk_button_new_stock (button_text, NULL),
|
||||
action_id);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_dialog_add_buttons_valist(GtkDialog *dialog,
|
||||
const gchar *first_button_text,
|
||||
gint first_action_id,
|
||||
va_list args)
|
||||
{
|
||||
const gchar* text;
|
||||
gint action_id;
|
||||
|
||||
text = first_button_text;
|
||||
action_id = first_action_id;
|
||||
|
||||
while (text != NULL)
|
||||
{
|
||||
gtk_dialog_add_button (dialog, text, action_id);
|
||||
|
||||
text = va_arg (args, gchar*);
|
||||
if (text == NULL)
|
||||
break;
|
||||
action_id = va_arg (args, int);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gtk_dialog_add_buttons (GtkDialog *dialog,
|
||||
const gchar *first_button_text,
|
||||
gint first_action_id,
|
||||
...)
|
||||
{
|
||||
|
||||
va_list args;
|
||||
|
||||
va_start (args, first_action_id);
|
||||
|
||||
gtk_dialog_add_buttons_valist (dialog,
|
||||
first_button_text, first_action_id,
|
||||
args);
|
||||
|
||||
va_end (args);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_dialog_action (GtkDialog *dialog,
|
||||
gint action_id)
|
||||
{
|
||||
g_return_if_fail (dialog != NULL);
|
||||
g_return_if_fail (GTK_IS_DIALOG (dialog));
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (dialog),
|
||||
dialog_signals[ACTION],
|
||||
action_id);
|
||||
}
|
||||
|
||||
|
||||
typedef struct {
|
||||
GtkDialog *dialog;
|
||||
gint action_id;
|
||||
GMainLoop *loop;
|
||||
guint action_handler;
|
||||
guint destroy_handler;
|
||||
guint delete_handler;
|
||||
} RunInfo;
|
||||
|
||||
static void
|
||||
run_destroy_handler (GtkDialog *dialog, gpointer data)
|
||||
{
|
||||
RunInfo *ri = data;
|
||||
|
||||
if (ri->loop != NULL)
|
||||
{
|
||||
g_main_quit (ri->loop);
|
||||
g_main_destroy (ri->loop);
|
||||
ri->loop = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
run_action_handler (GtkDialog *dialog,
|
||||
gint action_id,
|
||||
gpointer data)
|
||||
{
|
||||
RunInfo *ri;
|
||||
|
||||
ri = data;
|
||||
|
||||
ri->action_id = action_id;
|
||||
|
||||
run_destroy_handler (dialog, data);
|
||||
}
|
||||
|
||||
static gint
|
||||
run_delete_handler (GtkDialog *dialog,
|
||||
GdkEventAny *event,
|
||||
gpointer data)
|
||||
{
|
||||
run_destroy_handler (dialog, data);
|
||||
|
||||
return TRUE; /* Do not destroy */
|
||||
}
|
||||
|
||||
gint
|
||||
gtk_dialog_run (GtkDialog *dialog)
|
||||
{
|
||||
RunInfo ri = { NULL, GTK_ACTION_NONE, NULL, 0, 0 };
|
||||
gboolean was_modal;
|
||||
|
||||
g_return_val_if_fail (dialog != NULL, -1);
|
||||
g_return_val_if_fail (GTK_IS_DIALOG (dialog), -1);
|
||||
|
||||
gtk_object_ref (GTK_OBJECT (dialog));
|
||||
|
||||
was_modal = GTK_WINDOW (dialog)->modal;
|
||||
if (!was_modal)
|
||||
gtk_window_set_modal(GTK_WINDOW (dialog),TRUE);
|
||||
|
||||
|
||||
ri.action_handler =
|
||||
gtk_signal_connect (GTK_OBJECT (dialog),
|
||||
"action",
|
||||
GTK_SIGNAL_FUNC (run_action_handler),
|
||||
&ri);
|
||||
|
||||
ri.destroy_handler =
|
||||
gtk_signal_connect (GTK_OBJECT (dialog),
|
||||
"destroy",
|
||||
GTK_SIGNAL_FUNC (run_destroy_handler),
|
||||
&ri);
|
||||
|
||||
ri.delete_handler =
|
||||
gtk_signal_connect (GTK_OBJECT (dialog),
|
||||
"delete_event",
|
||||
GTK_SIGNAL_FUNC (run_delete_handler),
|
||||
&ri);
|
||||
|
||||
ri.loop = g_main_new(FALSE);
|
||||
|
||||
g_main_run(ri.loop);
|
||||
|
||||
g_assert(ri.loop == NULL);
|
||||
|
||||
if (!GTK_OBJECT_DESTROYED (dialog))
|
||||
{
|
||||
if (!was_modal)
|
||||
gtk_window_set_modal(GTK_WINDOW(dialog), FALSE);
|
||||
|
||||
gtk_signal_disconnect (GTK_OBJECT (dialog), ri.destroy_handler);
|
||||
gtk_signal_disconnect (GTK_OBJECT (dialog), ri.action_handler);
|
||||
gtk_signal_disconnect (GTK_OBJECT (dialog), ri.delete_handler);
|
||||
}
|
||||
|
||||
gtk_object_unref (GTK_OBJECT (dialog));
|
||||
|
||||
return ri.action_id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -36,6 +36,34 @@
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* Parameters for dialog construction */
|
||||
typedef enum
|
||||
{
|
||||
GTK_DIALOG_MODAL, /* call gtk_window_set_modal(win, TRUE) */
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT /* call gtk_window_set_destroy_with_parent () */
|
||||
|
||||
} GtkDialogFlags;
|
||||
|
||||
/* Convenience enum to use for action_id's. Positive values are
|
||||
totally user-interpreted. GTK will sometimes return GTK_ACTION_NONE
|
||||
if no action_id is available.
|
||||
|
||||
Typical usage is:
|
||||
if (gtk_dialog_run(dialog) == GTK_ACTION_ACCEPT)
|
||||
blah();
|
||||
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
/* GTK returns this if an action widget has no action_id,
|
||||
or the dialog gets destroyed with no action */
|
||||
GTK_ACTION_NONE = 0,
|
||||
/* GTK won't return these unless you pass them in
|
||||
as the action for an action widget */
|
||||
GTK_ACTION_REJECT = 1,
|
||||
GTK_ACTION_ACCEPT = 2
|
||||
} GtkActionType;
|
||||
|
||||
|
||||
#define GTK_TYPE_DIALOG (gtk_dialog_get_type ())
|
||||
#define GTK_DIALOG(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_DIALOG, GtkDialog))
|
||||
@ -47,8 +75,6 @@ extern "C" {
|
||||
|
||||
typedef struct _GtkDialog GtkDialog;
|
||||
typedef struct _GtkDialogClass GtkDialogClass;
|
||||
typedef struct _GtkDialogButton GtkDialogButton;
|
||||
|
||||
|
||||
struct _GtkDialog
|
||||
{
|
||||
@ -61,12 +87,43 @@ struct _GtkDialog
|
||||
struct _GtkDialogClass
|
||||
{
|
||||
GtkWindowClass parent_class;
|
||||
|
||||
void (* action) (GtkDialog *dialog, gint action_id);
|
||||
};
|
||||
|
||||
|
||||
GtkType gtk_dialog_get_type (void);
|
||||
GtkWidget* gtk_dialog_new (void);
|
||||
|
||||
GtkWidget* gtk_dialog_new_empty (const gchar *title,
|
||||
GtkWindow *parent,
|
||||
GtkDialogFlags flags);
|
||||
GtkWidget* gtk_dialog_new_with_buttons (const gchar *title,
|
||||
GtkWindow *parent,
|
||||
GtkDialogFlags flags,
|
||||
const gchar *first_button_text,
|
||||
gint first_action_id,
|
||||
...);
|
||||
|
||||
void gtk_dialog_add_action_widget (GtkDialog *dialog,
|
||||
GtkWidget *widget,
|
||||
gint action_id);
|
||||
|
||||
void gtk_dialog_add_button (GtkDialog *dialog,
|
||||
const gchar *button_text,
|
||||
gint action_id);
|
||||
|
||||
void gtk_dialog_add_buttons (GtkDialog *dialog,
|
||||
const gchar *first_button_text,
|
||||
gint first_action_id,
|
||||
...);
|
||||
|
||||
/* Emit action signal */
|
||||
void gtk_dialog_action (GtkDialog *dialog,
|
||||
gint action_id);
|
||||
|
||||
/* Returns action_id */
|
||||
gint gtk_dialog_run (GtkDialog *dialog);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -261,7 +261,6 @@ get_default_icons (GtkIconFactory *factory)
|
||||
{
|
||||
/* KEEP IN SYNC with gtkstock.c */
|
||||
|
||||
add_sized (factory, dialog_default, GTK_ICON_DIALOG, GTK_STOCK_DIALOG_GENERIC);
|
||||
add_sized (factory, dialog_error, GTK_ICON_DIALOG, GTK_STOCK_DIALOG_ERROR);
|
||||
add_sized (factory, dialog_info, GTK_ICON_DIALOG, GTK_STOCK_DIALOG_INFO);
|
||||
add_sized (factory, dialog_question, GTK_ICON_DIALOG, GTK_STOCK_DIALOG_QUESTION);
|
||||
|
@ -70,7 +70,14 @@ GtkIconSet * gtk_icon_factory_lookup (GtkIconFactory *factory,
|
||||
void gtk_push_default_icon_factory (GtkIconFactory *factory);
|
||||
GtkIconSet *gtk_default_icon_lookup (const gchar *stock_id);
|
||||
|
||||
/* Get real size from semantic size (eventually user-configurable) */
|
||||
/* Get preferred real size from semantic size (eventually
|
||||
* user-configurable). Note that themes SHOULD use this size, but they
|
||||
* aren't required to; for size requests and such, you should get the
|
||||
* actual pixbuf from the icon set and see what size it is.
|
||||
*
|
||||
* This function is intended for people who are scaling icons,
|
||||
* rather than for people who are displaying already-scaled icons.
|
||||
*/
|
||||
void gtk_get_icon_size (GtkIconSizeType semantic_size,
|
||||
gint *width,
|
||||
gint *height);
|
||||
|
123
gtk/gtkimage.c
123
gtk/gtkimage.c
@ -26,6 +26,7 @@
|
||||
|
||||
#include "gtkcontainer.h"
|
||||
#include "gtkimage.h"
|
||||
#include "gtkiconfactory.h"
|
||||
|
||||
static void gtk_image_class_init (GtkImageClass *klass);
|
||||
static void gtk_image_init (GtkImage *image);
|
||||
@ -137,8 +138,8 @@ gtk_image_new_from_pixbuf (GdkPixbuf *pixbuf)
|
||||
}
|
||||
|
||||
GtkWidget*
|
||||
gtk_image_new_from_stock (const gchar *stock_id,
|
||||
GtkIconSizeType size)
|
||||
gtk_image_new_from_stock (const gchar *stock_id,
|
||||
GtkIconSizeType size)
|
||||
{
|
||||
GtkImage *image;
|
||||
|
||||
@ -149,6 +150,19 @@ gtk_image_new_from_stock (const gchar *stock_id,
|
||||
return GTK_WIDGET (image);
|
||||
}
|
||||
|
||||
GtkWidget*
|
||||
gtk_image_new_from_icon_set (GtkIconSet *icon_set,
|
||||
GtkIconSizeType size)
|
||||
{
|
||||
GtkImage *image;
|
||||
|
||||
image = gtk_type_new (GTK_TYPE_IMAGE);
|
||||
|
||||
gtk_image_set_from_icon_set (image, icon_set, size);
|
||||
|
||||
return GTK_WIDGET (image);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_image_set_from_pixmap (GtkImage *image,
|
||||
GdkPixmap *pixmap,
|
||||
@ -287,6 +301,31 @@ gtk_image_set_from_stock (GtkImage *image,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gtk_image_set_from_icon_set (GtkImage *image,
|
||||
GtkIconSet *icon_set,
|
||||
GtkIconSizeType size)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_IMAGE (image));
|
||||
|
||||
if (icon_set)
|
||||
gtk_icon_set_ref (icon_set);
|
||||
|
||||
gtk_image_clear (image);
|
||||
|
||||
if (icon_set)
|
||||
{
|
||||
image->representation_type = GTK_IMAGE_ICON_SET;
|
||||
|
||||
image->data.icon_set.icon_set = icon_set;
|
||||
image->data.icon_set.size = size;
|
||||
|
||||
/* Size is demand-computed in size request method
|
||||
* if we're an icon set
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gtk_image_get_pixmap (GtkImage *image,
|
||||
GdkPixmap **pixmap,
|
||||
@ -342,6 +381,21 @@ gtk_image_get_stock (GtkImage *image,
|
||||
*size = image->data.stock.size;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_image_get_icon_set (GtkImage *image,
|
||||
GtkIconSet **icon_set,
|
||||
GtkIconSizeType *size)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_IMAGE (image));
|
||||
g_return_if_fail (image->representation_type == GTK_IMAGE_ICON_SET);
|
||||
|
||||
if (icon_set)
|
||||
*icon_set = image->data.icon_set.icon_set;
|
||||
|
||||
if (size)
|
||||
*size = image->data.icon_set.size;
|
||||
}
|
||||
|
||||
GtkWidget*
|
||||
gtk_image_new (GdkImage *val,
|
||||
GdkBitmap *mask)
|
||||
@ -444,6 +498,23 @@ gtk_image_expose (GtkWidget *widget,
|
||||
}
|
||||
break;
|
||||
|
||||
case GTK_IMAGE_ICON_SET:
|
||||
stock_pixbuf =
|
||||
gtk_icon_set_get_icon (image->data.icon_set.icon_set,
|
||||
widget->style,
|
||||
gtk_widget_get_direction (widget),
|
||||
GTK_WIDGET_STATE (widget),
|
||||
image->data.icon_set.size,
|
||||
widget,
|
||||
NULL);
|
||||
|
||||
if (stock_pixbuf)
|
||||
{
|
||||
image_bound.width = gdk_pixbuf_get_width (stock_pixbuf);
|
||||
image_bound.height = gdk_pixbuf_get_height (stock_pixbuf);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -491,7 +562,8 @@ gtk_image_expose (GtkWidget *widget,
|
||||
0, 0);
|
||||
break;
|
||||
|
||||
case GTK_IMAGE_STOCK:
|
||||
case GTK_IMAGE_STOCK: /* fall thru */
|
||||
case GTK_IMAGE_ICON_SET:
|
||||
if (stock_pixbuf)
|
||||
{
|
||||
gdk_pixbuf_render_to_drawable_alpha (stock_pixbuf,
|
||||
@ -571,6 +643,14 @@ gtk_image_clear (GtkImage *image)
|
||||
|
||||
break;
|
||||
|
||||
case GTK_IMAGE_ICON_SET:
|
||||
if (image->data.icon_set.icon_set)
|
||||
gtk_icon_set_unref (image->data.icon_set.icon_set);
|
||||
|
||||
image->data.icon_set.icon_set = NULL;
|
||||
|
||||
break;
|
||||
|
||||
case GTK_IMAGE_EMPTY:
|
||||
default:
|
||||
break;
|
||||
@ -591,25 +671,39 @@ gtk_image_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition)
|
||||
{
|
||||
GtkImage *image;
|
||||
|
||||
GdkPixbuf *pixbuf = NULL;
|
||||
|
||||
image = GTK_IMAGE (widget);
|
||||
|
||||
if (image->representation_type == GTK_IMAGE_STOCK)
|
||||
switch (image->representation_type)
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
|
||||
case GTK_IMAGE_STOCK:
|
||||
pixbuf = gtk_widget_get_icon (GTK_WIDGET (image),
|
||||
image->data.stock.stock_id,
|
||||
image->data.stock.size,
|
||||
NULL);
|
||||
break;
|
||||
|
||||
if (pixbuf)
|
||||
{
|
||||
gtk_image_update_size (image,
|
||||
gdk_pixbuf_get_width (pixbuf),
|
||||
gdk_pixbuf_get_height (pixbuf));
|
||||
g_object_unref (G_OBJECT (pixbuf));
|
||||
}
|
||||
case GTK_IMAGE_ICON_SET:
|
||||
pixbuf = gtk_icon_set_get_icon (image->data.icon_set.icon_set,
|
||||
widget->style,
|
||||
gtk_widget_get_direction (widget),
|
||||
GTK_WIDGET_STATE (widget),
|
||||
image->data.icon_set.size,
|
||||
widget,
|
||||
NULL);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (pixbuf)
|
||||
{
|
||||
gtk_image_update_size (image,
|
||||
gdk_pixbuf_get_width (pixbuf),
|
||||
gdk_pixbuf_get_height (pixbuf));
|
||||
g_object_unref (G_OBJECT (pixbuf));
|
||||
}
|
||||
|
||||
/* Chain up to default that simply reads current requisition */
|
||||
@ -625,3 +719,4 @@ gtk_image_update_size (GtkImage *image,
|
||||
GTK_WIDGET (image)->requisition.height = image_height + GTK_MISC (image)->ypad * 2;
|
||||
}
|
||||
|
||||
|
||||
|
@ -47,10 +47,11 @@ extern "C" {
|
||||
typedef struct _GtkImage GtkImage;
|
||||
typedef struct _GtkImageClass GtkImageClass;
|
||||
|
||||
typedef struct _GtkImagePixmapData GtkImagePixmapData;
|
||||
typedef struct _GtkImageImageData GtkImageImageData;
|
||||
typedef struct _GtkImagePixbufData GtkImagePixbufData;
|
||||
typedef struct _GtkImageStockData GtkImageStockData;
|
||||
typedef struct _GtkImagePixmapData GtkImagePixmapData;
|
||||
typedef struct _GtkImageImageData GtkImageImageData;
|
||||
typedef struct _GtkImagePixbufData GtkImagePixbufData;
|
||||
typedef struct _GtkImageStockData GtkImageStockData;
|
||||
typedef struct _GtkImageIconSetData GtkImageIconSetData;
|
||||
|
||||
struct _GtkImagePixmapData
|
||||
{
|
||||
@ -75,13 +76,20 @@ struct _GtkImageStockData
|
||||
GtkIconSizeType size;
|
||||
};
|
||||
|
||||
struct _GtkImageIconSetData
|
||||
{
|
||||
GtkIconSet *icon_set;
|
||||
GtkIconSizeType size;
|
||||
};
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GTK_IMAGE_EMPTY,
|
||||
GTK_IMAGE_PIXMAP,
|
||||
GTK_IMAGE_IMAGE,
|
||||
GTK_IMAGE_PIXBUF,
|
||||
GTK_IMAGE_STOCK
|
||||
GTK_IMAGE_STOCK,
|
||||
GTK_IMAGE_ICON_SET
|
||||
} GtkImageType;
|
||||
|
||||
struct _GtkImage
|
||||
@ -96,6 +104,7 @@ struct _GtkImage
|
||||
GtkImageImageData image;
|
||||
GtkImagePixbufData pixbuf;
|
||||
GtkImageStockData stock;
|
||||
GtkImageIconSetData icon_set;
|
||||
} data;
|
||||
};
|
||||
|
||||
@ -107,39 +116,48 @@ struct _GtkImageClass
|
||||
|
||||
GtkType gtk_image_get_type (void);
|
||||
|
||||
GtkWidget* gtk_image_new_from_pixmap (GdkPixmap *pixmap,
|
||||
GdkBitmap *mask);
|
||||
GtkWidget* gtk_image_new_from_image (GdkImage *image,
|
||||
GdkBitmap *mask);
|
||||
GtkWidget* gtk_image_new_from_file (const gchar *filename);
|
||||
GtkWidget* gtk_image_new_from_pixbuf (GdkPixbuf *pixbuf);
|
||||
GtkWidget* gtk_image_new_from_stock (const gchar *stock_id,
|
||||
GtkIconSizeType size);
|
||||
GtkWidget* gtk_image_new_from_pixmap (GdkPixmap *pixmap,
|
||||
GdkBitmap *mask);
|
||||
GtkWidget* gtk_image_new_from_image (GdkImage *image,
|
||||
GdkBitmap *mask);
|
||||
GtkWidget* gtk_image_new_from_file (const gchar *filename);
|
||||
GtkWidget* gtk_image_new_from_pixbuf (GdkPixbuf *pixbuf);
|
||||
GtkWidget* gtk_image_new_from_stock (const gchar *stock_id,
|
||||
GtkIconSizeType size);
|
||||
GtkWidget* gtk_image_new_from_icon_set (GtkIconSet *icon_set,
|
||||
GtkIconSizeType size);
|
||||
|
||||
void gtk_image_set_from_pixmap (GtkImage *image,
|
||||
GdkPixmap *pixmap,
|
||||
GdkBitmap *mask);
|
||||
void gtk_image_set_from_image (GtkImage *image,
|
||||
GdkImage *gdk_image,
|
||||
GdkBitmap *mask);
|
||||
void gtk_image_set_from_file (GtkImage *image,
|
||||
const gchar *filename);
|
||||
void gtk_image_set_from_pixbuf (GtkImage *image,
|
||||
GdkPixbuf *pixbuf);
|
||||
void gtk_image_set_from_stock (GtkImage *image,
|
||||
const gchar *stock_id,
|
||||
GtkIconSizeType size);
|
||||
void gtk_image_set_from_pixmap (GtkImage *image,
|
||||
GdkPixmap *pixmap,
|
||||
GdkBitmap *mask);
|
||||
void gtk_image_set_from_image (GtkImage *image,
|
||||
GdkImage *gdk_image,
|
||||
GdkBitmap *mask);
|
||||
void gtk_image_set_from_file (GtkImage *image,
|
||||
const gchar *filename);
|
||||
void gtk_image_set_from_pixbuf (GtkImage *image,
|
||||
GdkPixbuf *pixbuf);
|
||||
void gtk_image_set_from_stock (GtkImage *image,
|
||||
const gchar *stock_id,
|
||||
GtkIconSizeType size);
|
||||
void gtk_image_set_from_icon_set (GtkImage *image,
|
||||
GtkIconSet *icon_set,
|
||||
GtkIconSizeType size);
|
||||
|
||||
void gtk_image_get_pixmap (GtkImage *image,
|
||||
GdkPixmap **pixmap,
|
||||
GdkBitmap **mask);
|
||||
void gtk_image_get_image (GtkImage *image,
|
||||
GdkImage **gdk_image,
|
||||
GdkBitmap **mask);
|
||||
GdkPixbuf* gtk_image_get_pixbuf (GtkImage *image);
|
||||
void gtk_image_get_stock (GtkImage *image,
|
||||
gchar **stock_id,
|
||||
GtkIconSizeType *size);
|
||||
void gtk_image_get_icon_set (GtkImage *image,
|
||||
GtkIconSet **icon_set,
|
||||
GtkIconSizeType *size);
|
||||
|
||||
void gtk_image_get_pixmap (GtkImage *image,
|
||||
GdkPixmap **pixmap,
|
||||
GdkBitmap **mask);
|
||||
void gtk_image_get_image (GtkImage *image,
|
||||
GdkImage **gdk_image,
|
||||
GdkBitmap **mask);
|
||||
GdkPixbuf* gtk_image_get_pixbuf (GtkImage *image);
|
||||
void gtk_image_get_stock (GtkImage *image,
|
||||
gchar **stock_id,
|
||||
GtkIconSizeType *size);
|
||||
|
||||
|
||||
/* These three are deprecated */
|
||||
|
@ -136,20 +136,19 @@ gtk_stock_item_free (GtkStockItem *item)
|
||||
|
||||
static GtkStockItem builtin_items [] =
|
||||
{
|
||||
/* KEEP IN SYNC with gtkiconfactory.c stock icons */
|
||||
|
||||
{ GTK_STOCK_DIALOG_GENERIC, N_("Message"), 0, 0, GTK_DOMAIN },
|
||||
/* KEEP IN SYNC with gtkiconfactory.c stock icons */
|
||||
|
||||
{ GTK_STOCK_DIALOG_INFO, N_("Information"), 0, 0, GTK_DOMAIN },
|
||||
{ GTK_STOCK_DIALOG_WARNING, N_("Warning"), 0, 0, GTK_DOMAIN },
|
||||
{ GTK_STOCK_DIALOG_ERROR, N_("Error"), 0, 0, GTK_DOMAIN },
|
||||
{ GTK_STOCK_DIALOG_QUESTION, N_("Question"), 0, 0, GTK_DOMAIN },
|
||||
|
||||
{ GTK_STOCK_BUTTON_APPLY, N_("Apply"), GDK_CONTROL_MASK, 'a', GTK_DOMAIN },
|
||||
{ GTK_STOCK_BUTTON_OK, N_("OK"), GDK_CONTROL_MASK, 'o', GTK_DOMAIN },
|
||||
{ GTK_STOCK_BUTTON_CANCEL, N_("Cancel"), GDK_CONTROL_MASK, 'c', GTK_DOMAIN },
|
||||
{ GTK_STOCK_BUTTON_CLOSE, N_("Close"), GDK_CONTROL_MASK, 'c', GTK_DOMAIN },
|
||||
{ GTK_STOCK_BUTTON_YES, N_("Yes"), GDK_CONTROL_MASK, 'y', GTK_DOMAIN },
|
||||
{ GTK_STOCK_BUTTON_NO, N_("No"), GDK_CONTROL_MASK, 'n', GTK_DOMAIN },
|
||||
{ GTK_STOCK_BUTTON_APPLY, N_("_Apply"), 0, 0, GTK_DOMAIN },
|
||||
{ GTK_STOCK_BUTTON_OK, N_("OK"), 0, 0, GTK_DOMAIN },
|
||||
{ GTK_STOCK_BUTTON_CANCEL, N_("Cancel"), 0, 0, GTK_DOMAIN },
|
||||
{ GTK_STOCK_BUTTON_CLOSE, N_("_Close"), 0, 0, GTK_DOMAIN },
|
||||
{ GTK_STOCK_BUTTON_YES, N_("_Yes"), 0, 0, GTK_DOMAIN },
|
||||
{ GTK_STOCK_BUTTON_NO, N_("_No"), 0, 0, GTK_DOMAIN },
|
||||
|
||||
{ GTK_STOCK_CLOSE, N_("Close"), GDK_CONTROL_MASK, 'w', GTK_DOMAIN },
|
||||
{ GTK_STOCK_QUIT, N_("Quit"), GDK_CONTROL_MASK, 'q', GTK_DOMAIN },
|
||||
|
@ -59,7 +59,6 @@ void gtk_stock_item_free (GtkStockItem *item);
|
||||
|
||||
|
||||
/* Stock IDs */
|
||||
#define GTK_STOCK_DIALOG_GENERIC "Gtk_Message_Dialog"
|
||||
#define GTK_STOCK_DIALOG_INFO "Gtk_Info_Dialog"
|
||||
#define GTK_STOCK_DIALOG_WARNING "Gtk_Warning_Dialog"
|
||||
#define GTK_STOCK_DIALOG_ERROR "Gtk_Error_Dialog"
|
||||
|
143
gtk/gtkwindow.c
143
gtk/gtkwindow.c
@ -51,6 +51,7 @@
|
||||
|
||||
enum {
|
||||
SET_FOCUS,
|
||||
SET_TRANSIENT_FOR,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
enum {
|
||||
@ -124,6 +125,8 @@ static gint gtk_window_client_event (GtkWidget *widget,
|
||||
static void gtk_window_check_resize (GtkContainer *container);
|
||||
static void gtk_window_real_set_focus (GtkWindow *window,
|
||||
GtkWidget *focus);
|
||||
static void gtk_window_real_set_transient_for (GtkWindow *window,
|
||||
GtkWindow *parent);
|
||||
|
||||
static void gtk_window_move_resize (GtkWindow *window);
|
||||
static gboolean gtk_window_compare_hints (GdkGeometry *geometry_a,
|
||||
@ -233,6 +236,15 @@ gtk_window_class_init (GtkWindowClass *klass)
|
||||
GTK_TYPE_NONE, 1,
|
||||
GTK_TYPE_WIDGET);
|
||||
|
||||
window_signals[SET_TRANSIENT_FOR] =
|
||||
gtk_signal_new ("set_transient_for",
|
||||
GTK_RUN_LAST,
|
||||
GTK_CLASS_TYPE (object_class),
|
||||
GTK_SIGNAL_OFFSET (GtkWindowClass, set_transient_for),
|
||||
gtk_marshal_NONE__POINTER,
|
||||
GTK_TYPE_NONE, 1,
|
||||
GTK_TYPE_WIDGET);
|
||||
|
||||
gtk_object_class_add_signals (object_class, window_signals, LAST_SIGNAL);
|
||||
|
||||
object_class->set_arg = gtk_window_set_arg;
|
||||
@ -261,6 +273,7 @@ gtk_window_class_init (GtkWindowClass *klass)
|
||||
container_class->check_resize = gtk_window_check_resize;
|
||||
|
||||
klass->set_focus = gtk_window_real_set_focus;
|
||||
klass->set_transient_for = gtk_window_real_set_transient_for;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -681,6 +694,35 @@ gtk_window_shutdown (GObject *object)
|
||||
G_OBJECT_CLASS (parent_class)->shutdown (object);
|
||||
}
|
||||
|
||||
static void
|
||||
parent_destroyed_callback (GtkWindow *parent, GtkWindow *child)
|
||||
{
|
||||
gtk_widget_destroy (GTK_WIDGET (child));
|
||||
}
|
||||
|
||||
static void
|
||||
connect_parent_destroyed (GtkWindow *window)
|
||||
{
|
||||
if (window->transient_parent)
|
||||
{
|
||||
gtk_signal_connect (GTK_OBJECT (window->transient_parent),
|
||||
"destroy",
|
||||
GTK_SIGNAL_FUNC (parent_destroyed_callback),
|
||||
window);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
disconnect_parent_destroyed (GtkWindow *window)
|
||||
{
|
||||
if (window->transient_parent)
|
||||
{
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (window->transient_parent),
|
||||
GTK_SIGNAL_FUNC (parent_destroyed_callback),
|
||||
window);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_window_transient_parent_realized (GtkWidget *parent,
|
||||
GtkWidget *window)
|
||||
@ -713,6 +755,8 @@ gtk_window_unset_transient_for (GtkWindow *window)
|
||||
GTK_SIGNAL_FUNC (gtk_widget_destroyed),
|
||||
&window->transient_parent);
|
||||
|
||||
disconnect_parent_destroyed (window);
|
||||
|
||||
window->transient_parent = NULL;
|
||||
}
|
||||
}
|
||||
@ -721,38 +765,40 @@ void
|
||||
gtk_window_set_transient_for (GtkWindow *window,
|
||||
GtkWindow *parent)
|
||||
{
|
||||
g_return_if_fail (window != 0);
|
||||
g_return_if_fail (window != NULL);
|
||||
g_return_if_fail (parent != NULL);
|
||||
g_return_if_fail (GTK_IS_WINDOW (window));
|
||||
g_return_if_fail (GTK_IS_WINDOW (parent));
|
||||
g_return_if_fail (window != parent);
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (window),
|
||||
window_signals[SET_TRANSIENT_FOR],
|
||||
parent);
|
||||
}
|
||||
|
||||
if (window->transient_parent)
|
||||
void
|
||||
gtk_window_set_destroy_with_parent (GtkWindow *window,
|
||||
gboolean setting)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_WINDOW (window));
|
||||
|
||||
if (window->destroy_with_parent == (setting != FALSE))
|
||||
return;
|
||||
|
||||
if (window->destroy_with_parent)
|
||||
{
|
||||
if (GTK_WIDGET_REALIZED (window) &&
|
||||
GTK_WIDGET_REALIZED (window->transient_parent) &&
|
||||
(!parent || !GTK_WIDGET_REALIZED (parent)))
|
||||
gtk_window_transient_parent_unrealized (GTK_WIDGET (window->transient_parent),
|
||||
GTK_WIDGET (window));
|
||||
g_assert (!setting);
|
||||
|
||||
gtk_window_unset_transient_for (window);
|
||||
disconnect_parent_destroyed (window);
|
||||
}
|
||||
|
||||
window->transient_parent = parent;
|
||||
|
||||
if (parent)
|
||||
else
|
||||
{
|
||||
gtk_signal_connect (GTK_OBJECT (parent), "destroy",
|
||||
GTK_SIGNAL_FUNC (gtk_widget_destroyed),
|
||||
&window->transient_parent);
|
||||
gtk_signal_connect (GTK_OBJECT (parent), "realize",
|
||||
GTK_SIGNAL_FUNC (gtk_window_transient_parent_realized),
|
||||
window);
|
||||
gtk_signal_connect (GTK_OBJECT (parent), "unrealize",
|
||||
GTK_SIGNAL_FUNC (gtk_window_transient_parent_unrealized),
|
||||
window);
|
||||
g_assert (setting);
|
||||
|
||||
if (GTK_WIDGET_REALIZED (window) &&
|
||||
GTK_WIDGET_REALIZED (parent))
|
||||
gtk_window_transient_parent_realized (GTK_WIDGET (parent),
|
||||
GTK_WIDGET (window));
|
||||
connect_parent_destroyed (window);
|
||||
}
|
||||
|
||||
window->destroy_with_parent = setting;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -853,7 +899,7 @@ gtk_window_destroy (GtkObject *object)
|
||||
window = GTK_WINDOW (object);
|
||||
|
||||
if (window->transient_parent)
|
||||
gtk_window_unset_transient_for (window);
|
||||
gtk_window_set_transient_for (window, NULL);
|
||||
|
||||
if (window->has_user_ref_count)
|
||||
{
|
||||
@ -1538,6 +1584,51 @@ gtk_window_real_set_focus (GtkWindow *window,
|
||||
gtk_widget_queue_draw (window->default_widget);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_window_real_set_transient_for (GtkWindow *window,
|
||||
GtkWindow *parent)
|
||||
{
|
||||
g_return_if_fail (window != NULL);
|
||||
g_return_if_fail (parent != NULL);
|
||||
g_return_if_fail (GTK_IS_WINDOW (window));
|
||||
g_return_if_fail (GTK_IS_WINDOW (parent));
|
||||
g_return_if_fail (window != parent);
|
||||
|
||||
if (window->transient_parent)
|
||||
{
|
||||
if (GTK_WIDGET_REALIZED (window) &&
|
||||
GTK_WIDGET_REALIZED (window->transient_parent) &&
|
||||
(!parent || !GTK_WIDGET_REALIZED (parent)))
|
||||
gtk_window_transient_parent_unrealized (GTK_WIDGET (window->transient_parent),
|
||||
GTK_WIDGET (window));
|
||||
|
||||
gtk_window_unset_transient_for (window);
|
||||
}
|
||||
|
||||
window->transient_parent = parent;
|
||||
|
||||
if (parent)
|
||||
{
|
||||
gtk_signal_connect (GTK_OBJECT (parent), "destroy",
|
||||
GTK_SIGNAL_FUNC (gtk_widget_destroyed),
|
||||
&window->transient_parent);
|
||||
gtk_signal_connect (GTK_OBJECT (parent), "realize",
|
||||
GTK_SIGNAL_FUNC (gtk_window_transient_parent_realized),
|
||||
window);
|
||||
gtk_signal_connect (GTK_OBJECT (parent), "unrealize",
|
||||
GTK_SIGNAL_FUNC (gtk_window_transient_parent_unrealized),
|
||||
window);
|
||||
|
||||
if (window->destroy_with_parent)
|
||||
connect_parent_destroyed (window);
|
||||
|
||||
if (GTK_WIDGET_REALIZED (window) &&
|
||||
GTK_WIDGET_REALIZED (parent))
|
||||
gtk_window_transient_parent_realized (GTK_WIDGET (parent),
|
||||
GTK_WIDGET (window));
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************
|
||||
* Functions related to resizing *
|
||||
*********************************/
|
||||
|
@ -79,6 +79,7 @@ struct _GtkWindow
|
||||
*/
|
||||
guint use_uposition : 1;
|
||||
guint modal : 1;
|
||||
guint destroy_with_parent : 1;
|
||||
};
|
||||
|
||||
struct _GtkWindowClass
|
||||
@ -87,6 +88,9 @@ struct _GtkWindowClass
|
||||
|
||||
void (* set_focus) (GtkWindow *window,
|
||||
GtkWidget *focus);
|
||||
|
||||
void (* set_transient_for) (GtkWindow *window,
|
||||
GtkWindow *parent);
|
||||
};
|
||||
|
||||
|
||||
@ -112,6 +116,8 @@ gint gtk_window_activate_default (GtkWindow *window);
|
||||
|
||||
void gtk_window_set_transient_for (GtkWindow *window,
|
||||
GtkWindow *parent);
|
||||
void gtk_window_set_destroy_with_parent (GtkWindow *window,
|
||||
gboolean setting);
|
||||
void gtk_window_set_geometry_hints (GtkWindow *window,
|
||||
GtkWidget *geometry_widget,
|
||||
GdkGeometry *geometry,
|
||||
|
@ -1,9 +1,8 @@
|
||||
BUILT_SOURCES=gtkstockpixbufs.h
|
||||
|
||||
IMAGES=dialog_default.png dialog_error.png dialog_info.png dialog_question.png dialog_warning.png stock_button_apply.png stock_button_cancel.png stock_button_close.png stock_button_no.png stock_button_ok.png stock_button_yes.png stock_close.png stock_exit.png stock_help.png stock_new.png stock_open.png stock_save.png
|
||||
IMAGES= dialog_error.png dialog_info.png dialog_question.png dialog_warning.png stock_button_apply.png stock_button_cancel.png stock_button_close.png stock_button_no.png stock_button_ok.png stock_button_yes.png stock_close.png stock_exit.png stock_help.png stock_new.png stock_open.png stock_save.png
|
||||
|
||||
VARIABLES= dialog_default dialog_default.png \
|
||||
dialog_error dialog_error.png \
|
||||
VARIABLES= dialog_error dialog_error.png \
|
||||
dialog_info dialog_info.png \
|
||||
dialog_question dialog_question.png \
|
||||
dialog_warning dialog_warning.png \
|
||||
|
@ -166,8 +166,13 @@ create_buttons (void)
|
||||
|
||||
if (!window)
|
||||
{
|
||||
GtkAccelGroup *accel_group;
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
|
||||
accel_group = gtk_accel_group_new ();
|
||||
gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (window), "destroy",
|
||||
GTK_SIGNAL_FUNC (gtk_widget_destroyed),
|
||||
&window);
|
||||
@ -185,15 +190,17 @@ create_buttons (void)
|
||||
gtk_box_pack_start (GTK_BOX (box1), table, TRUE, TRUE, 0);
|
||||
|
||||
button[0] = gtk_button_new_with_label ("button1");
|
||||
button[1] = gtk_button_new_with_label ("button2");
|
||||
button[1] = gtk_button_new_accel ("_button2", accel_group);
|
||||
button[2] = gtk_button_new_with_label ("button3");
|
||||
button[3] = gtk_button_new_with_label ("button4");
|
||||
button[3] = gtk_button_new_stock (GTK_STOCK_BUTTON_OK, NULL);
|
||||
button[4] = gtk_button_new_with_label ("button5");
|
||||
button[5] = gtk_button_new_with_label ("button6");
|
||||
button[6] = gtk_button_new_with_label ("button7");
|
||||
button[7] = gtk_button_new_with_label ("button8");
|
||||
button[7] = gtk_button_new_stock (GTK_STOCK_BUTTON_CLOSE, accel_group);
|
||||
button[8] = gtk_button_new_with_label ("button9");
|
||||
|
||||
gtk_accel_group_unref (accel_group);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (button[0]), "clicked",
|
||||
GTK_SIGNAL_FUNC(button_window),
|
||||
button[1]);
|
||||
|
@ -166,8 +166,13 @@ create_buttons (void)
|
||||
|
||||
if (!window)
|
||||
{
|
||||
GtkAccelGroup *accel_group;
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
|
||||
accel_group = gtk_accel_group_new ();
|
||||
gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (window), "destroy",
|
||||
GTK_SIGNAL_FUNC (gtk_widget_destroyed),
|
||||
&window);
|
||||
@ -185,15 +190,17 @@ create_buttons (void)
|
||||
gtk_box_pack_start (GTK_BOX (box1), table, TRUE, TRUE, 0);
|
||||
|
||||
button[0] = gtk_button_new_with_label ("button1");
|
||||
button[1] = gtk_button_new_with_label ("button2");
|
||||
button[1] = gtk_button_new_accel ("_button2", accel_group);
|
||||
button[2] = gtk_button_new_with_label ("button3");
|
||||
button[3] = gtk_button_new_with_label ("button4");
|
||||
button[3] = gtk_button_new_stock (GTK_STOCK_BUTTON_OK, NULL);
|
||||
button[4] = gtk_button_new_with_label ("button5");
|
||||
button[5] = gtk_button_new_with_label ("button6");
|
||||
button[6] = gtk_button_new_with_label ("button7");
|
||||
button[7] = gtk_button_new_with_label ("button8");
|
||||
button[7] = gtk_button_new_stock (GTK_STOCK_BUTTON_CLOSE, accel_group);
|
||||
button[8] = gtk_button_new_with_label ("button9");
|
||||
|
||||
gtk_accel_group_unref (accel_group);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (button[0]), "clicked",
|
||||
GTK_SIGNAL_FUNC(button_window),
|
||||
button[1]);
|
||||
|
Loading…
Reference in New Issue
Block a user