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 399818 - misc patches to somewhat reduce dependency on libgnomeui
misc patches to somewhat reduce dependency on libgnomeui
Status: RESOLVED FIXED
Product: gnome-power-manager
Classification: Deprecated
Component: gnome-power-preferences
SVN TRUNK
Other All
: Normal enhancement
: ---
Assigned To: GNOME Power Manager Maintainer(s)
GNOME Power Manager Maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2007-01-23 15:43 UTC by Jani Monoses
Modified: 2008-03-19 01:19 UTC
See Also:
GNOME target: ---
GNOME version: Unversioned Enhancement


Attachments
the patch (11.70 KB, patch)
2007-01-23 16:00 UTC, Jani Monoses
none Details | Review
corrected patch (11.69 KB, patch)
2007-01-23 16:51 UTC, Jani Monoses
none Details | Review
a subset of the original patch (4.76 KB, patch)
2007-05-08 09:43 UTC, Jani Monoses
none Details | Review
replace gnome_help (4.07 KB, patch)
2007-06-22 08:41 UTC, Jani Monoses
none Details | Review
replace gnome_url_show (1.57 KB, patch)
2007-06-22 09:01 UTC, Jani Monoses
none Details | Review
original patch regenerated (12.22 KB, patch)
2007-08-03 12:15 UTC, Jani Monoses
none Details | Review
updated patch, fixes crash (12.24 KB, patch)
2007-08-03 17:11 UTC, Jani Monoses
committed Details | Review
drop unused gnome client frm main.c (2.54 KB, patch)
2007-08-03 18:30 UTC, Jani Monoses
committed Details | Review

Description Jani Monoses 2007-01-23 15:43:42 UTC
not a feature but this seemed the most appropriate category, as there's no 
'performance enhancement' label in GNOME bugzilla.
Comment 1 Jani Monoses 2007-01-23 16:00:05 UTC
Created attachment 80993 [details] [review]
the patch

This touches various files and does the following:

* switch the two tests from gnome to gtk_init and manual invocation of goption parsing. Additionally make the inhibit test exit when closing the window.
* add a gpm_help_display() function to gpm-common.c and use it in preference to
gnome_help_display variants. Call preferences and statistics with the specific help subsection.
* replace gnome_show_url with invoking xdg-open or gnome-open
* except the daemon switch to gtk_init + manual option handling
* config and makefile changes to support a new GTK_LIBS flag and to add gpm-common to statistics build.

the applets were not touched they are GNOME applets anyway and have additional deps.

I plan to use the new libeggsm code as well, making the non-applet bits of g-p-m
entirely independent of libgnome unless someone shouts :)

the preferences and statistics apps are linked against ~25 .so-s less on an ubuntu feisty system. Measured with exmap the resident memory is a few hundred Kb less but not consistent across measurements. Launch time for both is noticably less.

comments welcome
Comment 2 Richard Hughes 2007-01-23 16:21:04 UTC
I like the patch. Thanks for looking into this.

General comments:

* I always like to use braces, even for single line conditionals:

if (moo == TRUE) {
    foo();
}

* I never use the shorthand true false ? shorthand, e.g.

link_id ? "?" : "" makes little sense to me. Can you make this a proper if statement please.

* is there any problems with GNOME session management if we don't use gnome_program_init()?

* I tried to apply the patch for testing but get:

