Commit 1b975f91 authored by Ludovic Fauvet's avatar Ludovic Fauvet

Use a helper to close the popups

parent 31b13615
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include "ui/views/list_view.h" #include "ui/views/list_view.h"
#include "ui/playlists.h" #include "ui/playlists.h"
#include "ui/equalizer.h" #include "ui/equalizer.h"
#include "ui/popup.h"
struct audio_player { struct audio_player {
interface *intf; interface *intf;
...@@ -111,7 +112,7 @@ audio_player_close_popup(audio_player *mpd) ...@@ -111,7 +112,7 @@ audio_player_close_popup(audio_player *mpd)
{ {
mpd->more_state = false; mpd->more_state = false;
elm_image_file_set(mpd->fs_more_btn, ICON_DIR"ic_more_circle_normal_o.png", NULL); elm_image_file_set(mpd->fs_more_btn, ICON_DIR"ic_more_circle_normal_o.png", NULL);
evas_object_del(mpd->popup); popup_close(mpd->popup);
mpd->popup = NULL; mpd->popup = NULL;
} }
...@@ -240,7 +241,7 @@ popup_selected_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info) ...@@ -240,7 +241,7 @@ popup_selected_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
case MORE_JUMPTO: case MORE_JUMPTO:
/* */ /* */
evas_object_del(apd->mpd->popup); popup_close(apd->mpd->popup);
/* */ /* */
elm_image_file_set(apd->mpd->fs_more_btn, ICON_DIR"ic_more_circle_normal_o.png", NULL); elm_image_file_set(apd->mpd->fs_more_btn, ICON_DIR"ic_more_circle_normal_o.png", NULL);
/* */ /* */
...@@ -254,7 +255,7 @@ popup_selected_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info) ...@@ -254,7 +255,7 @@ popup_selected_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
case MORE_SPEED: case MORE_SPEED:
/* */ /* */
evas_object_del(apd->mpd->popup); popup_close(apd->mpd->popup);
/* */ /* */
elm_image_file_set(apd->mpd->fs_more_btn, ICON_DIR"ic_more_circle_normal_o.png", NULL); elm_image_file_set(apd->mpd->fs_more_btn, ICON_DIR"ic_more_circle_normal_o.png", NULL);
/* */ /* */
...@@ -268,7 +269,7 @@ popup_selected_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info) ...@@ -268,7 +269,7 @@ popup_selected_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
case MORE_SLEEP: case MORE_SLEEP:
/* */ /* */
evas_object_del(apd->mpd->popup); popup_close(apd->mpd->popup);
/* */ /* */
elm_image_file_set(apd->mpd->fs_more_btn, ICON_DIR"ic_more_circle_normal_o.png", NULL); elm_image_file_set(apd->mpd->fs_more_btn, ICON_DIR"ic_more_circle_normal_o.png", NULL);
/* */ /* */
...@@ -280,7 +281,7 @@ popup_selected_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info) ...@@ -280,7 +281,7 @@ popup_selected_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
break; break;
case MORE_PLAYLISTS: case MORE_PLAYLISTS:
/* */ /* */
evas_object_del(apd->mpd->popup); popup_close(apd->mpd->popup);
/* */ /* */
elm_image_file_set(apd->mpd->fs_more_btn, ICON_DIR"ic_more_circle_normal_o.png", NULL); elm_image_file_set(apd->mpd->fs_more_btn, ICON_DIR"ic_more_circle_normal_o.png", NULL);
/* */ /* */
...@@ -297,7 +298,7 @@ popup_selected_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info) ...@@ -297,7 +298,7 @@ popup_selected_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
break; break;
case MORE_EQUALIZER: case MORE_EQUALIZER:
/* */ /* */
evas_object_del(apd->mpd->popup); popup_close(apd->mpd->popup);
/* */ /* */
elm_image_file_set(apd->mpd->fs_more_btn, ICON_DIR"ic_more_circle_normal_o.png", NULL); elm_image_file_set(apd->mpd->fs_more_btn, ICON_DIR"ic_more_circle_normal_o.png", NULL);
/* */ /* */
...@@ -689,7 +690,7 @@ audio_player_more_popup_close_cb(void *data, Evas_Object *obj, void *event_info) ...@@ -689,7 +690,7 @@ audio_player_more_popup_close_cb(void *data, Evas_Object *obj, void *event_info)
mpd->more_state = false; mpd->more_state = false;
elm_image_file_set(mpd->fs_more_btn, ICON_DIR"ic_more_circle_normal_o.png", NULL); elm_image_file_set(mpd->fs_more_btn, ICON_DIR"ic_more_circle_normal_o.png", NULL);
evas_object_del(obj); popup_close(obj);
} }
static void static void
...@@ -739,7 +740,7 @@ fs_more_player_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info) ...@@ -739,7 +740,7 @@ fs_more_player_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
else else
{ {
/* */ /* */
evas_object_del(mpd->popup); popup_close(mpd->popup);
/* Change the more button img */ /* Change the more button img */
elm_image_file_set(mpd->fs_more_btn, ICON_DIR"ic_more_circle_normal_o.png", NULL); elm_image_file_set(mpd->fs_more_btn, ICON_DIR"ic_more_circle_normal_o.png", NULL);
......
...@@ -105,9 +105,9 @@ popup_menu_del_cb(void *data, Evas_Object *obj, void *event_info) ...@@ -105,9 +105,9 @@ popup_menu_del_cb(void *data, Evas_Object *obj, void *event_info)
} }
static void static void
popup_menu_close_cb(void *data, Evas_Object *obj, void *event_info) popup_menu_close(void *data, Evas_Object *obj, void *event_info)
{ {
evas_object_del(obj); popup_close(obj);
} }
Evas_Object * Evas_Object *
...@@ -175,7 +175,7 @@ popup_menu_orient_add(popup_menu *menu, Elm_Popup_Orient orient, void *data, Eva ...@@ -175,7 +175,7 @@ popup_menu_orient_add(popup_menu *menu, Elm_Popup_Orient orient, void *data, Eva
elm_object_content_set(popup, genlist); elm_object_content_set(popup, genlist);
evas_object_smart_callback_add(popup, "block,clicked", popup_menu_close_cb, NULL); evas_object_smart_callback_add(popup, "block,clicked", popup_menu_close, NULL);
return popup; return popup;
} }
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "common.h" #include "common.h"
#include "ui/interface.h" #include "ui/interface.h"
#include "ui/popup.h"
typedef struct popup_menu typedef struct popup_menu
{ {
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "playback_service.h" #include "playback_service.h"
#include "media/playlist_item.h" #include "media/playlist_item.h"
#include "ui/views/list_view.h" #include "ui/views/list_view.h"
#include "ui/popup.h"
struct playlists { struct playlists {
interface *intf; interface *intf;
...@@ -55,8 +56,8 @@ playlists_popup_close(playlists *pl) ...@@ -55,8 +56,8 @@ playlists_popup_close(playlists *pl)
if (!pl) if (!pl)
return; return;
evas_object_del(pl->popup); popup_close(pl->popup);
evas_object_del(pl->new_playlist_popup); popup_close(pl->new_playlist_popup);
pl->popup = NULL; pl->popup = NULL;
pl->new_playlist_popup = NULL; pl->new_playlist_popup = NULL;
} }
...@@ -76,7 +77,7 @@ on_create_playlist(void* data, Evas_Object* obj, void* event_info) ...@@ -76,7 +77,7 @@ on_create_playlist(void* data, Evas_Object* obj, void* event_info)
media_library* p_ml = (media_library*)application_get_media_library(p_app); media_library* p_ml = (media_library*)application_get_media_library(p_app);
media_library_create_add_to_playlist(p_ml, elm_entry_entry_get(pl->p_playlist_input), pl->media_id); media_library_create_add_to_playlist(p_ml, elm_entry_entry_get(pl->p_playlist_input), pl->media_id);
evas_object_del(pl->new_playlist_popup); popup_close(pl->new_playlist_popup);
pl->new_playlist_popup = NULL; pl->new_playlist_popup = NULL;
playlists_popup_close(pl); playlists_popup_close(pl);
} }
......
/*****************************************************************************
* Copyright © 2015-2016 VideoLAN, VideoLabs SAS
*****************************************************************************
*
* Authors: Ludovic Fauvet <etix@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*
* By committing to this project, you allow VideoLAN and VideoLabs to relicense
* the code to a different OSI approved license, in case it is required for
* compatibility with the Store
*****************************************************************************/
#include "popup.h"
#include <Elementary.h>
static void
popup_del(void *data, Evas_Object *obj, void *event_info)
{
evas_object_del(obj);
}
void
popup_close(Evas_Object *popup)
{
if (!popup)
return;
evas_object_smart_callback_add(popup, "dismissed", popup_del, NULL);
elm_popup_dismiss(popup);
}
/*****************************************************************************
* Copyright © 2015-2016 VideoLAN, VideoLabs SAS
*****************************************************************************
*
* Authors: Ludovic Fauvet <etix@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*
* By committing to this project, you allow VideoLAN and VideoLabs to relicense
* the code to a different OSI approved license, in case it is required for
* compatibility with the Store
*****************************************************************************/
#ifndef POPUP_H_
#define POPUP_H_
#include "common.h"
void
popup_close(Evas_Object *popup);
#endif // POPUP_H_
...@@ -178,7 +178,7 @@ audio_list_playlists_back_callback(list_sys *p_sys) ...@@ -178,7 +178,7 @@ audio_list_playlists_back_callback(list_sys *p_sys)
{ {
if (p_sys->current_popup != NULL) if (p_sys->current_popup != NULL)
{ {
evas_object_del(p_sys->current_popup); popup_close(p_sys->current_popup);
p_sys->current_popup = NULL; p_sys->current_popup = NULL;
return true; return true;
} }
...@@ -197,7 +197,7 @@ audio_list_playlists_longpress_remove_callback(void *data, Evas_Object *obj, voi ...@@ -197,7 +197,7 @@ audio_list_playlists_longpress_remove_callback(void *data, Evas_Object *obj, voi
media_library_delete_playlist(p_ml, ali->p_playlist_item->i_id); media_library_delete_playlist(p_ml, ali->p_playlist_item->i_id);
media_library_controller_refresh(p_sys->p_ctrl); media_library_controller_refresh(p_sys->p_ctrl);
evas_object_del(p_sys->current_popup); popup_close(p_sys->current_popup);
p_sys->current_popup = NULL; p_sys->current_popup = NULL;
p_sys->current_item = NULL; p_sys->current_item = NULL;
} }
......
...@@ -165,7 +165,7 @@ audio_view_refresh_cb(void *data, Evas_Object *obj, void *event_info) ...@@ -165,7 +165,7 @@ audio_view_refresh_cb(void *data, Evas_Object *obj, void *event_info)
media_library_reload(p_ml); media_library_reload(p_ml);
/* */ /* */
evas_object_del(obj); popup_close(p_sys->p_overflow_menu);
p_sys->p_overflow_menu = NULL; p_sys->p_overflow_menu = NULL;
} }
...@@ -179,7 +179,7 @@ static void ...@@ -179,7 +179,7 @@ static void
audio_view_popup_close_cb(void *data, Evas_Object *obj, void *event_info) audio_view_popup_close_cb(void *data, Evas_Object *obj, void *event_info)
{ {
view_sys *p_view_sys = data; view_sys *p_view_sys = data;
evas_object_del(p_view_sys->p_overflow_menu); popup_close(p_view_sys->p_overflow_menu);
p_view_sys->p_overflow_menu = NULL; p_view_sys->p_overflow_menu = NULL;
} }
...@@ -191,7 +191,7 @@ audio_view_callback(view_sys *p_view_sys, interface_view_event event) ...@@ -191,7 +191,7 @@ audio_view_callback(view_sys *p_view_sys, interface_view_event event)
{ {
if (p_view_sys->p_overflow_menu) if (p_view_sys->p_overflow_menu)
{ {
evas_object_del(p_view_sys->p_overflow_menu); popup_close(p_view_sys->p_overflow_menu);
p_view_sys->p_overflow_menu = NULL; p_view_sys->p_overflow_menu = NULL;
} }
else else
...@@ -206,7 +206,7 @@ audio_view_callback(view_sys *p_view_sys, interface_view_event event) ...@@ -206,7 +206,7 @@ audio_view_callback(view_sys *p_view_sys, interface_view_event event)
{ {
/* Hide overflow menu */ /* Hide overflow menu */
if (p_view_sys->p_overflow_menu) { if (p_view_sys->p_overflow_menu) {
evas_object_del(p_view_sys->p_overflow_menu); popup_close(p_view_sys->p_overflow_menu);
p_view_sys->p_overflow_menu = NULL; p_view_sys->p_overflow_menu = NULL;
return true; return true;
} }
......
...@@ -120,7 +120,7 @@ clicked_reuse(void *data, Evas_Object *obj, void *event_info) ...@@ -120,7 +120,7 @@ clicked_reuse(void *data, Evas_Object *obj, void *event_info)
item_data *item_data = elm_object_item_data_get(p_sys->current_item); item_data *item_data = elm_object_item_data_get(p_sys->current_item);
elm_entry_entry_set(p_sys->uri, item_data->uri); elm_entry_entry_set(p_sys->uri, item_data->uri);
evas_object_del(p_sys->current_popup); popup_close(p_sys->current_popup);
p_sys->current_popup = NULL; p_sys->current_popup = NULL;
} }
...@@ -154,7 +154,7 @@ clicked_remove(void *data, Evas_Object *obj, void *event_info) ...@@ -154,7 +154,7 @@ clicked_remove(void *data, Evas_Object *obj, void *event_info)
} }
elm_object_item_del(p_sys->current_item); elm_object_item_del(p_sys->current_item);
evas_object_del(p_sys->current_popup); popup_close(p_sys->current_popup);
p_sys->current_popup = NULL; p_sys->current_popup = NULL;
} }
...@@ -292,7 +292,7 @@ stream_view_callback(view_sys *p_view_sys, interface_view_event event) ...@@ -292,7 +292,7 @@ stream_view_callback(view_sys *p_view_sys, interface_view_event event)
switch (event) { switch (event) {
case INTERFACE_VIEW_EVENT_BACK: case INTERFACE_VIEW_EVENT_BACK:
if (p_view_sys->current_popup) { if (p_view_sys->current_popup) {
evas_object_del(p_view_sys->current_popup); popup_close(p_view_sys->current_popup);
p_view_sys->current_popup = NULL; p_view_sys->current_popup = NULL;
return true; return true;
} }
......
...@@ -157,7 +157,7 @@ audio_channel_selected(void *data, Evas_Object *obj, void *event_info) ...@@ -157,7 +157,7 @@ audio_channel_selected(void *data, Evas_Object *obj, void *event_info)
int index = elm_genlist_item_index_get(it_parent); int index = elm_genlist_item_index_get(it_parent);
playback_service_audio_channel_set(p_sys->p_ps, index - 1); playback_service_audio_channel_set(p_sys->p_ps, index - 1);
evas_object_del(obj); popup_close(obj);
} }
void void
...@@ -166,7 +166,7 @@ clicked_background_playback(void *data, Evas_Object *obj, void *event_info) ...@@ -166,7 +166,7 @@ clicked_background_playback(void *data, Evas_Object *obj, void *event_info)
view_sys *p_sys = data; view_sys *p_sys = data;
if (p_sys->p_current_popup) if (p_sys->p_current_popup)
evas_object_del(p_sys->p_current_popup); popup_close(p_sys->p_current_popup);
playback_service_enable_background_playback(p_sys->p_ps); playback_service_enable_background_playback(p_sys->p_ps);
} }
...@@ -180,7 +180,7 @@ clicked_audio_tracks(void *data, Evas_Object *obj, void *event_info) ...@@ -180,7 +180,7 @@ clicked_audio_tracks(void *data, Evas_Object *obj, void *event_info)
popup_menu *menu; popup_menu *menu;
if (p_sys->p_current_popup) if (p_sys->p_current_popup)
evas_object_del(p_sys->p_current_popup); popup_close(p_sys->p_current_popup);
// Get the list of channels // Get the list of channels
channel_list = playback_service_audio_channel_get_list(p_sys->p_ps); channel_list = playback_service_audio_channel_get_list(p_sys->p_ps);
...@@ -225,7 +225,7 @@ spu_selected(void *data, Evas_Object *obj, void *event_info) ...@@ -225,7 +225,7 @@ spu_selected(void *data, Evas_Object *obj, void *event_info)
// Disable subtitles is -1, first is 0 so index -2. // Disable subtitles is -1, first is 0 so index -2.
playback_service_spu_channel_set(p_sys->p_ps, index - 2); playback_service_spu_channel_set(p_sys->p_ps, index - 2);
evas_object_del(obj); popup_close(obj);
} }
void void
...@@ -237,7 +237,7 @@ clicked_spu(void *data, Evas_Object *obj, void *event_info) ...@@ -237,7 +237,7 @@ clicked_spu(void *data, Evas_Object *obj, void *event_info)
popup_menu *menu; popup_menu *menu;
if (p_sys->p_current_popup) if (p_sys->p_current_popup)
evas_object_del(p_sys->p_current_popup); popup_close(p_sys->p_current_popup);
// Get the list of spu // Get the list of spu
spu_list = playback_service_spu_channel_get_list(p_sys->p_ps); spu_list = playback_service_spu_channel_get_list(p_sys->p_ps);
...@@ -656,7 +656,7 @@ video_player_callback(view_sys *p_view_sys, interface_view_event event) ...@@ -656,7 +656,7 @@ video_player_callback(view_sys *p_view_sys, interface_view_event event)
} }
case INTERFACE_VIEW_EVENT_BACK: case INTERFACE_VIEW_EVENT_BACK:
if (p_view_sys->p_current_popup) { if (p_view_sys->p_current_popup) {
evas_object_del(p_view_sys->p_current_popup); popup_close(p_view_sys->p_current_popup);
p_view_sys->p_current_popup = NULL; p_view_sys->p_current_popup = NULL;
return true; return true;
} }
......
...@@ -55,7 +55,7 @@ video_view_refresh_cb(void *data, Evas_Object *obj, void *event_info) ...@@ -55,7 +55,7 @@ video_view_refresh_cb(void *data, Evas_Object *obj, void *event_info)
media_library_reload(p_ml); media_library_reload(p_ml);
/* */ /* */
evas_object_del(obj); popup_close(p_sys->p_overflow_menu);
p_sys->p_overflow_menu = NULL; p_sys->p_overflow_menu = NULL;
} }
...@@ -63,7 +63,7 @@ static void ...@@ -63,7 +63,7 @@ static void
video_view_popup_close_cb(void *data, Evas_Object *obj, void *event_info) video_view_popup_close_cb(void *data, Evas_Object *obj, void *event_info)
{ {
view_sys *p_view_sys = data; view_sys *p_view_sys = data;
evas_object_del(p_view_sys->p_overflow_menu); popup_close(p_view_sys->p_overflow_menu);
p_view_sys->p_overflow_menu = NULL; p_view_sys->p_overflow_menu = NULL;
} }
...@@ -81,7 +81,7 @@ video_view_callback(view_sys *p_view_sys, interface_view_event event) ...@@ -81,7 +81,7 @@ video_view_callback(view_sys *p_view_sys, interface_view_event event)
{ {
if (p_view_sys->p_overflow_menu) if (p_view_sys->p_overflow_menu)
{ {
evas_object_del(p_view_sys->p_overflow_menu); popup_close(p_view_sys->p_overflow_menu);
p_view_sys->p_overflow_menu = NULL; p_view_sys->p_overflow_menu = NULL;
} }
else else
...@@ -94,7 +94,7 @@ video_view_callback(view_sys *p_view_sys, interface_view_event event) ...@@ -94,7 +94,7 @@ video_view_callback(view_sys *p_view_sys, interface_view_event event)
} }
case INTERFACE_VIEW_EVENT_BACK: case INTERFACE_VIEW_EVENT_BACK:
if (p_view_sys->p_overflow_menu) { if (p_view_sys->p_overflow_menu) {
evas_object_del(p_view_sys->p_overflow_menu); popup_close(p_view_sys->p_overflow_menu);
p_view_sys->p_overflow_menu = NULL; p_view_sys->p_overflow_menu = NULL;
return true; return true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment