gtk2/examples/progressbar/progressbar.c
Owen Taylor 2cabeeb1c3 Removed g_object_pointer_hash, which was just g_direct_hash.
Tue Jun  9 18:44:57 1998  Owen Taylor  <otaylor@gtk.org>

	* gtk/gtkobject.c: Removed g_object_pointer_hash, which
	was just g_direct_hash.

Mon May 25 19:54:20 1998  Owen Taylor  <otaylor@gtk.org>

	* configure.in: x_libs=, not $x_libs=. Enough said.
          (Case only hit for --disable-xshm)

Mon May 25 12:08:14 1998  Owen Taylor  <otaylor@gtk.org>

	* configure.in (LDFLAGS): Add to $CFLAGS and $LDFLAGS
	  when testing for X libraries, don't replace them. Because
	  the user might have specified the path to the X libraries
	  themself before running configure.

	* examples/**.c: Changed all gpointer * to gpointer

Sat May 23 21:54:05 1998  Owen Taylor  <otaylor@gtk.org>

	* configure.in (LDFLAGS): Bomb out with a moderately
	  helpful message if detection of X libraries fails.

Sat May 23 18:57:06 1998  Owen Taylor  <otaylor@gtk.org>

  [ Combination of:
     gtk-rrh-980412-0.patch (Raja R Harinath <harinath@cs.umn.edu>)
     gtk-jbuhler-980516-0 (Jeremy Buhler <jbuhler@cs.washington.edu>) ]

	* gdk/gdk.h gdk/gdkcc.c gdk/gdkfont.c gtk/gtkmain.c
	  gtk/gtksignal.c gtk/gtktext.c:

	  Fixups for warnings from adding const to type of GHashFunc,
	  GCompareFunc

	* gtk/gtkcombo.c (gtk_combo_entry_key_press): Minor style/
	  ansi-warnings fixups.

Tue Jun  9 17:47:33 1998  Owen Taylor  <otaylor@gtk.org>

	* glib.h: Remove #error - HP/UX.

Sat May 23 19:00:01 1998  Owen Taylor  <otaylor@gtk.org>
  [ Combination of:
     gtk-rrh-980412-0.patch (Raja R Harinath <harinath@cs.umn.edu>)
     gtk-jbuhler-980516-0 (Jeremy Buhler <jbuhler@cs.washington.edu>) ]

	* glib.h ghash.c gstring.c gdataset.c gutils.c:
	- Added new typedef g_const_pointer; expunged all incorrect
	  uses of 'const gpointer'.
	- Fixed up warnings that that created,
	- Changed GHashFunc and GCompareFunc to take g_const_pointer
	  arguments. (Necessary, but will cause warnings in existing
	  code until fixed)
	- Added other new const in harmless positions.
1998-06-09 23:18:11 +00:00

94 lines
2.4 KiB
C

/* This file extracted from the GTK tutorial. */
/* progressbar.c */
#include <gtk/gtk.h>
static int ptimer = 0;
int pstat = TRUE;
/* This function increments and updates the progress bar, it also resets
the progress bar if pstat is FALSE */
gint progress (gpointer data)
{
gfloat pvalue;
/* get the current value of the progress bar */
pvalue = GTK_PROGRESS_BAR (data)->percentage;
if ((pvalue >= 1.0) || (pstat == FALSE)) {
pvalue = 0.0;
pstat = TRUE;
}
pvalue += 0.01;
gtk_progress_bar_update (GTK_PROGRESS_BAR (data), pvalue);
return TRUE;
}
/* This function signals a reset of the progress bar */
void progress_r (void)
{
pstat = FALSE;
}
void destroy (GtkWidget *widget, GdkEvent *event, gpointer data)
{
gtk_main_quit ();
}
int main (int argc, char *argv[])
{
GtkWidget *window;
GtkWidget *button;
GtkWidget *label;
GtkWidget *table;
GtkWidget *pbar;
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_signal_connect (GTK_OBJECT (window), "delete_event",
GTK_SIGNAL_FUNC (destroy), NULL);
gtk_container_border_width (GTK_CONTAINER (window), 10);
table = gtk_table_new(3,2,TRUE);
gtk_container_add (GTK_CONTAINER (window), table);
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 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);
/* Set the timeout to handle automatic updating of the progress bar */
ptimer = gtk_timeout_add (100, progress, pbar);
/* 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);
button = gtk_button_new_with_label ("Cancel");
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (destroy), NULL);
gtk_table_attach_defaults(GTK_TABLE(table), button, 1,2,2,3);
gtk_widget_show (button);
gtk_widget_show(table);
gtk_widget_show(window);
gtk_main ();
return 0;
}