remove trailer (gtk_entry_set_property): remove trailer
2001-03-07 Havoc Pennington <hp@redhat.com> * gtk/gtkentry.c (gtk_entry_get_property): remove trailer (gtk_entry_set_property): remove trailer * gtk/gtkentry.c (gtk_entry_set_width_chars): (gtk_entry_get_width_chars): new functions, to set size request to a given number of characters * gtk/testgtk.c (create_dialog): beef up the dialog test slightly * gtk/gtkdialog.c (gtk_dialog_set_has_separator): new function (gtk_dialog_get_has_separator): new function (run_delete_handler): fix to not emit "response" signal because we already did in the delete event handler installed at dialog creation time. * gtk/gtkdialog.h: add a has_separator property, add GTK_DIALOG_NO_SEPARATOR flag
This commit is contained in:
parent
9d1e2a1323
commit
29b902a481
20
ChangeLog
20
ChangeLog
@ -1,3 +1,23 @@
|
||||
2001-03-07 Havoc Pennington <hp@redhat.com>
|
||||
|
||||
* gtk/gtkentry.c (gtk_entry_get_property): remove trailer
|
||||
(gtk_entry_set_property): remove trailer
|
||||
|
||||
* gtk/gtkentry.c (gtk_entry_set_width_chars):
|
||||
(gtk_entry_get_width_chars): new functions, to set size request to
|
||||
a given number of characters
|
||||
|
||||
* gtk/testgtk.c (create_dialog): beef up the dialog test slightly
|
||||
|
||||
* gtk/gtkdialog.c (gtk_dialog_set_has_separator): new function
|
||||
(gtk_dialog_get_has_separator): new function
|
||||
(run_delete_handler): fix to not emit "response" signal
|
||||
because we already did in the delete event handler installed
|
||||
at dialog creation time.
|
||||
|
||||
* gtk/gtkdialog.h: add a has_separator property,
|
||||
add GTK_DIALOG_NO_SEPARATOR flag
|
||||
|
||||
2001-03-07 Havoc Pennington <hp@redhat.com>
|
||||
|
||||
* gtk/gtkwindow.c (gtk_window_set_decorated): new function, turns
|
||||
|
@ -1,3 +1,23 @@
|
||||
2001-03-07 Havoc Pennington <hp@redhat.com>
|
||||
|
||||
* gtk/gtkentry.c (gtk_entry_get_property): remove trailer
|
||||
(gtk_entry_set_property): remove trailer
|
||||
|
||||
* gtk/gtkentry.c (gtk_entry_set_width_chars):
|
||||
(gtk_entry_get_width_chars): new functions, to set size request to
|
||||
a given number of characters
|
||||
|
||||
* gtk/testgtk.c (create_dialog): beef up the dialog test slightly
|
||||
|
||||
* gtk/gtkdialog.c (gtk_dialog_set_has_separator): new function
|
||||
(gtk_dialog_get_has_separator): new function
|
||||
(run_delete_handler): fix to not emit "response" signal
|
||||
because we already did in the delete event handler installed
|
||||
at dialog creation time.
|
||||
|
||||
* gtk/gtkdialog.h: add a has_separator property,
|
||||
add GTK_DIALOG_NO_SEPARATOR flag
|
||||
|
||||
2001-03-07 Havoc Pennington <hp@redhat.com>
|
||||
|
||||
* gtk/gtkwindow.c (gtk_window_set_decorated): new function, turns
|
||||
|
@ -1,3 +1,23 @@
|
||||
2001-03-07 Havoc Pennington <hp@redhat.com>
|
||||
|
||||
* gtk/gtkentry.c (gtk_entry_get_property): remove trailer
|
||||
(gtk_entry_set_property): remove trailer
|
||||
|
||||
* gtk/gtkentry.c (gtk_entry_set_width_chars):
|
||||
(gtk_entry_get_width_chars): new functions, to set size request to
|
||||
a given number of characters
|
||||
|
||||
* gtk/testgtk.c (create_dialog): beef up the dialog test slightly
|
||||
|
||||
* gtk/gtkdialog.c (gtk_dialog_set_has_separator): new function
|
||||
(gtk_dialog_get_has_separator): new function
|
||||
(run_delete_handler): fix to not emit "response" signal
|
||||
because we already did in the delete event handler installed
|
||||
at dialog creation time.
|
||||
|
||||
* gtk/gtkdialog.h: add a has_separator property,
|
||||
add GTK_DIALOG_NO_SEPARATOR flag
|
||||
|
||||
2001-03-07 Havoc Pennington <hp@redhat.com>
|
||||
|
||||
* gtk/gtkwindow.c (gtk_window_set_decorated): new function, turns
|
||||
|
@ -1,3 +1,23 @@
|
||||
2001-03-07 Havoc Pennington <hp@redhat.com>
|
||||
|
||||
* gtk/gtkentry.c (gtk_entry_get_property): remove trailer
|
||||
(gtk_entry_set_property): remove trailer
|
||||
|
||||
* gtk/gtkentry.c (gtk_entry_set_width_chars):
|
||||
(gtk_entry_get_width_chars): new functions, to set size request to
|
||||
a given number of characters
|
||||
|
||||
* gtk/testgtk.c (create_dialog): beef up the dialog test slightly
|
||||
|
||||
* gtk/gtkdialog.c (gtk_dialog_set_has_separator): new function
|
||||
(gtk_dialog_get_has_separator): new function
|
||||
(run_delete_handler): fix to not emit "response" signal
|
||||
because we already did in the delete event handler installed
|
||||
at dialog creation time.
|
||||
|
||||
* gtk/gtkdialog.h: add a has_separator property,
|
||||
add GTK_DIALOG_NO_SEPARATOR flag
|
||||
|
||||
2001-03-07 Havoc Pennington <hp@redhat.com>
|
||||
|
||||
* gtk/gtkwindow.c (gtk_window_set_decorated): new function, turns
|
||||
|
@ -1,3 +1,23 @@
|
||||
2001-03-07 Havoc Pennington <hp@redhat.com>
|
||||
|
||||
* gtk/gtkentry.c (gtk_entry_get_property): remove trailer
|
||||
(gtk_entry_set_property): remove trailer
|
||||
|
||||
* gtk/gtkentry.c (gtk_entry_set_width_chars):
|
||||
(gtk_entry_get_width_chars): new functions, to set size request to
|
||||
a given number of characters
|
||||
|
||||
* gtk/testgtk.c (create_dialog): beef up the dialog test slightly
|
||||
|
||||
* gtk/gtkdialog.c (gtk_dialog_set_has_separator): new function
|
||||
(gtk_dialog_get_has_separator): new function
|
||||
(run_delete_handler): fix to not emit "response" signal
|
||||
because we already did in the delete event handler installed
|
||||
at dialog creation time.
|
||||
|
||||
* gtk/gtkdialog.h: add a has_separator property,
|
||||
add GTK_DIALOG_NO_SEPARATOR flag
|
||||
|
||||
2001-03-07 Havoc Pennington <hp@redhat.com>
|
||||
|
||||
* gtk/gtkwindow.c (gtk_window_set_decorated): new function, turns
|
||||
|
@ -1,3 +1,23 @@
|
||||
2001-03-07 Havoc Pennington <hp@redhat.com>
|
||||
|
||||
* gtk/gtkentry.c (gtk_entry_get_property): remove trailer
|
||||
(gtk_entry_set_property): remove trailer
|
||||
|
||||
* gtk/gtkentry.c (gtk_entry_set_width_chars):
|
||||
(gtk_entry_get_width_chars): new functions, to set size request to
|
||||
a given number of characters
|
||||
|
||||
* gtk/testgtk.c (create_dialog): beef up the dialog test slightly
|
||||
|
||||
* gtk/gtkdialog.c (gtk_dialog_set_has_separator): new function
|
||||
(gtk_dialog_get_has_separator): new function
|
||||
(run_delete_handler): fix to not emit "response" signal
|
||||
because we already did in the delete event handler installed
|
||||
at dialog creation time.
|
||||
|
||||
* gtk/gtkdialog.h: add a has_separator property,
|
||||
add GTK_DIALOG_NO_SEPARATOR flag
|
||||
|
||||
2001-03-07 Havoc Pennington <hp@redhat.com>
|
||||
|
||||
* gtk/gtkwindow.c (gtk_window_set_decorated): new function, turns
|
||||
|
@ -1,3 +1,23 @@
|
||||
2001-03-07 Havoc Pennington <hp@redhat.com>
|
||||
|
||||
* gtk/gtkentry.c (gtk_entry_get_property): remove trailer
|
||||
(gtk_entry_set_property): remove trailer
|
||||
|
||||
* gtk/gtkentry.c (gtk_entry_set_width_chars):
|
||||
(gtk_entry_get_width_chars): new functions, to set size request to
|
||||
a given number of characters
|
||||
|
||||
* gtk/testgtk.c (create_dialog): beef up the dialog test slightly
|
||||
|
||||
* gtk/gtkdialog.c (gtk_dialog_set_has_separator): new function
|
||||
(gtk_dialog_get_has_separator): new function
|
||||
(run_delete_handler): fix to not emit "response" signal
|
||||
because we already did in the delete event handler installed
|
||||
at dialog creation time.
|
||||
|
||||
* gtk/gtkdialog.h: add a has_separator property,
|
||||
add GTK_DIALOG_NO_SEPARATOR flag
|
||||
|
||||
2001-03-07 Havoc Pennington <hp@redhat.com>
|
||||
|
||||
* gtk/gtkwindow.c (gtk_window_set_decorated): new function, turns
|
||||
|
@ -144,6 +144,7 @@ gtk_window_set_title(). See the #GtkWindow section for more).
|
||||
|
||||
@GTK_DIALOG_MODAL:
|
||||
@GTK_DIALOG_DESTROY_WITH_PARENT:
|
||||
@GTK_DIALOG_NO_SEPARATOR:
|
||||
|
||||
<!-- ##### ENUM GtkResponseType ##### -->
|
||||
<para>
|
||||
@ -246,3 +247,8 @@ was clicked.
|
||||
@dialog: the object which received the signal.
|
||||
@arg1: the response ID
|
||||
|
||||
<!-- ##### ARG GtkDialog:has-separator ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
|
@ -300,3 +300,8 @@ are visible or not. See gtk_entry_set_visibility().
|
||||
|
||||
</para>
|
||||
|
||||
<!-- ##### ARG GtkEntry:width-chars ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
|
133
gtk/gtkdialog.c
133
gtk/gtkdialog.c
@ -32,6 +32,7 @@
|
||||
#include "gtksignal.h"
|
||||
#include "gdkkeysyms.h"
|
||||
#include "gtkmain.h"
|
||||
#include "gtkintl.h"
|
||||
|
||||
static void gtk_dialog_class_init (GtkDialogClass *klass);
|
||||
static void gtk_dialog_init (GtkDialog *dialog);
|
||||
@ -46,6 +47,19 @@ static gint gtk_dialog_delete_event_handler (GtkWidget *widget,
|
||||
GdkEventAny *event,
|
||||
gpointer user_data);
|
||||
|
||||
static void gtk_dialog_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gtk_dialog_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_HAS_SEPARATOR
|
||||
};
|
||||
|
||||
enum {
|
||||
RESPONSE,
|
||||
@ -83,16 +97,29 @@ gtk_dialog_get_type (void)
|
||||
static void
|
||||
gtk_dialog_class_init (GtkDialogClass *class)
|
||||
{
|
||||
GObjectClass *gobject_class;
|
||||
GtkObjectClass *object_class;
|
||||
GtkWidgetClass *widget_class;
|
||||
|
||||
object_class = (GtkObjectClass*) class;
|
||||
widget_class = (GtkWidgetClass*) class;
|
||||
|
||||
gobject_class = G_OBJECT_CLASS (class);
|
||||
object_class = GTK_OBJECT_CLASS (class);
|
||||
widget_class = GTK_WIDGET_CLASS (class);
|
||||
|
||||
parent_class = g_type_class_peek_parent (class);
|
||||
|
||||
gobject_class->set_property = gtk_dialog_set_property;
|
||||
gobject_class->get_property = gtk_dialog_get_property;
|
||||
|
||||
widget_class->key_press_event = gtk_dialog_key_press;
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_HAS_SEPARATOR,
|
||||
g_param_spec_boolean ("has_separator",
|
||||
_("Has separator"),
|
||||
_("The dialog has a separator bar above its buttons"),
|
||||
TRUE,
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
dialog_signals[RESPONSE] =
|
||||
gtk_signal_new ("response",
|
||||
GTK_RUN_LAST,
|
||||
@ -106,8 +133,6 @@ gtk_dialog_class_init (GtkDialogClass *class)
|
||||
static void
|
||||
gtk_dialog_init (GtkDialog *dialog)
|
||||
{
|
||||
GtkWidget *separator;
|
||||
|
||||
/* To avoid breaking old code that prevents destroy on delete event
|
||||
* by connecting a handler, we have to have the FIRST signal
|
||||
* connection on the dialog.
|
||||
@ -136,14 +161,59 @@ gtk_dialog_init (GtkDialog *dialog)
|
||||
FALSE, TRUE, 0);
|
||||
gtk_widget_show (dialog->action_area);
|
||||
|
||||
separator = gtk_hseparator_new ();
|
||||
gtk_box_pack_end (GTK_BOX (dialog->vbox), separator, FALSE, TRUE, 0);
|
||||
gtk_widget_show (separator);
|
||||
dialog->separator = gtk_hseparator_new ();
|
||||
gtk_box_pack_end (GTK_BOX (dialog->vbox), dialog->separator, FALSE, TRUE, 0);
|
||||
gtk_widget_show (dialog->separator);
|
||||
|
||||
gtk_window_set_type_hint (GTK_WINDOW (dialog),
|
||||
GDK_WINDOW_TYPE_HINT_DIALOG);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gtk_dialog_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkDialog *dialog;
|
||||
|
||||
dialog = GTK_DIALOG (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_HAS_SEPARATOR:
|
||||
gtk_dialog_set_has_separator (dialog, g_value_get_boolean (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_dialog_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkDialog *dialog;
|
||||
|
||||
dialog = GTK_DIALOG (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_HAS_SEPARATOR:
|
||||
g_value_set_boolean (value, dialog->separator != NULL);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
gtk_dialog_delete_event_handler (GtkWidget *widget,
|
||||
GdkEventAny *event,
|
||||
@ -172,7 +242,7 @@ gtk_dialog_key_press (GtkWidget *widget,
|
||||
if (key->keyval != GDK_Escape)
|
||||
return FALSE;
|
||||
|
||||
/* Synthesize delete_event on key press. */
|
||||
/* Synthesize delete_event to close dialog. */
|
||||
g_object_ref (G_OBJECT (event.window));
|
||||
|
||||
gtk_main_do_event ((GdkEvent*)&event);
|
||||
@ -209,6 +279,9 @@ gtk_dialog_new_empty (const gchar *title,
|
||||
if (flags & GTK_DIALOG_DESTROY_WITH_PARENT)
|
||||
gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
|
||||
|
||||
if (flags & GTK_DIALOG_NO_SEPARATOR)
|
||||
gtk_dialog_set_has_separator (dialog, FALSE);
|
||||
|
||||
return GTK_WIDGET (dialog);
|
||||
}
|
||||
|
||||
@ -233,7 +306,7 @@ gtk_dialog_new_empty (const gchar *title,
|
||||
* enumeration. If the user clicks one of these dialog buttons,
|
||||
* #GtkDialog will emit the "response" signal with the corresponding
|
||||
* response ID. If a #GtkDialog receives the "delete_event" signal, it
|
||||
* will emit "response" with a response ID of GTK_RESPONSE_NONE.
|
||||
* will emit "response" with a response ID of GTK_RESPONSE_DELETE_EVENT.
|
||||
* However, destroying a dialog does not emit the "response" signal;
|
||||
* so be careful relying on "response" when using
|
||||
* the GTK_DIALOG_DESTROY_WITH_PARENT flag. Buttons are from left to right,
|
||||
@ -544,6 +617,43 @@ gtk_dialog_set_default_response (GtkDialog *dialog,
|
||||
g_list_free (children);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_dialog_set_has_separator (GtkDialog *dialog,
|
||||
gboolean setting)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_DIALOG (dialog));
|
||||
|
||||
/* this might fail if we get called before _init() somehow */
|
||||
g_assert (dialog->vbox != NULL);
|
||||
|
||||
if (setting && dialog->separator == NULL)
|
||||
{
|
||||
dialog->separator = gtk_hseparator_new ();
|
||||
gtk_box_pack_end (GTK_BOX (dialog->vbox), dialog->separator, FALSE, TRUE, 0);
|
||||
|
||||
/* The app programmer could screw this up, but, their own fault.
|
||||
* Moves the separator just above the action area.
|
||||
*/
|
||||
gtk_box_reorder_child (GTK_BOX (dialog->vbox), dialog->separator, 1);
|
||||
gtk_widget_show (dialog->separator);
|
||||
}
|
||||
else if (!setting && dialog->separator != NULL)
|
||||
{
|
||||
gtk_widget_destroy (dialog->separator);
|
||||
dialog->separator = NULL;
|
||||
}
|
||||
|
||||
g_object_notify (G_OBJECT (dialog), "has_separator");
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_dialog_get_has_separator (GtkDialog *dialog)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_DIALOG (dialog), FALSE);
|
||||
|
||||
return dialog->separator != NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_dialog_response:
|
||||
* @dialog: a #GtkDialog
|
||||
@ -610,9 +720,6 @@ run_delete_handler (GtkDialog *dialog,
|
||||
RunInfo *ri = data;
|
||||
|
||||
shutdown_loop (ri);
|
||||
|
||||
/* emit response signal */
|
||||
gtk_dialog_response (dialog, GTK_RESPONSE_NONE);
|
||||
|
||||
return TRUE; /* Do not destroy */
|
||||
}
|
||||
|
@ -39,9 +39,9 @@ extern "C" {
|
||||
/* 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 () */
|
||||
|
||||
GTK_DIALOG_MODAL, /* call gtk_window_set_modal (win, TRUE) */
|
||||
GTK_DIALOG_DESTROY_WITH_PARENT, /* call gtk_window_set_destroy_with_parent () */
|
||||
GTK_DIALOG_NO_SEPARATOR /* no separator bar above buttons */
|
||||
} GtkDialogFlags;
|
||||
|
||||
/* Convenience enum to use for response_id's. Positive values are
|
||||
@ -99,6 +99,9 @@ struct _GtkDialog
|
||||
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *action_area;
|
||||
|
||||
/*< private >*/
|
||||
GtkWidget *separator;
|
||||
};
|
||||
|
||||
struct _GtkDialogClass
|
||||
@ -134,6 +137,10 @@ void gtk_dialog_set_response_sensitive (GtkDialog *dialog,
|
||||
void gtk_dialog_set_default_response (GtkDialog *dialog,
|
||||
gint response_id);
|
||||
|
||||
void gtk_dialog_set_has_separator (GtkDialog *dialog,
|
||||
gboolean setting);
|
||||
gboolean gtk_dialog_get_has_separator (GtkDialog *dialog);
|
||||
|
||||
/* Emit response signal */
|
||||
void gtk_dialog_response (GtkDialog *dialog,
|
||||
gint response_id);
|
||||
|
102
gtk/gtkentry.c
102
gtk/gtkentry.c
@ -75,7 +75,8 @@ enum {
|
||||
PROP_MAX_LENGTH,
|
||||
PROP_VISIBILITY,
|
||||
PROP_INVISIBLE_CHAR,
|
||||
PROP_ACTIVATES_DEFAULT
|
||||
PROP_ACTIVATES_DEFAULT,
|
||||
PROP_WIDTH_CHARS
|
||||
};
|
||||
|
||||
static guint signals[LAST_SIGNAL] = { 0 };
|
||||
@ -101,13 +102,11 @@ static void gtk_entry_init (GtkEntry *entry);
|
||||
static void gtk_entry_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec,
|
||||
const gchar *trailer);
|
||||
GParamSpec *pspec);
|
||||
static void gtk_entry_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec,
|
||||
const gchar *trailer);
|
||||
GParamSpec *pspec);
|
||||
static void gtk_entry_finalize (GObject *object);
|
||||
|
||||
/* GtkWidget methods
|
||||
@ -412,6 +411,16 @@ gtk_entry_class_init (GtkEntryClass *class)
|
||||
_("Whether to activate the default widget (such as the default button in a dialog) when Enter is pressed."),
|
||||
FALSE,
|
||||
G_PARAM_READABLE | G_PARAM_WRITABLE));
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_WIDTH_CHARS,
|
||||
g_param_spec_int ("width_chars",
|
||||
_("Width in chars"),
|
||||
_("Number of characters to leave space for in the entry."),
|
||||
-1,
|
||||
G_MAXINT,
|
||||
|
||||
-1,
|
||||
G_PARAM_READABLE | G_PARAM_WRITABLE));
|
||||
|
||||
signals[INSERT_TEXT] =
|
||||
gtk_signal_new ("insert_text",
|
||||
@ -648,11 +657,11 @@ gtk_entry_editable_init (GtkEditableClass *iface)
|
||||
iface->get_position = gtk_entry_get_position;
|
||||
}
|
||||
|
||||
static void gtk_entry_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec,
|
||||
const gchar *trailer)
|
||||
static void
|
||||
gtk_entry_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkEntry *entry = GTK_ENTRY (object);
|
||||
|
||||
@ -690,6 +699,10 @@ static void gtk_entry_set_property (GObject *object,
|
||||
case PROP_ACTIVATES_DEFAULT:
|
||||
gtk_entry_set_activates_default (entry, g_value_get_boolean (value));
|
||||
break;
|
||||
|
||||
case PROP_WIDTH_CHARS:
|
||||
gtk_entry_set_width_chars (entry, g_value_get_int (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
@ -697,11 +710,11 @@ static void gtk_entry_set_property (GObject *object,
|
||||
}
|
||||
}
|
||||
|
||||
static void gtk_entry_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec,
|
||||
const gchar *trailer)
|
||||
static void
|
||||
gtk_entry_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkEntry *entry;
|
||||
|
||||
@ -727,6 +740,10 @@ static void gtk_entry_get_property (GObject *object,
|
||||
case PROP_ACTIVATES_DEFAULT:
|
||||
g_value_set_boolean (value, entry->activates_default);
|
||||
break;
|
||||
case PROP_WIDTH_CHARS:
|
||||
g_value_set_int (value, entry->width_chars);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
@ -746,7 +763,8 @@ gtk_entry_init (GtkEntry *entry)
|
||||
entry->visible = TRUE;
|
||||
entry->invisible_char = '*';
|
||||
entry->dnd_position = -1;
|
||||
|
||||
entry->width_chars = -1;
|
||||
|
||||
entry->has_frame = TRUE;
|
||||
|
||||
gtk_drag_dest_set (GTK_WIDGET (entry),
|
||||
@ -935,8 +953,16 @@ gtk_entry_size_request (GtkWidget *widget,
|
||||
xborder += 1;
|
||||
yborder += 1;
|
||||
}
|
||||
|
||||
requisition->width = MIN_ENTRY_WIDTH + xborder * 2;
|
||||
|
||||
if (entry->width_chars < 0)
|
||||
requisition->width = MIN_ENTRY_WIDTH + xborder * 2;
|
||||
else
|
||||
{
|
||||
requisition->width =
|
||||
PANGO_PIXELS (metrics.approximate_char_width) * entry->width_chars +
|
||||
xborder * 2;
|
||||
}
|
||||
|
||||
requisition->height = ((metrics.ascent + metrics.descent) / PANGO_SCALE +
|
||||
yborder * 2);
|
||||
}
|
||||
@ -2955,6 +2981,46 @@ gtk_entry_get_activates_default (GtkEntry *entry)
|
||||
return entry->activates_default;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_entry_set_width_chars:
|
||||
* @entry: a #GtkEntry
|
||||
* @n_chars: width in chars
|
||||
*
|
||||
* Changes the size request of the entry to be about the right size
|
||||
* for @n_chars characters. Note that it changes the size
|
||||
* <emphasize>request</emphasize>, the size can still be affected by
|
||||
* how you pack the widget into containers. If @n_chars is -1, the
|
||||
* size reverts to the default entry size.
|
||||
*
|
||||
**/
|
||||
void
|
||||
gtk_entry_set_width_chars (GtkEntry *entry,
|
||||
gint n_chars)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_ENTRY (entry));
|
||||
|
||||
if (entry->width_chars != n_chars)
|
||||
{
|
||||
entry->width_chars = n_chars;
|
||||
g_object_notify (G_OBJECT (entry), "width_chars");
|
||||
gtk_widget_queue_resize (GTK_WIDGET (entry));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_entry_get_width_chars:
|
||||
* @entry: a #GtkEntry
|
||||
*
|
||||
* Gets the value set by gtk_entry_set_width_chars().
|
||||
*
|
||||
* Return value: number of chars to request space for, or negative if unset
|
||||
**/
|
||||
gint
|
||||
gtk_entry_get_width_chars (GtkEntry *entry)
|
||||
{
|
||||
return entry->width_chars;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_entry_set_has_frame:
|
||||
* @entry: a #GtkEntry
|
||||
|
@ -99,6 +99,8 @@ struct _GtkEntry
|
||||
gint drag_start_y;
|
||||
|
||||
gunichar invisible_char;
|
||||
|
||||
gint width_chars;
|
||||
};
|
||||
|
||||
struct _GtkEntryClass
|
||||
@ -152,6 +154,10 @@ void gtk_entry_set_activates_default (GtkEntry *entry,
|
||||
gboolean setting);
|
||||
gboolean gtk_entry_get_activates_default (GtkEntry *entry);
|
||||
|
||||
void gtk_entry_set_width_chars (GtkEntry *entry,
|
||||
gint n_chars);
|
||||
gint gtk_entry_get_width_chars (GtkEntry *entry);
|
||||
|
||||
/* Somewhat more convenient than the GtkEditable generic functions
|
||||
*/
|
||||
void gtk_entry_set_text (GtkEntry *entry,
|
||||
|
@ -482,14 +482,21 @@ static void
|
||||
gtk_spin_button_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition)
|
||||
{
|
||||
GtkEntry *entry;
|
||||
|
||||
g_return_if_fail (widget != NULL);
|
||||
g_return_if_fail (requisition != NULL);
|
||||
g_return_if_fail (GTK_IS_SPIN_BUTTON (widget));
|
||||
|
||||
GTK_WIDGET_CLASS (parent_class)->size_request (widget, requisition);
|
||||
entry = GTK_ENTRY (widget);
|
||||
|
||||
requisition->width = MIN_SPIN_BUTTON_WIDTH + ARROW_SIZE
|
||||
+ 2 * widget->style->xthickness;
|
||||
GTK_WIDGET_CLASS (parent_class)->size_request (widget, requisition);
|
||||
|
||||
if (entry->width_chars < 0)
|
||||
requisition->width = MIN_SPIN_BUTTON_WIDTH + ARROW_SIZE +
|
||||
2 * widget->style->xthickness;
|
||||
else
|
||||
requisition->width += ARROW_SIZE + 2 * widget->style->xthickness;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -6138,6 +6138,22 @@ label_toggle (GtkWidget *widget,
|
||||
gtk_widget_destroy (*label);
|
||||
}
|
||||
|
||||
#define RESPONSE_TOGGLE_SEPARATOR 1
|
||||
|
||||
static void
|
||||
print_response (GtkWidget *dialog,
|
||||
gint response_id,
|
||||
gpointer data)
|
||||
{
|
||||
g_print ("response signal received (%d)\n", response_id);
|
||||
|
||||
if (response_id == RESPONSE_TOGGLE_SEPARATOR)
|
||||
{
|
||||
gtk_dialog_set_has_separator (GTK_DIALOG (dialog),
|
||||
!gtk_dialog_get_has_separator (GTK_DIALOG (dialog)));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
create_dialog (void)
|
||||
{
|
||||
@ -6146,15 +6162,24 @@ create_dialog (void)
|
||||
|
||||
if (!dialog_window)
|
||||
{
|
||||
/* This is a terrible example; it's much simpler to create
|
||||
* dialogs than this. Don't use testgtk for example code,
|
||||
* use gtk-demo ;-)
|
||||
*/
|
||||
|
||||
dialog_window = gtk_dialog_new ();
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (dialog_window),
|
||||
"response",
|
||||
GTK_SIGNAL_FUNC (print_response),
|
||||
NULL);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (dialog_window), "destroy",
|
||||
GTK_SIGNAL_FUNC(gtk_widget_destroyed),
|
||||
&dialog_window);
|
||||
|
||||
gtk_window_set_title (GTK_WINDOW (dialog_window), "GtkDialog");
|
||||
gtk_container_set_border_width (GTK_CONTAINER (dialog_window), 0);
|
||||
gtk_widget_set_usize (dialog_window, 200, 110);
|
||||
|
||||
button = gtk_button_new_with_label ("OK");
|
||||
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
|
||||
@ -6173,6 +6198,15 @@ create_dialog (void)
|
||||
gtk_widget_show (button);
|
||||
|
||||
label = NULL;
|
||||
|
||||
button = gtk_button_new_with_label ("Separator");
|
||||
|
||||
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
|
||||
|
||||
gtk_dialog_add_action_widget (GTK_DIALOG (dialog_window),
|
||||
button,
|
||||
RESPONSE_TOGGLE_SEPARATOR);
|
||||
gtk_widget_show (button);
|
||||
}
|
||||
|
||||
if (!GTK_WIDGET_VISIBLE (dialog_window))
|
||||
|
@ -6138,6 +6138,22 @@ label_toggle (GtkWidget *widget,
|
||||
gtk_widget_destroy (*label);
|
||||
}
|
||||
|
||||
#define RESPONSE_TOGGLE_SEPARATOR 1
|
||||
|
||||
static void
|
||||
print_response (GtkWidget *dialog,
|
||||
gint response_id,
|
||||
gpointer data)
|
||||
{
|
||||
g_print ("response signal received (%d)\n", response_id);
|
||||
|
||||
if (response_id == RESPONSE_TOGGLE_SEPARATOR)
|
||||
{
|
||||
gtk_dialog_set_has_separator (GTK_DIALOG (dialog),
|
||||
!gtk_dialog_get_has_separator (GTK_DIALOG (dialog)));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
create_dialog (void)
|
||||
{
|
||||
@ -6146,15 +6162,24 @@ create_dialog (void)
|
||||
|
||||
if (!dialog_window)
|
||||
{
|
||||
/* This is a terrible example; it's much simpler to create
|
||||
* dialogs than this. Don't use testgtk for example code,
|
||||
* use gtk-demo ;-)
|
||||
*/
|
||||
|
||||
dialog_window = gtk_dialog_new ();
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (dialog_window),
|
||||
"response",
|
||||
GTK_SIGNAL_FUNC (print_response),
|
||||
NULL);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (dialog_window), "destroy",
|
||||
GTK_SIGNAL_FUNC(gtk_widget_destroyed),
|
||||
&dialog_window);
|
||||
|
||||
gtk_window_set_title (GTK_WINDOW (dialog_window), "GtkDialog");
|
||||
gtk_container_set_border_width (GTK_CONTAINER (dialog_window), 0);
|
||||
gtk_widget_set_usize (dialog_window, 200, 110);
|
||||
|
||||
button = gtk_button_new_with_label ("OK");
|
||||
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
|
||||
@ -6173,6 +6198,15 @@ create_dialog (void)
|
||||
gtk_widget_show (button);
|
||||
|
||||
label = NULL;
|
||||
|
||||
button = gtk_button_new_with_label ("Separator");
|
||||
|
||||
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
|
||||
|
||||
gtk_dialog_add_action_widget (GTK_DIALOG (dialog_window),
|
||||
button,
|
||||
RESPONSE_TOGGLE_SEPARATOR);
|
||||
gtk_widget_show (button);
|
||||
}
|
||||
|
||||
if (!GTK_WIDGET_VISIBLE (dialog_window))
|
||||
|
Loading…
Reference in New Issue
Block a user