edi_settings: allow settings window tab open choice.

This slight change to the API allows the user (when prompted) to
open the settings panel, access to the specific settings tab of
interest. Therefore a prompt for missing user information,
will open the settings panel at the project section of settings.
This commit is contained in:
Alastair Poole 2018-12-17 14:15:41 +00:00
parent 06d866411d
commit 2fb3860c72
4 changed files with 63 additions and 19 deletions

View File

@ -622,7 +622,7 @@ edi_launcher_config_missing()
title = _("Unable to launch");
message = _("No launch binary found, please configure in Settings.");
edi_screens_settings_message(_edi_main_win, title, message);
edi_screens_settings_message(_edi_main_win, EDI_SETTINGS_TAB_BUILDS, title, message);
}
void
@ -633,7 +633,7 @@ edi_debug_exe_missing(void)
title = _("Unable to launch debugger");
message = _("No debug binary found, please check system configuration and Settings.");
edi_screens_settings_message(_edi_main_win, title, message);
edi_screens_settings_message(_edi_main_win, EDI_SETTINGS_TAB_BUILDS, title, message);
}
static void
@ -645,7 +645,7 @@ _edi_project_credentials_missing()
title = _("Missing user information");
message = _("No user information found, please configure in Settings.");
edi_screens_settings_message(_edi_main_win, title, message);
edi_screens_settings_message(_edi_main_win, EDI_SETTINGS_TAB_PROJECT, title, message);
}
static Eina_Bool
@ -908,7 +908,7 @@ _tb_about_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_i
static void
_tb_settings_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
edi_settings_show(_edi_main_win);
edi_settings_show(_edi_main_win, EDI_SETTINGS_TAB_DISPLAY);
}
static void
@ -975,7 +975,7 @@ static void
_edi_menu_settings_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
edi_settings_show(_edi_main_win);
edi_settings_show(_edi_main_win, EDI_SETTINGS_TAB_DISPLAY);
}
static void

View File

