Enlightenment CVS committal

Author  : dj2
Project : e17
Module  : libs/ewl

Dir     : e17/libs/ewl/src/lib


Modified Files:
        Ewl.h.in Makefile.am ewl_button.c ewl_button.h 
        ewl_colordialog.c ewl_dialog.c ewl_dialog.h ewl_enums.h 
        ewl_filedialog.c ewl_fileselector.c 
Removed Files:
        ewl_button_stock.c ewl_button_stock.h 


Log Message:
- get rid of ewl_button_stock.[ch]. If you want a stock button you do:

  b = ewl_button_new();
  ewl_button_stock_type_set(EWL_BUTTON(b), EWL_STOCK_OK);

  and thats it. You can then attach a click callback to the button and in
  the callback do

  ewl_button_stock_type_get(EWL_BUTTON(b)); 

  to get the type of the button. Non-stock buttons have type EWL_STOCK_NONE.

- cleanup Ewl_Dialog. This gets rid of all the api for adding buttons and
  replaces it with ewl_dialog_active_area_set().  You specify which part of
  the dialog is active and just use the container functions to append into
  it.

===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/Ewl.h.in,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -3 -r1.20 -r1.21
--- Ewl.h.in    3 Oct 2005 18:43:25 -0000       1.20
+++ Ewl.h.in    10 Oct 2005 15:27:10 -0000      1.21
@@ -287,7 +287,6 @@
 
 #include <ewl_label.h>
 #include <ewl_button.h>
-#include <ewl_button_stock.h>
 #include <ewl_floater.h>
 #include <ewl_overlay.h>
 #include <ewl_embed.h>
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/Makefile.am,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -3 -r1.11 -r1.12
--- Makefile.am 25 Sep 2005 05:02:19 -0000      1.11
+++ Makefile.am 10 Oct 2005 15:27:10 -0000      1.12
@@ -16,7 +16,6 @@
        ewl_box.h \
        ewl_label.h \
        ewl_button.h \
-       ewl_button_stock.h \
        ewl_calendar.h \
        ewl_callback.h \
        ewl_cell.h \
@@ -82,7 +81,6 @@
        ewl_box.c \
        ewl_label.c \
        ewl_button.c \
-       ewl_button_stock.c \
        ewl_calendar.c \
        ewl_callback.c \
        ewl_cell.c \
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_button.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -3 -r1.8 -r1.9
--- ewl_button.c        9 Oct 2005 04:05:01 -0000       1.8
+++ ewl_button.c        10 Oct 2005 15:27:10 -0000      1.9
@@ -3,11 +3,39 @@
 #include "ewl_macros.h"
 #include "ewl_private.h"
 
+/*
+ * this array needs to have it's items in the same order as they
+ * appear in the Ewl_Stock_Type enum
+ */
+struct 
+{
+       char            *label;
+       char            *image_key;
+} ewl_stock_items[] = {
+               {"Apply",       "/stock/apply"},
+               {/*Arrow*/"Down",       "/stock/arrow/down"},
+               {/*Arrow*/"Left",       "/stock/arrow/left"},
+               {/*Arrow*/"Right",      "/stock/arrow/right"},
+               {/*Arrow*/"Up", "/stock/arrow/up"},
+               {"Cancel",      "/stock/cancel"},
+               {"FF",          "/stock/ff"},
+               {"Home",        "/stock/home"},
+               {"Ok",          "/stock/ok"},
+               {"Open",        "/stock/open"},
+               {"Pause",       "/stock/pause"},
+               {"Play",        "/stock/play"},
+               {"Quit",        "/stock/quit"},
+               {"Rewind",      "/stock/rewind"},
+               {"Save",        "/stock/save"},
+               {"Stop",        "/stock/stop"}
+       };
+
 /**
  * @return Returns NULL on failure, a pointer to a new button on success
  * @brief Allocate and initialize a new button
  */
-Ewl_Widget     *ewl_button_new(void)
+Ewl_Widget *
+ewl_button_new(void)
 {
        Ewl_Button     *b;
 
@@ -17,7 +45,10 @@
        if (!b)
                return NULL;
 
-       ewl_button_init(b);
+       if (!ewl_button_init(b)) {
+               ewl_widget_destroy(EWL_WIDGET(b));
+               b = NULL;
+       }
 
        DRETURN_PTR(EWL_WIDGET(b), DLEVEL_STABLE);
 }
@@ -29,7 +60,8 @@
  *
  * Initializes a button to default values and callbacks.
  */
