Re: Atk::ObjectFactory

2009-05-28 Thread Balazs Scheidler
On Wed, 2009-05-27 at 19:55 +0200, Murray Cumming wrote:
 On Wed, 2009-05-27 at 12:05 +0200, Balazs Scheidler wrote:
  I don't understand the build system of gtkmm and I couldn't convince
  it
  to regenerate files even when I've changed the atk.defs file. Is there
  a
  document that details how the build system/generating classes work?
 
 I guess you are using a tarball. It's generally best to work with the
 sources from git anyway, if you plan to create a patch.
 
 If you use autogen.sh then --enable-maintainer-mode will be passed to
 configure, causing the files to be regenerated. We avoid this in tarball
 builds, to reduce build-time dependencies.
 

Thanks, I've found that in the meantime. (and I'm also using git)

-- 
Bazsi

___
gtkmm-list mailing list
gtkmm-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtkmm-list


Re: Atk::ObjectFactory

2009-05-27 Thread Balazs Scheidler
On Tue, 2009-05-26 at 14:58 +0200, Murray Cumming wrote:
 On Tue, 2009-05-26 at 13:51 +0200, Balazs Scheidler wrote:
  Hi,
  
  We're trying to use dogtail  atk to test our application automatically
  and while trying to learn the tricks involved, I've learned that I have
  to create an accessibility class for each of our custom widgets.
  
  The problem is that the AtkObjectFactory class isn't wrapped in gtkmm
  and neither is atk_registry_set_factory_type(). This means that it is
  not possible to support accessibility ( automatic testability) from
  gtkmm.
  
  Can anyone point me in the right direction whether this was started
  earlier, or what the roadblocks are? Is there a specific reason why it
  hasn't been wrapped?
 
 I have no idea how this API would be used. Can you give us a clue?

The accessibility framework of Gtk+ has two major uses: provide
accessibility for those visually impaired _AND_ to automate GUI
operations from an external application. (used by automatic test tools).

To make gtk applications accessible, Gtk has a framework to allow each
widget to publish information about its internals and various actions
that can be performed on widgets.

For instance, a toggle button widget publishes its state and also
actions to toggle/untoggle the state it contains. This way screen reader
apps (like Orca) or automatic test tools (like LDTP or dogtail) can
discover the widget structure of the application AND perform action on
these widgets. 

The interfaces a given widget can publish are defined by the various Atk
interface classes that are also wrapped in gtkmm. E.g. if a widget is
capable of text editing, it can implement the AtkText interface, or if
it capable of selecting items, it can implement the AtkSelect interface.

Internally, Atk instantiates a new accessibility object for each
on-screen widget, this accessibility object then gets associated with
the widget in question. (you can get this via
Gtk::Widget-get_accessible())

This instantiation is done via a factory class, which is then registered
against the GType of the Gtk::Widget (in a hashtable hidden behind
various abstraction layers)

So in order to provide accessibility features for a widget, you have to
use a stock widget where Gtk already has the necessary Atk interface
implementation (in the Gtk module named gail), or if you have a custom
widget you have to implement your own accessibility class.

In C, this is implemented in the following way:
 * you need an AtkObjectFactory derived class, the sole purpose is to
instantiate the accessibility object through its create_accessible
virtual function, the GType of this class is registered using
atk_registry_set_factory_type
 * then in the create_accessible() function you create an instance of
your widget specific accessibility class

The way it could be implemented:
 * the Atk interfaces are already wrapped in gtkmm, thus the
accessibility class of a given widget could theoretically be implemented
as a C++ class
 * an Atk::ObjectFactory class should be created to wrap
AtkObjectFactory, I can see some relevant code in
gtkmm/atk/src/atk_methods.defs file, but no such class is generated.

I don't understand the build system of gtkmm and I couldn't convince it
to regenerate files even when I've changed the atk.defs file. Is there a
document that details how the build system/generating classes work?

 
 Is there a reason why you can't use the C API?
 

Of course I could use the C API, but I find that somewhat ugly in a
purely C++ program. :)
 

-- 
Bazsi

___
gtkmm-list mailing list
gtkmm-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtkmm-list


Atk::ObjectFactory

2009-05-26 Thread Balazs Scheidler
Hi,

We're trying to use dogtail  atk to test our application automatically
and while trying to learn the tricks involved, I've learned that I have
to create an accessibility class for each of our custom widgets.

