A
download gitkrrenderer.c
Language: C
LOC: 107
Project Info
GITK - Generalized Interface Toolkit(gitk)
Server: SourceForge
Type: cvs
...k\gitk\gitk‑renderer‑phone\
   autogen.sh
   config.h.in
   configure.in
   gitkr-phoneConf.sh.in
   gitkrdefines.h
   gitkrdone.c
   gitkrdone.h
   gitkreventloop.c
   gitkreventloop.h
   gitkrglobal.c
   gitkrglobal.h
   gitkrhideshow.c
   gitkrhideshow.h
   gitkrincludes.h
   gitkrinfo.c
   gitkrinfo.h
   gitkrinit.c
   gitkrinit.h
   gitkrlayout.c
   gitkrlayout.h
   gitkrrenderer.c
   gitkrrenderer.h
   gitkrtools.c
   gitkrtools.h
   Makefile.am

/** $Id: gitkrrenderer.c,v 1.7 2004/11/02 09:26:36 ensonic Exp $
 *
 * @file   gitk-renderer-phone/gitkrrenderer.c
 * @author Steffen ast <sast@users.sf.net>
 * @date   Sun Feb 15 00:29:59 2004
 * 
 * @brief  gitk renderer rendering routines
 * @ingroup gitkrendererphone
 * 
 */

#define GITK_RENDERER_C
#define GITKR_RENDERER_C

#include "gitkrincludes.h"

/** @brief renders the display depending on currently active context(s) and node
 * @internal
 */
void gitkr_render(void) {
  gitk_log_intro();
  
  while(!capi_incoming_connected) {

#ifdef HAVE_CAPI20
    capi_wait_for_incoming_calls(capiinfo);
#endif //HAVE_CAPI20
    
    capi_incoming_connected = (TRUE);
    gitk_log("incoming call detected");
    
    //-- render initial screen
    capi_text_output(capiinfo,welcome,ftinfo);
    
    //-- play help if the user wish it
    gitkr_welcome_help();
  }
  
  if(gitk_dialog_list) {
		GitkDialogPtr cur_context/*=gitk_context_get_current()*/;
		//-- let the user choose one context or just return one if there is only one
		/** @todo reset cur_context, when closing dialogs */
		//if(!cur_context) {
		cur_context=gitkr_set_context(); /* select a context */
		//}
		//-- now process that context
		if(cur_context) {
			gitk_dialog_lock(cur_context);
			//-- is context not yet layouted, or modified ?
			if(cur_context->changed) {
				//-- yes: layout context
				gitkr_dialog_generate_layout(cur_context);
				cur_context->changed=FALSE;
			}
     	//-- display layout
      gitk_log("try to display layout");
			gitkr_dialog_output_layout(cur_context);
			gitk_dialog_unlock(cur_context);
		}else gitk_log("!!!!!!!!!!!!!!!!kein cur_content");
  }else gitk_log("!!!!!!!!!!!!!!!!kein gitk_dialog_list");
  gitk_log_outro();
}

/** @brief count active contexts; immeditely select context, if there is only
 * one active, or let the user choose one
 */
GitkDialogPtr gitkr_set_context(void) {
  GitkDialogPtr cur_context=NULL;
  //gitk_log_intro();
  if((cur_context=gitk_context_activate())==NULL) {
		cur_context=gitkr_select_context();
  }
  return(cur_context);
}

/** @brief display context selection and let the user select a context
 * @return new active context
 */
GitkDialogPtr gitkr_select_context(void) {
  GList* node;
  GitkDialogPtr dialog;
  gint i;
  gchar *context_name;
  static gchar *dialog_desc_pre=\
	"<?xml version=\"1.0\" ?>"\
	"<!DOCTYPE giml SYSTEM \"http://gitk.sourceforge.net/giml.dtd\">"\
  "<giml xmlns=\""GITK_NS_URL"\""\
  "	xmlns:dc=\"http://purl.org/dc/elements/1.1/\""\
  "	xmlns:i18n=\""I18N_NS_URL"\""\
	"	>"\
	"  <dialog>"\
	"    <meta>"\
	"      <dc:title><i18n:text>context menu</i18n:text></dc:title"\
	"    </meta>"\
	"    <widgetgroup>";
	/** @todo use &lt;widget type="optionchoice_single_expanded"&gt; when ready (see gitk-examples/gitkLauncher.c) */
  static gchar *widget_desc_fmt=\
	"      <widget id=\"Menu%03d\" type=\"action_action\">"\
	"        <label>%s</label>"\
	"      </widget>";
  static gchar *dialog_desc_post=\
	"    </widgetgroup>"\
	"  </dialog>"\
	"</giml>";
  gchar *widget_desc=NULL;
  gchar *dialog_desc=NULL;

  g_assert(gitk_dialog_list!=NULL);

  gitk_log("gitkr_select_context() beg");
  node=g_list_first(gitk_dialog_list);
  //-- iterate of contexts and build a menu which the dialog module of the renderer can display
  i=0;
  dialog_desc=strdup(dialog_desc_pre);
  while(node) {
		dialog=(GitkDialogPtr)node->data;
		//gitk_log1("processing node : 0x%08lx",node);
		//gitk_log1("dialog=0x%08lx",dialog);
		context_name=gitkr_cxpath_get_string(dialog,xpath_get_dialog_name,NULL);
		//-- length is : fmtlen+namelen+numberlen - fmtcharslen
		widget_desc=g_new(gchar,strlen(widget_desc_fmt)+strlen(context_name)+3-6);
		sprintf(widget_desc,widget_desc_fmt,i,context_name);
		//-- allocate new space, copy old data and append new
		dialog_desc=strapp(dialog_desc,widget_desc);
		g_free(widget_desc);
		free(context_name);
		node=g_list_next(node);
		i++;
  }
  dialog_desc=strapp(dialog_desc,dialog_desc_post);

  //-- hide and free old context selecting context
  if(context_selection_dialog) {
		gitk_dialog_hide(context_selection_dialog);
		gitk_dialog_free(context_selection_dialog);
		context_selection_dialog=NULL;
  }
  //-- init and show the new context selecting dialog
  if((context_selection_dialog=gitk_dialog_new_from_string(dialog_desc))) {
		gitk_dialog_show(context_selection_dialog,TRUE);
		gitk_context_set_current(context_selection_dialog);
  }

  g_free(dialog_desc);
  return(context_selection_dialog);
}

/** @brief append a string to another
 * @internal
 * @param src1 pointer to first string
 * @param src2 pointer to second string
 * @return newly allocated memory containing both strings
 */
gchar *strapp(gchar *src1,gchar *src2) {
  gchar *ret;

  g_assert(src2!=NULL);

  if(src1==NULL) ret=strdup(src2);
  else {
		ret=g_new(gchar,strlen(src1)+strlen(src2)-1);
		strcpy(ret,src1);
		strcat(ret,src2);
		g_free(src1);
  }
  return(ret);
}

About Koders | Resources | Downloads | Support | Black Duck | Terms of Service | DMCA | Privacy Policy | Contact Us