Wrap the signal functions in the layout and use them in the little macros for setting...
authorIván Briano <sachieru@gmail.com>
Thu, 28 Oct 2010 13:54:57 +0000 (13:54 +0000)
committerIván Briano <sachieru@gmail.com>
Thu, 28 Oct 2010 13:54:57 +0000 (13:54 +0000)
SVN revision: 53958

src/lib/Elementary.h.in
src/lib/elm_layout.c

index 0dca6ec..406f2b5 100644 (file)
@@ -887,6 +887,10 @@ extern "C" {
    EAPI Evas_Object *elm_layout_table_unpack(Evas_Object *obj, const char *part, Evas_Object *child_obj);
    EAPI void         elm_layout_table_clear(Evas_Object *obj, const char *part, Eina_Bool clear);
 
+   EAPI void         elm_layout_signal_emit(Evas_Object *obj, const char *signal, const char *source);
+   EAPI void         elm_layout_signal_callback_add(Evas_Object *obj, const char *signal, const char *source, Edje_Signal_Cb func, void *data);
+   EAPI void        *elm_layout_signal_callback_del(Evas_Object *obj, const char *signal, const char *source, Edje_Signal_Cb func);
+
    EAPI Evas_Object *elm_layout_edje_get(const Evas_Object *obj);
    EAPI void         elm_layout_sizing_eval(Evas_Object *obj);
 
@@ -905,7 +909,15 @@ extern "C" {
  * @ingroup Layout
  */
 #define elm_layout_icon_set(_ly, _obj) \
-  elm_layout_content_set((_ly), "elm.swallow.icon", (_obj))
+  do {                                                             \
+       const char *sig;                                            \
+       elm_layout_content_set((_ly), "elm.swallow.icon", (_obj));  \
+       if ((_obj))                                                 \
+          sig = "elm,state,icon,visible";                          \
+       else                                                        \
+          sig = "elm,state,icon,hidden";                           \
+       elm_layout_signal_emit((_ly), sig, "elm");                  \
+  } while(0)
 
 /**
  * @def elm_layout_icon_get
@@ -925,7 +937,15 @@ extern "C" {
  * @ingroup Layout
  */
 #define elm_layout_end_set(_ly, _obj) \
-  elm_layout_content_set((_ly), "elm.swallow.end", (_obj))
+  do {                                                             \
+       const char *sig;                                            \
+       elm_layout_content_set((_ly), "elm.swallow.end", (_obj));  \
+       if ((_obj))                                                 \
+          sig = "elm,state,end,visible";                          \
+       else                                                        \
+          sig = "elm,state,end,hidden";                           \
+       elm_layout_signal_emit((_ly), sig, "elm");                  \
+  } while(0)
 
 /**
  * @def elm_layout_end_get
index 1cdce20..6b4b10d 100644 (file)
@@ -932,6 +932,70 @@ elm_layout_table_clear(Evas_Object *obj, const char *part, Eina_Bool clear)
    edje_object_part_table_clear(wd->lay, part, clear);
 }
 
+/**
+ * Send a signal to the Edje object of the layout
+ *
+ * Just a wrapper function around edje_object_signal_emit() so users don't
+ * need to fetch the edje from the layout every time.
+ *
+ * @param obj The layout object
+ * @param signal The signal to emit
+ * @param source The signal source
+ *
+ * @ingroup Layout
+ */
+EAPI void
+elm_layout_signal_emit(Evas_Object *obj, const char *signal, const char *source)
+{
+   Widget_Data *wd = elm_widget_data_get(obj);
+   ELM_CHECK_WIDTYPE(obj, widtype);
+   edje_object_signal_emit(wd->lay, signal, source);
+}
+
+/**
+ * Add a callback for signals emitted from Edje
+ *
+ * Wrapper function so users don't have to retrieve the edje object
+ * every time.
+ *
+ * @param obj The layout object
+ * @param signal Signal to listen for
+ * @param source Source to listen for
+ * @param func The function to call on signal emissions
+ * @param data User data
+ *
+ * @ingroup Layout
+ */
+EAPI void
+elm_layout_signal_callback_add(Evas_Object *obj, const char *signal, const char *source, Edje_Signal_Cb func, void *data)
+{
+   Widget_Data *wd = elm_widget_data_get(obj);
+   ELM_CHECK_WIDTYPE(obj, widtype);
+   edje_object_signal_callback_add(wd->lay, signal, source, func, data);
+}
+
+/**
+ * Delete a callback for signals.
+ *
+ * Wrapper function so users don't have to retrieve the edje object
+ * every time.
+ *
+ * @param obj The layout object
+ * @param signal Signal it was listening to
+ * @param source Source it was listening to
+ * @param func The function set as callback
+ *
+ * @return The user data given on @f elm_layout_signal_callback_add
+ *
+ * @ingroup Layout
+ */
+EAPI void *
+elm_layout_signal_callback_del(Evas_Object *obj, const char *signal, const char *source, Edje_Signal_Cb func)
+{
+   Widget_Data *wd = elm_widget_data_get(obj);
+   ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+   return edje_object_signal_callback_del(wd->lay, signal, source, func);
+}
 
 /**
  * Get the edje layout