all repos — openbox @ ef02a0c8ae65f169157c90064a335303e964a4c1

openbox fork - make it a bit more like ryudo

almost done the ustring conversion
Dana Jansens danakj@orodu.net
commit

ef02a0c8ae65f169157c90064a335303e964a4c1

parent

5a90d2b671f01f29043ab82f909440de0abfa362

M otk/otk.hhotk/otk.hh

@@ -29,6 +29,7 @@ #include "timer.hh"

#include "timerqueue.hh" #include "timerqueuemanager.hh" #include "util.hh" +#include "ustring.hh" #include "widget.hh" #endif // __otk_hh
M otk/otk.iotk/otk.i

@@ -12,6 +12,7 @@ %}

%include "stl.i" //%include std_list.i +%include "ustring.i" %ignore otk::OBDisplay::display; %inline %{
M otk/property.ccotk/property.cc

@@ -382,7 +382,7 @@ }

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);
M otk/ustring.ccotk/ustring.cc

@@ -142,6 +142,11 @@ {

return _string.max_size(); } +bool ustring::empty() const +{ + return _string.empty(); +} + void ustring::clear() { _string.erase();
M otk/ustring.hhotk/ustring.hh

@@ -152,7 +152,7 @@

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 @@ ustring::size_type size() const;

ustring::size_type bytes() const; ustring::size_type capacity() const; ustring::size_type max_size() const; + bool empty() const; // erase substrings
M src/client.ccsrc/client.cc

@@ -531,15 +531,15 @@ unsigned long num = 2;

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(); } }
M src/client.hhsrc/client.hh

@@ -12,6 +12,7 @@ #include "otk/point.hh"

#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 @@ //! The desktop on which the window resides (0xffffffff for all desktops)

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 @@ A value of 0xffffffff indicates that the window exists on all desktops.

*/ 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
M src/frame.ccsrc/frame.cc

@@ -64,7 +64,7 @@ {

} -void Frame::setTitle(const std::string &text) +void Frame::setTitle(const otk::ustring &text) { _label.setText(text); _label.update();

@@ -172,7 +172,7 @@

// separation between titlebar elements const int sep = bevel + 1; - std::string layout; + otk::ustring layout; if (!python_get_string("titlebar_layout", &layout)) layout = "ILMC";
M src/frame.hhsrc/frame.hh

@@ -18,6 +18,7 @@ #include "otk/rect.hh"

#include "otk/screeninfo.hh" #include "otk/style.hh" #include "otk/widget.hh" +#include "otk/ustring.hh" #include <string>

@@ -88,7 +89,7 @@ virtual void focus();

//! 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();
M src/labelwidget.ccsrc/labelwidget.cc

@@ -26,7 +26,7 @@ XftDrawDestroy(_xftdraw);

} -void LabelWidget::setText(const std::string &text) +void LabelWidget::setText(const otk::ustring &text) { _text = text; _dirty = true;

@@ -77,7 +77,7 @@

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
M src/labelwidget.hhsrc/labelwidget.hh

@@ -6,6 +6,7 @@ #include "widgetbase.hh"

#include "otk/widget.hh" #include "otk/font.hh" #include "otk/style.hh" +#include "otk/ustring.hh" namespace ob {

@@ -17,7 +18,7 @@ const otk::Font *_font;

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 @@ virtual void unfocus();

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); }; }
M src/openbox.isrc/openbox.i

@@ -112,6 +112,8 @@ %inline %{

Display *Display_display() { return otk::Display::display; } %}; +%include "../otk/ustring.i" + %include "../otk/display.hh" %include "../otk/point.hh" %include "../otk/property.hh"
M src/openbox_wrap.ccsrc/openbox_wrap.cc

@@ -676,8 +676,8 @@ #define SWIGTYPE_p_ob__KeyData swig_types[27]

#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]

@@ -884,6 +884,9 @@ #include <iterator>

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())

@@ -1506,7 +1509,8 @@ otk::Property *arg1 = (otk::Property *) 0 ;

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 @@ if(!PyArg_ParseTuple(args,(char *)"OOiiO:Property_set",&obj0,&obj1,&arg3,&arg4,&obj4)) goto fail;

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 @@ }

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 @@ _v = 1;

} } if (_v) { - return _wrap_Property_set__SWIG_2(self,args); + return _wrap_Property_set__SWIG_3(self,args); } } }

@@ -1631,16 +1639,10 @@ _v = (PyInt_Check(argv[3]) || PyLong_Check(argv[3])) ? 1 : 0;

} 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 @@ _v = (PyInt_Check(argv[3]) || PyLong_Check(argv[3])) ? 1 : 0;

} 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 @@ otk::Property *arg1 = (otk::Property *) 0 ;

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 @@ if(!PyArg_ParseTuple(args,(char *)"OOiiO:Property_get",&obj0,&obj1,&arg3,&arg4,&obj4)) goto fail;

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 @@ }

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 @@ if(!PyArg_ParseTuple(args,(char *)"OlO:Screen_setDesktopName",&obj0,&arg2,&obj2)) goto fail;

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_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_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::KeyData *", 0},{"_p_ob__KeyData"},{0}};

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,
M src/python.ccsrc/python.cc

@@ -66,7 +66,7 @@ *value = PyInt_AsLong(val);

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 @@ *value = PyString_AsString(val);

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;
M src/python.hhsrc/python.hh

@@ -10,6 +10,7 @@ #include "otk/point.hh"

#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 *
M src/screen.ccsrc/screen.cc

@@ -82,10 +82,10 @@ _root_cmap_installed = True;

// 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 @@ otk::Property::Atom_Cardinal,

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 @@ _desktop_names.push_back("Unnamed");

} -void Screen::setDesktopName(long i, const std::string &name) +void Screen::setDesktopName(long i, const otk::ustring &name) { assert(i >= 0);
M src/screen.hhsrc/screen.hh

@@ -19,6 +19,7 @@ #include "otk/style.hh"

#include "otk/screeninfo.hh" #include "otk/eventhandler.hh" #include "otk/property.hh" +#include "otk/ustring.hh" #include <string> #include <list>

@@ -191,7 +192,7 @@ @param i The index of the desktop to set the name for (starts at 0)

@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);