gitkrrenderer.c

Go to the documentation of this file.
00001 
00012 #define GITK_RENDERER_C
00013 #define GITKR_RENDERER_C
00014 
00015 #include "gitkrincludes.h"
00016 
00020 void gitkr_render(void) {
00021   gitk_log_intro();
00022   
00023   while(!capi_incoming_connected) {
00024 
00025 #ifdef HAVE_CAPI20
00026     capi_wait_for_incoming_calls(capiinfo);
00027 #endif //HAVE_CAPI20
00028     
00029     capi_incoming_connected = (TRUE);
00030     gitk_log("incoming call detected");
00031     
00032     //-- render initial screen
00033     capi_text_output(capiinfo,welcome,ftinfo);
00034     
00035     //-- play help if the user wish it
00036     gitkr_welcome_help();
00037   }
00038   
00039   if(gitk_dialog_list) {
00040     GitkDialogPtr cur_context/*=gitk_context_get_current()*/;
00041     //-- let the user choose one context or just return one if there is only one
00043     //if(!cur_context) {
00044     cur_context=gitkr_set_context(); /* select a context */
00045     //}
00046     //-- now process that context
00047     if(cur_context) {
00048       //-- is context not yet layouted, or modified ?
00049       if(cur_context->changed) {
00050         //-- yes: layout context
00051         gitkr_dialog_generate_layout(cur_context);
00052         cur_context->changed=FALSE;
00053       }
00054       //-- display layout
00055           gitk_log("try to display layout");
00056       gitkr_dialog_output_layout(cur_context);
00057     }else gitk_log("!!!!!!!!!!!!!!!!kein cur_content");
00058   }else gitk_log("!!!!!!!!!!!!!!!!kein gitk_dialog_list");
00059   gitk_log_outro();
00060 }
00061 
00065 GitkDialogPtr gitkr_set_context(void) {
00066   GitkDialogPtr cur_context=NULL;
00067   //gitk_log_intro();
00068   if((cur_context=gitk_context_activate())==NULL) {
00069     cur_context=gitkr_select_context();
00070   }
00071   return(cur_context);
00072 }
00073 
00077 GitkDialogPtr gitkr_select_context(void) {
00078   GList* node;
00079   GitkDialogPtr dialog;
00080   gint i;
00081   gchar *context_name;
00082   static gchar *dialog_desc_pre=\
00083   "<?xml version=\"1.0\" ?>"\
00084   "<!DOCTYPE giml SYSTEM \"http://gitk.sourceforge.net/giml.dtd\">"\
00085   "<giml xmlns=\""GITK_NS_URL"\""\
00086   " xmlns:dc=\"http://purl.org/dc/elements/1.1/\""\
00087   " xmlns:i18n=\""I18N_NS_URL"\""\
00088   " >"\
00089   "  <dialog>"\
00090   "    <meta>"\
00091   "      <dc:title><i18n:text>context menu</i18n:text></dc:title"\
00092   "    </meta>"\
00093   "    <widgetgroup>";
00095   static gchar *widget_desc_fmt=\
00096   "      <widget id=\"Menu%03d\" type=\"action_action\">"\
00097   "        <label>%s</label>"\
00098   "      </widget>";
00099   static gchar *dialog_desc_post=\
00100   "    </widgetgroup>"\
00101   "  </dialog>"\
00102   "</giml>";
00103   gchar *widget_desc=NULL;
00104   gchar *dialog_desc=NULL;
00105 
00106   g_assert(gitk_dialog_list!=NULL);
00107 
00108   gitk_log("gitkr_select_context() beg");
00109   node=g_list_first(gitk_dialog_list);
00110   //-- iterate of contexts and build a menu which the dialog module of the renderer can display
00111   i=0;
00112   dialog_desc=strdup(dialog_desc_pre);
00113   while(node) {
00114     dialog=(GitkDialogPtr)node->data;
00115     //gitk_log1("processing node : 0x%08lx",node);
00116     //gitk_log1("dialog=0x%08lx",dialog);
00117     context_name=gitkr_cxpath_get_string(dialog,xpath_get_dialog_name,NULL);
00118     //-- length is : fmtlen+namelen+numberlen - fmtcharslen
00119     widget_desc=g_new(gchar,strlen(widget_desc_fmt)+strlen(context_name)+3-6);
00120     sprintf(widget_desc,widget_desc_fmt,i,context_name);
00121     //-- allocate new space, copy old data and append new
00122     dialog_desc=strapp(dialog_desc,widget_desc);
00123     g_free(widget_desc);
00124     free(context_name);
00125     node=g_list_next(node);
00126     i++;
00127   }
00128   dialog_desc=strapp(dialog_desc,dialog_desc_post);
00129 
00130   //-- hide and free old context selecting context
00131   if(context_selection_dialog) {
00132     gitk_dialog_hide(context_selection_dialog);
00133     gitk_dialog_free(context_selection_dialog);
00134     context_selection_dialog=NULL;
00135   }
00136   //-- init and show the new context selecting dialog
00137   if((context_selection_dialog=gitk_dialog_new_from_string(dialog_desc))) {
00138     gitk_dialog_show(context_selection_dialog,TRUE);
00139     gitk_context_set_current(context_selection_dialog);
00140   }
00141 
00142   g_free(dialog_desc);
00143   return(context_selection_dialog);
00144 }
00145 
00152 gchar *strapp(gchar *src1,gchar *src2) {
00153   gchar *ret;
00154 
00155   g_assert(src2!=NULL);
00156 
00157   if(src1==NULL) ret=strdup(src2);
00158   else {
00159     ret=g_new(gchar,strlen(src1)+strlen(src2)-1);
00160     strcpy(ret,src1);
00161     strcat(ret,src2);
00162     g_free(src1);
00163   }
00164   return(ret);
00165 }

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