The problem is that the AtkObjectFactory class isn't wrapped in gtkmm
and neither is atk_registry_set_factory_type(). This means that it is
not possible to support accessibility ( automatic testability) from
gtkmm.

Can anyone point me in the right direction whether this was started
earlier, or what the roadblocks are? Is there a specific reason why it
hasn't been wrapped?

-- 
Bazsi

___
gtkmm-list mailing list
gtkmm-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtkmm-list


Re: Using gtkmm with Visual C++ and _SECURE_SCL=0

2008-10-18 Thread Balazs Scheidler
On Sat, 2008-10-18 at 16:30 +0200, Maik Beckmann wrote:
 2008/10/18 Armin Burgmeier [EMAIL PROTECTED]:
  On Fri, 2008-10-17 at 16:05 +0200, Thomas Frank wrote:
  I searched for _SECURE_SCL in the archives but didn't get any results.
  Has this ever been a topic?
 
  I didn't even know this option existed. Of course, we could enable this
  for the gtkmm runtime binaries, but then people need to set the same
  flag in their applications, which is just one step more that could go
  wrong. This is why I would rather avoid it.
 
 _SECURE_SCL=1 is similar to libstdc++ Debug Mode
  - http://gcc.gnu.org/onlinedocs/libstdc++/manual/debug_mode.html
 quote
 To use the libstdc++ debug mode, compile your application with the
 compiler flag -D_GLIBCXX_DEBUG. Note that this flag changes the sizes
 and behavior of standard class templates such as std::vector, and
 therefore you can only link code compiled with debug mode and code
 compiled without debug mode if no instantiation of a container is
 passed between the two translation units.
 /quote
 which means binary incompatibility.
 
  We could also supply release binaries for both _SECURE_SCL=0 and
  _SECURE_SCL=1 (so we would have 6 different VC++ DLLs for each C++
  module). Again, I'm not quite happy with this considering the
  duplication it involves.
 
  How many applications do (need to) use the _SECURE_SCL=0 option? Is it
  kind of standard that it is used for release builds?
 
 The VS default release build doesn't define _SECURE_SCL=0 by default,
 AFAIK.  If you just compile the header files define _SECURE_SCL=1 by
 default.
 
  If not, then I'm
  sorry, but I don't think it's reasonable to support all the different
  MSVC++ compiler settings that produce incompatible binaries. Just
  because there are too much of them.
 
 My impressions is, that performance suffers when using std containers
 and algorithm with _SECURE_SCL=1.  This might be a problem when i.e.
 doing heavy duty text processing using the stl.
 
 I for example was bitten by _SECURE_SCL=1 being the default :-).
 Coding a ND-LookupTable, mingw-gcc-4.2.3 outperformed msvc-8.0 by a
 factor of 2.5. A few month later I've read posting about this topic at
 the boost-ML.  Rebuilding everything with _SECURE_SCL=0 made msvc
 outperform gcc by a factor of 1.3.
 
  However, considering the rules posted on [1], I don't see an easy
  workaround for your problem without rebuilding the involved C++
  libraries.
 
 It would be best to have generic build scripts for msvc.  Do the
 autotools scripts work with CC=cl CXX=cl?
 
 A workaround is using LoadLibrary to open _SECURE_SCL=0 compiled DSOs
 containing performance critical code.

We're building glibmm using a wrapper script called cccl, which emulates
UNIX like cc options with the Microsoft compiler.

As far as I know it was an abandoned project, but one of my collegues
updated it somewhat to work better. As far as I know it still needs some
magic to actually produce working binaries, but that's the best option I
had so far to compile the gtkmm stack with MSVC++.

What does the binary installer use to compile gtkmm on Windows? Or you
are using mingw?

So if anyone is interested I'd be willing to publish our cccl fork,
maybe it could be cleaned up a bit. It would make it way easier to
compile Windows binaries by ourselves and in that case
binary-incompatible MSVC options would not bite that much.

-- 
Bazsi


___
gtkmm-list mailing list
gtkmm-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtkmm-list


Re: Latest Gtkmm Installer?

2008-01-31 Thread Balazs Scheidler

