Skip to content

Instantly share code, notes, and snippets.

@rbtylee
Created June 22, 2017 11:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rbtylee/8cf9c2f6c8899c7f92531a5dcb3aaa49 to your computer and use it in GitHub Desktop.
Save rbtylee/8cf9c2f6c8899c7f92531a5dcb3aaa49 to your computer and use it in GitHub Desktop.
EFL code to set a windows icon
/* Copyright 2017 ylee@bodhilinux.com
This work is free. You can redistribute it and/or modify it under the
terms of the Do What The Fuck You Want To Public License, Version 2,
as published by Sam Hocevar. See http://www.wtfpl.net/ for more details.
*/
#include <stdio.h>
#include <Elementary.h>
#define MAXLEN 255
#define ELM_CONFIG_ICON_THEME_ELEMENTARY "_Elementary_Icon_Theme"
EAPI_MAIN int
elm_main(int argc, char **argv)
{
Evas_Object *win = NULL, *ic = NULL, *img = NULL, *label = NULL;
const char *path = NULL, *group = NULL, *name = NULL;
char info[MAXLEN];
name = "preferences-system";
sprintf(info,"Icon Test: %s<br><br>Close when done.",name);
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
win = elm_win_util_standard_add("Testing", "Elementary Icon Dialog");
elm_win_autodel_set(win, EINA_TRUE);
ic = elm_icon_add(win);
img = evas_object_image_add(evas_object_evas_get(win));
elm_icon_standard_set(ic, name);
if (strcmp(ELM_CONFIG_ICON_THEME_ELEMENTARY, elm_config_icon_theme_get()))
{
elm_image_file_get(ic, &path, &group);
evas_object_image_file_set(img, path, NULL);
elm_win_icon_object_set(win, img);
}
printf("path = %s, group = %s, name = %s\n", path, group, name);
label = elm_label_add(win);
elm_object_text_set(label, info);
evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, label);
evas_object_show(label);
evas_object_resize(win, 300, 200);
evas_object_show(win);
elm_run();
return EXIT_SUCCESS;
}
ELM_MAIN()
//Compile with:
//gcc -o icon icon.c -g `pkg-config --cflags --libs elementary`
@rbtylee
Copy link
Author

rbtylee commented Jun 22, 2017

This works only if elementary_config is set to NOT to use elementary theme icons.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment