almost done the ustring conversion
authorDana Jansens <danakj@orodu.net>
Mon, 13 Jan 2003 05:54:40 +0000 (05:54 +0000)
committerDana Jansens <danakj@orodu.net>
Mon, 13 Jan 2003 05:54:40 +0000 (05:54 +0000)
17 files changed:
otk/otk.hh
otk/otk.i
otk/property.cc
otk/ustring.cc
otk/ustring.hh
src/client.cc
src/client.hh
src/frame.cc
src/frame.hh
src/labelwidget.cc
src/labelwidget.hh
src/openbox.i
src/openbox_wrap.cc
src/python.cc
src/python.hh
src/screen.cc
src/screen.hh

index b6e24a7..b06afcb 100644 (file)
@@ -29,6 +29,7 @@
 #include "timerqueue.hh"
 #include "timerqueuemanager.hh"
 #include "util.hh"
+#include "ustring.hh"
 #include "widget.hh"
 
 #endif // __otk_hh
index 148ff0c..d0e4331 100644 (file)
--- a/otk/otk.i
+++ b/otk/otk.i
@@ -12,6 +12,7 @@
 
 %include "stl.i"
 //%include std_list.i
+%include "ustring.i"
 
 %ignore otk::OBDisplay::display;
 %inline %{
index 232803c..ab99cd8 100644 (file)
@@ -382,7 +382,7 @@ bool Property::get(Window win, Atoms atom, StringType type,
 
 
 bool Property::get(Window win, Atoms atom, StringType type,
-                     unsigned long *nelements, StringVect *strings) const
+                   unsigned long *nelements, StringVect *strings) const
 {
   assert(atom >= 0 && atom < NUM_ATOMS);
   assert(type >= 0 && type < NUM_STRING_TYPE);
index 8f3cdfc..c15effb 100644 (file)
@@ -142,6 +142,11 @@ ustring::size_type ustring::max_size() const
   return _string.max_size();
 }
 
+bool ustring::empty() const
+{
+  return _string.empty();
+}
+
 void ustring::clear()
 {
   _string.erase();
index ef94440..647bee8 100644 (file)
@@ -152,7 +152,7 @@ public:
   ustring(const ustring& other);
   ustring& operator=(const ustring& other);
   ustring(const std::string& src);
-  ustring::ustring(const char* src);
+  ustring(const char* src);
 
   // append to the string
 
@@ -166,6 +166,7 @@ public:
   ustring::size_type bytes() const;
   ustring::size_type capacity() const;
   ustring::size_type max_size() const;
+  bool empty() const;
 
   // erase substrings
 
index 0fc485c..cdef1f9 100644 (file)
@@ -531,15 +531,15 @@ void Client::updateClass()
 
   if (property->get(_window, otk::Property::wm_class,
                     otk::Property::ascii, &num, &v)) {
-    if (num > 0) _app_name = v[0];
-    if (num > 1) _app_class = v[1];
+    if (num > 0) _app_name = v[0].c_str();
+    if (num > 1) _app_class = v[1].c_str();
   }
 
   v.clear();
   num = 1;
   if (property->get(_window, otk::Property::wm_window_role,
                     otk::Property::ascii, &num, &v)) {
-    if (num > 0) _role = v[0];
+    if (num > 0) _role = v[0].c_str();
   }
 }
 
index 14b5a45..9bac56f 100644 (file)
@@ -12,6 +12,7 @@
 #include "otk/strut.hh"
 #include "otk/rect.hh"
 #include "otk/eventhandler.hh"
+#include "otk/ustring.hh"
 
 extern "C" {
 #include <X11/Xlib.h>
@@ -182,9 +183,9 @@ private:
   long _desktop;
 
   //! Normal window title
-  std::string  _title; // XXX: Have to keep track if this string is Utf8 or not
+  otk::ustring  _title;
   //! Window title when iconifiged
-  std::string  _icon_title;
+  otk::ustring  _icon_title;
 
   //! The application that created the window
   std::string  _app_name;
@@ -412,9 +413,9 @@ BB    @param window The window id that the Client class should handle
   */
   inline long desktop() const { return _desktop; }
   //! Returns the window's title
-  inline const std::string &title() const { return _title; }
+  inline const otk::ustring &title() const { return _title; }
   //! Returns the window's title when it is iconified
-  inline const std::string &iconTitle() const { return _title; }
+  inline const otk::ustring &iconTitle() const { return _title; }
   //! Returns the application's name to whom the window belongs
   inline const std::string &appName() const { return _app_name; }
   //! Returns the class of the window
index 12a42ec..a2a6cc0 100644 (file)
@@ -64,7 +64,7 @@ Frame::~Frame()
 }
 
 
-void Frame::setTitle(const std::string &text)
+void Frame::setTitle(const otk::ustring &text)
 {
   _label.setText(text);
   _label.update();
@@ -172,7 +172,7 @@ void Frame::adjustSize()
     // separation between titlebar elements
     const int sep = bevel + 1;
 
-    std::string layout;
+    otk::ustring layout;
     if (!python_get_string("titlebar_layout", &layout))
       layout = "ILMC";
 
index 0a22cba..7831284 100644 (file)
@@ -18,6 +18,7 @@ extern "C" {
 #include "otk/screeninfo.hh"
 #include "otk/style.hh"
 #include "otk/widget.hh"
+#include "otk/ustring.hh"
 
 #include <string>
 
@@ -88,7 +89,7 @@ public:
   //! Displays unfocused decorations
   virtual void unfocus();
 
-  void setTitle(const std::string &text);
+  void setTitle(const otk::ustring &text);
  
   //! Reparents the client window from the root window onto the frame
   void grabClient();
index 445ae26..16c8eae 100644 (file)
@@ -26,7 +26,7 @@ LabelWidget::~LabelWidget()
 }
 
 
-void LabelWidget::setText(const std::string &text)
+void LabelWidget::setText(const otk::ustring &text)
 {
   _text = text;
   _dirty = true;
@@ -77,7 +77,7 @@ void LabelWidget::update()
   otk::Widget::update();
 
   if (draw) {
-    std::string t = _text;
+    otk::ustring t = _text;
     int x = _sidemargin;    // x coord for the text
 
     // find a string that will fit inside the area for text
index 92c35c3..094cf86 100644 (file)
@@ -6,6 +6,7 @@
 #include "otk/widget.hh"
 #include "otk/font.hh"
 #include "otk/style.hh"
+#include "otk/ustring.hh"
 
 namespace ob {
 
@@ -17,7 +18,7 @@ private:
   otk::Color *_text_color;
   int _sidemargin;
   otk::Style::TextJustify _justify;
-  std::string _text;
+  otk::ustring _text;
   //! Object used by Xft to render to the drawable
   XftDraw *_xftdraw;
   
@@ -34,8 +35,8 @@ public:
 
   virtual void update();
 
-  inline const std::string &text() const { return _text; }
-  void setText(const std::string &text);
+  inline const otk::ustring &text() const { return _text; }
+  void setText(const otk::ustring &text);
 };
 
 }
index edc29ae..6f76850 100644 (file)
@@ -112,6 +112,8 @@ void python_callback(PyObject *func, KeyData *data)
   Display *Display_display() { return otk::Display::display; }
 %};
 
+%include "../otk/ustring.i"
+
 %include "../otk/display.hh"
 %include "../otk/point.hh"
 %include "../otk/property.hh"
index 533b004..e26d59e 100644 (file)
@@ -676,8 +676,8 @@ SWIG_InstallConstants(PyObject *d, swig_const_info constants[]) {
 #define  SWIGTYPE_p_XConfigureEvent swig_types[28] 
 #define  SWIGTYPE_p_XCirculateEvent swig_types[29] 
 #define  SWIGTYPE_p_XRectangle swig_types[30] 
-#define  SWIGTYPE_p_std__string swig_types[31] 
-#define  SWIGTYPE_p_ustring swig_types[32] 
+#define  SWIGTYPE_p_otk__ustring swig_types[31] 
+#define  SWIGTYPE_p_std__string swig_types[32] 
 #define  SWIGTYPE_p_XCrossingEvent swig_types[33] 
 #define  SWIGTYPE_p_Display swig_types[34] 
 #define  SWIGTYPE_p_otk__Display swig_types[35] 
@@ -885,6 +885,9 @@ void python_callback(PyObject *func, KeyData *data)
 
   Display *Display_display() { return otk::Display::display; }
 
+
+#include "ustring.hh"
+
 ob::Client *ob_Screen_client(ob::Screen *self,int i){
     if (i >= (int)self->clients.size())
       return NULL;
@@ -1506,7 +1509,8 @@ static PyObject *_wrap_Property_set__SWIG_2(PyObject *self, PyObject *args) {
     Window arg2 ;
     int arg3 ;
     int arg4 ;
-    ustring *arg5 = 0 ;
+    otk::ustring *arg5 = 0 ;
+    otk::ustring temp5 ;
     PyObject * obj0  = 0 ;
     PyObject * obj1  = 0 ;
     PyObject * obj4  = 0 ;
@@ -1515,11 +1519,15 @@ static PyObject *_wrap_Property_set__SWIG_2(PyObject *self, PyObject *args) {
     if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_otk__Property,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
     arg2 = (Window) PyInt_AsLong(obj1);
     if (PyErr_Occurred()) SWIG_fail;
-    if ((SWIG_ConvertPtr(obj4,(void **) &arg5, SWIGTYPE_p_ustring,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
-    if (arg5 == NULL) {
-        PyErr_SetString(PyExc_TypeError,"null reference"); SWIG_fail; 
+    {
+        if (PyString_Check(obj4)) {
+            temp5 = otk::ustring(PyString_AsString(obj4));
+            arg5 = &temp5;
+        }else {
+            SWIG_exception(SWIG_TypeError, "ustring expected");
+        }
     }
-    ((otk::Property const *)arg1)->set(arg2,(otk::Property::Atoms )arg3,(otk::Property::StringType )arg4,(ustring const &)*arg5);
+    ((otk::Property const *)arg1)->set(arg2,(otk::Property::Atoms )arg3,(otk::Property::StringType )arg4,(otk::ustring const &)*arg5);
     
     Py_INCREF(Py_None); resultobj = Py_None;
     return resultobj;
@@ -1591,7 +1599,7 @@ static PyObject *_wrap_Property_set(PyObject *self, PyObject *args) {
                     if (_v) {
                         {
                             void *ptr;
-                            if (SWIG_ConvertPtr(argv[4], (void **) &ptr, SWIGTYPE_p_ustring, 0) == -1) {
+                            if (SWIG_ConvertPtr(argv[4], (void **) &ptr, SWIGTYPE_p_otk__Property__StringVect, 0) == -1) {
                                 _v = 0;
                                 PyErr_Clear();
                             }else {
@@ -1599,7 +1607,7 @@ static PyObject *_wrap_Property_set(PyObject *self, PyObject *args) {
                             }
                         }
                         if (_v) {
-                            return _wrap_Property_set__SWIG_2(self,args);
+                            return _wrap_Property_set__SWIG_3(self,args);
                         }
                     }
                 }
@@ -1631,16 +1639,10 @@ static PyObject *_wrap_Property_set(PyObject *self, PyObject *args) {
                     }
                     if (_v) {
                         {
-                            void *ptr;
-                            if (SWIG_ConvertPtr(argv[4], (void **) &ptr, SWIGTYPE_p_otk__Property__StringVect, 0) == -1) {
-                                _v = 0;
-                                PyErr_Clear();
-                            }else {
-                                _v = 1;
-                            }
+                            _v = (PyInt_Check(argv[4]) || PyLong_Check(argv[4])) ? 1 : 0;
                         }
                         if (_v) {
-                            return _wrap_Property_set__SWIG_3(self,args);
+                            return _wrap_Property_set__SWIG_0(self,args);
                         }
                     }
                 }
@@ -1672,10 +1674,10 @@ static PyObject *_wrap_Property_set(PyObject *self, PyObject *args) {
                     }
                     if (_v) {
                         {
-                            _v = (PyInt_Check(argv[4]) || PyLong_Check(argv[4])) ? 1 : 0;
+                            _v = PyString_Check(argv[4]) ? 1 : 0;
                         }
                         if (_v) {
-                            return _wrap_Property_set__SWIG_0(self,args);
+                            return _wrap_Property_set__SWIG_2(self,args);
                         }
                     }
                 }
@@ -1795,7 +1797,7 @@ static PyObject *_wrap_Property_get__SWIG_2(PyObject *self, PyObject *args) {
     Window arg2 ;
     int arg3 ;
     int arg4 ;
-    std::string *arg5 = (std::string *) 0 ;
+    otk::ustring *arg5 = (otk::ustring *) 0 ;
     bool result;
     PyObject * obj0  = 0 ;
     PyObject * obj1  = 0 ;
@@ -1805,7 +1807,7 @@ static PyObject *_wrap_Property_get__SWIG_2(PyObject *self, PyObject *args) {
     if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_otk__Property,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
     arg2 = (Window) PyInt_AsLong(obj1);
     if (PyErr_Occurred()) SWIG_fail;
-    if ((SWIG_ConvertPtr(obj4,(void **) &arg5, SWIGTYPE_p_std__string,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
+    if ((SWIG_ConvertPtr(obj4,(void **) &arg5, SWIGTYPE_p_otk__ustring,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
     result = (bool)((otk::Property const *)arg1)->get(arg2,(otk::Property::Atoms )arg3,(otk::Property::StringType )arg4,arg5);
     
     resultobj = PyInt_FromLong((long)result);
@@ -1920,7 +1922,7 @@ static PyObject *_wrap_Property_get(PyObject *self, PyObject *args) {
                     if (_v) {
                         {
                             void *ptr;
-                            if (SWIG_ConvertPtr(argv[4], (void **) &ptr, SWIGTYPE_p_std__string, 0) == -1) {
+                            if (SWIG_ConvertPtr(argv[4], (void **) &ptr, SWIGTYPE_p_otk__ustring, 0) == -1) {
                                 _v = 0;
                                 PyErr_Clear();
                             }else {
@@ -5596,8 +5598,8 @@ static PyObject *_wrap_Screen_setDesktopName(PyObject *self, PyObject *args) {
     PyObject *resultobj;
     ob::Screen *arg1 = (ob::Screen *) 0 ;
     long arg2 ;
-    std::string *arg3 = 0 ;
-    std::string temp3 ;
+    otk::ustring *arg3 = 0 ;
+    otk::ustring temp3 ;
     PyObject * obj0  = 0 ;
     PyObject * obj2  = 0 ;
     
@@ -5605,13 +5607,13 @@ static PyObject *_wrap_Screen_setDesktopName(PyObject *self, PyObject *args) {
     if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_ob__Screen,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
     {
         if (PyString_Check(obj2)) {
-            temp3 = std::string(PyString_AsString(obj2));
+            temp3 = otk::ustring(PyString_AsString(obj2));
             arg3 = &temp3;
         }else {
-            SWIG_exception(SWIG_TypeError, "string expected");
+            SWIG_exception(SWIG_TypeError, "ustring expected");
         }
     }
-    (arg1)->setDesktopName(arg2,(std::string const &)*arg3);
+    (arg1)->setDesktopName(arg2,(otk::ustring const &)*arg3);
     
     Py_INCREF(Py_None); resultobj = Py_None;
     return resultobj;
@@ -5969,14 +5971,14 @@ static PyObject *_wrap_Client_desktop(PyObject *self, PyObject *args) {
 static PyObject *_wrap_Client_title(PyObject *self, PyObject *args) {
     PyObject *resultobj;
     ob::Client *arg1 = (ob::Client *) 0 ;
-    std::string *result;
+    otk::ustring *result;
     PyObject * obj0  = 0 ;
     
     if(!PyArg_ParseTuple(args,(char *)"O:Client_title",&obj0)) goto fail;
     if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_ob__Client,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
     {
-        std::string const &_result_ref = ((ob::Client const *)arg1)->title();
-        result = (std::string *) &_result_ref;
+        otk::ustring const &_result_ref = ((ob::Client const *)arg1)->title();
+        result = (otk::ustring *) &_result_ref;
     }
     
     {
@@ -5991,14 +5993,14 @@ static PyObject *_wrap_Client_title(PyObject *self, PyObject *args) {
 static PyObject *_wrap_Client_iconTitle(PyObject *self, PyObject *args) {
     PyObject *resultobj;
     ob::Client *arg1 = (ob::Client *) 0 ;
-    std::string *result;
+    otk::ustring *result;
     PyObject * obj0  = 0 ;
     
     if(!PyArg_ParseTuple(args,(char *)"O:Client_iconTitle",&obj0)) goto fail;
     if ((SWIG_ConvertPtr(obj0,(void **) &arg1, SWIGTYPE_p_ob__Client,SWIG_POINTER_EXCEPTION | 0 )) == -1) SWIG_fail;
     {
-        std::string const &_result_ref = ((ob::Client const *)arg1)->iconTitle();
-        result = (std::string *) &_result_ref;
+        otk::ustring const &_result_ref = ((ob::Client const *)arg1)->iconTitle();
+        result = (otk::ustring *) &_result_ref;
     }
     
     {
@@ -8252,8 +8254,8 @@ static swig_type_info _swigt__p_ob__KeyData[] = {{"_p_ob__KeyData", 0, "ob::KeyD
 static swig_type_info _swigt__p_XConfigureEvent[] = {{"_p_XConfigureEvent", 0, "XConfigureEvent *", 0},{"_p_XConfigureEvent"},{0}};
 static swig_type_info _swigt__p_XCirculateEvent[] = {{"_p_XCirculateEvent", 0, "XCirculateEvent *", 0},{"_p_XCirculateEvent"},{0}};
 static swig_type_info _swigt__p_XRectangle[] = {{"_p_XRectangle", 0, "XRectangle *", 0},{"_p_XRectangle"},{0}};
+static swig_type_info _swigt__p_otk__ustring[] = {{"_p_otk__ustring", 0, "otk::ustring *", 0},{"_p_otk__ustring"},{0}};
 static swig_type_info _swigt__p_std__string[] = {{"_p_std__string", 0, "std::string *", 0},{"_p_std__string"},{0}};
-static swig_type_info _swigt__p_ustring[] = {{"_p_ustring", 0, "ustring *", 0},{"_p_ustring"},{0}};
 static swig_type_info _swigt__p_XCrossingEvent[] = {{"_p_XCrossingEvent", 0, "XCrossingEvent *", 0},{"_p_XCrossingEvent"},{0}};
 static swig_type_info _swigt__p_Display[] = {{"_p_Display", 0, "Display *", 0},{"_p_Display"},{0}};
 static swig_type_info _swigt__p_otk__Display[] = {{"_p_otk__Display", 0, "otk::Display *", 0},{"_p_otk__Display"},{0}};
@@ -8316,8 +8318,8 @@ _swigt__p_ob__KeyData,
 _swigt__p_XConfigureEvent, 
 _swigt__p_XCirculateEvent, 
 _swigt__p_XRectangle, 
+_swigt__p_otk__ustring, 
 _swigt__p_std__string, 
-_swigt__p_ustring, 
 _swigt__p_XCrossingEvent, 
 _swigt__p_Display, 
 _swigt__p_otk__Display, 
index a9a457f..f6ed7a7 100644 (file)
@@ -66,7 +66,7 @@ bool python_get_long(const char *name, long *value)
   return true;
 }
 
-bool python_get_string(const char *name, std::string *value)
+bool python_get_string(const char *name, otk::ustring *value)
 {
   PyObject *val = PyDict_GetItemString(obdict, const_cast<char*>(name));
   if (!(val && PyString_Check(val))) return false;
@@ -75,7 +75,7 @@ bool python_get_string(const char *name, std::string *value)
   return true;
 }
 
-bool python_get_stringlist(const char *name, std::vector<std::string> *value)
+bool python_get_stringlist(const char *name, std::vector<otk::ustring> *value)
 {
   PyObject *val = PyDict_GetItemString(obdict, const_cast<char*>(name));
   if (!(val && PyList_Check(val))) return false;
index 8b41f00..c346f92 100644 (file)
@@ -10,6 +10,7 @@
 #include "otk/rect.hh"
 #include "otk/property.hh"
 #include "otk/display.hh"
+#include "otk/ustring.hh"
 
 extern "C" {
 #include <X11/Xlib.h>
@@ -165,8 +166,8 @@ void python_destroy();
 bool python_exec(const std::string &path);
 
 bool python_get_long(const char *name, long *value);
-bool python_get_string(const char *name, std::string *value);
-bool python_get_stringlist(const char *name, std::vector<std::string> *value);
+bool python_get_string(const char *name, otk::ustring *value);
+bool python_get_stringlist(const char *name, std::vector<otk::ustring> *value);
 
 /***********************************************
  * These are found in openbox.i, not python.cc *
index 763931f..c211df1 100644 (file)
@@ -82,10 +82,10 @@ Screen::Screen(int screen)
 
   // initialize the screen's style
   _style.setImageControl(_image_control);
-  std::string stylepath;
+  otk::ustring stylepath;
   python_get_string("theme", &stylepath);
   otk::Configuration sconfig(false);
-  sconfig.setFile(otk::expandTilde(stylepath));
+  sconfig.setFile(otk::expandTilde(stylepath.c_str()));
   if (!sconfig.load()) {
     sconfig.setFile(otk::expandTilde(DEFAULTSTYLE));
     if (!sconfig.load()) {
@@ -107,7 +107,7 @@ Screen::Screen(int screen)
                                      geometry, 2);
 
   // Set the net_desktop_names property
-  std::vector<std::string> names;
+  std::vector<otk::ustring> names;
   python_get_stringlist("desktop_names", &names);
   Openbox::instance->property()->set(_info->rootWindow(),
                                      otk::Property::net_desktop_names,
@@ -710,7 +710,7 @@ void Screen::updateDesktopNames()
 }
 
 
-void Screen::setDesktopName(long i, const std::string &name)
+void Screen::setDesktopName(long i, const otk::ustring &name)
 {
   assert(i >= 0);
 
index 8904c2a..c3af7b6 100644 (file)
@@ -19,6 +19,7 @@ extern "C" {
 #include "otk/screeninfo.hh"
 #include "otk/eventhandler.hh"
 #include "otk/property.hh"
+#include "otk/ustring.hh"
 
 #include <string>
 #include <list>
@@ -191,7 +192,7 @@ public:
     @param name The name to set for the desktop
     If the index is too large, it is simply ignored.
   */
-  void setDesktopName(long i, const std::string &name);
+  void setDesktopName(long i, const otk::ustring &name);
 
   virtual void propertyHandler(const XPropertyEvent &e);
   virtual void clientMessageHandler(const XClientMessageEvent &e);