wip: should be ok - needs testing with script

This commit is contained in:
Jean Guyomarc'h 2016-05-18 19:45:03 +02:00
parent 82e013160a
commit 6b73832d57
13 changed files with 385 additions and 35 deletions

View File

@ -13,6 +13,7 @@ lib/ecore_cocoa/ecore_cocoa.m \
lib/ecore_cocoa/ecore_cocoa_keys.h \
lib/ecore_cocoa/ecore_cocoa_window.h \
lib/ecore_cocoa/ecore_cocoa_window.m \
lib/ecore_cocoa/ecore_cocoa_notification.m \
lib/ecore_cocoa/ecore_cocoa_cnp.m \
lib/ecore_cocoa/ecore_cocoa_app.m \
lib/ecore_cocoa/ecore_cocoa_app.h \

View File

@ -87,6 +87,7 @@ elm_public_eolian_files = \
lib/elementary/elm_sys_notify_interface.eo \
lib/elementary/elm_sys_notify.eo \
lib/elementary/elm_sys_notify_dbus.eo \
lib/elementary/elm_sys_notify_cocoa.eo \
lib/elementary/elm_systray.eo \
lib/elementary/elm_thumb.eo \
lib/elementary/elm_toolbar.eo \
@ -617,6 +618,7 @@ lib_elementary_libelementary_la_SOURCES = \
lib/elementary/elm_sys_notify_interface.c \
lib/elementary/elm_sys_notify.c \
lib/elementary/elm_sys_notify_dbus.c \
lib/elementary/elm_sys_notify_cocoa.c \
lib/elementary/elm_table.c \
lib/elementary/elm_theme.c \
lib/elementary/elm_thumb.c \

View File