On Thu, 2008-01-31 at 19:41 +0530, Surya Kiran Gullapalli wrote:
 Hello,
 I'm trying to get gtkmm-2.12.* version on windows (MSVS 2005 version).
 But 2.12 version of installer is not out yet.
 
 I've tried building gtkmm - 2.12 from source with MSVS2005. I had to
 tweak the project files, include some files in the projects, delete
 some, and finally was able to get the library.
 
 But running applications built with the library were crashing.
 
 I'd like to know when is the 2.12 installer due?
 
 It'd be very helpful to know what all things to be taken care of while
 building gtkmm on vs 2005.

make sure you use the same MSVC compiler options for the application and
gtkmm. There are some switches to the microsoft compiler that actually
changes the C++ ABI, e.g. if you compile the library with one set and
the application with a different one, your application will definitely
be crashing.

-- 
Bazsi

___
gtkmm-list mailing list
gtkmm-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtkmm-list


Re: ustring compose escaping capability

2008-01-23 Thread Balazs Scheidler

On Tue, 2008-01-22 at 15:43 -0600, Jonathon Jongsma wrote:
 On 1/22/08, Szilárd Pfeiffer [EMAIL PROTECTED] wrote:
  Hi,
 
  I have a question about the ustring::compose API. Is it purposed
  implementation of an escaping extension to the compose API? We have a
  solution for that and we would be happy if you found it useful and it
  was integrated to the glibmm 2.16 or later.
 
  regards
  Szilard
 
 I don't quite understand the question.  Would it be possible to
 re-word it somehow?

We wanted to implement escaping into ustring::compose, e.g. there are
cases when the programmer wants to write:

ustring::compose(SELECT * FROM table WHERE name=%1, name);

In this case SQL specific escaping should be applied when substituting
the argument, e.g. the substitution itself should be enclosed in quotes,
and if the contents of the name variable contains a quote itself it
should be properly escaped.

With the current state of the compose API, such escaping cannot be
added, unless the code is copy/pasted and then changed.

What we propose is to add a template argument to compose that performs
escaping, the current behaviour would not suffer as with template
specialization the same runtime performance can be achieved.

The skeleton of the solution is something like this:

template class EscapeImpl
class compose_tmpl 
{
  // the Stringify class is changed to use EscapeImpl to do escaping
};

class ComposeEscapeSQL
{
  static Glib::ustring escape(Glib::ustring source)
  {
// perform SQL escaping
  }
};

class ComposeEscapeNone
{
  static Glib::ustring escape(Glib::ustring source)
  {
// perform no escaping at all
  }
};

typedef compose_tmplComposeEscapeNone compose;
typedef compose_tmplComposeEscapeSQL compose_sql;

Of course this is only a rough sketch of what we have implemented. The
point is that we can reuse the core of the composition API, while still
achieving escaping.

This would be easy enough for programmers to avoid SQL/HTML injection

I can see additional uses of this change, like:
  * CSV escaping

std::cout  Glib::ustring::compose_csv(%1;%2;%3, value1, value2, value3);

