Stratis
September 25th, 2008, 01:24 AM
Hi! : )
I have a small Gtk/Glade (created) program that I'm having a problem with.
(callbacks.c)
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <gtk/gtk.h>
#include <stdio.h>
#include <assert.h>
#include <string.h>
#include <unistd.h>
#include "callbacks.h"
#include "interface.h"
#include "support.h"
void
on_spinbutton1_value_changed (GtkSpinButton *spinbutton,
gpointer user_data)
{
}
void
on_spinbutton2_value_changed (GtkSpinButton *spinbutton,
gpointer user_data)
{
}
void
on_spinbutton3_value_changed (GtkSpinButton *spinbutton,
gpointer user_data)
{
}
void
on_button1_released (GtkButton *button,
gpointer user_data)
{
int hr = 0, mn = 0, sc = 0, thr = 0, tmn = 0, tsc = 0;
GtkWidget * ent1 = lookup_widget(GTK_WIDGET(button), "entry1");
GtkWidget * spin1 = lookup_widget(GTK_WIDGET(button), "spinbutton1");
GtkWidget * spin2 = lookup_widget(GTK_WIDGET(button), "spinbutton2");
GtkWidget * spin3 = lookup_widget(GTK_WIDGET(button), "spinbutton3");
hr = gtk_spin_button_get_value_as_int(spin1);
mn = gtk_spin_button_get_value_as_int(spin2);
sc = gtk_spin_button_get_value_as_int(spin3);
thr = hr;
tmn = mn;
tsc = sc;
while (thr > 0 ) {
char str[100];
while (tmn > 0) {
while (tsc > 0) {
tsc--;
sprintf(str, "%dhr, %dmin, %dsec\n", thr, tmn, tsc);
//fprintf(stdout, "%s", str);
sleep(1);
gtk_entry_set_text(ent1, str);
}
tmn--;
sprintf(str, "%dhr, %dmin, %dsec\n", thr, tmn, tsc);
//fprintf(stdout, "%s", str);
sleep(60);
gtk_entry_set_text(ent1, str);
}
thr--;
sprintf(str, "%dhr, %dmin, %dsec\n", thr, tmn, tsc);
//fprintf(stdout, "%s", str);
sleep(3600);
gtk_entry_set_text(ent1, str);
}
}
void
on_entry1_insert_text (GtkEditable *editable,
gchar *new_text,
gint new_text_length,
gpointer position,
gpointer user_data)
{
}
I want the entry box to constantly update the countdown, but it won't do that (I'm new to all this).
It won't update the entry box until all the code in 'on_button1_released()' is done.
Any ideas? : )
Stratis
I have a small Gtk/Glade (created) program that I'm having a problem with.
(callbacks.c)
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <gtk/gtk.h>
#include <stdio.h>
#include <assert.h>
#include <string.h>
#include <unistd.h>
#include "callbacks.h"
#include "interface.h"
#include "support.h"
void
on_spinbutton1_value_changed (GtkSpinButton *spinbutton,
gpointer user_data)
{
}
void
on_spinbutton2_value_changed (GtkSpinButton *spinbutton,
gpointer user_data)
{
}
void
on_spinbutton3_value_changed (GtkSpinButton *spinbutton,
gpointer user_data)
{
}
void
on_button1_released (GtkButton *button,
gpointer user_data)
{
int hr = 0, mn = 0, sc = 0, thr = 0, tmn = 0, tsc = 0;
GtkWidget * ent1 = lookup_widget(GTK_WIDGET(button), "entry1");
GtkWidget * spin1 = lookup_widget(GTK_WIDGET(button), "spinbutton1");
GtkWidget * spin2 = lookup_widget(GTK_WIDGET(button), "spinbutton2");
GtkWidget * spin3 = lookup_widget(GTK_WIDGET(button), "spinbutton3");
hr = gtk_spin_button_get_value_as_int(spin1);
mn = gtk_spin_button_get_value_as_int(spin2);
sc = gtk_spin_button_get_value_as_int(spin3);
thr = hr;
tmn = mn;
tsc = sc;
while (thr > 0 ) {
char str[100];
while (tmn > 0) {
while (tsc > 0) {
tsc--;
sprintf(str, "%dhr, %dmin, %dsec\n", thr, tmn, tsc);
//fprintf(stdout, "%s", str);
sleep(1);
gtk_entry_set_text(ent1, str);
}
tmn--;
sprintf(str, "%dhr, %dmin, %dsec\n", thr, tmn, tsc);
//fprintf(stdout, "%s", str);
sleep(60);
gtk_entry_set_text(ent1, str);
}
thr--;
sprintf(str, "%dhr, %dmin, %dsec\n", thr, tmn, tsc);
//fprintf(stdout, "%s", str);
sleep(3600);
gtk_entry_set_text(ent1, str);
}
}
void
on_entry1_insert_text (GtkEditable *editable,
gchar *new_text,
gint new_text_length,
gpointer position,
gpointer user_data)
{
}
I want the entry box to constantly update the countdown, but it won't do that (I'm new to all this).
It won't update the entry box until all the code in 'on_button1_released()' is done.
Any ideas? : )
Stratis