@ -8,16 +8,6 @@
#ifndef __ECORE_COCOA_H__
#define __ECORE_COCOA_H__
/*
* DO NOT USE THIS HEADER. IT IS WORK IN PROGRESS. IT IS NOT FINAL AND
* THE API MAY CHANGE.
*/
#ifndef ECORE_COCOA_WIP_GNSIDNQI
# warning "You are using a work in progress API. This API is not stable"
# warning "and is subject to change. You use this at your own risk."
#endif
#include <Eina.h>
#ifdef EAPI
@ -43,6 +33,7 @@ extern "C" {
/**
* @typedef Ecore_Cocoa_Window
* Opaque handler to manipulate a Cocoa Window through Ecore
* @since 1.18
*/
typedef struct _Ecore_Cocoa_Window Ecore_Cocoa_Window;
#endif /* ! _ECORE_COCOA_WINDOW_PREDEF */
@ -50,36 +41,42 @@ typedef struct _Ecore_Cocoa_Window Ecore_Cocoa_Window;
/**
* @typedef Ecore_Cocoa_Screen
* Opaque handler to manipulate a Cocoa Screen through Ecore
* @since 1.18
*/
typedef struct _Ecore_Cocoa_Screen Ecore_Cocoa_Screen;
/**
* @typedef Ecore_Cocoa_Object
* Opaque handler to refer to an objective-c object (aka id)
* @since 1.18
*/
typedef void Ecore_Cocoa_Object;
/**
* @typedef Ecore_Cocoa_Event_Window_Resize_Request
* Type of event thrown when a Cocoa window is resized
* @since 1.18
*/
typedef struct _Ecore_Cocoa_Event_Window_Resize_Request Ecore_Cocoa_Event_Window_Resize_Request;
/**
* @typedef Ecore_Cocoa_Event_Window_Focused
* Type of event thrown when a Cocoa window receives focus
* @since 1.18
*/
typedef struct _Ecore_Cocoa_Event_Window_Focused Ecore_Cocoa_Event_Window_Focused;
/**
* @typedef Ecore_Cocoa_Event_Window_Unfocused
* Type of event thrown when a Cocoa window loses the focus
* @since 1.18
*/
typedef struct _Ecore_Cocoa_Event_Window_Unfocused Ecore_Cocoa_Event_Window_Unfocused;
/**
* @typedef Ecore_Cocoa_Event_Window_Destroy
* Type of event thrown when a Cocoa window gets destoyed
* @since 1.18
*/
typedef struct _Ecore_Cocoa_Event_Window_Destroy Ecore_Cocoa_Event_Window_Destroy;
@ -87,6 +84,7 @@ typedef struct _Ecore_Cocoa_Event_Window_Destroy Ecore_Cocoa_Event_Window_Destro
* @typedef Ecore_Cocoa_Cursor
* Values of the Cocoa cursors handled by Ecore_Cocoa
* See https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSCursor_Class/index.html for images of each cursors.
* @since 1.18
*/
typedef enum
{
@ -116,21 +114,29 @@ typedef enum
} Ecore_Cocoa_Cursor;
/** Event triggered when a Cocoa window receives focus */
/** Event triggered when a Cocoa window receives focus
* @since 1.18
*/
EAPI extern int ECORE_COCOA_EVENT_WINDOW_FOCUSED;
/** Event triggered when a Cocoa window loses focus */
/**
* Event triggered when a Cocoa window loses focus
* @since 1.18
*/
EAPI extern int ECORE_COCOA_EVENT_WINDOW_UNFOCUSED;
/** Event triggered when a Cocoa window is resized */
EAPI extern int ECORE_COCOA_EVENT_WINDOW_RESIZE_REQUEST;
/** Event triggered when a Cocoa window get destroyed */
/** Event triggered when a Cocoa window get destroyed
* @since 1.18
*/
EAPI extern int ECORE_COCOA_EVENT_WINDOW_DESTROY;
/**
* @struct _Ecore_Cocoa_Event_Window_Resize_Request
* Data available when a window is resized
* @since 1.18
*/
struct _Ecore_Cocoa_Event_Window_Resize_Request
{
@ -142,6 +148,7 @@ struct _Ecore_Cocoa_Event_Window_Resize_Request
/**
* @struct _Ecore_Cocoa_Event_Window_Focused
* Data available when a Cocoa window receives focus
* @since 1.18
*/
struct _Ecore_Cocoa_Event_Window_Focused
{
@ -151,6 +158,7 @@ struct _Ecore_Cocoa_Event_Window_Focused
/**
* @struct _Ecore_Cocoa_Event_Window_Unfocused
* Data available when a Cocoa window losrs focus
* @since 1.18
*/
struct _Ecore_Cocoa_Event_Window_Unfocused
{
@ -160,6 +168,7 @@ struct _Ecore_Cocoa_Event_Window_Unfocused
/**
* @struct _Ecore_Cocoa_Event_Window_Destroy
* Data available when a Cocoa window is destroyed
* @since 1.18
*/
struct _Ecore_Cocoa_Event_Window_Destroy
{
@ -170,6 +179,7 @@ struct _Ecore_Cocoa_Event_Window_Destroy
* @typedef Ecore_Cocoa_Cnp_Type
* Type used to interact with the Cocoa pasteboard.
* It hold types that can apply to a context.
* @since 1.18
*/
typedef enum
{
@ -188,12 +198,14 @@ typedef enum
/**
* Inits the Ecore_Cocoa library
* @return How many times Ecore_Cocoa has been initted
* @since 1.18
*/
EAPI int ecore_cocoa_init(void);
/**
* Shuts the Ecore_Cocoa library down
* @return How many times Ecore_Cocoa has been initted
* @since 1.18
*/
EAPI int ecore_cocoa_shutdown(void);
@ -207,6 +219,7 @@ EAPI int ecore_cocoa_shutdown(void);
* @param screen The screen which size must be retrieved
* @param [out] w The width of the screen
* @param [out] h The height of the screen
* @since 1.18
*/
EAPI void ecore_cocoa_screen_size_get(Ecore_Cocoa_Screen *screen, int *w, int *h);
@ -222,6 +235,7 @@ EAPI void ecore_cocoa_screen_size_get(Ecore_Cocoa_Screen *screen, int *w, int *h
* @param w The width of the window
* @param h The height of the window
* @return A handler on the window. NULL on failure
* @since 1.18
*/
EAPI Ecore_Cocoa_Window *ecore_cocoa_window_new(int x,
int y,
@ -233,6 +247,7 @@ EAPI Ecore_Cocoa_Window *ecore_cocoa_window_new(int x,
/**
* Releases a Cocoa window
* @param window The window to be released
* @since 1.18
*/
EAPI void ecore_cocoa_window_free(Ecore_Cocoa_Window *window)
EINA_ARG_NONNULL(1);
@ -242,6 +257,7 @@ EAPI void ecore_cocoa_window_free(Ecore_Cocoa_Window *window)
* @param window The window to be moved
* @param x The new origin of the window (X)
* @param y The new origin of the window (Y)
* @since 1.18
*/
EAPI void ecore_cocoa_window_move(Ecore_Cocoa_Window *window,
int x,
@ -253,6 +269,7 @@ EAPI void ecore_cocoa_window_move(Ecore_Cocoa_Window *window,
* @param window The window to be moved
* @param w The new width of the window
* @param h The new height of the window
* @since 1.18
*/
EAPI void ecore_cocoa_window_resize(Ecore_Cocoa_Window *window,
int w,
@ -269,6 +286,7 @@ EAPI void ecore_cocoa_window_resize(Ecore_Cocoa_Window *window,
*
* @see ecore_cocoa_window_resize()
* @see ecore_cocoa_window_move()
* @since 1.18
*/
EAPI void ecore_cocoa_window_move_resize(Ecore_Cocoa_Window *window,
int x,
@ -284,6 +302,7 @@ EAPI void ecore_cocoa_window_move_resize(Ecore_Cocoa_Window *window,
* @param y Pointer used to retrieve its origin in Y
* @param w Pointer used to retrieve its width
* @param h Pointer used to retrieve its height
* @since 1.18
*/
EAPI void ecore_cocoa_window_geometry_get(const Ecore_Cocoa_Window *window,
int *x,
@ -297,6 +316,7 @@ EAPI void ecore_cocoa_window_geometry_get(const Ecore_Cocoa_Window *window,
* @param window The window which size is queried
* @param w Pointer used to retrieve its width
* @param h Pointer used to retrieve its height
* @since 1.18
*/
EAPI void ecore_cocoa_window_size_get(const Ecore_Cocoa_Window *window,
int *w,
@ -308,6 +328,7 @@ EAPI void ecore_cocoa_window_size_get(const Ecore_Cocoa_Window *window,
* @param window The window which minimum size is to be altered
* @param w The new minimum width of the window
* @param h The new minimum height of the window
* @since 1.18
*/
EAPI void ecore_cocoa_window_size_min_set(Ecore_Cocoa_Window *window,
int w,
@ -319,6 +340,7 @@ EAPI void ecore_cocoa_window_size_min_set(Ecore_Cocoa_Window *window,
* @param window The window which minimum size is queried
* @param w Pointer used to retrieve its minimum width
* @param h Pointer used to retrieve its minimum height
* @since 1.18
*/
EAPI void ecore_cocoa_window_size_min_get(const Ecore_Cocoa_Window *window,
int *w,
@ -330,6 +352,7 @@ EAPI void ecore_cocoa_window_size_min_get(const Ecore_Cocoa_Window *window,
* @param window The window which maximum size is to be altered
* @param w The new maximum width of the window
* @param h The new maximum height of the window
* @since 1.18
*/
EAPI void ecore_cocoa_window_size_max_set(Ecore_Cocoa_Window *window,
int w,
@ -341,6 +364,7 @@ EAPI void ecore_cocoa_window_size_max_set(Ecore_Cocoa_Window *window,
* @param window The window which maximum size is queried
* @param w Pointer used to retrieve its maximum width
* @param h Pointer used to retrieve its maximum height
* @since 1.18
*/
EAPI void ecore_cocoa_window_size_max_get(const Ecore_Cocoa_Window *window,
int *w,
@ -352,6 +376,7 @@ EAPI void ecore_cocoa_window_size_max_get(const Ecore_Cocoa_Window *window,
* @param window The Cocoa window which resize increment is to be set
* @param w The width size increment
* @param h The height size increment
* @since 1.18
*/
EAPI void ecore_cocoa_window_size_step_set(Ecore_Cocoa_Window *window,
int w,
@ -363,6 +388,7 @@ EAPI void ecore_cocoa_window_size_step_set(Ecore_Cocoa_Window *window,
* @param window The Cocoa window which resize increment queried
* @param w The width size increment
* @param h The height size increment
* @since 1.18
*/
EAPI void ecore_cocoa_window_size_step_get(const Ecore_Cocoa_Window *window,
int *w,
@ -372,6 +398,7 @@ EAPI void ecore_cocoa_window_size_step_get(const Ecore_Cocoa_Window *window,
/**
* Display a Cocoa window
* @param window The Cocoa window to be displayed
* @since 1.18
*/
EAPI void ecore_cocoa_window_show(Ecore_Cocoa_Window *window)
EINA_ARG_NONNULL(1);
@ -379,6 +406,7 @@ EAPI void ecore_cocoa_window_show(Ecore_Cocoa_Window *window)
/**
* Hide a Cocoa window
* @param window The Cocoa window to be hid
* @since 1.18
*/
EAPI void ecore_cocoa_window_hide(Ecore_Cocoa_Window *window)
EINA_ARG_NONNULL(1);
@ -386,6 +414,7 @@ EAPI void ecore_cocoa_window_hide(Ecore_Cocoa_Window *window)
/**
* Brings a Cocoa window to front
* @param window The Cocoa window to be raised
* @since 1.18
*/
EAPI void ecore_cocoa_window_raise(Ecore_Cocoa_Window *window)
EINA_ARG_NONNULL(1);
@ -393,6 +422,7 @@ EAPI void ecore_cocoa_window_raise(Ecore_Cocoa_Window *window)
/**
* Brings a Cocoa window back
* @param window The Cocoa window to be lowered
* @since 1.18
*/
EAPI void ecore_cocoa_window_lower(Ecore_Cocoa_Window *window)
EINA_ARG_NONNULL(1);
@ -400,6 +430,7 @@ EAPI void ecore_cocoa_window_lower(Ecore_Cocoa_Window *window)
/**
* Makes a Cocoa window the current key window by raising it
* @param window The Cocoa window to be activated
* @since 1.18
*/
EAPI void ecore_cocoa_window_activate(Ecore_Cocoa_Window *window)
EINA_ARG_NONNULL(1);
@ -417,6 +448,7 @@ EAPI void ecore_cocoa_window_title_set(Ecore_Cocoa_Window *window,
* Miniaturize or deminiaturize a Cocoa window
* @param window The Cocoa window which iconify status is to be changed
* @param on If #EINA_TRUE, will miniaturize the window. Will deminiaturize it if #EINA_FALSE
* @since 1.18
*/
EAPI void ecore_cocoa_window_iconified_set(Ecore_Cocoa_Window *window,
Eina_Bool on)
@ -426,6 +458,7 @@ EAPI void ecore_cocoa_window_iconified_set(Ecore_Cocoa_Window *window,
* Manage the borders of a Cocoa window
* @param window The Cocoa window which borders are to be changed
* @param on If #EINA_TRUE, will remove borders. Will restore them if #EINA_FALSE
* @since 1.18
*/
EAPI void ecore_cocoa_window_borderless_set(Ecore_Cocoa_Window *window,
Eina_Bool on)
@ -435,6 +468,7 @@ EAPI void ecore_cocoa_window_borderless_set(Ecore_Cocoa_Window *window,
* Set the content view of a Cocoa window
* @param window The Cocoa window which internal view is to be set
* @param view The NSView to be set as @c window content view
* @since 1.18
*/
EAPI void ecore_cocoa_window_view_set(Ecore_Cocoa_Window *window,
Ecore_Cocoa_Object *view)
@ -444,6 +478,7 @@ EAPI void ecore_cocoa_window_view_set(Ecore_Cocoa_Window *window,
/**
* Get the height of the title bar of Cocoa windows
* @return The height of the title bar of Cocoa windows
* @since 1.18
*/
EAPI int ecore_cocoa_titlebar_height_get(void);
@ -451,6 +486,7 @@ EAPI int ecore_cocoa_titlebar_height_get(void);
* Retrieves the actual NSWindow behind the Ecore_Cocoa wrapper
* @param window The Ecore_Cocoa wrapper which window is to be retrieved
* @return The Cocoa NSWindow manipulated by @c window
* @since 1.18
*/
EAPI Ecore_Cocoa_Object *ecore_cocoa_window_get(const Ecore_Cocoa_Window *window)
EINA_ARG_NONNULL(1)
@ -462,6 +498,7 @@ EAPI Ecore_Cocoa_Object *ecore_cocoa_window_get(const Ecore_Cocoa_Window *window
* @param size The size in bytes of @c data
* @param type
* @return EINA_TRUE on success, EINA_FALSE on failure
* @since 1.18
*/
EAPI Eina_Bool ecore_cocoa_selection_clipboard_set(const void *data,
int size,
@ -477,6 +514,7 @@ EAPI Eina_Bool ecore_cocoa_selection_clipboard_set(const void *data,
* If @c type was ECORE_COCOA_CNP_TYPE_STRING or ECORE_COCOA_CNP_TYPE_MARKUP,
* @c retrieved_types will contain ECORE_COCOA_CNP_TYPE_STRING and the data
* will be a C string (char*) that must be freed after use.
* @since 1.18
*/
EAPI void *ecore_cocoa_selection_clipboard_get(int *size,
Ecore_Cocoa_Cnp_Type type,
@ -485,6 +523,7 @@ EAPI void *ecore_cocoa_selection_clipboard_get(int *size,
/**
* Deletes the contents of the Cocoa clipboard
* @since 1.18
*/
EAPI void ecore_cocoa_selection_clipboard_clear(void);
@ -492,6 +531,7 @@ EAPI void ecore_cocoa_selection_clipboard_clear(void);
* Set the Cocoa cursor for a given Cocoa window
* @param win The Cocoa window on which the cursor is to be changed.
* @param c The cursor to be set
* @since 1.18
*/
EAPI void ecore_cocoa_window_cursor_set(Ecore_Cocoa_Window *win,
Ecore_Cocoa_Cursor c)
@ -501,11 +541,25 @@ EAPI void ecore_cocoa_window_cursor_set(Ecore_Cocoa_Window *win,
* Hide or show the Cocoa cursor for a given Cocoa window
* @param win The Cocoa window on which the cursor is to be hid
* @param show Shows the cursor if EINA_TRUE. Hides it if EINA_FALSE
*
* @since 1.18
*/
EAPI void ecore_cocoa_window_cursor_show(Ecore_Cocoa_Window *win, Eina_Bool show);
EINA_ARG_NONNULL(1);
typedef struct _Ecore_Cocoa_Notification Ecore_Cocoa_Notification;
typedef void (*Ecore_Cocoa_Notify_Send_Cb)(void *data, unsigned int uid);
EAPI Ecore_Cocoa_Notification *ecore_cocoa_notification_get(unsigned int uid);
EAPI void
ecore_cocoa_notification_send(Ecore_Cocoa_Notification *replaces EINA_UNUSED,
const char *name,
const char *description,
const char *icon EINA_UNUSED,
Ecore_Cocoa_Notify_Send_Cb cb,
const void *cb_data);
#ifdef __cplusplus
}
#endif

View File

@ -67,6 +67,9 @@ ecore_cocoa_init(void)
if (!_ecore_cocoa_window_init())
return --_ecore_cocoa_init_count;
if (!_ecore_cocoa_notification_init())
return --_ecore_cocoa_init_count;
return _ecore_cocoa_init_count;
}
@ -82,6 +85,8 @@ ecore_cocoa_shutdown(void)
if (--_ecore_cocoa_init_count != 0)
return _ecore_cocoa_init_count;
_ecore_cocoa_notification_shutdown();
DBG("Ecore Cocoa shutdown");
eina_log_domain_unregister(_ecore_cocoa_log_domain);

View File

@ -0,0 +1,86 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#import <Cocoa/Cocoa.h>
#include "Ecore_Cocoa.h"
#include "ecore_cocoa_window.h"
#include "ecore_cocoa_private.h"
@interface EcoreCocoaNotificationDelegate: NSObject <NSUserNotificationCenterDelegate>
@end
@implementation EcoreCocoaNotificationDelegate
- (void)userNotificationCenter:(NSUserNotificationCenter *)center
didDeliverNotification:(NSUserNotification *)notification
{
NSLog(@"Hey, I just met you...\n");
}
@end
struct _Ecore_Cocoa_Notification
{
NSUserNotification *ref;
unsigned int uid;
};
EAPI void
ecore_cocoa_notification_send(Ecore_Cocoa_Notification *replaces EINA_UNUSED,
const char *name,
const char *description,
const char *icon EINA_UNUSED,
Ecore_Cocoa_Notify_Send_Cb cb,
const void *cb_data)
{
NSUserNotification *const n = [[NSUserNotification alloc] init];
n.title = [NSString stringWithUTF8String: name];
n.informativeText = [NSString stringWithUTF8String: description];
[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification: n];
}
EAPI Ecore_Cocoa_Notification *
ecore_cocoa_notification_get(unsigned int uid)
{
if (!uid) return NULL;
CRI("NOT IMPLEMENTED!!!!\n");
return NULL; /* TODO FIXME */
}
void
ecore_cocoa_notification_close(Ecore_Cocoa_Notification *n EINA_UNUSED)
{
CRI("Not implemented");
}
Eina_Bool
_ecore_cocoa_notification_init(void)
{
// NSUserNotificationCenter *def;
// EcoreCocoaNotificationDelegate *delegate;
// def = [NSUserNotificationCenter defaultUserNotificationCenter];
// delegate = [[EcoreCocoaNotificationDelegate alloc] init];
// if (EINA_UNLIKELY(delegate == nil))
// {
// CRI("Failed to create delegate of user notification center");
// return EINA_FALSE;
// }
// def.delegate = delegate;
return EINA_TRUE;
}
void
_ecore_cocoa_notification_shutdown(void)
{
// NSUserNotificationCenter *def;
// EcoreCocoaNotificationDelegate *delegate;
// def = [NSUserNotificationCenter defaultUserNotificationCenter];
// delegate = def.delegate;
// [delegate release];
// def.delegate = nil;
}

View File

@ -43,6 +43,8 @@ struct _Ecore_Cocoa_Screen
/* Internal init */
Eina_Bool _ecore_cocoa_window_init(void);
Eina_Bool _ecore_cocoa_notification_init(void);
void _ecore_cocoa_notification_shutdown(void);
Eina_Bool _ecore_cocoa_feed_events(void *anEvent);

View File

@ -92,6 +92,7 @@ elm_eolian_files = \
elm_sys_notify_interface.eo \
elm_sys_notify.eo \
elm_sys_notify_dbus.eo \
elm_sys_notify_cocoa.eo \
elm_systray.eo \
elm_table.eo \
elm_thumb.eo \
@ -603,6 +604,7 @@ libelementary_la_SOURCES = \
elm_sys_notify_interface.c \
elm_sys_notify.c \
elm_sys_notify_dbus.c \
elm_sys_notify_cocoa.c \
elm_table.c \
elm_theme.c \
elm_thumb.c \

View File

@ -9,6 +9,9 @@
#include "elm_sys_notify_dbus.eo.h"
#include "elm_sys_notify_dbus.eo.legacy.h"
#include "elm_sys_notify_cocoa.eo.h"
#include "elm_sys_notify_cocoa.eo.legacy.h"
#define MY_CLASS ELM_SYS_NOTIFY_CLASS
#define MY_CLASS_NAME "Elm_Sys_Notify"
@ -19,36 +22,44 @@ EAPI int ELM_EVENT_SYS_NOTIFY_ACTION_INVOKED = 0;
typedef const Eo_Class *(*Class_Get_Func)(void);
typedef struct
{
const char *name;
Class_Get_Func func;
} Sys_Notify;
static Elm_Sys_Notify *_singleton = NULL;
/*
* Registration of notification servers is done UNIQUELY
* in the two structures below.
* 1) ALWAYS add a SRV_XXX before __SRV_LAST
* 2) copy the #if ... #else ... #endif with the appropriate class
* getter (generated by Eolian) or NULL when unsupported
* 2) add the appropriate class getter (generated by Eolian)
*
* The rest of the code relies on the Srv enum and _class_getters
* to register/unregister notification servers.
* The rest of the code relies on the Srv enum and _sys_notify
* to register/unregister notification servers, as well
* as the ELM_SYS_NOTIFY_SERVER environment variable
*/
typedef enum
{
SRV_DBUS = 0,
SRV_COCOA,
__SRV_LAST /* Sentinel */
} Srv;
static Class_Get_Func _class_getters[__SRV_LAST] =
static const Sys_Notify _sys_notify[__SRV_LAST] =
{
#ifdef ELM_SYS_NOTIFY_DBUS_CLASS
[SRV_DBUS] = elm_sys_notify_dbus_class_get
#else
[SRV_DBUS] = NULL
#endif
[SRV_DBUS] = {
.name = "dbus",
.func = elm_sys_notify_dbus_class_get,
},
[SRV_COCOA] = {
.name = "cocoa",
.func = elm_sys_notify_cocoa_class_get,
},
};
typedef struct
{
Eo *servers[__SRV_LAST];
@ -104,7 +115,9 @@ _elm_sys_notify_elm_sys_notify_interface_send(const Eo *obj EINA_UNUSED,
/* Propagate to all registered servers */
for (i = SRV_DBUS; i < __SRV_LAST; ++i)
if (sd->servers[i])
elm_obj_sys_notify_interface_send(sd->servers[i], replaces_id, icon, summary, body, urgency, timeout, cb, cb_data);
elm_obj_sys_notify_interface_send(sd->servers[i], replaces_id, icon,
summary, body, urgency, timeout,
cb, cb_data);
}
EOLIAN static void
@ -119,7 +132,8 @@ _elm_sys_notify_elm_sys_notify_interface_simple_send(const Eo *obj EINA_UNUSED,
/* Propagate to all registered servers */
for (i = SRV_DBUS; i < __SRV_LAST; ++i)
if (sd->servers[i])
elm_obj_sys_notify_interface_simple_send(sd->servers[i], icon, summary, body);
elm_obj_sys_notify_interface_simple_send(sd->servers[i],
icon, summary, body);
}
EOLIAN static void
@ -141,7 +155,7 @@ _elm_sys_notify_elm_sys_notify_interface_close(const Eo *obj EINA_UNUSED,
*============================================================================*/
EOLIAN static Eina_Bool
_elm_sys_notify_servers_set(Eo *obj EINA_UNUSED,
_elm_sys_notify_servers_set(Eo *obj EINA_UNUSED,
Elm_Sys_Notify_Data *sd,
Elm_Sys_Notify_Server servers)
{
@ -162,7 +176,7 @@ _elm_sys_notify_servers_set(Eo *obj EINA_UNUSED,
/* If server is required, create when nonexistant */
if (servers & (1 << i))
{
class_get = _class_getters[i];
class_get = _sys_notify[i].func;
if (!class_get)
{
CRI("Unsupported notification server");
@ -170,6 +184,7 @@ _elm_sys_notify_servers_set(Eo *obj EINA_UNUSED,
}
sd->servers[i] = eo_add(class_get(), NULL);
printf("--> cocoa added\n");
if (EINA_UNLIKELY(!(sd->servers[i])))
{
CRI("Failed to create notification server");
@ -233,6 +248,7 @@ elm_need_sys_notify(void)
Elm_Sys_Notify_Server servers = ELM_SYS_NOTIFY_SERVER_NONE;
Elm_Sys_Notify *manager;
Srv i;
const char *env;
/* In theory, there can be N notification managers, but
* in the implementation there will be only one: the
@ -253,10 +269,29 @@ elm_need_sys_notify(void)
return EINA_FALSE;
}
/* Environment will override the default choice */
env = getenv("ELM_SYS_NOTIFY_SERVER");
/* Register available notification servers */
for (i = SRV_DBUS; i < __SRV_LAST; ++i)
if (_class_getters[i])
servers |= (1 << i);
{
if (env)
{
/*
* When env is specified, select the matching server only
*/
if (!strcmp(env, _sys_notify[i].name))
{
servers |= (1 << i);
printf("--> Found %s\n", env);
break;
}
}
else
{
servers |= (1 << i);
}
}
/* If no server are available, don't even bother... */
if (servers == ELM_SYS_NOTIFY_SERVER_NONE)
@ -275,7 +310,9 @@ elm_sys_notify_send(unsigned int replaces_id,
Elm_Sys_Notify_Send_Cb cb,
const void *cb_data)
{
elm_obj_sys_notify_interface_send(_singleton, replaces_id, icon, summary, body, urgency, timeout, cb, cb_data);
elm_obj_sys_notify_interface_send(_singleton, replaces_id, icon,
summary, body, urgency, timeout,
cb, cb_data);
}
EAPI void

View File

@ -0,0 +1,87 @@
#ifdef HAVE_CONFIG_H
# include "elementary_config.h"
#endif
#include <Elementary.h>
#include "elm_priv.h"
#include "elm_sys_notify_cocoa.eo.h"
#include "elm_sys_notify_cocoa.eo.legacy.h"
#define MY_CLASS ELM_SYS_NOTIFY_COCOA_CLASS
#ifdef HAVE_ELEMENTARY_COCOA
EOLIAN static void
_elm_sys_notify_cocoa_elm_sys_notify_interface_close(const Eo *obj EINA_UNUSED,
void *sd EINA_UNUSED,
unsigned int id EINA_UNUSED)
{
}
EOLIAN static void
_elm_sys_notify_cocoa_elm_sys_notify_interface_send(const Eo *obj EINA_UNUSED,
void *sd EINA_UNUSED,
unsigned int replaces_id EINA_UNUSED,
const char *icon EINA_UNUSED,
const char *summary,
const char *body,
Elm_Sys_Notify_Urgency urgency EINA_UNUSED,
int timeout EINA_UNUSED,
Elm_Sys_Notify_Send_Cb cb EINA_UNUSED,
const void *cb_data EINA_UNUSED)
{
Ecore_Cocoa_Notification *n;
printf("----> %s()\n", __func__);
n = ecore_cocoa_notification_get(replaces_id);
printf("-> %p\n", n);
ecore_cocoa_notification_send(n, summary, body, icon, cb, cb_data);
}
#else
EOLIAN static void
_elm_sys_notify_cocoa_elm_sys_notify_interface_close(const Eo *obj EINA_UNUSED,
void *sd EINA_UNUSED,
unsigned int id EINA_UNUSED)
{
}
EOLIAN static void
_elm_sys_notify_cocoa_elm_sys_notify_interface_send(const Eo *obj EINA_UNUSED,
void *sd EINA_UNUSED,
unsigned int replaces_id EINA_UNUSED,
const char *icon EINA_UNUSED,
const char *summary EINA_UNUSED,
const char *body EINA_UNUSED,
Elm_Sys_Notify_Urgency urgency EINA_UNUSED,
int timeout EINA_UNUSED,
Elm_Sys_Notify_Send_Cb cb EINA_UNUSED,
const void *cb_data EINA_UNUSED)
{
}
#endif
EOLIAN static void
_elm_sys_notify_cocoa_elm_sys_notify_interface_simple_send(const Eo *obj,
void *sd,
const char *icon,
const char *summary,
const char *body)
{
printf("----> %s()\n", __func__);
_elm_sys_notify_cocoa_elm_sys_notify_interface_send(obj, sd,
0, icon, summary, body,
ELM_SYS_NOTIFY_URGENCY_NORMAL,
-1, NULL, NULL);
}
#if 0
EOLIAN static Eina_Bool
_elm_sys_notify_cocoa_elm_sys_notify_interface_available_get(const Eo *obj,
void *sd)
{
#ifdef HAVE_ELEMENTARY_COCOA
return EINA_TRUE;
#else
return EINA_FALSE;
#endif
}
#endif
#include "elm_sys_notify_cocoa.eo.c"

View File

@ -0,0 +1,12 @@
class Elm.Sys_Notify.Cocoa (Eo.Base, Elm.Sys_Notify_Interface)
{
legacy_prefix: elm_sys_notify_cocoa;
eo_prefix: elm_obj_sys_notify_cocoa;
data: null;
implements {
Elm.Sys_Notify_Interface.send;
Elm.Sys_Notify_Interface.simple_send;
Elm.Sys_Notify_Interface.close;
}
}

View File

@ -0,0 +1,50 @@
#ifdef HAVE_CONFIG_H
# include "elementary_config.h"
#endif
#include <Elementary.h>
#include "elm_priv.h"
#include "elm_sys_notify_cocoa.eo.h"
#include "elm_sys_notify_cocoa.eo.legacy.h"
#define MY_CLASS ELM_SYS_NOTIFY_COCOA_CLASS
EOLIAN static void
_elm_sys_notify_cocoa_elm_sys_notify_interface_close(const Eo *obj,
void *sd,
unsigned int id)
{
}
EOLIAN static void
_elm_sys_notify_cocoa_elm_sys_notify_interface_send(const Eo *obj EINA_UNUSED,
void *sd EINA_UNUSED,
unsigned int replaces_id EINA_UNUSED,
const char *icon EINA_UNUSED,
const char *summary,
const char *body,
Elm_Sys_Notify_Urgency urgency EINA_UNUSED,
int timeout EINA_UNUSED,
Elm_Sys_Notify_Send_Cb cb EINA_UNUSED,
const void *cb_data EINA_UNUSED)
{
NSUserNotification *const n = [[NSUserNotification alloc] init];
n.title = [NSString stringWithUTF8String: summary];
n.informativeText = [NSString stringWithUTF8String: body];
[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification: n];
}
EOLIAN static void
_elm_sys_notify_cocoa_elm_sys_notify_interface_simple_send(const Eo *obj,
void *sd,
const char *icon,
const char *summary,
const char *body)
{
_elm_sys_notify_cocoa_elm_sys_notify_interface_send(obj, sd,
0, icon, summary, body,
ELM_SYS_NOTIFY_URGENCY_NORMAL,
-1, NULL, NULL);
}

View File

@ -393,6 +393,18 @@ _elm_sys_notify_dbus_eo_base_destructor(Eo *obj,
eo_destructor(eo_super(obj, MY_CLASS));
}
#if 0
EOLIAN static void
_elm_sys_notify_dbus_elm_sys_notify_interface_available_get(const Eo *obj,
void *sd)
{
#ifdef HAVE_ELEMENTARY_COCOA
return EINA_FALSE;
#else
return EINA_TRUE;
#endif
}
#endif
#include "elm_sys_notify_dbus.eo.c"

View File

@ -221,7 +221,7 @@ _ecore_evas_resize_common(Ecore_Evas *ee,
ee->w = w;
ee->h = h;
DBG("Ecore_Evas Resize %d %d", w, h);
CRI("Ecore_Evas Resize %d %d", w, h);
if (resize_cocoa)
ecore_cocoa_window_resize((Ecore_Cocoa_Window *)ee->prop.window, w, h);