gitktemplate.c

Go to the documentation of this file.
00001 
00018 #define GITK_LIB_C
00019 #define GITK_TEMPLATE_C
00020 
00021 #include "gitkincludes.h"
00022 
00023 //== global event handler ======================================================
00024 
00025 /* @brief handle global close events like pressing ctrl-c or closing the dialog window
00026  * @internal
00027  * @ingroup gitkcoretemplate
00028  *
00029 static gboolean dialog_on_close(GitkDialogPtr dialog,gchar *widget_id,GitkEventPtr event,gpointer user_data) {
00030   gitk_log("dialog_on_close()");
00031   return(TRUE);
00032 }
00033 */
00034 
00039 static gboolean dialog_on_clicked(GitkDialogPtr const dialog,gchar * const widget_id,GitkEventPtr const  event,gpointer const  user_data) {
00040   gitk_log1("dialog_on_clicked(\"%s\")",widget_id);
00041   if(!strcmp(widget_id,"Okay")) {
00042     gitk_event_loop_end();
00043     return(TRUE);
00044   }
00045   return(FALSE);
00046 }
00047 
00048 
00054 void gitk_template_message(gchar * const text) {
00055   gitk_template_message_with_title(text,NULL);
00056 }
00057 
00058 
00065 void gitk_template_message_with_title(gchar * const text,gchar * const title) {
00066   gpointer const dialog=gitk_dialog_new_from_file(GIML_PATH"gitkTemplate_message.xml");
00067   if(dialog) {
00068     //-- init vars with defaults
00069     if(title && *title) gitk_dialog_set_title(dialog,title);
00070     if(text && *text) gitk_widget_set_value(dialog,"Message","value",text);
00071     if(gitk_dialog_show(dialog,FALSE)) {
00072       gitk_log("dialog parsed and shown");
00073       // this should be handled by the application
00074       //gitk_dialog_attach_callback(NULL,NULL,GITK_EVENT_TYPE_ON_CLOSE,NULL,dialog_on_close);
00075       //-- callbacks
00076       gitk_dialog_attach_callback(dialog,"Okay",GITK_EVENT_TYPE_ON_CLICKED,NULL,dialog_on_clicked);
00077       //-- start event loop
00078       gitk_log("run");
00079       gitk_event_loop_start();
00080       gitk_log("hiding");
00081       gitk_dialog_hide(dialog);
00082     }
00083     else {
00084       //-- couldn't happen
00085     }
00086     gitk_dialog_free(dialog);
00087   }
00088   else {
00089     gitk_printf(_("error parsing dialog => %d : %s\n"),gitk_get_error_code(),gitk_get_error_str());
00090   }
00091 }
00092 

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