mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-06 00:30:08 +00:00
Update the following sections to the current API: - Container Widgets -
Sun Dec 13 22:15:48 GMT 1998 Tony Gale <gale@gtk.org> * docs/gtk_tut.sgml: Update the following sections to the current API: - Container Widgets - CList Widget - List Widget - Tree Widget
This commit is contained in:
parent
6d6d3a59b8
commit
113448e030
@ -1,3 +1,12 @@
|
|||||||
|
Sun Dec 13 22:15:48 GMT 1998 Tony Gale <gale@gtk.org>
|
||||||
|
|
||||||
|
* docs/gtk_tut.sgml: Update the following sections to the
|
||||||
|
current API:
|
||||||
|
- Container Widgets
|
||||||
|
- CList Widget
|
||||||
|
- List Widget
|
||||||
|
- Tree Widget
|
||||||
|
|
||||||
Sat Dec 12 19:11:35 1998 Tim Janik <timj@gtk.org>
|
Sat Dec 12 19:11:35 1998 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
* gtk/gtkmenuitem.c: made GtkMenuItem::activate a GTK_RUN_ACTION signal.
|
* gtk/gtkmenuitem.c: made GtkMenuItem::activate a GTK_RUN_ACTION signal.
|
||||||
|
@ -1,3 +1,12 @@
|
|||||||
|
Sun Dec 13 22:15:48 GMT 1998 Tony Gale <gale@gtk.org>
|
||||||
|
|
||||||
|
* docs/gtk_tut.sgml: Update the following sections to the
|
||||||
|
current API:
|
||||||
|
- Container Widgets
|
||||||
|
- CList Widget
|
||||||
|
- List Widget
|
||||||
|
- Tree Widget
|
||||||
|
|
||||||
Sat Dec 12 19:11:35 1998 Tim Janik <timj@gtk.org>
|
Sat Dec 12 19:11:35 1998 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
* gtk/gtkmenuitem.c: made GtkMenuItem::activate a GTK_RUN_ACTION signal.
|
* gtk/gtkmenuitem.c: made GtkMenuItem::activate a GTK_RUN_ACTION signal.
|
||||||
|
@ -1,3 +1,12 @@
|
|||||||
|
Sun Dec 13 22:15:48 GMT 1998 Tony Gale <gale@gtk.org>
|
||||||
|
|
||||||
|
* docs/gtk_tut.sgml: Update the following sections to the
|
||||||
|
current API:
|
||||||
|
- Container Widgets
|
||||||
|
- CList Widget
|
||||||
|
- List Widget
|
||||||
|
- Tree Widget
|
||||||
|
|
||||||
Sat Dec 12 19:11:35 1998 Tim Janik <timj@gtk.org>
|
Sat Dec 12 19:11:35 1998 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
* gtk/gtkmenuitem.c: made GtkMenuItem::activate a GTK_RUN_ACTION signal.
|
* gtk/gtkmenuitem.c: made GtkMenuItem::activate a GTK_RUN_ACTION signal.
|
||||||
|
@ -1,3 +1,12 @@
|
|||||||
|
Sun Dec 13 22:15:48 GMT 1998 Tony Gale <gale@gtk.org>
|
||||||
|
|
||||||
|
* docs/gtk_tut.sgml: Update the following sections to the
|
||||||
|
current API:
|
||||||
|
- Container Widgets
|
||||||
|
- CList Widget
|
||||||
|
- List Widget
|
||||||
|
- Tree Widget
|
||||||
|
|
||||||
Sat Dec 12 19:11:35 1998 Tim Janik <timj@gtk.org>
|
Sat Dec 12 19:11:35 1998 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
* gtk/gtkmenuitem.c: made GtkMenuItem::activate a GTK_RUN_ACTION signal.
|
* gtk/gtkmenuitem.c: made GtkMenuItem::activate a GTK_RUN_ACTION signal.
|
||||||
|
@ -1,3 +1,12 @@
|
|||||||
|
Sun Dec 13 22:15:48 GMT 1998 Tony Gale <gale@gtk.org>
|
||||||
|
|
||||||
|
* docs/gtk_tut.sgml: Update the following sections to the
|
||||||
|
current API:
|
||||||
|
- Container Widgets
|
||||||
|
- CList Widget
|
||||||
|
- List Widget
|
||||||
|
- Tree Widget
|
||||||
|
|
||||||
Sat Dec 12 19:11:35 1998 Tim Janik <timj@gtk.org>
|
Sat Dec 12 19:11:35 1998 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
* gtk/gtkmenuitem.c: made GtkMenuItem::activate a GTK_RUN_ACTION signal.
|
* gtk/gtkmenuitem.c: made GtkMenuItem::activate a GTK_RUN_ACTION signal.
|
||||||
|
@ -1,3 +1,12 @@
|
|||||||
|
Sun Dec 13 22:15:48 GMT 1998 Tony Gale <gale@gtk.org>
|
||||||
|
|
||||||
|
* docs/gtk_tut.sgml: Update the following sections to the
|
||||||
|
current API:
|
||||||
|
- Container Widgets
|
||||||
|
- CList Widget
|
||||||
|
- List Widget
|
||||||
|
- Tree Widget
|
||||||
|
|
||||||
Sat Dec 12 19:11:35 1998 Tim Janik <timj@gtk.org>
|
Sat Dec 12 19:11:35 1998 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
* gtk/gtkmenuitem.c: made GtkMenuItem::activate a GTK_RUN_ACTION signal.
|
* gtk/gtkmenuitem.c: made GtkMenuItem::activate a GTK_RUN_ACTION signal.
|
||||||
|
@ -1,3 +1,12 @@
|
|||||||
|
Sun Dec 13 22:15:48 GMT 1998 Tony Gale <gale@gtk.org>
|
||||||
|
|
||||||
|
* docs/gtk_tut.sgml: Update the following sections to the
|
||||||
|
current API:
|
||||||
|
- Container Widgets
|
||||||
|
- CList Widget
|
||||||
|
- List Widget
|
||||||
|
- Tree Widget
|
||||||
|
|
||||||
Sat Dec 12 19:11:35 1998 Tim Janik <timj@gtk.org>
|
Sat Dec 12 19:11:35 1998 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
* gtk/gtkmenuitem.c: made GtkMenuItem::activate a GTK_RUN_ACTION signal.
|
* gtk/gtkmenuitem.c: made GtkMenuItem::activate a GTK_RUN_ACTION signal.
|
||||||
|
1005
docs/gtk_tut.sgml
1005
docs/gtk_tut.sgml
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -45,7 +45,7 @@ gint main (int argc, gchar *argv[])
|
|||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
/* It isn't necessary to shadow the border, but it looks nice :) */
|
/* It isn't necessary to shadow the border, but it looks nice :) */
|
||||||
gtk_clist_set_border(GTK_CLIST(clist), GTK_SHADOW_OUT);
|
gtk_clist_set_shadow_type (GTK_CLIST(clist), GTK_SHADOW_OUT);
|
||||||
|
|
||||||
/* What however is important, is that we set the column widths as
|
/* What however is important, is that we set the column widths as
|
||||||
* they will never be right otherwise. Note that the columns are
|
* they will never be right otherwise. Note that the columns are
|
||||||
@ -53,10 +53,6 @@ gint main (int argc, gchar *argv[])
|
|||||||
*/
|
*/
|
||||||
gtk_clist_set_column_width (GTK_CLIST(clist), 0, 150);
|
gtk_clist_set_column_width (GTK_CLIST(clist), 0, 150);
|
||||||
|
|
||||||
/* Scollbars _only when needed_ */
|
|
||||||
gtk_clist_set_policy(GTK_CLIST(clist), GTK_POLICY_AUTOMATIC,
|
|
||||||
GTK_POLICY_AUTOMATIC);
|
|
||||||
|
|
||||||
/* Add the GtkCList widget to the vertical box and show it. */
|
/* Add the GtkCList widget to the vertical box and show it. */
|
||||||
gtk_box_pack_start(GTK_BOX(vbox), clist, TRUE, TRUE, 0);
|
gtk_box_pack_start(GTK_BOX(vbox), clist, TRUE, TRUE, 0);
|
||||||
gtk_widget_show(clist);
|
gtk_widget_show(clist);
|
||||||
@ -97,7 +93,7 @@ gint main (int argc, gchar *argv[])
|
|||||||
gtk_widget_show(window);
|
gtk_widget_show(window);
|
||||||
gtk_main();
|
gtk_main();
|
||||||
|
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* User clicked the "Add List" button. */
|
/* User clicked the "Add List" button. */
|
||||||
|
@ -1,50 +1,52 @@
|
|||||||
/* example-start list list.c */
|
/* example-start list list.c */
|
||||||
|
|
||||||
/* include the gtk+ header files
|
/* Include the gtk+ header files
|
||||||
* include stdio.h, we need that for the printf() function
|
* Include stdio.h, we need that for the printf() function
|
||||||
*/
|
*/
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
/* this is our data identification string to store
|
/* This is our data identification string to store
|
||||||
* data in list items
|
* data in list items
|
||||||
*/
|
*/
|
||||||
const gchar *list_item_data_key="list_item_data";
|
const gchar *list_item_data_key="list_item_data";
|
||||||
|
|
||||||
|
|
||||||
/* prototypes for signal handler that we are going to connect
|
/* prototypes for signal handler that we are going to connect
|
||||||
* to the GtkList widget
|
* to the GtkList widget
|
||||||
*/
|
*/
|
||||||
static void sigh_print_selection (GtkWidget *gtklist,
|
static void sigh_print_selection( GtkWidget *gtklist,
|
||||||
gpointer func_data);
|
gpointer func_data);
|
||||||
static void sigh_button_event (GtkWidget *gtklist,
|
|
||||||
GdkEventButton *event,
|
static void sigh_button_event( GtkWidget *gtklist,
|
||||||
GtkWidget *frame);
|
GdkEventButton *event,
|
||||||
|
GtkWidget *frame );
|
||||||
|
|
||||||
|
|
||||||
/* main function to set up the user interface */
|
/* Main function to set up the user interface */
|
||||||
|
|
||||||
gint main (int argc, gchar *argv[])
|
gint main (int argc,
|
||||||
|
gchar *argv[])
|
||||||
{
|
{
|
||||||
GtkWidget *separator;
|
GtkWidget *separator;
|
||||||
GtkWidget *window;
|
GtkWidget *window;
|
||||||
GtkWidget *vbox;
|
GtkWidget *vbox;
|
||||||
GtkWidget *scrolled_window;
|
GtkWidget *scrolled_window;
|
||||||
GtkWidget *frame;
|
GtkWidget *frame;
|
||||||
GtkWidget *gtklist;
|
GtkWidget *gtklist;
|
||||||
GtkWidget *button;
|
GtkWidget *button;
|
||||||
GtkWidget *list_item;
|
GtkWidget *list_item;
|
||||||
GList *dlist;
|
GList *dlist;
|
||||||
guint i;
|
guint i;
|
||||||
gchar buffer[64];
|
gchar buffer[64];
|
||||||
|
|
||||||
|
|
||||||
/* initialize gtk+ (and subsequently gdk) */
|
/* Initialize gtk+ (and subsequently gdk) */
|
||||||
|
|
||||||
gtk_init(&argc, &argv);
|
gtk_init(&argc, &argv);
|
||||||
|
|
||||||
|
|
||||||
/* create a window to put all the widgets in
|
/* Create a window to put all the widgets in
|
||||||
* connect gtk_main_quit() to the "destroy" event of
|
* connect gtk_main_quit() to the "destroy" event of
|
||||||
* the window to handle window manager close-window-events
|
* the window to handle window manager close-window-events
|
||||||
*/
|
*/
|
||||||
@ -56,34 +58,34 @@ gint main (int argc, gchar *argv[])
|
|||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
|
||||||
/* inside the window we need a box to arrange the widgets
|
/* Inside the window we need a box to arrange the widgets
|
||||||
* vertically */
|
* vertically */
|
||||||
vbox=gtk_vbox_new(FALSE, 5);
|
vbox=gtk_vbox_new(FALSE, 5);
|
||||||
gtk_container_border_width(GTK_CONTAINER(vbox), 5);
|
gtk_container_border_width(GTK_CONTAINER(vbox), 5);
|
||||||
gtk_container_add(GTK_CONTAINER(window), vbox);
|
gtk_container_add(GTK_CONTAINER(window), vbox);
|
||||||
gtk_widget_show(vbox);
|
gtk_widget_show(vbox);
|
||||||
|
|
||||||
/* this is the scrolled window to put the GtkList widget inside */
|
/* This is the scrolled window to put the GtkList widget inside */
|
||||||
scrolled_window=gtk_scrolled_window_new(NULL, NULL);
|
scrolled_window=gtk_scrolled_window_new(NULL, NULL);
|
||||||
gtk_widget_set_usize(scrolled_window, 250, 150);
|
gtk_widget_set_usize(scrolled_window, 250, 150);
|
||||||
gtk_container_add(GTK_CONTAINER(vbox), scrolled_window);
|
gtk_container_add(GTK_CONTAINER(vbox), scrolled_window);
|
||||||
gtk_widget_show(scrolled_window);
|
gtk_widget_show(scrolled_window);
|
||||||
|
|
||||||
/* create the GtkList widget
|
/* Create the GtkList widget.
|
||||||
* connect the sigh_print_selection() signal handler
|
* Connect the sigh_print_selection() signal handler
|
||||||
* function to the "selection_changed" signal of the GtkList
|
* function to the "selection_changed" signal of the GtkList
|
||||||
* to print out the selected items each time the selection
|
* to print out the selected items each time the selection
|
||||||
* has changed */
|
* has changed */
|
||||||
gtklist=gtk_list_new();
|
gtklist=gtk_list_new();
|
||||||
gtk_container_add(GTK_CONTAINER(scrolled_window), gtklist);
|
gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW(scrolled_window),
|
||||||
|
gtklist);
|
||||||
gtk_widget_show(gtklist);
|
gtk_widget_show(gtklist);
|
||||||
gtk_signal_connect(GTK_OBJECT(gtklist),
|
gtk_signal_connect(GTK_OBJECT(gtklist),
|
||||||
"selection_changed",
|
"selection_changed",
|
||||||
GTK_SIGNAL_FUNC(sigh_print_selection),
|
GTK_SIGNAL_FUNC(sigh_print_selection),
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
/* we create a "Prison" to put a list item in ;)
|
/* We create a "Prison" to put a list item in ;) */
|
||||||
*/
|
|
||||||
frame=gtk_frame_new("Prison");
|
frame=gtk_frame_new("Prison");
|
||||||
gtk_widget_set_usize(frame, 200, 50);
|
gtk_widget_set_usize(frame, 200, 50);
|
||||||
gtk_container_border_width(GTK_CONTAINER(frame), 5);
|
gtk_container_border_width(GTK_CONTAINER(frame), 5);
|
||||||
@ -91,7 +93,7 @@ gint main (int argc, gchar *argv[])
|
|||||||
gtk_container_add(GTK_CONTAINER(vbox), frame);
|
gtk_container_add(GTK_CONTAINER(vbox), frame);
|
||||||
gtk_widget_show(frame);
|
gtk_widget_show(frame);
|
||||||
|
|
||||||
/* connect the sigh_button_event() signal handler to the GtkList
|
/* Connect the sigh_button_event() signal handler to the GtkList
|
||||||
* which will handle the "arresting" of list items
|
* which will handle the "arresting" of list items
|
||||||
*/
|
*/
|
||||||
gtk_signal_connect(GTK_OBJECT(gtklist),
|
gtk_signal_connect(GTK_OBJECT(gtklist),
|
||||||
@ -99,15 +101,13 @@ gint main (int argc, gchar *argv[])
|
|||||||
GTK_SIGNAL_FUNC(sigh_button_event),
|
GTK_SIGNAL_FUNC(sigh_button_event),
|
||||||
frame);
|
frame);
|
||||||
|
|
||||||
/* create a separator
|
/* Create a separator */
|
||||||
*/
|
|
||||||
separator=gtk_hseparator_new();
|
separator=gtk_hseparator_new();
|
||||||
gtk_container_add(GTK_CONTAINER(vbox), separator);
|
gtk_container_add(GTK_CONTAINER(vbox), separator);
|
||||||
gtk_widget_show(separator);
|
gtk_widget_show(separator);
|
||||||
|
|
||||||
/* finally create a button and connect it´s "clicked" signal
|
/* Finally create a button and connect it's "clicked" signal
|
||||||
* to the destruction of the window
|
* to the destruction of the window */
|
||||||
*/
|
|
||||||
button=gtk_button_new_with_label("Close");
|
button=gtk_button_new_with_label("Close");
|
||||||
gtk_container_add(GTK_CONTAINER(vbox), button);
|
gtk_container_add(GTK_CONTAINER(vbox), button);
|
||||||
gtk_widget_show(button);
|
gtk_widget_show(button);
|
||||||
@ -117,9 +117,9 @@ gint main (int argc, gchar *argv[])
|
|||||||
GTK_OBJECT(window));
|
GTK_OBJECT(window));
|
||||||
|
|
||||||
|
|
||||||
/* now we create 5 list items, each having it´s own
|
/* Now we create 5 list items, each having it's own
|
||||||
* label and add them to the GtkList using gtk_container_add()
|
* label and add them to the GtkList using gtk_container_add()
|
||||||
* also we query the text string from the label and
|
* Also we query the text string from the label and
|
||||||
* associate it with the list_item_data_key for each list item
|
* associate it with the list_item_data_key for each list item
|
||||||
*/
|
*/
|
||||||
for (i=0; i<5; i++) {
|
for (i=0; i<5; i++) {
|
||||||
@ -138,16 +138,16 @@ gint main (int argc, gchar *argv[])
|
|||||||
list_item_data_key,
|
list_item_data_key,
|
||||||
string);
|
string);
|
||||||
}
|
}
|
||||||
/* here, we are creating another 5 labels, this time
|
/* Here, we are creating another 5 labels, this time
|
||||||
* we use gtk_list_item_new_with_label() for the creation
|
* we use gtk_list_item_new_with_label() for the creation
|
||||||
* we can´t query the text string from the label because
|
* we can't query the text string from the label because
|
||||||
* we don´t have the labels pointer and therefore
|
* we don't have the labels pointer and therefore
|
||||||
* we just associate the list_item_data_key of each
|
* we just associate the list_item_data_key of each
|
||||||
* list item with the same text string
|
* list item with the same text string.
|
||||||
* for adding of the list items we put them all into a doubly
|
* For adding of the list items we put them all into a doubly
|
||||||
* linked list (GList), and then add them by a single call to
|
* linked list (GList), and then add them by a single call to
|
||||||
* gtk_list_append_items()
|
* gtk_list_append_items().
|
||||||
* because we use g_list_prepend() to put the items into the
|
* Because we use g_list_prepend() to put the items into the
|
||||||
* doubly linked list, their order will be descending (instead
|
* doubly linked list, their order will be descending (instead
|
||||||
* of ascending when using g_list_append())
|
* of ascending when using g_list_append())
|
||||||
*/
|
*/
|
||||||
@ -163,29 +163,26 @@ gint main (int argc, gchar *argv[])
|
|||||||
}
|
}
|
||||||
gtk_list_append_items(GTK_LIST(gtklist), dlist);
|
gtk_list_append_items(GTK_LIST(gtklist), dlist);
|
||||||
|
|
||||||
/* finally we want to see the window, don't we? ;)
|
/* Finally we want to see the window, don't we? ;) */
|
||||||
*/
|
|
||||||
gtk_widget_show(window);
|
gtk_widget_show(window);
|
||||||
|
|
||||||
/* fire up the main event loop of gtk
|
/* Fire up the main event loop of gtk */
|
||||||
*/
|
|
||||||
gtk_main();
|
gtk_main();
|
||||||
|
|
||||||
/* we get here after gtk_main_quit() has been called which
|
/* We get here after gtk_main_quit() has been called which
|
||||||
* happens if the main window gets destroyed
|
* happens if the main window gets destroyed
|
||||||
*/
|
*/
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* this is the signal handler that got connected to button
|
/* This is the signal handler that got connected to button
|
||||||
* press/release events of the GtkList
|
* press/release events of the GtkList
|
||||||
*/
|
*/
|
||||||
void
|
void sigh_button_event( GtkWidget *gtklist,
|
||||||
sigh_button_event (GtkWidget *gtklist,
|
GdkEventButton *event,
|
||||||
GdkEventButton *event,
|
GtkWidget *frame )
|
||||||
GtkWidget *frame)
|
|
||||||
{
|
{
|
||||||
/* we only do something if the third (rightmost mouse button
|
/* We only do something if the third (rightmost mouse button
|
||||||
* was released
|
* was released
|
||||||
*/
|
*/
|
||||||
if (event->type==GDK_BUTTON_RELEASE &&
|
if (event->type==GDK_BUTTON_RELEASE &&
|
||||||
@ -193,7 +190,7 @@ sigh_button_event (GtkWidget *gtklist,
|
|||||||
GList *dlist, *free_list;
|
GList *dlist, *free_list;
|
||||||
GtkWidget *new_prisoner;
|
GtkWidget *new_prisoner;
|
||||||
|
|
||||||
/* fetch the currently selected list item which
|
/* Fetch the currently selected list item which
|
||||||
* will be our next prisoner ;)
|
* will be our next prisoner ;)
|
||||||
*/
|
*/
|
||||||
dlist=GTK_LIST(gtklist)->selection;
|
dlist=GTK_LIST(gtklist)->selection;
|
||||||
@ -202,9 +199,9 @@ sigh_button_event (GtkWidget *gtklist,
|
|||||||
else
|
else
|
||||||
new_prisoner=NULL;
|
new_prisoner=NULL;
|
||||||
|
|
||||||
/* look for already imprisoned list items, we
|
/* Look for already imprisoned list items, we
|
||||||
* will put them back into the list
|
* will put them back into the list.
|
||||||
* remember to free the doubly linked list that
|
* Remember to free the doubly linked list that
|
||||||
* gtk_container_children() returns
|
* gtk_container_children() returns
|
||||||
*/
|
*/
|
||||||
dlist=gtk_container_children(GTK_CONTAINER(frame));
|
dlist=gtk_container_children(GTK_CONTAINER(frame));
|
||||||
@ -220,9 +217,9 @@ sigh_button_event (GtkWidget *gtklist,
|
|||||||
}
|
}
|
||||||
g_list_free(free_list);
|
g_list_free(free_list);
|
||||||
|
|
||||||
/* if we have a new prisoner, remove him from the
|
/* If we have a new prisoner, remove him from the
|
||||||
* GtkList and put him into the frame "Prison"
|
* GtkList and put him into the frame "Prison".
|
||||||
* we need to unselect the item before
|
* We need to unselect the item first.
|
||||||
*/
|
*/
|
||||||
if (new_prisoner) {
|
if (new_prisoner) {
|
||||||
GList static_dlist;
|
GList static_dlist;
|
||||||
@ -238,35 +235,33 @@ sigh_button_event (GtkWidget *gtklist,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* this is the signal handler that gets called if GtkList
|
/* This is the signal handler that gets called if GtkList
|
||||||
* emits the "selection_changed" signal
|
* emits the "selection_changed" signal
|
||||||
*/
|
*/
|
||||||
void
|
void sigh_print_selection( GtkWidget *gtklist,
|
||||||
sigh_print_selection (GtkWidget *gtklist,
|
gpointer func_data)
|
||||||
gpointer func_data)
|
|
||||||
{
|
{
|
||||||
GList *dlist;
|
GList *dlist;
|
||||||
|
|
||||||
/* fetch the doubly linked list of selected items
|
/* Fetch the doubly linked list of selected items
|
||||||
* of the GtkList, remember to treat this as read-only!
|
* of the GtkList, remember to treat this as read-only!
|
||||||
*/
|
*/
|
||||||
dlist=GTK_LIST(gtklist)->selection;
|
dlist=GTK_LIST(gtklist)->selection;
|
||||||
|
|
||||||
/* if there are no selected items there is nothing more
|
/* If there are no selected items there is nothing more
|
||||||
* to do than just telling the user so
|
* to do than just telling the user so
|
||||||
*/
|
*/
|
||||||
if (!dlist) {
|
if (!dlist) {
|
||||||
g_print("Selection cleared\n");
|
g_print("Selection cleared\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* ok, we got a selection and so we print it
|
/* Ok, we got a selection and so we print it
|
||||||
*/
|
*/
|
||||||
g_print("The selection is a ");
|
g_print("The selection is a ");
|
||||||
|
|
||||||
/* get the list item from the doubly linked list
|
/* Get the list item from the doubly linked list
|
||||||
* and then query the data associated with list_item_data_key
|
* and then query the data associated with list_item_data_key.
|
||||||
* we then just print it
|
* We then just print it */
|
||||||
*/
|
|
||||||
while (dlist) {
|
while (dlist) {
|
||||||
GtkObject *list_item;
|
GtkObject *list_item;
|
||||||
gchar *item_data_string;
|
gchar *item_data_string;
|
||||||
|
@ -27,7 +27,7 @@ void remove_book (GtkButton *button, GtkNotebook *notebook)
|
|||||||
{
|
{
|
||||||
gint page;
|
gint page;
|
||||||
|
|
||||||
page = gtk_notebook_current_page(notebook);
|
page = gtk_notebook_get_current_page(notebook);
|
||||||
gtk_notebook_remove_page (notebook, page);
|
gtk_notebook_remove_page (notebook, page);
|
||||||
/* Need to refresh the widget --
|
/* Need to refresh the widget --
|
||||||
This forces the widget to redraw itself. */
|
This forces the widget to redraw itself. */
|
||||||
@ -60,8 +60,8 @@ int main (int argc, char *argv[])
|
|||||||
GTK_SIGNAL_FUNC (delete), NULL);
|
GTK_SIGNAL_FUNC (delete), NULL);
|
||||||
|
|
||||||
gtk_container_border_width (GTK_CONTAINER (window), 10);
|
gtk_container_border_width (GTK_CONTAINER (window), 10);
|
||||||
|
|
||||||
table = gtk_table_new(2,6,TRUE);
|
table = gtk_table_new(3,6,FALSE);
|
||||||
gtk_container_add (GTK_CONTAINER (window), table);
|
gtk_container_add (GTK_CONTAINER (window), table);
|
||||||
|
|
||||||
/* Create a new notebook, place the position of the tabs */
|
/* Create a new notebook, place the position of the tabs */
|
||||||
@ -70,7 +70,7 @@ int main (int argc, char *argv[])
|
|||||||
gtk_table_attach_defaults(GTK_TABLE(table), notebook, 0,6,0,1);
|
gtk_table_attach_defaults(GTK_TABLE(table), notebook, 0,6,0,1);
|
||||||
gtk_widget_show(notebook);
|
gtk_widget_show(notebook);
|
||||||
|
|
||||||
/* lets append a bunch of pages to the notebook */
|
/* Lets append a bunch of pages to the notebook */
|
||||||
for (i=0; i < 5; i++) {
|
for (i=0; i < 5; i++) {
|
||||||
sprintf(bufferf, "Append Frame %d", i+1);
|
sprintf(bufferf, "Append Frame %d", i+1);
|
||||||
sprintf(bufferl, "Page %d", i+1);
|
sprintf(bufferl, "Page %d", i+1);
|
||||||
@ -87,16 +87,12 @@ int main (int argc, char *argv[])
|
|||||||
label = gtk_label_new (bufferl);
|
label = gtk_label_new (bufferl);
|
||||||
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), frame, label);
|
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), frame, label);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Now lets add a page to a specific spot */
|
||||||
/* now lets add a page to a specific spot */
|
|
||||||
checkbutton = gtk_check_button_new_with_label ("Check me please!");
|
checkbutton = gtk_check_button_new_with_label ("Check me please!");
|
||||||
gtk_widget_set_usize(checkbutton, 100, 75);
|
gtk_widget_set_usize(checkbutton, 100, 75);
|
||||||
gtk_widget_show (checkbutton);
|
gtk_widget_show (checkbutton);
|
||||||
|
|
||||||
label = gtk_label_new ("Add spot");
|
|
||||||
gtk_container_add (GTK_CONTAINER (checkbutton), label);
|
|
||||||
gtk_widget_show (label);
|
|
||||||
label = gtk_label_new ("Add page");
|
label = gtk_label_new ("Add page");
|
||||||
gtk_notebook_insert_page (GTK_NOTEBOOK (notebook), checkbutton, label, 2);
|
gtk_notebook_insert_page (GTK_NOTEBOOK (notebook), checkbutton, label, 2);
|
||||||
|
|
||||||
@ -120,9 +116,8 @@ int main (int argc, char *argv[])
|
|||||||
|
|
||||||
/* Set what page to start at (page 4) */
|
/* Set what page to start at (page 4) */
|
||||||
gtk_notebook_set_page (GTK_NOTEBOOK(notebook), 3);
|
gtk_notebook_set_page (GTK_NOTEBOOK(notebook), 3);
|
||||||
|
|
||||||
|
/* Create a bunch of buttons */
|
||||||
/* create a bunch of buttons */
|
|
||||||
button = gtk_button_new_with_label ("close");
|
button = gtk_button_new_with_label ("close");
|
||||||
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
|
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
|
||||||
GTK_SIGNAL_FUNC (delete), NULL);
|
GTK_SIGNAL_FUNC (delete), NULL);
|
||||||
@ -168,6 +163,6 @@ int main (int argc, char *argv[])
|
|||||||
|
|
||||||
gtk_main ();
|
gtk_main ();
|
||||||
|
|
||||||
return 0;
|
return(0);
|
||||||
}
|
}
|
||||||
/* example-end */
|
/* example-end */
|
||||||
|
@ -22,7 +22,8 @@ create_list (void)
|
|||||||
|
|
||||||
/* Create a new list and put it in the scrolled window */
|
/* Create a new list and put it in the scrolled window */
|
||||||
list = gtk_list_new ();
|
list = gtk_list_new ();
|
||||||
gtk_container_add (GTK_CONTAINER(scrolled_window), list);
|
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_window),
|
||||||
|
list);
|
||||||
gtk_widget_show (list);
|
gtk_widget_show (list);
|
||||||
|
|
||||||
/* Add some messages to the window */
|
/* Add some messages to the window */
|
||||||
@ -114,11 +115,16 @@ main (int argc, char *argv[])
|
|||||||
gtk_signal_connect (GTK_OBJECT (window), "destroy",
|
gtk_signal_connect (GTK_OBJECT (window), "destroy",
|
||||||
GTK_SIGNAL_FUNC (gtk_main_quit), NULL);
|
GTK_SIGNAL_FUNC (gtk_main_quit), NULL);
|
||||||
gtk_container_border_width (GTK_CONTAINER (window), 10);
|
gtk_container_border_width (GTK_CONTAINER (window), 10);
|
||||||
|
gtk_widget_set_usize (GTK_WIDGET(window), 450, 400);
|
||||||
|
|
||||||
/* create a vpaned widget and add it to our toplevel window */
|
/* create a vpaned widget and add it to our toplevel window */
|
||||||
|
|
||||||
vpaned = gtk_vpaned_new ();
|
vpaned = gtk_vpaned_new ();
|
||||||
gtk_container_add (GTK_CONTAINER(window), vpaned);
|
gtk_container_add (GTK_CONTAINER(window), vpaned);
|
||||||
|
gtk_paned_set_handle_size (GTK_PANED(vpaned),
|
||||||
|
10);
|
||||||
|
gtk_paned_set_gutter_size (GTK_PANED(vpaned),
|
||||||
|
15);
|
||||||
gtk_widget_show (vpaned);
|
gtk_widget_show (vpaned);
|
||||||
|
|
||||||
/* Now create the contents of the two halves of the window */
|
/* Now create the contents of the two halves of the window */
|
||||||
|
@ -19,13 +19,13 @@ int main (int argc, char *argv[])
|
|||||||
gtk_init (&argc, &argv);
|
gtk_init (&argc, &argv);
|
||||||
|
|
||||||
/* Create a new dialog window for the scrolled window to be
|
/* Create a new dialog window for the scrolled window to be
|
||||||
* packed into. A dialog is just like a normal window except it has a
|
* packed into. A dialog is just like a normal window except it has a
|
||||||
* vbox and a horizontal separator packed into it. It's just a shortcut
|
* vbox and a horizontal separator packed into it. It's just a shortcut
|
||||||
* for creating dialogs */
|
* for creating dialogs */
|
||||||
window = gtk_dialog_new ();
|
window = gtk_dialog_new ();
|
||||||
gtk_signal_connect (GTK_OBJECT (window), "destroy",
|
gtk_signal_connect (GTK_OBJECT (window), "destroy",
|
||||||
(GtkSignalFunc) destroy, NULL);
|
(GtkSignalFunc) destroy, NULL);
|
||||||
gtk_window_set_title (GTK_WINDOW (window), "dialog");
|
gtk_window_set_title (GTK_WINDOW (window), "GtkScrolledWindow example");
|
||||||
gtk_container_border_width (GTK_CONTAINER (window), 0);
|
gtk_container_border_width (GTK_CONTAINER (window), 0);
|
||||||
gtk_widget_set_usize(window, 300, 300);
|
gtk_widget_set_usize(window, 300, 300);
|
||||||
|
|
||||||
@ -54,7 +54,8 @@ int main (int argc, char *argv[])
|
|||||||
gtk_table_set_col_spacings (GTK_TABLE (table), 10);
|
gtk_table_set_col_spacings (GTK_TABLE (table), 10);
|
||||||
|
|
||||||
/* pack the table into the scrolled window */
|
/* pack the table into the scrolled window */
|
||||||
gtk_container_add (GTK_CONTAINER (scrolled_window), table);
|
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_window),
|
||||||
|
table);
|
||||||
gtk_widget_show (table);
|
gtk_widget_show (table);
|
||||||
|
|
||||||
/* this simply creates a grid of toggle buttons on the table
|
/* this simply creates a grid of toggle buttons on the table
|
||||||
|
@ -93,7 +93,8 @@ int main (int argc, char *argv[])
|
|||||||
gtk_signal_connect (GTK_OBJECT(tree), "selection_changed",
|
gtk_signal_connect (GTK_OBJECT(tree), "selection_changed",
|
||||||
GTK_SIGNAL_FUNC(cb_selection_changed), tree);
|
GTK_SIGNAL_FUNC(cb_selection_changed), tree);
|
||||||
/* Add it to the scrolled window */
|
/* Add it to the scrolled window */
|
||||||
gtk_container_add (GTK_CONTAINER(scrolled_win), tree);
|
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW(scrolled_win),
|
||||||
|
tree);
|
||||||
/* Set the selection mode */
|
/* Set the selection mode */
|
||||||
gtk_tree_set_selection_mode (GTK_TREE(tree),
|
gtk_tree_set_selection_mode (GTK_TREE(tree),
|
||||||
GTK_SELECTION_MULTIPLE);
|
GTK_SELECTION_MULTIPLE);
|
||||||
|
Loading…
Reference in New Issue
Block a user