1 /* -*- Mode: C ; c-basic-offset: 2 -*- */
3 * LADI Session Handler (ladish)
5 * Copyright (C) 2010 Nedko Arnaudov <nedko@arnaudov.name>
7 **************************************************************************
8 * This file contains GtkAction related code
9 **************************************************************************
11 * LADI Session Handler is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * LADI Session Handler is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with LADI Session Handler. If not, see <http://www.gnu.org/licenses/>
23 * or write to the Free Software Foundation, Inc.,
24 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
29 #include "gtk_builder.h"
33 GtkAction
* g_clear_xruns_and_max_dsp_action
;
34 GtkAction
* g_zoom_100_action
;
35 GtkAction
* g_zoom_fit_action
;
36 GtkAction
* g_zoom_in_action
;
37 GtkAction
* g_zoom_out_action
;
39 void init_actions_and_accelerators(void)
41 static GtkActionGroup
* action_group_ptr
;
42 static GtkAccelGroup
* accel_group_ptr
;
44 g_clear_xruns_and_max_dsp_action
= GTK_ACTION(get_gtk_builder_object("clear_xruns_and_max_dsp_load_action"));
45 g_signal_connect(G_OBJECT(g_clear_xruns_and_max_dsp_action
), "activate", G_CALLBACK(clear_xruns_and_max_dsp
), NULL
);
47 g_zoom_100_action
= GTK_ACTION(get_gtk_builder_object("zoom_100_action"));
48 g_signal_connect(G_OBJECT(g_zoom_100_action
), "activate", G_CALLBACK(zoom_100
), NULL
);
50 g_zoom_fit_action
= GTK_ACTION(get_gtk_builder_object("zoom_fit_action"));
51 g_signal_connect(G_OBJECT(g_zoom_fit_action
), "activate", G_CALLBACK(zoom_fit
), NULL
);
53 g_zoom_in_action
= GTK_ACTION(get_gtk_builder_object("zoom_in_action"));
54 g_signal_connect(G_OBJECT(g_zoom_in_action
), "activate", G_CALLBACK(zoom_in
), NULL
);
56 g_zoom_out_action
= GTK_ACTION(get_gtk_builder_object("zoom_out_action"));
57 g_signal_connect(G_OBJECT(g_zoom_out_action
), "activate", G_CALLBACK(zoom_out
), NULL
);
61 GtkAction
* action_ptr
;
62 const char * shortcut
;
63 } * descriptor_ptr
, descriptors
[] =
65 {g_clear_xruns_and_max_dsp_action
, "c"},
66 {g_zoom_in_action
, "<Control>plus"},
67 {g_zoom_out_action
, "<Control>minus"},
68 {g_zoom_100_action
, "<Control>0"},
69 {g_zoom_fit_action
, "<Control>equal"},
73 action_group_ptr
= gtk_action_group_new("main");
74 accel_group_ptr
= gtk_accel_group_new();
76 for (descriptor_ptr
= descriptors
; descriptor_ptr
->action_ptr
!= NULL
; descriptor_ptr
++)
78 //log_info("action '%s' -> shortcut \"%s\"", gtk_action_get_name(descriptor_ptr->action_ptr), descriptor_ptr->shortcut);
79 gtk_action_group_add_action_with_accel(action_group_ptr
, descriptor_ptr
->action_ptr
, descriptor_ptr
->shortcut
);
80 gtk_action_set_accel_group(descriptor_ptr
->action_ptr
, accel_group_ptr
);
81 gtk_action_connect_accelerator(descriptor_ptr
->action_ptr
);
84 gtk_window_add_accel_group(GTK_WINDOW(g_main_win
), accel_group_ptr
);
87 void enable_action(GtkAction
* action
)
89 gtk_action_set_sensitive(action
, TRUE
);
92 void disable_action(GtkAction
* action
)
94 gtk_action_set_sensitive(action
, FALSE
);