Skip to content

Commit

Permalink
Free Accounts on list free; Merge initial events.
Browse files Browse the repository at this point in the history
  • Loading branch information
leiflm committed May 24, 2012
1 parent 7909137 commit cb0f08b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 40 deletions.
34 changes: 3 additions & 31 deletions src/controller/bks_controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,9 @@ Eina_Bool _event_refresh_data(void *data UNUSED)
return ECORE_CALLBACK_CANCEL;
}

Eina_Bool _event_refresh_prods_alpha(void *data UNUSED, int type UNUSED, void *event UNUSED)
{
bks_controller_products_alpha_get();

return ECORE_CALLBACK_RENEW;
}

Eina_Bool _event_refresh_prods_favs(void *data UNUSED, int type UNUSED, void *event UNUSED)
{
bks_controller_products_favs_get(5);

return ECORE_CALLBACK_RENEW;
}

Eina_Bool _event_refresh_user_accounts(void *data UNUSED, int type UNUSED, void *event UNUSED)
{
bks_controller_user_accounts_get();

return ECORE_CALLBACK_RENEW;
}

void bks_controller_init(void)
{
eina_lock_new(&ctrl.db_lock);

//add event handlers
ecore_event_handler_add(BKS_JOB_PRODUCTS_ALPHA_GET, _event_refresh_prods_alpha, NULL);
ecore_event_handler_add(BKS_JOB_PRODUCTS_FAVS_GET, _event_refresh_prods_favs, NULL);
ecore_event_handler_add(BKS_JOB_USER_ACCOUNTS_GET, _event_refresh_user_accounts, NULL);
}

void bks_controller_shutdown(void)
Expand All @@ -53,11 +27,6 @@ void bks_controller_shutdown(void)
void bks_controller_run(void)
{
//Add events processed later by the main loop
/*
ecore_event_add(BKS_JOB_PRODUCTS_ALPHA_GET, NULL, NULL, NULL);
ecore_event_add(BKS_JOB_PRODUCTS_FAVS_GET, NULL, NULL, NULL);
ecore_event_add(BKS_JOB_USER_ACCOUNTS_GET, NULL, NULL, NULL);
*/
ecore_timer_add(0.01, _event_refresh_data, NULL);
ecore_main_loop_begin();
}
Expand Down Expand Up @@ -95,6 +64,7 @@ _products_alpha_get_finished(void *data, Ecore_Thread *th UNUSED)
switch (job->status)
{
case BKS_MODEL_SQLITE_OK:
//bks_ui_controller_products_alpha_clear();
bks_ui_controller_products_page_alpha_set((Eina_List*)job->data);
bks_job_free(job);
printf("DB access was successful!\n");
Expand Down Expand Up @@ -144,6 +114,7 @@ _products_favs_get_finished(void *data, Ecore_Thread *th UNUSED)
switch (job->status)
{
case BKS_MODEL_SQLITE_OK:
//bks_ui_controller_products_favs_clear();
bks_ui_controller_products_page_favs_set((Eina_List*)job->data);
bks_job_free(job);
printf("DB access was successful!\n");
Expand Down Expand Up @@ -191,6 +162,7 @@ _user_accounts_get_finished(void *data, Ecore_Thread *th UNUSED)
switch (job->status)
{
case BKS_MODEL_SQLITE_OK:
//bks_ui_controller_user_accounts_clear();
bks_ui_controller_user_accounts_page_set((Eina_List*)job->data);
bks_job_free(job);
printf("DB access was successful!\n");
Expand Down
4 changes: 2 additions & 2 deletions src/ui/products_page.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ const Bks_Model_Product *bks_ui_controller_product_selected_get(void)

//API calls

void bks_ui_products_alpha_clear(void)
void bks_ui_controller_products_alpha_clear(void)
{
_products_grid_clear();
}

void bks_ui_products_favs_clear(void)
void bks_ui_controller_products_favs_clear(void)
{
_products_list_clear();
}
Expand Down
21 changes: 15 additions & 6 deletions src/ui/user_accounts_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,29 @@
#include "Bks_Ui_Private.h"

static void
_on_user_account_select(void *data UNUSED, Evas_Object *obj UNUSED, void *event_info)
_on_user_account_select(void *data, Evas_Object *obj UNUSED, void *event_info UNUSED)
{
Elm_Object_Item *li = (Elm_Object_Item*)event_info;
const Bks_Model_User_Account *acc = NULL;

EINA_SAFETY_ON_NULL_RETURN(li);
acc = (const Bks_Model_User_Account*)elm_object_item_data_get(li);
acc = (const Bks_Model_User_Account*)data;
EINA_SAFETY_ON_NULL_RETURN(acc);

printf("Account %s, %s was selected\n", acc->lastname, acc->firstname);

elm_object_disabled_set(ui.user_accounts.enp.next_btn, EINA_FALSE);
}

static void
_del_cb(void *data, Evas_Object *obj UNUSED, void *event_info UNUSED)
{
Bks_Model_User_Account *acc = NULL;

acc = (Bks_Model_User_Account*)data;
EINA_SAFETY_ON_NULL_RETURN(acc);

bks_model_user_account_free(acc);
}

/*
static void
_on_user_account_double_click(void *data UNUSED, Evas_Object *obj UNUSED, void *event_info UNUSED)
Expand Down Expand Up @@ -70,8 +79,8 @@ user_accounts_list_set(Eina_List *user_accounts)
printf("Trying to open %s as icon\n", buf);
}
snprintf(buf, (sizeof(buf) - 1), "%s, %s", acc->lastname, acc->firstname);
li = elm_list_item_append(ui.user_accounts.list, buf, NULL, ic, _on_user_account_select, NULL);
elm_object_item_data_set(li, acc);
li = elm_list_item_append(ui.user_accounts.list, buf, NULL, ic, _on_user_account_select, acc);
elm_object_item_del_cb_set(li, _del_cb);
}
elm_list_go(ui.user_accounts.list);
ecore_thread_main_loop_end();
Expand Down
2 changes: 1 addition & 1 deletion src/ui/user_accounts_page.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void user_accounts_page_set(Eina_List *user_accounts)
/**
* @brief Clears the user accounts ui elements.
*/
void bks_ui_user_accounts_clear(void)
void bks_ui_controller_user_accounts_clear(void)
{
ecore_thread_main_loop_begin();
elm_list_clear(ui.user_accounts.list);
Expand Down

0 comments on commit cb0f08b

Please sign in to comment.