Re: How center a small button horizontally like in this picture....
- From: "Bradley F. Hartman" <hartman mcci-arl-va com>
- To: gtk-list gnome org, dfs research att com
- Subject: Re: How center a small button horizontally like in this picture....
- Date: Thu, 28 Mar 2002 16:17:44 -0500 (EST)
Debby,
I think the problem is that you have a "\n" at the end of your label:
> buffer = g_strdup_printf ("variable %d\n", j);
Thus, in your attempts to align the label, you're attempting to align two
lines of text instead of one.
I modified your code such that there was no "\n" and there was no
alignment object (see below) and it seems to work okay here. Please let me
know if it doesn't work for you.
Brad
/* varpanelA.c */
#include <gtk/gtk.h>
#define false 0
#define true 1
void destroy( GtkWidget *widget, gpointer data )
{
gtk_main_quit();
}
int main( int argc, char *argv[] )
{
static GtkWidget *window;
GtkWidget *swin, *hbox, *vbox, *vb;
GtkWidget *button, *align, *label;
gchar *buffer;
int j;
gtk_init (&argc, &argv);
/* Create a dialog window */
window = gtk_dialog_new ();
gtk_signal_connect (GTK_OBJECT (window), "destroy",
(GtkSignalFunc) destroy, NULL);
gtk_window_set_title (GTK_WINDOW (window), "GtkScrolledWindow example");
gtk_container_set_border_width (GTK_CONTAINER (window), 0);
gtk_widget_set_usize(window, 300, 300);
/* create a scrolled window. */
swin = gtk_scrolled_window_new (NULL, NULL);
gtk_container_set_border_width (GTK_CONTAINER (swin), 10);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swin),
GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG(window)->vbox), swin,
TRUE, TRUE, 0);
vbox = gtk_vbox_new (true, 2);
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (swin), vbox);
/* create a grid of toggle buttons */
for (j = 0; j < 10; j++) {
hbox = gtk_hbox_new (false, 2);
gtk_box_pack_start (GTK_BOX (vbox), hbox, true, true, 0);
button = gtk_toggle_button_new_with_label (" X ");
gtk_box_pack_start (GTK_BOX (hbox), button, false, false, 2);
button = gtk_toggle_button_new_with_label (" Y ");
gtk_box_pack_start (GTK_BOX (hbox), button, false, false, 2);
buffer = g_strdup_printf ("variable %d", j);
label = gtk_label_new (buffer);
/*gtk_misc_set_alignment (GTK_MISC(label), 0, .5);*/
g_free (buffer);
/*
align = gtk_alignment_new (0, 0.0, 0, 0);
*/
/*
gtk_box_pack_start (GTK_BOX (hbox), align, 0, 1, 0);
gtk_container_add (GTK_CONTAINER (align), label);
*/
gtk_box_pack_start (GTK_BOX (hbox), label, 0, 1, 0);
}
/* Add a "close" button to the bottom of the dialog */
button = gtk_button_new_with_label ("close");
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
(GtkSignalFunc) gtk_widget_destroy, GTK_OBJECT (window));
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->action_area),
button, TRUE, TRUE, 0);
gtk_widget_show_all (window);
gtk_main();
return(0);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]