the contents of the 3 variables would be properly escaped

  * HTML escaping (not that I'd write HTML apps in C++)

std::cout  Glib::ustring::compose_html(htmlbody%1/body/html, value);

The contents of value would be properly HTML escaped to avoid 
cross-side-scripting attacks.

  * command line escaping

I think the list is endless, escaping is crucial in applications where security 
is important.

I hope I could shed some light on the matter.

We have an implementation of this idea, but it uses our private namespaces, the 
naming might not perfectly fit to Glibmm, etc. and we wanted to avoid the work 
of preparing a correct Glibmm patch if the functionality we implemented does 
not 
sound interesting.

-- 
Bazsi

___
gtkmm-list mailing list
gtkmm-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtkmm-list


Re: ustring compose escaping capability

2008-01-23 Thread Balazs Scheidler

On Wed, 2008-01-23 at 11:02 -0500, Paul Davis wrote:
 On Wed, 2008-01-23 at 10:36 +0100, Szilard Pfeiffer wrote:
  I hope there will be no misunderstanding if I write it step-by-step: 
  
  1. in the glibmm there is an ustring::compose API 
  2. it is not possible to escaping with this API 
  3. it would be useful for us (my colleges and me) and maybe for
  others 
  4. we have a potential solution (without API incompatibility) 
  5. with some work i can create a patch for you 
  6. it would be lovely if you integrated our patch to the glibmm 
  
  Do you plan to implement your own solution to the problem? 
  May I hope you integrate our solution to the glibmm if you find it
  correct? 
  
  regards 
  Szilard 
  
  p.s.:
  
  In this case escaping means string conversion. I think something like
  the following:
  
  ustring::compose(SELECT * FROM table_name WHERE pub='%1', Joe's)
  
  The result of the composition should be SELECT * FROM table_name
  WHERE pub='Joe\'s', but without escaping it will be SELECT * FROM
  table_name WHERE pub='Joe's', which is an incorrect SQL command.
 
 its totally wrong to do this within the compose code.
 
 the function you want is much more general:
 
 ustring::compose (SELECT * FROM table_name WHERE pub='%1',
 make_legal_sql (Joe's))
 
 ustring make_legal_sql(const ustring) is a critical function because it
 is (presumably) accepting user input and passing it to an SQL execution
 engine. any user input should be thoroughly scrubbed before this
 happens because of the potential security implications. simply escaping
 quotes is only the start of what is needed (although its a big part).

In my humble opinion it is totally wrong in the way you describe.

Suppose you have 100 different queries, each 2 different arguments (on
average), you state that calling make_legal_sql() 200 times is a safer
approach than providing the same functionality in one place in compose?

I'd bet that everyone would forget at least one make_legal_sql()
invocation.

What does make_legal_sql() do in your example? I say that everything it
does can be done in the escaping mechanism that we described. Under the
term escaping I mean to do whatever transformation on the string
necessary to make it sane in the specific context.

-- 
Bazsi

___
gtkmm-list mailing list
gtkmm-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtkmm-list


Re: ustring compose escaping capability

2008-01-23 Thread Balazs Scheidler

On Wed, 2008-01-23 at 16:51 -0500, Paul Davis wrote:
 On Wed, 2008-01-23 at 17:39 +0100, Balazs Scheidler wrote:
 
  In my humble opinion it is totally wrong in the way you describe.
  
  Suppose you have 100 different queries, each 2 different arguments (on
  average), you state that calling make_legal_sql() 200 times is a safer
  approach than providing the same functionality in one place in compose?
  
  I'd bet that everyone would forget at least one make_legal_sql()
  invocation.
  
  What does make_legal_sql() do in your example? I say that everything it
  does can be done in the escaping mechanism that we described. Under the
  term escaping I mean to do whatever transformation on the string
  necessary to make it sane in the specific context.
 
 
 what happens if I am using compose to build a shell command to be passed
 to system, where the rules for escaping are totally different? For
 example, in a shell script, you cannot put single quotes inside other
 single quotes *even if they are escaped. how is compose() supposed to
 know this? 
 
 sure, if you want to do ustring::sql_compose() then go ahead, but then
 you will also need ustring::python_compose(), ustring::sh_compose(), all
 the way down to ustring::some_language_i_have_forgotten_compose().
 
 leave compose to do the job of merging strings; use other code to handle
 language-context-specific escaping.

That's the whole point, plugging in a language specific escaping is
simple and can be done by the application. We don't need to add this
code to glibmm, only the possibility to do this in an application.

Maybe this was missing from my description. The only change in glibmm is
the _ability_ to plug in escaping classes by the application. Glibmm
will not get neither SQL nor HTML escaping implementations, that's up to
the application to add.

But while remaining source  binary compatible with glibmm, the
application is free to _reuse_ the code that's already there, not having
to invent its own.

-- 
Bazsi

___
gtkmm-list mailing list
gtkmm-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtkmm-list


accelerators in a Gtk::Window

2007-09-04 Thread Balazs Scheidler
Hi,

I'd like to add some window-wide accelerators but without using a
menubar or a UIManager.

First I thought I'd need Gtk::AccelGroup, but that object seems to be a
read-only class, it is not possible to add further accelerators as
AccelGroup::connect() is not wrapped for some reason.

Then I connected to window-signal_key_press_event() but as it seems the
currently focused widget gets the keys first.

Do I need to grab the keyboard focus or there's another possibility?

-- 
Bazsi

___
gtkmm-list mailing list
gtkmm-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtkmm-list


refptr based tree model

2006-12-29 Thread Balazs Scheidler
Hi,

I'm trying to create a custom tree model. My data structure contains a
tree of reference counted objects. The problem I have is that I'm unable
to put a Glib::RefPtrMyObject instance (which represents a node in my
tree) to Gtk::TreeIter.

I was following the code in examples/treemodelcustom/, it simply uses
Gtk::TreeIter-gobj() (e.g. GtkTreeIter structure) to represent an
iterator (e.g. a reference to a tree-node). I guessed the reason to use
gobj() instead of C++ members, is that GtkTreeIter is not a real class
in GTK+, and instances of that structure are defined/passed around in
plain C code.

So if my guess above is true, I also have to put a node reference (e.g.
a value of type Glib::RefPtrMyObject) to GtkTreeIter somehow.
GtkTreeIter defines 3 pointers (12 bytes) for this purpose.

My problem:

1) I cannot extend Gtk::TreeIter to define a Glib::RefPtrMyObject
member
2) I cannot get a raw pointer from Glib::RefPtrMyObject which I
could put into GtkTreeIter

The only solution right now that I can see, is to create a Glue class,
that holds a reference to my node and store a pointer to this glue class
in GtkTreeIter. Then have some mechanism in place that ensures that Glue
instances get freed. However I don't really like this solution (why
allocate a new object just to store a simple pointer?), and I'd like to
avoid this if possible.

Any other ideas?

-- 
Bazsi

___
gtkmm-list mailing list
gtkmm-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtkmm-list


toggletoolbutton label leak?

2006-12-29 Thread Balazs Scheidler
Hi,

Sorry If I'm missing something obvious, but I'm a newbie in both Gtkmm
and Gtk+.

I'm trying to generate toolbar entries dynamically, basically I want a
nautilus like history bar, using Gtk::ToggleToolButtons to represent
nodes in my tree.

Thus whenever a node is selected I'm updating the toolbar with the
following code:

Gtk::ToolItem *
MainWindow::new_history_button(const std::string text) const
{
  Gtk::ToggleToolButton *b;
  Gtk::Label *label;

  label = Gtk::manage(new Gtk::Label());
  label-set_use_markup(true);
  label-set_label(text);
  label-show();

  b = Gtk::manage(new Gtk::ToggleToolButton());
  b-set_label_widget(*label);
  b-set_homogeneous(false);
  b-show();
  return b;
}

void
MainWindow::update_history_bar(const Glib::RefPtrComponent last_shown)
{
  Glib::RefPtrComponent p;
  Gtk::ToolItem *item;

  // free previous toolbar buttons
  while (history_bar-get_n_items()  0)
{
  item = history_bar-get_nth_item(0);
  if (item)
{
  history_bar-remove(*item);
  delete item;
}
}

  // build new buttons
  p = last_shown;
  while (p-get_parent())
{
  item = new_history_button(p-name);
  static_castGtk::ToggleToolButton 
*(item)-signal_toggled().connect(sigc::mem_fun(*this, 
MainWindow::on_history_button_pressed));
  
  history_bar-prepend(*item); 
  p = p-get_parent();
}
}

My problem is that, according to valgrind, new_history_button() function
leaks all Gtk::Label instances regardless if I'm using Gtk::manage() on 
instance creation or not. 

The funny part is that the Gtk::ToggleToolButton instances are not
leaked. So as it seems Gtk::ToggleToolButton fails to free the label
attached using set_label_widget()

What am I missing here?

-- 
Bazsi

___
gtkmm-list mailing list
gtkmm-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtkmm-list


Re: refptr based tree model

2006-12-29 Thread Balazs Scheidler
On Fri, 2006-12-29 at 14:14 +0100, Balazs Scheidler wrote:

 My problem:
 
 1) I cannot extend Gtk::TreeIter to define a Glib::RefPtrMyObject
 member
 2) I cannot get a raw pointer from Glib::RefPtrMyObject which I
 could put into GtkTreeIter
 
 The only solution right now that I can see, is to create a Glue class,
 that holds a reference to my node and store a pointer to this glue class
 in GtkTreeIter. Then have some mechanism in place that ensures that Glue
 instances get freed. However I don't really like this solution (why
 allocate a new object just to store a simple pointer?), and I'd like to
 avoid this if possible.

In the meanwhile I became friend with the third possibility, e.g. to use
a wrapper class around Glib::RefPtrMyObject and store the address of
this wrapper in GtkTreeIter's user_data member.

So unless you have a smarter solution, please ignore this post. :)

Thanks.

-- 
Bazsi

___
gtkmm-list mailing list
gtkmm-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtkmm-list