how to i get the arrow-buttons moving?
- From: Gary Kline <kline thought org>
- To: gtk-app <gtk-app-devel-list gnome org>
- Subject: how to i get the arrow-buttons moving?
- Date: Tue, 2 Sep 2014 16:39:00 -0700
here are thee labels that show up when you use the gcc compile string.
how do I get the up- and -down arrows to point at the label and echo the
"label strings"?
#include <stdio.h>
#include <gtk/gtk.h>
/*
COMPILE WITH:
gcc -Wall -Wextra -g arrow.c -o arrow `pkg-config --cflags gtk+-3.0` `pkg-config --libs gtk+-3.0`
*/
GtkWidget *
create_arrow_button (GtkArrowType arrow_type,
GtkShadowType shadow_type)
{
GtkWidget *button;
GtkWidget *arrow;
button = gtk_button_new ();
arrow = gtk_arrow_new (arrow_type, shadow_type);
gtk_container_add (GTK_CONTAINER (button), arrow);
gtk_widget_show (button);
gtk_widget_show (arrow);
return (button);
}
static void
button_clicked (__attribute__ ((unused)) GtkButton *button,
gpointer user_data)
{
printf ("button %d clicked\n", GPOINTER_TO_INT (user_data));
}
int
main (int argc, char *argv[])
{
/*
GtkWidget is the storage type for widgets
*/
GtkWidget *window;
GtkWidget *button;
GtkWidget *box;
GtkWidget *vbox, *vlbox;
GtkWidget *label1, *label2, *label3;
/*
Initialize the toolkit
*/
gtk_init (&argc, &argv);
/*
Create a new window
*/
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (window, "destroy",
G_CALLBACK (gtk_main_quit), NULL);
gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER);
gtk_window_set_default_size (GTK_WINDOW (window), 850, 500);
/*
Sets the border width of the window.
*/
gtk_container_set_border_width (GTK_CONTAINER (window), 10);
/*
It's a good idea to do this for all windows.
gtk_signal_connect (GTK_OBJECT (window), "destroy",
GTK_SIGNAL_FUNC (gtk_main_quit), NULL);
*/
/*
Create a box to hold the arrows/buttons
*/
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 9);
gtk_container_add (GTK_CONTAINER (window), vbox);
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_container_set_border_width (GTK_CONTAINER (box), 2);
gtk_container_add (GTK_CONTAINER (vbox), box);
button = create_arrow_button (GTK_ARROW_UP, GTK_SHADOW_IN);
g_signal_connect (button, "clicked",
G_CALLBACK (button_clicked), GINT_TO_POINTER (0));
gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 3);
button = create_arrow_button (GTK_ARROW_DOWN, GTK_SHADOW_OUT);
g_signal_connect (button, "clicked",
G_CALLBACK (button_clicked), GINT_TO_POINTER (1));
gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 3);
/* line 100 */
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
vlbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5); // GTK3
gtk_container_add(GTK_CONTAINER(vbox), vlbox);
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 (label1);
gtk_widget_show (label2);
gtk_widget_show (label3);
gtk_widget_show_all (window);
gtk_main ();
return (0);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]