1 /*************************************************************************/
2 /* Copyright (C) 2007-2009 sujith <m.sujith@gmail.com>                   */
3 /* Copyright (C) 2009-2013 matias <mati86dl@gmail.com>                   */
4 /*                                                                       */
5 /* This program is free software: you can redistribute it and/or modify  */
6 /* it under the terms of the GNU General Public License as published by  */
7 /* the Free Software Foundation, either version 3 of the License, or     */
8 /* (at your option) any later version.                                   */
9 /*                                                                       */
10 /* This program is distributed in the hope that it will be useful,       */
11 /* but WITHOUT ANY WARRANTY; without even the implied warranty of        */
12 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         */
13 /* GNU General Public License for more details.                          */
14 /*                                                                       */
15 /* You should have received a copy of the GNU General Public License     */
16 /* along with this program.  If not, see <http://www.gnu.org/licenses/>. */
17 /*************************************************************************/
18 
19 #ifndef PRAGHA_MENU_H
20 #define PRAGHA_MENU_H
21 
22 #include <gtk/gtk.h>
23 #include "pragha-backend.h"
24 
25 #include "pragha.h"
26 
27 /*
28  * Helper to GMenumodel definitions.
29  *
30  * NOTE: Remember use "&lt;" and "&gt;" as "<" and ">" in accelerators.
31  */
32 
33 #define NEW_MENU(_MENU) \
34 	"<interface>" \
35 	"  <menu id='" _MENU "'>" \
36 	"    <section>"
37 
38 #define NEW_SUBMENU(_LABEL) \
39 	"  <submenu>" \
40 	"    <attribute name='label' translatable='yes'>" _LABEL "</attribute>" \
41 	"      <section>"
42 
43 #define NEW_NAMED_SUBMENU(_ID,_LABEL) \
44 	"  <submenu id='" _ID "'>" \
45 	"    <attribute name='label' translatable='yes'>" _LABEL "</attribute>" \
46 	"      <section>"
47 
48 #define NEW_ITEM(_LABEL,_PREFIX,_ACTION) \
49 	"        <item>" \
50 	"          <attribute name='label' translatable='yes'>" _LABEL "</attribute>" \
51 	"          <attribute name='action'>" _PREFIX "." _ACTION  "</attribute>"  \
52 	"        </item>"
53 
54 #define NEW_ACCEL_ITEM(_LABEL,_ACCEL,_PREFIX,_ACTION) \
55 	"        <item>" \
56 	"          <attribute name='label' translatable='yes'>" _LABEL "</attribute>" \
57 	"          <attribute name='action'>" _PREFIX "." _ACTION  "</attribute>"  \
58 	"          <attribute name='accel'>" _ACCEL  "</attribute>"  \
59 	"        </item>"
60 
61 #define NEW_ICON_ITEM(_LABEL,_ICON,_PREFIX,_ACTION) \
62 	"        <item>" \
63 	"          <attribute name='label' translatable='yes'>" _LABEL "</attribute>" \
64 	"          <attribute name='action'>" _PREFIX "." _ACTION  "</attribute>"  \
65 	"          <attribute name='icon'>" _ICON "</attribute>" \
66 	"        </item>"
67 
68 #define NEW_ICON_ACCEL_ITEM(_LABEL,_ICON,_ACCEL,_PREFIX,_ACTION) \
69 	"        <item>" \
70 	"          <attribute name='label' translatable='yes'>" _LABEL "</attribute>" \
71 	"          <attribute name='action'>" _PREFIX "." _ACTION  "</attribute>"  \
72 	"          <attribute name='icon'>" _ICON "</attribute>" \
73 	"          <attribute name='accel'>" _ACCEL  "</attribute>"  \
74 	"        </item>"
75 
76 #define SEPARATOR \
77 	"      </section>" \
78 	"      <section>"
79 #define NEW_PLACEHOLDER(_TAG) \
80 	"      <section id='" _TAG "'/>"
81 
82 #define OPEN_PLACEHOLDER(_TAG) \
83 	"      <section id='" _TAG "'>"
84 
85 #define CLOSE_PLACEHOLDER \
86 	"      </section>"
87 
88 #define CLOSE_SUBMENU \
89 	"      </section>" \
90 	"    </submenu>"
91 
92 #define CLOSE_MENU \
93 	"    </section>" \
94 	"  </menu>" \
95 	"</interface>"
96 
97 #define NEW_POPUP(_POPUP) \
98 	"<interface>" \
99 	"  <menu id='" _POPUP "'>" \
100 	"    <section>"
101 
102 #define CLOSE_POPUP \
103 	"    </section>" \
104 	"  </menu>" \
105 	"</interface>"
106 
107 void pragha_menubar_update_playback_state_cb (PraghaBackend *backend, GParamSpec *pspec, gpointer user_data);
108 
109 /*
110  * Public api..
111  */
112 
113 void pragha_menubar_connect_signals (GtkUIManager *menu_ui_manager, PraghaApplication *pragha);
114 
115 void
116 pragha_menubar_set_enable_action (GtkWindow  *window,
117                                   const char *action_name,
118                                   gboolean    enabled);
119 
120 void
121 pragha_menubar_append_action (PraghaApplication *pragha,
122                               const gchar       *placeholder,
123                               GSimpleAction     *action,
124                               GMenuItem         *item);
125 void
126 pragha_menubar_remove_action (PraghaApplication *pragha,
127                               const gchar       *placeholder,
128                               const gchar       *action_name);
129 
130 void
131 pragha_menubar_append_submenu (PraghaApplication  *pragha,
132                                const gchar        *placeholder,
133                                const gchar        *xml_ui,
134                                const gchar        *menu_id,
135                                const gchar        *label,
136                                gpointer            user_data);
137 void
138 pragha_menubar_remove_by_id (PraghaApplication *pragha,
139                              const gchar       *placeholder,
140                              const gchar       *item_id);
141 
142 GtkUIManager *pragha_menubar_new       (void);
143 GtkBuilder   *pragha_gmenu_toolbar_new (PraghaApplication *pragha);
144 
145 #endif /* PRAGHA_MENU_H */