~jmarsden/lxde/lxterminal-packaging

« back to all changes in this revision

Viewing changes to src/lxterminal.c

  • Committer: Ming-Ting Yao Wei
  • Date: 2011-05-29 16:35:49 UTC
  • mfrom: (1.1.3)
  • Revision ID: git-v1:0d020536f8ec047f713e1b78291fc689f2ab4c3b
Merge commit 'upstream/0.1.9'

Show diffs side-by-side

added added

removed removed

Lines of Context:
68
68
 
69
69
/* Menu and accelerator event handlers. */
70
70
static void terminal_initialize_switch_tab_accelerator(Term * term);
 
71
static void terminal_set_disable_alt(Term *term, gboolean disable_alt);
71
72
static void terminal_switch_tab_accelerator(Term * term);
72
73
static void terminal_new_window_activate_event(GtkAction * action, LXTerminal * terminal);
73
74
static void terminal_new_window_accelerator(LXTerminal * terminal, guint action, GtkWidget * item);
300
301
 
301
302
        /* Define the accelerator. */
302
303
        term->closure = g_cclosure_new_swap(G_CALLBACK(terminal_switch_tab_accelerator), term, NULL);
303
 
        gtk_accel_group_connect(term->parent->accel_group, key, mods, GTK_ACCEL_LOCKED, term->closure);
 
304
        if (gtk_accel_group_from_accel_closure(term->closure) == NULL)
 
305
            gtk_accel_group_connect(term->parent->accel_group, key, mods, GTK_ACCEL_LOCKED, term->closure);
 
306
    }
 
307
}
 
308
 
 
309
/* whether disable alt-n to switch tabs or not. */
 
310
void terminal_set_disable_alt(Term * term, gboolean disable_alt)
 
311
{
 
312
    if (GTK_IS_ACCEL_GROUP(term->parent->accel_group))
 
313
    {
 
314
        if (disable_alt)
 
315
        {
 
316
            if (term->closure != NULL)
 
317
                gtk_accel_group_disconnect(term->parent->accel_group, term->closure);
 
318
        }
 
319
        else
 
320
            terminal_initialize_switch_tab_accelerator(term);
304
321
    }
305
322
}
306
323
 
378
395
        terminal_window_set_fixed_size(terminal);
379
396
        gtk_notebook_set_show_tabs(GTK_NOTEBOOK(term->parent->notebook), TRUE);
380
397
    }
381
 
    terminal_initialize_switch_tab_accelerator(term);
 
398
 
 
399
    /* Disable Alt-n switch tabs or not. */
 
400
    terminal_set_disable_alt(term, terminal->setting->disable_alt);
382
401
}
383
402
 
384
403
/* Handler for accelerator <SHIFT><CTRL> T.  Open a new tab. */
513
532
/* Handler for accelerator <CTRL><PAGE UP>.  Cycle through tabs in the reverse direction. */
514
533
static void terminal_previous_tab_accelerator(LXTerminal * terminal, guint action, GtkWidget * item)
515
534
{
516
 
    terminal_previous_tab_activate_event(NULL, terminal);
 
535
    GtkAction *_action = gtk_action_group_get_action(terminal->action_group, "Tabs_PreviousTab");
 
536
    gtk_action_activate(_action);
517
537
}
518
538
 
519
539
/* Handler for "activate" signal on Tabs/Next Tab menu item.
530
550
/* Handler for accelerator <CTRL><PAGE DOWN>.  Cycle through tabs in the forward direction. */
531
551
static void terminal_next_tab_accelerator(LXTerminal * terminal, guint action, GtkWidget * item)
532
552
{
533
 
    terminal_next_tab_activate_event(NULL, terminal);
 
553
    GtkAction *_action = gtk_action_group_get_action(terminal->action_group, "Tabs_NextTab");
 
554
    gtk_action_activate(_action);
534
555
}
535
556
 
