hello-world/src/menu.c File Reference

#include <stdio.h>
#include <unistd.h>
#include "log.h"
#include "i18n.h"
#include "ipc.h"
#include "main.h"
#include "menu.h"
Include dependency graph for hello-world/src/menu.c:

Go to the source code of this file.

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_text (void)
 Initialise text items in popup menus for content browser.
void menu_select_view_type (const viewtypes_t view_type)
 Set the specified option in the "View" group to selected.
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 = "helloworld_menu_main"
static const char * GROUP_VIEWS = "helloworld_view"
static const char * GROUP_ACTIONS = "helloworld_actions"
static const char * ITEM_VIEW_ICON = "view_small"
static const char * ITEM_VIEW_LIST = "view_detail"
static const char * ITEM_ACTION_OPEN = "open"
static const char * ITEM_ACTION_COPY = "copy"
static const char * ITEM_ACTION_CUT = "cut"
static const char * ITEM_ACTION_PASTE = "paste"
static const char * ITEM_ACTION_CLOSE = "close"
static const char * STATE_NORMAL = "normal"
static const char * STATE_SELECTED = "selected"
static const char * STATE_DISABLED = "disabled"

Function Documentation

void menu_destroy ( void   ) 

Remove the popup menus.

---------------------------------------------------------------------------

Name : menu_destroy

Parameters:
-- 
Returns:
--

--------------------------------------------------------------------------

Definition at line 145 of file hello-world/src/menu.c.

References ipc_remove_menu(), LOGPRINTF, and MENU_MAIN.

00146 {
00147     LOGPRINTF("entry");
00148 
00149     // remove the main menu
00150     ipc_remove_menu( MENU_MAIN );
00151 }

Here is the call graph for this function:

void menu_init (  ) 

Initialise popup menus for content browser.

Initialise popup menus for settings application.

Initialise popup menus.

---------------------------------------------------------------------------

Name : menu_init

Parameters:
-- 
Returns:
--

--------------------------------------------------------------------------

Definition at line 97 of file hello-world/src/menu.c.

References GROUP_ACTIONS, GROUP_VIEWS, ipc_menu_add_group(), ipc_menu_add_item(), ipc_menu_add_menu(), ipc_menu_set_item_state(), ITEM_ACTION_CLOSE, ITEM_ACTION_COPY, ITEM_ACTION_CUT, ITEM_ACTION_OPEN, ITEM_ACTION_PASTE, ITEM_VIEW_ICON, ITEM_VIEW_LIST, LOGPRINTF, MENU_MAIN, menu_set_text(), menu_show(), STATE_DISABLED, and WARNPRINTF.

00098 {
00099     static gboolean firsttime = TRUE;
00100     const char      *group;
00101 
00102     LOGPRINTF("entry");
00103 
00104     // execute only once
00105     if ( !firsttime )
00106     {
00107         WARNPRINTF("function called twice");
00108         return;
00109     }
00110     firsttime = FALSE;
00111 
00112     // add groups
00113     group = GROUP_VIEWS;
00114     ipc_menu_add_group( group,                  "",    "folder"          );
00115     ipc_menu_add_item ( ITEM_VIEW_ICON,         group, "view_small"      );
00116     ipc_menu_add_item ( ITEM_VIEW_LIST,         group, "view_detail"     );
00117     //                                                                                                                
00118     group = GROUP_ACTIONS;
00119     ipc_menu_add_group( group,                  "",    "folder"          );
00120     ipc_menu_add_item ( ITEM_ACTION_OPEN,       group, "open"            );
00121     ipc_menu_add_item ( ITEM_ACTION_COPY,       group, "copy"            );
00122     ipc_menu_add_item ( ITEM_ACTION_CUT,        group, "cut"             );
00123     ipc_menu_add_item ( ITEM_ACTION_PASTE,      group, "paste"           );
00124     ipc_menu_add_item ( ITEM_ACTION_CLOSE,      group, "close"           );
00125 
00126     // add menus
00127     ipc_menu_add_menu( MENU_MAIN, GROUP_VIEWS, GROUP_ACTIONS, NULL );
00128 
00129     // set menu texts
00130     menu_set_text();
00131 
00132     // disable what is not yet implemented
00133     // TODO: implement all and remove this list
00134     group = GROUP_ACTIONS;
00135     ipc_menu_set_item_state ( ITEM_ACTION_COPY,  group, STATE_DISABLED );
00136     ipc_menu_set_item_state ( ITEM_ACTION_CUT,   group, STATE_DISABLED );
00137     ipc_menu_set_item_state ( ITEM_ACTION_PASTE, group, STATE_DISABLED );
00138     
00139     // set menu context
00140     menu_show();    
00141 }

