forked from AuroraMiddleware/gtk
- re-write the GtkProgressBar section to the 1.1 API. - add an Appendix
Thu Dec 10 17:58:49 GMT 1998 Tony Gale <gale@gtk.org> * docs/gtk_tut.sgml: - re-write the GtkProgressBar section to the 1.1 API. - add an Appendix listing all the signals (apologies to TimJ for taking so long in using his hard work in automating the extraction - thanx Tim). * examples/*: bring them all upto the tutorial versions
This commit is contained in:
parent
600ef4e7d1
commit
3821880398
@ -1,3 +1,12 @@
|
||||
Thu Dec 10 17:58:49 GMT 1998 Tony Gale <gale@gtk.org>
|
||||
|
||||
* docs/gtk_tut.sgml:
|
||||
- re-write the GtkProgressBar section to the 1.1 API.
|
||||
- add an Appendix listing all the signals
|
||||
(apologies to TimJ for taking so long in using his hard work
|
||||
in automating the extraction - thanx Tim).
|
||||
* examples/*: bring them all upto the tutorial versions
|
||||
|
||||
Thu Dec 10 02:21:16 1998 Jeff Garzik <jgarzik@pobox.com>
|
||||
|
||||
* gtk/testdnd.c: use g_snprintf, eliminate need for string.h
|
||||
|
@ -1,3 +1,12 @@
|
||||
Thu Dec 10 17:58:49 GMT 1998 Tony Gale <gale@gtk.org>
|
||||
|
||||
* docs/gtk_tut.sgml:
|
||||
- re-write the GtkProgressBar section to the 1.1 API.
|
||||
- add an Appendix listing all the signals
|
||||
(apologies to TimJ for taking so long in using his hard work
|
||||
in automating the extraction - thanx Tim).
|
||||
* examples/*: bring them all upto the tutorial versions
|
||||
|
||||
Thu Dec 10 02:21:16 1998 Jeff Garzik <jgarzik@pobox.com>
|
||||
|
||||
* gtk/testdnd.c: use g_snprintf, eliminate need for string.h
|
||||
|
@ -1,3 +1,12 @@
|
||||
Thu Dec 10 17:58:49 GMT 1998 Tony Gale <gale@gtk.org>
|
||||
|
||||
* docs/gtk_tut.sgml:
|
||||
- re-write the GtkProgressBar section to the 1.1 API.
|
||||
- add an Appendix listing all the signals
|
||||
(apologies to TimJ for taking so long in using his hard work
|
||||
in automating the extraction - thanx Tim).
|
||||
* examples/*: bring them all upto the tutorial versions
|
||||
|
||||
Thu Dec 10 02:21:16 1998 Jeff Garzik <jgarzik@pobox.com>
|
||||
|
||||
* gtk/testdnd.c: use g_snprintf, eliminate need for string.h
|
||||
|
@ -1,3 +1,12 @@
|
||||
Thu Dec 10 17:58:49 GMT 1998 Tony Gale <gale@gtk.org>
|
||||
|
||||
* docs/gtk_tut.sgml:
|
||||
- re-write the GtkProgressBar section to the 1.1 API.
|
||||
- add an Appendix listing all the signals
|
||||
(apologies to TimJ for taking so long in using his hard work
|
||||
in automating the extraction - thanx Tim).
|
||||
* examples/*: bring them all upto the tutorial versions
|
||||
|
||||
Thu Dec 10 02:21:16 1998 Jeff Garzik <jgarzik@pobox.com>
|
||||
|
||||
* gtk/testdnd.c: use g_snprintf, eliminate need for string.h
|
||||
|
@ -1,3 +1,12 @@
|
||||
Thu Dec 10 17:58:49 GMT 1998 Tony Gale <gale@gtk.org>
|
||||
|
||||
* docs/gtk_tut.sgml:
|
||||
- re-write the GtkProgressBar section to the 1.1 API.
|
||||
- add an Appendix listing all the signals
|
||||
(apologies to TimJ for taking so long in using his hard work
|
||||
in automating the extraction - thanx Tim).
|
||||
* examples/*: bring them all upto the tutorial versions
|
||||
|
||||
Thu Dec 10 02:21:16 1998 Jeff Garzik <jgarzik@pobox.com>
|
||||
|
||||
* gtk/testdnd.c: use g_snprintf, eliminate need for string.h
|
||||
|
@ -1,3 +1,12 @@
|
||||
Thu Dec 10 17:58:49 GMT 1998 Tony Gale <gale@gtk.org>
|
||||
|
||||
* docs/gtk_tut.sgml:
|
||||
- re-write the GtkProgressBar section to the 1.1 API.
|
||||
- add an Appendix listing all the signals
|
||||
(apologies to TimJ for taking so long in using his hard work
|
||||
in automating the extraction - thanx Tim).
|
||||
* examples/*: bring them all upto the tutorial versions
|
||||
|
||||
Thu Dec 10 02:21:16 1998 Jeff Garzik <jgarzik@pobox.com>
|
||||
|
||||
* gtk/testdnd.c: use g_snprintf, eliminate need for string.h
|
||||
|
@ -1,3 +1,12 @@
|
||||
Thu Dec 10 17:58:49 GMT 1998 Tony Gale <gale@gtk.org>
|
||||
|
||||
* docs/gtk_tut.sgml:
|
||||
- re-write the GtkProgressBar section to the 1.1 API.
|
||||
- add an Appendix listing all the signals
|
||||
(apologies to TimJ for taking so long in using his hard work
|
||||
in automating the extraction - thanx Tim).
|
||||
* examples/*: bring them all upto the tutorial versions
|
||||
|
||||
Thu Dec 10 02:21:16 1998 Jeff Garzik <jgarzik@pobox.com>
|
||||
|
||||
* gtk/testdnd.c: use g_snprintf, eliminate need for string.h
|
||||
|
1443
docs/gtk_tut.sgml
1443
docs/gtk_tut.sgml
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
||||
/* aspectframe.c */
|
||||
/* example-start aspectframe aspectframe.c */
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
@ -41,3 +41,4 @@ main (int argc, char *argv[])
|
||||
gtk_main ();
|
||||
return 0;
|
||||
}
|
||||
/* example-end */
|
||||
|
@ -14,6 +14,6 @@ int main( int argc,
|
||||
|
||||
gtk_main ();
|
||||
|
||||
return 0;
|
||||
return(0);
|
||||
}
|
||||
/* example-end */
|
||||
|
@ -39,7 +39,7 @@ gint main (int argc, gchar *argv[])
|
||||
clist = gtk_clist_new_with_titles( 2, titles);
|
||||
|
||||
/* When a selection is made, we want to know about it. The callback
|
||||
* used is selection_made, and it's code can be found further down */
|
||||
* used is selection_made, and its code can be found further down */
|
||||
gtk_signal_connect(GTK_OBJECT(clist), "select_row",
|
||||
GTK_SIGNAL_FUNC(selection_made),
|
||||
NULL);
|
||||
|
@ -1,6 +1,4 @@
|
||||
/* This file extracted from the GTK tutorial. */
|
||||
|
||||
/* entry.c */
|
||||
/* example-start entry entry.c */
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
@ -90,3 +88,4 @@ int main (int argc, char *argv[])
|
||||
gtk_main();
|
||||
return(0);
|
||||
}
|
||||
/* example-end */
|
||||
|
@ -1,6 +1,4 @@
|
||||
/* This file extracted from the GTK tutorial. */
|
||||
|
||||
/* eventbox.c */
|
||||
/* example-start eventbox eventbox.c */
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
@ -53,3 +51,4 @@ main (int argc, char *argv[])
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* example-end */
|
||||
|
@ -1,6 +1,4 @@
|
||||
/* This file extracted from the GTK tutorial. */
|
||||
|
||||
/* filesel.c */
|
||||
/* example-start filesel filesel.c */
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
@ -44,3 +42,4 @@ int main (int argc, char *argv[])
|
||||
gtk_main ();
|
||||
return 0;
|
||||
}
|
||||
/* example-end */
|
||||
|
@ -1,3 +1,5 @@
|
||||
/* example-start gtkdial gtkdial.c */
|
||||
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
@ -26,7 +28,7 @@
|
||||
#define SCROLL_DELAY_LENGTH 300
|
||||
#define DIAL_DEFAULT_SIZE 100
|
||||
|
||||
/* Forward declararations */
|
||||
/* Forward declarations */
|
||||
|
||||
static void gtk_dial_class_init (GtkDialClass *klass);
|
||||
static void gtk_dial_init (GtkDial *dial);
|
||||
@ -587,5 +589,4 @@ gtk_dial_adjustment_value_changed (GtkAdjustment *adjustment,
|
||||
dial->old_value = adjustment->value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* example-end */
|
||||
|
@ -1,3 +1,5 @@
|
||||
/* example-start gtkdial gtkdial.h */
|
||||
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
@ -87,3 +89,4 @@ void gtk_dial_set_adjustment (GtkDial *dial,
|
||||
|
||||
|
||||
#endif /* __GTK_DIAL_H__ */
|
||||
/* example-end */
|
||||
|
@ -1,6 +1,4 @@
|
||||
/* This file extracted from the GTK tutorial. */
|
||||
|
||||
/* list.c */
|
||||
/* example-start list list.c */
|
||||
|
||||
/* include the gtk+ header files
|
||||
* include stdio.h, we need that for the printf() function
|
||||
@ -65,7 +63,7 @@ gint main (int argc, gchar *argv[])
|
||||
gtk_container_add(GTK_CONTAINER(window), vbox);
|
||||
gtk_widget_show(vbox);
|
||||
|
||||
/* this is the scolled 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);
|
||||
gtk_widget_set_usize(scrolled_window, 250, 150);
|
||||
gtk_container_add(GTK_CONTAINER(vbox), scrolled_window);
|
||||
@ -94,7 +92,7 @@ gint main (int argc, gchar *argv[])
|
||||
gtk_widget_show(frame);
|
||||
|
||||
/* connect the sigh_button_event() signal handler to the GtkList
|
||||
* wich will handle the "arresting" of list items
|
||||
* which will handle the "arresting" of list items
|
||||
*/
|
||||
gtk_signal_connect(GTK_OBJECT(gtklist),
|
||||
"button_release_event",
|
||||
@ -107,8 +105,8 @@ gint main (int argc, gchar *argv[])
|
||||
gtk_container_add(GTK_CONTAINER(vbox), separator);
|
||||
gtk_widget_show(separator);
|
||||
|
||||
/* finaly create a button and connect it´s "clicked" signal
|
||||
* to the destroyment of the window
|
||||
/* finally create a button and connect it´s "clicked" signal
|
||||
* to the destruction of the window
|
||||
*/
|
||||
button=gtk_button_new_with_label("Close");
|
||||
gtk_container_add(GTK_CONTAINER(vbox), button);
|
||||
@ -165,7 +163,7 @@ gint main (int argc, gchar *argv[])
|
||||
}
|
||||
gtk_list_append_items(GTK_LIST(gtklist), dlist);
|
||||
|
||||
/* finaly we want to see the window, don´t we? ;)
|
||||
/* finally we want to see the window, don't we? ;)
|
||||
*/
|
||||
gtk_widget_show(window);
|
||||
|
||||
@ -204,7 +202,7 @@ sigh_button_event (GtkWidget *gtklist,
|
||||
else
|
||||
new_prisoner=NULL;
|
||||
|
||||
/* look for already prisoned list items, we
|
||||
/* look for already imprisoned list items, we
|
||||
* will put them back into the list
|
||||
* remember to free the doubly linked list that
|
||||
* gtk_container_children() returns
|
||||
@ -282,3 +280,4 @@ sigh_print_selection (GtkWidget *gtklist,
|
||||
}
|
||||
g_print("\n");
|
||||
}
|
||||
/* example-end */
|
||||
|
@ -1,6 +1,4 @@
|
||||
/* This file extracted from the GTK tutorial. */
|
||||
|
||||
/* menu.c */
|
||||
/* example-start menu menu.c */
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
@ -27,7 +25,7 @@ int main (int argc, char *argv[])
|
||||
gtk_widget_set_usize( GTK_WIDGET (window), 200, 100);
|
||||
gtk_window_set_title(GTK_WINDOW (window), "GTK Menu Test");
|
||||
gtk_signal_connect(GTK_OBJECT (window), "delete_event",
|
||||
(GtkSignalFunc) gtk_exit, NULL);
|
||||
(GtkSignalFunc) gtk_main_quit, NULL);
|
||||
|
||||
/* Init the menu-widget, and remember -- never
|
||||
* gtk_show_widget() the menu widget!!
|
||||
@ -101,8 +99,6 @@ int main (int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Respond to a button-press by posting a menu passed in as widget.
|
||||
*
|
||||
* Note that the "widget" argument is the menu being posted, NOT
|
||||
@ -132,3 +128,4 @@ static void menuitem_response (gchar *string)
|
||||
{
|
||||
printf("%s\n", string);
|
||||
}
|
||||
/* example-end */
|
||||
|
@ -1,6 +1,4 @@
|
||||
/* This file extracted from the GTK tutorial. */
|
||||
|
||||
/* notebook.c */
|
||||
/* example-start notebook notebook.c */
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
@ -36,7 +34,7 @@ void remove_book (GtkButton *button, GtkNotebook *notebook)
|
||||
gtk_widget_draw(GTK_WIDGET(notebook), NULL);
|
||||
}
|
||||
|
||||
void delete (GtkWidget *widget, GdkEvent *event, gpointer data)
|
||||
void delete (GtkWidget *widget, GtkWidget *event, gpointer data)
|
||||
{
|
||||
gtk_main_quit ();
|
||||
}
|
||||
@ -172,3 +170,4 @@ int main (int argc, char *argv[])
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* example-end */
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
CC = gcc
|
||||
|
||||
packer: packer.c
|
||||
packer: pack.c
|
||||
$(CC) `gtk-config --cflags` pack.c -o packer `gtk-config --libs`
|
||||
|
||||
clean:
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* paned.c */
|
||||
/* example-start paned paned.c */
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
@ -134,3 +134,4 @@ main (int argc, char *argv[])
|
||||
gtk_main ();
|
||||
return 0;
|
||||
}
|
||||
/* example-end */
|
||||
|
@ -1,6 +1,4 @@
|
||||
/* This file extracted from the GTK tutorial. */
|
||||
|
||||
/* pixmap.c */
|
||||
/* example-start pixmap pixmap.c */
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
@ -31,8 +29,7 @@ static const char * xpm_data[] = {
|
||||
|
||||
/* when invoked (via signal delete_event), terminates the application.
|
||||
*/
|
||||
void close_application( GtkWidget *widget, GdkEvent *event, gpointer data )
|
||||
{
|
||||
void close_application( GtkWidget *widget, GdkEvent *event, gpointer data ) {
|
||||
gtk_main_quit();
|
||||
}
|
||||
|
||||
@ -84,3 +81,4 @@ int main( int argc, char *argv[] )
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* example-end */
|
||||
|
@ -1,93 +1,220 @@
|
||||
/* This file extracted from the GTK tutorial. */
|
||||
|
||||
/* progressbar.c */
|
||||
/* example-start progressbar progressbar.c */
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
static int ptimer = 0;
|
||||
int pstat = TRUE;
|
||||
typedef struct _ProgressData {
|
||||
GtkWidget *window;
|
||||
GtkWidget *pbar;
|
||||
int timer;
|
||||
} ProgressData;
|
||||
|
||||
/* This function increments and updates the progress bar, it also resets
|
||||
the progress bar if pstat is FALSE */
|
||||
gint progress (gpointer data)
|
||||
/* Update the value of the progress bar so that we get
|
||||
* some movement */
|
||||
gint progress_timeout( gpointer data )
|
||||
{
|
||||
gfloat pvalue;
|
||||
gfloat new_val;
|
||||
GtkAdjustment *adj;
|
||||
|
||||
/* get the current value of the progress bar */
|
||||
pvalue = GTK_PROGRESS_BAR (data)->percentage;
|
||||
adj = GTK_PROGRESS (data)->adjustment;
|
||||
|
||||
if ((pvalue >= 1.0) || (pstat == FALSE)) {
|
||||
pvalue = 0.0;
|
||||
pstat = TRUE;
|
||||
}
|
||||
pvalue += 0.01;
|
||||
/* Calculate the value of the progress bar using the
|
||||
* value range set in the adjustment object */
|
||||
new_val = adj->value + 1;
|
||||
if (new_val > adj->upper)
|
||||
new_val = adj->lower;
|
||||
|
||||
gtk_progress_bar_update (GTK_PROGRESS_BAR (data), pvalue);
|
||||
/* Set the new value */
|
||||
gtk_progress_set_value (GTK_PROGRESS (data), new_val);
|
||||
|
||||
return TRUE;
|
||||
/* As this is a timeout function, return TRUE so that it
|
||||
* continues to get called */
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
/* This function signals a reset of the progress bar */
|
||||
void progress_r (void)
|
||||
/* Callback that toggles the text display within the progress
|
||||
* bar trough */
|
||||
void toggle_show_text( GtkWidget *widget,
|
||||
ProgressData *pdata )
|
||||
{
|
||||
pstat = FALSE;
|
||||
gtk_progress_set_show_text (GTK_PROGRESS (pdata->pbar),
|
||||
GTK_TOGGLE_BUTTON (widget)->active);
|
||||
}
|
||||
|
||||
void destroy (GtkWidget *widget, GdkEvent *event, gpointer data)
|
||||
/* Callback that toggles the activity mode of the progress
|
||||
* bar */
|
||||
void toggle_activity_mode( GtkWidget *widget,
|
||||
ProgressData *pdata )
|
||||
{
|
||||
gtk_progress_set_activity_mode (GTK_PROGRESS (pdata->pbar),
|
||||
GTK_TOGGLE_BUTTON (widget)->active);
|
||||
}
|
||||
|
||||
/* Callback that toggles the continuous mode of the progress
|
||||
* bar */
|
||||
void set_continuous_mode( GtkWidget *widget,
|
||||
ProgressData *pdata )
|
||||
{
|
||||
gtk_progress_bar_set_bar_style (GTK_PROGRESS_BAR (pdata->pbar),
|
||||
GTK_PROGRESS_CONTINUOUS);
|
||||
}
|
||||
|
||||
/* Callback that toggles the discrete mode of the progress
|
||||
* bar */
|
||||
void set_discrete_mode( GtkWidget *widget,
|
||||
ProgressData *pdata )
|
||||
{
|
||||
gtk_progress_bar_set_bar_style (GTK_PROGRESS_BAR (pdata->pbar),
|
||||
GTK_PROGRESS_DISCRETE);
|
||||
}
|
||||
|
||||
/* Clean up allocated memory and remove the timer */
|
||||
void destroy_progress( GtkWidget *widget,
|
||||
ProgressData *pdata)
|
||||
{
|
||||
gtk_timeout_remove (pdata->timer);
|
||||
pdata->timer = 0;
|
||||
pdata->window = NULL;
|
||||
g_free(pdata);
|
||||
gtk_main_quit();
|
||||
}
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
int main( int argc,
|
||||
char *argv[])
|
||||
{
|
||||
GtkWidget *window;
|
||||
GtkWidget *button;
|
||||
GtkWidget *label;
|
||||
ProgressData *pdata;
|
||||
GtkWidget *align;
|
||||
GtkWidget *separator;
|
||||
GtkWidget *table;
|
||||
GtkWidget *pbar;
|
||||
GtkAdjustment *adj;
|
||||
GtkWidget *button;
|
||||
GtkWidget *check;
|
||||
GtkWidget *vbox;
|
||||
|
||||
gtk_init (&argc, &argv);
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
/* Allocate memory for the data that is passwd to the callbacks */
|
||||
pdata = g_malloc( sizeof(ProgressData) );
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (window), "delete_event",
|
||||
GTK_SIGNAL_FUNC (destroy), NULL);
|
||||
pdata->window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_policy (GTK_WINDOW (pdata->window), FALSE, FALSE, TRUE);
|
||||
|
||||
gtk_container_border_width (GTK_CONTAINER (window), 10);
|
||||
gtk_signal_connect (GTK_OBJECT (pdata->window), "destroy",
|
||||
GTK_SIGNAL_FUNC (destroy_progress),
|
||||
pdata);
|
||||
gtk_window_set_title (GTK_WINDOW (pdata->window), "GtkProgressBar");
|
||||
gtk_container_set_border_width (GTK_CONTAINER (pdata->window), 0);
|
||||
|
||||
table = gtk_table_new(3,2,TRUE);
|
||||
gtk_container_add (GTK_CONTAINER (window), table);
|
||||
vbox = gtk_vbox_new (FALSE, 5);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 10);
|
||||
gtk_container_add (GTK_CONTAINER (pdata->window), vbox);
|
||||
gtk_widget_show(vbox);
|
||||
|
||||
label = gtk_label_new ("Progress Bar Example");
|
||||
gtk_table_attach_defaults(GTK_TABLE(table), label, 0,2,0,1);
|
||||
gtk_widget_show(label);
|
||||
/* Create a centering alignment object */
|
||||
align = gtk_alignment_new (0.5, 0.5, 0, 0);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), align, FALSE, FALSE, 5);
|
||||
gtk_widget_show(align);
|
||||
|
||||
/* Create a new progress bar, pack it into the table, and show it */
|
||||
pbar = gtk_progress_bar_new ();
|
||||
gtk_table_attach_defaults(GTK_TABLE(table), pbar, 0,2,1,2);
|
||||
gtk_widget_show (pbar);
|
||||
/* Create a GtkAdjusment object to hold the range of the
|
||||
* progress bar */
|
||||
adj = (GtkAdjustment *) gtk_adjustment_new (0, 1, 150, 0, 0, 0);
|
||||
|
||||
/* Set the timeout to handle automatic updating of the progress bar */
|
||||
ptimer = gtk_timeout_add (100, progress, pbar);
|
||||
/* Create the GtkProgressBar using the adjustment */
|
||||
pdata->pbar = gtk_progress_bar_new_with_adjustment (adj);
|
||||
|
||||
/* This button signals the progress bar to be reset */
|
||||
button = gtk_button_new_with_label ("Reset");
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||
GTK_SIGNAL_FUNC (progress_r), NULL);
|
||||
gtk_table_attach_defaults(GTK_TABLE(table), button, 0,1,2,3);
|
||||
gtk_widget_show(button);
|
||||
/* Set the format of the string that can be displayed in the
|
||||
* trough of the progress bar:
|
||||
* %p - percentage
|
||||
* %v - value
|
||||
* %l - lower range value
|
||||
* %u - upper range value */
|
||||
gtk_progress_set_format_string (GTK_PROGRESS (pdata->pbar),
|
||||
"%v from [%l-%u] (=%p%%)");
|
||||
gtk_container_add (GTK_CONTAINER (align), pdata->pbar);
|
||||
gtk_widget_show(pdata->pbar);
|
||||
|
||||
button = gtk_button_new_with_label ("Cancel");
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||
GTK_SIGNAL_FUNC (destroy), NULL);
|
||||
/* Add a timer callback to update the value of the progress bar */
|
||||
pdata->timer = gtk_timeout_add (100, progress_timeout, pdata->pbar);
|
||||
|
||||
gtk_table_attach_defaults(GTK_TABLE(table), button, 1,2,2,3);
|
||||
gtk_widget_show (button);
|
||||
separator = gtk_hseparator_new ();
|
||||
gtk_box_pack_start (GTK_BOX (vbox), separator, FALSE, FALSE, 0);
|
||||
gtk_widget_show(separator);
|
||||
|
||||
/* rows, columns, homogeneous */
|
||||
table = gtk_table_new (2, 3, FALSE);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, TRUE, 0);
|
||||
gtk_widget_show(table);
|
||||
gtk_widget_show(window);
|
||||
|
||||
/* Add a check button to select displaying of the trough text */
|
||||
check = gtk_check_button_new_with_label ("Show text");
|
||||
gtk_table_attach (GTK_TABLE (table), check, 0, 1, 0, 1,
|
||||
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL,
|
||||
5, 5);
|
||||
gtk_signal_connect (GTK_OBJECT (check), "clicked",
|
||||
GTK_SIGNAL_FUNC (toggle_show_text),
|
||||
pdata);
|
||||
gtk_widget_show(check);
|
||||
|
||||
/* Add a check button to toggle activity mode */
|
||||
check = gtk_check_button_new_with_label ("Activity mode");
|
||||
gtk_table_attach (GTK_TABLE (table), check, 0, 1, 1, 2,
|
||||
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL,
|
||||
5, 5);
|
||||
gtk_signal_connect (GTK_OBJECT (check), "clicked",
|
||||
GTK_SIGNAL_FUNC (toggle_activity_mode),
|
||||
pdata);
|
||||
gtk_widget_show(check);
|
||||
|
||||
separator = gtk_vseparator_new ();
|
||||
gtk_table_attach (GTK_TABLE (table), separator, 1, 2, 0, 2,
|
||||
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL,
|
||||
5, 5);
|
||||
gtk_widget_show(separator);
|
||||
|
||||
/* Add a radio button to select continuous display mode */
|
||||
button = gtk_radio_button_new_with_label (NULL, "Continuous");
|
||||
gtk_table_attach (GTK_TABLE (table), button, 2, 3, 0, 1,
|
||||
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL,
|
||||
5, 5);
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||
GTK_SIGNAL_FUNC (set_continuous_mode),
|
||||
pdata);
|
||||
gtk_widget_show (button);
|
||||
|
||||
/* Add a radio button to select discrete display mode */
|
||||
button = gtk_radio_button_new_with_label(
|
||||
gtk_radio_button_group (GTK_RADIO_BUTTON (button)),
|
||||
"Discrete");
|
||||
gtk_table_attach (GTK_TABLE (table), button, 2, 3, 1, 2,
|
||||
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL,
|
||||
5, 5);
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||
GTK_SIGNAL_FUNC (set_discrete_mode),
|
||||
pdata);
|
||||
gtk_widget_show (button);
|
||||
|
||||
separator = gtk_hseparator_new ();
|
||||
gtk_box_pack_start (GTK_BOX (vbox), separator, FALSE, FALSE, 0);
|
||||
gtk_widget_show(separator);
|
||||
|
||||
/* Add a button to exit the program */
|
||||
button = gtk_button_new_with_label ("close");
|
||||
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
|
||||
(GtkSignalFunc) gtk_widget_destroy,
|
||||
GTK_OBJECT (pdata->window));
|
||||
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
||||
|
||||
/* This makes it so the button is the default. */
|
||||
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
|
||||
|
||||
/* This grabs this button to be the default button. Simply hitting
|
||||
* the "Enter" key will cause this button to activate. */
|
||||
gtk_widget_grab_default (button);
|
||||
gtk_widget_show(button);
|
||||
|
||||
gtk_widget_show (pdata->window);
|
||||
|
||||
gtk_main ();
|
||||
|
||||
return 0;
|
||||
return(0);
|
||||
}
|
||||
/* example-end */
|
||||
|
@ -1,6 +1,4 @@
|
||||
/* This file extracted from the GTK tutorial. */
|
||||
|
||||
/* rulers.c */
|
||||
/* example-start rulers rulers.c */
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
@ -9,20 +7,16 @@
|
||||
#define XSIZE 600
|
||||
#define YSIZE 400
|
||||
|
||||
/* this routine gets control when the close button is clicked
|
||||
*/
|
||||
void close_application( GtkWidget *widget, GdkEvent *event, gpointer data )
|
||||
{
|
||||
/* This routine gets control when the close button is clicked */
|
||||
void close_application( GtkWidget *widget, GdkEvent *event, gpointer data ) {
|
||||
gtk_main_quit();
|
||||
}
|
||||
|
||||
|
||||
/* the main routine
|
||||
*/
|
||||
/* The main routine */
|
||||
int main( int argc, char *argv[] ) {
|
||||
GtkWidget *window, *table, *area, *hrule, *vrule;
|
||||
|
||||
/* initialize gtk and create the main window */
|
||||
/* Initialize GTK and create the main window */
|
||||
gtk_init( &argc, &argv );
|
||||
|
||||
window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
|
||||
@ -30,7 +24,7 @@ int main( int argc, char *argv[] ) {
|
||||
GTK_SIGNAL_FUNC( close_application ), NULL);
|
||||
gtk_container_border_width (GTK_CONTAINER (window), 10);
|
||||
|
||||
/* create a table for placing the ruler and the drawing area */
|
||||
/* Create a table for placing the ruler and the drawing area */
|
||||
table = gtk_table_new( 3, 2, FALSE );
|
||||
gtk_container_add( GTK_CONTAINER(window), table );
|
||||
|
||||
@ -41,7 +35,7 @@ int main( int argc, char *argv[] ) {
|
||||
gtk_widget_set_events( area, GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK );
|
||||
|
||||
/* The horizontal ruler goes on top. As the mouse moves across the drawing area,
|
||||
a motion_notify_event is passed to the appropriate event handler for the ruler. */
|
||||
* a motion_notify_event is passed to the appropriate event handler for the ruler. */
|
||||
hrule = gtk_hruler_new();
|
||||
gtk_ruler_set_metric( GTK_RULER(hrule), GTK_PIXELS );
|
||||
gtk_ruler_set_range( GTK_RULER(hrule), 7, 13, 0, 20 );
|
||||
@ -53,7 +47,7 @@ int main( int argc, char *argv[] ) {
|
||||
GTK_EXPAND|GTK_SHRINK|GTK_FILL, GTK_FILL, 0, 0 );
|
||||
|
||||
/* The vertical ruler goes on the left. As the mouse moves across the drawing area,
|
||||
a motion_notify_event is passed to the appropriate event handler for the ruler. */
|
||||
* a motion_notify_event is passed to the appropriate event handler for the ruler. */
|
||||
vrule = gtk_vruler_new();
|
||||
gtk_ruler_set_metric( GTK_RULER(vrule), GTK_PIXELS );
|
||||
gtk_ruler_set_range( GTK_RULER(vrule), 0, YSIZE, 10, YSIZE );
|
||||
@ -64,7 +58,7 @@ int main( int argc, char *argv[] ) {
|
||||
gtk_table_attach( GTK_TABLE(table), vrule, 0, 1, 1, 2,
|
||||
GTK_FILL, GTK_EXPAND|GTK_SHRINK|GTK_FILL, 0, 0 );
|
||||
|
||||
/* now show everything */
|
||||
/* Now show everything */
|
||||
gtk_widget_show( area );
|
||||
gtk_widget_show( hrule );
|
||||
gtk_widget_show( vrule );
|
||||
@ -72,5 +66,6 @@ int main( int argc, char *argv[] ) {
|
||||
gtk_widget_show( window );
|
||||
gtk_main();
|
||||
|
||||
return 0;
|
||||
return(0);
|
||||
}
|
||||
/* example-end */
|
||||
|
@ -1,3 +1,5 @@
|
||||
/* example-start scribble-simple scribble-simple.c */
|
||||
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
@ -175,3 +177,4 @@ main (int argc, char *argv[])
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* example-end */
|
||||
|
@ -1,6 +1,4 @@
|
||||
/* This file extracted from the GTK tutorial. */
|
||||
|
||||
/* scrolledwin.c */
|
||||
/* example-start scrolledwin scrolledwin.c */
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
@ -22,7 +20,7 @@ int main (int argc, char *argv[])
|
||||
|
||||
/* 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
|
||||
* vbox and a horizontal seperator packed into it. It's just a shortcut
|
||||
* vbox and a horizontal separator packed into it. It's just a shortcut
|
||||
* for creating dialogs */
|
||||
window = gtk_dialog_new ();
|
||||
gtk_signal_connect (GTK_OBJECT (window), "destroy",
|
||||
@ -38,7 +36,7 @@ int main (int argc, char *argv[])
|
||||
|
||||
/* the policy is one of GTK_POLICY AUTOMATIC, or GTK_POLICY_ALWAYS.
|
||||
* GTK_POLICY_AUTOMATIC will automatically decide whether you need
|
||||
* scrollbars, wheras GTK_POLICY_ALWAYS will always leave the scrollbars
|
||||
* scrollbars, whereas GTK_POLICY_ALWAYS will always leave the scrollbars
|
||||
* there. The first one is the horizontal scrollbar, the second,
|
||||
* the vertical. */
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
|
||||
@ -92,3 +90,4 @@ int main (int argc, char *argv[])
|
||||
|
||||
return(0);
|
||||
}
|
||||
/* example-end */
|
||||
|
@ -1,6 +1,4 @@
|
||||
/* This file extracted from the GTK tutorial. */
|
||||
|
||||
/* gettargets.c */
|
||||
/* example-start selection gettargets.c */
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
@ -14,7 +12,7 @@ get_targets (GtkWidget *widget, gpointer data)
|
||||
{
|
||||
static GdkAtom targets_atom = GDK_NONE;
|
||||
|
||||
/* Get the atom corresonding to the string "TARGETS" */
|
||||
/* Get the atom corresponding to the string "TARGETS" */
|
||||
if (targets_atom == GDK_NONE)
|
||||
targets_atom = gdk_atom_intern ("TARGETS", FALSE);
|
||||
|
||||
@ -96,3 +94,4 @@ main (int argc, char *argv[])
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* example-end */
|
||||
|
@ -1,6 +1,4 @@
|
||||
/* This file extracted from the GTK tutorial. */
|
||||
|
||||
/* setselection.c */
|
||||
/* example-start selection setselection.c */
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <time.h>
|
||||
@ -104,3 +102,4 @@ main (int argc, char *argv[])
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* example-end */
|
||||
|
@ -1,6 +1,4 @@
|
||||
/* This file extracted from the GTK tutorial. */
|
||||
|
||||
/* statusbar.c (Tony Gale) */
|
||||
/* example-start statusbar statusbar.c */
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <glib.h>
|
||||
@ -72,3 +70,4 @@ int main (int argc, char *argv[])
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* example-end */
|
||||
|
@ -1,3 +1,5 @@
|
||||
/* example-start tictactoe tictactoe.c */
|
||||
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
@ -154,3 +156,5 @@ tictactoe_toggle (GtkWidget *widget, Tictactoe *ttt)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* example-end */
|
||||
|
@ -1,3 +1,5 @@
|
||||
/* example-start tictactoe tictactoe.h */
|
||||
|
||||
/* GTK - The GIMP Toolkit
|
||||
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||
*
|
||||
@ -59,3 +61,5 @@ void tictactoe_clear (Tictactoe *ttt);
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __TICTACTOE_H__ */
|
||||
|
||||
/* example-end */
|
||||
|
@ -1,3 +1,5 @@
|
||||
/* example-start tictactoe ttt_test.c */
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include "tictactoe.h"
|
||||
|
||||
@ -39,3 +41,5 @@ main (int argc, char *argv[])
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* example-end */
|
||||
|
@ -126,7 +126,7 @@ int main (int argc, char *argv[])
|
||||
g_print ("-> item %s->%p, subtree %p\n", itemnames[i], item,
|
||||
subtree);
|
||||
|
||||
/* This is still necesary if you want these signals to be called
|
||||
/* This is still necessary if you want these signals to be called
|
||||
for the subtree's children. Note that selection_change will be
|
||||
signalled for the root tree regardless. */
|
||||
gtk_signal_connect (GTK_OBJECT(subtree), "select_child",
|
||||
|
@ -1,6 +1,4 @@
|
||||
/* This file extracted from the GTK tutorial. */
|
||||
|
||||
/* wheelbarrow.c */
|
||||
/* example-start wheelbarrow wheelbarrow.c */
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
@ -121,8 +119,7 @@ static char * WheelbarrowFull_xpm[] = {
|
||||
" "};
|
||||
|
||||
|
||||
/* when invoked (via signal delete_event), terminates the application.
|
||||
*/
|
||||
/* When invoked (via signal delete_event), terminates the application */
|
||||
void close_application( GtkWidget *widget, GdkEvent *event, gpointer data ) {
|
||||
gtk_main_quit();
|
||||
}
|
||||
@ -136,16 +133,16 @@ int main (int argc, char *argv[])
|
||||
GtkStyle *style;
|
||||
GdkGC *gc;
|
||||
|
||||
/* create the main window, and attach delete_event signal to terminate
|
||||
the application. Note that the main window will not have a titlebar
|
||||
since we're making it a popup. */
|
||||
/* Create the main window, and attach delete_event signal to terminate
|
||||
* the application. Note that the main window will not have a titlebar
|
||||
* since we're making it a popup. */
|
||||
gtk_init (&argc, &argv);
|
||||
window = gtk_window_new( GTK_WINDOW_POPUP );
|
||||
gtk_signal_connect (GTK_OBJECT (window), "delete_event",
|
||||
GTK_SIGNAL_FUNC (close_application), NULL);
|
||||
gtk_widget_realize (window);
|
||||
gtk_widget_show (window);
|
||||
|
||||
/* now for the pixmap and the pixmap widget */
|
||||
/* Now for the pixmap and the pixmap widget */
|
||||
style = gtk_widget_get_default_style();
|
||||
gc = style->black_gc;
|
||||
gdk_pixmap = gdk_pixmap_create_from_xpm_d( window->window, &mask,
|
||||
@ -169,5 +166,6 @@ int main (int argc, char *argv[])
|
||||
gtk_widget_show( window );
|
||||
gtk_main ();
|
||||
|
||||
return 0;
|
||||
return(0);
|
||||
}
|
||||
/* example-end */
|
||||
|
Loading…
Reference in New Issue
Block a user