hughsie@hughsie-laptop:~/gnome-power-manager$ patch --dry-run -p0 < /home/hughsie/Desktop/libgnome.diff 
patching file configure.in
patching file src/gpm-statistics.c
patching file src/gpm-inhibit-test.c
patching file src/gpm-tray-icon.c
patch: **** malformed patch at line 177:  /**

Cheers,

Richard.
Comment 3 Jani Monoses 2007-01-23 16:51:43 UTC
Created attachment 80996 [details] [review]
corrected patch

thanks for the comments.
I added braces for the two if statements, dropped the ? conditional, added an extra g_free I missed last time and resisted cosmetising the diff so it should actually apply now :)

losing gnome_program_init() does not affect session management but means no bug buddy integration. Is that ok?
Comment 4 Richard Hughes 2007-01-23 17:02:19 UTC
(In reply to comment #3)
> losing gnome_program_init() does not affect session management but means no bug
> buddy integration. Is that ok?

That is a big loss. Have you done some profiling on exactly how much memory we save and how the startup speed increases? I can post to desktop-development mailing list and get some comments.

Thanks.
Comment 5 Jani Monoses 2007-01-23 18:24:18 UTC
Startup speed I did not profile I just noticed that while both times were sub-second, without the processing of extra ~25 dsos the diff is noticable.
As for memory usage, this is probably the same as the difference between a hello world app which uses gtk_init vs one that uses gnome_program_init and nothing more but stary in the main loop.

Here are the measurements done with exmap for effective resident memory:

           patched        svn
g-p-prefs: 3182K           3933K
g-p-stats: 4614K           4714K

though I don't know how to explain the 100K vs 750K difference when the same kind of dep removal was applied to both.

For various other apps I got 100K-1.1M diffs, it may be that exmap is not precise enough or I am not interpreting it right.

The desktop list would be a good idea as there are a few devs who blogged about similar measurements in the past and they may have something to add or help profiling g-p-m on their own to get data from multiple people. There are a few other apps in gnome svn which rely in the same way on libgnomeui so profiling changes against those would help estimate how much would a complete average desktop benefit if these changes added up.




Comment 6 Jani Monoses 2007-01-30 10:33:26 UTC
Richard, if you're uncomfortable with replacing gnome_program_init with gtk_init because of bug buddy, would you mind applying the rest of the bits from the patch?
I'd also submit a patch which adds an --enable-gnome configure option which would only ifdef on g_p_i() and _gtk_init() so it would be small. This way it would make it a lot more likely g-p-m is accepted in Xfce and distros based on it. It may even make sense in stock Ubuntu where apport, the external crash handler is preferred over bug buddy.

thanks
Comment 7 Christian Persch 2007-01-30 12:48:07 UTC
A few comments:

+	g_option_context_add_group (context, gtk_get_option_group (FALSE));
+	g_option_context_parse (context, &argc, &argv, NULL);
[...]
+	gtk_init (&argc, &argv);

Why the gtk_init call? You already added gtk's option group to the context and parsed it. And you're ignoring errors from the g_option_context_parse call.


+		command = g_strconcat ("gnome-help ghelp://", uri, "?", link_id, NULL);
+	} else {
+		command = g_strconcat ("gnome-help ghelp://", uri,  NULL);

I think one should use gnome-open ghelp://..., not gnome-help directly.
Comment 8 Jani Monoses 2007-05-08 09:43:53 UTC
Created attachment 87791 [details] [review]
a subset of the original patch

this just replaces the use of gnome_help_display and gnome_show_url
calls gnome-open not gnome-help as per Christian's suggestion
it does not require ifdefs since it works with or without having a GNOME platform (yelp, gnome-open) installed.
The only libgomeui dependency left is gnome_program_init, but that depends on the status of bug buddy being a GTK_MODULE or not in 2.20
Comment 9 Sven Neumann 2007-05-09 08:31:35 UTC
See http://bugzilla.gnome.org/show_bug.cgi?id=436832#c2 about hardcoding BINDIR.
Comment 10 Jani Monoses 2007-06-22 08:41:13 UTC
Created attachment 90439 [details] [review]
replace gnome_help

subset of original patch, factors out calling to help and makes it take the gscreen into account. This is similar to what has recently been commited in gcalctool
Comment 11 Jani Monoses 2007-06-22 09:01:06 UTC
Created attachment 90440 [details] [review]
replace gnome_url_show

patch independent of previous one, replaces gnome_url_show by invoking gnome-open and if that fails xdg-open. Fixed the BINDIR problem that Sven pointed out, works with gscreens and pops up dialog on error.
Comment 12 Jani Monoses 2007-08-02 20:45:51 UTC
Now that bug-buddy can be activated without gnome_program_init in 2.20 would you consider applying these? thanks.
Comment 13 Richard Hughes 2007-08-03 09:06:47 UTC
Jani, how do we activate bug buddy? If you can add the activation into the patches above then sure, you can merge these for 2-19.
Comment 14 Jani Monoses 2007-08-03 09:24:38 UTC
it happens just like adding support for a11y via the GTK_MODULES mechanism. gnome-session sets up the GTK_MODULES env var and adds bug-buddy to it if it's in the path

svn trunk:
./gnome-session/main.c for bug-buddy
./gnome-session/gsm-at-startup.c for a11y

so it's taken care at the GTK level.
Comment 15 Richard Hughes 2007-08-03 10:12:44 UTC
Jani, please commit your latest patches. Many thanks.
Comment 16 Jani Monoses 2007-08-03 10:28:03 UTC
I do not have commit access to GNOME svn :)
Comment 17 Richard Hughes 2007-08-03 10:44:10 UTC
Ohh, no problem. Can you generate a patch for todays svn please, and include a ChangeLog entry so you get credit. Thanks.
Comment 18 Jani Monoses 2007-08-03 12:15:52 UTC
Created attachment 93007 [details] [review]
original patch regenerated

Here's the original patch against current svn, with Christian's comment regarding gtk_init and g_option parsing taken into account.
It swithces two tests, g-p-m-preferences andg-p-m- statistics away from gnome_program_init(), and replaces gnome_show_url and gnome_help_display with
calls to gnome-open.

There are a few other pieces of GNOME APIs and autoconf nits left, but it is a lot easier doing and testing this piece by piece.
Comment 19 Richard Hughes 2007-08-03 13:04:10 UTC
I don't know why but this patch makes "make check" fail in the self test code. For some reason the DPMS checks fail. Do you see this also?
Comment 20 Jani Monoses 2007-08-03 13:27:53 UTC
make check fails here with or without the patch, but in the RECALL not the DPMS test.

> check #82     GpmCell:        make sure we got a single recall notice...FAILED [did not get recall (install fdi?)]
FAIL: gnome-power-self-test
===================
1 of 1 tests failed
===================

not sure if it reaches DPMS test
Comment 21 Jani Monoses 2007-08-03 17:08:21 UTC
which is the DPMS test exaclty, I cannot find it in the source.
Comment 22 Jani Monoses 2007-08-03 17:11:09 UTC
Created attachment 93046 [details] [review]
updated patch, fixes crash

add back gtk_init() or else the inhibit test crashes.
Comment 23 Richard Hughes 2007-08-03 17:19:10 UTC
Committed, many thanks. Do you want to make some changes in configure.in also?
Comment 24 Jani Monoses 2007-08-03 17:27:30 UTC
yes, I'll take a look at the last bits of libgnome (particluarly gnome client) and then the configure bits.  Can you describe briefly what the use for gnome client is in g-p-m? I wonder if it can be easily replaced and I'll look at the code but your comments would give me a headstart. There are some apps that used gnome client because it was copy-pasted but was mostly a noop (sets up an empty "die" callback, or is obsoleted by the fdo autostart mechanism), n-m is one that recently got rid of it. But g-p-m may have a valid reason.

thanks
Comment 25 Richard Hughes 2007-08-03 17:45:18 UTC
Nope, I don't use gnomeclient for anything anymore IIRC. We used to use it for autostarting, but I think that got ripped out ages ago.

Thanks for looking into this.
Comment 26 Jani Monoses 2007-08-03 18:30:41 UTC
Created attachment 93051 [details] [review]
drop unused gnome client frm main.c

the GnomeClient usage in main.c is a noop currently (commented out
code, and a "die" callback that does not seem useful)

also do GOption parsing via gtk and drop gnome_program_init()

there are 3 more use left of GnomeClient in gpm-manager.c and gpm-control.c they appear to be requesting a global session save on reboot, shutdown and logout. I am not sure how that can be replaced yet. If it really is needed probably via X11 XSM calls?
Comment 27 Christian Persch 2007-08-16 22:11:08 UTC
From attachment (id=93046):
+	g_option_context_add_group (context, gtk_get_option_group (FALSE));
+	g_option_context_parse (context, &argc, &argv, NULL);
+	gtk_init (&argc, &argv);

That really shouldn't be necessary. Maybe the problem is with the |FALSE| in the gtk_get_option_group call which makes it not open the default display after parsing the arguments, while gtk_init does open it?
Comment 28 Jani Monoses 2007-08-28 16:13:27 UTC
Richard, can you please commit the patch in comment #26? It is independent of the other uses of GnomeClient in g-p-m.

As for the latter it is used to request a global session save in case of reboot, shutdown and interactive_action (I am not sure what this does). IIRC at one point they were ifdeffed out in the ubuntu package, somewhat supporting your view that GC is not necessary for anything anymore, but they're still there in the code, and probably not just legacy code.
Comment 29 Richard Hughes 2007-09-17 15:49:40 UTC
>can you please commit the patch

It's now hard code freeze for gnome 2-20, but I'll hopefully get these patches tested and upstream when svn re-opens.

Richard.
Comment 30 André Klapper 2007-12-21 03:06:17 UTC
@hughsie: *ping*
Comment 31 Richard Hughes 2007-12-21 16:01:50 UTC
Thanks for the ping, applied to trunk:

2007-12-21  Richard Hughes  <richard@hughsie.com>

	* src/gpm-main.c: (main):
	Drop unused gnome client from main.c

	The GnomeClient usage in main.c is a noop currently (commented out
	code, and a "die" callback that does not seem useful)

	Patch from Jani Monoses <jani@ubuntu.com>, many thanks.
Comment 32 Jaap A. Haitsma 2008-02-01 19:08:28 UTC
Richard,

I think this bug can be closed. All patches seem to be applied

Jaap