Here is the call graph for this function:

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

Parameters:
[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
Returns:
--

--------------------------------------------------------------------------

Definition at line 229 of file hello-world/src/menu.c.

References CTB_CONTENTVIEW, CTB_ICONVIEW, CTB_LISTVIEW, CTB_SORT_BY_AUTHOR, CTB_SORT_BY_DATE_ADDED, CTB_SORT_BY_DATE_READ, CTB_SORT_BY_NAME, CTB_SORT_BY_SIZE, CTB_SORT_BY_TYPE, fileview_create_shortcut(), fileview_set_sort_order(), fileview_set_view_type(), fileview_toggle_delete_mode(), g_action, g_mountpoint, GROUP_ACTIONS, GROUP_SORT, GROUP_VIEWS, ICONVIEW, ipc_menu_updates_finished(), ipc_sys_start_task(), ITEM_ACTION_CLOSE, ITEM_ACTION_DELETE, ITEM_ACTION_OPEN, ITEM_SORT_AUTHOR, ITEM_SORT_DATE_ADDED, ITEM_SORT_DATE_READ, ITEM_SORT_NAME, ITEM_VIEW_CONTENT, ITEM_VIEW_DETAIL, ITEM_VIEW_ICON, ITEM_VIEW_LIST, LISTVIEW, LOGPRINTF, main_quit(), main_set_view_type(), msg, START_TIMER, STATE_NORMAL, and WARNPRINTF.

Referenced by on_menu_item().

00233 {
00234     gboolean    ok = TRUE;
00235     viewtypes_t view_type  = 0;
00236     gchar       *msg = NULL;
00237 
00238     LOGPRINTF("entry: item [%s] group [%s]", item, group);
00239 
00240     if ( strcmp(group, GROUP_VIEWS) == 0 )
00241     {
00242         if ( strcmp(state, STATE_NORMAL) == 0 )
00243         {
00244             if (      strcmp(item, ITEM_VIEW_ICON) == 0 )
00245             {
00246                 view_type = ICONVIEW;
00247             }
00248             else if ( strcmp(item, ITEM_VIEW_LIST) == 0 )
00249             {
00250                 view_type = LISTVIEW;
00251             }
00252             else
00253             {
00254                 WARNPRINTF("unexpected menu item [%s] in group [%s]", item, group);
00255                 ok = FALSE;
00256             }
00257 
00258             if (ok)
00259             {
00260                 main_set_view_type( view_type );
00261             }
00262         }
00263         else
00264         {
00265             WARNPRINTF("ignore state [%s] item [%s][%s]", state, item, group);
00266         }
00267     }
00268     else if ( strcmp(group, GROUP_ACTIONS) == 0 )
00269     {
00270         if ( strcmp(state, STATE_NORMAL) == 0 )
00271         {
00272             if (      strcmp(item, ITEM_ACTION_OPEN) == 0 )
00273             {
00274                 // open a document in the viewer
00275                 msg = g_strdup_printf("uds %s/%s", g_mountpoint, "test.pdf");
00276                 ipc_sys_start_task(msg, g_mountpoint, "test.pdf", NULL, NULL);
00277                 g_free(msg);
00278             }
00279             else if ( strcmp(item, ITEM_ACTION_CLOSE) == 0 )
00280             {
00281                 // quit and exit application
00282                 main_quit();
00283                 _exit(0);
00284                 return;
00285             }
00286             else
00287             {
00288                 WARNPRINTF("unexpected menu item [%s] in group [%s]", item, group);
00289                 ok = FALSE;
00290             }
00291 
00292             if (ok)
00293             {
00294                 main_set_view_type( view_type );
00295             }
00296         }
00297         else
00298         {
00299             WARNPRINTF("ignore state [%s] item [%s][%s]", state, item, group);
00300         }
00301     }
00302     else
00303     {
00304         WARNPRINTF("unexpected menu group [%s]", group);
00305         ok = FALSE;
00306     }
00307 
00308     if (!ok)
00309     {
00310         msg = g_strdup_printf( _("Unhandled menu item.\n"
00311                                  "menu: %s\n"
00312                                  "group: %s\n"
00313                                  "item: %s\n"
00314                                  "state: %s"),
00315                                menu,
00316                                group,
00317                                item,
00318                                state );
00319         gtk_label_set_text( GTK_LABEL(g_action), msg);
00320         g_free(msg);
00321     }
00322 }

Here is the call graph for this function:

Here is the caller graph for this function:

void menu_select_view_type ( const viewtypes_t  view_type  ) 

Set the specified option in the "View" group to selected.

---------------------------------------------------------------------------

Name : menu_select_view_type

Parameters:
[in] view_type - currently active view type
Returns:
--

--------------------------------------------------------------------------

Definition at line 191 of file hello-world/src/menu.c.

References GROUP_VIEWS, ICONVIEW, ipc_menu_set_item_state(), ITEM_VIEW_ICON, ITEM_VIEW_LIST, LISTVIEW, LOGPRINTF, N_VIEWTYPES, STATE_NORMAL, and STATE_SELECTED.

00192 {
00193     static const char   *item_old = "";
00194            const char   *item_new = "";
00195 
00196     LOGPRINTF("entry: view_type [%d]", view_type);
00197     g_assert(view_type < N_VIEWTYPES);
00198 
00199     switch (view_type)
00200     {
00201         case ICONVIEW:
00202             item_new = ITEM_VIEW_ICON;
00203             break;
00204         case LISTVIEW:
00205             item_new = ITEM_VIEW_LIST;
00206             break;
00207         default:
00208             ;  // ignore: handled by assert at function entry
00209     }
00210 
00211     if ( strcmp(item_old, item_new) != 0 )
00212     {
00213         if ( item_old[0] != '\0' )
00214         {
00215             ipc_menu_set_item_state ( item_old, GROUP_VIEWS, STATE_NORMAL   );
00216         }
00217         ipc_menu_set_item_state ( item_new, GROUP_VIEWS, STATE_SELECTED );
00218 
00219         item_old = item_new;
00220     }
00221 }

Here is the call graph for this function:

void menu_set_text (  ) 

Initialise text items in popup menus for content browser.

Initiliase text items in popup menu(s).

---------------------------------------------------------------------------

Name : menu_set_text

Parameters:
-- 
Returns:
--

--------------------------------------------------------------------------

Definition at line 165 of file hello-world/src/menu.c.

References GROUP_ACTIONS, GROUP_SORT, GROUP_VIEWS, ipc_menu_set_group_label(), ipc_menu_set_item_label(), ipc_menu_set_menu_label(), ITEM_ACTION_CLOSE, ITEM_ACTION_COPY, ITEM_ACTION_CUT, ITEM_ACTION_OPEN, ITEM_ACTION_PASTE, ITEM_SORT_AUTHOR, ITEM_SORT_DATE_ADDED, ITEM_SORT_DATE_READ, ITEM_SORT_NAME, ITEM_VIEW_CONTENT, ITEM_VIEW_DETAIL, ITEM_VIEW_ICON, ITEM_VIEW_LIST, LOGPRINTF, MENU_MAIN, update_category(), and update_viewmode_text().

Referenced by main_set_locale(), menu_init(), and on_locale().

00166 {
00167     const char      *group;
00168 
00169     LOGPRINTF("entry");
00170 
00171     // set groups + items
00172     group = GROUP_VIEWS;
00173     ipc_menu_set_group_label( group,                    _("View")              );
00174     ipc_menu_set_item_label ( ITEM_VIEW_ICON,    group, _("Thumbnails")        );
00175     ipc_menu_set_item_label ( ITEM_VIEW_LIST,    group, _("Details")           );
00176     //                                                                                                                 
00177     group = GROUP_ACTIONS;                                                     
00178     ipc_menu_set_group_label( group,                    _("Actions")           );
00179     ipc_menu_set_item_label ( ITEM_ACTION_OPEN,  group, _("Open")              );
00180     ipc_menu_set_item_label ( ITEM_ACTION_COPY,  group, _("Copy")              );
00181     ipc_menu_set_item_label ( ITEM_ACTION_CUT,   group, _("Cut")               );
00182     ipc_menu_set_item_label ( ITEM_ACTION_PASTE, group, _("Paste")             );
00183     ipc_menu_set_item_label ( ITEM_ACTION_CLOSE, group, _("Close")             );
00184 
00185     // set menus
00186     ipc_menu_set_menu_label( MENU_MAIN,  _("Hello World Menu") );
00187 }

Here is the call graph for this function:

Here is the caller graph for this function:

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

Parameters:
-- 
Returns:
--

--------------------------------------------------------------------------

Definition at line 155 of file hello-world/src/menu.c.

References filemodel_get_menu_content(), filemodel_update_pagecounter(), filemodel_window_is_on_top(), ipc_menu_show_menu(), ipc_status_set_stylus(), LOGPRINTF, MENU_MAIN, STYLUS_NONE, and update_category().

Referenced by menu_init(), menu_on_goto_location(), on_file_open(), and on_window_activated().

00156 {
00157     LOGPRINTF("entry");
00158 
00159     // show the main menu
00160     ipc_menu_show_menu( MENU_MAIN );
00161 }

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

const char* GROUP_ACTIONS = "helloworld_actions" [static]

Definition at line 61 of file hello-world/src/menu.c.

Referenced by menu_init(), menu_on_item_activated(), and menu_set_text().

const char* GROUP_VIEWS = "helloworld_view" [static]
const char* ITEM_ACTION_CLOSE = "close" [static]
const char* ITEM_ACTION_COPY = "copy" [static]

Definition at line 69 of file hello-world/src/menu.c.

Referenced by menu_init(), and menu_set_text().

const char* ITEM_ACTION_CUT = "cut" [static]

Definition at line 70 of file hello-world/src/menu.c.

Referenced by menu_init(), and menu_set_text().

const char* ITEM_ACTION_OPEN = "open" [static]

Definition at line 68 of file hello-world/src/menu.c.

Referenced by menu_init(), menu_on_item_activated(), and menu_set_text().

const char* ITEM_ACTION_PASTE = "paste" [static]

Definition at line 71 of file hello-world/src/menu.c.

Referenced by menu_init(), and menu_set_text().

const char* ITEM_VIEW_ICON = "view_small" [static]
const char* ITEM_VIEW_LIST = "view_detail" [static]
const char* MENU_MAIN = "helloworld_menu_main" [static]

Copyright (C) 2009 iRex Technologies B.V. All rights reserved.

Definition at line 56 of file hello-world/src/menu.c.

Referenced by menu_destroy(), menu_init(), menu_set_text(), and menu_show().

const char* STATE_DISABLED = "disabled" [static]
const char* STATE_NORMAL = "normal" [static]

Definition at line 75 of file hello-world/src/menu.c.

Referenced by menu_on_item_activated(), and menu_select_view_type().

const char* STATE_SELECTED = "selected" [static]

Definition at line 76 of file hello-world/src/menu.c.

Referenced by menu_select_view_type().

Generated by  doxygen 1.6.2-20100208