[no subject]



Hi all,
    can anybody tell me how, i can make this with autorefreshing....i mean instead of clicking toggle, it should toggle to window B, after a specified time.
also how i can display sytem time in my gtk application.

is there any documetation for window refresh and Gtimer widget.







/* windowA.c */

#include <stdio.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <sys/time.h>
#include <string.h>

void callback_winb(GtkWidget *,gpointer);

extern GtkWidget *windowb;
GtkWidget *windowa;
gpointer data1;

/* This is a simple call back fuction for closing the window */

void
callback1(GtkWidget *widget,
         gpointer data)
{
        g_print("Pressed key is: %s\n",(gchar *)data);
        gtk_main_quit();
}

int
callback_wina(GtkWidget *widget,
                gpointer data)
{
//      gtk_widget_hide(windowb);       this shows a warning

        GtkWidget *image;
        GtkWidget *boxa;
        GtkWidget *buttona;

        windowa=gtk_window_new(GTK_WINDOW_TOPLEVEL);
        gtk_window_set_title(GTK_WINDOW(windowa),"Window A");
        g_signal_connect(G_OBJECT(windowa),"destroy",
                         G_CALLBACK(callback1),(gpointer)"Close");
        g_print("toggling to window b\n");
        gtk_container_set_border_width(GTK_CONTAINER(windowa),20);

        boxa=gtk_hbox_new(FALSE,0);
        gtk_container_add(GTK_CONTAINER(windowa),boxa);

        image = gtk_image_new_from_file ((gchar *)data);
        gtk_box_pack_start(GTK_BOX(boxa),image,TRUE,TRUE,0);

        buttona=gtk_button_new_with_label("Toggle_A");
        g_signal_connect(G_OBJECT(buttona),"clicked",
                         G_CALLBACK(callback_winb),data1);
        gtk_box_pack_start(GTK_BOX(boxa),buttona,TRUE,TRUE,0);

        gtk_widget_show_all(windowa);
}

int
main(int argc,
        char *argv[])
{
        GTimer *startup_timer = g_timer_new();

        data1=(gpointer)argv[1];

        gtk_init(&argc,&argv);

        callback_wina(windowa,(gpointer)argv[1]);

        printf( "startup :  %gsec\n",g_timer_elapsed(startup_timer,NULL));

        gtk_main();

        printf( "Running Time : %g sec\n",g_timer_elapsed(startup_timer,NULL));

        return 0;
}      

/* windowB.c */

#include <stdio.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>

/* This is a simple call back fuction for closing the window */
void callback1(GtkWidget *,gpointer);
void callback_wina(GtkWidget *,gpointer);

extern GtkWidget *windowa;
GtkWidget *windowb;
extern gpointer data1;

void
callback_winb(GtkWidget *widget,
                 gpointer data)
{
      gtk_widget_hide(windowa);
        GtkWidget *image;
        GtkWidget *boxb;
        GtkWidget *buttonb;
        windowb=gtk_window_new(GTK_WINDOW_TOPLEVEL);
        gtk_window_set_title(GTK_WINDOW(windowb),"Window B");
        g_signal_connect(G_OBJECT(windowb),"destroy",
                         G_CALLBACK(callback1),(gpointer)"Close");
        g_print("toggling to window a\n");
        gtk_container_set_border_width(GTK_CONTAINER(windowb),20);

        boxb=gtk_hbox_new(FALSE,0);
        gtk_container_add(GTK_CONTAINER(windowb),boxb);

        image = gtk_image_new_from_file ((gchar *)data);
        gtk_box_pack_start(GTK_BOX(boxb),image,TRUE,TRUE,0);

        buttonb=gtk_button_new_with_label("Toggle_B");
        g_signal_connect(G_OBJECT(buttonb),"clicked",
                         G_CALLBACK(callback_wina),data);
        gtk_box_pack_start(GTK_BOX(boxb),buttonb,TRUE,TRUE,0);
        gtk_widget_show_all(windowb);
}
       
#make file for toggle windows
togg: windowA.c windowB.c
        gcc -g windowA.c windowB.c  -o togg `pkg-config --cflags --libs gtk+-2.0`
clean:
        rm -f togg


With regds,



Shyjumon N

TTEC

Tel: +91-80-4180-3500 Extn. 3273

Mobile: +91-9945006965



The information contained in this e-mail message and in any annexure is confidential to the  recipient and may contain privileged information. If you are not the intended recipient, please notify the sender and delete the message along with any annexure. You should not disclose, copy or otherwise use the information contained
in the message or any annexure. Any views expressed in this e-mail are those of the individual sender except where the sender specifically states them to be the views of SoCrates Software India Pvt Ltd., Bangalore.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]