Add constrained sizing to the widgets. This gives us all images running

Thu Sep 16 00:33:11 2004  Jonathan Blandford  <jrb@gnome.org>

        * docs/tools/widgets.c (new_widget_info): Add constrained sizing
        to the widgets.  This gives us all images running the same size,
        which will make the table layout look better.
This commit is contained in:
Jonathan Blandford 2004-09-16 04:34:21 +00:00 committed by Jonathan Blandford
parent bd2aaa4bad
commit 1f3000ceb9
5 changed files with 121 additions and 61 deletions

View File

@ -1,3 +1,9 @@
Thu Sep 16 00:33:11 2004 Jonathan Blandford <jrb@gnome.org>
* docs/tools/widgets.c (new_widget_info): Add constrained sizing
to the widgets. This gives us all images running the same size,
which will make the table layout look better.
2004-09-15 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents):

View File

@ -1,3 +1,9 @@
Thu Sep 16 00:33:11 2004 Jonathan Blandford <jrb@gnome.org>
* docs/tools/widgets.c (new_widget_info): Add constrained sizing
to the widgets. This gives us all images running the same size,
which will make the table layout look better.
2004-09-15 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents):

View File

@ -1,3 +1,9 @@
Thu Sep 16 00:33:11 2004 Jonathan Blandford <jrb@gnome.org>
* docs/tools/widgets.c (new_widget_info): Add constrained sizing
to the widgets. This gives us all images running the same size,
which will make the table layout look better.
2004-09-15 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents):

View File

@ -1,3 +1,9 @@
Thu Sep 16 00:33:11 2004 Jonathan Blandford <jrb@gnome.org>
* docs/tools/widgets.c (new_widget_info): Add constrained sizing
to the widgets. This gives us all images running the same size,
which will make the table layout look better.
2004-09-15 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkwindow-win32.c (gdk_window_get_frame_extents):

View File

