132 |
app_ip_edit_show_transcript (ed->edit); |
app_ip_edit_show_transcript (ed->edit); |
133 |
} |
} |
134 |
|
|
135 |
|
/* |
136 |
static void |
static void |
137 |
_ipe_fix_warnings (AppIpEditor *ed) |
_ipe_fix_warnings (AppIpEditor *ed) |
138 |
{ |
{ |
141 |
|
|
142 |
app_ip_run_fixup (app_ip_edit_get_data (ed->edit), Whole->rules); |
app_ip_run_fixup (app_ip_edit_get_data (ed->edit), Whole->rules); |
143 |
} |
} |
144 |
|
*/ |
145 |
|
|
146 |
static void |
static void |
147 |
_ipe_play (AppIpEditor *ed) |
_ipe_play (AppIpEditor *ed) |
289 |
gtk_box_pack_start_defaults (GTK_BOX (bbox), button); |
gtk_box_pack_start_defaults (GTK_BOX (bbox), button); |
290 |
g_signal_connect_swapped (button, "clicked", G_CALLBACK (_ipe_play), ed); |
g_signal_connect_swapped (button, "clicked", G_CALLBACK (_ipe_play), ed); |
291 |
|
|
292 |
|
/* |
293 |
button = gtk_button_new_with_label (_("Fix Warnings")); |
button = gtk_button_new_with_label (_("Fix Warnings")); |
294 |
gtk_box_pack_start_defaults (GTK_BOX (bbox), button); |
gtk_box_pack_start_defaults (GTK_BOX (bbox), button); |
295 |
g_signal_connect_swapped (button, "clicked", |
g_signal_connect_swapped (button, "clicked", |
296 |
G_CALLBACK (_ipe_fix_warnings), ed); |
G_CALLBACK (_ipe_fix_warnings), ed); |
297 |
|
*/ |
298 |
|
|
299 |
button = gtk_button_new_with_label (_("Done")); |
button = gtk_button_new_with_label (_("Done")); |
300 |
gtk_box_pack_start_defaults (GTK_BOX (bbox), button); |
gtk_box_pack_start_defaults (GTK_BOX (bbox), button); |
393 |
GtkWidget *editor = |
GtkWidget *editor = |
394 |
GTK_WIDGET (g_object_new (app_ip_editor_get_type (), 0)); |
GTK_WIDGET (g_object_new (app_ip_editor_get_type (), 0)); |
395 |
|
|
396 |
app_transcript_set_child_window_title (GTK_WINDOW (editor), tx, |
gchar buf[64]; |
397 |
"Abstract Situation"); |
gint mx; |
398 |
|
g_ptr_set_lookup_ptr (tx->ip_by_start, &mx, ip); |
399 |
|
g_snprintf (buf, sizeof buf, "Situation #%d", mx + SITUATION_ZERO); |
400 |
|
app_transcript_set_child_window_title (GTK_WINDOW (editor), tx, buf); |
401 |
|
|
402 |
app_ip_edit_set_data (APP_IP_EDITOR (editor)->edit, ip); |
app_ip_edit_set_data (APP_IP_EDITOR (editor)->edit, ip); |
403 |
|
|
512 |
GtkWidget *role[2]; |
GtkWidget *role[2]; |
513 |
GtkWidget *situation; |
GtkWidget *situation; |
514 |
GtkWidget *situation_item[NUM_INTENTPAIRS]; |
GtkWidget *situation_item[NUM_INTENTPAIRS]; |
515 |
|
GtkWidget *topic_label; |
516 |
|
GtkWidget *topic; |
517 |
|
GtkWidget *topic_type; |
518 |
|
gint cur_topic_type; |
519 |
GtkWidget *spacer[2]; |
GtkWidget *spacer[2]; |
520 |
GtkWidget *power_frame; |
GtkWidget *power_frame; |
521 |
GtkWidget *power[3]; |
GtkWidget *power[3]; |
634 |
} |
} |
635 |
|
|
636 |
static void |
static void |
637 |
|
_load_topic (AppIpEdit *ed) |
638 |
|
{ |
639 |
|
LeadrTopic *tpc; |
640 |
|
g_object_get (ed->ip, "topic", &tpc, NULL); |
641 |
|
|
642 |
|
gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (ed->topic)->entry), |
643 |
|
tpc? leadr_topic_get_name (tpc) : ""); |
644 |
|
} |
645 |
|
|
646 |
|
static void |
647 |
|
_load_topics (AppIpEdit *ed) |
648 |
|
{ |
649 |
|
AppTranscript *tx = app_ip_get_transcript (ed->ip); |
650 |
|
|
651 |
|
GList *names = NULL; |
652 |
|
for (gint xx=0; xx < g_ptr_set_len (tx->topics); xx++) { |
653 |
|
const gchar *str = |
654 |
|
leadr_topic_get_name (g_ptr_set_at (tx->topics, xx)); |
655 |
|
names = g_list_append (names, (gchar*) str); |
656 |
|
} |
657 |
|
|
658 |
|
// set_popdown_strings expects at least one string |
659 |
|
if (!names) |
660 |
|
names = g_list_append (names, ""); |
661 |
|
|
662 |
|
gtk_combo_set_popdown_strings (GTK_COMBO (ed->topic), names); |
663 |
|
|
664 |
|
g_list_free (names); |
665 |
|
|
666 |
|
_load_topic (ed); |
667 |
|
} |
668 |
|
|
669 |
|
static void |
670 |
_load_names (AppIpEdit *ed) |
_load_names (AppIpEdit *ed) |
671 |
{ |
{ |
672 |
AppTranscript *tx; |
AppTranscript *tx; |
675 |
|
|
676 |
tx = app_ip_get_transcript (ed->ip); |
tx = app_ip_get_transcript (ed->ip); |
677 |
|
|
678 |
for (gint xx=0; xx < g_ptr_set_len (tx->names_by_use); xx++) { |
for (gint xx=0; xx < g_ptr_set_len (tx->names_by_alpha); xx++) { |
679 |
str = (gchar*) app_ip_name_get (g_ptr_set_at (tx->names_by_use, xx)); |
str = (gchar*) app_ip_name_get (g_ptr_set_at (tx->names_by_alpha, xx)); |
680 |
names = g_list_append (names, str); |
names = g_list_append (names, str); |
681 |
} |
} |
682 |
|
|
798 |
--ed->noninteractive; |
--ed->noninteractive; |
799 |
} |
} |
800 |
|
|
801 |
|
static const gchar *topic_type_a_a[] = { "Trade", "Beauty" }; |
802 |
|
static const gchar *topic_type_e_s[] = { "Law", "Own" }; |
803 |
|
|
804 |
|
static void |
805 |
|
_load_topic_type (AppIpEdit *ed) |
806 |
|
{ |
807 |
|
gint intention; |
808 |
|
g_object_get (ed->ip, "intent", &intention, NULL); |
809 |
|
|
810 |
|
gint tt_e_s = (intention == IP_INTENT_EXPOSES || |
811 |
|
intention == IP_INTENT_STEALS); |
812 |
|
|
813 |
|
const gchar **topic_types = |
814 |
|
tt_e_s? topic_type_e_s : topic_type_a_a; |
815 |
|
|
816 |
|
GtkWidget *menu = gtk_menu_new (); |
817 |
|
|
818 |
|
for (gint xx=0; xx < 2; xx++) { |
819 |
|
GtkWidget *mi = gtk_menu_item_new_with_label (topic_types[xx]); |
820 |
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); |
821 |
|
} |
822 |
|
|
823 |
|
gtk_widget_show_all (menu); // otherwise widget doesn't size properly! |
824 |
|
gtk_option_menu_set_menu (GTK_OPTION_MENU (ed->topic_type), menu); |
825 |
|
|
826 |
|
ed->cur_topic_type = tt_e_s; |
827 |
|
} |
828 |
|
|
829 |
static void |
static void |
830 |
_load_intention_interface (AppIpEdit *ed) |
_load_intention_interface (AppIpEdit *ed) |
831 |
{ |
{ |
857 |
gtk_box_reorder_child (GTK_BOX (box), ed->spacer[0], 0); |
gtk_box_reorder_child (GTK_BOX (box), ed->spacer[0], 0); |
858 |
} |
} |
859 |
gtk_widget_show (ed->spacer[0]); |
gtk_widget_show (ed->spacer[0]); |
860 |
|
|
861 |
} |
} |
862 |
|
|
863 |
|
gtk_widget_set_sensitive (ed->topic_label, is_phase); |
864 |
|
gtk_widget_set_sensitive (ed->topic, is_phase); |
865 |
|
gtk_widget_set_sensitive (ed->topic_type, is_phase); |
866 |
|
|
867 |
|
gint tt_e_s = (situation == IP_INTENT_EXPOSES || |
868 |
|
situation == IP_INTENT_STEALS); |
869 |
|
if (ed->cur_topic_type != tt_e_s) |
870 |
|
_load_topic_type (ed); |
871 |
|
|
872 |
|
++ed->noninteractive; |
873 |
|
gtk_option_menu_set_history (GTK_OPTION_MENU (ed->topic_type), |
874 |
|
(situation == IP_INTENT_ADMIRES || |
875 |
|
situation == IP_INTENT_STEALS)); |
876 |
|
--ed->noninteractive; |
877 |
|
|
878 |
const gint buflen = 64; |
const gint buflen = 64; |
879 |
gchar buf[buflen]; |
gchar buf[buflen]; |
880 |
const gchar *power_title; |
const gchar *power_title; |
892 |
label = gtk_frame_get_label_widget (GTK_FRAME (ed->power_frame)); |
label = gtk_frame_get_label_widget (GTK_FRAME (ed->power_frame)); |
893 |
gtk_label_set_markup (GTK_LABEL (label), buf); |
gtk_label_set_markup (GTK_LABEL (label), buf); |
894 |
|
|
895 |
if (situation == IP_INTENT_KILLS) |
if (situation == IP_INTENT_PROTESTS) |
896 |
{ |
{ |
897 |
gtk_widget_hide (ed->power_frame); |
gtk_widget_hide (ed->power_frame); |
898 |
if (!ed->spacer[1]) { |
if (!ed->spacer[1]) { |
1132 |
|
|
1133 |
int nval = gtk_option_menu_get_history(menu); |
int nval = gtk_option_menu_get_history(menu); |
1134 |
if (nval > 0) nval -= 1; // adjust for separator |
if (nval > 0) nval -= 1; // adjust for separator |
1135 |
g_object_set(ed->ip, "intent", nval, NULL); |
|
1136 |
|
++ed->noninteractive; |
1137 |
|
g_object_set (ed->ip, "intent", nval, NULL); |
1138 |
|
--ed->noninteractive; |
1139 |
} |
} |
1140 |
|
|
1141 |
static void |
static void |
1542 |
} |
} |
1543 |
|
|
1544 |
static void |
static void |
1545 |
|
_ipe_topic_type (AppIpEdit *ed) |
1546 |
|
{ |
1547 |
|
if (ed->noninteractive) |
1548 |
|
return; |
1549 |
|
|
1550 |
|
gint intention; |
1551 |
|
g_object_get (ed->ip, "intent", &intention, NULL); |
1552 |
|
|
1553 |
|
gint tt = gtk_option_menu_get_history (GTK_OPTION_MENU (ed->topic_type)); |
1554 |
|
|
1555 |
|
switch (intention) { |
1556 |
|
case IP_INTENT_ACCEPTS: if (tt) intention = IP_INTENT_ADMIRES; break; |
1557 |
|
case IP_INTENT_ADMIRES: if (!tt) intention = IP_INTENT_ACCEPTS; break; |
1558 |
|
case IP_INTENT_EXPOSES: if (tt) intention = IP_INTENT_STEALS; break; |
1559 |
|
case IP_INTENT_STEALS: if (!tt) intention = IP_INTENT_EXPOSES; break; |
1560 |
|
default: |
1561 |
|
break; |
1562 |
|
} |
1563 |
|
|
1564 |
|
g_object_set (ed->ip, "intent", intention, NULL); |
1565 |
|
} |
1566 |
|
|
1567 |
|
static void |
1568 |
|
_ipe_topic_edit (AppIpEdit *ed) |
1569 |
|
{ |
1570 |
|
if (ed->noninteractive) |
1571 |
|
return; |
1572 |
|
++ed->noninteractive; |
1573 |
|
|
1574 |
|
LeadrTopic *orig; |
1575 |
|
g_object_get (ed->ip, "topic", &orig, NULL); |
1576 |
|
|
1577 |
|
GtkWidget *entry = GTK_COMBO (ed->topic)->entry; |
1578 |
|
|
1579 |
|
if (!app_transcript_can_edit (ed->tx, TP_READONLY)) { |
1580 |
|
gtk_entry_set_text (GTK_ENTRY (entry), leadr_topic_get_name (orig)); |
1581 |
|
|
1582 |
|
--ed->noninteractive; |
1583 |
|
return; |
1584 |
|
} |
1585 |
|
|
1586 |
|
const gchar *name = gtk_entry_get_text (GTK_ENTRY (entry)); |
1587 |
|
if (name[0] == 0) { |
1588 |
|
--ed->noninteractive; |
1589 |
|
return; |
1590 |
|
} |
1591 |
|
AppTranscript *tx = ed->tx; |
1592 |
|
|
1593 |
|
LeadrTopic *tpc = NULL; |
1594 |
|
guint mx; |
1595 |
|
if (g_ptr_set_lookup_key (tx->topics, &mx, name)) |
1596 |
|
tpc = g_ptr_set_at (tx->topics, mx); |
1597 |
|
else { |
1598 |
|
if (app_transcript_can_edit (ed->tx, TP_TEXT)) { |
1599 |
|
tpc = leadr_topic_new (tx, name, NULL); |
1600 |
|
TopicEditor *te = app_transcript_get_topic_editor (ed->tx); |
1601 |
|
topic_editor_set_selection (te, tpc); |
1602 |
|
} else |
1603 |
|
gtk_entry_set_text (GTK_ENTRY (entry), leadr_topic_get_name (orig)); |
1604 |
|
} |
1605 |
|
|
1606 |
|
if (tpc) |
1607 |
|
g_object_set (ed->ip, "topic", tpc, NULL); |
1608 |
|
|
1609 |
|
--ed->noninteractive; |
1610 |
|
} |
1611 |
|
|
1612 |
|
static void |
1613 |
_ed_extract_futu_jtype (GtkTreeViewColumn *tree_column, |
_ed_extract_futu_jtype (GtkTreeViewColumn *tree_column, |
1614 |
GtkCellRenderer *cell, |
GtkCellRenderer *cell, |
1615 |
GtkTreeModel *model, |
GtkTreeModel *model, |
1964 |
gtk_widget_show_all (menu); // needed to get the widget to size properly! |
gtk_widget_show_all (menu); // needed to get the widget to size properly! |
1965 |
gtk_option_menu_set_menu (GTK_OPTION_MENU (ed->situation), menu); |
gtk_option_menu_set_menu (GTK_OPTION_MENU (ed->situation), menu); |
1966 |
g_signal_connect_swapped (ed->situation, "changed", |
g_signal_connect_swapped (ed->situation, "changed", |
1967 |
G_CALLBACK(_app_ip_edit_situation), ed); |
G_CALLBACK (_app_ip_edit_situation), ed); |
1968 |
|
|
1969 |
|
GtkWidget *box15 = gtk_hbox_new (FALSE, 8); |
1970 |
|
gtk_box_pack_start (GTK_BOX (box3), box15, FALSE, FALSE, 0); |
1971 |
|
|
1972 |
|
ed->topic_label = gtk_label_new (NULL); |
1973 |
|
gtk_box_pack_start (GTK_BOX (box15), ed->topic_label, FALSE, FALSE, 0); |
1974 |
|
gtk_label_set_markup (GTK_LABEL (ed->topic_label), "<b>Topic</b>"); |
1975 |
|
|
1976 |
|
ed->topic = gtk_combo_new (); |
1977 |
|
gtk_box_pack_start_defaults (GTK_BOX (box15), ed->topic); |
1978 |
|
gtk_combo_set_case_sensitive (GTK_COMBO (ed->topic), FALSE); |
1979 |
|
gtk_combo_disable_activate (GTK_COMBO (ed->topic)); |
1980 |
|
|
1981 |
|
combotop = gtk_widget_get_ancestor (GTK_COMBO (ed->topic)->list, GTK_TYPE_WINDOW); |
1982 |
|
g_signal_connect_data (combotop, "hide", G_CALLBACK (_ipe_topic_edit), |
1983 |
|
ed, NULL, G_CONNECT_SWAPPED | G_CONNECT_AFTER); |
1984 |
|
entry = GTK_COMBO (ed->topic)->entry; |
1985 |
|
g_signal_connect_swapped (entry, "activate", |
1986 |
|
G_CALLBACK (_ipe_topic_edit), ed); |
1987 |
|
|
1988 |
|
ed->topic_type = gtk_option_menu_new (); |
1989 |
|
gtk_box_pack_start (GTK_BOX (box15), ed->topic_type, FALSE, FALSE, 0); |
1990 |
|
g_signal_connect_swapped (ed->topic_type, "changed", |
1991 |
|
G_CALLBACK (_ipe_topic_type), ed); |
1992 |
|
|
1993 |
gtk_box_pack_start (GTK_BOX (box3), ge_strut_new (1,2), FALSE, FALSE, 0); |
gtk_box_pack_start (GTK_BOX (box3), ge_strut_new (1,2), FALSE, FALSE, 0); |
1994 |
|
|
2348 |
tx = ed->tx = app_ip_get_transcript(_ip); |
tx = ed->tx = app_ip_get_transcript(_ip); |
2349 |
|
|
2350 |
g_signal_connect_swapped (tx, "name-changed", G_CALLBACK (_load_names), ed); |
g_signal_connect_swapped (tx, "name-changed", G_CALLBACK (_load_names), ed); |
2351 |
|
g_signal_connect_swapped (tx, "topic-changed", G_CALLBACK (_load_topics), ed); |
2352 |
g_signal_connect_swaf (tx, "ip-set-span", G_CALLBACK (_ip_edit_set_span), ed); |
g_signal_connect_swaf (tx, "ip-set-span", G_CALLBACK (_ip_edit_set_span), ed); |
2353 |
g_signal_connect_swapped (tx, "ip-modified", |
g_signal_connect_swapped (tx, "ip-modified", |
2354 |
G_CALLBACK (_ie_ip_modified), ed); |
G_CALLBACK (_ie_ip_modified), ed); |
2364 |
G_CALLBACK (_load_initiator), ed); |
G_CALLBACK (_load_initiator), ed); |
2365 |
app_notice_object(&ed->handler_id, ed->ip, "intent", |
app_notice_object(&ed->handler_id, ed->ip, "intent", |
2366 |
G_CALLBACK (_load_initiator), ed); |
G_CALLBACK (_load_initiator), ed); |
2367 |
|
app_notice_object (&ed->handler_id, ed->ip, "topic", |
2368 |
|
G_CALLBACK (_load_topic), ed); |
2369 |
app_notice_object(&ed->handler_id, ed->ip, "intent", |
app_notice_object(&ed->handler_id, ed->ip, "intent", |
2370 |
G_CALLBACK (_load_intention_interface), ed); |
G_CALLBACK (_load_intention_interface), ed); |
2371 |
app_notice_object(&ed->handler_id, ed->ip, "phase", |
app_notice_object(&ed->handler_id, ed->ip, "phase", |
2382 |
|
|
2383 |
++ ed->noninteractive; |
++ ed->noninteractive; |
2384 |
|
|
2385 |
_load_situation(ed); |
_load_situation (ed); |
2386 |
_load_names(ed); |
_load_names (ed); |
2387 |
_load_left(ed); |
_load_topics (ed); |
2388 |
_load_right(ed); |
_load_left (ed); |
2389 |
|
_load_right (ed); |
2390 |
|
_load_topic (ed); |
2391 |
|
_load_topic_type (ed); |
2392 |
_load_to_past (ed); |
_load_to_past (ed); |
2393 |
_load_from_future (ed); |
_load_from_future (ed); |
2394 |
_load_abstract(ed); |
_load_abstract (ed); |
2395 |
_load_transcript(ed); |
_load_transcript (ed); |
2396 |
|
|
2397 |
{ |
{ |
2398 |
gchar *notes; |
gchar *notes; |