Example #1
0
static int ftk_wnd_manager_get_status_bar_height(FtkWndManager* thiz)
{
	(void)thiz;
	if(ftk_default_status_panel() != NULL)
	{
		return ftk_widget_height(ftk_default_status_panel());
	}
	else
	{
		return 0;
	}
}
Example #2
0
static Ret button_close_top_clicked(void* ctx, void* obj)
{
	FtkWidget* panel = ftk_default_status_panel();
	FtkWidget* title_widget = ftk_widget_lookup(panel, IDC_TITLE_ITEM);
	FtkWidget* top_window = (FtkWidget*)ftk_widget_user_data(title_widget);

	if(top_window != NULL && ftk_widget_type(top_window) == FTK_WINDOW)
	{
		if(!ftk_widget_has_attr(top_window, FTK_ATTR_IGNORE_CLOSE))
		{
			ftk_widget_set_user_data(title_widget, NULL, NULL);
			ftk_logd("%s: close window %s\n", __func__, ftk_widget_get_text(top_window));
			ftk_widget_unref(top_window);
		}
		else
		{
			ftk_logd("%s: the top window has attribute FTK_ATTR_IGNORE_CLOSE\n", __func__);
		}
	}
	else
	{
		ftk_logd("%s: not normal window.\n", __func__);
	}

	return RET_OK;
}
Example #3
0
static int lua_ftk_default_status_panel(lua_State* L)
{
	FtkWidget* retv;
	retv = ftk_default_status_panel();
	tolua_pushusertype(L, (FtkWidget*)retv, "FtkWidget");

	return 1;
}
Example #4
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;
}
Example #5
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;
}
Example #6
0
static Ret _movie_user_on_event(FtkWidget* thiz, FtkEvent* event)
{
	FtkWidget* panel = NULL;

	if (event->type == FTK_EVT_MOUSE_UP)
	{
		system("killall mplayer");
		ftk_widget_invalidate(thiz);

		panel = ftk_default_status_panel();
		if (panel)
			ftk_widget_invalidate(panel);
	}

	return RET_OK;
}
Example #7
0
static Ret desktop_update_time(void* ctx)
{
	char text[10] = {0};
	time_t now = time(0);
	FtkWidget* item = NULL;
	FtkWidget* panel = NULL;
	FtkWidget* win = ctx;
	FtkWidget* image = NULL;
	FtkBitmap* bitmap = NULL;
	char filename[FTK_MAX_PATH] = {0};
	struct tm* t = localtime(&now);

	panel = ftk_default_status_panel();
	if(panel == NULL)
	{
		return RET_REMOVE;
	}

	ftk_snprintf(text, sizeof(text)-1, "%d:%02d", t->tm_hour, t->tm_min);
	item = ftk_widget_lookup(panel, IDC_TIME_ITEM);
	ftk_widget_set_text(item, text);
	ftk_logd("%s\n", __func__);
	
	image = ftk_widget_lookup(win, 1);
	ftk_snprintf(filename, sizeof(filename)-1, "icons/%d.png", t->tm_hour/10);
	bitmap = ftk_icon_cache_load(g_desktop.icon_cache, filename);
	ftk_image_set_image(image, bitmap);
	
	image = ftk_widget_lookup(win, 2);
	ftk_snprintf(filename, sizeof(filename)-1, "icons/%d.png", t->tm_hour%10);
	bitmap = ftk_icon_cache_load(g_desktop.icon_cache, filename);
	ftk_image_set_image(image, bitmap);

	image = ftk_widget_lookup(win, 4);
	ftk_snprintf(filename, sizeof(filename)-1, "icons/%d.png", t->tm_min/10);
	bitmap = ftk_icon_cache_load(g_desktop.icon_cache, filename);
	ftk_image_set_image(image, bitmap);
	
	image = ftk_widget_lookup(win, 5);
	ftk_snprintf(filename, sizeof(filename)-1, "icons/%d.png", t->tm_min%10);
	bitmap = ftk_icon_cache_load(g_desktop.icon_cache, filename);
	ftk_image_set_image(image, bitmap);

	return RET_OK;
}
Example #8
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;
}