After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 637443 - Missing signal open in Gio::Application
Missing signal open in Gio::Application
Status: RESOLVED FIXED
Product: glibmm
Classification: Bindings
Component: giomm
2.27.x
Other Linux
: Normal normal
: ---
Assigned To: gtkmm-forge
gtkmm-forge
Depends on: 637457
Blocks:
 
 
Reported: 2010-12-17 09:28 UTC by Yannick.Guesnet
Modified: 2010-12-23 21:11 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
A patch to add the signal open to Gio::Application (6.55 KB, patch)
2010-12-21 20:30 UTC, Yannick.Guesnet
committed Details | Review
Gio::Application example (1.20 KB, application/x-compressed-tar)
2010-12-22 08:52 UTC, Yannick.Guesnet
  Details
Gio::Application example for gtkmm-documentation (4.05 KB, patch)
2010-12-22 21:00 UTC, Yannick.Guesnet
needs-work Details | Review
A Gtk::Application example (10.80 KB, patch)
2010-12-23 12:54 UTC, Yannick.Guesnet
none Details | Review
A Gtk::Application example (10.77 KB, patch)
2010-12-23 13:25 UTC, Yannick.Guesnet
none Details | Review
A Gtk::Application example (10.77 KB, patch)
2010-12-23 14:25 UTC, Yannick.Guesnet
none Details | Review

Description Yannick.Guesnet 2010-12-17 09:28:42 UTC
The Gio::Application class does not offer a way to connect to the signal "open" of  GApplication.
Comment 1 Murray Cumming 2010-12-17 12:24:19 UTC
Yes. We haven't wrapped it because it has awkward parameters, as I've just mentioned in bug #637457. If necessary, we can probably wrap this by hand, I guess.
Comment 2 Yannick.Guesnet 2010-12-21 20:28:37 UTC
In order to discover how glibmm is coded, I wrap by hand the close signal (it's my first attemp to adapt glibmm).
I join it.
Comment 3 Yannick.Guesnet 2010-12-21 20:30:03 UTC
Created attachment 176861 [details] [review]
A patch to add the signal open to Gio::Application
Comment 4 Murray Cumming 2010-12-22 08:03:54 UTC
It looks right to me. Well done. Does it work for you?
Comment 5 Yannick.Guesnet 2010-12-22 08:50:12 UTC
Yes, I attach an example (the one given in the mailing-list).
Comment 6 Yannick.Guesnet 2010-12-22 08:52:06 UTC
Created attachment 176886 [details]
Gio::Application example
Comment 7 Yannick.Guesnet 2010-12-22 21:00:50 UTC
Created attachment 176899 [details] [review]
Gio::Application example for gtkmm-documentation

Here is the Gio::Application for the gtkmm documentation.
It follows the advices of Murray Cummings given throw the mailing list.
Comment 8 Murray Cumming 2010-12-22 22:06:55 UTC
Review of attachment 176899 [details] [review]:

Please patch the ChangeLog.

Please create a git patch. Just do this when you have made the changes to a git checkout and have committed the changes locally:
git format-patch HEAD^

The files are missing the usual license comments at the top. Please see the other files.

::: examples/book/giomm/application/exampleapplication.cc
@@ +9,3 @@
+void ExampleApplication::new_window(const Glib::RefPtr<Gio::File>& file)
+{
+  Gtk::Window * window = new ExampleWindow(file);

The other examples use "Thing* thing" rather than "Thing * thing".

@@ +12,3 @@
+  add_window(*window);
+  window->signal_hide().connect(sigc::bind<Gtk::Window *>(sigc::mem_fun(*this,
+      &ExampleApplication::window_hide_cb), window));

The other examples use an on_ prefix rather than a _cb suffix. Please be consistent with the other examples.

@@ +15,3 @@
+}
+
+void ExampleApplication::window_hide_cb(Gtk::Window * window)

Again, the other examples use "Thing* thing" rather than "Thing * thing".

@@ +22,3 @@
+void ExampleApplication::on_activate()
+{
+  new_window(Glib::RefPtr<Gio::File>(0));

The 0 should be unnecessary here.

::: examples/book/giomm/application/exampleapplication.h
@@ +7,3 @@
+{
+public:
+  ExampleApplication(const Glib::ustring& appid, Gio::ApplicationFlags flags =

This should be explicit because it can have one parameter.

@@ +8,3 @@
+public:
+  ExampleApplication(const Glib::ustring& appid, Gio::ApplicationFlags flags =
+      Gio::APPLICATION_FLAGS_NONE);

Please use multiples of two spaces for indentation.

::: examples/book/giomm/application/examplewindow.cc
@@ +5,3 @@
+ExampleWindow::ExampleWindow(const Glib::RefPtr<Gio::File>& file)
+{
+  set_title("Bloatpad");

"Gio::Application example" would be more appropriate.

@@ +10,3 @@
+  scrolled.add(view);
+
+  if (file)

The other examples use if(something) rather than if (something).

Also, this might be cleaner with just
if(!file)
  return;
which would avoid the nesting.

@@ +12,3 @@
+  if (file)
+  {
+    gchar *contents;

We use char* instead of gchar*. It's the same anyway. And I would initialize these to 0 and put them just before their use, instead of at the top of the method.

@@ +19,3 @@
+      if (file->load_contents(contents, length))
+      {
+        Glib::ustring text = Glib::ustring(contents, length);

const Glib::ustring text(contents, length)
would be slightly better.

I would do an if(contents && length) first though.

@@ +27,3 @@
+        g_free(contents);
+      }
+    } catch (Glib::Error& e)

Exceptions should be caught as const &, not just &.

@@ +33,3 @@
+  }
+
+  show_all();

We generally avoid using show_all(), because constructors should not decide when their widgets/windows are shown. The caller should decide when to call show() on them. You probably mean show_all_children().

::: examples/book/giomm/application/examplewindow.h
@@ +7,3 @@
+{
+public:
+  ExampleWindow(const Glib::RefPtr<Gio::File>& file);

This should be explicit.

::: examples/book/giomm/application/main.cc
@@ +14,3 @@
+  Gtk::Main kit(argc, argv);
+
+  ExampleApplication bloat_pad("org.gtkmm.Test.bloatpad",

bloatpad is a bad name.
Comment 9 Murray Cumming 2010-12-22 22:07:33 UTC
Review of attachment 176861 [details] [review]:

Committed with minor changes.
Comment 10 Yannick.Guesnet 2010-12-23 12:54:10 UTC
Created attachment 176932 [details] [review]
A Gtk::Application example
Comment 11 Yannick.Guesnet 2010-12-23 12:56:30 UTC
I post a new version of the example.
Thanks to Murray Cumming for its review. I have tried to follow its recommendations.
However I put the example in the examples/book/application directory since it is indeed a Gtk::Application example and not really a Gio::Application example.
Comment 12 Yannick.Guesnet 2010-12-23 13:25:01 UTC
Created attachment 176935 [details] [review]
A Gtk::Application example

Correct the preceding patch (a window->show() forgotten)
Comment 13 Yannick.Guesnet 2010-12-23 14:25:50 UTC
Created attachment 176937 [details] [review]
A Gtk::Application example

There was another bug in the example : I used "const Glib::ustring text(contents, length);" to construct the UTF-8 string but length was the size in bytes, not in UTF-8 characters. A simpler const Glib::ustring text(contents); suffices since the contents is allways NULL terminated.
Comment 14 Murray Cumming 2010-12-23 21:11:56 UTC
Thanks. I have applied that and made some minor changes.

It's a good start, though I think we'll want to expand it as we discover more about how it should be used.