Re: any ideas for a fix?
- From: Phil Wolff <adiabat centurylink net>
- To: gtk-app-devel-list gnome org
- Subject: Re: any ideas for a fix?
- Date: Thu, 21 Aug 2014 13:41:46 -0700
You're trying to use each label in three places, and you can't do that.
Try this:
int
main (int argc, char *argv[])
{
GtkWidget *window, *vbox; // Labels go in here, vertically orientated.
//GtkWidget *label1, *label2, *label3;
GtkWidget *label1[32], *label2[32], *label3[32];
int tt = 0;
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER);
gtk_window_set_default_size (GTK_WINDOW (window), 700, 900);
gtk_window_set_title (GTK_WINDOW (window), "Labels Left-Margins");
gtk_container_set_border_width (GTK_CONTAINER (window), 10);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
for (tt = 0; tt < 3; tt++)
{
printf ("For-Loop(): main with tt = (%d)\n", tt);
label1[tt] = gtk_label_new ("1: This is the file name named talk.1.txt");
gtk_misc_set_alignment (GTK_MISC (label1[tt]), 0, 0.5); // left
label2[tt] = gtk_label_new ("2: This is talk.2.txt");
gtk_misc_set_alignment (GTK_MISC (label2[tt]), 0, 0.5); // left
label3[tt] =
gtk_label_new ("3: File talk.3.txt file.");
gtk_misc_set_alignment (GTK_MISC (label3[tt]), 0, 0.5); // left
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5); // GTK3
gtk_container_add (GTK_CONTAINER (window), vbox);
gtk_box_pack_start (GTK_BOX (vbox), label1[tt], FALSE, TRUE, 0);
gtk_widget_show (label1[tt]);
gtk_box_pack_start(GTK_BOX(vbox), label2[tt], FALSE, TRUE, 0);
gtk_widget_show (label2[tt]);
gtk_box_pack_start(GTK_BOX(vbox), label3[tt], FALSE, TRUE, 0);
gtk_widget_show (label3[tt]);
gtk_widget_show_all (window);
gtk_widget_show_all (window);
}
gtk_main ();
return 0;
}
On 08/21/2014 01:30 PM, Gary Kline wrote:
=====
Organization: Thought Unlimited. Public service Unix since 1986.
Of_Interest: With 28 years of service to the Unix community.
On Thu, Aug 21, 2014 at 01:01:24PM +0200, Marcus Karlsson wrote:
On Tue, Aug 19, 2014 at 06:43:22PM -0700, Gary Kline wrote:
=====
Organization: Thought Unlimited. Public service Unix since 1986.
Of_Interest: With 28 years of service to the Unix community.
guys,
last time I encloused this "leftJ*" code, it output a 700 by 900
label with label1, label2, label3. in "labelWidgets.h" I've got
a *label[32], and use a global tt=0 that is inc in a for loop.
the gcc line builds ./leftJ after you unshar or simply run sh against
the sharball.
it doesn't segv or anything; but it only printfs the last line. WITH
complaiints. can any body help me here?
tia,
gary
Attached: leftJustify.shar
Looks like your attachment didn't make it. Can you post the code sample
online, or include the problematic part inline?
Marcus
hi marcus,
don't know what happened to the SHAR file. BUT: below is the
entire program--minus the labelWidgets.h header. the header file
just had the int tt.
as-is, this printfs the 700 by 900 window and the third label.
last night, localtime here in seattle, I send mail to two
chaps named chris, moller and vine. My *main* problem is that
I don't know how to add multiple labels to a single vbox.
Clue me in and givve me a place to stand, and I'll be able to
move the globe!
gary
#include <stdio.h>
#include <gtk/gtk.h>
// no-more :: #include "labelWidgets.h"
/***
gcc -Wall -g leftJ.c -o leftJ `pkg-config --cflags gtk+-3.0` `pkg-config --libs gtk+-3.0`
***/
int
main (int argc, char *argv[])
{
GtkWidget *window, *vbox; // Labels go in here, vertically orientated.
//GtkWidget *label1, *label2, *label3;
GtkWidget *label[32];
int tt = 0;
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER);
gtk_window_set_default_size (GTK_WINDOW (window), 700, 900);
gtk_window_set_title (GTK_WINDOW (window), "Labels Left-Margins");
gtk_container_set_border_width (GTK_CONTAINER (window), 10);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
for (tt = 0; tt < 3; tt++)
{
printf ("For-Loop(): main with tt = (%d)\n", tt);
label[tt] = gtk_label_new ("1: This is the file name named talk.1.txt");
gtk_misc_set_alignment (GTK_MISC (label[tt]), 0, 0.5); // left
label[tt] = gtk_label_new ("2: This is talk.2.txt");
gtk_misc_set_alignment (GTK_MISC (label[tt]), 0, 0.5); // left
label[tt] =
gtk_label_new ("3: File talk.3.txt file.");
gtk_misc_set_alignment (GTK_MISC (label[tt]), 0, 0.5); // left
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5); // GTK3
gtk_container_add (GTK_CONTAINER (window), vbox);
gtk_box_pack_start (GTK_BOX (vbox), label[tt], FALSE, TRUE, 0);
gtk_widget_show (label[tt]);
gtk_box_pack_start(GTK_BOX(vbox), label[tt], FALSE, TRUE, 0);
gtk_widget_show (label[tt]);
gtk_box_pack_start(GTK_BOX(vbox), label[tt], FALSE, TRUE, 0);
gtk_widget_show (label[tt]);
gtk_widget_show_all (window);
}
gtk_main ();
return 0;
}
--
If sunbeams were weapons of war, we would have had solar energy
centuries ago.
-- George Porter
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]