dialog padding patch
- From: Havoc Pennington <hp redhat com>
- To: gtk-devel-list gnome org
- Subject: dialog padding patch
- Date: 19 Apr 2001 22:53:05 -0400
Hi,
This one makes the various GtkDialog/GtkMessageDialog spacings part of
the theme, so you can have a theme with unchubby dialogs.
I also have a patch at work to make the default button box
paddings/spacings/sizes be part of the theme.
With these two patches plus setting xthickness/ythickness to 0 you can
have a hideously ugly theme, but with absolutely zero space
wastage. ;-) In dialogs anyway...
Havoc
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtk+/ChangeLog,v
retrieving revision 1.1907
diff -u -u -r1.1907 ChangeLog
--- ChangeLog 2001/04/18 22:21:42 1.1907
+++ ChangeLog 2001/04/20 02:45:01
@@ -1,3 +1,11 @@
+2001-04-19 Havoc Pennington <hp pobox com>
+
+ * gtk/gtkmessagedialog.c (gtk_message_dialog_init): strip out a
+ bunch of extra padding that served no purpose
+
+ * gtk/gtkdialog.c: Make all the spacings configurable via style
+ properties, for chubbiness configuration in themes
+
2001-04-18 Havoc Pennington <hp redhat com>
* gtk/gtkwindow.c (gtk_window_class_init): add signals and binding
Index: gtk/gtkdialog.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkdialog.c,v
retrieving revision 1.22
diff -u -u -r1.22 gtkdialog.c
--- gtk/gtkdialog.c 2001/03/21 18:58:15 1.22
+++ gtk/gtkdialog.c 2001/04/20 02:45:01
@@ -55,6 +55,8 @@
guint prop_id,
GValue *value,
GParamSpec *pspec);
+static void gtk_dialog_style_set (GtkWidget *widget,
+ GtkStyle *prev_style);
enum {
PROP_0,
@@ -111,7 +113,8 @@
gobject_class->get_property = gtk_dialog_get_property;
widget_class->key_press_event = gtk_dialog_key_press;
-
+ widget_class->style_set = gtk_dialog_style_set;
+
g_object_class_install_property (gobject_class,
PROP_HAS_SEPARATOR,
g_param_spec_boolean ("has_separator",
@@ -128,6 +131,59 @@
gtk_marshal_NONE__INT,
GTK_TYPE_NONE, 1,
GTK_TYPE_INT);
+
+ gtk_widget_class_install_style_property (widget_class,
+ g_param_spec_int ("content_area_border",
+ _("Content area border"),
+ _("Width of border around the main dialog area"),
+ 0,
+ G_MAXINT,
+ 2,
+ G_PARAM_READABLE));
+ gtk_widget_class_install_style_property (widget_class,
+ g_param_spec_int ("button_spacing",
+ _("Button spacing"),
+ _("Spacing between buttons"),
+ 0,
+ G_MAXINT,
+ 1,
+ G_PARAM_READABLE));
+
+ gtk_widget_class_install_style_property (widget_class,
+ g_param_spec_int ("action_area_border",
+ _("Action area border"),
+ _("Width of border around the button area at the bottom of the dialog"),
+ 0,
+ G_MAXINT,
+ 0,
+ G_PARAM_READABLE));
+}
+
+static void
+update_spacings (GtkDialog *dialog)
+{
+ GtkWidget *widget;
+ gint content_area_border;
+ gint button_spacing;
+ gint action_area_border;
+
+ widget = GTK_WIDGET (dialog);
+
+ gtk_widget_style_get (widget,
+ "content_area_border",
+ &content_area_border,
+ "button_spacing",
+ &button_spacing,
+ "action_area_border",
+ &action_area_border,
+ NULL);
+
+ gtk_container_set_border_width (GTK_CONTAINER (dialog->vbox),
+ content_area_border);
+ gtk_box_set_spacing (GTK_BOX (dialog->action_area),
+ button_spacing);
+ gtk_container_set_border_width (GTK_CONTAINER (dialog->action_area),
+ action_area_border);
}
static void
@@ -143,8 +199,6 @@
NULL);
dialog->vbox = gtk_vbox_new (FALSE, 0);
-
- gtk_container_set_border_width (GTK_CONTAINER (dialog->vbox), 2);
gtk_container_add (GTK_CONTAINER (dialog), dialog->vbox);
gtk_widget_show (dialog->vbox);
@@ -152,11 +206,8 @@
dialog->action_area = gtk_hbutton_box_new ();
gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog->action_area),
- GTK_BUTTONBOX_END);
+ GTK_BUTTONBOX_END);
- gtk_box_set_spacing (GTK_BOX (dialog->action_area), 5);
-
- gtk_container_set_border_width (GTK_CONTAINER (dialog->action_area), 5);
gtk_box_pack_end (GTK_BOX (dialog->vbox), dialog->action_area,
FALSE, TRUE, 0);
gtk_widget_show (dialog->action_area);
@@ -252,6 +303,13 @@
return TRUE;
}
+static void
+gtk_dialog_style_set (GtkWidget *widget,
+ GtkStyle *prev_style)
+{
+ update_spacings (GTK_DIALOG (widget));
+}
+
GtkWidget*
gtk_dialog_new (void)
{
@@ -444,7 +502,7 @@
gtk_box_pack_end (GTK_BOX (dialog->action_area),
child,
- FALSE, TRUE, 5);
+ FALSE, TRUE, 0);
}
/**
Index: gtk/gtkmessagedialog.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkmessagedialog.c,v
retrieving revision 1.3
diff -u -u -r1.3 gtkmessagedialog.c
--- gtk/gtkmessagedialog.c 2000/11/06 16:44:01 1.3
+++ gtk/gtkmessagedialog.c 2001/04/20 02:45:01
@@ -30,10 +30,14 @@
#include "gtkimage.h"
#include "gtkstock.h"
#include "gtkiconfactory.h"
+#include "gtkintl.h"
static void gtk_message_dialog_class_init (GtkMessageDialogClass *klass);
static void gtk_message_dialog_init (GtkMessageDialog *dialog);
+static void gtk_message_dialog_style_set (GtkWidget *widget,
+ GtkStyle *prev_style);
+static gpointer parent_class;
GtkType
gtk_message_dialog_get_type (void)
@@ -63,6 +67,22 @@
static void
gtk_message_dialog_class_init (GtkMessageDialogClass *class)
{
+ GtkWidgetClass *widget_class;
+
+ widget_class = GTK_WIDGET_CLASS (class);
+
+ parent_class = g_type_class_peek_parent (class);
+
+ widget_class->style_set = gtk_message_dialog_style_set;
+
+ gtk_widget_class_install_style_property (widget_class,
+ g_param_spec_int ("message_border",
+ _("Image/label border"),
+ _("Width of border around the label and image in the message dialog"),
+ 0,
+ G_MAXINT,
+ 8,
+ G_PARAM_READABLE));
}
static void
@@ -75,19 +95,17 @@
gtk_label_set_line_wrap (GTK_LABEL (dialog->label), TRUE);
- hbox = gtk_hbox_new (FALSE, 10);
+ hbox = gtk_hbox_new (FALSE, 6);
- gtk_container_set_border_width (GTK_CONTAINER (hbox), 10);
-
gtk_box_pack_start (GTK_BOX (hbox), dialog->image,
- FALSE, FALSE, 2);
+ FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox), dialog->label,
- TRUE, TRUE, 2);
+ TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
hbox,
- FALSE, FALSE, 10);
+ FALSE, FALSE, 0);
gtk_widget_show_all (hbox);
}
@@ -246,4 +264,26 @@
}
return widget;
+}
+
+static void
+gtk_message_dialog_style_set (GtkWidget *widget,
+ GtkStyle *prev_style)
+{
+ GtkWidget *parent;
+ gint border_width = 0;
+
+ parent = GTK_WIDGET (GTK_MESSAGE_DIALOG (widget)->image->parent);
+
+ if (parent)
+ {
+ gtk_widget_style_get (widget, "message_border",
+ &border_width, NULL);
+
+ gtk_container_set_border_width (GTK_CONTAINER (parent),
+ border_width);
+ }
+
+ if (GTK_WIDGET_CLASS (parent_class)->style_set)
+ (GTK_WIDGET_CLASS (parent_class)->style_set) (widget, prev_style);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]