536
557
/* Helper for move tab left and right. */
718
739
        {
719
740
            Term * t = g_ptr_array_index(terminal->terms, i);
720
741
            t->index -= 1;
 
742
            if ((GTK_IS_ACCEL_GROUP(t->parent->accel_group)) && (t->closure != NULL))
 
743
                gtk_accel_group_disconnect(t->parent->accel_group, t->closure);
 
744
            terminal_set_disable_alt(t, t->parent->setting->disable_alt);
721
745
        }
722
746
 
723
747
        /* Delete the tab and free the Term structure. */
936
960
/* Deallocate a Term structure. */
937
961
static void terminal_free(Term * term)
938
962
{
939
 
    gtk_accel_group_disconnect(term->parent->accel_group, term->closure);
 
963
    if ((GTK_IS_ACCEL_GROUP(term->parent->accel_group)) && (term->closure != NULL))
 
964
        gtk_accel_group_disconnect(term->parent->accel_group, term->closure);
940
965
    g_free(term);
941
966
}
942
967
 
945
970
{
946
971
    /* Initialize UI manager. */
947
972
    GtkUIManager * manager = gtk_ui_manager_new();
948
 
    GtkActionGroup * action_group = gtk_action_group_new("MenuBar");
949
 
    gtk_action_group_set_translation_domain(action_group, GETTEXT_PACKAGE);
950
 
    gtk_action_group_add_actions(action_group, menus, MENUBAR_MENU_COUNT, terminal);
951
 
    gtk_action_group_add_actions(action_group, menu_items, MENUBAR_MENUITEM_COUNT, terminal);
952
 
    gtk_ui_manager_insert_action_group(manager, action_group, 0);
 
973
    terminal->action_group = gtk_action_group_new("MenuBar");
 
974
    gtk_action_group_set_translation_domain(terminal->action_group, GETTEXT_PACKAGE);
 
975
    gtk_action_group_add_actions(terminal->action_group, menus, MENUBAR_MENU_COUNT, terminal);
 
976
    gtk_action_group_add_actions(terminal->action_group, menu_items, MENUBAR_MENUITEM_COUNT, terminal);
 
977
    gtk_ui_manager_insert_action_group(manager, terminal->action_group, 0);
953
978
 
954
979
    guint merge_id = gtk_ui_manager_new_merge_id(manager);
955
980
    gtk_ui_manager_add_ui(manager, merge_id, "/", "MenuBar", NULL, GTK_UI_MANAGER_MENUBAR, FALSE);
1223
1248
 
1224
1249
    /* Initialize accelerators. */
1225
1250
    terminal_accelerator_initialize(terminal);
1226
 
    terminal_initialize_switch_tab_accelerator(term);
 
1251
 
 
1252
    /* Show the widget, so it is realized and has a window. */
 
1253
    gtk_widget_show_all(terminal->window);
1227
1254
 
1228
1255
    /* Update terminal settings. */
1229
1256
    terminal_settings_apply(terminal);
1230
1257
 
1231
 
    /* Show the widget, so it is realized and has a window. */
1232
 
    gtk_widget_show_all(terminal->window);
1233
 
 
1234
1258
    /* Initialize the geometry hints. */
1235
1259
    gdk_window_get_geometry_hints(GTK_WIDGET(term->vte)->window, &terminal->geometry, &terminal->geometry_mask);
1236
1260
 
1248
1272
    /* Apply settings to all windows. */
1249
1273
    int i;
1250
1274
    for (i = 0; i < terminal->terms->len; i += 1)
 
1275
    {
1251
1276
        terminal_settings_apply_to_term(terminal, g_ptr_array_index(terminal->terms, i));
 
1277
        terminal_set_disable_alt(g_ptr_array_index(terminal->terms, i), terminal->setting->disable_alt);
 
1278
    }
1252
1279
 
1253
1280
    /* Update tab position. */
1254
1281
    terminal->tab_position = terminal_tab_get_position_id(terminal->setting->tab_position);