ipc: set theme on new instance

This commit is contained in:
Boris Faure 2019-10-19 10:57:57 +02:00
parent 98787cfc2d
commit 984d7e07c6
3 changed files with 38 additions and 21 deletions

View File

@ -93,6 +93,8 @@ ipc_init(void)
"background", background, EET_T_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(new_inst_edd, Ipc_Instance,
"name", name, EET_T_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(new_inst_edd, Ipc_Instance,
"theme", theme, EET_T_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(new_inst_edd, Ipc_Instance,
"role", role, EET_T_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(new_inst_edd, Ipc_Instance,

View File

@ -11,6 +11,7 @@ struct _Ipc_Instance
char *cd;
char *background;
char *name;
char *theme;
char *role;
char *title;
char *icon_name;

View File

@ -26,6 +26,30 @@ Eina_Bool multisense_available = EINA_TRUE;
static Config *_main_config = NULL;
static void
_set_instance_theme(Ipc_Instance *inst)
{
char path[PATH_MAX];
char theme_name[PATH_MAX];
const char *theme_path = (const char *)&path;
if (!inst->theme)
return;
if (eina_str_has_suffix(inst->theme, ".edj"))
eina_strlcpy(theme_name, inst->theme, sizeof(theme_name));
else
snprintf(theme_name, sizeof(theme_name), "%s.edj", inst->theme);
if (strchr(theme_name, '/'))
eina_strlcpy(path, theme_name, sizeof(path));
else
theme_path = theme_path_get(theme_name);
eina_stringshare_replace(&(inst->config->theme), theme_path);
inst->config->temporary = EINA_TRUE;
}
static void
_check_multisense(void)
{
@ -94,6 +118,7 @@ main_ipc_new(Ipc_Instance *inst)
if (inst->xterm_256color) nargc += 1;
if (inst->active_links) nargc += 1;
if (inst->cmd) nargc += 2;
if (inst->theme) nargc += 2;
nargv = calloc(nargc + 1, sizeof(char *));
if (!nargv) return;
@ -115,6 +140,11 @@ main_ipc_new(Ipc_Instance *inst)
nargv[i++] = "-n";
nargv[i++] = (char *)inst->name;
}
if (inst->theme)
{
nargv[i++] = "-t";
nargv[i++] = (char *)inst->theme;
}
if (inst->role)
{
nargv[i++] = "-r";
@ -247,6 +277,9 @@ main_ipc_new(Ipc_Instance *inst)
win = win_evas_object_get(wn);
config = win_config_get(wn);
inst->config = config;
_set_instance_theme(inst);
if (inst->background)
{
@ -697,7 +730,6 @@ exit:
EAPI_MAIN int
elm_main(int argc, char **argv)
{
char *theme = NULL;
char *geometry = NULL;
char *video_module = NULL;
Eina_Bool video_mute = 0xff; /* unset */
@ -717,7 +749,7 @@ elm_main(int argc, char **argv)
Ecore_Getopt_Value values[] = {
ECORE_GETOPT_VALUE_BOOL(cmd_options),
ECORE_GETOPT_VALUE_STR(instance.cd),
ECORE_GETOPT_VALUE_STR(theme),
ECORE_GETOPT_VALUE_STR(instance.theme),
ECORE_GETOPT_VALUE_STR(instance.background),
ECORE_GETOPT_VALUE_STR(geometry),
ECORE_GETOPT_VALUE_STR(instance.name),
@ -849,25 +881,7 @@ elm_main(int argc, char **argv)
_check_multisense();
if (theme)
{
char path[PATH_MAX];
char theme_name[PATH_MAX];
const char *theme_path = (const char *)&path;
if (eina_str_has_suffix(theme, ".edj"))
eina_strlcpy(theme_name, theme, sizeof(theme_name));
else
snprintf(theme_name, sizeof(theme_name), "%s.edj", theme);
if (strchr(theme_name, '/'))
eina_strlcpy(path, theme_name, sizeof(path));
else
theme_path = theme_path_get(theme_name);
eina_stringshare_replace(&(instance.config->theme), theme_path);
instance.config->temporary = EINA_TRUE;
}
_set_instance_theme(&instance);
if (instance.background)
{