forked from AuroraMiddleware/gtk
new widget from Lars Hamann <hamann@braunschweig.netsurf.de> and Stefan
Wed Feb 25 22:56:42 1998 Tim Janik <timj@gimp.org> * gtk/gtkspinbutton.h: * gtk/gtkspinbutton.c: new widget from Lars Hamann <hamann@braunschweig.netsurf.de> and Stefan Jeske <jeske@braunschweig.netsurf.de>. * gtk/gtknotebook.c: fixups from lars and stefan.
This commit is contained in:
parent
3cdf88be4d
commit
6c2818881d
@ -1,3 +1,12 @@
|
||||
Wed Feb 25 22:56:42 1998 Tim Janik <timj@gimp.org>
|
||||
|
||||
* gtk/gtkspinbutton.h:
|
||||
* gtk/gtkspinbutton.c:
|
||||
new widget from Lars Hamann <hamann@braunschweig.netsurf.de> and
|
||||
Stefan Jeske <jeske@braunschweig.netsurf.de>.
|
||||
|
||||
* gtk/gtknotebook.c: fixups from lars and stefan.
|
||||
|
||||
Wed Feb 25 13:18:53 1998 Owen Taylor <owt1@cornell.edu>
|
||||
|
||||
* gtk/gtkbbox.[ch] gtk/gtkhbox.[ch] gtk/gtkvbox.[ch] :
|
||||
|
@ -1,3 +1,12 @@
|
||||
Wed Feb 25 22:56:42 1998 Tim Janik <timj@gimp.org>
|
||||
|
||||
* gtk/gtkspinbutton.h:
|
||||
* gtk/gtkspinbutton.c:
|
||||
new widget from Lars Hamann <hamann@braunschweig.netsurf.de> and
|
||||
Stefan Jeske <jeske@braunschweig.netsurf.de>.
|
||||
|
||||
* gtk/gtknotebook.c: fixups from lars and stefan.
|
||||
|
||||
Wed Feb 25 13:18:53 1998 Owen Taylor <owt1@cornell.edu>
|
||||
|
||||
* gtk/gtkbbox.[ch] gtk/gtkhbox.[ch] gtk/gtkvbox.[ch] :
|
||||
|
@ -1,3 +1,12 @@
|
||||
Wed Feb 25 22:56:42 1998 Tim Janik <timj@gimp.org>
|
||||
|
||||
* gtk/gtkspinbutton.h:
|
||||
* gtk/gtkspinbutton.c:
|
||||
new widget from Lars Hamann <hamann@braunschweig.netsurf.de> and
|
||||
Stefan Jeske <jeske@braunschweig.netsurf.de>.
|
||||
|
||||
* gtk/gtknotebook.c: fixups from lars and stefan.
|
||||
|
||||
Wed Feb 25 13:18:53 1998 Owen Taylor <owt1@cornell.edu>
|
||||
|
||||
* gtk/gtkbbox.[ch] gtk/gtkhbox.[ch] gtk/gtkvbox.[ch] :
|
||||
|
@ -1,3 +1,12 @@
|
||||
Wed Feb 25 22:56:42 1998 Tim Janik <timj@gimp.org>
|
||||
|
||||
* gtk/gtkspinbutton.h:
|
||||
* gtk/gtkspinbutton.c:
|
||||
new widget from Lars Hamann <hamann@braunschweig.netsurf.de> and
|
||||
Stefan Jeske <jeske@braunschweig.netsurf.de>.
|
||||
|
||||
* gtk/gtknotebook.c: fixups from lars and stefan.
|
||||
|
||||
Wed Feb 25 13:18:53 1998 Owen Taylor <owt1@cornell.edu>
|
||||
|
||||
* gtk/gtkbbox.[ch] gtk/gtkhbox.[ch] gtk/gtkvbox.[ch] :
|
||||
|
@ -1,3 +1,12 @@
|
||||
Wed Feb 25 22:56:42 1998 Tim Janik <timj@gimp.org>
|
||||
|
||||
* gtk/gtkspinbutton.h:
|
||||
* gtk/gtkspinbutton.c:
|
||||
new widget from Lars Hamann <hamann@braunschweig.netsurf.de> and
|
||||
Stefan Jeske <jeske@braunschweig.netsurf.de>.
|
||||
|
||||
* gtk/gtknotebook.c: fixups from lars and stefan.
|
||||
|
||||
Wed Feb 25 13:18:53 1998 Owen Taylor <owt1@cornell.edu>
|
||||
|
||||
* gtk/gtkbbox.[ch] gtk/gtkhbox.[ch] gtk/gtkvbox.[ch] :
|
||||
|
@ -1,3 +1,12 @@
|
||||
Wed Feb 25 22:56:42 1998 Tim Janik <timj@gimp.org>
|
||||
|
||||
* gtk/gtkspinbutton.h:
|
||||
* gtk/gtkspinbutton.c:
|
||||
new widget from Lars Hamann <hamann@braunschweig.netsurf.de> and
|
||||
Stefan Jeske <jeske@braunschweig.netsurf.de>.
|
||||
|
||||
* gtk/gtknotebook.c: fixups from lars and stefan.
|
||||
|
||||
Wed Feb 25 13:18:53 1998 Owen Taylor <owt1@cornell.edu>
|
||||
|
||||
* gtk/gtkbbox.[ch] gtk/gtkhbox.[ch] gtk/gtkvbox.[ch] :
|
||||
|
@ -1,3 +1,12 @@
|
||||
Wed Feb 25 22:56:42 1998 Tim Janik <timj@gimp.org>
|
||||
|
||||
* gtk/gtkspinbutton.h:
|
||||
* gtk/gtkspinbutton.c:
|
||||
new widget from Lars Hamann <hamann@braunschweig.netsurf.de> and
|
||||
Stefan Jeske <jeske@braunschweig.netsurf.de>.
|
||||
|
||||
* gtk/gtknotebook.c: fixups from lars and stefan.
|
||||
|
||||
Wed Feb 25 13:18:53 1998 Owen Taylor <owt1@cornell.edu>
|
||||
|
||||
* gtk/gtkbbox.[ch] gtk/gtkhbox.[ch] gtk/gtkvbox.[ch] :
|
||||
|
@ -70,6 +70,7 @@ libgtk_la_SOURCES = \
|
||||
gtkselection.c \
|
||||
gtkseparator.c \
|
||||
gtksignal.c \
|
||||
gtkspinbutton.c \
|
||||
gtkstyle.c \
|
||||
gtkstatusbar.c \
|
||||
gtktable.c \
|
||||
@ -164,6 +165,7 @@ gtkinclude_HEADERS = \
|
||||
gtkselection.h \
|
||||
gtkseparator.h \
|
||||
gtksignal.h \
|
||||
gtkspinbutton.h \
|
||||
gtkstyle.h \
|
||||
gtkstatusbar.h \
|
||||
gtktable.h \
|
||||
|
@ -86,6 +86,7 @@
|
||||
#include <gtk/gtkselection.h>
|
||||
#include <gtk/gtkseparator.h>
|
||||
#include <gtk/gtksignal.h>
|
||||
#include <gtk/gtkspinbutton.h>
|
||||
#include <gtk/gtkstyle.h>
|
||||
#include <gtk/gtkstatusbar.h>
|
||||
#include <gtk/gtktable.h>
|
||||
|
@ -1778,33 +1778,37 @@ gtk_real_notebook_switch_page (GtkNotebook *notebook,
|
||||
GtkNotebookPage *page)
|
||||
{
|
||||
g_return_if_fail (notebook != NULL);
|
||||
g_return_if_fail (GTK_IS_NOTEBOOK (notebook));
|
||||
g_return_if_fail (page != NULL);
|
||||
|
||||
if (notebook->cur_page != page)
|
||||
if (notebook->cur_page == page)
|
||||
return;
|
||||
|
||||
if (notebook->cur_page && GTK_WIDGET_MAPPED (notebook->cur_page->child))
|
||||
gtk_widget_unmap (notebook->cur_page->child);
|
||||
|
||||
notebook->cur_page = page;
|
||||
|
||||
if (notebook->focus_tab->data != (gpointer) notebook->cur_page)
|
||||
notebook->focus_tab =
|
||||
g_list_find (notebook->children, notebook->cur_page);
|
||||
|
||||
gtk_notebook_pages_allocate (notebook, >K_WIDGET (notebook)->allocation);
|
||||
|
||||
if (GTK_WIDGET_MAPPED (notebook))
|
||||
{
|
||||
if (notebook->cur_page && GTK_WIDGET_MAPPED (notebook->cur_page->child))
|
||||
gtk_widget_unmap (notebook->cur_page->child);
|
||||
|
||||
notebook->cur_page = page;
|
||||
gtk_notebook_pages_allocate (notebook, >K_WIDGET (notebook)->allocation);
|
||||
|
||||
if (GTK_WIDGET_MAPPED (notebook))
|
||||
if (GTK_WIDGET_REALIZED (notebook->cur_page->child))
|
||||
gtk_widget_map (notebook->cur_page->child);
|
||||
else
|
||||
{
|
||||
if (GTK_WIDGET_REALIZED (notebook->cur_page->child))
|
||||
{
|
||||
gtk_widget_map (notebook->cur_page->child);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_map (notebook->cur_page->child);
|
||||
gtk_widget_size_allocate (GTK_WIDGET (notebook),
|
||||
>K_WIDGET (notebook)->allocation);
|
||||
}
|
||||
gtk_widget_map (notebook->cur_page->child);
|
||||
gtk_widget_size_allocate (GTK_WIDGET (notebook),
|
||||
>K_WIDGET (notebook)->allocation);
|
||||
}
|
||||
|
||||
if (GTK_WIDGET_DRAWABLE (notebook))
|
||||
gtk_widget_queue_draw (GTK_WIDGET (notebook));
|
||||
}
|
||||
|
||||
if (GTK_WIDGET_DRAWABLE (notebook))
|
||||
gtk_widget_queue_draw (GTK_WIDGET (notebook));
|
||||
}
|
||||
|
||||
static void
|
||||
@ -2539,6 +2543,10 @@ gtk_notebook_menu_switch_page (GtkWidget *widget,
|
||||
|
||||
notebook = GTK_NOTEBOOK (gtk_menu_get_attach_widget
|
||||
(GTK_MENU (widget->parent)));
|
||||
|
||||
if (notebook->cur_page == page)
|
||||
return;
|
||||
|
||||
page_num = 0;
|
||||
children = notebook->children;
|
||||
while (children && children->data != page)
|
||||
@ -2557,7 +2565,14 @@ static void
|
||||
gtk_notebook_switch_page (GtkNotebook *notebook,
|
||||
GtkNotebookPage *page,
|
||||
gint page_num)
|
||||
{
|
||||
{
|
||||
g_return_if_fail (notebook != NULL);
|
||||
g_return_if_fail (GTK_IS_NOTEBOOK (notebook));
|
||||
g_return_if_fail (page != NULL);
|
||||
|
||||
if (notebook->cur_page == page)
|
||||
return;
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (notebook),
|
||||
notebook_signals[SWITCH_PAGE],
|
||||
page,
|
||||
|
1039
gtk/gtkspinbutton.c
Normal file
1039
gtk/gtkspinbutton.c
Normal file
File diff suppressed because it is too large
Load Diff
117
gtk/gtkspinbutton.h
Normal file
117
gtk/gtkspinbutton.h
Normal file
@ -0,0 +1,117 @@
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GTK_SPIN_BUTTON_H__
|
||||
#define __GTK_SPIN_BUTTON_H__
|
||||
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
#include <gtk/gtkentry.h>
|
||||
#include <gtk/gtkadjustment.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
#define GTK_SPIN_BUTTON(obj) GTK_CHECK_CAST (obj, gtk_spin_button_get_type (), GtkSpinButton)
|
||||
#define GTK_SPIN_BUTTON_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gtk_spin_button_get_type (), GtkSpinButtonClass)
|
||||
#define GTK_IS_SPIN_BUTTON(obj) GTK_CHECK_TYPE (obj, gtk_spin_button_get_type ())
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GTK_UPDATE_ALWAYS = 1 << 0,
|
||||
GTK_UPDATE_IF_VALID = 1 << 1,
|
||||
GTK_UPDATE_SNAP_TO_TICKS = 1 << 2
|
||||
} GtkSpinButtonUpdatePolicy;
|
||||
|
||||
|
||||
typedef struct _GtkSpinButton GtkSpinButton;
|
||||
typedef struct _GtkSpinButtonClass GtkSpinButtonClass;
|
||||
|
||||
|
||||
struct _GtkSpinButton
|
||||
{
|
||||
GtkEntry entry;
|
||||
|
||||
GtkAdjustment *adjustment;
|
||||
|
||||
GdkWindow *panel;
|
||||
|
||||
guint32 timer;
|
||||
|
||||
gfloat climb_rate;
|
||||
gfloat timer_step;
|
||||
|
||||
guint8 update_policy;
|
||||
|
||||
guint snapped : 1;
|
||||
guint in_child : 2;
|
||||
guint click_child : 2;
|
||||
guint button : 2;
|
||||
guint need_timer : 1;
|
||||
guint timer_calls : 3;
|
||||
guint digits : 7;
|
||||
};
|
||||
|
||||
struct _GtkSpinButtonClass
|
||||
{
|
||||
GtkEntryClass parent_class;
|
||||
};
|
||||
|
||||
guint
|
||||
gtk_spin_button_get_type (void);
|
||||
|
||||
GtkWidget *
|
||||
gtk_spin_button_new (GtkAdjustment *adjustment,
|
||||
gfloat climb_rate,
|
||||
gint digits);
|
||||
|
||||
void
|
||||
gtk_spin_button_set_adjustment (GtkSpinButton *spin_button,
|
||||
GtkAdjustment *adjustment);
|
||||
|
||||
GtkAdjustment *
|
||||
gtk_spin_button_get_adjustment (GtkSpinButton *spin_button);
|
||||
|
||||
void
|
||||
gtk_spin_button_set_digits (GtkSpinButton *spin_button,
|
||||
gint digits);
|
||||
|
||||
gfloat
|
||||
gtk_spin_button_get_value_as_float (GtkSpinButton *spin_button);
|
||||
|
||||
gint
|
||||
gtk_spin_button_get_value_as_int (GtkSpinButton *spin_button);
|
||||
|
||||
void
|
||||
gtk_spin_button_set_value (GtkSpinButton *spin_button,
|
||||
gfloat value);
|
||||
|
||||
void
|
||||
gtk_spin_button_set_update_policy (GtkSpinButton *spin_button,
|
||||
GtkSpinButtonUpdatePolicy policy);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
#endif /* __GTK_SPIN_BUTTON_H__ */
|
171
gtk/testgtk.c
171
gtk/testgtk.c
@ -1636,8 +1636,174 @@ create_entry ()
|
||||
|
||||
if (!GTK_WIDGET_VISIBLE (window))
|
||||
gtk_widget_show (window);
|
||||
/* else
|
||||
gtk_widget_destroy (window); */
|
||||
else
|
||||
gtk_widget_destroy (window);
|
||||
}
|
||||
|
||||
GtkWidget *spinner1;
|
||||
|
||||
static void
|
||||
toggle_snap (GtkWidget *widget, GtkSpinButton *spin)
|
||||
{
|
||||
if (GTK_TOGGLE_BUTTON (widget)->active)
|
||||
gtk_spin_button_set_update_policy (spin, GTK_UPDATE_ALWAYS
|
||||
| GTK_UPDATE_SNAP_TO_TICKS);
|
||||
else
|
||||
gtk_spin_button_set_update_policy (spin, GTK_UPDATE_ALWAYS);
|
||||
}
|
||||
|
||||
static void
|
||||
change_digits (GtkWidget *widget, GtkSpinButton *spin)
|
||||
{
|
||||
gtk_spin_button_set_digits (GTK_SPIN_BUTTON (spinner1),
|
||||
gtk_spin_button_get_value_as_int (spin));
|
||||
}
|
||||
|
||||
static void
|
||||
create_spins ()
|
||||
{
|
||||
static GtkWidget *window = NULL;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *main_vbox;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *vbox2;
|
||||
GtkWidget *spinner2;
|
||||
GtkWidget *spinner;
|
||||
GtkWidget *button;
|
||||
GtkWidget *label;
|
||||
GtkAdjustment *adj;
|
||||
|
||||
if (!window)
|
||||
{
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (window), "destroy",
|
||||
GTK_SIGNAL_FUNC (destroy_window),
|
||||
&window);
|
||||
gtk_signal_connect (GTK_OBJECT (window), "delete_event",
|
||||
GTK_SIGNAL_FUNC (destroy_window),
|
||||
&window);
|
||||
|
||||
gtk_window_set_title (GTK_WINDOW (window), "GtkSpinButton");
|
||||
|
||||
main_vbox = gtk_vbox_new (FALSE, 5);
|
||||
gtk_container_border_width (GTK_CONTAINER (main_vbox), 10);
|
||||
gtk_container_add (GTK_CONTAINER (window), main_vbox);
|
||||
|
||||
frame = gtk_frame_new ("Not accelerated");
|
||||
gtk_box_pack_start (GTK_BOX (main_vbox), frame, TRUE, TRUE, 0);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 0);
|
||||
gtk_container_border_width (GTK_CONTAINER (vbox), 5);
|
||||
gtk_container_add (GTK_CONTAINER (frame), vbox);
|
||||
|
||||
/* Day, month, year spinners */
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 5);
|
||||
|
||||
vbox2 = gtk_vbox_new (FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), vbox2, FALSE, TRUE, 5);
|
||||
|
||||
label = gtk_label_new ("Day :");
|
||||
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
|
||||
gtk_box_pack_start (GTK_BOX (vbox2), label, FALSE, TRUE, 0);
|
||||
|
||||
adj = (GtkAdjustment *) gtk_adjustment_new (1.0, 1.0, 31.0, 1.0,
|
||||
5.0, 0.0);
|
||||
spinner = gtk_spin_button_new (adj, 0, 0);
|
||||
gtk_box_pack_start (GTK_BOX (vbox2), spinner, FALSE, TRUE, 0);
|
||||
|
||||
vbox2 = gtk_vbox_new (FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), vbox2, FALSE, TRUE, 5);
|
||||
|
||||
label = gtk_label_new ("Month :");
|
||||
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
|
||||
gtk_box_pack_start (GTK_BOX (vbox2), label, FALSE, TRUE, 0);
|
||||
|
||||
adj = (GtkAdjustment *) gtk_adjustment_new (1.0, 1.0, 12.0, 1.0,
|
||||
5.0, 0.0);
|
||||
spinner = gtk_spin_button_new (adj, 0, 0);
|
||||
gtk_box_pack_start (GTK_BOX (vbox2), spinner, FALSE, TRUE, 0);
|
||||
|
||||
vbox2 = gtk_vbox_new (FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), vbox2, FALSE, TRUE, 5);
|
||||
|
||||
label = gtk_label_new ("Year :");
|
||||
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
|
||||
gtk_box_pack_start (GTK_BOX (vbox2), label, FALSE, TRUE, 0);
|
||||
|
||||
adj = (GtkAdjustment *) gtk_adjustment_new (1998.0, 0.0, 2100.0,
|
||||
1.0, 100.0, 0.0);
|
||||
spinner = gtk_spin_button_new (adj, 0, 0);
|
||||
gtk_widget_set_usize (spinner, 55, 0);
|
||||
gtk_box_pack_start (GTK_BOX (vbox2), spinner, FALSE, TRUE, 0);
|
||||
|
||||
frame = gtk_frame_new ("Accelerated");
|
||||
gtk_box_pack_start (GTK_BOX (main_vbox), frame, TRUE, TRUE, 0);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 0);
|
||||
gtk_container_border_width (GTK_CONTAINER (vbox), 5);
|
||||
gtk_container_add (GTK_CONTAINER (frame), vbox);
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 5);
|
||||
|
||||
vbox2 = gtk_vbox_new (FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), vbox2, FALSE, TRUE, 5);
|
||||
|
||||
label = gtk_label_new ("Value :");
|
||||
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
|
||||
gtk_box_pack_start (GTK_BOX (vbox2), label, FALSE, TRUE, 0);
|
||||
|
||||
adj = (GtkAdjustment *) gtk_adjustment_new (0.0, 0.0, 10000.0,
|
||||
1.0, 100.0, 0.0);
|
||||
spinner1 = gtk_spin_button_new (adj, 1.0, 3);
|
||||
gtk_widget_set_usize (spinner1, 120, 0);
|
||||
gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (spinner1),
|
||||
GTK_UPDATE_ALWAYS);
|
||||
gtk_box_pack_start (GTK_BOX (vbox2), spinner1, FALSE, TRUE, 0);
|
||||
|
||||
vbox2 = gtk_vbox_new (FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), vbox2, FALSE, TRUE, 0);
|
||||
|
||||
label = gtk_label_new ("Digits :");
|
||||
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
|
||||
gtk_box_pack_start (GTK_BOX (vbox2), label, FALSE, TRUE, 0);
|
||||
|
||||
adj = (GtkAdjustment *) gtk_adjustment_new (3.0, 0.0, 8.0,
|
||||
1.0, 3.0, 0.0);
|
||||
spinner2 = gtk_spin_button_new (adj, 0.0, 0);
|
||||
gtk_signal_connect (GTK_OBJECT (adj), "value_changed",
|
||||
GTK_SIGNAL_FUNC (change_digits),
|
||||
(gpointer) spinner2);
|
||||
gtk_box_pack_start (GTK_BOX (vbox2), spinner2, FALSE, TRUE, 0);
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 5);
|
||||
|
||||
button = gtk_check_button_new_with_label ("Snap to ticks");
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||
GTK_SIGNAL_FUNC (toggle_snap),
|
||||
spinner1);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, TRUE, 0);
|
||||
gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (button), TRUE);
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, TRUE, 0);
|
||||
|
||||
button = gtk_button_new_with_label ("Close");
|
||||
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
|
||||
GTK_SIGNAL_FUNC (gtk_widget_destroy),
|
||||
GTK_OBJECT (window));
|
||||
gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 5);
|
||||
}
|
||||
|
||||
if (!GTK_WIDGET_VISIBLE (window))
|
||||
gtk_widget_show_all (window);
|
||||
else
|
||||
gtk_widget_destroy (window);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -4377,6 +4543,7 @@ create_main_window ()
|
||||
{ "scrolled windows", create_scrolled_windows },
|
||||
{ "drawing areas", NULL },
|
||||
{ "entry", create_entry },
|
||||
{ "spinbutton", create_spins },
|
||||
{ "list", create_list },
|
||||
{ "clist", create_clist},
|
||||
{ "color selection", create_color_selection },
|
||||
|
171
tests/testgtk.c
171
tests/testgtk.c
@ -1636,8 +1636,174 @@ create_entry ()
|
||||
|
||||
if (!GTK_WIDGET_VISIBLE (window))
|
||||
gtk_widget_show (window);
|
||||
/* else
|
||||
gtk_widget_destroy (window); */
|
||||
else
|
||||
gtk_widget_destroy (window);
|
||||
}
|
||||
|
||||
GtkWidget *spinner1;
|
||||
|
||||
static void
|
||||
toggle_snap (GtkWidget *widget, GtkSpinButton *spin)
|
||||
{
|
||||
if (GTK_TOGGLE_BUTTON (widget)->active)
|
||||
gtk_spin_button_set_update_policy (spin, GTK_UPDATE_ALWAYS
|
||||
| GTK_UPDATE_SNAP_TO_TICKS);
|
||||
else
|
||||
gtk_spin_button_set_update_policy (spin, GTK_UPDATE_ALWAYS);
|
||||
}
|
||||
|
||||
static void
|
||||
change_digits (GtkWidget *widget, GtkSpinButton *spin)
|
||||
{
|
||||
gtk_spin_button_set_digits (GTK_SPIN_BUTTON (spinner1),
|
||||
gtk_spin_button_get_value_as_int (spin));
|
||||
}
|
||||
|
||||
static void
|
||||
create_spins ()
|
||||
{
|
||||
static GtkWidget *window = NULL;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *main_vbox;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *vbox2;
|
||||
GtkWidget *spinner2;
|
||||
GtkWidget *spinner;
|
||||
GtkWidget *button;
|
||||
GtkWidget *label;
|
||||
GtkAdjustment *adj;
|
||||
|
||||
if (!window)
|
||||
{
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (window), "destroy",
|
||||
GTK_SIGNAL_FUNC (destroy_window),
|
||||
&window);
|
||||
gtk_signal_connect (GTK_OBJECT (window), "delete_event",
|
||||
GTK_SIGNAL_FUNC (destroy_window),
|
||||
&window);
|
||||
|
||||
gtk_window_set_title (GTK_WINDOW (window), "GtkSpinButton");
|
||||
|
||||
main_vbox = gtk_vbox_new (FALSE, 5);
|
||||
gtk_container_border_width (GTK_CONTAINER (main_vbox), 10);
|
||||
gtk_container_add (GTK_CONTAINER (window), main_vbox);
|
||||
|
||||
frame = gtk_frame_new ("Not accelerated");
|
||||
gtk_box_pack_start (GTK_BOX (main_vbox), frame, TRUE, TRUE, 0);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 0);
|
||||
gtk_container_border_width (GTK_CONTAINER (vbox), 5);
|
||||
gtk_container_add (GTK_CONTAINER (frame), vbox);
|
||||
|
||||
/* Day, month, year spinners */
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 5);
|
||||
|
||||
vbox2 = gtk_vbox_new (FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), vbox2, FALSE, TRUE, 5);
|
||||
|
||||
label = gtk_label_new ("Day :");
|
||||
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
|
||||
gtk_box_pack_start (GTK_BOX (vbox2), label, FALSE, TRUE, 0);
|
||||
|
||||
adj = (GtkAdjustment *) gtk_adjustment_new (1.0, 1.0, 31.0, 1.0,
|
||||
5.0, 0.0);
|
||||
spinner = gtk_spin_button_new (adj, 0, 0);
|
||||
gtk_box_pack_start (GTK_BOX (vbox2), spinner, FALSE, TRUE, 0);
|
||||
|
||||
vbox2 = gtk_vbox_new (FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), vbox2, FALSE, TRUE, 5);
|
||||
|
||||
label = gtk_label_new ("Month :");
|
||||
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
|
||||
gtk_box_pack_start (GTK_BOX (vbox2), label, FALSE, TRUE, 0);
|
||||
|
||||
adj = (GtkAdjustment *) gtk_adjustment_new (1.0, 1.0, 12.0, 1.0,
|
||||
5.0, 0.0);
|
||||
spinner = gtk_spin_button_new (adj, 0, 0);
|
||||
gtk_box_pack_start (GTK_BOX (vbox2), spinner, FALSE, TRUE, 0);
|
||||
|
||||
vbox2 = gtk_vbox_new (FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), vbox2, FALSE, TRUE, 5);
|
||||
|
||||
label = gtk_label_new ("Year :");
|
||||
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
|
||||
gtk_box_pack_start (GTK_BOX (vbox2), label, FALSE, TRUE, 0);
|
||||
|
||||
adj = (GtkAdjustment *) gtk_adjustment_new (1998.0, 0.0, 2100.0,
|
||||
1.0, 100.0, 0.0);
|
||||
spinner = gtk_spin_button_new (adj, 0, 0);
|
||||
gtk_widget_set_usize (spinner, 55, 0);
|
||||
gtk_box_pack_start (GTK_BOX (vbox2), spinner, FALSE, TRUE, 0);
|
||||
|
||||
frame = gtk_frame_new ("Accelerated");
|
||||
gtk_box_pack_start (GTK_BOX (main_vbox), frame, TRUE, TRUE, 0);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 0);
|
||||
gtk_container_border_width (GTK_CONTAINER (vbox), 5);
|
||||
gtk_container_add (GTK_CONTAINER (frame), vbox);
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 5);
|
||||
|
||||
vbox2 = gtk_vbox_new (FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), vbox2, FALSE, TRUE, 5);
|
||||
|
||||
label = gtk_label_new ("Value :");
|
||||
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
|
||||
gtk_box_pack_start (GTK_BOX (vbox2), label, FALSE, TRUE, 0);
|
||||
|
||||
adj = (GtkAdjustment *) gtk_adjustment_new (0.0, 0.0, 10000.0,
|
||||
1.0, 100.0, 0.0);
|
||||
spinner1 = gtk_spin_button_new (adj, 1.0, 3);
|
||||
gtk_widget_set_usize (spinner1, 120, 0);
|
||||
gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (spinner1),
|
||||
GTK_UPDATE_ALWAYS);
|
||||
gtk_box_pack_start (GTK_BOX (vbox2), spinner1, FALSE, TRUE, 0);
|
||||
|
||||
vbox2 = gtk_vbox_new (FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), vbox2, FALSE, TRUE, 0);
|
||||
|
||||
label = gtk_label_new ("Digits :");
|
||||
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
|
||||
gtk_box_pack_start (GTK_BOX (vbox2), label, FALSE, TRUE, 0);
|
||||
|
||||
adj = (GtkAdjustment *) gtk_adjustment_new (3.0, 0.0, 8.0,
|
||||
1.0, 3.0, 0.0);
|
||||
spinner2 = gtk_spin_button_new (adj, 0.0, 0);
|
||||
gtk_signal_connect (GTK_OBJECT (adj), "value_changed",
|
||||
GTK_SIGNAL_FUNC (change_digits),
|
||||
(gpointer) spinner2);
|
||||
gtk_box_pack_start (GTK_BOX (vbox2), spinner2, FALSE, TRUE, 0);
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 5);
|
||||
|
||||
button = gtk_check_button_new_with_label ("Snap to ticks");
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||
GTK_SIGNAL_FUNC (toggle_snap),
|
||||
spinner1);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, TRUE, 0);
|
||||
gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (button), TRUE);
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, TRUE, 0);
|
||||
|
||||
button = gtk_button_new_with_label ("Close");
|
||||
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
|
||||
GTK_SIGNAL_FUNC (gtk_widget_destroy),
|
||||
GTK_OBJECT (window));
|
||||
gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 5);
|
||||
}
|
||||
|
||||
if (!GTK_WIDGET_VISIBLE (window))
|
||||
gtk_widget_show_all (window);
|
||||
else
|
||||
gtk_widget_destroy (window);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -4377,6 +4543,7 @@ create_main_window ()
|
||||
{ "scrolled windows", create_scrolled_windows },
|
||||
{ "drawing areas", NULL },
|
||||
{ "entry", create_entry },
|
||||
{ "spinbutton", create_spins },
|
||||
{ "list", create_list },
|
||||
{ "clist", create_clist},
|
||||
{ "color selection", create_color_selection },
|
||||
|
Loading…
Reference in New Issue
Block a user