#include "config.h"
#include <stdio.h>
#include <unistd.h>
#include "log.h"
#include "i18n.h"
#include "ipc.h"
#include "main.h"
#include "menu.h"
#include "view.h"
Go to the source code of this file.
Defines | |
#define | UNUSED(x) (void)(x) |
Functions | |
void | menu_init (void) |
Initialise popup menus for content browser. | |
void | menu_destroy (void) |
Remove the popup menus. | |
void | menu_show (void) |
Set the context menu to show in the popup menu. | |
void | menu_set_full_screen (gboolean mode) |
void | menu_set_text (void) |
Initialise text items in popup menus for content browser. | |
void | menu_set_zoom_level (gfloat zoom_level) |
void | menu_on_item_activated (const gchar *item, const gchar *group, const gchar *menu, const gchar *state) |
Handle a menu button that has been pressed by the user. | |
Variables | |
static const char * | MENU_MAIN = "erbrowser_menu_main" |
static const char * | GROUP_ACTIONS = "erbrowser_actions" |
static const char * | GROUP_TOOLS = "erbrowser_tools" |
static const char * | GROUP_ZOOM_FONT_TOOLS = "erbrowser_zoom" |
static const char * | ITEM_FONT_SIZE_SMALL = "zoom_small" |
static const char * | ITEM_FONT_SIZE_MEDIUM = "zoom_medium" |
static const char * | ITEM_FONT_SIZE_LARGE = "zoom_large" |
static const char * | ITEM_FONT_SIZE_XLARGE = "zoom_xlarge" |
static const char * | GROUP_TOOLS_FONTSIZE = "erbrowser_font_size" |
static const char * | ITEM_ACTION_BACK = "history_back" |
static const char * | ITEM_ACTION_FORWARD = "history_forward" |
static const char * | ITEM_ACTION_RELOAD = "reload" |
static const char * | STATE_NORMAL = "normal" |
static const char * | STATE_SELECTED = "selected" |
static const gfloat | ZOOM_LEVEL_SMALL = 0.8f |
static const gfloat | ZOOM_LEVEL_MEDIUM = 1.0f |
static const gfloat | ZOOM_LEVEL_LARGE = 1.2f |
static const gfloat | ZOOM_LEVEL_XLARGE = 1.5f |
#define UNUSED | ( | x | ) | (void)(x) |
Copyright (C) 2009 iRex Technologies B.V. All rights reserved.
Definition at line 47 of file erbrowser/src/menu.c.
void menu_destroy | ( | void | ) |
Remove the popup menus.
---------------------------------------------------------------------------
Name : menu_destroy
-- |
--------------------------------------------------------------------------
Definition at line 145 of file erbrowser/src/menu.c.
00146 { 00147 LOGPRINTF("entry"); 00148 00149 // remove the main menu 00150 ipc_remove_menu( MENU_MAIN ); 00151 }
void menu_init | ( | ) |
Initialise popup menus for content browser.
Initialise popup menus for settings application.
Initialise popup menus.
---------------------------------------------------------------------------
Name : menu_init
-- |
--------------------------------------------------------------------------
Definition at line 108 of file erbrowser/src/menu.c.
References GROUP_ACTIONS, GROUP_TOOLS, GROUP_TOOLS_FONTSIZE, GROUP_ZOOM_FONT_TOOLS, ipc_menu_add_group(), ipc_menu_add_item(), ipc_menu_add_menu(), ipc_menu_set_item_state(), ITEM_ACTION_BACK, ITEM_ACTION_CLOSE, ITEM_ACTION_FORWARD, ITEM_ACTION_RELOAD, ITEM_FONT_SIZE_LARGE, ITEM_FONT_SIZE_MEDIUM, ITEM_FONT_SIZE_SMALL, ITEM_FONT_SIZE_XLARGE, LOGPRINTF, MENU_MAIN, menu_set_text(), menu_show(), and STATE_SELECTED.
00109 { 00110 LOGPRINTF("entry"); 00111 00112 const char *group; 00113 group = GROUP_TOOLS; 00114 ipc_menu_add_group( group, "", "folder" ); 00115 ipc_menu_add_group( GROUP_TOOLS_FONTSIZE, group, "tools_character" ); // reuse UDS icon 00116 00117 group = GROUP_ZOOM_FONT_TOOLS; 00118 ipc_menu_add_group( group, GROUP_TOOLS_FONTSIZE, "folder" ); 00119 ipc_menu_add_item ( ITEM_FONT_SIZE_SMALL, group, ITEM_FONT_SIZE_SMALL ); 00120 ipc_menu_add_item ( ITEM_FONT_SIZE_MEDIUM, group, ITEM_FONT_SIZE_MEDIUM ); 00121 ipc_menu_set_item_state( ITEM_FONT_SIZE_MEDIUM, group, STATE_SELECTED ); 00122 ipc_menu_add_item ( ITEM_FONT_SIZE_LARGE, group, ITEM_FONT_SIZE_LARGE ); 00123 ipc_menu_add_item ( ITEM_FONT_SIZE_XLARGE, group, ITEM_FONT_SIZE_XLARGE ); 00124 00125 group = GROUP_ACTIONS; 00126 ipc_menu_add_group( group, "", "folder" ); 00127 ipc_menu_add_item ( ITEM_ACTION_BACK, group, ITEM_ACTION_BACK ); 00128 ipc_menu_add_item ( ITEM_ACTION_FORWARD, group, ITEM_ACTION_FORWARD ); 00129 ipc_menu_add_item ( ITEM_ACTION_RELOAD, group, ITEM_ACTION_RELOAD ); 00130 #if MACHINE_IS_DR1000S || MACHINE_IS_DR1000SW 00131 ipc_menu_add_item ( ITEM_ACTION_FULL_SCREEN, group, ITEM_ACTION_FULL_SCREEN ); 00132 ipc_menu_add_item ( ITEM_ACTION_CLOSE, group, ITEM_ACTION_CLOSE ); 00133 #endif 00134 00135 ipc_menu_add_menu ( MENU_MAIN, GROUP_ACTIONS, GROUP_TOOLS, NULL ); 00136 00137 menu_set_text(); 00138 00139 // set menu context 00140 menu_show(); 00141 }
void menu_on_item_activated | ( | const gchar * | item, | |
const gchar * | group, | |||
const gchar * | menu, | |||
const gchar * | state | |||
) |
Handle a menu button that has been pressed by the user.
---------------------------------------------------------------------------
Name : menu_on_item_activated
[in] | item | - item name of the activated item |
[in] | group | - name of the parent group of the activated item |
[in] | menu | - name of the current menu |
[in] | state | - state of the item when activated |
--------------------------------------------------------------------------
Definition at line 243 of file erbrowser/src/menu.c.
References GROUP_ACTIONS, GROUP_ZOOM_FONT_TOOLS, ITEM_ACTION_BACK, ITEM_ACTION_CLOSE, ITEM_ACTION_FORWARD, ITEM_ACTION_RELOAD, ITEM_FONT_SIZE_LARGE, ITEM_FONT_SIZE_MEDIUM, ITEM_FONT_SIZE_SMALL, ITEM_FONT_SIZE_XLARGE, LOGPRINTF, main_quit(), STATE_NORMAL, STATE_SELECTED, view_full_screen(), view_go_back(), view_go_forward(), view_reload(), view_set_zoom_level(), WARNPRINTF, ZOOM_LEVEL_LARGE, ZOOM_LEVEL_MEDIUM, ZOOM_LEVEL_SMALL, and ZOOM_LEVEL_XLARGE.
00247 { 00248 gboolean ok = TRUE; 00249 00250 LOGPRINTF("entry: item [%s] group [%s]", item, group); 00251 00252 if ( strcmp(group, GROUP_ACTIONS) == 0 ) 00253 { 00254 if ( strcmp(item, ITEM_ACTION_BACK) == 0 ) 00255 { 00256 view_go_back(); 00257 } 00258 else if ( strcmp(item, ITEM_ACTION_FORWARD) == 0 ) 00259 { 00260 view_go_forward(); 00261 } 00262 else if ( strcmp(item, ITEM_ACTION_RELOAD) == 0 ) 00263 { 00264 view_reload(); 00265 } 00266 #if MACHINE_IS_DR1000S || MACHINE_IS_DR1000SW 00267 else if ( strcmp(item, ITEM_ACTION_FULL_SCREEN) == 0 ) 00268 { 00269 if ( strcmp(state, STATE_NORMAL) == 0 ) 00270 { 00271 view_full_screen(TRUE); 00272 } 00273 else if ( strcmp(state, STATE_SELECTED) == 0 ) 00274 { 00275 view_full_screen(FALSE); 00276 } 00277 } 00278 else if ( strcmp(item, ITEM_ACTION_CLOSE) == 0 ) 00279 { 00280 // quit and exit application 00281 main_quit(); 00282 } 00283 #endif 00284 else 00285 { 00286 WARNPRINTF("unexpected menu item [%s] in group [%s]", item, group); 00287 ok = FALSE; 00288 } 00289 } 00290 else if ( strcmp(group, GROUP_ZOOM_FONT_TOOLS) == 0 ) 00291 { 00292 if ( strcmp(item, ITEM_FONT_SIZE_SMALL) == 0 ) 00293 { 00294 view_set_zoom_level(ZOOM_LEVEL_SMALL); 00295 } 00296 else if ( strcmp(item, ITEM_FONT_SIZE_MEDIUM) == 0 ) 00297 { 00298 view_set_zoom_level(ZOOM_LEVEL_MEDIUM); 00299 } 00300 else if ( strcmp(item, ITEM_FONT_SIZE_LARGE) == 0 ) 00301 { 00302 view_set_zoom_level(ZOOM_LEVEL_LARGE); 00303 } 00304 else if ( strcmp(item, ITEM_FONT_SIZE_XLARGE) == 0 ) 00305 { 00306 view_set_zoom_level(ZOOM_LEVEL_XLARGE); 00307 } 00308 else 00309 { 00310 WARNPRINTF("unexpected menu item [%s] in group [%s]", item, group); 00311 ok = FALSE; 00312 } 00313 } 00314 else 00315 { 00316 WARNPRINTF("unexpected menu group [%s]", group); 00317 ok = FALSE; 00318 } 00319 00320 if (!ok) 00321 { 00322 WARNPRINTF("unhandled menu item.\n" 00323 "menu: %s\n" 00324 "group: %s\n" 00325 "item: %s\n" 00326 "state: %s", 00327 menu, 00328 group, 00329 item, 00330 state ); 00331 } 00332 }
void menu_set_full_screen | ( | gboolean | mode | ) |
Definition at line 164 of file erbrowser/src/menu.c.
References GROUP_ACTIONS, ipc_menu_set_item_state(), LOGPRINTF, STATE_NORMAL, STATE_SELECTED, and UNUSED.
Referenced by main(), and view_full_screen().
00165 { 00166 LOGPRINTF("entry"); 00167 00168 #if MACHINE_IS_DR1000S || MACHINE_IS_DR1000SW 00169 if (mode) 00170 { 00171 ipc_menu_set_item_state(ITEM_ACTION_FULL_SCREEN, GROUP_ACTIONS, STATE_SELECTED); 00172 } 00173 else 00174 { 00175 ipc_menu_set_item_state(ITEM_ACTION_FULL_SCREEN, GROUP_ACTIONS, STATE_NORMAL); 00176 } 00177 #else 00178 UNUSED(mode); 00179 #endif 00180 }
void menu_set_text | ( | ) |
Initialise text items in popup menus for content browser.
Initiliase text items in popup menu(s).
---------------------------------------------------------------------------
Name : menu_set_text
-- |
--------------------------------------------------------------------------
Definition at line 183 of file erbrowser/src/menu.c.
References GROUP_ACTIONS, GROUP_TOOLS, GROUP_TOOLS_FONTSIZE, GROUP_ZOOM_FONT_TOOLS, ipc_menu_set_group_label(), ipc_menu_set_item_label(), ITEM_ACTION_BACK, ITEM_ACTION_CLOSE, ITEM_ACTION_FORWARD, ITEM_ACTION_RELOAD, ITEM_FONT_SIZE_LARGE, ITEM_FONT_SIZE_MEDIUM, ITEM_FONT_SIZE_SMALL, ITEM_FONT_SIZE_XLARGE, and LOGPRINTF.
00184 { 00185 LOGPRINTF("entry"); 00186 00187 const char *group; 00188 group = GROUP_TOOLS; 00189 ipc_menu_set_group_label( GROUP_TOOLS_FONTSIZE, _("Adjust Font Size")); 00190 00191 group = GROUP_ZOOM_FONT_TOOLS; 00192 ipc_menu_set_group_label( group, _("Actions") ); 00193 ipc_menu_set_item_label ( ITEM_FONT_SIZE_SMALL, group, _("Small") ); 00194 ipc_menu_set_item_label ( ITEM_FONT_SIZE_MEDIUM, group, _("Medium") ); 00195 ipc_menu_set_item_label ( ITEM_FONT_SIZE_LARGE, group, _("Large") ); 00196 ipc_menu_set_item_label ( ITEM_FONT_SIZE_XLARGE, group, _("X-Large") ); 00197 00198 group = GROUP_ACTIONS; 00199 ipc_menu_set_group_label( group, _("Actions") ); 00200 ipc_menu_set_item_label ( ITEM_ACTION_BACK, group, _("Previous") ); 00201 ipc_menu_set_item_label ( ITEM_ACTION_FORWARD, group, _("Next") ); 00202 ipc_menu_set_item_label ( ITEM_ACTION_RELOAD, group, _("Reload Page") ); 00203 #if MACHINE_IS_DR1000S || MACHINE_IS_DR1000SW 00204 ipc_menu_set_item_label ( ITEM_ACTION_FULL_SCREEN, group, _("Full Screen") ); 00205 ipc_menu_set_item_label ( ITEM_ACTION_CLOSE, group, _("Close") ); 00206 #endif 00207 }
void menu_set_zoom_level | ( | gfloat | zoom_level | ) |
Definition at line 210 of file erbrowser/src/menu.c.
References GROUP_ZOOM_FONT_TOOLS, ipc_menu_set_item_state(), ITEM_FONT_SIZE_LARGE, ITEM_FONT_SIZE_MEDIUM, ITEM_FONT_SIZE_SMALL, ITEM_FONT_SIZE_XLARGE, STATE_NORMAL, STATE_SELECTED, ZOOM_LEVEL_LARGE, ZOOM_LEVEL_MEDIUM, and ZOOM_LEVEL_SMALL.
Referenced by view_set_zoom_level().
00211 { 00212 const gchar *selected = NULL; 00213 00214 // pick font size 00215 if (zoom_level <= ZOOM_LEVEL_SMALL) 00216 selected = ITEM_FONT_SIZE_SMALL; 00217 else if (zoom_level <= ZOOM_LEVEL_MEDIUM) 00218 selected = ITEM_FONT_SIZE_MEDIUM; 00219 else if (zoom_level <= ZOOM_LEVEL_LARGE) 00220 selected = ITEM_FONT_SIZE_LARGE; 00221 else 00222 selected = ITEM_FONT_SIZE_XLARGE; 00223 00224 // select font size in menu 00225 if (selected != ITEM_FONT_SIZE_SMALL) 00226 ipc_menu_set_item_state(ITEM_FONT_SIZE_SMALL, GROUP_ZOOM_FONT_TOOLS, STATE_NORMAL); 00227 if (selected != ITEM_FONT_SIZE_MEDIUM) 00228 ipc_menu_set_item_state(ITEM_FONT_SIZE_MEDIUM, GROUP_ZOOM_FONT_TOOLS, STATE_NORMAL); 00229 if (selected != ITEM_FONT_SIZE_LARGE) 00230 ipc_menu_set_item_state(ITEM_FONT_SIZE_LARGE, GROUP_ZOOM_FONT_TOOLS, STATE_NORMAL); 00231 if (selected != ITEM_FONT_SIZE_XLARGE) 00232 ipc_menu_set_item_state(ITEM_FONT_SIZE_XLARGE, GROUP_ZOOM_FONT_TOOLS, STATE_NORMAL); 00233 if (selected) 00234 ipc_menu_set_item_state(selected, GROUP_ZOOM_FONT_TOOLS, STATE_SELECTED); 00235 }
void menu_show | ( | ) |
Set the context menu to show in the popup menu.
Display the proper popup menu for the current context.
---------------------------------------------------------------------------
Name : menu_show
-- |
--------------------------------------------------------------------------
Definition at line 155 of file erbrowser/src/menu.c.
References ipc_menu_show_menu(), LOGPRINTF, and MENU_MAIN.
00156 { 00157 LOGPRINTF("entry"); 00158 00159 // show the main menu 00160 ipc_menu_show_menu( MENU_MAIN ); 00161 }
const char* GROUP_ACTIONS = "erbrowser_actions" [static] |
Definition at line 63 of file erbrowser/src/menu.c.
Referenced by menu_init(), menu_on_item_activated(), menu_set_full_screen(), and menu_set_text().
const char* GROUP_TOOLS = "erbrowser_tools" [static] |
Definition at line 66 of file erbrowser/src/menu.c.
Referenced by menu_init(), and menu_set_text().
const char* GROUP_TOOLS_FONTSIZE = "erbrowser_font_size" [static] |
Definition at line 72 of file erbrowser/src/menu.c.
Referenced by menu_init(), and menu_set_text().
const char* GROUP_ZOOM_FONT_TOOLS = "erbrowser_zoom" [static] |
Definition at line 67 of file erbrowser/src/menu.c.
Referenced by menu_init(), menu_on_item_activated(), menu_set_text(), and menu_set_zoom_level().
const char* ITEM_ACTION_BACK = "history_back" [static] |
Definition at line 75 of file erbrowser/src/menu.c.
Referenced by menu_init(), menu_on_item_activated(), and menu_set_text().
const char* ITEM_ACTION_FORWARD = "history_forward" [static] |
Definition at line 76 of file erbrowser/src/menu.c.
Referenced by menu_init(), menu_on_item_activated(), and menu_set_text().
const char* ITEM_ACTION_RELOAD = "reload" [static] |
Definition at line 77 of file erbrowser/src/menu.c.
Referenced by menu_init(), menu_on_item_activated(), and menu_set_text().
const char* ITEM_FONT_SIZE_LARGE = "zoom_large" [static] |
Definition at line 70 of file erbrowser/src/menu.c.
Referenced by menu_init(), menu_on_item_activated(), menu_set_text(), and menu_set_zoom_level().
const char* ITEM_FONT_SIZE_MEDIUM = "zoom_medium" [static] |
Definition at line 69 of file erbrowser/src/menu.c.
Referenced by menu_init(), menu_on_item_activated(), menu_set_text(), and menu_set_zoom_level().
const char* ITEM_FONT_SIZE_SMALL = "zoom_small" [static] |
Definition at line 68 of file erbrowser/src/menu.c.
Referenced by menu_init(), menu_on_item_activated(), menu_set_text(), and menu_set_zoom_level().
const char* ITEM_FONT_SIZE_XLARGE = "zoom_xlarge" [static] |
Definition at line 71 of file erbrowser/src/menu.c.
Referenced by menu_init(), menu_on_item_activated(), menu_set_text(), and menu_set_zoom_level().
const char* MENU_MAIN = "erbrowser_menu_main" [static] |
Definition at line 60 of file erbrowser/src/menu.c.
Referenced by menu_destroy(), menu_init(), and menu_show().
const char* STATE_NORMAL = "normal" [static] |
Definition at line 84 of file erbrowser/src/menu.c.
Referenced by menu_on_item_activated(), menu_set_full_screen(), and menu_set_zoom_level().
const char* STATE_SELECTED = "selected" [static] |
Definition at line 85 of file erbrowser/src/menu.c.
Referenced by menu_init(), menu_on_item_activated(), menu_set_full_screen(), and menu_set_zoom_level().
const gfloat ZOOM_LEVEL_LARGE = 1.2f [static] |
Definition at line 89 of file erbrowser/src/menu.c.
Referenced by menu_on_item_activated(), and menu_set_zoom_level().
const gfloat ZOOM_LEVEL_MEDIUM = 1.0f [static] |
Definition at line 88 of file erbrowser/src/menu.c.
Referenced by menu_on_item_activated(), and menu_set_zoom_level().
const gfloat ZOOM_LEVEL_SMALL = 0.8f [static] |
Definition at line 87 of file erbrowser/src/menu.c.
Referenced by menu_on_item_activated(), and menu_set_zoom_level().
const gfloat ZOOM_LEVEL_XLARGE = 1.5f [static] |
Definition at line 90 of file erbrowser/src/menu.c.
Referenced by menu_on_item_activated().