@ -14,6 +14,12 @@ static void
_edi_screens_popup_cancel_cb(void *data, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
Edi_Settings_Tab *default_tab;
default_tab = evas_object_data_get((Evas_Object *) data, "default_tab");
if (default_tab)
free(default_tab);
evas_object_del((Evas_Object *) data);
}
@ -129,16 +135,20 @@ static void
_edi_screens_settings_display_cb(void *data, Evas_Object *obj,
void *event_info EINA_UNUSED)
{
Evas_Object *parent = evas_object_data_get(obj, "parent");
Evas_Object *parent;
Edi_Settings_Tab type;
parent = evas_object_data_get(obj, "parent");
type = *((Edi_Settings_Tab *) evas_object_data_get((Evas_Object *) data, "default_tab"));
evas_object_del((Evas_Object *) data);
edi_settings_show(parent);
edi_settings_show(parent, type);
}
void edi_screens_settings_message(Evas_Object *parent, const char *title, const char *message)
void edi_screens_settings_message(Evas_Object *parent, Edi_Settings_Tab type, const char *title, const char *message)
{
Evas_Object *popup, *frame, *table, *box, *icon, *sep, *label, *button;
Edi_Settings_Tab *default_tab;
popup = elm_popup_add(parent);
elm_object_part_text_set(popup, "title,text", title);
@ -182,6 +192,14 @@ void edi_screens_settings_message(Evas_Object *parent, const char *title, const
elm_object_text_set(button, _("Settings"));
elm_object_part_content_set(popup, "button2", button);
evas_object_data_set(button, "parent", parent);
default_tab = malloc(sizeof(Edi_Settings_Tab));
if (default_tab)
{
*default_tab = type;
evas_object_data_set(popup, "default_tab", default_tab);
}
evas_object_smart_callback_add(button, "clicked", _edi_screens_settings_display_cb, popup);
evas_object_show(popup);

View File

@ -22,6 +22,14 @@ extern "C" {
*
*/
typedef enum _Edi_Settings_Tab
{
EDI_SETTINGS_TAB_DISPLAY = 0,
EDI_SETTINGS_TAB_PROJECT = 1,
EDI_SETTINGS_TAB_BUILDS = 2,
EDI_SETTINGS_TAB_BEHAVIOUR = 3,
} Edi_Settings_Tab;
/**
* Initialise a new Edi welcome window and display it.
*
@ -56,7 +64,7 @@ Evas_Object *edi_about_show(Evas_Object *mainwin);
*
* @ingroup UI
*/
Evas_Object *edi_settings_show(Evas_Object *mainwin);
Evas_Object *edi_settings_show(Evas_Object *mainwin, Edi_Settings_Tab type);
/**
* Return a pointer to the settings window.
@ -104,12 +112,13 @@ void edi_screens_message(Evas_Object *parent, const char *title, const char *mes
* Create an information dialogue with additional button to settings.
*
* @param parent The parent object to display the dialogue in.
* @param type The type of tab to be opened in the settings window.
* @param title The title for the popup.
* @param message The text to be displayed in the popup.
*
* @ingroup UI
*/
void edi_screens_settings_message(Evas_Object *parent, const char *title, const char *message);
void edi_screens_settings_message(Evas_Object *parent, Edi_Settings_Tab type, const char *title, const char *message);
/**
* Send a desktop notification message to the window manager.

View File

@ -852,10 +852,11 @@ edi_settings_win_get(void)
}
Evas_Object *
edi_settings_show(Evas_Object *mainwin)
edi_settings_show(Evas_Object *mainwin, Edi_Settings_Tab type)
{
Evas_Object *win, *bg, *table, *naviframe, *tb;
Elm_Object_Item *tb_it, *default_it;
Elm_Object_Item *it_project, *it_display, *it_behaviour, *it_builds;
if (edi_settings_win_get())
return NULL;
@ -908,18 +909,34 @@ edi_settings_show(Evas_Object *mainwin)
_edi_settings_behaviour_create(naviframe), NULL);
elm_naviframe_item_title_enabled_set(_edi_settings_behaviour, EINA_FALSE, EINA_FALSE);
elm_toolbar_item_append(tb, "applications-development", _("Project"),_edi_settings_category_cb, _edi_settings_project);
default_it = elm_toolbar_item_append(tb, "preferences-desktop", _("Display"),
_edi_settings_category_cb, _edi_settings_display);
elm_toolbar_item_append(tb, "system-run", "Builds",
_edi_settings_category_cb, _edi_settings_builds);
it_project = elm_toolbar_item_append(tb, "applications-development", _("Project"),_edi_settings_category_cb, _edi_settings_project);
it_display = elm_toolbar_item_append(tb, "preferences-desktop", _("Display"), _edi_settings_category_cb, _edi_settings_display);
it_builds = elm_toolbar_item_append(tb, "system-run", _("Builds"), _edi_settings_category_cb, _edi_settings_builds);
tb_it = elm_toolbar_item_append(tb, NULL, NULL, NULL, NULL);
elm_toolbar_item_separator_set(tb_it, EINA_TRUE);
elm_toolbar_item_append(tb, "application-internet", _("Global"), NULL, NULL);
elm_toolbar_item_append(tb, "preferences-other", _("Behaviour"),
_edi_settings_category_cb, _edi_settings_behaviour);
elm_object_item_disabled_set(tb, EINA_TRUE);
it_behaviour = elm_toolbar_item_append(tb, "preferences-other", _("Behaviour"),
_edi_settings_category_cb, _edi_settings_behaviour);
switch (type)
{
case EDI_SETTINGS_TAB_DISPLAY:
default_it = it_display;
break;
case EDI_SETTINGS_TAB_PROJECT:
default_it = it_project;
break;
case EDI_SETTINGS_TAB_BEHAVIOUR:
default_it = it_behaviour;
break;
case EDI_SETTINGS_TAB_BUILDS:
default_it = it_builds;
break;
}
elm_toolbar_item_selected_set(default_it, EINA_TRUE);
evas_object_show(naviframe);