+ for ( i = 0; i < g_categorycount; i++ ) {
+ free ( labels [ i ] );
+ }
+
+ return;
+}
+
+void ui_recache_context ( ui_context_t *c ) {
+
+ c -> screen_width = pnd_conf_get_as_int_d ( g_conf, "display.screen_width", 800 );
+
+ c -> font_rgba_r = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_r", 200 );
+ c -> font_rgba_g = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_g", 200 );
+ c -> font_rgba_b = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_b", 200 );
+ c -> font_rgba_a = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_a", 100 );
+
+ c -> grid_offset_x = pnd_conf_get_as_int ( g_conf, "grid.grid_offset_x" );
+ c -> grid_offset_y = pnd_conf_get_as_int ( g_conf, "grid.grid_offset_y" );
+
+ c -> icon_offset_x = pnd_conf_get_as_int ( g_conf, "grid.icon_offset_x" );
+ c -> icon_offset_y = pnd_conf_get_as_int ( g_conf, "grid.icon_offset_y" );
+ c -> icon_max_width = pnd_conf_get_as_int ( g_conf, "grid.icon_max_width" );
+ c -> icon_max_height = pnd_conf_get_as_int ( g_conf, "grid.icon_max_height" );
+ c -> sel_icon_offset_x = pnd_conf_get_as_int_d ( g_conf, "grid.sel_offoffset_x", 0 );
+ c -> sel_icon_offset_y = pnd_conf_get_as_int_d ( g_conf, "grid.sel_offoffset_y", 0 );
+
+ c -> text_width = pnd_conf_get_as_int ( g_conf, "grid.text_width" );
+ c -> text_clip_x = pnd_conf_get_as_int ( g_conf, "grid.text_clip_x" );
+ c -> text_offset_x = pnd_conf_get_as_int ( g_conf, "grid.text_offset_x" );
+ c -> text_offset_y = pnd_conf_get_as_int ( g_conf, "grid.text_offset_y" );
+ c -> text_hilite_offset_y = pnd_conf_get_as_int ( g_conf, "grid.text_hilite_offset_y" );
+
+ c -> row_max = pnd_conf_get_as_int_d ( g_conf, "grid.row_max", 4 );
+ c -> col_max = pnd_conf_get_as_int_d ( g_conf, "grid.col_max", 5 );
+
+ c -> cell_width = pnd_conf_get_as_int ( g_conf, "grid.cell_width" );
+ c -> cell_height = pnd_conf_get_as_int ( g_conf, "grid.cell_height" );
+
+ c -> arrow_bar_x = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_bar_x", 450 );
+ c -> arrow_bar_y = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_bar_y", 100 );
+ c -> arrow_bar_clip_w = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_bar_clip_w", 10 );
+ c -> arrow_bar_clip_h = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_bar_clip_h", 100 );
+ c -> arrow_up_x = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_up_x", 450 );
+ c -> arrow_up_y = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_up_y", 80 );
+ c -> arrow_down_x = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_down_x", 450 );
+ c -> arrow_down_y = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_down_y", 80 );
+
+ // font colour
+ SDL_Color tmp = { c -> font_rgba_r, c -> font_rgba_g, c -> font_rgba_b, c -> font_rgba_a };
+ c -> fontcolor = tmp;
+
+ // now that we've got 'normal' (detail pane shown) param's, lets check if detail pane
+ // is hidden; if so, override some values with those alternate skin values where possible.
+ if ( ui_detail_hidden ) {
+ // if detail panel is hidden, and theme cannot support it, unhide the bloody thing. (This may help
+ // when someone is amid theme hacking or changing.)
+ if ( ! ui_is_detail_hideable() ) {
+ ui_detail_hidden = 0;
+ }
+
+ // still hidden?
+ if ( ui_detail_hidden ) {
+
+ c -> row_max = pnd_conf_get_as_int_d ( g_conf, "grid.row_max_w", c -> row_max );
+ c -> col_max = pnd_conf_get_as_int_d ( g_conf, "grid.col_max_w", c -> col_max );
+
+ c -> cell_width = pnd_conf_get_as_int_d ( g_conf, "grid.cell_width_w", c -> cell_width );
+ c -> cell_height = pnd_conf_get_as_int_d ( g_conf, "grid.cell_height_w", c -> cell_height );
+
+ c -> arrow_bar_x = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_bar_x_w", 450 );
+ c -> arrow_bar_y = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_bar_y_w", 100 );
+ c -> arrow_up_x = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_up_x_w", 450 );
+ c -> arrow_up_y = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_up_y_w", 80 );
+ c -> arrow_down_x = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_down_x_w", 450 );
+ c -> arrow_down_y = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_down_y_w", 80 );
+
+ } // if detail hidden.. still.
+
+ } // if detail hidden
+
+ return;
+}
+
+unsigned char ui_is_detail_hideable ( void ) {
+
+ // if skin has a bit of info for wide-mode, we assume wide-mode is available
+ if ( pnd_conf_get_as_char ( g_conf, "grid.row_max_w" ) != NULL ) {
+ return ( 1 );
+ }
+
+ // else not!
+ return ( 0 );
+}
+
+void ui_toggle_detail_pane ( void ) {
+
+ // no bitmask trickery here; I like it to be stand-out obvious at 3am.
+
+ if ( ui_detail_hidden ) {
+ ui_detail_hidden = 0;
+ } else {
+ ui_detail_hidden = 1;
+ }
+
+ // repull skin config
+ ui_recache_context ( &ui_display_context );
+
+ // redraw
+ render_mask |= CHANGED_EVERYTHING;
+
+ return;
+}
+
+void ui_menu_context ( mm_appref_t *a ) {
+
+ unsigned char rescan_apps = 0;
+ unsigned char context_alive = 1;
+
+ enum {
+ context_done = 0,
+ context_file_info,
+ context_file_delete,
+ context_app_info,
+ context_app_hide,
+ context_app_recategorize,
+ context_app_recategorize_sub,
+ context_app_rename,
+ context_app_cpuspeed,
+ context_app_run,
+ context_menu_max
+ };
+
+ char *verbiage[] = {
+ "Done (return to grid)", // context_done
+ "Get info about file/dir", // context_file_info
+ "Delete file/dir", // context_file_delete
+ "Get info", // context_app_info
+ "Hide application", // hide
+ "Recategorize", // recategorize
+ "Recategorize subcategory", // recategorize
+ "Change displayed title", // rename
+ "Set CPU speed for launch", // cpuspeed
+ "Run application" // run
+ };
+
+ unsigned short int menu [ context_menu_max ];
+ char *menustring [ context_menu_max ];
+ unsigned char menumax = 0;
+
+ // ++ done
+ menu [ menumax ] = context_done; menustring [ menumax++ ] = verbiage [ context_done ];
+
+ // hook up appropriate menu options based on tab-type and object-type
+ if ( g_categories [ ui_category ] -> fspath ) {
+ return; // TBD
+ menu [ menumax ] = context_file_info; menustring [ menumax++ ] = verbiage [ context_file_info ];
+ menu [ menumax ] = context_file_delete; menustring [ menumax++ ] = verbiage [ context_file_delete ];
+ } else {
+ //menu [ menumax ] = context_app_info; menustring [ menumax++ ] = verbiage [ context_app_info ];
+ menu [ menumax ] = context_app_hide; menustring [ menumax++ ] = verbiage [ context_app_hide ];
+ menu [ menumax ] = context_app_recategorize; menustring [ menumax++ ] = verbiage [ context_app_recategorize ];
+ menu [ menumax ] = context_app_recategorize_sub; menustring [ menumax++ ] = verbiage [ context_app_recategorize_sub ];
+ menu [ menumax ] = context_app_rename; menustring [ menumax++ ] = verbiage [ context_app_rename ];
+ menu [ menumax ] = context_app_cpuspeed; menustring [ menumax++ ] = verbiage [ context_app_cpuspeed ];
+ menu [ menumax ] = context_app_run; menustring [ menumax++ ] = verbiage [ context_app_run ];
+ }
+
+ // operate the menu
+ while ( context_alive ) {
+
+ int sel = ui_modal_single_menu ( menustring, menumax, a -> ref -> title_en ? a -> ref -> title_en : "Quickpick Menu" /* title */, "B or Enter; other to cancel." /* footer */ );
+
+ if ( sel < 0 ) {
+ context_alive = 0;
+
+ } else {
+
+ switch ( menu [ sel ] ) {
+
+ case context_done:
+ context_alive = 0;
+ break;
+
+ case context_file_info:
+ break;
+
+ case context_file_delete:
+ //ui_menu_twoby ( "Delete - Are you sure?", "B/enter; other to cancel", "Delete", "Do not delete" );
+ break;
+
+ case context_app_info:
+ break;
+
+ case context_app_hide:
+ {
+ // determine key
+ char confkey [ 1000 ];
+ snprintf ( confkey, 999, "%s.%s", "appshow", a -> ref -> unique_id );
+
+ // turn app 'off'
+ pnd_conf_set_char ( g_conf, confkey, "0" );
+
+ // write conf, so it will take next time
+ conf_write ( g_conf, conf_determine_location ( g_conf ) );
+
+ // request rescan and wrap up
+ rescan_apps++;
+ context_alive = 0; // nolonger visible, so lets just get out
+
+ }
+
+ break;
+
+ case context_app_recategorize:
+ {
+ char *opts [ 250 ];
+ unsigned char optmax = 0;
+ unsigned char i;
+
+ i = 0;
+ while ( 1 ) {
+
+ if ( ! freedesktop_complete [ i ].cat ) {
+ break;
+ }
+
+ if ( ! freedesktop_complete [ i ].parent_cat ) {
+ opts [ optmax++ ] = freedesktop_complete [ i ].cat;
+ }
+
+ i++;
+ } // while
+
+ char prompt [ 101 ];
+ snprintf ( prompt, 100, "Pick category [%s]", a -> ref -> main_category ? a -> ref -> main_category : "NoParentCategory" );
+
+ int sel = ui_modal_single_menu ( opts, optmax, prompt /*"Select parent category"*/, "Enter to select; other to skip." );
+
+ if ( sel >= 0 ) {
+ char confirm [ 1001 ];
+ snprintf ( confirm, 1000, "Confirm: %s", opts [ sel ] );
+
+ if ( ui_menu_twoby ( confirm, "B/enter; other to cancel", "Confirm categorization", "Do not set category" ) == 1 ) {
+ ovr_replace_or_add ( a, "maincategory", opts [ sel ] );
+ rescan_apps++;
+ }
+
+ }
+
+ }
+ break;
+
+ case context_app_recategorize_sub:
+ {
+ char *opts [ 250 ];
+ unsigned char optmax = 0;
+ unsigned char i;
+
+ i = 0;
+ while ( 1 ) {
+
+ if ( ! freedesktop_complete [ i ].cat ) {
+ break;
+ }
+
+ if ( freedesktop_complete [ i ].parent_cat ) {
+ opts [ optmax++ ] = freedesktop_complete [ i ].cat;
+ }
+
+ i++;
+ } // while
+
+ char prompt [ 101 ];
+ snprintf ( prompt, 100, "Pick subcategory [%s]", a -> ref -> main_category1 ? a -> ref -> main_category1 : "NoSubcategory" );
+
+ int sel = ui_modal_single_menu ( opts, optmax, prompt /*"Select subcategory"*/, "Enter to select; other to skip." );
+
+ if ( sel >= 0 ) {
+ char confirm [ 1001 ];
+ snprintf ( confirm, 1000, "Confirm: %s", opts [ sel ] );
+
+ if ( ui_menu_twoby ( confirm, "B/enter; other to cancel", "Confirm sub-categorization", "Do not set sub-category" ) == 1 ) {
+ ovr_replace_or_add ( a, "maincategorysub1", opts [ sel ] );
+ rescan_apps++;
+ }
+
+ }
+
+ }
+ break;
+
+ case context_app_rename:
+ {
+ char namebuf [ 101 ];
+ unsigned char changed;
+
+ changed = ui_menu_get_text_line ( "Rename application", "Use keyboard; Enter when done.",
+ a -> ref -> title_en ? a -> ref -> title_en : "blank", namebuf, 30, 0 /* alphanumeric */ );
+
+ if ( changed ) {
+ char confirm [ 1001 ];
+ snprintf ( confirm, 1000, "Confirm: %s", namebuf );
+
+ if ( ui_menu_twoby ( confirm, "B/enter; other to cancel", "Confirm rename", "Do not rename" ) == 1 ) {
+ ovr_replace_or_add ( a, "title", namebuf );
+ rescan_apps++;
+ }
+
+ }
+
+ }
+
+ break;
+
+ case context_app_cpuspeed:
+ {
+ char namebuf [ 101 ];
+ unsigned char changed;
+
+ changed = ui_menu_get_text_line ( "Specify runspeed", "Use keyboard; Enter when done.",
+ a -> ref -> clockspeed ? a -> ref -> clockspeed : "500", namebuf, 6, 1 /* numeric */ );
+
+ if ( changed ) {
+ char confirm [ 1001 ];
+ snprintf ( confirm, 1000, "Confirm: %s", namebuf );
+
+ if ( ui_menu_twoby ( confirm, "B/enter; other to cancel", "Confirm clockspeed", "Do not set" ) == 1 ) {
+ ovr_replace_or_add ( a, "clockspeed", namebuf );
+ rescan_apps++;
+ }
+
+ }
+
+ }
+
+ break;
+
+ case context_app_run:
+ ui_push_exec();
+ break;
+
+ default:
+ return;
+
+ } // switch
+
+ } // if useful return
+
+ } // menu is alive?
+
+ // rescan apps?
+ if ( rescan_apps ) {
+ applications_free();
+ applications_scan();
+ }
+