-int ewl_button_init(Ewl_Button * b)
+int
+ewl_button_init(Ewl_Button *b)
 {
        Ewl_Widget     *w;
 
@@ -38,8 +70,10 @@
 
        w = EWL_WIDGET(b);
 
-       if (!ewl_box_init(EWL_BOX(b)))
+       if (!ewl_box_init(EWL_BOX(b))) {
                DRETURN_INT(FALSE, DLEVEL_STABLE);
+       }
+       ewl_button_stock_type_set(b, EWL_STOCK_NONE);
 
        ewl_box_orientation_set(EWL_BOX(b), EWL_ORIENTATION_HORIZONTAL);
        ewl_widget_appearance_set(w, "button");
@@ -54,9 +88,10 @@
  * @return Returns no value.
  * @brief Change the label of the specified button
  */
-void ewl_button_label_set(Ewl_Button * b, char *l)
+void
+ewl_button_label_set(Ewl_Button *b, char *l)
 {
-       Ewl_Widget     *w;
+       Ewl_Widget *w;
 
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR("b", b);
@@ -88,7 +123,8 @@
  * @return A newly allocated copy of the label on the button.
  * @brief Retrieve the label of the specified button
  */
-char *ewl_button_label_get(Ewl_Button *b)
+char *
+ewl_button_label_get(Ewl_Button *b)
 {
        char *val = NULL;
 
@@ -99,3 +135,105 @@
 
        DRETURN_PTR(val, DLEVEL_STABLE);
 }
+
+/**
+ * @param b: The button to set the stock type on
+ * @param stock: The Ewl_Stock_Type to set on the button
+ * @return Returns no value.
+ */
+void
+ewl_button_stock_type_set(Ewl_Button *b, Ewl_Stock_Type stock)
+{
+       char *data;
+
+       DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR("b", b);
+
+       if (stock == b->stock_type) {
+               DRETURN(DLEVEL_STABLE);
+       }
+       b->stock_type = stock;
+
+       /* we're done if it's none */
+       if (b->stock_type == EWL_STOCK_NONE) {
+               DRETURN(DLEVEL_STABLE);
+       }
+
+       ewl_button_label_set(b, ewl_stock_items[b->stock_type].label);
+
+       /* check for an image key */
+       data = ewl_theme_data_str_get(EWL_WIDGET(b), 
+                               ewl_stock_items[b->stock_type].image_key);
+       if (data) {
+               char *theme;
+
+               theme = ewl_theme_path_get();
+               ewl_button_image_set(b, theme, data);
+               FREE(theme);
+       }
+
+       DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+/**
+ * @param b: The button to get the stock type from
+ * @return Returns the Ewl_Stock_Type of the button
+ */
+Ewl_Stock_Type 
+ewl_button_stock_type_get(Ewl_Button *b)
+{
+       DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR_RET("b", b, EWL_STOCK_NONE);
+
+       DRETURN_INT(b->stock_type, DLEAVE_FUNCTION);
+}
+
+/**
+ * @param b: The button to set the image on
+ * @param file: The file to use for the image
+ * @param key: The edje key to use for the image (or NULL if not using edje)
+ * @return Returns no value.
+ */
+void
+ewl_button_image_set(Ewl_Button *b, char *file, char *key)
+{
+       DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR("b", b);
+       DCHECK_PARAM_PTR("file", file);
+
+       if (b->image_object) {
+               ewl_widget_destroy(b->image_object);
+
+       }
+
+       b->image_object = ewl_image_new();
+       ewl_container_child_prepend(EWL_CONTAINER(b), b->image_object);
+       ewl_image_file_set(EWL_IMAGE(b->image_object), file, key);
+       ewl_widget_internal_set(b->image_object, TRUE);
+       ewl_widget_show(b->image_object);
+
+       DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+/**
+ * @param b: The button to the the image file from
+ * @return Returns the image file used in the button or NULL on failure
+ */
+char *
+ewl_button_image_get(Ewl_Button *b)
+{
+       char *file;
+
+       DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR_RET("b", b, NULL);
+
+       if (!b->image_object)
+               file = NULL;
+       else 
+               file = ewl_image_file_get(EWL_IMAGE(b->image_object));
+
+       DRETURN_PTR(file, DLEVEL_STABLE);
+}
+
+
+
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_button.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- ewl_button.h        3 Oct 2005 06:43:06 -0000       1.3
+++ ewl_button.h        10 Oct 2005 15:27:10 -0000      1.4
@@ -30,22 +30,31 @@
 /**
  * @struct Ewl_Button
  * @brief A simple Ewl_Widget to provide for a clickable button in the UI.
- * Provides easy facilities for adding a Ewl_Text label to the button, but
- * allows for placing any number of Ewl_Widget's in the Ewl_Button.
+ * Provides easy facilities for adding a Ewl_Text label to the button, and
+ * a Ewl_Image but allows for placing any number of Ewl_Widget's in the 
Ewl_Button.
  */
 struct Ewl_Button
 {
-       Ewl_Box         box; /**< Inherit from the box for adding widgets */
-       Ewl_Widget     *label_object; /**< Labels are common, make it easy */
+       Ewl_Box         box;            /**< Inherit from the box for adding 
widgets */
+       Ewl_Widget     *label_object;   /**< Labels are common, make it easy */
+       Ewl_Widget     *image_object;   /**< Add an image to the button if 
needed */
+       Ewl_Stock_Type  stock_type;     /**< The stock type of the button */
 };
 
-Ewl_Widget     *ewl_button_new(void);
-int             ewl_button_init(Ewl_Button * b);
-void            ewl_button_label_set(Ewl_Button * b, char *l);
-char           *ewl_button_label_get(Ewl_Button *b);
+Ewl_Widget     *ewl_button_new(void);
+int             ewl_button_init(Ewl_Button *b);
+void            ewl_button_label_set(Ewl_Button *b, char *l);
+char           *ewl_button_label_get(Ewl_Button *b);
 
+void            ewl_button_stock_type_set(Ewl_Button *b, Ewl_Stock_Type stock);
+Ewl_Stock_Type  ewl_button_stock_type_get(Ewl_Button *b);
+
+void            ewl_button_image_set(Ewl_Button *b, char *file, char *key);
+char           *ewl_button_image_get(Ewl_Button *b);
+  
 /**
  * @}
  */
 
 #endif                         /* __EWL_BUTTON_H__ */
+
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_colordialog.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -3 -r1.13 -r1.14
--- ewl_colordialog.c   9 Oct 2005 05:18:39 -0000       1.13
+++ ewl_colordialog.c   10 Oct 2005 15:27:10 -0000      1.14
@@ -175,11 +175,8 @@
                            ewl_colordialog_valuevalue_changed, cd);
        ewl_widget_show(cd->value_entry);
 
-       button = ewl_button_stock_new();
-       ewl_button_stock_id_set(EWL_BUTTON_STOCK(button),
-                                        EWL_STOCK_OK);
-       ewl_button_stock_response_id_set(EWL_BUTTON_STOCK(button),
-                                        EWL_RESPONSE_OK);
+       button = ewl_button_new();
+       ewl_button_stock_type_set(EWL_BUTTON(button), EWL_STOCK_OK);
        ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_HFILL);
        ewl_object_alignment_set(EWL_OBJECT(button), EWL_FLAG_ALIGN_CENTER);
        ewl_callback_append(button, EWL_CALLBACK_CLICKED,
@@ -187,10 +184,8 @@
        ewl_container_child_append(EWL_CONTAINER(vbox), button);
        ewl_widget_show(button);
 
-       button = ewl_button_stock_new();
-       ewl_button_stock_id_set(EWL_BUTTON_STOCK(button), EWL_STOCK_CANCEL);
-       ewl_button_stock_response_id_set(EWL_BUTTON_STOCK(button),
-                                        EWL_RESPONSE_CANCEL);
+       button = ewl_button_new();
+       ewl_button_stock_type_set(EWL_BUTTON(button), EWL_STOCK_CANCEL);
        ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_HFILL);
        ewl_object_alignment_set(EWL_OBJECT(button), EWL_FLAG_ALIGN_CENTER);
        ewl_callback_append(button, EWL_CALLBACK_CLICKED,
@@ -446,7 +441,7 @@
        cd = user_data;
        ewl_callback_call_with_event_data(EWL_WIDGET(cd),
                                          EWL_CALLBACK_VALUE_CHANGED,
-                                         &EWL_BUTTON_STOCK(w)->response_id);
+                                         &EWL_BUTTON(w)->stock_type);
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_dialog.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -3 -r1.7 -r1.8
--- ewl_dialog.c        10 Oct 2005 04:49:22 -0000      1.7
+++ ewl_dialog.c        10 Oct 2005 15:27:10 -0000      1.8
@@ -7,17 +7,22 @@
  * @return Returns a pointer to a new dialog on success, NULL on failure.
  * @brief Create a new internal dialog
  */
-Ewl_Widget *ewl_dialog_new(void)
+Ewl_Widget *
+ewl_dialog_new(void)
 {
        Ewl_Dialog *d;
 
        DENTER_FUNCTION(DLEVEL_STABLE);
 
        d = NEW(Ewl_Dialog, 1);
-       if (!d)
+       if (!d) {
                DRETURN_PTR(NULL, DLEVEL_STABLE);
+       }
 
-       ewl_dialog_init(d);
+       if (!ewl_dialog_init(d)) {
+               ewl_widget_destroy(EWL_WIDGET(d));
+               d = NULL;
+       }
 
        DRETURN_PTR(EWL_WIDGET(d), DLEVEL_STABLE);
 }
@@ -27,18 +32,19 @@
  * @return Return TRUE on success, FALSE otherwise.
  * @brief Initialize an internal dialog to starting values
  */
-int ewl_dialog_init(Ewl_Dialog * dialog)
+int
+ewl_dialog_init(Ewl_Dialog *dialog)
 {
        Ewl_Widget *w;
-       Ewl_Widget *spacer;
 
        DENTER_FUNCTION(DLEVEL_STABLE);
-       DCHECK_PARAM_PTR_RET("d", dialog, 0);
+       DCHECK_PARAM_PTR_RET("dialog", dialog, FALSE);
 
        w = EWL_WIDGET(dialog);
 
-       if (!ewl_window_init(EWL_WINDOW(dialog)))
+       if (!ewl_window_init(EWL_WINDOW(dialog))) {
                DRETURN_INT(FALSE, DLEVEL_STABLE);
+       }
 
        ewl_widget_appearance_set(w, "window");
        ewl_widget_inherit(w, "dialog");
@@ -49,57 +55,50 @@
         * Create a box for laying out the whole window
         */
        dialog->box = ewl_vbox_new();
-       if (dialog->box) {
-               ewl_container_child_append(EWL_CONTAINER(dialog), dialog->box);
-               ewl_object_fill_policy_set(EWL_OBJECT(dialog->box),
-                                          EWL_FLAG_FILL_ALL);
-               ewl_widget_show(dialog->box);
+       if (!dialog->box) {
+               DRETURN_INT(FALSE, DLEVEL_STABLE);
        }
+       ewl_container_child_append(EWL_CONTAINER(dialog), dialog->box);
+       ewl_widget_internal_set(dialog->box, TRUE);
+       ewl_object_fill_policy_set(EWL_OBJECT(dialog->box), EWL_FLAG_FILL_ALL);
+       ewl_widget_show(dialog->box);
 
        /*
         * Setup a vertical box for the displayed window contents.
         */
        dialog->vbox = ewl_vbox_new();
-       ewl_object_fill_policy_set(EWL_OBJECT(dialog->vbox), EWL_FLAG_FILL_ALL);
-       if (dialog->vbox) {
-               ewl_container_child_append(EWL_CONTAINER(dialog->box),
-                                          dialog->vbox);
-               ewl_box_homogeneous_set(EWL_BOX(dialog->vbox), FALSE);
-               dialog->action_area = ewl_hbox_new();
-               dialog->separator = ewl_hseparator_new();
-               ewl_widget_show(dialog->vbox);
+       if (!dialog->vbox) {
+               DRETURN_INT(FALSE, DLEVEL_STABLE);
        }
 
-       if (dialog->separator) {
-               ewl_container_child_append(EWL_CONTAINER(dialog->box),
-                                          dialog->separator);
-               ewl_widget_show(dialog->separator);
+       ewl_container_child_append(EWL_CONTAINER(dialog->box), dialog->vbox);
+       ewl_widget_internal_set(dialog->vbox, TRUE);
+       ewl_box_homogeneous_set(EWL_BOX(dialog->vbox), FALSE);
+       ewl_object_fill_policy_set(EWL_OBJECT(dialog->vbox), EWL_FLAG_FILL_ALL);
+       ewl_widget_show(dialog->vbox);
+
+       dialog->separator = ewl_hseparator_new();
+       if (!dialog->separator) {
+               DRETURN_INT(FALSE, DLEVEL_STABLE);
        }
+       ewl_container_child_append(EWL_CONTAINER(dialog->box), 
dialog->separator);
+       ewl_widget_show(dialog->separator);
 
        /*
         * Create an action area for buttons
         */
-       if (dialog->action_area) {
-               ewl_container_child_append(EWL_CONTAINER(dialog->box),
+       dialog->action_area = ewl_hbox_new();
+       if (!dialog->action_area) {
+               DRETURN_INT(FALSE, DLEVEL_STABLE);
+       }
+       ewl_container_child_append(EWL_CONTAINER(dialog->box),
                                           dialog->action_area);
-               ewl_object_fill_policy_set(EWL_OBJECT(dialog->action_area),
-                                          EWL_FLAG_FILL_HFILL);
+       ewl_object_fill_policy_set(EWL_OBJECT(dialog->action_area),
+                          EWL_FLAG_FILL_HFILL | EWL_FLAG_FILL_VSHRINK);
+       ewl_box_homogeneous_set(EWL_BOX(dialog->action_area), FALSE);
+       ewl_widget_show(dialog->action_area);
 
-               ewl_box_homogeneous_set(EWL_BOX(dialog->action_area),
-                                       FALSE);
-               ewl_widget_show(dialog->action_area);
-
-               spacer = ewl_spacer_new();
-               ewl_container_child_append(EWL_CONTAINER
-                                          (dialog->action_area), spacer);
-               ewl_object_fill_policy_set(EWL_OBJECT(spacer),
-                                          EWL_FLAG_FILL_FILL);
-               ewl_widget_show(spacer);
-
-               ewl_container_redirect_set(EWL_CONTAINER(dialog),
-                                          EWL_CONTAINER(dialog->
-                                                        action_area));
-       }
+       ewl_dialog_active_area_set(dialog, dialog->position);
 
        DRETURN_INT(TRUE, DLEVEL_STABLE);
 }
@@ -110,13 +109,15 @@
  * @return Returns no value.
  * @brief Changes the action area position for a dialog.
  */
-void ewl_dialog_action_position_set(Ewl_Dialog *d, Ewl_Position pos)
+void
+ewl_dialog_action_position_set(Ewl_Dialog *d, Ewl_Position pos)
 {
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR("d", d);
 
-       if (pos == d->position)
+       if (pos == d->position) {
                DRETURN(DLEVEL_STABLE);
+       }
 
        d->position = pos;
 
@@ -167,7 +168,8 @@
  * @return Returns the current action area position.
  * @brief Checks the action area position for a dialog.
  */
-Ewl_Position ewl_dialog_action_position_get(Ewl_Dialog *d)
+Ewl_Position
+ewl_dialog_action_position_get(Ewl_Dialog *d)
 {
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR_RET("d", d, EWL_POSITION_BOTTOM);
@@ -176,120 +178,15 @@
 }
 
 /**
- * @param dialog: the dialog to add the widget in.
- * @param w: the widget to add in the vbox.
- * @return Returns no value.
- * @brief Convenient function to add widgets in the vbox.
- */
-void ewl_dialog_widget_add(Ewl_Dialog * dialog, Ewl_Widget * w)
-{
-       DENTER_FUNCTION(DLEVEL_STABLE);
-       DCHECK_PARAM_PTR("d", dialog);
-
-       if (!dialog)
-               return;
-
-       switch (dialog->position) {
-       case EWL_POSITION_LEFT:
-               {
-                       ewl_container_child_append(EWL_CONTAINER(dialog->vbox),
-                                                  w);
-                       break;
-               }
-       case EWL_POSITION_TOP:
-               {
-                       ewl_container_child_append(EWL_CONTAINER(dialog->vbox),
-                                                  w);
-                       break;
-               }
-       case EWL_POSITION_RIGHT:
-               {
-                       ewl_container_child_prepend(EWL_CONTAINER(dialog->vbox),
-                                                   w);
-                       break;
-               }
-       default:
-               {
-                       ewl_container_child_prepend(EWL_CONTAINER(dialog->vbox),
-                                                   w);
-                       break;
-               }
-       }
-
-       DLEAVE_FUNCTION(DLEVEL_STABLE);
-}
-
-/**
- * @param dialog: the dialog to add the button in.
- * @param button_text: the text of the button or a stock Id.
- * @param response_id: The Id that will be retured when clicking on the button.
- * @return Returns a button, or NULL on failure.
- * @brief Add a (stock) button on the right of the action_area of @a dialog.
- */
-Ewl_Widget *ewl_dialog_button_add(Ewl_Dialog * dialog, char *button_text,
-                                 int response_id)
-{
-       Ewl_Widget *button;
-
-       DENTER_FUNCTION(DLEVEL_STABLE);
-       DCHECK_PARAM_PTR_RET("d", dialog, 0);
-
-       if (!dialog)
-               return NULL;
-
-       button = ewl_button_stock_new();
-       ewl_button_stock_id_set(EWL_BUTTON_STOCK(button), button_text);
-       ewl_button_stock_response_id_set(EWL_BUTTON_STOCK(button), response_id);
-       ewl_object_padding_set(EWL_OBJECT(button), 0, 3, 3, 3);
-       ewl_container_child_append(EWL_CONTAINER(dialog->action_area),
-                                  button);
-       ewl_object_fill_policy_set(EWL_OBJECT(button),
-                                  EWL_FLAG_FILL_VFILL
-                                  || EWL_FLAG_FILL_SHRINK);
-
-       DRETURN_PTR(button, DLEVEL_STABLE);
-}
-
-/**
- * @param dialog: the dialog to add the button in.
- * @param button_text: the text of the button or a stock Id.
- * @param response_id: The Id that will be retured when clicking on the button.
- * @return Returns a button, or NULL on failure.
- * @brief Same as ewl_dialog_add_button(), but add the button on the left.
- */
-Ewl_Widget *ewl_dialog_button_left_add(Ewl_Dialog * dialog,
-                                      char *button_text, int response_id)
-{
-       Ewl_Widget *button;
-
-       DENTER_FUNCTION(DLEVEL_STABLE);
-       DCHECK_PARAM_PTR_RET("d", dialog, 0);
-
-       if (!dialog)
-               return NULL;
-
-       button = ewl_button_stock_new();
-       ewl_button_stock_id_set(EWL_BUTTON_STOCK(button), button_text);
-       ewl_button_stock_response_id_set(EWL_BUTTON_STOCK(button), response_id);
-       ewl_object_padding_set(EWL_OBJECT(button), 0, 3, 3, 3);
-       ewl_container_child_prepend(EWL_CONTAINER(dialog->action_area),
-                                   button);
-       ewl_object_fill_policy_set(EWL_OBJECT(button),
-                                  EWL_FLAG_FILL_VFILL
-                                  || EWL_FLAG_FILL_SHRINK);
-
-       DRETURN_PTR(button, DLEVEL_STABLE);
-}
-
-/**
  * @param dialog: the dialog.
  * @return Returns TRUE if @a dialog has a separator.
  * @brief Checks if @a dialog has a separator or not.
  */
-unsigned int ewl_dialog_has_separator_get(Ewl_Dialog * dialog)
+unsigned int
+ewl_dialog_has_separator_get(Ewl_Dialog *dialog)
 {
        DENTER_FUNCTION(DLEVEL_STABLE);
-       DCHECK_PARAM_PTR_RET("d", dialog, 0);
+       DCHECK_PARAM_PTR_RET("dialog", dialog, 0);
 
        if (!dialog)
                return FALSE;
@@ -304,31 +201,24 @@
  * @brief Sets the separator of @a dialog.
  */
 void
-ewl_dialog_has_separator_set(Ewl_Dialog * dialog, unsigned int has_sep)
+ewl_dialog_has_separator_set(Ewl_Dialog *dialog, unsigned int has_sep)
 {
        Ewl_Widget *child;
        int n;
 
        DENTER_FUNCTION(DLEVEL_STABLE);
-       DCHECK_PARAM_PTR("d", dialog);
+       DCHECK_PARAM_PTR("dialog", dialog);
 
        if (!dialog)
                DLEAVE_FUNCTION(DLEVEL_STABLE);
 
        if (has_sep && (dialog->separator == NULL)) {
-               ewl_container_child_iterate_begin(EWL_CONTAINER(EWL_DIALOG
-                                                               (dialog)->
-                                                               vbox));
+               
ewl_container_child_iterate_begin(EWL_CONTAINER(EWL_DIALOG(dialog)->vbox));
                n = 0;
-               child = ewl_container_child_next(EWL_CONTAINER(EWL_DIALOG
-                                                              (dialog)->
-                                                              vbox));
+               child = 
ewl_container_child_next(EWL_CONTAINER(EWL_DIALOG(dialog)->vbox));
                while (child) {
                        n++;
-                       child =
-                           ewl_container_child_next(EWL_CONTAINER
-                                                    (EWL_DIALOG(dialog)->
-                                                     vbox));
+                       child = 
ewl_container_child_next(EWL_CONTAINER(EWL_DIALOG(dialog)->vbox));
                }
                dialog->separator = ewl_hseparator_new();
                ewl_container_child_insert(EWL_CONTAINER(dialog->vbox),
@@ -344,3 +234,32 @@
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
+
+void
+ewl_dialog_active_area_set(Ewl_Dialog *d, Ewl_Position pos)
+{
+       DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR("d", d);
+
+       d->active_area = pos;
+
+       if (pos == d->position)
+               ewl_container_redirect_set(EWL_CONTAINER(d),
+                                          EWL_CONTAINER(d->action_area));
+       else
+               ewl_container_redirect_set(EWL_CONTAINER(d),
+                                          EWL_CONTAINER(d->vbox));
+
+       DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+Ewl_Position
+ewl_dialog_active_area_get(Ewl_Dialog *d)
+{
+       DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR_RET("d", d, EWL_POSITION_TOP);
+
+       DRETURN_INT(d->active_area, DLEVEL_STABLE);
+}
+
+
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_dialog.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- ewl_dialog.h        9 Oct 2005 05:18:39 -0000       1.4
+++ ewl_dialog.h        10 Oct 2005 15:27:10 -0000      1.5
@@ -47,6 +47,7 @@
        Ewl_Widget  *separator;   /* The separator between vbox and action_area 
*/
 
        Ewl_Position position;    /* Position of the action_area */
+       Ewl_Position active_area; /* Which section of the dialog is active */
 };
   
 Ewl_Widget  *ewl_dialog_new (void);
@@ -55,11 +56,8 @@
 void         ewl_dialog_action_position_set(Ewl_Dialog *d, Ewl_Position pos);
 Ewl_Position ewl_dialog_action_position_get(Ewl_Dialog *dialog);
 
-void         ewl_dialog_widget_add(Ewl_Dialog *dialog, Ewl_Widget *w);
-Ewl_Widget  *ewl_dialog_button_add(Ewl_Dialog *dialog, char *button_text,
-                                  int response_id);
-Ewl_Widget  *ewl_dialog_button_left_add(Ewl_Dialog *dialog, char *button_text,
-                                       int response_id);
+void         ewl_dialog_active_area_set(Ewl_Dialog *d, Ewl_Position pos);
+Ewl_Position ewl_dialog_active_area_get(Ewl_Dialog *d);
 
 unsigned int ewl_dialog_has_separator_get (Ewl_Dialog *dialog);
 void         ewl_dialog_has_separator_set (Ewl_Dialog *dialog,
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_enums.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -3 -r1.13 -r1.14
--- ewl_enums.h 6 Oct 2005 03:49:52 -0000       1.13
+++ ewl_enums.h 10 Oct 2005 15:27:10 -0000      1.14
@@ -270,25 +270,27 @@
 
 typedef enum Ewl_Key_Modifiers Ewl_Key_Modifiers;
 
-/**
- * @enum Ewl_Response_Type
- */
-enum Ewl_Response_Type
+enum Ewl_Stock_Type
 {
-       EWL_RESPONSE_OPEN     = -5,
-       EWL_RESPONSE_SAVE     = -6,
-       EWL_RESPONSE_OK       = -10,
-       EWL_RESPONSE_CANCEL   = -11,
-       EWL_RESPONSE_APPLY    = -12,
-       EWL_RESPONSE_PLAY     = -20,
-       EWL_RESPONSE_PAUSE    = -21,
-       EWL_RESPONSE_STOP     = -22,
-       EWL_RESPONSE_QUIT     = -23,
-       EWL_RESPONSE_ARROW_UP = -24,
-       EWL_RESPONSE_HOME     = -25,
+       EWL_STOCK_APPLY = 0,
+       EWL_STOCK_ARROW_DOWN,
+       EWL_STOCK_ARROW_LEFT,
+       EWL_STOCK_ARROW_RIGHT,
+       EWL_STOCK_ARROW_UP,
+       EWL_STOCK_CANCEL,
+       EWL_STOCK_FASTFORWARD,
+       EWL_STOCK_HOME,
+       EWL_STOCK_OK,
+       EWL_STOCK_OPEN,
+       EWL_STOCK_PAUSE,
+       EWL_STOCK_PLAY,
+       EWL_STOCK_QUIT,
+       EWL_STOCK_REWIND,
+       EWL_STOCK_SAVE,
+       EWL_STOCK_STOP,
+       EWL_STOCK_NONE
 };
-
-typedef enum Ewl_Response_Type Ewl_Response_Type;
+typedef enum Ewl_Stock_Type Ewl_Stock_Type;
 
 /**
  * @enum Ewl_Color_Pick_Mode
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_filedialog.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- ewl_filedialog.c    5 Oct 2005 05:41:01 -0000       1.6
+++ ewl_filedialog.c    10 Oct 2005 15:27:10 -0000      1.7
@@ -83,20 +83,16 @@
        ewl_widget_show(box);
 
        /* Buttons */
-       fd->confirm = ewl_button_stock_new();
-       ewl_button_stock_id_set(EWL_BUTTON_STOCK(fd->confirm), EWL_STOCK_OPEN);
-       ewl_button_stock_response_id_set(EWL_BUTTON_STOCK(fd->confirm),
-                                        EWL_RESPONSE_OPEN);
+       fd->confirm = ewl_button_new();
+       ewl_button_stock_type_set(EWL_BUTTON(fd->confirm), EWL_STOCK_OPEN);
 
        ewl_callback_append(fd->confirm, EWL_CALLBACK_CLICKED,
                                                ewl_filedialog_click_cb, fd);
        ewl_container_child_append(EWL_CONTAINER(box), fd->confirm);
        ewl_widget_show(fd->confirm);
 
-       fd->cancel = ewl_button_stock_new();
-       ewl_button_stock_id_set(EWL_BUTTON_STOCK(fd->cancel), EWL_STOCK_CANCEL);
-       ewl_button_stock_response_id_set(EWL_BUTTON_STOCK(fd->cancel),
-                                        EWL_RESPONSE_CANCEL);
+       fd->cancel = ewl_button_new();
+       ewl_button_stock_type_set(EWL_BUTTON(fd->cancel), EWL_STOCK_CANCEL);
        ewl_callback_append(fd->cancel, EWL_CALLBACK_CLICKED,
                                                ewl_filedialog_click_cb, fd);
        ewl_container_child_append(EWL_CONTAINER(box), fd->cancel);
@@ -129,16 +125,10 @@
        DCHECK_PARAM_PTR("fd", fd);
 
        if (t == EWL_FILEDIALOG_TYPE_OPEN) {
-               ewl_button_stock_id_set(EWL_BUTTON_STOCK(fd->confirm),
-                                       EWL_STOCK_OPEN);
-               ewl_button_stock_response_id_set(EWL_BUTTON_STOCK(fd->confirm),
-                                                EWL_RESPONSE_OPEN);
+               ewl_button_stock_type_set(EWL_BUTTON(fd->confirm), 
EWL_STOCK_OPEN);
        }
        else if (t == EWL_FILEDIALOG_TYPE_SAVE) {
-               ewl_button_stock_id_set(EWL_BUTTON_STOCK(fd->confirm),
-                                       EWL_STOCK_SAVE);
-               ewl_button_stock_response_id_set(EWL_BUTTON_STOCK(fd->confirm),
-                                                EWL_RESPONSE_SAVE);
+               ewl_button_stock_type_set(EWL_BUTTON(fd->confirm), 
EWL_STOCK_SAVE);
        }
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
@@ -248,14 +238,14 @@
 /*
  * Internally used callback, override at your own risk.
  */
-void ewl_filedialog_click_cb(Ewl_Widget * w, void *ev_data __UNUSED__,
+void ewl_filedialog_click_cb(Ewl_Widget *w, void *ev_data __UNUSED__,
                                                                void* data)
 {
        Ewl_Filedialog *fd = EWL_FILEDIALOG(data);
 
        ewl_callback_call_with_event_data(EWL_WIDGET(fd),
                                          EWL_CALLBACK_VALUE_CHANGED,
-                                         &EWL_BUTTON_STOCK(w)->response_id);
+                                         &EWL_BUTTON(w)->stock_type);
 }
 
 
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/lib/ewl_fileselector.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -3 -r1.25 -r1.26
--- ewl_fileselector.c  5 Oct 2005 05:41:01 -0000       1.25
+++ ewl_fileselector.c  10 Oct 2005 15:27:10 -0000      1.26
@@ -116,26 +116,18 @@
                                           EWL_FLAG_FILL_FILL);
                ewl_widget_show(misc);
 
-               button = ewl_button_stock_new();
-               ewl_button_stock_id_set(EWL_BUTTON_STOCK(button),
-                                       EWL_STOCK_ARROW_UP);
-               ewl_button_stock_response_id_set(EWL_BUTTON_STOCK(button),
-                                                EWL_RESPONSE_ARROW_UP);
+               button = ewl_button_new();
+               ewl_button_stock_type_set(EWL_BUTTON(button), 
EWL_STOCK_ARROW_UP);
                ewl_callback_append(button, EWL_CALLBACK_CLICKED,
                                    ewl_fileselector_go_up_cb, fs);
                ewl_container_child_append(EWL_CONTAINER(hbox), button);
                ewl_widget_show(button);
 
-               button = ewl_button_stock_new();
-               ewl_button_stock_id_set(EWL_BUTTON_STOCK(button),
-                                       EWL_STOCK_HOME);
-               ewl_button_stock_response_id_set(EWL_BUTTON_STOCK(button),
-                                                EWL_RESPONSE_HOME);
-               button = ewl_button_stock_new();
-               ewl_button_stock_id_set(EWL_BUTTON_STOCK(button),
-                                       EWL_STOCK_HOME);
-               ewl_button_stock_response_id_set(EWL_BUTTON_STOCK(button),
-                                                EWL_RESPONSE_HOME);
+               button = ewl_button_new();
+               ewl_button_stock_type_set(EWL_BUTTON(button), EWL_STOCK_HOME);
+
+               button = ewl_button_new();
+               ewl_button_stock_type_set(EWL_BUTTON(button), EWL_STOCK_HOME);
                ewl_callback_append(button, EWL_CALLBACK_CLICKED,
                                    ewl_fileselector_go_home_cb, fs);
                ewl_container_child_append(EWL_CONTAINER(hbox), button);




-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to