/[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.6 by jpritikin, Wed Aug 13 10:29:28 2003 UTC revision 1.7 by jpritikin, Thu Oct 9 03:18:59 2003 UTC
# Line 35  struct _AppIp { Line 35  struct _AppIp {
35    AppIpName *right;    AppIpName *right;
36    gshort initiator;    gshort initiator;
37    gshort intent;    gshort intent;
38      LeadrTopic *topic;
39    gshort power;       // intensity or tension    gshort power;       // intensity or tension
40    gshort phase;    gshort phase;
41    
# Line 51  struct _AppIp { Line 52  struct _AppIp {
52  };  };
53    
54  enum {  enum {
55    PROP_0 = IP_PROP_PRIVATE,    IP_PROP_0,
56    
57      IP_PROP_NOTES,
58      IP_PROP_LEFT,
59      IP_PROP_RIGHT,
60      IP_PROP_INITIATOR,
61      IP_PROP_VICTIM,
62      IP_PROP_INTENT,
63      IP_PROP_TOPIC,
64      IP_PROP_INTENSITY,
65      IP_PROP_TENSION,
66      IP_PROP_PHASE,
67      IP_PROP_CHAINING,
68      IP_PROP_JOINTS,
69    
70    PROP_INTENT_NAME,    PROP_INTENT_NAME,
71    PROP_TENSION_NAME,    PROP_TENSION_NAME,
# Line 727  app_ip_compare (AppIp *ip1, AppIp *ip2, Line 741  app_ip_compare (AppIp *ip1, AppIp *ip2,
741    
742    out->score[IP_COMPARE_INTENT] = intent_score;    out->score[IP_COMPARE_INTENT] = intent_score;
743    
744    if (ip1->intent != IP_INTENT_KILLS &&    if (ip1->intent != IP_INTENT_PROTESTS &&
745        ip2->intent != IP_INTENT_KILLS)        ip2->intent != IP_INTENT_PROTESTS)
746      {      {
747        out->max_score[IP_COMPARE_POWER] = cx->weight[IP_COMPARE_POWER];        out->max_score[IP_COMPARE_POWER] = cx->weight[IP_COMPARE_POWER];
748    
# Line 1323  rule_get_property_type (gchar *prop) Line 1337  rule_get_property_type (gchar *prop)
1337    else if (EQ (prop, "victim"))    return IP_TYPE_INITIATOR;    else if (EQ (prop, "victim"))    return IP_TYPE_INITIATOR;
1338    else if (EQ (prop, "intent"))    return IP_TYPE_INTENT;    else if (EQ (prop, "intent"))    return IP_TYPE_INTENT;
1339    else if (EQ (prop, "situation")) return IP_TYPE_INTENT; //deprecated    else if (EQ (prop, "situation")) return IP_TYPE_INTENT; //deprecated
1340      else if (EQ (prop, "topic"))     return IP_TYPE_TOPIC;
1341    else if (EQ (prop, "intensity")) return IP_TYPE_INTENSITY;    else if (EQ (prop, "intensity")) return IP_TYPE_INTENSITY;
1342    else if (EQ (prop, "tension"))   return IP_TYPE_TENSION;    else if (EQ (prop, "tension"))   return IP_TYPE_TENSION;
1343    else if (EQ (prop, "phase"))     return IP_TYPE_PHASE;    else if (EQ (prop, "phase"))     return IP_TYPE_PHASE;
# Line 1345  rule_get_property_gtype (gchar *prop) Line 1360  rule_get_property_gtype (gchar *prop)
1360    else if (EQ (prop, "initiator")) return AppIpInitiatorEnumType;    else if (EQ (prop, "initiator")) return AppIpInitiatorEnumType;
1361    else if (EQ (prop, "victim"))    return AppIpInitiatorEnumType;    else if (EQ (prop, "victim"))    return AppIpInitiatorEnumType;
1362    else if (EQ (prop, "intent"))    return AppIpIntentEnumType;    else if (EQ (prop, "intent"))    return AppIpIntentEnumType;
1363      else if (EQ (prop, "topic"))     return G_TYPE_POINTER;
1364    else if (EQ (prop, "situation")) return AppIpIntentEnumType; //deprecated    else if (EQ (prop, "situation")) return AppIpIntentEnumType; //deprecated
1365    else if (EQ (prop, "intensity")) return AppIpIntensityEnumType;    else if (EQ (prop, "intensity")) return AppIpIntensityEnumType;
1366    else if (EQ (prop, "tension"))   return AppIpTensionEnumType;    else if (EQ (prop, "tension"))   return AppIpTensionEnumType;
# Line 1408  rule_try_cast (run_rules_context *rc, Ap Line 1424  rule_try_cast (run_rules_context *rc, Ap
1424        g_value_init (to_value, AppIpChainingEnumType);        g_value_init (to_value, AppIpChainingEnumType);
1425        g_value_set_enum (to_value, 0);        g_value_set_enum (to_value, 0);
1426      }      }
1427      else if (from_type == IP_TYPE_UNSET &&
1428               to_type == IP_TYPE_TOPIC)
1429        {
1430          g_value_init (to_value, G_TYPE_POINTER);
1431          g_value_set_pointer (to_value, NULL);
1432        }
1433    else    else
1434      return FALSE;      return FALSE;
1435    
# Line 2183  void app_ip_to_xml (AppTranscript *tx, g Line 2205  void app_ip_to_xml (AppTranscript *tx, g
2205    gchar num2[numsize];    gchar num2[numsize];
2206    gchar num3[numsize];    gchar num3[numsize];
2207    gchar num4[numsize];    gchar num4[numsize];
2208      gchar num5[16];
2209        
2210    AppIp *ip = g_ptr_set_at (tx->ip_by_start, nth);    AppIp *ip = g_ptr_set_at (tx->ip_by_start, nth);
2211    
# Line 2198  void app_ip_to_xml (AppTranscript *tx, g Line 2221  void app_ip_to_xml (AppTranscript *tx, g
2221    g_snprintf (num4, numsize, "%d", app_ip_get_span_chars (ip));    g_snprintf (num4, numsize, "%d", app_ip_get_span_chars (ip));
2222    
2223    {    {
2224      const gint max_kv = 22 * 2 + 1;      const gint max_kv = 23 * 2 + 1;
2225      const char *kvlist[max_kv];      const char *kvlist[max_kv];
2226      gint num_kv = 0;      gint num_kv = 0;
2227    
# Line 2218  void app_ip_to_xml (AppTranscript *tx, g Line 2241  void app_ip_to_xml (AppTranscript *tx, g
2241      kvlist[num_kv++] = "intent";      kvlist[num_kv++] = "intent";
2242      kvlist[num_kv++] =  g_enum_get_value (AppIpIntentEnumClass,      kvlist[num_kv++] =  g_enum_get_value (AppIpIntentEnumClass,
2243                                            ip->intent)->value_nick;                                            ip->intent)->value_nick;
2244        
2245        if (ip->topic) {
2246          gint id;
2247          g_ptr_set_lookup (tx->topics, &id, ip->topic);
2248          g_snprintf (num5, sizeof (num5), "%d", id);
2249    
2250          kvlist[num_kv++] = "topic";
2251          kvlist[num_kv++] = num5;
2252        }
2253    
2254      kvlist[num_kv++] = "power";      kvlist[num_kv++] = "power";
2255      kvlist[num_kv++] =  g_enum_get_value (AppIpIntensityEnumClass,      kvlist[num_kv++] =  g_enum_get_value (AppIpIntensityEnumClass,
2256                                            ip->power)->value_nick;                                            ip->power)->value_nick;
# Line 2262  void app_ip_to_xml (AppTranscript *tx, g Line 2295  void app_ip_to_xml (AppTranscript *tx, g
2295  static void  static void
2296  _ip_set_initiator_intention (AppIp *ip, gint initiator, gint intention)  _ip_set_initiator_intention (AppIp *ip, gint initiator, gint intention)
2297  {  {
2298    gboolean change = FALSE;    gboolean ch_left_right = FALSE;
2299      gboolean ch_initiator = FALSE;
2300      gboolean ch_intent = FALSE;
2301      gboolean ch_phase = FALSE;
2302      gboolean ch_topic = FALSE;
2303    
2304    if (initiator == IP_INITIATOR_RIGHT &&    if (initiator == IP_INITIATOR_RIGHT &&
2305        is_left_initiator_intention (intention)) {        is_left_initiator_intention (intention)) {
# Line 2270  _ip_set_initiator_intention (AppIp *ip, Line 2307  _ip_set_initiator_intention (AppIp *ip,
2307      ip->right = ip->left;      ip->right = ip->left;
2308      ip->left = tmp_nm;      ip->left = tmp_nm;
2309      intention = is_left_initiator_intention (intention);      intention = is_left_initiator_intention (intention);
       
     app_notice_emit (ip, "left");  
     app_notice_emit (ip, "right");  
     change = TRUE;  
         
2310      initiator = IP_INITIATOR_LEFT;      initiator = IP_INITIATOR_LEFT;
2311        ch_left_right = TRUE;
2312    }    }
2313        
2314    if (ip->initiator != initiator) {    if (ip->initiator != initiator) {
2315      ip->initiator = initiator;      ip->initiator = initiator;
2316      app_notice_emit (ip, "initiator");      ch_initiator = TRUE;
     change = TRUE;  
2317    }    }
2318    
2319    if (ip->intent != intention) {    if (ip->intent != intention) {
# Line 2289  _ip_set_initiator_intention (AppIp *ip, Line 2321  _ip_set_initiator_intention (AppIp *ip,
2321        app_ip_update_highlight (ip, FALSE);        app_ip_update_highlight (ip, FALSE);
2322    
2323      ip->intent = intention;      ip->intent = intention;
2324      app_notice_emit (ip, "intent");      ch_intent = TRUE;
2325    
2326        if (!IP_IS_PHASE_INTENT (intention)) {
2327          if (ip->phase) {
2328            ip->phase = IP_PHASE_UNSET;
2329            ch_phase = TRUE;
2330          }
2331          if (ip->topic) {
2332            leadr_topic_unuse (ip->topic);
2333            ip->topic = NULL;
2334            ch_topic = TRUE;
2335          }
2336        }
2337      }
2338    
2339      gboolean change = FALSE;
2340    
2341      if (ch_left_right) {
2342        app_notice_emit (ip, "left");
2343        app_notice_emit (ip, "right");
2344        change = TRUE;
2345      }
2346      if (ch_initiator) {
2347        app_notice_emit (ip, "initiator");
2348        change = TRUE;
2349      }
2350      if (ch_intent) {
2351        app_notice_emit (ip, "intent");
2352      if (app_ip_visible (ip))      if (app_ip_visible (ip))
2353        app_ip_update_highlight (ip, TRUE);        app_ip_update_highlight (ip, TRUE);
   
     if (!IP_IS_PHASE_INTENT (intention) && ip->phase) {  
       ip->phase = IP_PHASE_UNSET;  
       app_notice_emit (ip, "phase");  
     }  
2354      change = TRUE;      change = TRUE;
2355    }    }
2356      if (ch_phase) {
2357        app_notice_emit (ip, "phase");
2358        change = TRUE;
2359      }
2360      if (ch_topic) {
2361        app_notice_emit (ip, "topic");
2362        change = TRUE;
2363      }
2364    if (change)    if (change)
2365      app_ip_modified (ip);      app_ip_modified (ip);
2366  }  }
# Line 2353  app_ip_set_property (GObject      *objec Line 2413  app_ip_set_property (GObject      *objec
2413      _ip_set_initiator_intention (ip, ip->initiator, g_value_get_enum (value));      _ip_set_initiator_intention (ip, ip->initiator, g_value_get_enum (value));
2414      break;      break;
2415    
2416      case IP_PROP_TOPIC:{
2417        LeadrTopic *tpc = g_value_get_pointer (value);
2418        if (tpc != ip->topic) {
2419          leadr_topic_unuse (ip->topic);
2420          ip->topic = leadr_topic_use (tpc);
2421          app_notice_emit (object, "topic");
2422          app_ip_modified (ip);
2423        }
2424        break;}
2425    
2426    case IP_PROP_PHASE:{    case IP_PROP_PHASE:{
2427      int nval = g_value_get_enum(value);      int nval = g_value_get_enum(value);
2428      if (ip->phase != nval) {      if (ip->phase != nval) {
# Line 2462  app_ip_get_property (GObject      *objec Line 2532  app_ip_get_property (GObject      *objec
2532      g_value_set_enum(value, ip->intent);      g_value_set_enum(value, ip->intent);
2533      break;      break;
2534    
2535      case IP_PROP_TOPIC:
2536        g_value_set_pointer (value, ip->topic);
2537        break;
2538    
2539    case PROP_INTENT_NAME:    case PROP_INTENT_NAME:
2540      g_value_set_static_string(value, g_enum_get_value(AppIpIntentEnumClass,      g_value_set_static_string(value, g_enum_get_value(AppIpIntentEnumClass,
2541                                                        ip->intent)->value_nick);                                                        ip->intent)->value_nick);
# Line 2549  AppIp *app_ip_new(AppTranscript *tx) Line 2623  AppIp *app_ip_new(AppTranscript *tx)
2623  static GObjectClass *_app_ip_parent_class;  static GObjectClass *_app_ip_parent_class;
2624    
2625  static void  static void
2626  app_ip_finalize (GObject *object) {  app_ip_finalize (GObject *object)
2627    AppIp *ip =  {
2628      APP_IP(object);    AppIp *ip = APP_IP (object);
   //AppTranscript *tx = app_ip_get_transcript (ip);  
2629        
2630    if (ip->notes)    if (ip->notes)
2631      g_free (ip->notes);      g_free (ip->notes);
# Line 2562  app_ip_finalize (GObject *object) { Line 2635  app_ip_finalize (GObject *object) {
2635    
2636    app_ip_name_unuse (ip->left);    app_ip_name_unuse (ip->left);
2637    app_ip_name_unuse (ip->right);    app_ip_name_unuse (ip->right);
2638      leadr_topic_unuse (ip->topic);
2639    
2640    (* G_OBJECT_CLASS (_app_ip_parent_class)->finalize) (object);    (* G_OBJECT_CLASS (_app_ip_parent_class)->finalize) (object);
2641  }  }
# Line 2595  app_ip_class_init(AppIpClass *klass) { Line 2669  app_ip_class_init(AppIpClass *klass) {
2669                                                        G_PARAM_READABLE|G_PARAM_WRITABLE));                                                        G_PARAM_READABLE|G_PARAM_WRITABLE));
2670    g_object_class_install_property (object_class,    g_object_class_install_property (object_class,
2671                                     IP_PROP_VICTIM,                                     IP_PROP_VICTIM,
2672                                     g_param_spec_enum ("victim",                                     g_param_spec_enum ("victim", // rename to contra XXX
2673                                                        "",                                                        "",
2674                                                        "",                                                        "",
2675                                                        AppIpInitiatorEnumType,                                                        AppIpInitiatorEnumType,
# Line 2609  app_ip_class_init(AppIpClass *klass) { Line 2683  app_ip_class_init(AppIpClass *klass) {
2683                                                        AppIpIntentEnumType,                                                        AppIpIntentEnumType,
2684                                                        IP_INTENT_UNSET,                                                        IP_INTENT_UNSET,
2685                                                        G_PARAM_READABLE|G_PARAM_WRITABLE));                                                        G_PARAM_READABLE|G_PARAM_WRITABLE));
2686      g_object_class_install_property
2687        (object_class, IP_PROP_TOPIC, g_param_spec_pointer
2688         ("topic", "", "", G_PARAM_READABLE|G_PARAM_WRITABLE));
2689    g_object_class_install_property (object_class,    g_object_class_install_property (object_class,
2690                                     PROP_INTENT_NAME,                                     PROP_INTENT_NAME,
2691                                     g_param_spec_string ("intent_name",                                     g_param_spec_string ("intent_name",

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

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