00001 00018 #define GITK_LIB_C 00019 #define GITK_CONTEXT_C 00020 00021 #include "gitkincludes.h" 00022 00028 gint gitk_context_count_active(void) { 00029 if(gitk_dialog_list) { 00030 GList* node=g_list_first(gitk_dialog_list); 00031 GitkDialogPtr dialog; 00032 gint number_of_contexts=0; 00033 /* 00034 xmlXPathCompExprPtr comp; 00035 xmlXPathContextPtr ctxt; 00036 gchar *is_modal; 00037 */ 00038 00039 gitk_log("gitk_context_count_active beg"); 00040 while(node) { 00041 dialog=(GitkDialogPtr)node->data; 00042 /* 00043 if(is_modal=gitk_cxpath_get_string(dialog,xpath_get_dialog_modality)) { 00044 if(!stricmp(is_modal,"true")) { 00045 cur_context=dialog; 00046 free(is_modal); 00047 return(1); 00048 } 00049 free(is_modal); 00050 } 00051 */ 00052 number_of_contexts++; 00053 node=g_list_next(node); 00054 } 00055 if(number_of_contexts==1) { 00056 cur_context=dialog; 00057 return(1); 00058 } 00059 return(number_of_contexts); 00060 } 00061 return(0); 00062 } 00063 00068 GitkDialogPtr gitk_context_activate(void) { 00069 if(gitk_dialog_list) { 00070 GList* node=g_list_first(gitk_dialog_list); 00071 GitkDialogPtr dialog=NULL; 00072 gint number_of_contexts=0; 00073 gint priority=0; 00074 00075 gitk_log("gitk_context_activate() beg"); 00076 00077 while(node) { 00078 dialog=(GitkDialogPtr)node->data; 00079 if(dialog->priority>priority) { 00080 priority=dialog->priority; 00081 number_of_contexts=1; 00082 } 00083 else number_of_contexts++; 00084 node=g_list_next(node); 00085 } 00086 if(number_of_contexts==1) { 00087 cur_context=dialog; 00088 return(cur_context); 00089 } 00090 else { gitk_log1("zero or multiple active dialogs found : %d",number_of_contexts); } 00091 } 00092 gitk_log("no active dialogs found"); 00093 return(NULL); 00094 } 00095 00100 gint gitk_context_get_highest_used_priority(void) { 00101 if(gitk_dialog_list) { 00102 GList* node=g_list_first(gitk_dialog_list); 00103 GitkDialogPtr dialog; 00104 gint priority=0; 00105 00106 gitk_log("gitk_context_get_highest_used_priority beg"); 00107 while(node) { 00108 dialog=(GitkDialogPtr)node->data; 00109 if(dialog->priority>priority) { 00110 priority=dialog->priority; 00111 } 00112 node=g_list_next(node); 00113 } 00114 gitk_log1("=%d",priority); 00115 return(priority); 00116 } 00117 else return(0); 00118 } 00119 00124 GitkDialogPtr gitk_context_get_current(void) { 00125 return(cur_context); 00126 } 00127 00132 void gitk_context_set_current(GitkDialogPtr const new_context) { 00133 cur_context=new_context; 00134 } 00135