changeset 2041:034d4d1baf33

merge
author Jorge Arellano Cid <jcid@dillo.org>
date Fri, 20 May 2011 10:29:07 -0400
parents 6c012332ba15 (current diff) db2bd1610db1 (diff)
children 8f021c978252
files
diffstat 6 files changed, 33 insertions(+), 131 deletions(-) [+]
line wrap: on
line diff
--- a/dpi/cookies.c	Wed May 18 14:22:14 2011 -0400
+++ b/dpi/cookies.c	Fri May 20 10:29:07 2011 -0400
@@ -412,15 +412,24 @@
    while ((node = dList_nth_data(domains, 0))) {
       for (i = 0; (cookie = dList_nth_data(node->cookies, i)); ++i) {
          if (!cookie->session_only && difftime(cookie->expires_at, now) > 0) {
-            fprintf(file_stream, "%s\t%s\t%s\t%s\t%ld\t%s\t%s\n",
-                    cookie->domain,
-                    cookie->host_only ? "FALSE" : "TRUE",
-                    cookie->path,
-                    cookie->secure ? "TRUE" : "FALSE",
-                    (long)difftime(cookie->expires_at, cookies_epoch_time),
-                    cookie->name,
-                    cookie->value);
-            saved++;
+            int len;
+            char buf[LINE_MAXLEN];
+
+            len = snprintf(buf, LINE_MAXLEN, "%s\t%s\t%s\t%s\t%ld\t%s\t%s\n",
+                           cookie->domain,
+                           cookie->host_only ? "FALSE" : "TRUE",
+                           cookie->path,
+                           cookie->secure ? "TRUE" : "FALSE",
+                           (long) difftime(cookie->expires_at,
+                                           cookies_epoch_time),
+                           cookie->name,
+                           cookie->value);
+            if (len < LINE_MAXLEN) {
+               fprintf(file_stream, "%s", buf);
+               saved++;
+            } else {
+               MSG("Not saving overly long cookie for %s.\n", cookie->domain);
+            }
          }
          Cookies_free_cookie(cookie);
       }
--- a/dpi/downloads.cc	Wed May 18 14:22:14 2011 -0400
+++ b/dpi/downloads.cc	Fri May 20 10:29:07 2011 -0400
@@ -431,7 +431,7 @@
    int idx = (strcmp(dl_argv[1], "-c")) ? 2 : 3;
    dFree(dl_argv[idx]);
    dFree(dl_argv[idx+3]);
-   delete(dl_argv);
+   delete [] dl_argv;
 
    delete(group);
 }
--- a/dw/fltkcomplexbutton.cc	Wed May 18 14:22:14 2011 -0400
+++ b/dw/fltkcomplexbutton.cc	Fri May 20 10:29:07 2011 -0400
@@ -29,7 +29,6 @@
   Sets the current value of the button.
   A non-zero value sets the button to 1 (ON), and zero sets it to 0 (OFF).
   \param[in] v button value.
-  \see set(), clear()
  */
 int ComplexButton::value(int v) {
   v = v ? 1 : 0;
@@ -38,38 +37,15 @@
   if (value_ != v) {
     value_ = v;
     if (box()) redraw();
-    else redraw_label();
     return 1;
   } else {
     return 0;
   }
 }
 
