static Ret designer_init(FtkWidget* win) { ftk_widget_set_user_data(win, info_destroy, info_create()); ftk_widget_set_event_listener(win, designer_on_event, win); ftk_app_window_set_on_prepare_options_menu(win, designer_on_prepare_options_menu, win); ftk_widget_show(win, 1); return RET_OK; }
Ret designer_select_file(const char* title, const char* init_path, FtkListener on_select, void* ctx) { int width = 0; int height = 0; int y_offset = 0; Info* info = NULL; FtkWidget* win = NULL; FtkWidget* label = NULL; FtkWidget* entry = NULL; FtkWidget* button = NULL; info = info_create(); return_val_if_fail(info != NULL, RET_FAIL); win = ftk_app_window_create(); ftk_widget_set_user_data(win, info_destroy, info); ftk_widget_set_text(win, title); width = ftk_widget_width(win); height = ftk_widget_height(win); info->on_select = on_select; info->on_select_ctx = ctx; info->init_path = ftk_strdup(init_path); y_offset = height/3 - 30; label = ftk_label_create(win, 0, y_offset, width/5, 30); ftk_widget_set_text(label, _("FileName:")); y_offset = height/3; info->widget_file_name = entry = ftk_entry_create(win, 5, y_offset, width*4/5-2, 30); if(s_last_file[0] == '\0') { ftk_fs_get_cwd(s_last_file); } ftk_widget_set_text(entry, s_last_file); button = ftk_button_create(win, width*4/5, y_offset-5, width/5, 40); ftk_widget_set_text(button, _("...")); ftk_button_set_clicked_listener(button, button_browse_clicked, win); button = ftk_button_create(win, width/5, height-60, width/5, 50); ftk_widget_set_text(button, _("OK")); ftk_button_set_clicked_listener(button, button_ok_clicked, win); button = ftk_button_create(win, width*3/5, height-60, width/5, 50); ftk_widget_set_text(button, _("Cancel")); ftk_button_set_clicked_listener(button, button_cancel_clicked, win); ftk_widget_show_all(win, 1); return RET_OK; }
error tag_cloud_init(void) { if (tag_cloud_refcount == 0) { /* initialise */ LOCALS.main_w = window_create("tag_cloud"); LOCALS.toolbar_w = window_create("tag_cloud_t"); LOCALS.newtag_d = name_create("tag_new"); LOCALS.renametag_d = name_create("tag_rename"); LOCALS.taginfo_d = info_create("tag_info"); info_set_padding(LOCALS.taginfo_d, 128); /* 64 on either side */ } tag_cloud_refcount++; return error_OK; }
static void backup_key_info_handler () { bk_nano.binfo = 1; NhelperTitleBarSetContent(_("Information")); TimerDisable(bk_nano.timer); /* Create Info id */ bk_nano.info_id = info_create(); int* is_running = backup_get_ttsstate(); /* Fill info item */ char* backup_info[1]; char present_info[128]; snprintf(present_info, 128, "%s %f%% %s", _("Backup"), bk_nano.thiz->prog_val, _("completed.")); backup_info[0] = present_info; info_start (bk_nano.info_id, backup_info, 1, is_running); info_destroy (bk_nano.info_id); TimerEnable(bk_nano.timer); NhelperTitleBarSetContent(_("Backup")); NhelperStatusBarSetIcon(SRQST_SET_CATEGORY_ICON, SBAR_CATEGORY_ICON_BACKUP); switch(bk_nano.media) { case 0: NhelperStatusBarSetIcon(SRQST_SET_MEDIA_ICON, SBAR_MEDIA_ICON_INTERNAL_MEM); break; case 1: NhelperStatusBarSetIcon(SRQST_SET_MEDIA_ICON, SBAR_MEDIA_ICON_SD_CARD); break; case 2: NhelperStatusBarSetIcon(SRQST_SET_MEDIA_ICON, SBAR_MEDIA_ICON_USB_MEM); break; } bk_nano.binfo = 0; }