/[aleader]/aleader/aleader/appip.c
ViewVC logotype

Diff of /aleader/aleader/appip.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by jpritikin, Sat Jul 26 04:26:47 2003 UTC revision 1.5 by jpritikin, Mon Aug 11 13:45:21 2003 UTC
# Line 280  app_ip_compare_span_with_iter (AppIp *ip Line 280  app_ip_compare_span_with_iter (AppIp *ip
280  gboolean app_ip_visible (AppIp *ip)  gboolean app_ip_visible (AppIp *ip)
281  { return ip->start_mark != NULL; }  { return ip->start_mark != NULL; }
282    
283    gint
284    is_left_initiator_intention (gint intention)
285    {
286      switch (intention) {
287      case IP_INTENT_IMPASSE:
288        return IP_INTENT_IMPASSE;
289      case IP_INTENT_UNEASY:
290        return IP_INTENT_OBSERVES;
291      case IP_INTENT_OBSERVES:
292        return IP_INTENT_UNEASY;
293      case IP_INTENT_READY:
294        return IP_INTENT_READY;
295      default:
296        return IP_INTENT_UNSET;
297      }
298    }
299    
300  const gchar *  const gchar *
301  i_tension (gint tension)  i_tension (gint tension)
302  {  {
# Line 631  app_ip_compare (AppIp *ip1, AppIp *ip2, Line 648  app_ip_compare (AppIp *ip1, AppIp *ip2,
648    out->max_score[IP_COMPARE_NAME] = cx->weight[IP_COMPARE_NAME];    out->max_score[IP_COMPARE_NAME] = cx->weight[IP_COMPARE_NAME];
649    gint name_score = 0;    gint name_score = 0;
650    
651    if (IP_IS_SYMMETRIC_INTENT (ip1->intent) &&    if (ge_utf8_casefold_collate (app_ip_name_get (ip1->left),
652        IP_IS_SYMMETRIC_INTENT (ip2->intent))                                  app_ip_name_get (ip2->left)) == 0)
653      {      name_score += 2;
654        if (ge_utf8_casefold_collate (app_ip_name_get (ip1->left),    else if (ge_utf8_casefold_collate (app_ip_name_get (ip1->left),
655                                      app_ip_name_get (ip2->left)) == 0 ||                                       app_ip_name_get (ip2->right)) == 0)
656            ge_utf8_casefold_collate (app_ip_name_get (ip1->left),      name_score += 1;
657                                      app_ip_name_get (ip2->right)) == 0)    
658          name_score += 2;    if (ge_utf8_casefold_collate (app_ip_name_get (ip1->right),
659                                    app_ip_name_get (ip2->right)) == 0)
660        if (ge_utf8_casefold_collate (app_ip_name_get (ip1->right),      name_score += 2;
661                                      app_ip_name_get (ip2->right)) == 0 ||    else if (ge_utf8_casefold_collate (app_ip_name_get (ip1->right),
662            ge_utf8_casefold_collate (app_ip_name_get (ip1->right),                                       app_ip_name_get (ip2->left)) == 0)
663                                      app_ip_name_get (ip2->left)) == 0)      name_score += 1;
         name_score += 2;  
     }  
   else  
     {  
       if (ge_utf8_casefold_collate (app_ip_name_get (ip1->left),  
                                     app_ip_name_get (ip2->left)) == 0)  
         name_score += 2;  
       else if (ge_utf8_casefold_collate (app_ip_name_get (ip1->left),  
                                          app_ip_name_get (ip2->right)) == 0)  
         name_score += 1;  
         
       if (ge_utf8_casefold_collate (app_ip_name_get (ip1->right),  
                                     app_ip_name_get (ip2->right)) == 0)  
         name_score += 2;  
       else if (ge_utf8_casefold_collate (app_ip_name_get (ip1->right),  
                                          app_ip_name_get (ip2->left)) == 0)  
         name_score += 1;  
     }  
664    
665    out->score[IP_COMPARE_NAME] =    out->score[IP_COMPARE_NAME] =
666      (cx->weight[IP_COMPARE_NAME] * name_score) / 4;      (cx->weight[IP_COMPARE_NAME] * name_score) / 4;
# Line 2088  void app_ip_swap (AppIp *ip) Line 2087  void app_ip_swap (AppIp *ip)
2087    ip->left = tmp_nm;    ip->left = tmp_nm;
2088    
2089    gboolean has_initiator =    gboolean has_initiator =
2090      ip->initiator != IP_INITIATOR_UNSET;      (ip->initiator != IP_INITIATOR_UNSET &&
2091         !is_left_initiator_intention (ip->intent));
2092    
2093    if (has_initiator)    if (has_initiator)
2094      ip->initiator = (ip->initiator == IP_INITIATOR_LEFT?      ip->initiator = (ip->initiator == IP_INITIATOR_LEFT?
# Line 2232  void app_ip_to_xml (AppTranscript *tx, g Line 2232  void app_ip_to_xml (AppTranscript *tx, g
2232  }  }
2233    
2234  static void  static void
2235    _ip_set_initiator_intention (AppIp *ip, gint initiator, gint intention)
2236    {
2237      gboolean change = FALSE;
2238    
2239      if (initiator == IP_INITIATOR_RIGHT &&
2240          is_left_initiator_intention (intention)) {
2241        AppIpName *tmp_nm = ip->right;
2242        ip->right = ip->left;
2243        ip->left = tmp_nm;
2244        intention = is_left_initiator_intention (intention);
2245        
2246        app_notice_emit (ip, "left");
2247        app_notice_emit (ip, "right");
2248        change = TRUE;
2249          
2250        initiator = IP_INITIATOR_LEFT;
2251      }
2252      
2253      if (ip->initiator != initiator) {
2254        ip->initiator = initiator;
2255        app_notice_emit (ip, "initiator");
2256        change = TRUE;
2257      }
2258    
2259      if (ip->intent != intention) {
2260        if (app_ip_visible (ip))
2261          app_ip_update_highlight (ip, FALSE);
2262    
2263        ip->intent = intention;
2264        app_notice_emit (ip, "intent");
2265    
2266        if (app_ip_visible (ip))
2267          app_ip_update_highlight (ip, TRUE);
2268    
2269        if (!IP_IS_PHASE_INTENT (intention) && ip->phase) {
2270          ip->phase = IP_PHASE_UNSET;
2271          app_notice_emit (ip, "phase");
2272        }
2273        change = TRUE;
2274      }
2275    
2276      if (change)
2277        app_ip_modified (ip);
2278    }
2279    
2280    static void
2281  app_ip_set_property (GObject      *object,  app_ip_set_property (GObject      *object,
2282                       guint         prop_id,                       guint         prop_id,
2283                       const GValue *value,                       const GValue *value,
# Line 2271  app_ip_set_property (GObject      *objec Line 2317  app_ip_set_property (GObject      *objec
2317      }      }
2318      break;}      break;}
2319    
2320    case IP_PROP_INITIATOR:{    case IP_PROP_INITIATOR:
2321      gint nval = g_value_get_enum(value);      _ip_set_initiator_intention (ip, g_value_get_enum (value), ip->intent);
2322        break;
2323      if (ip->initiator != nval) {  
2324        ip->initiator = nval;    case IP_PROP_INTENT:
2325        app_notice_emit (object, "initiator");      _ip_set_initiator_intention (ip, ip->initiator, g_value_get_enum (value));
2326        app_ip_modified (ip);      break;
     }  
     break;}  
   
   case IP_PROP_INTENT:{  
     int nval = g_value_get_enum(value);  
   
     if (ip->intent != nval) {   // ugh, emit a signal?!  
       if (app_ip_visible (ip))  
         app_ip_update_highlight (ip, FALSE);  
   
       ip->intent = nval;  
       app_notice_emit (ip, "intent");  
   
       if (app_ip_visible (ip))  
         app_ip_update_highlight (ip, TRUE);  
   
       if (!IP_IS_PHASE_INTENT (nval) && ip->phase) {  
         ip->phase = IP_PHASE_UNSET;  
         app_notice_emit (ip, "phase");  
       }  
   
       app_ip_modified (ip);  
     }  
     break;}  
2327    
2328    case IP_PROP_PHASE:{    case IP_PROP_PHASE:{
2329      int nval = g_value_get_enum(value);      int nval = g_value_get_enum(value);

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26