示例#1
0
static gboolean
cmdline_icon_pixbuf (const gchar    *option,
                     const gchar    *value,
                     struct config  *cfg,
                     GError        **error)
{
    StatusNotifierIcon icon;
    GdkPixbuf *pixbuf;

    if (streq (option, "-I") || streq (option, "--pixbuf"))
        icon = STATUS_NOTIFIER_ICON;
    else if (streq (option, "-A") || streq (option, "--attention-pixbuf"))
        icon = STATUS_NOTIFIER_ATTENTION_ICON;
    else if (streq (option, "-O") || streq (option, "--overlay-pixbuf"))
        icon = STATUS_NOTIFIER_OVERLAY_ICON;
    else /* if (streq (option, "-L") || streq (option, "--tooltip-pixbuf")) */
        icon = STATUS_NOTIFIER_TOOLTIP_ICON;

    pixbuf = gdk_pixbuf_new_from_file (value, error);
    if (!pixbuf)
    {
        g_prefix_error (error, "Failed to load pixbuf from '%s': ", value);
        return FALSE;
    }

    free_icon (cfg, icon);
    cfg->icon[icon].pixbuf = pixbuf;
    cfg->icon[icon].has_pixbuf = TRUE;
    return TRUE;
}
示例#2
0
static void elemstyle_free(elemstyle_t *elemstyle) {
  elemstyle_condition_t *cond;
  for (cond = elemstyle->condition; cond;) {
    if(cond->key)   xmlFree(cond->key);
    if(cond->value) xmlFree(cond->value);
    elemstyle_condition_t *prevcond = cond;
    cond = cond->next;
    g_free(prevcond);
  }

  switch(elemstyle->type) {
  case ES_TYPE_NONE:
    break;
  case ES_TYPE_LINE:
    free_line(elemstyle->line);
    break;
  case ES_TYPE_AREA:
    free_area(elemstyle->area);
    break;
  case ES_TYPE_LINE_MOD:
    free_line_mod(elemstyle->line_mod);
    break;
  }
  if(elemstyle->icon) free_icon(elemstyle->icon);
  g_free(elemstyle);
}
示例#3
0
void Widget_CheckBox::addedToWindowEvent(WidgetAddedToWindowEvent* event)
{
    if(g_check_texture_user_count == 0)
    {
        IconColors ic;
        Image* img = get_icon(IconName::Check, 16, &ic);
        g_check_texture = event->textureManager()->newTexture(img);
        free_icon(&img);
    }
    g_check_texture_user_count++;
}
示例#4
0
void cleanup_launcher_theme(Launcher *launcher)
{
	free_area(&launcher->area);
	GSList *l;
	for (l = launcher->list_icons; l ; l = l->next) {
		LauncherIcon *launcherIcon = (LauncherIcon*)l->data;
		if (launcherIcon) {
			free_icon(launcherIcon->icon_scaled);
			free_icon(launcherIcon->icon_original);
			free(launcherIcon->icon_name);
			free(launcherIcon->icon_path);
			free(launcherIcon->cmd);
			free(launcherIcon->icon_tooltip);
		}
		free(launcherIcon);
	}
	g_slist_free(launcher->list_icons);
	launcher->list_icons = NULL;

	free_themes(launcher->list_themes);
	launcher->list_themes = NULL;
}
示例#5
0
static gboolean
cmdline_icon_name (const gchar      *option,
                   const gchar      *value,
                   struct config    *cfg,
                   GError          **error)
{
    StatusNotifierIcon icon;

    if (streq (option, "-i") || streq (option, "--icon"))
        icon = STATUS_NOTIFIER_ICON;
    else if (streq (option, "-a") || streq (option, "--attention-icon"))
        icon = STATUS_NOTIFIER_ATTENTION_ICON;
    else if (streq (option, "-o") || streq (option, "--overlay-icon"))
        icon = STATUS_NOTIFIER_OVERLAY_ICON;
    else /* if (streq (option, "-l") || streq (option, "--tooltip-icon")) */
        icon = STATUS_NOTIFIER_TOOLTIP_ICON;

    free_icon (cfg, icon);
    cfg->icon[icon].icon_name = g_strdup (value);
    return TRUE;
}
示例#6
0
int open_window( GlobalFunc *global )
{
   int i;

   natorder = native_order();

   msgf    = global( LWMESSAGEFUNCS_GLOBAL, GFUSE_TRANSIENT );
   filereq = global( LWFILEREQFUNC_GLOBAL,  GFUSE_TRANSIENT );
   rasf    = global( LWRASTERFUNCS_GLOBAL,  GFUSE_TRANSIENT );
   panf    = global( LWPANELFUNCS_GLOBAL,   GFUSE_TRANSIENT );
   if ( !msgf || !filereq || !rasf || !panf )
      return AFUNC_BADGLOBAL;

   panf->globalFun = global;

   if( !( panel = PAN_CREATE( panf, PANEL_TITLE ))) {
      msgf->error( PLUGIN_NAME " couldn't create its panel,", "not sure why." );
      return AFUNC_OK;
   }

   panf->set( panel, PAN_USERKEYS, handle_key );
   panf->set( panel, PAN_USEROPEN, handle_panopen );

   cras[ 0 ] = create_char( COLOR_WHITE, SYSTEM_Ic( 30 ), rasf );
   cras[ 1 ] = create_char( COLOR_BLACK, SYSTEM_Ic(  2 ), rasf );
   cras[ 2 ] = create_char( COLOR_BLACK, SYSTEM_Ic( 15 ), rasf );

   create_controls();
   panf->open( panel, PANF_BLOCKING );

   PAN_KILL( panf, panel );

   for ( i = 0; i < 3; i++ )
      free_char( cras[ i ], rasf );
   free_icon( rasf );

   return AFUNC_OK;
}
示例#7
0
int resize_launcher(void *obj)
{
	Launcher *launcher = obj;
	GSList *l;
	int count, icon_size;
	int icons_per_column=1, icons_per_row=1, marging=0;

	if (panel_horizontal) {
		icon_size = launcher->area.height;
	} else {
		icon_size = launcher->area.width;
	}
	icon_size = icon_size - (2 * launcher->area.bg->border.width) - (2 * launcher->area.paddingy);
	if (launcher_max_icon_size > 0 && icon_size > launcher_max_icon_size)
		icon_size = launcher_max_icon_size;

	// Resize icons if necessary
	for (l = launcher->list_icons; l ; l = l->next) {
		LauncherIcon *launcherIcon = (LauncherIcon *)l->data;
		if (launcherIcon->icon_size != icon_size || !launcherIcon->icon_original) {
			launcherIcon->icon_size = icon_size;
			launcherIcon->area.width = launcherIcon->icon_size;
			launcherIcon->area.height = launcherIcon->icon_size;

			// Get the path for an icon file with the new size
			char *new_icon_path = get_icon_path(launcher->list_themes, launcherIcon->icon_name, launcherIcon->icon_size);
			if (!new_icon_path) {
				// Draw a blank icon
				free_icon(launcherIcon->icon_original);
				launcherIcon->icon_original = NULL;
				free_icon(launcherIcon->icon_scaled);
				launcherIcon->icon_scaled = NULL;
				continue;
			}
			if (launcherIcon->icon_path && strcmp(new_icon_path, launcherIcon->icon_path) == 0) {
				// If it's the same file just rescale
				free_icon(launcherIcon->icon_scaled);
				launcherIcon->icon_scaled = scale_icon(launcherIcon->icon_original, icon_size);
				free(new_icon_path);
				fprintf(stderr, "launcher.c %d: Using icon %s\n", __LINE__, launcherIcon->icon_path);
			} else {
				// Free the old files
				free_icon(launcherIcon->icon_original);
				free_icon(launcherIcon->icon_scaled);
				launcherIcon->icon_original = launcherIcon->icon_scaled = NULL;
				// Load the new file and scale
#ifdef HAVE_RSVG
				if (g_str_has_suffix(new_icon_path, ".svg")) {
					GError* err = NULL;
					RsvgHandle* svg = rsvg_handle_new_from_file(new_icon_path, &err);

					if (err != NULL) {
						fprintf(stderr, "Could not load svg image!: %s", err->message);
						g_error_free(err);
						launcherIcon->icon_original = NULL;
					} else {
						char suffix[128];
						sprintf(suffix, "tmpicon-%d.png", getpid());
						gchar *name = g_build_filename(g_get_user_config_dir(), "tint2", suffix, NULL);
						GdkPixbuf *pixbuf = rsvg_handle_get_pixbuf(svg);
						gdk_pixbuf_save(pixbuf, name, "png", NULL, NULL);
						launcherIcon->icon_original = imlib_load_image_immediately_without_cache(name);
						g_remove(name);
						g_free(name);
						g_object_unref(G_OBJECT(pixbuf));
						g_object_unref(G_OBJECT(svg));
					}
				} else
#endif
				{
					launcherIcon->icon_original = imlib_load_image_immediately(new_icon_path);
				}
				// On loading error, fallback to default
				if (!launcherIcon->icon_original) {
					free(new_icon_path);
					new_icon_path = get_icon_path(launcher->list_themes, DEFAULT_ICON, launcherIcon->icon_size);
					if (new_icon_path)
						launcherIcon->icon_original = imlib_load_image_immediately(new_icon_path);
				}

				if (!launcherIcon->icon_original) {
					// Loading default icon failed, draw a blank icon
					free(new_icon_path);
				} else {
					// Loaded icon successfully
					launcherIcon->icon_scaled = scale_icon(launcherIcon->icon_original, launcherIcon->icon_size);
					free(launcherIcon->icon_path);
					launcherIcon->icon_path = new_icon_path;
					fprintf(stderr, "launcher.c %d: Using icon %s\n", __LINE__, launcherIcon->icon_path);
				}
			}
		}
	}
	
	count = g_slist_length(launcher->list_icons);

	if (panel_horizontal) {
		if (!count) {
			launcher->area.width = 0;
		} else {
			int height = launcher->area.height - 2*launcher->area.bg->border.width - 2*launcher->area.paddingy;
			// here icons_per_column always higher than 0
			icons_per_column = (height+launcher->area.paddingx) / (icon_size+launcher->area.paddingx);
			marging = height - (icons_per_column-1)*(icon_size+launcher->area.paddingx) - icon_size;
			icons_per_row = count / icons_per_column + (count%icons_per_column != 0);
			launcher->area.width = (2 * launcher->area.bg->border.width) +
								   (2 * launcher->area.paddingxlr) +
								   (icon_size * icons_per_row) +
								   ((icons_per_row-1) * launcher->area.paddingx);
		}
	}
	else {
		if (!count) {
			launcher->area.height = 0;
		} else {
			int width = launcher->area.width - 2*launcher->area.bg->border.width - 2*launcher->area.paddingy;
			// here icons_per_row always higher than 0
			icons_per_row = (width+launcher->area.paddingx) / (icon_size+launcher->area.paddingx);
			marging = width - (icons_per_row-1)*(icon_size+launcher->area.paddingx) - icon_size;
			icons_per_column = count / icons_per_row+ (count%icons_per_row != 0);
			launcher->area.height = (2 * launcher->area.bg->border.width) +
									(2 * launcher->area.paddingxlr) +
									(icon_size * icons_per_column) +
									((icons_per_column-1) * launcher->area.paddingx);
		}
	}

	int i, posx, posy;
	int start = launcher->area.bg->border.width + launcher->area.paddingy + marging/2;
	if (panel_horizontal) {
		posy = start;
		posx = launcher->area.bg->border.width + launcher->area.paddingxlr;
	} else {
		posx = start;
		posy = launcher->area.bg->border.width + launcher->area.paddingxlr;
	}

	for (i=1, l = launcher->list_icons; l ; i++, l = l->next) {
		LauncherIcon *launcherIcon = (LauncherIcon*)l->data;
		
		launcherIcon->y = posy;
		launcherIcon->x = posx;
		launcherIcon->area.posy = ((Area*)launcherIcon->area.parent)->posy + launcherIcon->y;
		launcherIcon->area.posx = ((Area*)launcherIcon->area.parent)->posx + launcherIcon->x;
		launcherIcon->area.width = launcherIcon->icon_size;
		launcherIcon->area.height = launcherIcon->icon_size;
		//printf("launcher %d : %d,%d\n", i, posx, posy);
		if (panel_horizontal) {
			if (i % icons_per_column) {
				posy += icon_size + launcher->area.paddingx;
			} else {
				posy = start;
				posx += (icon_size + launcher->area.paddingx);
			}
		} else {
			if (i % icons_per_row) {
				posx += icon_size + launcher->area.paddingx;
			} else {
				posx = start;
				posy += (icon_size + launcher->area.paddingx);
			}
		}
	}
	return 1;
}
示例#8
0
文件: oo_ui.c 项目: EX311/moira
int main(int argc, char *argv[])
{
	int ret;
	struct tsdev *ts;
	lua_State *L;

	myfb = myfb_open();
	set_vfb_buf(1);
	ts = ts_init();

	L = luaL_newstate();
	luaL_openlibs(L);

	lua_register(L, "SET_COUNT", lua_set_icon_count);
	lua_register(L, "SET_ICON", lua_set_icon_info);
	lua_register(L, "SET_CMD", lua_set_cmd_list);
	lua_register(L, "SET_BGCOLOR", lua_set_bgcolor);
	lua_register(L, "SET_BGIMAGE", lua_set_bgimage);

	luaL_dofile(L, file_ui);
	lua_close(L);

	while (1) {
		int c, da_count, old_da_count, pid, state = 0;
		struct ts_sample samp;
		struct icon *i;
		struct cmd_list *j;

		da_count = get_DeviceAttached();
		if (!da_count)
			da_count = 0;

		if (!old_da_count)
			old_da_count = da_count;
		else {
			if (old_da_count != da_count) {
				clear_screen();
				put_string_center(myfb->fbvar.xres/2, myfb->fbvar.yres/2 - 10, "Attached Info is changed!", white);
				put_string_center(myfb->fbvar.xres/2, myfb->fbvar.yres/2 + 10, "Touch the screen!", white);
				old_da_count = da_count;
				ret = ts_read(ts, &samp, 1);
				continue;
			}
		}

		set_bgimage();
		set_bgcolor();
		for (c=0; c<=da_count; c++)
			draw_block(myfb->fbvar.xres-12*c-12, 3);
		
		if (head == NULL) {
			put_string_center(myfb->fbvar.xres/2, myfb->fbvar.yres/2, "Sorry, No Apps. registered!", white);
#ifdef DEBUG
			fprintf(stderr, "No Apps!\n");
#endif
			break;
		}

		for (i=head; i != NULL; i=i->next)
			draw_icon(i);

		ret = ts_read(ts, &samp, 1);
		if (ret < 0) {
			perror("ts_read");
			continue;
		}
		if (ret != 1)
			continue;

		if (samp.x > 310 && samp.y >230)
			break;

		for (i=head, j=cmdlist; i != NULL; i=i->next, j=j->next) {
			if (icon_handle(i, &samp) > 0) {
				if (chat_count < 20)
					continue;
				chat_count = 0;

				pid = fork();
				if (pid == 0) {
#ifdef DEBUG
					fprintf(stderr, " *** This is CHILD! ***\n");
#endif
					if (j)
						ret = execl(j->path, j->args, 0);
					if (ret < 0) {
						perror("execl");
						exit(1);
					}
				} else {
					sleep(1);
					wait(&state);
					no_count = 0;
					put_string_center(myfb->fbvar.xres/2, myfb->fbvar.yres/2, "End of Program!", white);
#ifdef DEBUG
					fprintf(stderr, " *** End of CHILD! ***\n");
#endif
				}
			}
		}
	}

	clear_screen();
	put_string_center(myfb->fbvar.xres/2, myfb->fbvar.yres/2, "Thanks for Use!", white);

	free_icon();
	free_cmd();
	ts_close(ts);
	free_vfb_buf(1);
	myfb_close();
	return 0;
}