Re: nuts!



=====
Organization: Thought Unlimited.  Public service Unix since 1986.
Of_Interest: With 28 years  of service  to the  Unix  community.

On Tue, Jul 29, 2014 at 08:06:24PM -0003, Tristan Van Berkom wrote:
On Tue, Jul 29, 2014 at 6:36 AM, Chris Vine
<chris cvine freeserve co uk> wrote:
On Mon, 28 Jul 2014 23:00:34 -0700
Gary Kline <kline thought org> wrote:
while I can create several {N} labels, they print centered.
how do I  get the labels to print from the left side of the
window widget:

Use 'gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5)' to align left,
and 'gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5)' to align right.
For multi-line labels, you would also want to call gtk_set_justify().



Note that since GTK+-3.0 there are the 'halign' and 'valign' properties
of GtkWidget which accomplish the same as setting the GtkMisc alignment
properties.

These are preferred and the GtkMisc API, while not officially
deprecated,
is not recommended for use in new code[0].

Instead, you should be able to use:
  gtk_widget_set_halign (label, GTK_ALIGN_START);


This should align whatever widget to the left of the available space for
the given widget (or to the right in RTL mode) - this API can also
be used
for any widget (it is not limited to GtkMisc derived widgets).

Cheers,
   -Tristan

[0]: https://developer.gnome.org/gtk3/stable/GtkMisc.html


I'm going over the url you gave.  I got up super early today for my 
daughter who is going to study comp-sci this fall(!); so I  really 
do need more coffee or a *nap*.  meanwhile, below is a testfile that
print N labels [[ here N == 3 ]]. Id send you the makefiles, but figure 
you can mouse the gcc line.  "x2" is my lack of imagination.  

at any rate, iv'e used the GTK__MISC string--macro? everything I'm coding 
from now on is 3.0, so could you edit in the recommended way?  you've got 
halign; shouldn t I use the valign for mmy labels?  

tx much,
        gary



-- 
 Gary Kline  kline thought org  http://www.thought.org  Public Service Unix
             Twenty-eight years of service to the Unix community.


#include <stdio.h>  
#include <gtk/gtk.h>

/*** gcc -Wall -g x2.c -o x2 `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;

  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);

  label1 = gtk_label_new("1: This is the file name named talk.1.txt");
  gtk_misc_set_alignment(GTK_MISC(label1), 0, 0.5);  // left
  label2 = gtk_label_new("2: This is talk.2.txt");
  gtk_misc_set_alignment(GTK_MISC(label2), 0, 0.5);  // left
  label3 = gtk_label_new("3: File talk.3.txt for the speech impaired.");
  gtk_misc_set_alignment(GTK_MISC(label3), 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, FALSE, TRUE, 0);
  gtk_box_pack_start(GTK_BOX(vbox), label2, FALSE, TRUE, 0);
  gtk_box_pack_start(GTK_BOX(vbox), label3, FALSE, 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]