gitkreventloop.c

Go to the documentation of this file.
00001 
00012 #define GITK_RENDERER_C
00013 #define GITKR_EVENTLOOP_C
00014                                                       
00015 #include "gitkrincludes.h"
00016 
00017 gboolean restart_poll(gpointer data) {
00018   gboolean res=FALSE;
00019   
00020   if(restart_event_loop) {
00021     gitk_log("about to exit the event-loop");
00022     gitkr_event_loop_end();
00023     res=TRUE;
00024   }
00025   return(res);
00026 }
00027 
00032 void gitkr_event_loop_start(void) {
00033   //guint idle_handler_id;
00034   
00035   gitk_log_intro();
00036   
00037   //idle_handler_id=gtk_idle_add(restart_poll,NULL);
00038   //gitk_log1("add idle handler : %ld",idle_handler_id);
00039   restart_event_loop=TRUE;
00040   //-- start the event-loop
00041   while(restart_event_loop) {
00042     restart_event_loop=FALSE;
00043     gtk_main();
00044     gitk_log("leaving event-loop");
00045     if(restart_event_loop) gitk_relayout();
00046   }
00047   //gtk_idle_remove(idle_handler_id);
00048   gitk_log_outro();
00049 }
00050 
00055 void gitkr_event_loop_end(void) {
00056   gitk_log_intro();
00057   g_assert(gtk_main_level());
00058   //-- quits the gtk-main loop
00059   //if(gtk_main_level()) {
00060     gitk_log1("stopping event loop of level=%d",gtk_main_level());
00061     gtk_main_quit();
00062   //}
00063   gitk_log_outro();
00064 }
00065 
00070 void gitkr_event_loop_restart(void) {
00071   gitk_log_intro();
00072   restart_event_loop=TRUE;
00074   gitkr_event_loop_end();
00075 }
00076 
00080 gint sighandler_window_on_close(GtkWidget *gtk_widget, GdkEvent *gdkEvent, gpointer data) {
00081   GitkEvent event;
00082 
00083   gitk_log_intro();
00084   event.type=GITK_EVENT_TYPE_ON_CLOSE;
00085   event.data=NULL;
00086   if(gitk_dialog_process_event(NULL,NULL,&event)) {
00087     gitk_log("  accepted");
00088     //gitk_event_loop_end();
00089     return(FALSE);
00090   }
00091   else {                             
00092     gitk_log("  rejected");
00093     return(TRUE);
00094   }
00095 }
00096 
00100 void sighandler_window_on_destroy(GtkWidget *gtk_widget, gpointer data) {
00101   GitkrGtkLayoutPtr layout =(GitkrGtkLayoutPtr)data;
00102   gitk_log_intro();
00103   gitk_log1("layout : %p",layout);
00104   if(layout) layout->window=NULL;
00105   if(gtk_main_level()) {
00106     gitk_log("quitting the gtk-main loop");
00107     gitk_event_loop_end();
00108   }
00109   gitk_log_outro();
00110 }
00111 
00112 gboolean sighandler_widget_on_focus_in(GtkWidget *widget,GdkEventFocus *event,gpointer data) {
00113   GitkrGtkWidgetPtr new_widget;
00114 
00115   //gitk_log_intro();
00116   new_widget=(GitkrGtkWidgetPtr)data;
00117   //gitk_log1("@@ widget id=\"%s\" received focus",new_widget->id);
00118   gitk_dialog_move_focus(NULL,(GitkWidgetPtr)new_widget);
00119   return(FALSE);
00120 }
00121 
00122 gboolean sighandler_widget_on_focus_out(GtkWidget *widget,GdkEventFocus *event,gpointer data) {
00123   GitkrGtkWidgetPtr old_widget;
00124 
00125   //gitk_log_intro();
00126   old_widget=(GitkrGtkWidgetPtr)data;
00127   //gitk_log1("@@ widget id=\"%s\" lost focus",old_widget->id);
00128   gitk_dialog_move_focus((GitkWidgetPtr)old_widget,NULL);
00129   return(FALSE);
00130 }                                                                    
00131 
00135 void sighandler_widget_on_clicked(GtkWidget *gtk_widget, gpointer data) {
00136   GitkEvent event;
00137   GitkrGtkWidgetPtr widget;
00138 
00139   g_assert(data!=NULL);
00140 
00141   gitk_log_intro();
00142   widget=(GitkrGtkWidgetPtr)data;
00143   event.type=GITK_EVENT_TYPE_ON_CLICKED;
00144   event.data=NULL;
00145   gitk_log1("   widget=0x%08lx",(unsigned long)widget);
00146   gitk_log1("   dialog=0x%08lx",(unsigned long)widget->dialog);
00147   gitk_log1("       id=\"%s\"",(widget->id?widget->id:"-"));
00148   gitk_log1("     impl=0x%08lx",(unsigned long)gtk_widget);
00149   gitk_dialog_process_event(widget->dialog,widget->id,&event);
00150   gitk_log("  accepted");
00151 }
00152 
00156 void sighandler_editable_widget_on_changed(GtkEditable *gtk_widget, gpointer data) {
00157   GitkEvent event;
00158   GitkrGtkWidgetPtr widget;
00159 
00160   g_assert(data!=NULL);
00161 
00162   gitk_log_intro();
00163   widget=(GitkrGtkWidgetPtr)data;
00164   event.type=GITK_EVENT_TYPE_ON_CHANGED;
00165 
00166   gitk_widget_set_value(widget->dialog,widget->id,"value",gtk_entry_get_text(GTK_ENTRY(gtk_widget)));
00167 
00168   gitk_log1("   widget=0x%08lx",(unsigned long)widget);
00169   gitk_log1("   dialog=0x%08lx",(unsigned long)widget->dialog);
00170   gitk_log1("       id=\"%s\"",(widget->id?widget->id:"-"));
00171   gitk_log1("     impl=0x%08lx",(unsigned long)gtk_widget);
00172   gitk_dialog_process_event(widget->dialog,widget->id,&event);
00173   gitk_log("  accepted");
00174 }
00175 
00179 void sighandler_option_widget_on_changed(GtkOptionMenu *gtk_widget, gpointer data) {
00180   GitkEvent event;
00181   GitkrGtkWidgetPtr widget;
00182   static char res[10];
00183 
00184   g_assert(data!=NULL);
00185 
00186   gitk_log_intro();
00187   widget=(GitkrGtkWidgetPtr)data;
00188   event.type=GITK_EVENT_TYPE_ON_CHANGED;
00189 
00190   sprintf(res,"%d",gtk_option_menu_get_history(GTK_OPTION_MENU(widget->impl)));
00191   gitk_widget_set_value(widget->dialog,widget->id,"value",res);
00192 
00193   gitk_log1("   widget=0x%08lx",(unsigned long)widget);
00194   gitk_log1("   dialog=0x%08lx",(unsigned long)widget->dialog);
00195   gitk_log1("       id=\"%s\"",(widget->id?widget->id:"-"));
00196   gitk_log1("     impl=0x%08lx",(unsigned long)gtk_widget);
00197   gitk_dialog_process_event(widget->dialog,widget->id,&event);
00198   gitk_log("  accepted");
00199 }

Generated on Thu Oct 28 10:59:10 2004 for gitk by doxygen 1.3.6