@ -1,10 +1,17 @@
#include <gdk/gdkkeysyms.h>
#include "widgets.h"
typedef enum
{
SMALL,
MEDIUM,
LARGE
} WidgetSize;
static WidgetInfo *
new_widget_info (const char *name,
GtkWidget *widget)
GtkWidget *widget,
WidgetSize size)
{
WidgetInfo *info;
@ -19,7 +26,25 @@ new_widget_info (const char *name,
gtk_container_set_border_width (GTK_CONTAINER (info->window), 12);
gtk_widget_show_all (widget);
gtk_container_add (GTK_CONTAINER (info->window), widget);
switch (size)
{
case SMALL:
gtk_widget_set_size_request (info->window,
240, 75);
break;
case MEDIUM:
gtk_widget_set_size_request (info->window,
240, 165);
break;
case LARGE:
gtk_widget_set_size_request (info->window,
240, 240);
break;
default:
break;
}
return info;
}
@ -27,44 +52,56 @@ static WidgetInfo *
create_button (void)
{
GtkWidget *widget;
widget = gtk_button_new_with_mnemonic ("_Button");
GtkWidget *align;
return new_widget_info ("button", widget);
widget = gtk_button_new_with_mnemonic ("_Button");
align = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
gtk_container_add (GTK_CONTAINER (align), widget);
return new_widget_info ("button", align, SMALL);
}
static WidgetInfo *
create_toggle_button (void)
{
GtkWidget *widget;
GtkWidget *align;
widget = gtk_toggle_button_new_with_mnemonic ("_Toggle Button");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);
align = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
gtk_container_add (GTK_CONTAINER (align), widget);
return new_widget_info ("toggle-button", widget);
return new_widget_info ("toggle-button", align, SMALL);
}
static WidgetInfo *
create_check_button (void)
{
GtkWidget *widget;
GtkWidget *align;
widget = gtk_check_button_new_with_mnemonic ("_Check Button");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
align = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
gtk_container_add (GTK_CONTAINER (align), widget);
return new_widget_info ("check-button", widget);
return new_widget_info ("check-button", align, SMALL);
}
static WidgetInfo *
create_entry (void)
{
GtkWidget *widget;
GtkWidget *align;
widget = gtk_entry_new ();
gtk_entry_set_text (GTK_ENTRY (widget), "Entry");
gtk_editable_set_position (GTK_EDITABLE (widget), -1);
return new_widget_info ("entry", widget);
align = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
gtk_container_add (GTK_CONTAINER (align), widget);
return new_widget_info ("entry", align, SMALL);
}
static WidgetInfo *
@ -72,26 +109,32 @@ create_radio (void)
{
GtkWidget *widget;
GtkWidget *radio;
widget = gtk_vbox_new (FALSE, 3);
radio = gtk_radio_button_new_with_mnemonic (NULL, "Radio Button Item _One");
gtk_box_pack_start (GTK_BOX (widget), radio, FALSE, FALSE, 0);
radio = gtk_radio_button_new_with_mnemonic_from_widget (GTK_RADIO_BUTTON (radio), "Radio Button Item _Two");
gtk_box_pack_start (GTK_BOX (widget), radio, FALSE, FALSE, 0);
radio = gtk_radio_button_new_with_mnemonic_from_widget (GTK_RADIO_BUTTON (radio), "Radio Button Item T_hree");
gtk_box_pack_start (GTK_BOX (widget), radio, FALSE, FALSE, 0);
GtkWidget *align;
return new_widget_info ("radio-group", widget);
widget = gtk_vbox_new (FALSE, 3);
radio = gtk_radio_button_new_with_mnemonic (NULL, "Radio Button _One");
gtk_box_pack_start (GTK_BOX (widget), radio, FALSE, FALSE, 0);
radio = gtk_radio_button_new_with_mnemonic_from_widget (GTK_RADIO_BUTTON (radio), "Radio Button _Two");
gtk_box_pack_start (GTK_BOX (widget), radio, FALSE, FALSE, 0);
radio = gtk_radio_button_new_with_mnemonic_from_widget (GTK_RADIO_BUTTON (radio), "Radio Button T_hree");
gtk_box_pack_start (GTK_BOX (widget), radio, FALSE, FALSE, 0);
align = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
gtk_container_add (GTK_CONTAINER (align), widget);
return new_widget_info ("radio-group", align, MEDIUM);
}
static WidgetInfo *
create_label (void)
{
GtkWidget *widget;
GtkWidget *align;
widget = gtk_label_new ("Label");
align = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
gtk_container_add (GTK_CONTAINER (align), widget);
return new_widget_info ("label", widget);
return new_widget_info ("label", align, SMALL);
}
static WidgetInfo *
@ -106,7 +149,7 @@ create_accel_label (void)
button = gtk_button_new_with_label ("Quit");
gtk_accel_label_set_accel_widget (GTK_ACCEL_LABEL (widget), button);
gtk_widget_set_no_show_all (button, TRUE);
box = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (box), widget);
gtk_container_add (GTK_CONTAINER (box), button);
@ -114,19 +157,8 @@ create_accel_label (void)
gtk_accel_label_set_accel_widget (GTK_ACCEL_LABEL (widget), button);
accel_group = gtk_accel_group_new();
info = g_new0 (WidgetInfo, 1);
info->name = g_strdup ("accel-label");
info->window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_widget_set_size_request (info->window, 200, -1);
gtk_widget_show_all (box);
gtk_container_add (GTK_CONTAINER (info->window), box);
info = new_widget_info ("accel-label", box, SMALL);
info->no_focus = TRUE;
info->include_decorations = FALSE;
gtk_widget_set_app_paintable (info->window, TRUE);
g_signal_connect (info->window, "focus", G_CALLBACK (gtk_true), NULL);
gtk_container_set_border_width (GTK_CONTAINER (info->window), 12);
gtk_widget_add_accelerator (button, "activate", accel_group, GDK_Q, GDK_CONTROL_MASK,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
@ -137,12 +169,14 @@ static WidgetInfo *
create_combo_box_entry (void)
{
GtkWidget *widget;
GtkWidget *align;
widget = gtk_combo_box_entry_new_text ();
gtk_entry_set_text (GTK_ENTRY (GTK_BIN (widget)->child), "Combo Box Entry");
align = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
gtk_container_add (GTK_CONTAINER (align), widget);
return new_widget_info ("combo-box-entry", widget);
return new_widget_info ("combo-box-entry", align, SMALL);
}
static WidgetInfo *
@ -157,10 +191,10 @@ create_text_view (void)
gtk_container_add (GTK_CONTAINER (widget), text_view);
/* Bad hack to add some size to the widget */
gtk_text_buffer_set_text (gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view)),
"Multiline \nText\n\n", -1);
"Multiline\nText\n\n", -1);
gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (text_view), FALSE);
return new_widget_info ("multiline-text", widget);
return new_widget_info ("multiline-text", widget, MEDIUM);
}
static WidgetInfo *
@ -188,8 +222,8 @@ create_tree_view (void)
gtk_cell_renderer_text_new (),
"text", 0, NULL);
gtk_container_add (GTK_CONTAINER (widget), tree_view);
info = new_widget_info ("list-and-tree", widget);
info = new_widget_info ("list-and-tree", widget, MEDIUM);
info->no_focus = FALSE;
return info;
@ -222,19 +256,18 @@ create_icon_view (void)
gtk_icon_view_set_model (GTK_ICON_VIEW (icon_view), GTK_TREE_MODEL (list_store));
gtk_icon_view_set_text_column (GTK_ICON_VIEW (icon_view), 0);
gtk_icon_view_set_pixbuf_column (GTK_ICON_VIEW (icon_view), 1);
gtk_widget_set_size_request (icon_view, 220, 60);
gtk_container_add (GTK_CONTAINER (widget), icon_view);
vbox = gtk_vbox_new (FALSE, 3);
align = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
align = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
gtk_container_add (GTK_CONTAINER (align), widget);
gtk_box_pack_start (GTK_BOX (vbox), align, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), align, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (vbox),
gtk_label_new ("Icon View"),
FALSE, FALSE, 0);
info = new_widget_info ("icon-view", vbox);
info = new_widget_info ("icon-view", vbox, MEDIUM);
info->no_focus = FALSE;
return info;
@ -260,7 +293,7 @@ create_color_button (void)
gtk_label_new ("Color Button"),
FALSE, FALSE, 0);
return new_widget_info ("color-button", vbox);
return new_widget_info ("color-button", vbox, SMALL);
}
static WidgetInfo *
@ -279,7 +312,7 @@ create_font_button (void)
gtk_label_new ("Font Button"),
FALSE, FALSE, 0);
return new_widget_info ("font-button", vbox);
return new_widget_info ("font-button", vbox, SMALL);
}
static WidgetInfo *
@ -300,7 +333,7 @@ create_file_button (void)
gtk_label_new ("File Button"),
FALSE, FALSE, 0);
return new_widget_info ("file-button", vbox);
return new_widget_info ("file-button", vbox, SMALL);
}
static WidgetInfo *
@ -317,12 +350,15 @@ create_separator (void)
gtk_box_pack_start (GTK_BOX (hbox),
gtk_vseparator_new (),
TRUE, TRUE, 0);
gtk_widget_set_size_request (hbox, 200, 150);
// gtk_widget_set_size_request (hbox, 200, 150);
gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (vbox),
gtk_label_new ("Horizontal and Vertical Separators"),
g_object_new (GTK_TYPE_LABEL,
"label", "Horizontal and Vertical\nSeparators",
"justify", GTK_JUSTIFY_CENTER,
NULL),
FALSE, FALSE, 0);
return new_widget_info ("separator", vbox);
return new_widget_info ("separator", vbox, LARGE);
}
static WidgetInfo *
@ -362,12 +398,14 @@ create_panes (void)
gtk_box_pack_start (GTK_BOX (hbox),
pane,
TRUE, TRUE, 0);
gtk_widget_set_size_request (hbox, 200, 150);
gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (vbox),
gtk_label_new ("Horizontal and Vertical Panes"),
g_object_new (GTK_TYPE_LABEL,
"label", "Horizontal and Vertical\nPanes",
"justify", GTK_JUSTIFY_CENTER,
NULL),
FALSE, FALSE, 0);
return new_widget_info ("panes", vbox);
return new_widget_info ("panes", vbox, LARGE);
}
static WidgetInfo *
@ -376,9 +414,8 @@ create_frame (void)
GtkWidget *widget;
widget = gtk_frame_new ("Frame");
gtk_widget_set_size_request (widget, 150, 150);
return new_widget_info ("frame", widget);
return new_widget_info ("frame", widget, MEDIUM);
}
static WidgetInfo *
@ -389,8 +426,7 @@ create_window (void)
widget = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (widget), GTK_SHADOW_NONE);
gtk_widget_set_size_request (widget, 150, 150);
info = new_widget_info ("window", widget);
info = new_widget_info ("window", widget, MEDIUM);
info->include_decorations = TRUE;
gtk_window_set_title (GTK_WINDOW (info->window), "Window");
@ -420,6 +456,6 @@ get_all_widgets (void)
retval = g_list_prepend (retval, create_accel_label ());
retval = g_list_prepend (retval, create_file_button ());
retval = g_list_prepend (retval, create_icon_view ());
return retval;
}