Пример #1
0
static int FW_update(const char *file) {
    int ret;
    FtkWidget* wait_box = NULL;
    char buf[64] = { 0, };
    char cmd[100] = {0,};
    printf("file: %s\n", file);
    /*
    snprintf(buf, sizeof(buf), "opkg --noaction install %s", file);
    printf("buf: %s\n", buf);
    ret = system(buf);
    if (ret) {
        return -1;
    }
    */
    wait_box = ftk_widget_lookup(app_wins[APP_WIN_0],WAIT_BOX_ID);
    ftk_widget_show(wait_box, 1);
    ftk_wait_box_start_waiting(wait_box);
	if (access("/opt/PBAPPS/ipks/pb62_1.ipk", F_OK) == 0) {
		printf("pb62 is exist\n");
		sprintf(cmd, "%s", "rm /opt/PBAPPS/ipks/pb62_1.ipk");
		//ftk_wait_box_start_waiting(wait_box);
		ret = system(cmd);
		if (ret) {
			return -1;
		}
	}

	/*
    snprintf(buf, sizeof(buf), "cp %s /opt/PBAPPS/ipks/", file);
    printf("buf: %s\n", buf);
    ret = system(buf);
    if (ret) {
		  return -1;
	  }
    */
    memset(cmd,0,sizeof(cmd));
    sprintf(cmd,"%s %s %s","cp",file,"/opt/PBAPPS/ipks/pb62_1.ipk");
    printf("cmd is %s\n",cmd);

    ret = system(cmd);
    if (ret) {
	   return -1;
    }
    ftk_tips("updating,please wait for some minutes");
    memset(buf,0,sizeof(buf));
    snprintf(buf, sizeof(buf), "opkg install /opt/PBAPPS/ipks/pb62_1.ipk");
    printf("buf: %s\n", buf);
    ret = system(buf);
        if (ret) {
            return -1;
        }
    ftk_wait_box_stop_waiting(wait_box);
    //ftk_widget_remove_child(app_wins[APP_WIN_0], wait_box);
    ftk_widget_show(wait_box, 0);
    //ftk_widget_destroy(wait_box);
    //return 0;
    //system("echo ./ipks/pb62_1.ipk > /etc/.need_update");
    return system("echo ./ipks/pb62_1.ipk > /etc/.need_update");
}
Пример #2
0
static void ftk_init_panel(void)
{
	FtkGc gc;
	FtkWidget* item = NULL;	
	FtkWidget* panel = ftk_status_panel_create(FTK_STATUS_PANEL_HEIGHT);
	size_t width = ftk_widget_width(panel);

	ftk_set_status_panel(panel);
	quit_if_fail(ftk_default_status_panel(), "Init status panel failed.\n");

	memset(&gc, 0x00, sizeof(gc));
	gc.mask   = FTK_GC_BITMAP;
	gc.bitmap = ftk_theme_load_image(ftk_default_theme(), "status-bg"FTK_STOCK_IMG_SUFFIX);
	ftk_widget_set_gc(panel, FTK_WIDGET_NORMAL, &gc);
	ftk_widget_set_gc(panel, FTK_WIDGET_ACTIVE, &gc);
	ftk_widget_set_gc(panel, FTK_WIDGET_FOCUSED, &gc);
	ftk_gc_reset(&gc);
	
	item = ftk_status_item_create(panel, -100, 32);
	ftk_widget_set_id(item, IDC_CLOSE_ITEM);
	gc.bitmap = ftk_theme_load_image(ftk_default_theme(), "close-32"FTK_STOCK_IMG_SUFFIX);
	if(gc.bitmap != NULL)
	{
		gc.mask = FTK_GC_BITMAP;
		ftk_widget_set_gc(item, FTK_WIDGET_NORMAL, &gc);
		ftk_widget_set_gc(item, FTK_WIDGET_FOCUSED, &gc);
		ftk_gc_reset(&gc);
		gc.mask = FTK_GC_BITMAP;
		gc.bitmap = ftk_theme_load_image(ftk_default_theme(), "close-pressed-32"FTK_STOCK_IMG_SUFFIX);
		ftk_widget_set_gc(item, FTK_WIDGET_ACTIVE, &gc);
		ftk_gc_reset(&gc);
	}
	ftk_status_item_set_clicked_listener(item, button_close_top_clicked, NULL);

	gc.bitmap = ftk_theme_load_image(ftk_default_theme(), "flag-32"FTK_STOCK_IMG_SUFFIX);
	item = ftk_status_item_create(panel, 1, gc.bitmap ? min(ftk_bitmap_width(gc.bitmap), 100) : 32);
	ftk_widget_set_id(item, IDC_ICON_ITEM);
	if(gc.bitmap != NULL)
	{
		gc.mask = FTK_GC_BITMAP;
		ftk_widget_set_gc(item, FTK_WIDGET_NORMAL, &gc);
		ftk_widget_set_gc(item, FTK_WIDGET_ACTIVE, &gc);
		ftk_widget_set_gc(item, FTK_WIDGET_FOCUSED, &gc);
		ftk_gc_reset(&gc);
	}
	ftk_widget_show(item, 1);

	item = ftk_status_item_create(panel, 2, width/2);
	ftk_widget_set_id(item, IDC_TITLE_ITEM);
	ftk_widget_show(item, 1);

	ftk_wnd_manager_add_global_listener(ftk_default_wnd_manager(), on_wnd_manager_global_event, NULL);
	ftk_widget_show(panel, 1);
	
	return;
}
Пример #3
0
static Ret ftk_bluetooth_on_prepare_options_menu(void* ctx, FtkWidget* menu_panel)
{
	FtkWidget* item = ftk_menu_item_create(menu_panel);
	ftk_widget_set_text(item, _("검색"));
	ftk_menu_item_set_clicked_listener(item, ftk_bluetooth_on_scan, ctx);
	ftk_widget_show(item, 1);

	item = ftk_menu_item_create(menu_panel);
	ftk_widget_set_text(item, _("Quit"));
	ftk_menu_item_set_clicked_listener(item, ftk_bluetooth_on_shutdown, ctx);
	ftk_widget_show(item, 1);

	return RET_OK;
}
Пример #4
0
static Ret designer_on_duplicate(void* ctx, void* item)
{
	FtkWidget* widget = NULL;
	FtkWidget* win = (FtkWidget*)ctx;
	const WidgetInfo* widget_info = NULL; 
	Info* info = (Info*)ftk_widget_user_data(win);
	
	if(!designer_has_selected_widget(win))
	{
		return RET_OK;
	}

	widget_info = widgets_info_find_by_type(ftk_widget_type(info->selected_widget));
	return_val_if_fail(widget_info != NULL, RET_FAIL);

	if(widget_info->is_leaf_widget)
	{
		widget = widget_info->create(
			ftk_widget_parent(info->selected_widget),
			ftk_widget_left(info->selected_widget),
			ftk_widget_top(info->selected_widget) + ftk_widget_height(info->selected_widget),
			ftk_widget_width(info->selected_widget),
			ftk_widget_height(info->selected_widget));
		ftk_widget_set_text(widget, ftk_widget_get_text(info->selected_widget));
		ftk_widget_show(widget, 1);
		ftk_widget_ref(widget);
		/*TODO: duplicate listview/combobox/iconview*/
	}

	return RET_OK;
}
Пример #5
0
static Ret button_start_clicked(void* ctx, void* obj)
{
    ftk_widget_show(ctx, 1);
    ftk_wait_box_start_waiting(ctx);

    return RET_OK;
}
Пример #6
0
static Ret ftk_file_browser_on_prepare_options_menu_for_choose(void* ctx, FtkWidget* menu_panel)
{
	FtkWidget* item = NULL;
	
	item = ftk_menu_item_create(menu_panel);
	ftk_widget_set_text(item, _("OK"));
	ftk_menu_item_set_clicked_listener(item, ftk_file_browser_on_ok, ctx);
	ftk_widget_show(item, 1);
	
	item = ftk_menu_item_create(menu_panel);
	ftk_widget_set_text(item, _("Cancel"));
	ftk_menu_item_set_clicked_listener(item, ftk_file_browser_on_cancel, ctx);
	ftk_widget_show(item, 1);

	return	RET_OK;
}
Пример #7
0
static Ret desktop_on_button_close_applist_clicked(void* ctx, void* obj)
{
	ftk_main_loop_add_source(ftk_default_main_loop(), g_timer);

	desktop_update_time(_win);
	ftk_widget_show(ctx, 0);

	return RET_OK;
}
Пример #8
0
int main(int argc, char* argv[])
{
	int i = 0;
	int j = 0;
	int width = 0;
	int height = 0;
	FtkGc gc = {0};
	FtkWidget* win = NULL;
	FtkWidget* button = NULL;
	ftk_init(argc, argv);

	width = ftk_display_width(ftk_default_display());
	height = ftk_display_height(ftk_default_display());
	gc.mask = FTK_GC_BITMAP;
	win = ftk_window_create(0, 0, width, height);

	for(i = 0; i < height/80; i++)
	{
		for(j = 0; j < width/80; j++)
		{
			gc.bitmap = ftk_bitmap_factory_load(ftk_default_bitmap_factory(), pngs[i + 1]);
			button = ftk_button_create(1000, j * 80, i * 80, ftk_bitmap_width(gc.bitmap), ftk_bitmap_height(gc.bitmap));
			ftk_widget_set_gc(button, FTK_WIDGET_NORMAL, &gc);
			ftk_widget_set_gc(button, FTK_WIDGET_FOCUSED, &gc);
			ftk_widget_append_child(win, button);
			ftk_widget_show(button, 1);
			ftk_bitmap_unref(gc.bitmap);

			if(i == 0 && j == 0)
			{
				ftk_button_set_clicked_listener(button, button_clicked, NULL);
				ftk_button_set_text(button, "Quit");
			}
		}
	}

	ftk_window_set_title(win, "button demo");
	ftk_widget_show(win, 1);

	ftk_run();

	return 0;
}
Пример #9
0
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;
}
Пример #10
0
static Ret ftk_file_browser_on_prepare_options_menu(void* ctx, FtkWidget* menu_panel)
{
	FtkWidget* item = ftk_menu_item_create(menu_panel);
	ftk_widget_set_text(item, _("Remove"));
	ftk_menu_item_set_clicked_listener(item, ftk_file_browser_on_remove, ctx);
	ftk_widget_show(item, 1);
	
	item = ftk_menu_item_create(menu_panel);
	ftk_widget_set_text(item, _("Rename"));
	ftk_menu_item_set_clicked_listener(item, ftk_file_browser_on_rename, ctx);
	ftk_widget_show(item, 1);
	
	item = ftk_menu_item_create(menu_panel);
	ftk_widget_set_text(item, _("Create Folder"));
	ftk_menu_item_set_clicked_listener(item, ftk_file_browser_on_create_folder, ctx);
	ftk_widget_show(item, 1);
	
	item = ftk_menu_item_create(menu_panel);
	ftk_widget_set_text(item, _("Detail"));
	ftk_menu_item_set_clicked_listener(item, ftk_file_browser_on_detail, ctx);
	ftk_widget_show(item, 1);
	
	item = ftk_menu_item_create(menu_panel);
	ftk_widget_set_text(item, _("Quit"));
	ftk_menu_item_set_clicked_listener(item, ftk_file_browser_on_quit, ctx);
	ftk_widget_show(item, 1);
	
	item = ftk_menu_item_create(menu_panel);
	ftk_widget_set_text(item, _("More"));
	ftk_menu_item_set_clicked_listener(item, ftk_file_browser_on_more, ctx);
	ftk_widget_show(item, 1);

	return	RET_OK;
}
Пример #11
0
static Ret on_prepare_options_menu(void* ctx, FtkWidget* menu_panel)
{
	int i = 0;
	for(i = 0; i < 3; i++)
	{
		char text[32] = {0};
		FtkWidget* item = ftk_menu_item_create(menu_panel);
		ftk_snprintf(text, sizeof(text), "Menu%02d", i);
		ftk_widget_set_text(item, text);
		ftk_widget_show(item, 1);
	}

	return i > 0 ? RET_OK : RET_FAIL;
}
Пример #12
0
static Ret desktop_on_prepare_options_menu(void* ctx, FtkWidget* menu_panel)
{
	FtkWidget* item = ftk_menu_item_create(menu_panel);
	ftk_widget_set_text(item, _("Shutdown"));
	ftk_menu_item_set_clicked_listener(item, desktop_on_shutdown, ctx);
	ftk_widget_show(item, 1);

#ifdef USE_VNC
	item = ftk_menu_item_create(menu_panel);
	if(ftk_display_vnc_is_active())
	{
		ftk_widget_set_text(item, _("Stop VNC"));
	}
	else
	{
		ftk_widget_set_text(item, _("Start VNC"));
	}
	ftk_menu_item_set_clicked_listener(item, desktop_on_vnc, ctx);
	ftk_widget_show(item, 1);
#endif

	return	RET_OK;
}
Пример #13
0
static Ret desktop_add_time_item_on_statusbar(void)
{
	FtkWidget* item = NULL;
	FtkWidget* panel = NULL;

	panel = ftk_default_status_panel();
	if(panel != NULL)
	{
		item = ftk_status_item_create(panel, -2, 60);
		ftk_widget_set_id(item, IDC_TIME_ITEM);
		ftk_widget_show(item, 1);
	}

	ftk_logd("%s\n", __func__);
	return RET_OK;
}
Пример #14
0
static Ret designer_on_prepare_options_menu(void* ctx, FtkWidget* menu_panel)
{
	size_t i = 0;
	FtkWidget* item = NULL;
	FtkWidget* win = (FtkWidget*)ctx;

	for(i = 0; i < FTK_ARRAY_SIZE(s_menu_items); i++)	
	{
		item = ftk_menu_item_create(menu_panel);
		ftk_widget_set_text(item, _(s_menu_items[i].name));
		ftk_menu_item_set_clicked_listener(item, s_menu_items[i].on_clicked, win);
		ftk_widget_show(item, 1);
	}
	
	return RET_OK;
}
Пример #15
0
static Ret  ftk_menu_panel_on_event(FtkWidget* thiz, FtkEvent* event)
{
	Ret ret = RET_OK;
	DECL_PRIV1(thiz, priv);

	if(event->type == FTK_EVT_KEY_UP && event->u.key.code == FTK_KEY_MENU)
	{
		ftk_widget_unref(thiz);

		return ret;
	}

	if(event->type == FTK_EVT_SHOW)
	{
		ftk_wnd_manager_grab(ftk_default_wnd_manager(), thiz);
	}
	
	if(event->type == FTK_EVT_HIDE)
	{
		ftk_wnd_manager_ungrab(ftk_default_wnd_manager(), thiz);
	}
	
	if((event->type == FTK_EVT_MOUSE_UP && ret != RET_IGNORED)
		|| (event->type == FTK_EVT_KEY_UP && FTK_IS_ACTIVE_KEY(event->u.key.code)))
	{
		ftk_widget_show(thiz, 0);
	}

	ret = priv->parent_on_event(thiz, event);

	if((event->type == FTK_EVT_MOUSE_UP && ret != RET_IGNORED)
		|| (event->type == FTK_EVT_KEY_UP && FTK_IS_ACTIVE_KEY(event->u.key.code)))
	{
		ftk_widget_unref(thiz);
	}

	return ret;
}
Пример #16
0
static Ret desktop_on_button_close_applist_clicked(void* ctx, void* obj)
{
	ftk_widget_show(ctx, 0);

	return RET_OK;
}
Пример #17
0
static Ret on_wnd_manager_global_event(void* ctx, void* obj)
{
	Ret ret = RET_OK;
	FtkEvent* event = (FtkEvent*)obj;
	FtkWidget* panel = NULL;
	FtkWidget* top_window = NULL;
	FtkWidget* close_widget = NULL;
	FtkWidget* title_widget = NULL;

	if(event->type != FTK_EVT_TOP_WND_CHANGED
		&& event->type != FTK_EVT_WND_CONFIG_CHANGED)
	{
		return RET_OK;
	}

	if(ftk_widget_type((FtkWidget*)event->widget) != FTK_WINDOW)
	{
		return RET_OK;
	}

	panel = ftk_default_status_panel();
	close_widget = ftk_widget_lookup(panel, IDC_CLOSE_ITEM);
	title_widget = ftk_widget_lookup(panel, IDC_TITLE_ITEM);
	switch(event->type)
	{
		case FTK_EVT_TOP_WND_CHANGED:
		{
			top_window = (FtkWidget*)event->widget;

			if(top_window != NULL)
			{
				ftk_widget_set_text(title_widget, ftk_widget_get_text(top_window));
				ftk_logd("top_window changed: %s\n", ftk_widget_get_text(top_window));
			}
			else
			{
				ftk_widget_set_text(title_widget, NULL);
			}
			ftk_widget_set_user_data(title_widget, NULL, top_window);
			ret = RET_REMOVE;

			break;
		}
		case FTK_EVT_WND_CONFIG_CHANGED:
		{
			top_window = (FtkWidget*)ftk_widget_user_data(title_widget);
			if(top_window == event->widget)
			{
				ftk_widget_set_text(title_widget, ftk_widget_get_text(top_window));
			}
			
			ftk_logd("%s: config changed: %p %p\n", __func__, top_window, event->widget);
			ret = RET_REMOVE;
			break;
		}
		default:break;
	}

	if(top_window != NULL && close_widget != NULL)
	{
		ftk_widget_show(close_widget, !ftk_widget_has_attr(top_window, FTK_ATTR_IGNORE_CLOSE));
	}

	return ret;
}