-/**
-  Turns on this button and turns off all other radio buttons in the group
-  (calling \c value(1) or \c set() does not do this).
- */
-void ComplexButton::setonly() { // set this radio button on, turn others off
-  value(1);
-  Fl_Group* g = parent();
-  Fl_Widget*const* a = g->array();
-  for (int i = g->children(); i--;) {
-    Fl_Widget* o = *a++;
-    if (o != this && o->type()==FL_RADIO_BUTTON) ((Fl_Button*)o)->value(0);
-  }
-}
-
 void ComplexButton::draw() {
-  if (type() == FL_HIDDEN_BUTTON) return;
   Fl_Color col = value() ? selection_color() : color();
   draw_box(value() ? (down_box()?down_box():fl_down(box())) : box(), col);
-  draw_backdrop();
-  if (labeltype() == FL_NORMAL_LABEL && value()) {
-    Fl_Color c = labelcolor();
-    labelcolor(fl_contrast(c, col));
-    draw_label();
-    labelcolor(c);
-  } else draw_label();
   if (Fl::focus() == this) draw_focus();
 
   // ComplexButton is a Group; draw its children
@@ -85,14 +61,12 @@
   switch (event) {
   case FL_ENTER: /* FALLTHROUGH */
   case FL_LEAVE:
-//  if ((value_?selection_color():color())==FL_GRAY) redraw();
     return 1;
   case FL_PUSH:
     if (Fl::visible_focus() && handle(FL_FOCUS)) Fl::focus(this);
   case FL_DRAG:
     if (Fl::event_inside(this)) {
-      if (type() == FL_RADIO_BUTTON) newval = 1;
-      else newval = !oldval;
+      newval = !oldval;
     } else
     {
       clear_changed();
@@ -111,24 +85,15 @@
       return 1;
     }
     set_changed();
-    if (type() == FL_RADIO_BUTTON) setonly();
-    else if (type() == FL_TOGGLE_BUTTON) oldval = value_;
-    else {
-      value(oldval);
-      set_changed();
-      if (when() & FL_WHEN_CHANGED) {
-        Fl_Widget_Tracker wp(this);
-        do_callback();
-        if (wp.deleted()) return 1;
-      }
+    value(oldval);
+    set_changed();
+    if (when() & FL_WHEN_CHANGED) {
+      Fl_Widget_Tracker wp(this);
+      do_callback();
+      if (wp.deleted()) return 1;
     }
     if (when() & FL_WHEN_RELEASE) do_callback();
     return 1;
-  case FL_SHORTCUT:
-    if (!(shortcut() ?
-          Fl::test_shortcut(shortcut()) : test_shortcut())) return 0;
-    if (Fl::visible_focus() && handle(FL_FOCUS)) Fl::focus(this);
-    goto triggered_by_keyboard;
   case FL_FOCUS : /* FALLTHROUGH */
   case FL_UNFOCUS :
     if (Fl::visible_focus()) {
@@ -146,15 +111,7 @@
     if (Fl::focus() == this && Fl::event_key() == ' ' &&
         !(Fl::event_state() & (FL_SHIFT | FL_CTRL | FL_ALT | FL_META))) {
       set_changed();
-    triggered_by_keyboard:
       Fl_Widget_Tracker wp(this);
-      if (type() == FL_RADIO_BUTTON && !value_) {
-        setonly();
-        if (when() & FL_WHEN_CHANGED) do_callback();
-      } else if (type() == FL_TOGGLE_BUTTON) {
-        value(!value());
-        if (when() & FL_WHEN_CHANGED) do_callback();
-      }
       if (wp.deleted()) return 1;
       if (when() & FL_WHEN_RELEASE) do_callback();
       return 1;
@@ -175,7 +132,6 @@
   box(FL_UP_BOX);
   down_box(FL_NO_BOX);
   value_ = oldval = 0;
-  shortcut_ = 0;
 }
 
 ComplexButton::~ComplexButton() {
--- a/dw/fltkcomplexbutton.hh	Wed May 18 14:22:14 2011 -0400
+++ b/dw/fltkcomplexbutton.hh	Fri May 20 10:29:07 2011 -0400
@@ -22,15 +22,6 @@
 
 #include <FL/Fl_Group.H>
 
-// values for type()
-#define FL_NORMAL_BUTTON	0   /**< value() will be set to 1 during the press of the button and
-                                         reverts back to 0 when the button is released */
-#define FL_TOGGLE_BUTTON	1   ///< value() toggles between 0 and 1 at every click of the button
-#define FL_RADIO_BUTTON		(FL_RESERVED_TYPE+2) /**< is set to 1 at button press, and all other
-				         buttons in the same group with <tt>type() == FL_RADIO_BUTTON</tt>
-				         are set to zero.*/
-#define FL_HIDDEN_BUTTON	3   ///< for Forms compatibility
-
 extern FL_EXPORT Fl_Shortcut fl_old_shortcut(const char*);
 
 namespace dw {
@@ -45,15 +36,9 @@
   uchar down_box_;
 
 protected:
-
-  static Fl_Widget_Tracker *key_release_tracker;
-  static void key_release_timeout(void*);
-  void simulate_key_action();
-
   virtual void draw();
 
 public:
-
   virtual int handle(int);
 
   ComplexButton(int X, int Y, int W, int H, const char *L = 0);
@@ -67,47 +52,6 @@
   char value() const {return value_;}
 
   /**
-    Same as \c value(1).
-    \see value(int v)
-   */
-  int set() {return value(1);}
-
-  /**
-    Same as \c value(0).
-    \see value(int v)
-   */
-  int clear() {return value(0);}
-
-  void setonly(); // this should only be called on FL_RADIO_BUTTONs
-
-  /**
-    Returns the current shortcut key for the button.
-    \retval int
-   */
-  int shortcut() const {return shortcut_;}
-
-  /**
-    Sets the shortcut key to \c s.
-    Setting this overrides the use of '\&' in the label().
-    The value is a bitwise OR of a key and a set of shift flags, for example:
-    <tt>FL_ALT | 'a'</tt>, or
-    <tt>FL_ALT | (FL_F + 10)</tt>, or just
-    <tt>'a'</tt>.
-    A value of 0 disables the shortcut.
-
-    The key can be any value returned by Fl::event_key(), but will usually be
-    an ASCII letter.  Use a lower-case letter unless you require the shift key
-    to be held down.
-
-    The shift flags can be any set of values accepted by Fl::event_state().
-    If the bit is on, that shift key must be pushed.  Meta, Alt, Ctrl, and
-    Shift must be off if they are not in the shift flags (zero for the other
-    bits indicates a "don't care" setting).
-    \param[in] s bitwise OR of key and shift flags
-   */
-  void shortcut(int s) {shortcut_ = s;}
-
-  /**
     Returns the current down box type, which is drawn when value() is non-zero.
     \retval Fl_Boxtype
    */
@@ -119,15 +63,6 @@
     \param[in] b down box type
    */
   void down_box(Fl_Boxtype b) {down_box_ = b;}
-
-  /// (for backwards compatibility)
-  void shortcut(const char *s) {shortcut(fl_old_shortcut(s));}
-
-  /// (for backwards compatibility)
-  Fl_Color down_color() const {return selection_color();}
-
-  /// (for backwards compatibility)
-  void down_color(unsigned c) {selection_color(c);}
 };
 
 } // namespace ui
--- a/dw/fltkui.cc	Wed May 18 14:22:14 2011 -0400
+++ b/dw/fltkui.cc	Fri May 20 10:29:07 2011 -0400
@@ -1092,7 +1092,7 @@
    }
 }
 
-void *FltkListResource::newItem (const char *str, bool enabled)
+void *FltkListResource::newItem (const char *str, bool enabled, bool selected)
 {
    Fl_Tree *tree = (Fl_Tree *) widget;
    Fl_Tree_Item *parent = (Fl_Tree_Item *)currParent;
@@ -1103,6 +1103,7 @@
    item->activate(enabled);
    item->user_data((void *)index);
    itemsSelected.increase ();
+   itemsSelected.set (itemsSelected.size() - 1, selected);
 
    return item;
 }
@@ -1110,12 +1111,11 @@
 void FltkListResource::addItem (const char *str, bool enabled, bool selected)
 {
    Fl_Tree *tree = (Fl_Tree *) widget;
-   Fl_Tree_Item *item = (Fl_Tree_Item *) newItem(str, enabled);
+   Fl_Tree_Item *item = (Fl_Tree_Item *) newItem(str, enabled, selected);
 
    if (selected) {
       if (mode == SELECTION_MULTIPLE) {
          item->select(selected);
-         itemsSelected.set (itemsSelected.size() - 1, selected);
       } else {
          const bool do_callback = true;
          tree->select_only(item, do_callback);
@@ -1126,8 +1126,10 @@
 
 void FltkListResource::pushGroup (const char *name, bool enabled)
 {
+   bool selected = false;
+
    /* TODO: make it impossible to select a group */
-   currParent = (Fl_Tree_Item *) newItem(name, enabled);
+   currParent = (Fl_Tree_Item *) newItem(name, enabled, selected);
    queueResize (true);
 }
 
--- a/dw/fltkui.hh	Wed May 18 14:22:14 2011 -0400
+++ b/dw/fltkui.hh	Fri May 20 10:29:07 2011 -0400
@@ -490,7 +490,7 @@
 
 private:
    static void widgetCallback (Fl_Widget *widget, void *data);
-   void *newItem (const char *str, bool enabled);
+   void *newItem (const char *str, bool enabled, bool selected);
    void *currParent;
    lout::misc::SimpleVector <bool> itemsSelected;
    int showRows;