summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorOwen Taylor <owt1@cornell.edu>1998-03-18 21:11:04 +0000
committerOwen Taylor <otaylor@src.gnome.org>1998-03-18 21:11:04 +0000
commitf9739e834376121d8f766072499126e1cac2f332 (patch)
treedb18acfaf13950986d1f9098980326cfabfb1d5a /gtk
parent85d4cd0f43c29fcca9c38282d7fa169bf775409e (diff)
downloadgdk-pixbuf-f9739e834376121d8f766072499126e1cac2f332.tar.gz
( From: James Henstridge <james@daa.com.au> )
Wed Mar 18 11:09:10 1998 Owen Taylor <owt1@cornell.edu> ( From: James Henstridge <james@daa.com.au> ) * gtk/gtkclist.c: Don't remove, then destroy labels in gtk_clist_set_column_[*], just remove them. * gtk/gtkmain.c (gtk_invoke_timeout_function): call marshal when appropriate, not function. Tue Mar 17 14:15:07 1998 Owen Taylor <owt1@cornell.edu> * gtk/testgtk.c (create_main_window): Alphabetize tests * gtk/gtk[hv]paned.c: Change division on resize if necessary to keep handle visible. * gtk/gtkgamma.c gtk/gtkcurve.c: Moved initialization into _init() functions. * gtk/gtkscrolledwindow.c: Added missing _construct() functions.
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtkclist.c10
-rw-r--r--gtk/gtkcurve.c41
-rw-r--r--gtk/gtkgamma.c104
-rw-r--r--gtk/gtkhpaned.c4
-rw-r--r--gtk/gtkradiobutton.c34
-rw-r--r--gtk/gtkradiobutton.h2
-rw-r--r--gtk/gtkscrolledwindow.c14
-rw-r--r--gtk/gtkscrolledwindow.h3
-rw-r--r--gtk/gtktext.c6
-rw-r--r--gtk/gtkvpaned.c4
-rw-r--r--gtk/testgtk.c66
-rw-r--r--gtk/testselection.c2
12 files changed, 174 insertions, 116 deletions
diff --git a/gtk/gtkclist.c b/gtk/gtkclist.c
index 1c5e4c381..9392948b6 100644
--- a/gtk/gtkclist.c
+++ b/gtk/gtkclist.c
@@ -679,10 +679,7 @@ gtk_clist_set_column_title (GtkCList * clist,
/* remove and destroy the old widget */
old_widget = GTK_BUTTON (clist->column[column].button)->child;
if (old_widget)
- {
- gtk_container_remove (GTK_CONTAINER (clist->column[column].button), old_widget);
- gtk_widget_destroy (old_widget);
- }
+ gtk_container_remove (GTK_CONTAINER (clist->column[column].button), old_widget);
/* create new alignment based no column justification */
switch (clist->column[column].justification)
@@ -742,10 +739,7 @@ gtk_clist_set_column_widget (GtkCList * clist,
/* remove and destroy the old widget */
old_widget = GTK_BUTTON (clist->column[column].button)->child;
if (old_widget)
- {
- gtk_container_remove (GTK_CONTAINER (clist->column[column].button), old_widget);
- gtk_widget_destroy (old_widget);
- }
+ gtk_container_remove (GTK_CONTAINER (clist->column[column].button), old_widget);
/* add and show the widget */
if (widget)
diff --git a/gtk/gtkcurve.c b/gtk/gtkcurve.c
index 0790917f6..e10389cb6 100644
--- a/gtk/gtkcurve.c
+++ b/gtk/gtkcurve.c
@@ -43,10 +43,13 @@ static guint curve_type_changed_signal = 0;
/* forward declarations: */
-static void gtk_curve_class_init (GtkCurveClass *class);
-static void gtk_curve_init (GtkCurve *curve);
-static void gtk_curve_finalize (GtkObject *object);
-
+static void gtk_curve_class_init (GtkCurveClass *class);
+static void gtk_curve_init (GtkCurve *curve);
+static void gtk_curve_finalize (GtkObject *object);
+static gint gtk_curve_graph_events (GtkWidget *widget,
+ GdkEvent *event,
+ GtkCurve *c);
+static void gtk_curve_size_graph (GtkCurve *curve);
guint
gtk_curve_get_type (void)
@@ -92,6 +95,8 @@ gtk_curve_class_init (GtkCurveClass *class)
static void
gtk_curve_init (GtkCurve *curve)
{
+ gint old_mask;
+
curve->cursor_type = GDK_TOP_LEFT_ARROW;
curve->pixmap = NULL;
curve->curve_type = GTK_CURVE_TYPE_SPLINE;
@@ -103,6 +108,17 @@ gtk_curve_init (GtkCurve *curve)
curve->num_ctlpoints = 0;
curve->ctlpoint = NULL;
+
+ curve->min_x = 0.0;
+ curve->max_x = 1.0;
+ curve->min_y = 0.0;
+ curve->max_y = 1.0;
+
+ old_mask = gtk_widget_get_events (GTK_WIDGET (curve));
+ gtk_widget_set_events (GTK_WIDGET (curve), old_mask | GRAPH_MASK);
+ gtk_signal_connect (GTK_OBJECT (curve), "event",
+ (GtkSignalFunc) gtk_curve_graph_events, curve);
+ gtk_curve_size_graph (curve);
}
static int
@@ -823,22 +839,7 @@ gtk_curve_get_vector (GtkCurve *c, int veclen, gfloat vector[])
GtkWidget*
gtk_curve_new (void)
{
- GtkCurve *curve;
- gint old_mask;
-
- curve = gtk_type_new (gtk_curve_get_type ());
- curve->min_x = 0.0;
- curve->max_x = 1.0;
- curve->min_y = 0.0;
- curve->max_y = 1.0;
-
- old_mask = gtk_widget_get_events (GTK_WIDGET (curve));
- gtk_widget_set_events (GTK_WIDGET (curve), old_mask | GRAPH_MASK);
- gtk_signal_connect (GTK_OBJECT (curve), "event",
- (GtkSignalFunc) gtk_curve_graph_events, curve);
- gtk_curve_size_graph (curve);
-
- return GTK_WIDGET (curve);
+ return gtk_type_new (gtk_curve_get_type ());
}
static void
diff --git a/gtk/gtkgamma.c b/gtk/gtkgamma.c
index cfad6cc8b..db4b903fd 100644
--- a/gtk/gtkgamma.c
+++ b/gtk/gtkgamma.c
@@ -42,6 +42,11 @@ static void gtk_gamma_curve_class_init (GtkGammaCurveClass *class);
static void gtk_gamma_curve_init (GtkGammaCurve *curve);
static void gtk_gamma_curve_destroy (GtkObject *object);
+static void curve_type_changed_callback (GtkWidget *w, gpointer data);
+static void button_realize_callback (GtkWidget *w);
+static void button_toggled_callback (GtkWidget *w, gpointer data);
+static void button_clicked_callback (GtkWidget *w, gpointer data);
+
enum
{
LINEAR = 0,
@@ -234,7 +239,54 @@ gtk_gamma_curve_class_init (GtkGammaCurveClass *class)
static void
gtk_gamma_curve_init (GtkGammaCurve *curve)
{
+ GtkWidget *vbox;
+ int i;
+
curve->gamma = 1.0;
+
+ curve->table = gtk_table_new (1, 2, FALSE);
+ gtk_table_set_col_spacings (GTK_TABLE (curve->table), 3);
+ gtk_container_add (GTK_CONTAINER (curve), curve->table);
+
+ curve->curve = gtk_curve_new ();
+ gtk_signal_connect (GTK_OBJECT (curve->curve), "curve_type_changed",
+ (GtkSignalFunc) curve_type_changed_callback, curve);
+ gtk_table_attach_defaults (GTK_TABLE (curve->table), curve->curve, 0, 1, 0, 1);
+
+ vbox = gtk_vbox_new (/* homogeneous */ FALSE, /* spacing */ 3);
+ gtk_table_attach (GTK_TABLE (curve->table), vbox, 1, 2, 0, 1, 0, 0, 0, 0);
+
+ /* toggle buttons: */
+ for (i = 0; i < 3; ++i)
+ {
+ curve->button[i] = gtk_toggle_button_new ();
+ gtk_object_set_data (GTK_OBJECT (curve->button[i]), "_GtkGammaCurveIndex",
+ (gpointer) (long) i);
+ gtk_container_add (GTK_CONTAINER (vbox), curve->button[i]);
+ gtk_signal_connect (GTK_OBJECT (curve->button[i]), "realize",
+ (GtkSignalFunc) button_realize_callback, 0);
+ gtk_signal_connect (GTK_OBJECT (curve->button[i]), "toggled",
+ (GtkSignalFunc) button_toggled_callback, curve);
+ gtk_widget_show (curve->button[i]);
+ }
+
+ /* push buttons: */
+ for (i = 3; i < 5; ++i)
+ {
+ curve->button[i] = gtk_button_new ();
+ gtk_object_set_data (GTK_OBJECT (curve->button[i]), "_GtkGammaCurveIndex",
+ (gpointer) (long) i);
+ gtk_container_add (GTK_CONTAINER (vbox), curve->button[i]);
+ gtk_signal_connect (GTK_OBJECT (curve->button[i]), "realize",
+ (GtkSignalFunc) button_realize_callback, 0);
+ gtk_signal_connect (GTK_OBJECT (curve->button[i]), "clicked",
+ (GtkSignalFunc) button_clicked_callback, curve);
+ gtk_widget_show (curve->button[i]);
+ }
+
+ gtk_widget_show (vbox);
+ gtk_widget_show (curve->table);
+ gtk_widget_show (curve->curve);
}
static void
@@ -395,57 +447,7 @@ curve_type_changed_callback (GtkWidget *w, gpointer data)
GtkWidget*
gtk_gamma_curve_new (void)
{
- GtkGammaCurve *c;
- GtkWidget *vbox;
- int i;
-
- c = gtk_type_new (gtk_gamma_curve_get_type ());
-
- c->table = gtk_table_new (1, 2, FALSE);
- gtk_table_set_col_spacings (GTK_TABLE (c->table), 3);
- gtk_container_add (GTK_CONTAINER (c), c->table);
-
- c->curve = gtk_curve_new ();
- gtk_signal_connect (GTK_OBJECT (c->curve), "curve_type_changed",
- (GtkSignalFunc) curve_type_changed_callback, c);
- gtk_table_attach_defaults (GTK_TABLE (c->table), c->curve, 0, 1, 0, 1);
-
- vbox = gtk_vbox_new (/* homogeneous */ FALSE, /* spacing */ 3);
- gtk_table_attach (GTK_TABLE (c->table), vbox, 1, 2, 0, 1, 0, 0, 0, 0);
-
- /* toggle buttons: */
- for (i = 0; i < 3; ++i)
- {
- c->button[i] = gtk_toggle_button_new ();
- gtk_object_set_data (GTK_OBJECT (c->button[i]), "_GtkGammaCurveIndex",
- (gpointer) (long) i);
- gtk_container_add (GTK_CONTAINER (vbox), c->button[i]);
- gtk_signal_connect (GTK_OBJECT (c->button[i]), "realize",
- (GtkSignalFunc) button_realize_callback, 0);
- gtk_signal_connect (GTK_OBJECT (c->button[i]), "toggled",
- (GtkSignalFunc) button_toggled_callback, c);
- gtk_widget_show (c->button[i]);
- }
-
- /* push buttons: */
- for (i = 3; i < 5; ++i)
- {
- c->button[i] = gtk_button_new ();
- gtk_object_set_data (GTK_OBJECT (c->button[i]), "_GtkGammaCurveIndex",
- (gpointer) (long) i);
- gtk_container_add (GTK_CONTAINER (vbox), c->button[i]);
- gtk_signal_connect (GTK_OBJECT (c->button[i]), "realize",
- (GtkSignalFunc) button_realize_callback, 0);
- gtk_signal_connect (GTK_OBJECT (c->button[i]), "clicked",
- (GtkSignalFunc) button_clicked_callback, c);
- gtk_widget_show (c->button[i]);
- }
-
- gtk_widget_show (vbox);
- gtk_widget_show (c->table);
- gtk_widget_show (c->curve);
-
- return GTK_WIDGET (c);
+ return gtk_type_new (gtk_gamma_curve_get_type ());
}
static void
diff --git a/gtk/gtkhpaned.c b/gtk/gtkhpaned.c
index d89e00827..9ef2ff095 100644
--- a/gtk/gtkhpaned.c
+++ b/gtk/gtkhpaned.c
@@ -149,6 +149,10 @@ gtk_hpaned_size_allocate (GtkWidget *widget,
else
paned->child1_size = 0;
}
+ else
+ paned->child1_size = CLAMP (paned->child1_size, 0,
+ allocation->width - paned->gutter_size
+ - 2 * GTK_CONTAINER (paned)->border_width);
/* Move the handle before the children so we don't get extra expose events */
diff --git a/gtk/gtkradiobutton.c b/gtk/gtkradiobutton.c
index 17b980027..774d916d8 100644
--- a/gtk/gtkradiobutton.c
+++ b/gtk/gtkradiobutton.c
@@ -84,17 +84,29 @@ gtk_radio_button_init (GtkRadioButton *radio_button)
radio_button->group = NULL;
}
-GtkWidget*
-gtk_radio_button_new (GSList *group)
+void
+gtk_radio_button_set_group (GtkRadioButton *radio_button,
+ GSList *group)
{
- GtkRadioButton *radio_button;
- GtkRadioButton *tmp_button;
GSList *tmp_list;
+ GtkRadioButton *tmp_button;
- radio_button = gtk_type_new (gtk_radio_button_get_type ());
+ if (radio_button->group)
+ {
+ radio_button->group = g_slist_remove (radio_button->group, radio_button);
+
+ tmp_list = radio_button->group;
+ while (tmp_list)
+ {
+ tmp_button = tmp_list->data;
+ tmp_list = tmp_list->next;
+
+ tmp_button->group = radio_button->group;
+ }
+ }
- tmp_list = group;
radio_button->group = g_slist_prepend (group, radio_button);
+ tmp_list = group;
if (tmp_list)
{
@@ -111,6 +123,16 @@ gtk_radio_button_new (GSList *group)
GTK_TOGGLE_BUTTON (radio_button)->active = TRUE;
gtk_widget_set_state (GTK_WIDGET (radio_button), GTK_STATE_ACTIVE);
}
+}
+
+GtkWidget*
+gtk_radio_button_new (GSList *group)
+{
+ GtkRadioButton *radio_button;
+
+ radio_button = gtk_type_new (gtk_radio_button_get_type ());
+
+ gtk_radio_button_set_group (radio_button, group);
return GTK_WIDGET (radio_button);
}
diff --git a/gtk/gtkradiobutton.h b/gtk/gtkradiobutton.h
index 468e5b7eb..5c872ab27 100644
--- a/gtk/gtkradiobutton.h
+++ b/gtk/gtkradiobutton.h
@@ -55,6 +55,8 @@ GtkWidget* gtk_radio_button_new_from_widget (GtkRadioButton *group);
GtkWidget* gtk_radio_button_new_with_label (GSList *group,
const gchar *label);
GSList* gtk_radio_button_group (GtkRadioButton *radio_button);
+void gtk_radio_button_set_group (GtkRadioButton *radio_button,
+ GSList *group);
#ifdef __cplusplus
diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c
index f0cd16c60..9b3488e67 100644
--- a/gtk/gtkscrolledwindow.c
+++ b/gtk/gtkscrolledwindow.c
@@ -122,6 +122,18 @@ gtk_scrolled_window_new (GtkAdjustment *hadjustment,
scrolled_window = gtk_type_new (gtk_scrolled_window_get_type ());
+ gtk_scrolled_window_construct (scrolled_window, hadjustment, vadjustment);
+
+ return GTK_WIDGET (scrolled_window);
+}
+
+void
+gtk_scrolled_window_construct (GtkScrolledWindow *scrolled_window,
+ GtkAdjustment *hadjustment,
+ GtkAdjustment *vadjustment)
+{
+ scrolled_window = gtk_type_new (gtk_scrolled_window_get_type ());
+
scrolled_window->viewport = gtk_viewport_new (hadjustment, vadjustment);
hadjustment = gtk_viewport_get_hadjustment (GTK_VIEWPORT (scrolled_window->viewport));
vadjustment = gtk_viewport_get_vadjustment (GTK_VIEWPORT (scrolled_window->viewport));
@@ -147,8 +159,6 @@ gtk_scrolled_window_new (GtkAdjustment *hadjustment,
gtk_widget_ref (scrolled_window->viewport);
gtk_widget_ref (scrolled_window->hscrollbar);
gtk_widget_ref (scrolled_window->vscrollbar);
-
- return GTK_WIDGET (scrolled_window);
}
GtkAdjustment*
diff --git a/gtk/gtkscrolledwindow.h b/gtk/gtkscrolledwindow.h
index 54ed5637e..140fcc50e 100644
--- a/gtk/gtkscrolledwindow.h
+++ b/gtk/gtkscrolledwindow.h
@@ -61,6 +61,9 @@ struct _GtkScrolledWindowClass
guint gtk_scrolled_window_get_type (void);
GtkWidget* gtk_scrolled_window_new (GtkAdjustment *hadjustment,
GtkAdjustment *vadjustment);
+void gtk_scrolled_window_construct (GtkScrolledWindow *scrolled_window,
+ GtkAdjustment *hadjustment,
+ GtkAdjustment *vadjustment);
GtkAdjustment* gtk_scrolled_window_get_hadjustment (GtkScrolledWindow *scrolled_window);
GtkAdjustment* gtk_scrolled_window_get_vadjustment (GtkScrolledWindow *scrolled_window);
void gtk_scrolled_window_set_policy (GtkScrolledWindow *scrolled_window,
diff --git a/gtk/gtktext.c b/gtk/gtktext.c
index f8b4b4f97..3b77f44a8 100644
--- a/gtk/gtktext.c
+++ b/gtk/gtktext.c
@@ -1734,12 +1734,16 @@ gtk_text_key_press (GtkWidget *widget,
break;
case GDK_Tab:
gtk_text_insert_1_at_point (text, '\t');
+ gtk_editable_changed (editable);
break;
case GDK_Return:
if (event->state & GDK_CONTROL_MASK)
gtk_signal_emit_by_name (GTK_OBJECT (text), "activate");
else
- gtk_text_insert_1_at_point (text, '\n');
+ {
+ gtk_text_insert_1_at_point (text, '\n');
+ gtk_editable_changed (editable);
+ }
break;
case GDK_Escape:
/* Don't insert literally */
diff --git a/gtk/gtkvpaned.c b/gtk/gtkvpaned.c
index 6db823ff6..3672b6704 100644
--- a/gtk/gtkvpaned.c
+++ b/gtk/gtkvpaned.c
@@ -149,6 +149,10 @@ gtk_vpaned_size_allocate (GtkWidget *widget,
else
paned->child1_size = 0;
}
+ else
+ paned->child1_size = CLAMP (paned->child1_size, 0,
+ allocation->height - paned->gutter_size
+ - 2 * GTK_CONTAINER (paned)->border_width);
/* Move the handle before the children so we don't get extra expose events */
diff --git a/gtk/testgtk.c b/gtk/testgtk.c
index 59702102b..83c2da51d 100644
--- a/gtk/testgtk.c
+++ b/gtk/testgtk.c
@@ -1276,6 +1276,13 @@ cb_create_tree(GtkWidget* w)
nb_item = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(sTreeSampleSelection.nb_item_spinner));
recursion_level = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(sTreeSampleSelection.recursion_spinner));
+ if (pow (nb_item, recursion_level) > 10000)
+ {
+ g_print ("%g total items? That will take a very long time. Try less\n",
+ pow (nb_item, recursion_level));
+ return;
+ }
+
create_tree_sample(selection_mode, draw_line, view_line, no_root_item, nb_item, recursion_level);
}
@@ -4100,6 +4107,7 @@ create_panes ()
GtkWidget *frame;
GtkWidget *hpaned;
GtkWidget *vpaned;
+ GtkWidget *button;
if (!window)
{
@@ -4125,6 +4133,10 @@ create_panes ()
gtk_widget_set_usize (frame, 60, 60);
gtk_paned_add1 (GTK_PANED (hpaned), frame);
gtk_widget_show (frame);
+
+ button = gtk_button_new_with_label ("Hi there");
+ gtk_container_add (GTK_CONTAINER(frame), button);
+ gtk_widget_show (button);
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME(frame), GTK_SHADOW_IN);
@@ -5486,46 +5498,46 @@ create_main_window ()
void (*func) ();
} buttons[] =
{
+ { "button box", create_button_box },
{ "buttons", create_buttons },
- { "toggle buttons", create_toggle_buttons },
{ "check buttons", create_check_buttons },
- { "radio buttons", create_radio_buttons },
- { "button box", create_button_box },
- { "toolbar", create_toolbar },
- { "handle box", create_handle_box },
- { "statusbar", create_statusbar },
- { "reparent", create_reparent },
- { "pixmap", create_pixmap },
- { "tooltips", create_tooltips },
- { "menus", create_menus },
- { "scrolled windows", create_scrolled_windows },
- { "cursors", create_cursors },
- { "entry", create_entry },
- { "spinbutton", create_spins },
- { "list", create_list },
{ "clist", create_clist},
- { "tree", create_tree_mode_window},
{ "color selection", create_color_selection },
- { "file selection", create_file_selection },
+ { "cursors", create_cursors },
{ "dialog", create_dialog },
+ { "dnd", create_dnd },
+ { "entry", create_entry },
+ { "file selection", create_file_selection },
+ { "gamma curve", create_gamma_curve },
+ { "handle box", create_handle_box },
+ { "list", create_list },
+ { "menus", create_menus },
{ "miscellaneous", NULL },
- { "range controls", create_range_controls },
- { "rulers", create_rulers },
- { "text", create_text },
{ "notebook", create_notebook },
{ "panes", create_panes },
- { "shapes", create_shapes },
- { "dnd", create_dnd },
- { "WM hints", create_wmhints },
- { "progress bar", create_progress_bar },
+ { "pixmap", create_pixmap },
{ "preview color", create_color_preview },
{ "preview gray", create_gray_preview },
- { "gamma curve", create_gamma_curve },
+ { "progress bar", create_progress_bar },
+ { "radio buttons", create_radio_buttons },
+ { "range controls", create_range_controls },
+ { "reparent", create_reparent },
+ { "rulers", create_rulers },
+ { "scrolled windows", create_scrolled_windows },
+ { "shapes", create_shapes },
+ { "spinbutton", create_spins },
+ { "statusbar", create_statusbar },
+ { "test idle", create_idle_test },
+ { "test mainloop", create_test },
{ "test scrolling", create_scroll_test },
{ "test selection", create_selection_test },
{ "test timeout", create_timeout_test },
- { "test idle", create_idle_test },
- { "test", create_test },
+ { "text", create_text },
+ { "toggle buttons", create_toggle_buttons },
+ { "toolbar", create_toolbar },
+ { "tooltips", create_tooltips },
+ { "tree", create_tree_mode_window},
+ { "WM hints", create_wmhints },
};
int nbuttons = sizeof (buttons) / sizeof (buttons[0]);
GtkWidget *window;
diff --git a/gtk/testselection.c b/gtk/testselection.c
index 6a0592913..663111838 100644
--- a/gtk/testselection.c
+++ b/gtk/testselection.c
@@ -163,7 +163,7 @@ selection_handle (GtkWidget *widget,
}
else
{
- buffer = selection_string->str;
+ buffer = (guchar *)selection_string->str;
len = selection_string->len;
}