73 |
return qu; |
return qu; |
74 |
} |
} |
75 |
|
|
76 |
|
GQuark app_transcript_topic_editor_quark (void) |
77 |
|
{ |
78 |
|
static GQuark qu = 0; |
79 |
|
if (!qu) |
80 |
|
qu = g_quark_from_static_string ("AppTranscriptTopicEditor"); |
81 |
|
return qu; |
82 |
|
} |
83 |
|
|
84 |
// ---------------------------------------------- app_transcript_view : start |
// ---------------------------------------------- app_transcript_view : start |
85 |
|
|
86 |
struct _AppTranscriptView { |
struct _AppTranscriptView { |
500 |
_t_name_editor (AppTranscriptView *tv) |
_t_name_editor (AppTranscriptView *tv) |
501 |
{ app_transcript_get_name_editor (_tv_get_model (tv)); } |
{ app_transcript_get_name_editor (_tv_get_model (tv)); } |
502 |
|
|
503 |
|
static void |
504 |
|
_t_topic_editor (AppTranscriptView *tv) |
505 |
|
{ app_transcript_get_topic_editor (_tv_get_model (tv)); } |
506 |
|
|
507 |
static gboolean |
static gboolean |
508 |
_t_can_add_ip (AppTranscript *tx) |
_t_can_add_ip (AppTranscript *tx) |
509 |
{ |
{ |
1927 |
g_signal_connect_swapped (mi, "activate", |
g_signal_connect_swapped (mi, "activate", |
1928 |
G_CALLBACK (_t_name_editor), cx); |
G_CALLBACK (_t_name_editor), cx); |
1929 |
|
|
1930 |
|
mi = gtk_menu_item_new_with_label ("Topics"); |
1931 |
|
gtk_menu_append (GTK_MENU_SHELL (menu), mi); |
1932 |
|
g_signal_connect_swapped (mi, "activate", |
1933 |
|
G_CALLBACK (_t_topic_editor), cx); |
1934 |
|
|
1935 |
mi = gtk_menu_item_new_with_label ("Labels"); |
mi = gtk_menu_item_new_with_label ("Labels"); |
1936 |
gtk_menu_append (GTK_MENU_SHELL (menu), mi); |
gtk_menu_append (GTK_MENU_SHELL (menu), mi); |
1937 |
gtk_widget_set_sensitive (mi, FALSE); |
gtk_widget_set_sensitive (mi, FALSE); |
2002 |
gtk_menu_append (GTK_MENU_SHELL (menu), mi); |
gtk_menu_append (GTK_MENU_SHELL (menu), mi); |
2003 |
g_signal_connect (mi, "toggled", G_CALLBACK (_tv_toggle_linenum), cx); |
g_signal_connect (mi, "toggled", G_CALLBACK (_tv_toggle_linenum), cx); |
2004 |
|
|
2005 |
mi = gtk_check_menu_item_new_with_label ("Emotion Detail"); |
mi = gtk_check_menu_item_new_with_label ("Affect Detail"); |
2006 |
gtk_menu_append (GTK_MENU_SHELL (menu), mi); |
gtk_menu_append (GTK_MENU_SHELL (menu), mi); |
2007 |
g_signal_connect (mi, "toggled", G_CALLBACK (_tv_toggle_empathy_detail), cx); |
g_signal_connect (mi, "toggled", G_CALLBACK (_tv_toggle_empathy_detail), cx); |
2008 |
|
|
2242 |
|
|
2243 |
cx->emotion_column = gtk_tree_view_column_new (); |
cx->emotion_column = gtk_tree_view_column_new (); |
2244 |
cell_renderer = gtk_cell_renderer_text_new (); |
cell_renderer = gtk_cell_renderer_text_new (); |
2245 |
gtk_tree_view_column_set_title (cx->emotion_column, "Emotion"); |
gtk_tree_view_column_set_title (cx->emotion_column, "Affect"); |
2246 |
gtk_tree_view_column_pack_start (cx->emotion_column, cell_renderer, TRUE); |
gtk_tree_view_column_pack_start (cx->emotion_column, cell_renderer, TRUE); |
2247 |
gtk_tree_view_column_set_cell_data_func |
gtk_tree_view_column_set_cell_data_func |
2248 |
(cx->emotion_column, cell_renderer, (GtkTreeCellDataFunc) _tv_extract_emotion, cx, NULL); |
(cx->emotion_column, cell_renderer, (GtkTreeCellDataFunc) _tv_extract_emotion, cx, NULL); |
3119 |
} |
} |
3120 |
|
|
3121 |
// ---------------------------------------------------- app_name_editor : end |
// ---------------------------------------------------- app_name_editor : end |
3122 |
|
// ---------------------------------------------------- topic_editor : start |
3123 |
|
|
3124 |
|
struct _TopicEditorClass { |
3125 |
|
GtkWindowClass parent_class; |
3126 |
|
}; |
3127 |
|
|
3128 |
|
struct _TopicEditor { |
3129 |
|
GtkWindow parent; |
3130 |
|
|
3131 |
|
AppTranscript *tx; |
3132 |
|
|
3133 |
|
GtkWidget *listview; |
3134 |
|
guint hide_titles_id; |
3135 |
|
|
3136 |
|
LeadrTopic *current; |
3137 |
|
GSList *labels; |
3138 |
|
GtkWidget *name; |
3139 |
|
GtkWidget *used; |
3140 |
|
gulong use_count_id; |
3141 |
|
GtkWidget *note; |
3142 |
|
|
3143 |
|
GtkWidget *new_topic; |
3144 |
|
GtkWidget *rename; |
3145 |
|
GtkWidget *del; |
3146 |
|
|
3147 |
|
gint noninteractive; |
3148 |
|
}; |
3149 |
|
|
3150 |
|
static void |
3151 |
|
_te_extract_name (GtkTreeViewColumn *tree_column, |
3152 |
|
GtkCellRenderer *cell, |
3153 |
|
GtkTreeModel *model, |
3154 |
|
GtkTreeIter *iter, |
3155 |
|
gpointer data) |
3156 |
|
{ |
3157 |
|
LeadrTopic *tpc; |
3158 |
|
|
3159 |
|
gtk_tree_model_get (model, iter, 0, &tpc, -1); |
3160 |
|
if (!tpc) |
3161 |
|
return; |
3162 |
|
|
3163 |
|
g_object_set (GTK_CELL_RENDERER (cell), |
3164 |
|
"text", leadr_topic_get_name (tpc), |
3165 |
|
NULL); |
3166 |
|
} |
3167 |
|
|
3168 |
|
static void |
3169 |
|
_te_extract_use (GtkTreeViewColumn *tree_column, |
3170 |
|
GtkCellRenderer *cell, |
3171 |
|
GtkTreeModel *model, |
3172 |
|
GtkTreeIter *iter, |
3173 |
|
gpointer data) |
3174 |
|
{ |
3175 |
|
LeadrTopic *tpc; |
3176 |
|
gtk_tree_model_get (model, iter, 0, &tpc, -1); |
3177 |
|
if (!tpc) |
3178 |
|
return; |
3179 |
|
|
3180 |
|
char buf[16]; |
3181 |
|
g_snprintf (buf, sizeof buf, "%d", leadr_topic_get_use (tpc)); |
3182 |
|
|
3183 |
|
g_object_set (GTK_CELL_RENDERER (cell), "text", buf, NULL); |
3184 |
|
} |
3185 |
|
|
3186 |
|
static void |
3187 |
|
_te_extract_note (GtkTreeViewColumn *tree_column, |
3188 |
|
GtkCellRenderer *cell, |
3189 |
|
GtkTreeModel *model, |
3190 |
|
GtkTreeIter *iter, |
3191 |
|
gpointer data) |
3192 |
|
{ |
3193 |
|
LeadrTopic *tpc; |
3194 |
|
gtk_tree_model_get (model, iter, 0, &tpc, -1); |
3195 |
|
if (!tpc) |
3196 |
|
return; |
3197 |
|
|
3198 |
|
const gchar *orig = leadr_topic_get_note (tpc); |
3199 |
|
const gchar *endp = orig; |
3200 |
|
gchar *tmp = NULL; |
3201 |
|
gint len = 0; |
3202 |
|
|
3203 |
|
while (*endp && ++len < 80) { |
3204 |
|
endp = g_utf8_next_char (endp); |
3205 |
|
} |
3206 |
|
if (*endp) { |
3207 |
|
gint bytes = endp - orig; |
3208 |
|
const gchar *suffix = " .."; |
3209 |
|
tmp = g_new (char, bytes + strlen (suffix) + 2); |
3210 |
|
memcpy (tmp, orig, bytes); |
3211 |
|
memcpy (tmp + bytes, suffix, strlen (suffix) + 1); |
3212 |
|
} |
3213 |
|
|
3214 |
|
g_object_set (GTK_CELL_RENDERER (cell), "text", tmp? tmp : orig, NULL); |
3215 |
|
|
3216 |
|
if (tmp) |
3217 |
|
g_free (tmp); |
3218 |
|
} |
3219 |
|
|
3220 |
|
static void |
3221 |
|
_te_rename (TopicEditor *ed) |
3222 |
|
{ |
3223 |
|
g_return_if_fail (ed->current); |
3224 |
|
|
3225 |
|
AppTranscript *tx = ed->tx; |
3226 |
|
|
3227 |
|
if (!app_transcript_can_edit (tx, TP_TEXT)) |
3228 |
|
return; |
3229 |
|
|
3230 |
|
LeadrTopic *old_current = ed->current; |
3231 |
|
|
3232 |
|
const gchar *name = gtk_entry_get_text (GTK_ENTRY (ed->name)); |
3233 |
|
|
3234 |
|
guint matchx; |
3235 |
|
if (g_ptr_set_lookup_key (tx->topics, &matchx, name) && |
3236 |
|
g_ptr_set_at (tx->topics, matchx) != ed->current) { |
3237 |
|
if (app_message_run (GTK_MESSAGE_WARNING, |
3238 |
|
APP_BUTTONS_YES_NO, |
3239 |
|
"The name `%s' is already in use. Are you sure you\n" |
3240 |
|
"want to merge `%s' to `%s'?", |
3241 |
|
name, leadr_topic_get_name (ed->current), name) |
3242 |
|
!= GTK_RESPONSE_YES) |
3243 |
|
return; |
3244 |
|
|
3245 |
|
old_current = g_ptr_set_at (tx->topics, matchx); |
3246 |
|
} |
3247 |
|
|
3248 |
|
g_object_set (ed->current, "name", name, NULL); |
3249 |
|
|
3250 |
|
if (g_ptr_set_lookup_ptr (tx->topics, &matchx, old_current)) |
3251 |
|
topic_editor_set_selection (ed, old_current); |
3252 |
|
} |
3253 |
|
|
3254 |
|
static void |
3255 |
|
_te_delete (TopicEditor *ed) |
3256 |
|
{ |
3257 |
|
if (!app_transcript_can_edit (ed->tx, TP_TEXT)) |
3258 |
|
return; |
3259 |
|
|
3260 |
|
if (leadr_topic_get_use (ed->current)) { |
3261 |
|
app_message_run (GTK_MESSAGE_ERROR, |
3262 |
|
APP_BUTTONS_OK, |
3263 |
|
"The name `%s' is still in use (%d times). You can " |
3264 |
|
"only delete names which are unused.", |
3265 |
|
leadr_topic_get_name (ed->current), |
3266 |
|
leadr_topic_get_use (ed->current)); |
3267 |
|
return; |
3268 |
|
} |
3269 |
|
|
3270 |
|
g_object_unref (ed->current); |
3271 |
|
} |
3272 |
|
|
3273 |
|
static void |
3274 |
|
_te_load_use_count (TopicEditor *ne) |
3275 |
|
{ |
3276 |
|
LeadrTopic *tpc = ne->current; |
3277 |
|
|
3278 |
|
char buf[16]; |
3279 |
|
g_snprintf (buf, sizeof buf, "%d", leadr_topic_get_use (tpc)); |
3280 |
|
gtk_label_set_text (GTK_LABEL (ne->used), buf); |
3281 |
|
} |
3282 |
|
|
3283 |
|
static void |
3284 |
|
_te_load_rename (TopicEditor *ne) |
3285 |
|
{ |
3286 |
|
gboolean can_rename = FALSE; |
3287 |
|
|
3288 |
|
LeadrTopic *tpc = ne->current; |
3289 |
|
if (tpc) { |
3290 |
|
can_rename = |
3291 |
|
(strcmp (leadr_topic_get_name (tpc), |
3292 |
|
gtk_entry_get_text (GTK_ENTRY (ne->name))) != 0); |
3293 |
|
} |
3294 |
|
|
3295 |
|
gint protect; |
3296 |
|
g_object_get (ne->tx, "protection", &protect, NULL); |
3297 |
|
|
3298 |
|
gtk_widget_set_sensitive (ne->rename, can_rename && protect < TP_TEXT); |
3299 |
|
} |
3300 |
|
|
3301 |
|
static void |
3302 |
|
_te_set_current (TopicEditor *ne, LeadrTopic *cur) |
3303 |
|
{ |
3304 |
|
if (ne->current) { |
3305 |
|
g_signal_handler_disconnect (ne->current, ne->use_count_id); |
3306 |
|
} |
3307 |
|
ne->current = cur; |
3308 |
|
if (cur) { |
3309 |
|
ne->use_count_id = |
3310 |
|
g_signal_connect_swapped (cur, "notify::use-count", |
3311 |
|
G_CALLBACK (_te_load_use_count), ne); |
3312 |
|
} |
3313 |
|
} |
3314 |
|
|
3315 |
|
static void |
3316 |
|
_te_selection_changed (TopicEditor *ne) |
3317 |
|
{ |
3318 |
|
GtkTreeSelection *selection = |
3319 |
|
gtk_tree_view_get_selection (GTK_TREE_VIEW (ne->listview)); |
3320 |
|
|
3321 |
|
GtkTreeModel *model; |
3322 |
|
GtkTreeIter iter; |
3323 |
|
LeadrTopic *tpc = NULL; |
3324 |
|
if (gtk_tree_selection_get_selected (selection, &model, &iter)) |
3325 |
|
gtk_tree_model_get (model, &iter, 0, &tpc, -1); |
3326 |
|
|
3327 |
|
gint protect; |
3328 |
|
g_object_get (ne->tx, "protection", &protect, NULL); |
3329 |
|
|
3330 |
|
gboolean can_edit = protect < TP_TEXT; |
3331 |
|
|
3332 |
|
for (GSList *elem = ne->labels; elem; elem = g_slist_next (elem)) |
3333 |
|
gtk_widget_set_sensitive (GTK_WIDGET (elem->data), can_edit); |
3334 |
|
|
3335 |
|
gtk_widget_set_sensitive (ne->name, can_edit); |
3336 |
|
gtk_widget_set_sensitive (ne->used, can_edit); |
3337 |
|
gtk_widget_set_sensitive (ne->note, can_edit); |
3338 |
|
|
3339 |
|
gtk_widget_set_sensitive (ne->new_topic, protect < TP_TEXT); |
3340 |
|
gtk_widget_set_sensitive (ne->del, can_edit); |
3341 |
|
|
3342 |
|
_te_set_current (ne, tpc); |
3343 |
|
|
3344 |
|
if (tpc) { |
3345 |
|
++ne->noninteractive; |
3346 |
|
|
3347 |
|
gtk_entry_set_text (GTK_ENTRY (ne->name), leadr_topic_get_name (tpc)); |
3348 |
|
|
3349 |
|
_te_load_use_count (ne); |
3350 |
|
|
3351 |
|
GtkTextBuffer *buffer = |
3352 |
|
gtk_text_view_get_buffer (GTK_TEXT_VIEW (ne->note)); |
3353 |
|
gtk_text_buffer_set_text (buffer, leadr_topic_get_note (tpc), -1); |
3354 |
|
gtk_text_buffer_set_modified (buffer, FALSE); |
3355 |
|
|
3356 |
|
--ne->noninteractive; |
3357 |
|
} |
3358 |
|
|
3359 |
|
_te_load_rename (ne); |
3360 |
|
} |
3361 |
|
|
3362 |
|
static void |
3363 |
|
_te_hide_column_titles (GConfClient *cl, guint cnxn_id, GConfEntry *entry, |
3364 |
|
TopicEditor *ne) |
3365 |
|
{ |
3366 |
|
const gint bufsize = 128; |
3367 |
|
gchar buf[bufsize]; |
3368 |
|
g_snprintf (buf, bufsize, "%s/%s", app_gconf_dir, "hide_column_titles"); |
3369 |
|
gboolean yes = gconf_client_get_bool (app_gconf_client (), buf, NULL); |
3370 |
|
|
3371 |
|
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (ne->listview), !yes); |
3372 |
|
} |
3373 |
|
|
3374 |
|
static gboolean |
3375 |
|
_te_new_closed (struct modal_run_data *mrd) |
3376 |
|
{ |
3377 |
|
if (g_main_loop_is_running (mrd->loop)) |
3378 |
|
g_main_loop_quit (mrd->loop); |
3379 |
|
|
3380 |
|
return TRUE; |
3381 |
|
} |
3382 |
|
|
3383 |
|
static void |
3384 |
|
_te_new_ok (struct modal_run_data *mrd) |
3385 |
|
{ |
3386 |
|
mrd->ok = TRUE; |
3387 |
|
_te_new_closed (mrd); |
3388 |
|
} |
3389 |
|
|
3390 |
|
static void |
3391 |
|
_te_new_cancel (struct modal_run_data *mrd) |
3392 |
|
{ _te_new_closed (mrd); } |
3393 |
|
|
3394 |
|
static void |
3395 |
|
_te_new (TopicEditor *ne) |
3396 |
|
{ |
3397 |
|
// easy to factor |
3398 |
|
|
3399 |
|
GtkWidget *button; |
3400 |
|
|
3401 |
|
if (!app_transcript_can_edit (ne->tx, TP_TEXT)) |
3402 |
|
return; |
3403 |
|
|
3404 |
|
GtkWidget *top = gtk_window_new (GTK_WINDOW_TOPLEVEL); |
3405 |
|
gtk_window_set_title (GTK_WINDOW (top), ""); |
3406 |
|
gtk_window_set_modal (GTK_WINDOW (top), TRUE); |
3407 |
|
gtk_window_set_position (GTK_WINDOW (top), GTK_WIN_POS_MOUSE); |
3408 |
|
gtk_window_set_resizable (GTK_WINDOW (top), FALSE); |
3409 |
|
gtk_window_set_type_hint (GTK_WINDOW (top), GDK_WINDOW_TYPE_HINT_DIALOG); |
3410 |
|
|
3411 |
|
struct modal_run_data mrd; |
3412 |
|
|
3413 |
|
g_signal_connect_swapped (top, "delete-event", |
3414 |
|
G_CALLBACK (_te_new_closed), &mrd); |
3415 |
|
|
3416 |
|
GtkWidget *box1 = gtk_vbox_new (FALSE, 6); |
3417 |
|
gtk_container_add (GTK_CONTAINER (top), box1); |
3418 |
|
gtk_container_set_border_width (GTK_CONTAINER (box1), 12); |
3419 |
|
|
3420 |
|
GtkWidget *box2 = gtk_hbox_new (FALSE, 6); |
3421 |
|
gtk_box_pack_start_defaults (GTK_BOX (box1), box2); |
3422 |
|
|
3423 |
|
gtk_box_pack_start_defaults (GTK_BOX (box2), gtk_label_new ("New Name:")); |
3424 |
|
GtkWidget *entry = gtk_entry_new (); |
3425 |
|
gtk_box_pack_start_defaults (GTK_BOX (box2), entry); |
3426 |
|
g_signal_connect_swapped (entry, "activate", G_CALLBACK (_te_new_ok), &mrd); |
3427 |
|
|
3428 |
|
gtk_box_pack_start (GTK_BOX (box1), gtk_hseparator_new (), FALSE, FALSE, 0); |
3429 |
|
|
3430 |
|
GtkWidget *bbox = gtk_hbutton_box_new (); |
3431 |
|
gtk_box_pack_start (GTK_BOX (box1), bbox, FALSE, FALSE, 0); |
3432 |
|
|
3433 |
|
button = gtk_button_new_from_stock (GTK_STOCK_OK); |
3434 |
|
gtk_box_pack_start_defaults (GTK_BOX (bbox), button); |
3435 |
|
g_signal_connect_swapped (button, "clicked", G_CALLBACK (_te_new_ok), &mrd); |
3436 |
|
|
3437 |
|
button = gtk_button_new_from_stock (GTK_STOCK_CANCEL); |
3438 |
|
gtk_box_pack_start_defaults (GTK_BOX (bbox), button); |
3439 |
|
g_signal_connect_swapped (button, "clicked", |
3440 |
|
G_CALLBACK (_te_new_cancel), &mrd); |
3441 |
|
|
3442 |
|
gtk_widget_show_all (top); |
3443 |
|
|
3444 |
|
mrd.loop = g_main_loop_new (NULL, FALSE); |
3445 |
|
mrd.ok = FALSE; |
3446 |
|
g_main_loop_run (mrd.loop); |
3447 |
|
g_main_loop_unref (mrd.loop); |
3448 |
|
|
3449 |
|
if (mrd.ok) { |
3450 |
|
const gchar *name = gtk_entry_get_text (GTK_ENTRY (entry)); |
3451 |
|
|
3452 |
|
LeadrTopic *tpc; |
3453 |
|
gint mx; |
3454 |
|
if (g_ptr_set_lookup_key (ne->tx->topics, &mx, name)) |
3455 |
|
tpc = g_ptr_set_at (ne->tx->topics, mx); |
3456 |
|
else |
3457 |
|
tpc = leadr_topic_new (ne->tx, name, NULL); |
3458 |
|
|
3459 |
|
topic_editor_set_selection (ne, tpc); |
3460 |
|
} |
3461 |
|
|
3462 |
|
gtk_widget_destroy (top); |
3463 |
|
} |
3464 |
|
|
3465 |
|
static void |
3466 |
|
_te_copyback_note (TopicEditor *ne) |
3467 |
|
{ |
3468 |
|
GtkTextBuffer *buffer = |
3469 |
|
gtk_text_view_get_buffer (GTK_TEXT_VIEW (ne->note)); |
3470 |
|
|
3471 |
|
if (!gtk_text_buffer_get_modified (buffer)) |
3472 |
|
return; |
3473 |
|
|
3474 |
|
if (ne->current) { |
3475 |
|
GtkTextIter start, end; |
3476 |
|
gtk_text_buffer_get_bounds (buffer, &start, &end); |
3477 |
|
gchar *text = |
3478 |
|
gtk_text_buffer_get_text (buffer, &start, &end, FALSE); |
3479 |
|
g_object_set (ne->current, "note", text, NULL); |
3480 |
|
g_free (text); |
3481 |
|
} |
3482 |
|
|
3483 |
|
gtk_text_buffer_set_modified (buffer, FALSE); |
3484 |
|
} |
3485 |
|
|
3486 |
|
static void |
3487 |
|
_te_shutdown (TopicEditor *ne) |
3488 |
|
{ |
3489 |
|
_te_copyback_note (ne); |
3490 |
|
gtk_object_destroy (GTK_OBJECT (ne)); |
3491 |
|
} |
3492 |
|
|
3493 |
|
static gboolean |
3494 |
|
_te_delete_event (TopicEditor *ne) |
3495 |
|
{ |
3496 |
|
_te_shutdown (ne); |
3497 |
|
return TRUE; |
3498 |
|
} |
3499 |
|
|
3500 |
|
static void |
3501 |
|
topic_editor_init (TopicEditor *ne) |
3502 |
|
{ |
3503 |
|
GtkWidget *frame; |
3504 |
|
GtkWidget *sw; |
3505 |
|
GtkWidget *label; |
3506 |
|
GtkWidget *button; |
3507 |
|
GtkTreeSelection *selection; |
3508 |
|
const gint ne_width = 90; |
3509 |
|
|
3510 |
|
gtk_window_set_default_size (GTK_WINDOW (ne), |
3511 |
|
ne_width * ge_font_width (GTK_WIDGET (ne)), |
3512 |
|
21 * ge_font_height (GTK_WIDGET (ne))); |
3513 |
|
|
3514 |
|
GtkWidget *box1 = gtk_vbox_new (FALSE, 6); |
3515 |
|
gtk_container_add (GTK_CONTAINER (ne), box1); |
3516 |
|
gtk_container_set_border_width (GTK_CONTAINER (box1), 10); |
3517 |
|
|
3518 |
|
GtkWidget *paned = gtk_hpaned_new (); |
3519 |
|
gtk_box_pack_start_defaults (GTK_BOX (box1), paned); |
3520 |
|
gtk_paned_set_position (GTK_PANED (paned), |
3521 |
|
ne_width / 2 * ge_font_width (GTK_WIDGET (ne))); |
3522 |
|
|
3523 |
|
frame = gtk_frame_new (NULL); |
3524 |
|
gtk_paned_pack1 (GTK_PANED (paned), frame, TRUE, FALSE); |
3525 |
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); |
3526 |
|
|
3527 |
|
sw = gtk_scrolled_window_new (0,0); |
3528 |
|
gtk_container_add (GTK_CONTAINER (frame), sw); |
3529 |
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), |
3530 |
|
GTK_POLICY_AUTOMATIC, |
3531 |
|
GTK_POLICY_AUTOMATIC); |
3532 |
|
|
3533 |
|
ne->listview = gtk_tree_view_new (); |
3534 |
|
gtk_container_add (GTK_CONTAINER (sw), ne->listview); |
3535 |
|
|
3536 |
|
gtk_tree_view_insert_column_with_data_func |
3537 |
|
(GTK_TREE_VIEW (ne->listview), |
3538 |
|
-1, |
3539 |
|
"# Use", |
3540 |
|
gtk_cell_renderer_text_new (), |
3541 |
|
_te_extract_use, |
3542 |
|
NULL, |
3543 |
|
NULL); |
3544 |
|
|
3545 |
|
gtk_tree_view_insert_column_with_data_func |
3546 |
|
(GTK_TREE_VIEW (ne->listview), |
3547 |
|
-1, |
3548 |
|
_("Name"), |
3549 |
|
gtk_cell_renderer_text_new (), |
3550 |
|
_te_extract_name, |
3551 |
|
NULL, |
3552 |
|
NULL); |
3553 |
|
|
3554 |
|
gtk_tree_view_insert_column_with_data_func |
3555 |
|
(GTK_TREE_VIEW (ne->listview), |
3556 |
|
-1, |
3557 |
|
_("Note"), |
3558 |
|
gtk_cell_renderer_text_new (), |
3559 |
|
_te_extract_note, |
3560 |
|
NULL, |
3561 |
|
NULL); |
3562 |
|
|
3563 |
|
ge_tree_view_set_columns_resizable (GTK_TREE_VIEW (ne->listview), TRUE); |
3564 |
|
|
3565 |
|
ne->hide_titles_id = |
3566 |
|
app_gconf_notify_add ("hide_column_titles", |
3567 |
|
(GConfClientNotifyFunc) _te_hide_column_titles, ne); |
3568 |
|
|
3569 |
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (ne->listview)); |
3570 |
|
|
3571 |
|
gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE); |
3572 |
|
|
3573 |
|
g_signal_connect_swapped (selection, "changed", |
3574 |
|
G_CALLBACK (_te_selection_changed), ne); |
3575 |
|
|
3576 |
|
GtkTable *table = |
3577 |
|
(GtkTable*) gtk_table_new (4, 2, FALSE); |
3578 |
|
gtk_paned_pack2 (GTK_PANED (paned), GTK_WIDGET (table), TRUE, FALSE); |
3579 |
|
gint row = 0; |
3580 |
|
|
3581 |
|
gtk_table_set_row_spacings (table, 6); |
3582 |
|
gtk_table_set_col_spacings (table, 6); |
3583 |
|
|
3584 |
|
label = ge_right_label_new ("Name:"); |
3585 |
|
ne->labels = g_slist_prepend (ne->labels, label); |
3586 |
|
gtk_table_attach (table, label, 0,1, row,row+1, |
3587 |
|
GTK_FILL, GTK_FILL, 0, 0); |
3588 |
|
ne->name = gtk_entry_new (); |
3589 |
|
gtk_table_attach (table, ne->name, 1,2, row,row+1, |
3590 |
|
GTK_FILL, GTK_FILL, 0, 0); |
3591 |
|
|
3592 |
|
g_signal_connect_swapped (ne->name, "changed", |
3593 |
|
G_CALLBACK (_te_load_rename), ne); |
3594 |
|
|
3595 |
|
++row; |
3596 |
|
label = ge_right_label_new ("Used:"); |
3597 |
|
ne->labels = g_slist_prepend (ne->labels, label); |
3598 |
|
gtk_table_attach (table, label, 0,1, row,row+1, |
3599 |
|
GTK_FILL, GTK_FILL, 0, 0); |
3600 |
|
ne->used = ge_left_label_new (NULL); |
3601 |
|
gtk_table_attach (table, ne->used, 1,2, row,row+1, |
3602 |
|
GTK_FILL, GTK_FILL, 0, 0); |
3603 |
|
|
3604 |
|
++row; |
3605 |
|
label = gtk_label_new ("Note:"); |
3606 |
|
ne->labels = g_slist_prepend (ne->labels, label); |
3607 |
|
gtk_table_attach (table, label, 0,1, row,row+1, |
3608 |
|
GTK_FILL, GTK_FILL, 0, 0); |
3609 |
|
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_RIGHT); |
3610 |
|
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.0); |
3611 |
|
|
3612 |
|
frame = gtk_frame_new (NULL); |
3613 |
|
gtk_table_attach (table, frame, 1,2, row,row+1, |
3614 |
|
GTK_EXPAND | GTK_SHRINK | GTK_FILL, |
3615 |
|
GTK_EXPAND | GTK_FILL, 0, 0); |
3616 |
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); |
3617 |
|
|
3618 |
|
sw = gtk_scrolled_window_new (0,0); |
3619 |
|
gtk_container_add (GTK_CONTAINER (frame), sw); |
3620 |
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), |
3621 |
|
GTK_POLICY_NEVER, |
3622 |
|
GTK_POLICY_AUTOMATIC); |
3623 |
|
|
3624 |
|
ne->note = gtk_text_view_new (); |
3625 |
|
gtk_container_add (GTK_CONTAINER (sw), ne->note); |
3626 |
|
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (ne->note), GTK_WRAP_WORD); |
3627 |
|
g_object_set (ne->note, "width-request", 16 * ge_font_width (GTK_WIDGET (ne)), NULL); |
3628 |
|
|
3629 |
|
gtk_box_pack_start (GTK_BOX (box1), gtk_hseparator_new (), FALSE, FALSE, 0); |
3630 |
|
|
3631 |
|
GtkWidget *bbox = gtk_hbutton_box_new (); |
3632 |
|
gtk_box_pack_start (GTK_BOX (box1), bbox, FALSE, FALSE, 0); |
3633 |
|
|
3634 |
|
ne->new_topic = gtk_button_new_with_label ("New"); |
3635 |
|
gtk_box_pack_start_defaults (GTK_BOX (bbox), ne->new_topic); |
3636 |
|
g_signal_connect_swapped (ne->new_topic, "clicked", |
3637 |
|
G_CALLBACK (_te_new), ne); |
3638 |
|
|
3639 |
|
ne->rename = gtk_button_new_with_label ("Rename"); |
3640 |
|
gtk_box_pack_start_defaults (GTK_BOX (bbox), ne->rename); |
3641 |
|
g_signal_connect_swapped (ne->rename, "clicked", |
3642 |
|
G_CALLBACK (_te_rename), ne); |
3643 |
|
|
3644 |
|
ne->del = gtk_button_new_with_label ("Delete"); |
3645 |
|
gtk_box_pack_start_defaults (GTK_BOX (bbox), ne->del); |
3646 |
|
g_signal_connect_swapped (ne->del, "clicked", |
3647 |
|
G_CALLBACK (_te_delete), ne); |
3648 |
|
|
3649 |
|
button = gtk_button_new_with_label ("OK"); |
3650 |
|
gtk_box_pack_start_defaults (GTK_BOX (bbox), button); |
3651 |
|
g_signal_connect_swapped (button, "clicked", |
3652 |
|
G_CALLBACK (_te_shutdown), ne); |
3653 |
|
|
3654 |
|
g_signal_connect_swapped (ne, "delete-event", |
3655 |
|
G_CALLBACK (_te_delete_event), ne); |
3656 |
|
} |
3657 |
|
|
3658 |
|
static void |
3659 |
|
_te_topic_changed (TopicEditor *te, LeadrTopic *tpc) |
3660 |
|
{ |
3661 |
|
gint mx; |
3662 |
|
if (g_ptr_set_lookup_ptr (te->tx->topics, &mx, tpc)) |
3663 |
|
app_list_store_row_changed (APP_LIST_STORE (te->tx->topics), mx); |
3664 |
|
} |
3665 |
|
|
3666 |
|
void |
3667 |
|
topic_editor_set_selection (TopicEditor *te, LeadrTopic *tpc) |
3668 |
|
{ |
3669 |
|
gint mx; |
3670 |
|
if (!g_ptr_set_lookup_ptr (te->tx->topics, &mx, tpc)) { |
3671 |
|
g_critical ("topic_editor_set_selection: can't find topic"); |
3672 |
|
return; |
3673 |
|
} |
3674 |
|
|
3675 |
|
// This has no effect if the window is not mapped. XXX |
3676 |
|
|
3677 |
|
GtkTreeSelection *selection = |
3678 |
|
gtk_tree_view_get_selection (GTK_TREE_VIEW (te->listview)); |
3679 |
|
|
3680 |
|
GtkTreePath *path = gtk_tree_path_new (); |
3681 |
|
gtk_tree_path_append_index (path, mx); |
3682 |
|
gtk_tree_selection_select_path (selection, path); |
3683 |
|
gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (te->listview), path, NULL, |
3684 |
|
FALSE, .5, .5); |
3685 |
|
gtk_tree_path_free (path); |
3686 |
|
} |
3687 |
|
|
3688 |
|
TopicEditor * |
3689 |
|
topic_editor_new (AppTranscript *tx) |
3690 |
|
{ |
3691 |
|
TopicEditor *te = |
3692 |
|
(TopicEditor*) g_object_new (topic_editor_get_type (), 0); |
3693 |
|
|
3694 |
|
te->tx = tx; |
3695 |
|
|
3696 |
|
app_transcript_set_child_window_title (GTK_WINDOW (te), tx, "Topics"); |
3697 |
|
|
3698 |
|
gtk_tree_view_set_model (GTK_TREE_VIEW (te->listview), |
3699 |
|
GTK_TREE_MODEL (tx->topics)); |
3700 |
|
|
3701 |
|
g_signal_connect_object (tx, "topic-changed", |
3702 |
|
G_CALLBACK (_te_topic_changed), te, |
3703 |
|
G_CONNECT_SWAPPED); |
3704 |
|
|
3705 |
|
g_signal_connect_object (tx, "presave", |
3706 |
|
G_CALLBACK (_te_copyback_note), te, |
3707 |
|
G_CONNECT_SWAPPED); |
3708 |
|
|
3709 |
|
g_signal_connect_object (tx, "notify::protection", |
3710 |
|
G_CALLBACK (_te_selection_changed), te, |
3711 |
|
G_CONNECT_SWAPPED); |
3712 |
|
return te; |
3713 |
|
} |
3714 |
|
|
3715 |
|
static GObjectClass *topic_editor_parent_class; |
3716 |
|
|
3717 |
|
static void |
3718 |
|
topic_editor_dispose (GObject *object) |
3719 |
|
{ |
3720 |
|
TopicEditor *te = TOPIC_EDITOR (object); |
3721 |
|
|
3722 |
|
if (!te->tx) return; |
3723 |
|
|
3724 |
|
_te_set_current (te, NULL); |
3725 |
|
|
3726 |
|
gconf_client_notify_remove (app_gconf_client (), te->hide_titles_id); |
3727 |
|
|
3728 |
|
g_object_steal_qdata (G_OBJECT (te->tx), |
3729 |
|
app_transcript_topic_editor_quark ()); |
3730 |
|
te->tx = NULL; |
3731 |
|
|
3732 |
|
(* G_OBJECT_CLASS (topic_editor_parent_class)->dispose) (object); |
3733 |
|
} |
3734 |
|
|
3735 |
|
static void |
3736 |
|
topic_editor_class_init (TopicEditorClass *klass) |
3737 |
|
{ |
3738 |
|
GObjectClass *o_class = G_OBJECT_CLASS (klass); |
3739 |
|
|
3740 |
|
topic_editor_parent_class = g_type_class_peek_parent (klass); |
3741 |
|
|
3742 |
|
o_class->dispose = topic_editor_dispose; |
3743 |
|
} |
3744 |
|
|
3745 |
|
GType topic_editor_get_type (void) |
3746 |
|
{ |
3747 |
|
static GType our_type = 0; |
3748 |
|
|
3749 |
|
if (our_type == 0) { |
3750 |
|
static const GTypeInfo our_info = { |
3751 |
|
sizeof(TopicEditorClass), |
3752 |
|
(GBaseInitFunc) NULL, |
3753 |
|
(GBaseFinalizeFunc) NULL, |
3754 |
|
(GClassInitFunc) topic_editor_class_init, |
3755 |
|
NULL, /* class_finalize */ |
3756 |
|
NULL, /* class_data */ |
3757 |
|
sizeof (TopicEditor), |
3758 |
|
0, /* n_preallocs */ |
3759 |
|
(GInstanceInitFunc) topic_editor_init, |
3760 |
|
NULL |
3761 |
|
}; |
3762 |
|
|
3763 |
|
our_type = g_type_register_static (GTK_TYPE_WINDOW, |
3764 |
|
"TopicEditor", |
3765 |
|
&our_info, |
3766 |
|
0); |
3767 |
|
} |
3768 |
|
return our_type; |
3769 |
|
} |
3770 |
|
|
3771 |
|
// ---------------------------------------------------- topic_editor : end |
3772 |
// --------------------------------------------- app_tscript_info : start |
// --------------------------------------------- app_tscript_info : start |
3773 |
|
|
3774 |
struct _AppTscriptInfoClass { |
struct _AppTscriptInfoClass { |