Enlightenment CVS committal

Author  : codewarrior
Project : e17
Module  : proto

Dir     : e17/proto/etk/src/lib


Modified Files:
        etk_dialog.c etk_dialog.h 


Log Message:
- more functionality to dialog, reponse id's are in.

===================================================================
RCS file: /cvsroot/enlightenment/e17/proto/etk/src/lib/etk_dialog.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- etk_dialog.c        4 Mar 2006 18:04:10 -0000       1.5
+++ etk_dialog.c        12 Mar 2006 12:48:07 -0000      1.6
@@ -29,7 +29,8 @@
 static void _etk_dialog_constructor(Etk_Dialog *dialog);
 static void _etk_dialog_property_set(Etk_Object *object, int property_id, 
Etk_Property_Value *value);
 static void _etk_dialog_property_get(Etk_Object *object, int property_id, 
Etk_Property_Value *value);
-
+static void _etk_dialog_button_clicked_cb(Etk_Object *object, void *data);
+  
 static Etk_Signal *_etk_dialog_signals[ETK_DIALOG_NUM_SIGNALS];
 
 /**************************
@@ -143,26 +144,56 @@
    return dialog->has_separator;
 }
 
-/* TODO: doc */
-void etk_dialog_button_add(Etk_Dialog *dialog, const char *label, int 
response_id)
+/**
+ * @brief Add a button to the dialog's action area
+ * @param label the button's label
+ * @param response_id the button's response id (Etk_Dialog_Response_ID)
+ * @return Returns the newly added button.
+ */
+Etk_Widget *etk_dialog_button_add(Etk_Dialog *dialog, const char *label, int 
response_id)
 {
    Etk_Widget *button;
-   int *id;
 
    if (!dialog)
-      return;
-
+      return NULL;
+   
    button = etk_button_new_with_label(label);
-   etk_widget_visibility_locked_set(button, ETK_TRUE);
+   etk_dialog_pack_button_in_action_area(dialog, ETK_BUTTON(button), 
response_id, ETK_FALSE, ETK_FALSE, 6, ETK_TRUE);
+   return button;   
+}
+
+/**
+ * @brief Pack a pre-created button into the dialog's action area
+ * @param dialog the dialog we want to pack into
+ * @param button the button we want to pacl
+ * @param response_id the response id of the button (Etk_Dialog_Response_ID)
+ * @param expand expand the button
+ * @param fill make the button fill the available space
+ * @param padding how much padding the button will have in pixels
+ * @param pack_at_end if true, the button will be packed at the end of button 
box
+ */
+void etk_dialog_pack_button_in_action_area(Etk_Dialog *dialog, Etk_Button 
*button, int response_id, Etk_Bool expand, Etk_Bool fill, int padding, Etk_Bool 
pack_at_end)
+{
+   int *id;   
+
+   if (!dialog)
+      return;   
+   
+   etk_widget_visibility_locked_set(ETK_WIDGET(button), ETK_TRUE);
+   etk_signal_connect("clicked", ETK_OBJECT(button), 
ETK_CALLBACK(_etk_dialog_button_clicked_cb), dialog);
    
    id = malloc(sizeof(int));
    *id = response_id;
-   etk_object_data_set_full(ETK_OBJECT(dialog), "_Etk_Dialog::response_id", 
id, free);
+   etk_object_data_set_full(ETK_OBJECT(button), "_Etk_Dialog::response_id", 
id, free);
    
-   etk_box_pack_end(ETK_BOX(dialog->action_area_hbox), button, ETK_FALSE, 
ETK_FALSE, 6);
-   etk_widget_show(button);
+   if(pack_at_end)
+     etk_box_pack_end(ETK_BOX(dialog->action_area_hbox), ETK_WIDGET(button), 
fill, expand, padding);
+   else
+     etk_box_pack_start(ETK_BOX(dialog->action_area_hbox), ETK_WIDGET(button), 
fill, expand, padding);     
+   etk_widget_show(ETK_WIDGET(button));
 }
 
+
 /**************************
  *
  * Etk specific functions
@@ -239,5 +270,13 @@
  *
  **************************/
 
+static void _etk_dialog_button_clicked_cb(Etk_Object *object, void *data)
+{
+   int *response_id;
+   
+   response_id = (int*)etk_object_data_get(object, "_Etk_Dialog::response_id");
+
+   etk_signal_emit(_etk_dialog_signals[ETK_DIALOG_RESPONSE_SIGNAL], 
ETK_OBJECT(data), NULL, *response_id);
+}
 
 /** @} */
===================================================================
RCS file: /cvsroot/enlightenment/e17/proto/etk/src/lib/etk_dialog.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- etk_dialog.h        2 Dec 2005 21:57:55 -0000       1.1
+++ etk_dialog.h        12 Mar 2006 12:48:08 -0000      1.2
@@ -61,7 +61,8 @@
 void etk_dialog_pack_in_main_area(Etk_Dialog *dialog, Etk_Widget *widget, 
Etk_Bool expand, Etk_Bool fill, int padding, Etk_Bool pack_at_end);
 void etk_dialog_pack_in_action_area(Etk_Dialog *dialog, Etk_Widget *widget, 
Etk_Bool expand, Etk_Bool fill, int padding, Etk_Bool pack_at_end);
 
-void etk_dialog_button_add(Etk_Dialog *dialog, const char *label, int 
response_id);
+void etk_dialog_pack_button_in_action_area(Etk_Dialog *dialog, Etk_Button 
*button, int response_id, Etk_Bool expand, Etk_Bool fill, int padding, Etk_Bool 
pack_at_end);
+Etk_Widget *etk_dialog_button_add(Etk_Dialog *dialog, const char *label, int 
response_id);
 
 void etk_dialog_has_separator_set(Etk_Dialog *dialog, Etk_Bool has_separator);
 Etk_Bool etk_dialog_has_separator_get(Etk_Dialog *dialog);




-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to