gitk.h

Go to the documentation of this file.
00001 
00013 #ifndef GITK_H
00014 #define GITK_H
00015 
00016 #ifdef __cplusplus
00017 extern "C" {
00018 #endif
00019 
00020 //-- includes ------------------------------------------------------------------
00021 
00022 #ifdef HAVE_X11_XLOCALE_H
00023   /* defines a more portable setlocale for X11 (_Xsetlocale) */
00024   #include <X11/Xlocale.h>
00025 #else
00026   #include <locale.h>
00027 #endif
00028 #include <dirent.h>
00029 //#include <dlfcn.h>  // that does not exist on mingw and we should not need it anymore
00030 #include <errno.h>
00031 #include <glib.h>
00032 #include <gmodule.h>
00033 #include <signal.h>
00034 #include <stdio.h>
00035 #include <stdlib.h>
00036 #include <string.h>
00037 #include <strings.h>
00038 #include <unistd.h> 
00039 #include <sys/types.h>
00040 
00041 //-- libxml2/libxslt
00042 #include <libxml/parser.h>
00043 #include <libxml/parserInternals.h>
00044 #include <libxml/xmlmemory.h>
00045 #include <libxml/xpath.h>
00046 #include <libxml/xpathInternals.h>
00047 #ifdef GITK_LIB_C
00048   #include <libxslt/xslt.h>
00049   #include <libxslt/xsltInternals.h>
00050   #include <libxslt/transform.h>
00051   #include <libxslt/xsltutils.h>
00052   #include <libxslt/extensions.h>
00053 #endif
00054 
00055 //-- i18n
00056 #ifdef ENABLE_NLS
00057   #include <langinfo.h>
00058   #include <libintl.h>
00059 
00060   #define _(String) dgettext(PACKAGE,String)
00061   #ifdef GITK_LIB_C
00062     #define __(String) dgettext(client_package_name,String)
00063   #endif
00064   #ifdef gettext_noop
00065     #define N_(String) gettext_noop(String)
00066   #else
00067     #define N_(String) (String)
00068   #endif
00069 #else /* NLS is disabled */
00070 
00071   #define _(String) (String)
00072 
00073   #define __(String) (String)
00074 
00075   #define N_(String) (String)
00076   #ifdef gettext
00077     #undef gettext
00078   #endif
00079 
00080   #define gettext(String) (String)
00081   #ifdef dgettext
00082     #undef dgettext
00083   #endif
00084 
00085   #define dgettext(Domain,String) (String)
00086 
00087   #define textdomain(Domain)
00088 
00089   #define bindtextdomain(Package, Directory)
00090 #endif
00091 
00092 //-- internal http server
00093 #ifdef USE_LIBHTTPD
00094   #include "httpd.h"
00095   #include "pthread.h"
00096 #endif
00097 
00098 
00099 //-- global defines ------------------------------------------------------------
00100 
00102 #define GITK_NS_PREFIX "giml"
00103 
00104 #define GITK_NS_URL    "http://gitk.sourceforge.net/"
00105 
00107 #define I18N_NS_PREFIX "i18n"
00108 
00109 #define I18N_NS_URL    "http://apache.org/cocoon/i18n/2.0"
00110 
00112 #define GIML_ROOT_PATH DATADIR""G_DIR_SEPARATOR_S"giml"G_DIR_SEPARATOR_S
00113 
00114 #define GIML_PATH GIML_ROOT_PATH""PACKAGE""G_DIR_SEPARATOR_S
00115 
00117 #define XSL_ROOT_PATH DATADIR""G_DIR_SEPARATOR_S"xsl"G_DIR_SEPARATOR_S
00118 
00119 #define XSL_PATH XSL_ROOT_PATH""PACKAGE""G_DIR_SEPARATOR_S
00120 
00121 //-- typedefs and structs ------------------------------------------------------
00122 
00123 //-- focus types - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00124 
00126 typedef enum GitkFocusType {
00128   GITK_FOCUS_TYPE_MAIN=0,
00130   GITK_FOCUS_TYPE_CTRL,
00131 } GitkFocusType;
00132 
00133 //-- layout - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00134 
00136 typedef struct GitkLayout GitkLayout;
00138 typedef GitkLayout *GitkLayoutPtr;
00140 struct GitkLayout {
00141 #define GitkLayoutFields \
00142   gchar *title; \
00143   GitkFocusType focus;  
00144   GitkLayoutFields
00145 };
00146                                                                                                                                                                                                                                                
00147 //-- dialog - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00148 
00152 #if defined(GITK_LIB_C) || defined(GITK_RENDERER_C)
00153 typedef struct GitkDialog GitkDialog;
00154 #else
00155 typedef void GitkDialog;
00156 #endif
00157 
00160 typedef GitkDialog *GitkDialogPtr;
00164 struct GitkDialog {
00165   xmlDocPtr src;          
00166   xmlDocPtr dst;          
00167   xmlNsPtr ns;            
00168   GitkLayoutPtr layout;   
00169   GList *callback_list;   
00170   gint priority;          
00171   gboolean changed;       
00172   GMutex *lock;           
00173 };
00174 
00175 //-- dialog access  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00176 
00180 typedef enum GitkDialogAccessType {
00182   GITK_DIALOG_ACCESS_RENDERER=0,
00184   GITK_DIALOG_ACCESS_CLIENT
00185 } GitkDialogAccessType;
00186 
00187 //-- widgets  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00188 
00190 #define GITK_CONTROL_ID_MAXLEN 50
00191 
00192 //-- event types - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00193 
00198 typedef enum GitkEventType {
00199   //-- global events
00201   GITK_EVENT_TYPE_ON_CLOSE=0,
00203   GITK_EVENT_TYPE_ON_DIALOG_SHOW,
00205   GITK_EVENT_TYPE_ON_DIALOG_HIDE,
00206   /* @brief global event, dialog structure has changed, example ?
00207   GITK_EVENT_TYPE_ON_DIALOG_CHANGED,
00208   */
00209   //-- widget events
00211   GITK_EVENT_TYPE_ON_CLICKED,
00213   GITK_EVENT_TYPE_ON_CHANGED
00214   /* @brief
00215   GITK_EVENT_TYPE_ON_ENABLED
00216   */
00217 } GitkEventType;
00218 
00219 //-- event structure - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00220 
00222 typedef struct GitkEvent GitkEvent;
00224 typedef GitkEvent *GitkEventPtr;
00226 struct GitkEvent {
00227   GitkEventType type; 
00228   gpointer data; 
00229 };
00230 
00231 //-- event callback  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00232 
00241 typedef gboolean (*GitkCallbackPtr)(GitkDialogPtr dialog,gchar *widget_id,GitkEventPtr event,gpointer user_data);
00242 
00243 //-- event callback node - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00244 
00248 typedef struct GitkCallbackNode GitkCallbackNode;
00252 typedef GitkCallbackNode *GitkCallbackNodePtr;
00256 struct GitkCallbackNode {
00257   gchar *widget_id; 
00258   GitkEventType type; 
00259   gpointer user_data; 
00260   GitkCallbackPtr callback; 
00261   gchar *callback_name; 
00262 };
00263 
00264 //-- widget types --------------------------------------------------------------
00265 
00267 typedef enum GitkWidgetType {
00269   GITK_WIDGET_TYPE_UNDEF=0, 
00270 
00272   GITK_WIDGET_TYPE_ACTION, 
00273 
00275   GITK_WIDGET_TYPE_CHARACTERINPUT,
00277   GITK_WIDGET_TYPE_CHARACTERINPUT_NUMERIC,
00279   GITK_WIDGET_TYPE_CHARACTERINPUT_ALPHABETIC,
00280 
00282   GITK_WIDGET_TYPE_OPTIONCHOICE,
00284   GITK_WIDGET_TYPE_OPTIONCHOICE_BOOLEAN,
00286   GITK_WIDGET_TYPE_OPTIONCHOICE_SINGLE,
00288   GITK_WIDGET_TYPE_OPTIONCHOICE_SINGLE_COMPACT,
00289 
00291   GITK_WIDGET_TYPE_LABEL
00292 } GitkWidgetType;
00293 
00294 //-- general widget structure --------------------------------------------------
00295 
00297 typedef struct GitkWidget GitkWidget;
00299 typedef GitkWidget *GitkWidgetPtr;
00301 struct GitkWidget {
00302 #define GitkWidgetFields \
00303   gchar *id; \
00304   GitkDialogPtr dialog; \
00305   GitkWidgetType type; 
00306   GitkWidgetFields
00307 };
00308 
00309 //-- local includes ------------------------------------------------------------
00310 
00311 //-- libgitk-renderer
00312 #include <libgitk/gitkrenderer.h>
00313 
00314 //-- libgitk
00315 #include <libgitk/gitkcallback.h>
00316 #include <libgitk/gitkcontext.h>
00317 #include <libgitk/gitkdialog.h>
00318 #include <libgitk/gitkdone.h>
00319 #include <libgitk/gitkerrors.h>
00320 #include <libgitk/gitkglobal.h>
00321 #include <libgitk/gitkinit.h>
00322 #include <libgitk/gitklayout.h>
00323 #include <libgitk/gitkprofile.h>
00324 #include <libgitk/gitkserver.h>
00325 #include <libgitk/gitktemplate.h>
00326 #include <libgitk/gitktools.h>
00327 #include <libgitk/gitktrans.h>
00328 #include <libgitk/gitktrans-domain.h>
00329 #include <libgitk/gitktrans-expand.h>
00330 #include <libgitk/gitktrans-i18n.h>
00331 #include <libgitk/gitktrans-style.h>
00332 #include <libgitk/gitkwidget.h>
00333 #include <libgitk/gitkwrapper.h>
00334 #include <libgitk/gitkversion.h>
00335 
00336 //-- defines -------------------------------------------------------------------
00337 
00338 //-- ansi color macros
00339 #ifdef USE_ANSI_COLOR
00340   // normal
00341   #define ANSI_COLOR_BLACK       "\e[00;30m"
00342   #define ANSI_COLOR_RED         "\e[00;31m"
00343   #define ANSI_COLOR_GREEN       "\e[00;32m"
00344   #define ANSI_COLOR_BROWN       "\e[00;33m"
00345   #define ANSI_COLOR_BLUE        "\e[00;34m"
00346   #define ANSI_COLOR_PURPLE      "\e[00;35m"
00347   #define ANSI_COLOR_CYAN        "\e[00;36m"
00348   #define ANSI_COLOR_LIGHTGRAY   "\e[00;37m"
00349   // bold
00350   #define ANSI_COLOR_DARKGRAY    "\e[01;30m"
00351   #define ANSI_COLOR_LIGHTRED    "\e[01;31m"
00352   #define ANSI_COLOR_LIGHTGREEN  "\e[01;32m"
00353   #define ANSI_COLOR_YELLOW      "\e[01;33m"
00354   #define ANSI_COLOR_LIGHTBLUE   "\e[01;34m"
00355   #define ANSI_COLOR_LIGHTPURPLE "\e[01;35m"
00356   #define ANSI_COLOR_LIGHTCYAN   "\e[01;36m"
00357   #define ANSI_COLOR_WHITE       "\e[01;37m"
00358   // underlined
00359   //#define ANSI_COLOR_WHITE     "\e[04;37m"
00360 #else
00361 
00364   #define ANSI_COLOR_BLACK
00365 
00368   #define ANSI_COLOR_RED
00369 
00372   #define ANSI_COLOR_GREEN
00373 
00376   #define ANSI_COLOR_BROWN
00377 
00380   #define ANSI_COLOR_BLUE
00381 
00384   #define ANSI_COLOR_PURPLE
00385 
00388   #define ANSI_COLOR_CYAN
00389 
00392   #define ANSI_COLOR_LIGHTGRAY
00393 
00396   #define ANSI_COLOR_DARKGRAY
00397 
00400   #define ANSI_COLOR_LIGHTRED
00401 
00404   #define ANSI_COLOR_LIGHTGREEN
00405 
00408   #define ANSI_COLOR_YELLOW
00409 
00412   #define ANSI_COLOR_LIGHTBLUE
00413 
00416   #define ANSI_COLOR_LIGHTPURPLE
00417 
00420   #define ANSI_COLOR_LIGHTCYAN
00421 
00424   #define ANSI_COLOR_WHITE
00425 #endif
00426 
00427 //-- diagnostic output macros
00428 #ifdef APP_DEBUG
00429   #define gitk_dump(str) g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO,str)
00430   #define gitk_dump1(fmt,par1) g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO,fmt,par1)
00431   #define gitk_dump2(fmt,par1,par2) g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO,fmt,par1,par2)
00432   #define gitk_log(str) g_log(G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, ANSI_COLOR_LIGHTGRAY"["PACKAGE_NAME":%s:%d]"ANSI_COLOR_WHITE" : %s\n",__FILE__,__LINE__,str)
00433   #define gitk_log1(fmt,par1) g_log(G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, ANSI_COLOR_LIGHTGRAY"["PACKAGE_NAME":%s:%d]"ANSI_COLOR_WHITE" : "fmt"\n",__FILE__,__LINE__,par1)
00434   #define gitk_log2(fmt,par1,par2) g_log(G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, ANSI_COLOR_LIGHTGRAY"["PACKAGE_NAME":%s:%d]"ANSI_COLOR_WHITE" : "fmt"\n",__FILE__,__LINE__,par1,par2)
00435   #define gitk_log3(fmt,par1,par2,par3) g_log(G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, ANSI_COLOR_LIGHTGRAY"["PACKAGE_NAME":%s:%d]"ANSI_COLOR_WHITE" : "fmt"\n",__FILE__,__LINE__,par1,par2,par3)
00436   #define gitk_log4(fmt,par1,par2,par3,par4) g_log(G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, ANSI_COLOR_LIGHTGRAY"["PACKAGE_NAME":%s:%d]"ANSI_COLOR_WHITE" : "fmt"\n",__FILE__,__LINE__,par1,par2,par3,par4)
00437   #define gitk_err(str) g_log(G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, ANSI_COLOR_LIGHTGRAY"["PACKAGE_NAME":%s:%d]"ANSI_COLOR_LIGHTRED" : %s"ANSI_COLOR_WHITE"\n",__FILE__,__LINE__,str)
00438   #define gitk_err1(fmt,par1) g_log(G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, ANSI_COLOR_LIGHTGRAY"["PACKAGE_NAME":%s:%d]"ANSI_COLOR_LIGHTRED" : "fmt""ANSI_COLOR_WHITE"\n",__FILE__,__LINE__,par1)
00439   #define gitk_err2(fmt,par1,par2) g_log(G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, ANSI_COLOR_LIGHTGRAY"["PACKAGE_NAME":%s:%d]"ANSI_COLOR_LIGHTRED" : "fmt""ANSI_COLOR_WHITE"\n",__FILE__,__LINE__,par1,par2)
00440   #define gitk_err3(fmt,par1,par2,par3) g_log(G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, ANSI_COLOR_LIGHTGRAY"["PACKAGE_NAME":%s:%d]"ANSI_COLOR_LIGHTRED" : "fmt""ANSI_COLOR_WHITE"\n",__FILE__,__LINE__,par1,par2,par3)
00441   #define gitk_err4(fmt,par1,par2,par3,par4) g_log(G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, ANSI_COLOR_LIGHTGRAY"["PACKAGE_NAME":%s:%d]"ANSI_COLOR_LIGHTRED" : "fmt""ANSI_COLOR_WHITE"\n",__FILE__,__LINE__,par1,par2,par3,par4)
00442 
00443   #define gitk_log_intro() g_log(G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, ANSI_COLOR_LIGHTGRAY"["PACKAGE_NAME":%s:%d]"ANSI_COLOR_WHITE" : %s() beg\n",__FILE__,__LINE__,__FUNCTION__)
00444   #define gitk_log_outro() g_log(G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, ANSI_COLOR_LIGHTGRAY"["PACKAGE_NAME":%s:%d]"ANSI_COLOR_WHITE" : %s() end\n",__FILE__,__LINE__,__FUNCTION__)
00445 #else 
00446 
00449   #define gitk_dump(str)
00450 
00453   #define gitk_dump1(fmt,par1)
00454 
00457   #define gitk_dump2(fmt,par1,par2)
00458 
00461   #define gitk_log(str) 
00462 
00465   #define gitk_log1(fmt,par1) 
00466 
00469   #define gitk_log2(fmt,par1,par2) 
00470 
00473   #define gitk_log3(fmt,par1,par2,par3) 
00474 
00477   #define gitk_log4(fmt,par1,par2,par3,par4) 
00478 
00481   #define gitk_err(str) 
00482 
00485   #define gitk_err1(fmt,par1) 
00486 
00489   #define gitk_err2(fmt,par1,par2) 
00490 
00493   #define gitk_err3(fmt,par1,par2,par3) 
00494 
00497   #define gitk_err4(fmt,par1,par2,par3,par4)
00498 
00501   #define gitk_log_intro()
00502 
00505   #define gitk_log_outro()
00506 #endif
00507 
00509 #define gitk_save_get_string(str) (((void *)str)?(const char *)str:"[NULL]")
00510 
00511 //-- ansi color macros
00512 #ifdef USE_ANSI_COLOR
00513   #define print_ansi(code)       gitk_dump(code)
00514 #else
00515 
00518   #define print_ansi(code)
00519 #endif
00520 
00521 #ifdef __cplusplus
00522 } // extern "C"
00523 #endif
00524 
00525 #endif /* GITK_H */

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