Merge lp:~ted/indicator-appmenu/hudectomy into lp:indicator-appmenu/13.04

Proposed by Ted Gould
Status: Merged
Approved by: Mathieu Trudel-Lapierre
Approved revision: 231
Merged at revision: 233
Proposed branch: lp:~ted/indicator-appmenu/hudectomy
Merge into: lp:indicator-appmenu/13.04
Diff against target: 15191 lines (+5/-14591)
101 files modified
Makefile.am (+2/-4)
configure.ac (+0/-24)
data/Makefile.am (+1/-12)
data/com.canonical.hud.service.in (+0/-3)
data/com.canonical.indicator.appmenu.hud.gschema.xml (+0/-16)
data/com.canonical.indicator.appmenu.hud.search.gschema.xml (+0/-72)
debian/control (+1/-6)
debian/indicator-appmenu-tools.install (+0/-7)
debian/indicator-appmenu.install (+0/-2)
docs/HUD Architecture.svg (+0/-368)
docs/Makefile.am (+0/-1)
docs/devel/Makefile.am (+0/-36)
docs/devel/hud-docs.xml (+0/-58)
docs/devel/hud-overview.xml (+0/-91)
docs/devel/hud-sections.txt (+0/-172)
docs/devel/hud.types (+0/-11)
docs/man/Makefile.am (+0/-16)
docs/man/hud-cli.xml (+0/-38)
docs/man/hud-dump-application.xml (+0/-45)
docs/man/hud-list-applications.xml (+0/-44)
docs/man/hud-verify-app-info.xml (+0/-35)
po/POTFILES.in (+0/-22)
src/Makefile.am (+1/-179)
src/create-db.h (+0/-4)
src/create-db.sql (+0/-2)
src/dump-app-info.c (+0/-174)
src/dump-app-info.h (+0/-30)
src/hud-cli.c (+0/-237)
src/hud-dump-application.c (+0/-73)
src/hud-list-applications (+0/-11)
src/hud-service.c (+0/-335)
src/hud-verify-app-info.c (+0/-100)
src/hud.xml (+0/-37)
src/hudappindicatorsource.c (+0/-432)
src/hudappindicatorsource.h (+0/-36)
src/hudappmenuregistrar.c (+0/-507)
src/hudappmenuregistrar.h (+0/-53)
src/huddbusmenucollector.c (+0/-679)
src/huddbusmenucollector.h (+0/-48)
src/huddebugsource.c (+0/-168)
src/huddebugsource.h (+0/-36)
src/hudindicatorsource.c (+0/-286)
src/hudindicatorsource.h (+0/-36)
src/huditem.c (+0/-343)
src/huditem.h (+0/-79)
src/hudmenumodelcollector.c (+0/-757)
src/hudmenumodelcollector.h (+0/-46)
src/hudquery.c (+0/-319)
src/hudquery.h (+0/-50)
src/hudresult.c (+0/-310)
src/hudresult.h (+0/-48)
src/hudsettings.c (+0/-128)
src/hudsettings.h (+0/-43)
src/hudsource.c (+0/-173)
src/hudsource.h (+0/-57)
src/hudsourcelist.c (+0/-165)
src/hudsourcelist.h (+0/-39)
src/hudstringlist.c (+0/-227)
src/hudstringlist.h (+0/-40)
src/hudtoken.c (+0/-406)
src/hudtoken.h (+0/-43)
src/hudwebappsource.c (+0/-376)
src/hudwebappsource.h (+0/-36)
src/hudwindowsource.c (+0/-372)
src/hudwindowsource.h (+0/-37)
src/load-app-info.c (+0/-319)
src/load-app-info.h (+0/-30)
src/shared-values.h (+0/-33)
tests/Makefile.am (+0/-447)
tests/bad-app-info/dual-headers.hud-app-info (+0/-3)
tests/bad-app-info/item-no-count.hud-app-info (+0/-8)
tests/bad-app-info/item-no-name.hud-app-info (+0/-8)
tests/bad-app-info/menu-no-name.hud-app-info (+0/-8)
tests/bad-app-info/missing-desktop.hud-app-info (+0/-7)
tests/bad-app-info/missing-menus.hud-app-info (+0/-6)
tests/bad-app-info/multiple-menus.hud-app-info (+0/-13)
tests/good-app-info/testapp.desktop.hud-app-info (+0/-8)
tests/good-app-info/testapp100.desktop.hud-app-info (+0/-8)
tests/good-app-info/tons-of-entries.hud-app-info (+0/-143)
tests/hud-performance.c (+0/-278)
tests/run-xvfb.sh (+0/-7)
tests/test-app-indicator.c (+0/-65)
tests/test-bad-app-info.c (+0/-100)
tests/test-dbus-message-count-send-query (+0/-4)
tests/test-dbus-message-count.in (+0/-18)
tests/test-dbus-message-count.json (+0/-2928)
tests/test-distance.c (+0/-267)
tests/test-load-app-info.c (+0/-82)
tests/test-result-highlighting.c (+0/-198)
tests/test-usage-db-ancient.c (+0/-39)
tests/test-usage-db-ancient.sql (+0/-7)
tests/test-usage-db-old.c (+0/-80)
tests/test-usage-db-old.sql (+0/-11)
tests/test-usage-db-simple.c (+0/-106)
tests/test-usage-db-simple.sql (+0/-11)
tests/test-usage-db-testapp.c (+0/-80)
tests/test-usage-dump-entries.sql (+0/-1)
tests/word-list.h (+0/-364)
tools-vala/Makefile.am (+0/-24)
tools-vala/hud-gtk.ui (+0/-119)
tools-vala/hud-gtk.vala (+0/-121)
To merge this branch: bzr merge lp:~ted/indicator-appmenu/hudectomy
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Mathieu Trudel-Lapierre Approve
Charles Kerr (community) Approve
Review via email: mp+131237@code.launchpad.net

Commit message

Remove the HUD files from indicator-appmenu

Description of the change

We've move the HUD to lp:hud. It shouldn't be here anymore.

To post a comment you must log in.
Revision history for this message
Charles Kerr (charlesk) wrote :

Cool.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Allan LeSage (allanlesage) wrote :

Legit CI failure above, packaging needs to be updated:

dh_install --fail-missing
dh_install: indicator-appmenu missing files (debian/tmp/usr/lib/*/hud-service), aborting
make[1]: *** [override_dh_install] Error 2
make[1]: Leaving directory `/tmp/buildd/indicator-appmenu-12.10.4daily12.11.23'
make: *** [binary] Error 2
dpkg-buildpackage: error: fakeroot debian/rules binary gave error exit status 2
E: Failed autobuilding of package

cyphermox advocates editing debian/indicator-appmenu.install to remove this expectation of finding the removed built files.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

Approve.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Makefile.am'
--- Makefile.am 2012-12-03 17:40:45 +0000
+++ Makefile.am 2013-02-19 17:11:22 +0000
@@ -3,15 +3,13 @@
3SUBDIRS = \3SUBDIRS = \
4 data \4 data \
5 po \5 po \
6 src \6 src
7 docs
87
9if BUILD_TESTS8if BUILD_TESTS
10SUBDIRS += \9SUBDIRS += \
11 scripts \10 scripts \
12 tests \11 tests \
13 tools \12 tools
14 tools-vala
15endif13endif
1614
17tests: src15tests: src
1816
=== modified file 'configure.ac'
--- configure.ac 2013-01-22 20:39:37 +0000
+++ configure.ac 2013-02-19 17:11:22 +0000
@@ -76,26 +76,6 @@
76AC_SUBST(INDICATOR_LIBS)76AC_SUBST(INDICATOR_LIBS)
7777
78###########################78###########################
79# Dependencies
80###########################
81
82DBUSMENU_GLIB_REQUIRED_VERSION=0.4.0
83BAMF_REQUIRED_VERSION=0.2.53
84SQLITE_REQUIRED_VERSION=0.0
85
86PKG_CHECK_MODULES([HUD],[
87 dbusmenu-glib-0.4 >= $DBUSMENU_GLIB_REQUIRED_VERSION
88 gio-2.0 >= $GIO_REQUIRED_VERSION
89 libbamf3
90 sqlite3 >= $SQLITE_REQUIRED_VERSION
91])
92
93PKG_CHECK_MODULES([HUD_CLIENT],[
94 gio-unix-2.0 >= $GIO_REQUIRED_VERSION
95 gtk+-3.0 >= $GTK_REQUIRED_VERSION
96])
97
98###########################
99# CLI Dependencies79# CLI Dependencies
100###########################80###########################
10181
@@ -233,12 +213,8 @@
233data/Makefile213data/Makefile
234tools/Makefile214tools/Makefile
235po/Makefile.in215po/Makefile.in
236tools-vala/Makefile
237tests/Makefile216tests/Makefile
238tests/manual/Makefile217tests/manual/Makefile
239docs/Makefile
240docs/man/Makefile
241docs/devel/Makefile
242])218])
243219
244###########################220###########################
245221
=== modified file 'data/Makefile.am'
--- data/Makefile.am 2012-12-03 17:40:45 +0000
+++ data/Makefile.am 2013-02-19 17:11:22 +0000
@@ -1,19 +1,8 @@
1gsettings_SCHEMAS = \1gsettings_SCHEMAS = \
2 com.canonical.indicator.appmenu.gschema.xml \2 com.canonical.indicator.appmenu.gschema.xml
3 com.canonical.indicator.appmenu.hud.gschema.xml \
4 com.canonical.indicator.appmenu.hud.search.gschema.xml
53
6@GSETTINGS_RULES@4@GSETTINGS_RULES@
75
8dbus_servicesdir = $(DBUSSERVICEDIR)
9dbus_services_DATA = com.canonical.hud.service
10
11%.service: %.service.in
12 sed -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@
13
14EXTRA_DIST = \6EXTRA_DIST = \
15 $(dbus_services_DATA:.service=.service.in) \
16 $(gsettings_SCHEMAS)7 $(gsettings_SCHEMAS)
178
18CLEANFILES = \
19 $(dbus_services_DATA)
209
=== removed file 'data/com.canonical.hud.service.in'
--- data/com.canonical.hud.service.in 2012-12-03 17:40:45 +0000
+++ data/com.canonical.hud.service.in 1970-01-01 00:00:00 +0000
@@ -1,3 +0,0 @@
1[D-BUS Service]
2Name=com.canonical.hud
3Exec=@libexecdir@/hud-service
40
=== removed file 'data/com.canonical.indicator.appmenu.hud.gschema.xml'
--- data/com.canonical.indicator.appmenu.hud.gschema.xml 2012-12-03 17:40:45 +0000
+++ data/com.canonical.indicator.appmenu.hud.gschema.xml 1970-01-01 00:00:00 +0000
@@ -1,16 +0,0 @@
1<?xml version='1.0' encoding='UTF-8'?>
2
3<schemalist>
4 <schema path='/com/canonical/indicator/appmenu/hud/' id='com.canonical.indicator.appmenu.hud' gettext-domain='indicator-appmenu'>
5 <key type='b' name='store-usage-data'>
6 <default>true</default>
7 <summary>Whether to store usage data</summary>
8 <description>
9 When the HUD executes operations it stores the execution in order to
10 make the future results better. Some users could choose to not want
11 this data to be stored. If that is the case they should disable this
12 property.
13 </description>
14 </key>
15 </schema>
16</schemalist>
170
=== removed file 'data/com.canonical.indicator.appmenu.hud.search.gschema.xml'
--- data/com.canonical.indicator.appmenu.hud.search.gschema.xml 2012-12-03 17:40:45 +0000
+++ data/com.canonical.indicator.appmenu.hud.search.gschema.xml 1970-01-01 00:00:00 +0000
@@ -1,72 +0,0 @@
1<?xml version='1.0' encoding='UTF-8'?>
2
3<schemalist>
4 <schema path='/com/canonical/indicator/appmenu/hud/search/'
5 id='com.canonical.indicator.appmenu.hud.search'
6 gettext-domain='indicator-appmenu'>
7 <key type='u' name='indicator-penalty'>
8 <default>50</default>
9 <summary>The penalty given to a menu item being in an indicator</summary>
10 <description>
11 In order to have the application's menu items appear higher in the search results a slight penalty is
12 given to the indicator menu items. This value represents the percentage of that penalty so a value of
13 '50' is a 50% additional to the calculated distance.
14 </description>
15 </key>
16
17 <key type='u' name='add-penalty'>
18 <default>10</default>
19 <summary>Penalty for extra characters added to the search</summary>
20 <description>
21 The penalty for each extra character in the search string that does not appear in the text of a menu
22 item.
23
24 This penalty would be applied if the user typed "fiile" when searching against the menu item "File", for
25 example.
26 </description>
27 </key>
28
29 <key type='u' name='drop-penalty'>
30 <default>10</default>
31 <summary>Penalty applied if a character is dropped</summary>
32 <description>
33 The penalty for each character dropped from the search string, as compared with the text of a menu item.
34 This only applies to missing characters that are not at the end of the search term.
35
36 This penalty would be applied if the user typed "fle" when searching against the menu item "File", for
37 example.
38 </description>
39 </key>
40
41 <key type='u' name='end-drop-penalty'>
42 <default>1</default>
43 <summary>Penalty applied if a character is dropped from the end</summary>
44 <description>
45 The penalty for each missing character at the end of a search term.
46
47 This penalty would be applied if the user typed "fil" when searching against the menu item "File", for
48 example.
49 </description>
50 </key>
51
52 <key type='u' name='swap-penalty'>
53 <default>15</default>
54 <summary>Penalty applied when the characters are not the same</summary>
55 <description>
56 The penalty for each substituted character in the search term.
57
58 The penalty would be applied if the user typed "fike" when searching against the menu item "File", for
59 example.
60 </description>
61 </key>
62
63 <key type='u' name='max-distance'>
64 <default>30</default>
65 <summary>The highest distance value that is shown in the results</summary>
66 <description>
67 After the distances are calculated (including the indicator penalty) then all values above this max are
68 dropped. This means that the history for those entries aren't looked up as well.
69 </description>
70 </key>
71 </schema>
72</schemalist>
730
=== modified file 'debian/control'
--- debian/control 2013-01-22 20:39:37 +0000
+++ debian/control 2013-02-19 17:11:22 +0000
@@ -17,13 +17,8 @@
17 libdbusmenu-gtk3-dev (>= 0.5.90),17 libdbusmenu-gtk3-dev (>= 0.5.90),
18 libdbusmenu-jsonloader-dev (>= 0.5.90),18 libdbusmenu-jsonloader-dev (>= 0.5.90),
19 libbamf3-dev (>= 0.2.53),19 libbamf3-dev (>= 0.2.53),
20 libsqlite3-dev,
21 sqlite3,
22 libreadline-dev,
23 libncurses5-dev,
24 libappindicator3-dev,20 libappindicator3-dev,
25 indicator-application (>= 0.4.90),21 indicator-application (>= 0.4.90),
26 valac-0.16,
27Standards-Version: 3.9.222Standards-Version: 3.9.2
28Homepage: http://launchpad.net/indicator-appmenu23Homepage: http://launchpad.net/indicator-appmenu
29# If you aren't a member of ~indicator-applet-developers but need to upload24# If you aren't a member of ~indicator-applet-developers but need to upload
@@ -36,6 +31,7 @@
36Architecture: any31Architecture: any
37Depends: ${shlibs:Depends},32Depends: ${shlibs:Depends},
38 ${misc:Depends},33 ${misc:Depends},
34 hud,
39Recommends: indicator-applet | indicator-renderer,35Recommends: indicator-applet | indicator-renderer,
40 appmenu-gtk,36 appmenu-gtk,
41 appmenu-gtk3,37 appmenu-gtk3,
@@ -50,7 +46,6 @@
50 ${misc:Depends},46 ${misc:Depends},
51 indicator-appmenu (= ${binary:Version}),47 indicator-appmenu (= ${binary:Version}),
52 libdbusmenu-tools,48 libdbusmenu-tools,
53 sqlite3,
54Description: Tools for debuging application menus.49Description: Tools for debuging application menus.
55 .50 .
56 This package provides tools for supporting application menus.51 This package provides tools for supporting application menus.
5752
=== modified file 'debian/indicator-appmenu-tools.install'
--- debian/indicator-appmenu-tools.install 2012-12-03 17:40:45 +0000
+++ debian/indicator-appmenu-tools.install 2013-02-19 17:11:22 +0000
@@ -1,10 +1,3 @@
1debian/tmp/usr/lib/*/current-menu*1debian/tmp/usr/lib/*/current-menu*
2debian/tmp/usr/lib/*/menu-pusher2debian/tmp/usr/lib/*/menu-pusher
3debian/tmp/usr/lib/*/mock-json-app3debian/tmp/usr/lib/*/mock-json-app
4debian/tmp/usr/bin/hud-cli /usr/bin/
5debian/tmp/usr/bin/hud-dump-application /usr/bin/
6debian/tmp/usr/bin/hud-gtk /usr/bin/
7debian/tmp/usr/bin/hud-list-applications /usr/bin/
8debian/tmp/usr/bin/hud-verify-app-info /usr/bin/
9debian/tmp/usr/share/man/ /usr/share/
10debian/tmp/usr/share/hud-gtk /usr/share/
114
=== modified file 'debian/indicator-appmenu.install'
--- debian/indicator-appmenu.install 2012-12-03 17:40:45 +0000
+++ debian/indicator-appmenu.install 2013-02-19 17:11:22 +0000
@@ -1,6 +1,4 @@
1debian/tmp/usr/lib/indicators3 /usr/lib1debian/tmp/usr/lib/indicators3 /usr/lib
2debian/source_indicator-appmenu.py /usr/share/apport/package-hooks/2debian/source_indicator-appmenu.py /usr/share/apport/package-hooks/
3debian/indicator-appmenu-crashdb.conf /etc/apport/crashdb.conf.d/3debian/indicator-appmenu-crashdb.conf /etc/apport/crashdb.conf.d/
4debian/tmp/usr/lib/*/hud-service
5debian/tmp/usr/share/dbus-1/ /usr/share/
6debian/tmp/usr/share/glib-2.0/ /usr/share/4debian/tmp/usr/share/glib-2.0/ /usr/share/
75
=== removed directory 'docs'
=== removed file 'docs/HUD Architecture.svg'
--- docs/HUD Architecture.svg 2012-12-03 17:40:45 +0000
+++ docs/HUD Architecture.svg 1970-01-01 00:00:00 +0000
@@ -1,368 +0,0 @@
1<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2<!-- Created with Inkscape (http://www.inkscape.org/) -->
3
4<svg
5 xmlns:dc="http://purl.org/dc/elements/1.1/"
6 xmlns:cc="http://creativecommons.org/ns#"
7 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
8 xmlns:svg="http://www.w3.org/2000/svg"
9 xmlns="http://www.w3.org/2000/svg"
10 xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
11 xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
12 width="706.61322"
13 height="774.54626"
14 id="svg2"
15 version="1.1"
16 inkscape:version="0.48.2 r9819"
17 sodipodi:docname="HUD Architecture.svg">
18 <defs
19 id="defs4">
20 <inkscape:path-effect
21 effect="spiro"
22 id="path-effect4218"
23 is_visible="true" />
24 <inkscape:path-effect
25 effect="spiro"
26 id="path-effect4214"
27 is_visible="true" />
28 <inkscape:path-effect
29 effect="spiro"
30 id="path-effect4210"
31 is_visible="true" />
32 <inkscape:path-effect
33 effect="spiro"
34 id="path-effect4206"
35 is_visible="true" />
36 <inkscape:path-effect
37 effect="spiro"
38 id="path-effect4054"
39 is_visible="true" />
40 <inkscape:path-effect
41 effect="spiro"
42 id="path-effect3863"
43 is_visible="true" />
44 <inkscape:path-effect
45 effect="spiro"
46 id="path-effect3829"
47 is_visible="true" />
48 <inkscape:path-effect
49 effect="spiro"
50 id="path-effect3825"
51 is_visible="true" />
52 </defs>
53 <sodipodi:namedview
54 id="base"
55 pagecolor="#ffffff"
56 bordercolor="#666666"
57 borderopacity="1.0"
58 inkscape:pageopacity="0.0"
59 inkscape:pageshadow="2"
60 inkscape:zoom="1.1071895"
61 inkscape:cx="232.7327"
62 inkscape:cy="382.51953"
63 inkscape:document-units="px"
64 inkscape:current-layer="layer1"
65 showgrid="false"
66 inkscape:showpageshadow="false"
67 inkscape:window-width="1680"
68 inkscape:window-height="1026"
69 inkscape:window-x="0"
70 inkscape:window-y="24"
71 inkscape:window-maximized="1"
72 fit-margin-top="50"
73 fit-margin-left="50"
74 fit-margin-right="50"
75 fit-margin-bottom="50" />
76 <metadata
77 id="metadata7">
78 <rdf:RDF>
79 <cc:Work
80 rdf:about="">
81 <dc:format>image/svg+xml</dc:format>
82 <dc:type
83 rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
84 <dc:title />
85 </cc:Work>
86 </rdf:RDF>
87 </metadata>
88 <g
89 inkscape:label="Layer 1"
90 inkscape:groupmode="layer"
91 id="layer1"
92 transform="translate(-153.88477,-277.83542)">
93 <rect
94 style="color:#000000;fill:none;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
95 id="rect2985"
96 width="192.93913"
97 height="104.04572"
98 x="241.00642"
99 y="328.33542" />
100 <rect
101 style="color:#000000;fill:none;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
102 id="rect2985-3"
103 width="192.93913"
104 height="104.04572"
105 x="245.62126"
106 y="558.84198" />
107 <rect
108 style="color:#000000;fill:none;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
109 id="rect2985-9"
110 width="192.93913"
111 height="104.04572"
112 x="586.43182"
113 y="384.48648" />
114 <rect
115 style="color:#000000;fill:none;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
116 id="rect2985-7"
117 width="192.93913"
118 height="104.04572"
119 x="617.05884"
120 y="561.62695" />
121 <flowRoot
122 xml:space="preserve"
123 id="flowRoot3805"
124 style="font-size:18px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Bumped BRK;-inkscape-font-specification:Bumped BRK"><flowRegion
125 id="flowRegion3807"><rect
126 id="rect3809"
127 width="187.07358"
128 height="95.192307"
129 x="242.53345"
130 y="43.193981"
131 style="font-family:Bumped BRK;-inkscape-font-specification:Bumped BRK" /></flowRegion><flowPara
132 id="flowPara3811" /></flowRoot> <flowRoot
133 xml:space="preserve"
134 id="flowRoot3813"
135 style="font-size:18px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:100%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:Ubuntu;-inkscape-font-specification:Ubuntu"
136 transform="translate(0,310.93426)"><flowRegion
137 id="flowRegion3815"><rect
138 id="rect3817"
139 width="175.48492"
140 height="46.354519"
141 x="249.15552"
142 y="52.299332"
143 style="text-align:center;text-anchor:middle"
144 ry="0"
145 rx="0" /></flowRegion><flowPara
146 id="flowPara3819"
147 style="font-weight:bold;-inkscape-font-specification:Ubuntu Bold">Unity</flowPara><flowPara
148 id="flowPara3821"
149 style="font-weight:bold;-inkscape-font-specification:Ubuntu Bold">GUI</flowPara></flowRoot> <path
150 style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
151 d="m 449.47325,302.28261 c 29.69243,-2.03406 58.53652,-14.78861 80.02111,-35.38449 10.47599,-10.04266 19.17966,-21.79342 29.4484,-32.0479 8.83486,-8.8226 18.80808,-16.50398 29.59403,-22.79336"
152 id="path3823"
153 inkscape:path-effect="#path-effect3825"
154 inkscape:original-d="m 449.47325,302.28261 c 35.92724,5.92939 56.6183,-19.31435 80.02111,-35.38449 11.7014,-8.03507 19.73501,-22.46822 29.4484,-32.0479 9.7134,-9.57969 21.10658,-14.30591 29.59403,-22.79336"
155 inkscape:connector-curvature="0"
156 transform="translate(0,287.36218)"
157 sodipodi:nodetypes="cssc" />
158 <path
159 style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
160 d="m 449.81773,318.01003 c 21.09159,-2.06081 42.43769,-1.50335 63.39297,1.65552 17.10783,2.5789 34.02902,6.89013 51.32108,7.44983 12.84929,0.4159 25.76421,-1.26865 38.07692,-4.96655"
161 id="path3827"
162 inkscape:path-effect="#path-effect3829"
163 inkscape:original-d="m 449.81773,318.01003 c 11.59516,1.94007 62.94692,-1.93293 63.39297,1.65552 1.01665,8.17897 40.57446,3.86763 51.32108,7.44983 19.17114,6.39038 20.04051,-0.45745 38.07692,-4.96655"
164 inkscape:connector-curvature="0"
165 transform="translate(0,287.36218)"
166 sodipodi:nodetypes="cssc" />
167 <flowRoot
168 xml:space="preserve"
169 id="flowRoot3813-1"
170 style="font-size:18px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:100%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:Ubuntu;-inkscape-font-specification:Ubuntu"
171 transform="translate(2.6759825,544.72955)"><flowRegion
172 id="flowRegion3815-4"><rect
173 id="rect3817-9"
174 width="175.48492"
175 height="46.354519"
176 x="249.15552"
177 y="52.299332"
178 style="text-align:center;text-anchor:middle"
179 ry="0"
180 rx="0" /></flowRegion><flowPara
181 id="flowPara3819-7"
182 style="font-weight:bold">HUD</flowPara><flowPara
183 id="flowPara3821-6"
184 style="font-weight:bold">Service</flowPara></flowRoot> <path
185 style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
186 d="m 342.69231,158.25251 0,103.4699"
187 id="path3861"
188 inkscape:path-effect="#path-effect3863"
189 inkscape:original-d="m 342.69231,158.25251 c 0,102.64214 0,103.4699 0,103.4699"
190 inkscape:connector-curvature="0"
191 transform="translate(0,287.36218)" />
192 <text
193 xml:space="preserve"
194 style="font-size:18px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Ubuntu;-inkscape-font-specification:Ubuntu"
195 x="658.00934"
196 y="442.75534"
197 id="text3865"
198 sodipodi:linespacing="100%"><tspan
199 sodipodi:role="line"
200 id="tspan3867"
201 x="658.00934"
202 y="442.75534"
203 style="font-weight:bold">BAMF</tspan></text>
204 <text
205 xml:space="preserve"
206 style="font-size:18px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:100%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:Ubuntu;-inkscape-font-specification:Ubuntu"
207 x="714.17834"
208 y="609.96881"
209 id="text3869"
210 sodipodi:linespacing="100%"><tspan
211 sodipodi:role="line"
212 id="tspan3871"
213 x="714.17834"
214 y="609.96881"
215 style="font-weight:bold">Indicator</tspan><tspan
216 sodipodi:role="line"
217 x="714.17834"
218 y="627.96881"
219 id="tspan3873"
220 style="font-weight:bold">AppMenu</tspan></text>
221 <text
222 xml:space="preserve"
223 style="font-size:18px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#444444;fill-opacity:1;stroke:none;font-family:Ubuntu;-inkscape-font-specification:Ubuntu"
224 x="203.62877"
225 y="481.20834"
226 id="text3875"
227 sodipodi:linespacing="100%"><tspan
228 sodipodi:role="line"
229 id="tspan3877"
230 x="203.62877"
231 y="481.20834"
232 style="font-size:16px;fill:#444444;fill-opacity:1">Text Area</tspan><tspan
233 sodipodi:role="line"
234 x="203.62877"
235 y="497.20834"
236 id="tspan3879"
237 style="font-size:16px;fill:#444444;fill-opacity:1">Target Text</tspan><tspan
238 sodipodi:role="line"
239 x="203.62877"
240 y="513.20837"
241 id="tspan3881"
242 style="font-size:16px;fill:#444444;fill-opacity:1">Suggestions</tspan></text>
243 <text
244 xml:space="preserve"
245 style="font-size:18px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-indent:0;text-align:start;text-decoration:none;line-height:100%;letter-spacing:0px;word-spacing:0px;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:start;baseline-shift:baseline;color:#000000;fill:#444444;fill-opacity:1;fill-rule:nonzero;stroke:none;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;font-family:Ubuntu;-inkscape-font-specification:Ubuntu"
246 x="470.16724"
247 y="506.04111"
248 id="text3883"
249 sodipodi:linespacing="100%"><tspan
250 sodipodi:role="line"
251 id="tspan3885"
252 x="470.16724"
253 y="506.04111">Focused</tspan><tspan
254 sodipodi:role="line"
255 x="470.16724"
256 y="524.04114"
257 id="tspan3925">Window</tspan></text>
258 <text
259 xml:space="preserve"
260 style="font-size:18px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-indent:0;text-align:start;text-decoration:none;line-height:100%;letter-spacing:0px;word-spacing:0px;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:start;baseline-shift:baseline;color:#000000;fill:#444444;fill-opacity:1;fill-rule:nonzero;stroke:none;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;font-family:Ubuntu;-inkscape-font-specification:Ubuntu"
261 x="471.28049"
262 y="644.96588"
263 id="text3887"
264 sodipodi:linespacing="100%"><tspan
265 sodipodi:role="line"
266 id="tspan3889"
267 x="471.28049"
268 y="644.96588">Window to</tspan><tspan
269 sodipodi:role="line"
270 x="471.28049"
271 y="662.96588"
272 id="tspan3891">Menu mapping</tspan></text>
273 <rect
274 style="color:#000000;fill:none;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
275 id="rect2985-3-6-2"
276 width="259.15988"
277 height="245.59258"
278 x="230.90923"
279 y="756.28912" />
280 <text
281 xml:space="preserve"
282 style="font-size:18px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;font-family:Ubuntu;-inkscape-font-specification:Ubuntu"
283 x="326.11465"
284 y="994.28821"
285 id="text3865-8-2"
286 sodipodi:linespacing="100%"><tspan
287 sodipodi:role="line"
288 id="tspan3867-7-3"
289 x="326.11465"
290 y="994.28821"
291 style="font-weight:bold">Window</tspan></text>
292 <rect
293 style="color:#000000;fill:none;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
294 id="rect2985-7-7"
295 width="239.29364"
296 height="44.447052"
297 x="239.60066"
298 y="925.6922" />
299 <text
300 xml:space="preserve"
301 style="font-size:18px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-indent:0;text-align:center;text-decoration:none;line-height:100%;letter-spacing:0px;word-spacing:0px;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:middle;baseline-shift:baseline;color:#000000;fill:#444444;fill-opacity:1;fill-rule:nonzero;stroke:none;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;font-family:Ubuntu;-inkscape-font-specification:Ubuntu"
302 x="359.65784"
303 y="953.23474"
304 id="text3887-1"
305 sodipodi:linespacing="100%"><tspan
306 sodipodi:role="line"
307 x="359.65784"
308 y="953.23474"
309 id="tspan3891-2">Appmenu Module</tspan></text>
310 <path
311 style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
312 d="m 485.89465,652.84114 c 16.23733,-3.84221 30.5802,-15.04776 38.23686,-29.87304 6.96387,-13.48385 8.38625,-29.21496 7.3396,-44.35478 -1.04664,-15.13982 -4.41236,-30.01318 -6.51184,-45.04321 -2.74315,-19.63804 -3.3102,-39.70499 0.0347,-59.24953 3.34491,-19.54455 10.71754,-38.58634 22.79255,-54.3144 15.0578,-19.61323 37.35193,-33.53801 61.58305,-38.46438"
313 id="path4052"
314 inkscape:path-effect="#path-effect4054"
315 inkscape:original-d="m 485.89465,652.84114 c 69.8028,11.24543 30.70744,15.30352 38.23686,-29.87304 4.70103,-28.20618 0.82776,-60.68417 0.82776,-89.39799 0,-3.09441 20.32766,-111.06434 22.82725,-113.56393 2.41681,-2.4168 58.09902,-38.46438 61.58305,-38.46438"
316 inkscape:connector-curvature="0"
317 transform="translate(0,287.36218)"
318 sodipodi:nodetypes="csssc" />
319 <rect
320 style="color:#000000;fill:none;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
321 id="rect4056"
322 width="237.68489"
323 height="150.42575"
324 x="239.97879"
325 y="765.35535" />
326 <text
327 xml:space="preserve"
328 style="font-size:18px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-indent:0;text-align:center;text-decoration:none;line-height:100%;letter-spacing:0px;word-spacing:0px;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:middle;baseline-shift:baseline;color:#000000;fill:#444444;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;font-family:Ubuntu;-inkscape-font-specification:Ubuntu"
329 x="358.56305"
330 y="846.6972"
331 id="text4093"
332 sodipodi:linespacing="100%"><tspan
333 sodipodi:role="line"
334 id="tspan4095"
335 x="358.56305"
336 y="846.6972">Menus</tspan></text>
337 <path
338 style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
339 d="m 325.97456,760.29042 c -3.42872,-7.04416 -5.0107,-14.97733 -4.54619,-22.79786 0.46451,-7.82052 2.97446,-15.51064 7.21293,-22.0994 4.43899,-6.90047 10.66453,-12.51742 15.05132,-19.45118 4.11736,-6.5079 6.50844,-14.09719 6.86513,-21.78993"
340 id="path4204"
341 inkscape:path-effect="#path-effect4206"
342 inkscape:original-d="m 325.97456,760.29042 c -12.83313,-16.30425 -6.68734,-30.5721 2.66674,-44.89726 4.67704,-7.16258 10.74147,-11.99823 15.05132,-19.45118 4.30985,-7.45294 6.86513,-13.52319 6.86513,-21.78993"
343 inkscape:connector-curvature="0"
344 sodipodi:nodetypes="cssc" />
345 <text
346 xml:space="preserve"
347 style="font-size:18px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-indent:0;text-align:start;text-decoration:none;line-height:100%;letter-spacing:0px;word-spacing:0px;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:start;baseline-shift:baseline;color:#000000;fill:#444444;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;font-family:Ubuntu;-inkscape-font-specification:Ubuntu"
348 x="357.66235"
349 y="720.89227"
350 id="text3118"
351 sodipodi:linespacing="100%"><tspan
352 sodipodi:role="line"
353 id="tspan3120"
354 x="357.66235"
355 y="720.89227">Dbusmenu</tspan></text>
356 <text
357 xml:space="preserve"
358 style="font-size:18px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-indent:0;text-align:start;text-decoration:none;line-height:100%;letter-spacing:0px;word-spacing:0px;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:start;baseline-shift:baseline;color:#000000;fill:#444444;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;font-family:Ubuntu;-inkscape-font-specification:Ubuntu"
359 x="556.55219"
360 y="804.53925"
361 id="text3118-3"
362 sodipodi:linespacing="100%"><tspan
363 sodipodi:role="line"
364 id="tspan3120-3"
365 x="556.55219"
366 y="804.53925">Registration</tspan></text>
367 </g>
368</svg>
3690
=== removed file 'docs/Makefile.am'
--- docs/Makefile.am 2012-12-03 17:40:45 +0000
+++ docs/Makefile.am 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1SUBDIRS = man devel
20
=== removed directory 'docs/devel'
=== removed file 'docs/devel/Makefile.am'
--- docs/devel/Makefile.am 2012-12-03 17:40:45 +0000
+++ docs/devel/Makefile.am 1970-01-01 00:00:00 +0000
@@ -1,36 +0,0 @@
1include $(top_srcdir)/gtk-doc.make
2
3DOC_MODULE = hud
4
5DOC_MAIN_SGML_FILE = $(DOC_MODULE)-docs.xml
6
7DOC_SOURCE_DIR = $(top_srcdir)/src
8
9MKDB_OPTIONS = --sgml-mode --output-format=xml
10
11HFILE_GLOB = $(DOC_SOURCE_DIR)/*.h
12CFILE_GLOB = $(DOC_SOURCE_DIR)/*.c
13
14IGNORE_HFILES = \
15 MwmUtil.h \
16 create-db.h \
17 dbus-shared.h \
18 distance.h \
19 dump-app-info.h \
20 gen-application-menu-renderer.xml.h \
21 gen-application-menu-registrar.xml.h \
22 gdk-get-func.h \
23 hud.interface.h \
24 indicator-tracker.h \
25 load-app-info.h \
26 menuitem-collector.h \
27 shared-values.h \
28 usage-tracker.h \
29 utils.h \
30 window-menus.h
31
32GTKDOC_CFLAGS = -I$(top_srcdir)/src $(HUD_CFLAGS)
33
34GTKDOC_LIBS = $(top_builddir)/src/libhud-service.a \
35 $(HUD_LIBS) \
36 $(COVERAGE_LDFLAGS)
370
=== removed file 'docs/devel/hud-docs.xml'
--- docs/devel/hud-docs.xml 2012-12-03 17:40:45 +0000
+++ docs/devel/hud-docs.xml 1970-01-01 00:00:00 +0000
@@ -1,58 +0,0 @@
1<?xml version="1.0"?>
2<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
3 "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd"
4[
5 <!ENTITY % local.common.attrib "xmlns:xi CDATA #FIXED 'http://www.w3.org/2003/XInclude'">
6 ]>
7
8<book id="index">
9 <bookinfo>
10 <title>hud-service Hacking Guide</title>
11 </bookinfo>
12
13 <xi:include href="hud-overview.xml"/>
14
15 <chapter>
16 <title>Data Types</title>
17 <xi:include href="xml/hudstringlist.xml"/>
18 </chapter>
19
20 <chapter>
21 <title>Queries, Results, Items</title>
22 <xi:include href="xml/huditem.xml"/>
23 <xi:include href="xml/hudresult.xml"/>
24 <xi:include href="xml/hudquery.xml"/>
25 </chapter>
26
27 <chapter>
28 <title>Sources</title>
29 <xi:include href="xml/hudsource.xml"/>
30 <xi:include href="xml/hudsourcelist.xml"/>
31 <xi:include href="xml/hudwindowsource.xml"/>
32 <xi:include href="xml/hudindicatorsource.xml"/>
33 <xi:include href="xml/hudappindicatorsource.xml"/>
34 <xi:include href="xml/huddbusmenucollector.xml"/>
35 <xi:include href="xml/hudmenumodelcollector.xml"/>
36 </chapter>
37
38 <chapter>
39 <title>Utility API</title>
40 <xi:include href="xml/hudsettings.xml"/>
41 <xi:include href="xml/hudappmenuregistrar.xml"/>
42 </chapter>
43
44 <chapter id="object-tree">
45 <title>Object Hierarchy</title>
46 <xi:include href="xml/tree_index.sgml"/>
47 </chapter>
48 <index id="api-index-full">
49 <title>API Index</title>
50 <xi:include href="xml/api-index-full.xml"><xi:fallback /></xi:include>
51 </index>
52 <index id="deprecated-api-index" role="deprecated">
53 <title>Index of deprecated API</title>
54 <xi:include href="xml/api-index-deprecated.xml"><xi:fallback /></xi:include>
55 </index>
56
57 <xi:include href="xml/annotation-glossary.xml"><xi:fallback /></xi:include>
58</book>
590
=== removed file 'docs/devel/hud-overview.xml'
--- docs/devel/hud-overview.xml 2012-12-03 17:40:45 +0000
+++ docs/devel/hud-overview.xml 1970-01-01 00:00:00 +0000
@@ -1,91 +0,0 @@
1<?xml version='1.0'?>
2
3
4<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
5 "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd">
6
7<chapter>
8 <title>Overview</title>
9
10 <para>
11 The HUD consists of the interface in the shell and a backend service, <literal>hud-service</literal>. This
12 document attempts to describe the internal architecture of the service.
13 </para>
14
15 <para>
16 The most important type in the service is <link linkend="HudSource"><type>HudSource</type></link>. This is
17 an interface. Each source is an entity against which a search can be performed. There is one interface
18 method: <link linkend="hud-source-search"><function>hud_source_search()</function></link>. This is the main
19 mechanism by which queries are performed in the HUD. The interface also features a signal
20 <link linkend="HudSource-changed"><function>::changed</function></link> that is emitted when the result of
21 searching may have changed.
22 </para>
23
24 <para>
25 Several implementations of <link linkend="HudSource"><type>HudSource</type></link> exist. A particular type
26 of source that gathers possible search results is referred to as a "collector". There are two of these:
27 <link linkend="HudMenuModelCollector"><type>HudMenuModelCollector</type></link> (for
28 <link linkend="GDBusMenuModel"><type>GDBusMenuModel</type></link>) and
29 <link linkend="HudDbusmenuCollector"><type>HudDbusmenuCollector</type></link> for Dbusmenu. These
30 "collector" sources only function when targetted at a particular endpoint (ie: a unique name and object path
31 on D-Bus). This is only useful for searching for items in one particular set of menus.
32 </para>
33
34 <para>
35 <link linkend="HudSourceList"><type>HudWindowSource</type></link> acts as a multiplexer. It is responsible
36 for determining the currently focused window and performing searches submitted to it against the correct
37 collector for that window. Similarly, there are
38 <link linkend="HudSourceList"><type>HudIndicatorSource</type></link> and
39 <link linkend="HudSourceList"><type>HudAppIndicatorSource</type></link> for performing searches against the
40 system and application indicators, respectively.
41 </para>
42
43 <para>
44 Finally, there is <link linkend="HudSourceList"><type>HudSourceList</type></link> which functions as a list
45 of multiple other <link linkend="HudSource"><type>HudSource</type></link>s (such that performing a search
46 against the list gives the combined result of searches performed against each of the contained sources).
47 </para>
48
49 <para>
50 The <literal>hud-service</literal> initialises itself by creating the window, indicator and appindicator
51 sources and putting each of them into a <link linkend="HudSourceList"><type>HudSourceList</type></link>.
52 This is the source against which all queries submitted to the service are executed.
53 </para>
54
55 <para>
56 Collectors are essentially a collection of <link linkend="HudItem"><type>HudItem</type></link>s. Each item
57 corresponds to an action that may appear in the results of a search made with the HUD. Items have a list of
58 strings describing themselves (eg: <literal>['File', 'Open']</literal> or
59 <literal>['Bluetooth', 'Settings...']</literal>) and some information about their origin (eg: the desktop
60 file of the application or indicator that created them). An item can be disabled, in which case it will
61 never appear in the results of a search. Items are activated using
62 <link linkend="hud-item-activate"><function>hud_item_activate()</function></link> which is implemented by
63 the collector in the appropriate way.
64 </para>
65
66 <para>
67 The result of performing a search is a set of <link linkend="HudResult"><type>HudResult</type></link>s.
68 Each result refers to <link linkend="HudItem"><type>HudItem</type></link> along with information about why
69 that item matched, and how closely.
70 </para>
71
72 <para>
73 The toplevel interface to performing a query is <link linkend="HudQuery"><type>HudQuery</type></link>. It
74 takes a search string and a reference to a <link linkend="HudSource"><type>HudSource</type></link> to search
75 (which, as implemented, is always the toplevel 'list' source). It submits the search to the source then
76 sorts the results by relevence. If the source changes, it resubmits the search. The interface of
77 <link linkend="HudQuery"><type>HudQuery</type></link> is an ordered sequence of results.
78 <link linkend="HudQuery"><type>HudQuery</type></link> has its own
79 <link linkend="HudQuery-changed"><function>::changed</function></link> signal.
80 </para>
81
82 <para>
83 <literal>hud-service</literal> is essentially a simple D-Bus interface corresponding to
84 <link linkend="HudQuery"><type>HudQuery</type></link> as used against the toplevel source list. New queries
85 can be created using <function>StartQuery</function>. Queries can be destroyed using
86 <function>CloseQuery</function>. <link linkend="HudItem"><type>HudItem</type></link>s corresponding to
87 results from the query can be activated using <function>ExecuteQuery</function>. Finally, the
88 <link linkend="HudQuery-changed"><function>::changed</function></link> signal is reported as the
89 <function>UpdatedQuery</function> D-Bus signal.
90 </para>
91</chapter>
920
=== removed file 'docs/devel/hud-sections.txt'
--- docs/devel/hud-sections.txt 2012-12-03 17:40:45 +0000
+++ docs/devel/hud-sections.txt 1970-01-01 00:00:00 +0000
@@ -1,172 +0,0 @@
1<SECTION>
2<FILE>hudsettings</FILE>
3HudSettings
4hud_settings
5hud_settings_init
6</SECTION>
7
8<SECTION>
9<FILE>hudappmenuregistrar</FILE>
10HudAppMenuRegistrar
11HudAppMenuRegistrarObserverFunc
12hud_app_menu_registrar_add_observer
13hud_app_menu_registrar_get
14hud_app_menu_registrar_remove_observer
15<SUBSECTION Standard>
16HUD_APP_MENU_REGISTRAR
17HUD_IS_APP_MENU_REGISTRAR
18HUD_TYPE_APP_MENU_REGISTRAR
19hud_app_menu_registrar_get_type
20</SECTION>
21
22<SECTION>
23<FILE>huddbusmenucollector</FILE>
24HudDbusmenuCollector
25hud_dbusmenu_collector_new_for_endpoint
26hud_dbusmenu_collector_new_for_window
27hud_dbusmenu_collector_set_prefix
28<SUBSECTION Standard>
29HUD_DBUSMENU_COLLECTOR
30HUD_IS_DBUSMENU_COLLECTOR
31HUD_TYPE_DBUSMENU_COLLECTOR
32hud_dbusmenu_collector_get_type
33</SECTION>
34
35<SECTION>
36<FILE>hudindicatorsource</FILE>
37HudIndicatorSource
38hud_indicator_source_new
39<SUBSECTION Standard>
40HUD_INDICATOR_SOURCE
41HUD_IS_INDICATOR_SOURCE
42HUD_TYPE_INDICATOR_SOURCE
43hud_indicator_source_get_type
44</SECTION>
45
46<SECTION>
47<FILE>hudappindicatorsource</FILE>
48HudAppIndicatorSource
49hud_app_indicator_source_new
50<SUBSECTION Standard>
51HUD_APP_INDICATOR_SOURCE
52HUD_IS_APP_INDICATOR_SOURCE
53HUD_TYPE_APP_INDICATOR_SOURCE
54hud_app_indicator_source_get_type
55</SECTION>
56
57<SECTION>
58<FILE>huditem</FILE>
59<TITLE>HudItem</TITLE>
60HudItem
61HudItemClass
62hud_item_activate
63hud_item_construct
64hud_item_get_app_icon
65hud_item_get_enabled
66hud_item_get_item_icon
67hud_item_get_tokens
68hud_item_get_usage
69hud_item_new
70<SUBSECTION Standard>
71HUD_IS_ITEM
72HUD_IS_ITEM_CLASS
73HUD_ITEM
74HUD_ITEM_CLASS
75HUD_ITEM_GET_CLASS
76HUD_TYPE_ITEM
77HudItemPrivate
78hud_item_get_type
79</SECTION>
80
81<SECTION>
82<FILE>hudmenumodelcollector</FILE>
83HudMenuModelCollector
84hud_menu_model_collector_get
85<SUBSECTION Standard>
86HUD_IS_MENU_MODEL_COLLECTOR
87HUD_MENU_MODEL_COLLECTOR
88HUD_TYPE_MENU_MODEL_COLLECTOR
89hud_menu_model_collector_get_type
90</SECTION>
91
92<SECTION>
93<FILE>hudquery</FILE>
94HudQuery
95hud_query_close
96hud_query_get_generation
97hud_query_get_n_results
98hud_query_get_query_key
99hud_query_get_result_by_index
100hud_query_lookup
101hud_query_new
102<SUBSECTION Standard>
103HUD_IS_QUERY
104HUD_QUERY
105HUD_TYPE_QUERY
106hud_query_get_type
107</SECTION>
108
109<SECTION>
110<FILE>hudresult</FILE>
111HudResult
112hud_result_get_distance
113hud_result_get_html_description
114hud_result_get_if_matched
115hud_result_get_item
116hud_result_new
117<SUBSECTION Standard>
118HUD_IS_RESULT
119HUD_RESULT
120HUD_TYPE_RESULT
121hud_result_get_type
122</SECTION>
123
124<SECTION>
125<FILE>hudsource</FILE>
126<TITLE>HudSource</TITLE>
127HudSource
128HudSourceInterface
129hud_source_changed
130hud_source_search
131<SUBSECTION Standard>
132HUD_IS_SOURCE
133HUD_SOURCE
134HUD_SOURCE_GET_IFACE
135HUD_TYPE_SOURCE
136hud_source_get_type
137</SECTION>
138
139<SECTION>
140<FILE>hudsourcelist</FILE>
141HudSourceList
142hud_source_list_add
143hud_source_list_new
144<SUBSECTION Standard>
145HUD_IS_SOURCE_LIST
146HUD_SOURCE_LIST
147HUD_TYPE_SOURCE_LIST
148hud_source_list_get_type
149</SECTION>
150
151<SECTION>
152<FILE>hudstringlist</FILE>
153HudStringList
154hud_string_list_cons
155hud_string_list_cons_label
156hud_string_list_get_head
157hud_string_list_get_tail
158hud_string_list_pretty_print
159hud_string_list_ref
160hud_string_list_unref
161</SECTION>
162
163<SECTION>
164<FILE>hudwindowsource</FILE>
165HudWindowSource
166hud_window_source_new
167<SUBSECTION Standard>
168HUD_IS_WINDOW_SOURCE
169HUD_TYPE_WINDOW_SOURCE
170HUD_WINDOW_SOURCE
171hud_window_source_get_type
172</SECTION>
1730
=== removed file 'docs/devel/hud.types'
--- docs/devel/hud.types 2012-12-03 17:40:45 +0000
+++ docs/devel/hud.types 1970-01-01 00:00:00 +0000
@@ -1,11 +0,0 @@
1hud_app_indicator_source_get_type
2hud_app_menu_registrar_get_type
3hud_dbusmenu_collector_get_type
4hud_indicator_source_get_type
5hud_item_get_type
6hud_menu_model_collector_get_type
7hud_query_get_type
8hud_result_get_type
9hud_source_get_type
10hud_source_list_get_type
11hud_window_source_get_type
120
=== removed directory 'docs/man'
=== removed file 'docs/man/Makefile.am'
--- docs/man/Makefile.am 2012-12-03 17:40:45 +0000
+++ docs/man/Makefile.am 1970-01-01 00:00:00 +0000
@@ -1,16 +0,0 @@
1
2man_MANS = \
3 hud-cli.1 \
4 hud-dump-application.1 \
5 hud-list-applications.1 \
6 hud-verify-app-info.1
7
8.xml.1:
9 @env -u XML_CATALOG_FILES $(XSLT_PROC) -nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $<
10
11EXTRA_DIST = \
12 $(man_MANS) \
13 $(man_MANS:.1=.xml)
14
15CLEANFILES = \
16 $(man_MANS)
170
=== removed file 'docs/man/hud-cli.xml'
--- docs/man/hud-cli.xml 2012-12-03 17:40:45 +0000
+++ docs/man/hud-cli.xml 1970-01-01 00:00:00 +0000
@@ -1,38 +0,0 @@
1<refentry id="hud-cli" lang="en">
2
3<refmeta>
4 <refentrytitle>hud-cli</refentrytitle>
5 <manvolnum>1</manvolnum>
6 <refmiscinfo class="manual">User Commands</refmiscinfo>
7</refmeta>
8
9<refnamediv>
10 <refname>hud-cli</refname>
11 <refpurpose>Tool to exercise the HUD on the command line</refpurpose>
12</refnamediv>
13
14<refsynopsisdiv>
15 <cmdsynopsis>
16 <command>hud-cli</command>
17 </cmdsynopsis>
18 <cmdsynopsis>
19 <command>hud-cli</command>
20 <arg choice="plain"><replaceable>search string</replaceable></arg>
21 </cmdsynopsis>
22</refsynopsisdiv>
23
24<refsect1>
25 <title>AUTHOR</title>
26 <para>
27 Written by Ted Gould <email>ted@canonical.com</email> and others.
28 </para>
29</refsect1>
30
31<refsect1>
32 <title>BUGS</title>
33 <para>
34 Bugs should be submitted to Launchpad: <ulink url="https://bugs.launchpad.net/indicator-appmenu/+filebug"/>
35 </para>
36</refsect1>
37
38</refentry>
390
=== removed file 'docs/man/hud-dump-application.xml'
--- docs/man/hud-dump-application.xml 2012-12-03 17:40:45 +0000
+++ docs/man/hud-dump-application.xml 1970-01-01 00:00:00 +0000
@@ -1,45 +0,0 @@
1<refentry id="hud-dump-application" lang="en">
2
3<refmeta>
4 <refentrytitle>hud-dump-application</refentrytitle>
5 <manvolnum>1</manvolnum>
6 <refmiscinfo class="manual">User Commands</refmiscinfo>
7</refmeta>
8
9<refnamediv>
10 <refname>hud-dump-application</refname>
11 <refpurpose>Tool to dump information on an application from the HUD usage database</refpurpose>
12</refnamediv>
13
14<refsynopsisdiv>
15 <cmdsynopsis>
16 <command>hud-dump-application</command>
17 <arg choice="plain"><replaceable>desktop file path</replaceable></arg>
18 </cmdsynopsis>
19</refsynopsisdiv>
20
21<refsect1>
22 <title>AUTHOR</title>
23 <para>
24 Written by Ted Gould <email>ted@canonical.com</email> and others.
25 </para>
26</refsect1>
27
28<refsect1>
29 <title>BUGS</title>
30 <para>
31 Bugs should be submitted to Launchpad: <ulink url="https://bugs.launchpad.net/indicator-appmenu/+filebug"/>
32 </para>
33</refsect1>
34
35<refsect1>
36 <title>SEE ALSO</title>
37 <para>
38 <citerefentry>
39 <refentrytitle>hud-list-applications</refentrytitle>
40 <manvolnum>1</manvolnum>
41 </citerefentry>
42 </para>
43</refsect1>
44
45</refentry>
460
=== removed file 'docs/man/hud-list-applications.xml'
--- docs/man/hud-list-applications.xml 2012-12-03 17:40:45 +0000
+++ docs/man/hud-list-applications.xml 1970-01-01 00:00:00 +0000
@@ -1,44 +0,0 @@
1<refentry id="hud-list-applications" lang="en">
2
3<refmeta>
4 <refentrytitle>hud-list-applications</refentrytitle>
5 <manvolnum>1</manvolnum>
6 <refmiscinfo class="manual">User Commands</refmiscinfo>
7</refmeta>
8
9<refnamediv>
10 <refname>hud-list-applications</refname>
11 <refpurpose>Tool to list the applications in the HUD usage database</refpurpose>
12</refnamediv>
13
14<refsynopsisdiv>
15 <cmdsynopsis>
16 <command>hud-list-applications</command>
17 </cmdsynopsis>
18</refsynopsisdiv>
19
20<refsect1>
21 <title>AUTHOR</title>
22 <para>
23 Written by Ted Gould <email>ted@canonical.com</email> and others.
24 </para>
25</refsect1>
26
27<refsect1>
28 <title>BUGS</title>
29 <para>
30 Bugs should be submitted to Launchpad: <ulink url="https://bugs.launchpad.net/indicator-appmenu/+filebug"/>
31 </para>
32</refsect1>
33
34<refsect1>
35 <title>SEE ALSO</title>
36 <para>
37 <citerefentry>
38 <refentrytitle>hud-dump-application</refentrytitle>
39 <manvolnum>1</manvolnum>
40 </citerefentry>
41 </para>
42</refsect1>
43
44</refentry>
450
=== removed file 'docs/man/hud-verify-app-info.xml'
--- docs/man/hud-verify-app-info.xml 2012-12-03 17:40:45 +0000
+++ docs/man/hud-verify-app-info.xml 1970-01-01 00:00:00 +0000
@@ -1,35 +0,0 @@
1<refentry id="hud-verify-app-info" lang="en">
2
3<refmeta>
4 <refentrytitle>hud-verify-app-info</refentrytitle>
5 <manvolnum>1</manvolnum>
6 <refmiscinfo class="manual">User Commands</refmiscinfo>
7</refmeta>
8
9<refnamediv>
10 <refname>hud-verify-app-info</refname>
11 <refpurpose>Tool to verify an app-info file that is expected to be used in the HUD</refpurpose>
12</refnamediv>
13
14<refsynopsisdiv>
15 <cmdsynopsis>
16 <command>hud-verify-app-info</command>
17 <arg choice="plain"><replaceable>path to app info file</replaceable></arg>
18 </cmdsynopsis>
19</refsynopsisdiv>
20
21<refsect1>
22 <title>AUTHOR</title>
23 <para>
24 Written by Ted Gould <email>ted@canonical.com</email> and others.
25 </para>
26</refsect1>
27
28<refsect1>
29 <title>BUGS</title>
30 <para>
31 Bugs should be submitted to Launchpad: <ulink url="https://bugs.launchpad.net/indicator-appmenu/+filebug"/>
32 </para>
33</refsect1>
34
35</refentry>
360
=== modified file 'po/POTFILES.in'
--- po/POTFILES.in 2012-12-03 17:40:45 +0000
+++ po/POTFILES.in 2013-02-19 17:11:22 +0000
@@ -1,28 +1,6 @@
1data/com.canonical.indicator.appmenu.gschema.xml1data/com.canonical.indicator.appmenu.gschema.xml
2data/com.canonical.indicator.appmenu.hud.gschema.xml
3data/com.canonical.indicator.appmenu.hud.search.gschema.xml
4src/dump-app-info.c
5src/gdk-get-func.c2src/gdk-get-func.c
6src/hudappindicatorsource.c
7src/hudappmenuregistrar.c
8src/hud-cli.c
9src/huddbusmenucollector.c
10src/hud-dump-application.c
11src/hudindicatorsource.c
12src/huditem.c
13src/hudmenumodelcollector.c
14src/hudquery.c
15src/hudresult.c
16src/hud-service.c
17src/hudsource.c
18src/hudsourcelist.c
19src/hudstringlist.c
20src/hudtoken.c
21src/hud-verify-app-info.c
22src/hudwindowsource.c
23src/indicator-appmenu.c3src/indicator-appmenu.c
24src/load-app-info.c
25src/usage-tracker.c
26src/window-menu.c4src/window-menu.c
27src/window-menu-dbusmenu.c5src/window-menu-dbusmenu.c
28src/window-menu-model.c6src/window-menu-model.c
297
=== removed directory 'service'
=== modified file 'src/Makefile.am'
--- src/Makefile.am 2012-12-27 15:50:33 +0000
+++ src/Makefile.am 2013-02-19 17:11:22 +0000
@@ -1,18 +1,7 @@
1CLEANFILES =1CLEANFILES =
2DISTCLEANFILES =2DISTCLEANFILES =
3BUILT_SOURCES =3BUILT_SOURCES =
4EXTRA_DIST = \4EXTRA_DIST =
5 hud-list-applications
6
7bin_PROGRAMS = \
8 hud-dump-application \
9 hud-verify-app-info
10
11bin_SCRIPTS = \
12 hud-list-applications
13
14libexec_PROGRAMS = \
15 hud-service
165
17include $(top_srcdir)/Makefile.am.marshal6include $(top_srcdir)/Makefile.am.marshal
187
@@ -80,173 +69,6 @@
80 gen-application-menu-registrar.xml.c \69 gen-application-menu-registrar.xml.c \
81 gen-application-menu-registrar.xml.h70 gen-application-menu-registrar.xml.h
8271
83####################
84# HUD Service
85####################
86
87noinst_LIBRARIES = libhud-service.a
88
89libhud_service_a_SOURCES = \
90 create-db.h \
91 create-db.c \
92 dump-app-info.h \
93 dump-app-info.c \
94 shared-values.h \
95 hudsettings.h \
96 hudsettings.c \
97 hudappmenuregistrar.h \
98 hudappmenuregistrar.c \
99 huddbusmenucollector.h \
100 huddbusmenucollector.c \
101 hudmenumodelcollector.h \
102 hudmenumodelcollector.c \
103 hudappindicatorsource.h \
104 hudappindicatorsource.c \
105 hudwebappsource.h \
106 hudwebappsource.c \
107 hudindicatorsource.h \
108 hudindicatorsource.c \
109 hudwindowsource.h \
110 hudwindowsource.c \
111 huddebugsource.h \
112 huddebugsource.c \
113 hudsourcelist.h \
114 hudsourcelist.c \
115 hudsource.h \
116 hudsource.c \
117 hudtoken.h \
118 hudtoken.c \
119 hudquery.h \
120 hudquery.c \
121 hudstringlist.h \
122 hudstringlist.c \
123 huditem.h \
124 huditem.c \
125 hudresult.h \
126 hudresult.c \
127 hud.interface.h \
128 hud.interface.c \
129 load-app-info.h \
130 load-app-info.c \
131 usage-tracker.h \
132 usage-tracker.c
133
134hud_service_SOURCES = hud-service.c
135
136libhud_service_a_CFLAGS = \
137 $(HUD_CFLAGS) \
138 $(COVERAGE_CFLAGS) \
139 -DDATADIR=\""$(datadir)"\" \
140 -Wall -Werror
141hud_service_CFLAGS = \
142 $(HUD_CFLAGS) \
143 $(COVERAGE_CFLAGS) \
144 -DDATADIR=\""$(datadir)"\" \
145 -Wall -Werror
146hud_service_LDADD = \
147 libhud-service.a \
148 $(HUD_LIBS)
149hud_service_LDFLAGS = \
150 $(COVERAGE_LDFLAGS)
151
152
153create-db.c: create-db.sql
154 echo "#include \"create-db.h\"" > $@
155 echo -n "const gchar * create_db = \"" >> $@
156 cat $< | xargs printf "%s " >> $@
157 echo -n "\";" >> $@
158
159CLEANFILES += \
160 create-db.c
161
162
163####################
164# HUD CLI
165####################
166
167hud_cli_SOURCES = \
168 shared-values.h \
169 hud-cli.c \
170 hud.interface.h \
171 hud.interface.c
172
173hud_cli_CFLAGS = \
174 $(HUD_CFLAGS) \
175 $(HUD_CLIENT_CFLAGS) \
176 $(COVERAGE_CFLAGS) \
177 -Wall -Werror
178
179hud_cli_LDFLAGS = \
180 $(HUD_LIBS) \
181 $(HUD_CLIENT_LIBS) \
182 $(COVERAGE_LDFLAGS) \
183 -lreadline -lcurses
184
185
186if BUILD_CLI
187bin_PROGRAMS += \
188 hud-cli
189else
190EXTRA_DIST += \
191 $(hud_cli_SOURCES)
192endif
193
194#######################
195# HUD Dump Application
196#######################
197
198hud_dump_application_SOURCES = \
199 dump-app-info.h \
200 dump-app-info.c \
201 hud-dump-application.c
202
203hud_dump_application_CFLAGS = \
204 $(HUD_CFLAGS) \
205 $(COVERAGE_CFLAGS) \
206 -Wall -Werror
207hud_dump_application_LDFLAGS = \
208 $(COVERAGE_LDFLAGS) \
209 $(HUD_LIBS)
210
211#######################
212# HUD Verify App Info
213#######################
214
215hud_verify_app_info_SOURCES = \
216 create-db.h \
217 create-db.c \
218 load-app-info.h \
219 load-app-info.c \
220 hud-verify-app-info.c
221
222hud_verify_app_info_CFLAGS = \
223 $(HUD_CFLAGS) \
224 $(COVERAGE_CFLAGS) \
225 -Wall -Werror
226hud_verify_app_info_LDFLAGS = \
227 $(COVERAGE_LDFLAGS) \
228 $(HUD_LIBS)
229
230####################
231# HUD DBus Interface
232####################
233
234EXTRA_DIST += \
235 hud.xml \
236 create-db.sql
237
238BUILT_SOURCES += \
239 hud.interface.c \
240 hud.interface.h
241
242%.interface.h: %.xml
243 echo "extern const char * $(subst -,_,$(subst .,_,$(basename $(notdir $@))));" > $@
244
245%.interface.c: %.xml
246 echo "const char * $(subst -,_,$(subst .,_,$(basename $(notdir $@)))) = " > $@
247 sed -e "s:\":\\\\\":g" -e s:^:\": -e s:\$$:\\\\n\": $< >> $@
248 echo ";" >> $@
249
250CLEANFILES += $(BUILT_SOURCES)72CLEANFILES += $(BUILT_SOURCES)
25173
252EXTRA_DIST += $(DBUS_SPECS) clean-namespaces.xslt74EXTRA_DIST += $(DBUS_SPECS) clean-namespaces.xslt
25375
=== removed file 'src/create-db.h'
--- src/create-db.h 2012-12-03 17:40:45 +0000
+++ src/create-db.h 1970-01-01 00:00:00 +0000
@@ -1,4 +0,0 @@
1
2#include <glib.h>
3
4extern const gchar * create_db;
50
=== removed file 'src/create-db.sql'
--- src/create-db.sql 2012-12-03 17:40:45 +0000
+++ src/create-db.sql 1970-01-01 00:00:00 +0000
@@ -1,2 +0,0 @@
1create table if not exists usage (application text, entry text, timestamp datetime);
2create index if not exists application_index on usage (application);
30
=== removed file 'src/dump-app-info.c'
--- src/dump-app-info.c 2012-12-03 17:40:45 +0000
+++ src/dump-app-info.c 1970-01-01 00:00:00 +0000
@@ -1,174 +0,0 @@
1/*
2Prints out application info for debugging and CLI tools
3
4Copyright 2011 Canonical Ltd.
5
6Authors:
7 Ted Gould <ted@canonical.com>
8
9This program is free software: you can redistribute it and/or modify it
10under the terms of the GNU General Public License version 3, as published
11by the Free Software Foundation.
12
13This program is distributed in the hope that it will be useful, but
14WITHOUT ANY WARRANTY; without even the implied warranties of
15MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
16PURPOSE. See the GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License along
19with this program. If not, see <http://www.gnu.org/licenses/>.
20*/
21
22#include "dump-app-info.h"
23#include "shared-values.h"
24
25typedef enum _tree_type_t tree_type_t;
26enum _tree_type_t {
27 MENU_TYPE,
28 ITEM_TYPE
29};
30
31typedef struct _menu_t menu_t;
32struct _menu_t {
33 tree_type_t tree_type;
34 gchar * name;
35 int count;
36 GList * subitems;
37};
38
39GList *
40place_on_tree (GList * tree_in, gchar ** entries)
41{
42 menu_t * menu;
43
44 if (entries[0] == NULL) {
45 return tree_in;
46 }
47
48 GList * entry = tree_in;
49 while (entry != NULL) {
50 menu = (menu_t *)entry->data;
51
52 if (g_strcmp0(menu->name, entries[0]) == 0) {
53 break;
54 }
55
56 entry = g_list_next(entry);
57 }
58
59 if (entry != NULL) {
60 if (menu->tree_type == ITEM_TYPE) {
61 if (entries[1] != NULL) {
62 g_warning("Error parsing on entry '%s'", entries[0]);
63 } else {
64 menu->count++;
65 }
66 } else {
67 menu->subitems = place_on_tree(menu->subitems, &entries[1]);
68 }
69
70 return tree_in;
71 }
72
73 menu = g_new0(menu_t, 1);
74 menu->name = g_strdup(entries[0]);
75
76 if (entries[1] == NULL) {
77 /* This is an item */
78 menu->tree_type = ITEM_TYPE;
79 menu->count = 1;
80 menu->subitems = NULL;
81 } else {
82 /* This is a menu */
83 menu->tree_type = MENU_TYPE;
84 menu->subitems = place_on_tree(NULL, &entries[1]);
85 }
86
87 return g_list_append(tree_in, menu);
88}
89
90static int
91entry_cb (void * user_data, int columns, char ** values, char ** names)
92{
93 GList ** tree = (GList **)user_data;
94
95 gchar ** entries = g_strsplit(values[0], DB_SEPARATOR, -1);
96
97 *tree = place_on_tree(*tree, entries);
98
99 g_strfreev(entries);
100
101 return SQLITE_OK;
102}
103
104void
105print_tree (GList * tree, guint tab_depth)
106{
107 if (tree == NULL) {
108 return;
109 }
110
111 int i;
112 for (i = 0; i < tab_depth; i++) {
113 g_print("\t");
114 }
115
116 menu_t * menu = (menu_t *)tree->data;
117
118 if (menu->tree_type == ITEM_TYPE) {
119 g_print("<item name=\"%s\" count=\"%d\" />\n", menu->name, menu->count);
120 } else {
121 g_print("<menu name=\"%s\">\n", menu->name);
122
123 GList * subs = menu->subitems;
124 while (subs != NULL) {
125 print_tree(subs, tab_depth + 1);
126 subs = g_list_next(subs);
127 }
128
129 for (i = 0; i < tab_depth; i++) {
130 g_print("\t");
131 }
132 g_print("</menu>\n");
133 }
134
135 return;
136}
137
138void
139dump_app_info (const gchar * app, const gchar * domain, sqlite3 * db)
140{
141 g_return_if_fail(app != NULL);
142 g_return_if_fail(db != NULL);
143
144 g_print("<hudappinfo>\n");
145
146 g_print("\t<desktopfile path=\"%s\" />\n", app);
147
148 if (domain != NULL) {
149 g_print("\t<gettext-domain>%s</gettext-domain>\n", domain);
150 }
151
152 gchar * statement = g_strdup_printf("select entry from usage where application = '%s';", app);
153
154 int exec_status = SQLITE_OK;
155 gchar * failstring = NULL;
156 GList * tree = NULL;
157 exec_status = sqlite3_exec(db,
158 statement,
159 entry_cb, &tree, &failstring);
160 if (exec_status != SQLITE_OK) {
161 g_warning("Unable to get entries: %s", failstring);
162 }
163
164 g_free(statement);
165
166 if (tree != NULL) {
167 g_print("\t<menus>\n");
168 print_tree(tree, 2);
169 g_print("\t</menus>\n");
170 }
171
172 g_print("</hudappinfo>\n");
173 return;
174}
1750
=== removed file 'src/dump-app-info.h'
--- src/dump-app-info.h 2012-12-03 17:40:45 +0000
+++ src/dump-app-info.h 1970-01-01 00:00:00 +0000
@@ -1,30 +0,0 @@
1/*
2Prints out application info for debugging and CLI tools
3
4Copyright 2011 Canonical Ltd.
5
6Authors:
7 Ted Gould <ted@canonical.com>
8
9This program is free software: you can redistribute it and/or modify it
10under the terms of the GNU General Public License version 3, as published
11by the Free Software Foundation.
12
13This program is distributed in the hope that it will be useful, but
14WITHOUT ANY WARRANTY; without even the implied warranties of
15MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
16PURPOSE. See the GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License along
19with this program. If not, see <http://www.gnu.org/licenses/>.
20*/
21
22#ifndef __DUMP_APP_INFO_H__
23#define __DUMP_APP_INFO_H__
24
25#include <glib.h>
26#include <sqlite3.h>
27
28void dump_app_info (const gchar * app, const gchar * domain, sqlite3 * db);
29
30#endif /* __DUMP_APP_INFO_H__ */
310
=== removed file 'src/hud-cli.c'
--- src/hud-cli.c 2013-01-22 20:39:37 +0000
+++ src/hud-cli.c 1970-01-01 00:00:00 +0000
@@ -1,237 +0,0 @@
1/*
2Small utility to excersise the HUD from the command line
3
4Copyright 2011 Canonical Ltd.
5
6Authors:
7 Ted Gould <ted@canonical.com>
8
9This program is free software: you can redistribute it and/or modify it
10under the terms of the GNU General Public License version 3, as published
11by the Free Software Foundation.
12
13This program is distributed in the hope that it will be useful, but
14WITHOUT ANY WARRANTY; without even the implied warranties of
15MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
16PURPOSE. See the GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License along
19with this program. If not, see <http://www.gnu.org/licenses/>.
20*/
21
22#include <glib.h>
23#include <gio/gunixinputstream.h>
24#include <gtk/gtk.h>
25#include <unistd.h>
26#include <stdio.h>
27#include <readline/readline.h>
28#include <readline/history.h>
29#include <stdlib.h>
30#include <curses.h>
31
32#include "shared-values.h"
33#include "hud.interface.h"
34
35
36static void print_suggestions(const char * query);
37static GDBusProxy * proxy = NULL;
38static GVariant * last_key = NULL;
39static void update(char *string);
40void sighandler(int);
41
42WINDOW *twindow = NULL;
43int use_curses = 0;
44
45int
46main (int argc, char *argv[])
47{
48 int single_char;
49 int pos = 0;
50
51 char *line = (char*) malloc(256 * sizeof(char));
52
53 signal(SIGINT, sighandler);
54
55 GDBusConnection * session = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL);
56 g_return_val_if_fail(session != NULL, 1);
57
58 GDBusNodeInfo * nodeinfo = g_dbus_node_info_new_for_xml(hud_interface, NULL);
59 g_return_val_if_fail(nodeinfo != NULL, 1);
60
61 GDBusInterfaceInfo * ifaceinfo = g_dbus_node_info_lookup_interface(nodeinfo, DBUS_IFACE);
62 g_return_val_if_fail(ifaceinfo != NULL, 1);
63
64 proxy = g_dbus_proxy_new_sync(session,
65 G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
66 ifaceinfo,
67 DBUS_NAME,
68 DBUS_PATH,
69 DBUS_IFACE,
70 NULL, NULL);
71 g_return_val_if_fail(proxy != NULL, 1);
72
73
74 // reading from pipe
75 if (!isatty (STDIN_FILENO) ) {
76 size_t a;
77 int r;
78 r = getline (&line, &a, stdin);
79
80 if ( r == -1 ){
81 perror("Error reading from pipe");
82 exit(EXIT_FAILURE);
83 }
84
85 // get rid of newline
86 if( line[r-1] == '\n' )
87 line[r-1] = '\0';
88
89 printf("\nsearch token: %s\n", line);
90 print_suggestions( line );
91 }
92 // read command line parameter - hud-cli "search string"
93 else if( argc > 1 ){
94 printf("\nsearch token: %s\n", argv[1]);
95 print_suggestions( argv[1] );
96 }
97 // interactive mode
98 else{
99 use_curses = 1;
100
101 twindow = initscr();
102 cbreak();
103 keypad(stdscr, TRUE);
104 noecho();
105
106 /* initialize the query screen */
107 update( "" );
108
109 /* interactive shell interface */
110 while( 1 ){
111
112 single_char = getch();
113 /* need to go left in the buffer */
114 if ( single_char == KEY_BACKSPACE ){
115 /* don't go too far left */
116 if( pos > 0 ){
117 pos--;
118 line[pos] = '\0';
119 update( line );
120 }
121 else
122 ; /* we are at the beginning of the buffer already */
123 }
124 /* ENTER will trigger the action for the first selected suggestion */
125 else if ( single_char == '\n' ){
126
127 /* FIXME: execute action on RETURN */
128 break;
129 }
130 /* add character to the buffer and terminate string */
131 else if ( single_char != KEY_RESIZE ) {
132 if ( pos < 256 -1 ){ // -1 for \0
133 line[pos] = single_char;
134 line[pos+1] = '\0';
135 pos++;
136 update( line );
137 }
138 else {
139
140 }
141 }
142 else{
143 // nothing to do
144 }
145 }
146 endwin();
147 }
148
149 free(line);
150
151 g_dbus_node_info_unref(nodeinfo);
152 g_object_unref(session);
153
154 return 0;
155}
156
157static void
158update( char *string ){
159
160 werase(twindow);
161 mvwprintw(twindow, 7, 10, "Search: %s", string);
162
163 print_suggestions( string );
164
165 // move cursor back to input line
166 wmove( twindow, 7, 10 + 8 + strlen(string) );
167
168 refresh();
169}
170
171
172static void
173print_suggestions (const char *query)
174{
175 GError * error = NULL;
176 GVariantBuilder querybuilder;
177 g_variant_builder_init(&querybuilder, G_VARIANT_TYPE_TUPLE);
178 g_variant_builder_add_value(&querybuilder, g_variant_new_string(query));
179 g_variant_builder_add_value(&querybuilder, g_variant_new_int32(5));
180
181 GVariant * suggests = g_dbus_proxy_call_sync(proxy,
182 "StartQuery",
183 g_variant_builder_end(&querybuilder),
184 G_DBUS_CALL_FLAGS_NONE,
185 -1,
186 NULL,
187 &error);
188
189 if (error != NULL) {
190 g_warning("Unable to get suggestions: %s", error->message);
191 g_error_free(error);
192 return ;
193 }
194
195 GVariant * target = g_variant_get_child_value(suggests, 0);
196 g_variant_unref(target);
197
198 GVariant * suggestions = g_variant_get_child_value(suggests, 1);
199 GVariantIter iter;
200 g_variant_iter_init(&iter, suggestions);
201 gchar * suggestion = NULL;
202 gchar * appicon = NULL;
203 gchar * icon = NULL;
204 gchar * complete = NULL;
205 gchar * accel = NULL;
206 GVariant * key = NULL;
207
208 last_key = NULL;
209
210 int i=0;
211 char *clean_line;
212
213 while (g_variant_iter_loop(&iter, "(sssssv)", &suggestion, &appicon, &icon, &complete, &accel, &key)) {
214 if( use_curses)
215 mvwprintw(twindow, 9 + i, 15, "%s", suggestion);
216 else{
217 pango_parse_markup(suggestion, -1, 0, NULL, &clean_line, NULL, NULL);
218 printf("\t%s\n", clean_line);
219 free(clean_line);
220 }
221 i++;
222
223 }
224
225 g_variant_unref(suggestions);
226
227 /* NOTE: Ignoring the Query Key as we're not handling the signal now
228 and just letting it timeout. */
229
230 return;
231}
232
233void sighandler(int signal){
234 endwin();
235 g_object_unref(proxy);
236 exit(EXIT_SUCCESS);
237}
2380
=== removed file 'src/hud-dump-application.c'
--- src/hud-dump-application.c 2012-12-03 17:40:45 +0000
+++ src/hud-dump-application.c 1970-01-01 00:00:00 +0000
@@ -1,73 +0,0 @@
1/*
2Small utility to dump application info in the HUD usage DB
3
4Copyright 2011 Canonical Ltd.
5
6Authors:
7 Ted Gould <ted@canonical.com>
8
9This program is free software: you can redistribute it and/or modify it
10under the terms of the GNU General Public License version 3, as published
11by the Free Software Foundation.
12
13This program is distributed in the hope that it will be useful, but
14WITHOUT ANY WARRANTY; without even the implied warranties of
15MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
16PURPOSE. See the GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License along
19with this program. If not, see <http://www.gnu.org/licenses/>.
20*/
21
22#include <glib.h>
23#include "dump-app-info.h"
24
25int
26main (int argv, char * argc[])
27{
28 if (argv != 2 && argv != 3) {
29 g_printerr("Usage: %s <desktop file path> [gettext domain]\n", argc[0]);
30 return 1;
31 }
32
33 const gchar * basecachedir = g_getenv("HUD_CACHE_DIR");
34 if (basecachedir == NULL) {
35 basecachedir = g_get_user_cache_dir();
36 }
37
38 gchar * cachedir = g_build_filename(basecachedir, "indicator-appmenu", NULL);
39 if (!g_file_test(cachedir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
40 g_warning("Cache directory '%s' doesn't exist", cachedir);
41 return 1;
42 }
43 g_free(cachedir);
44
45 gchar * cachefile = g_build_filename(basecachedir, "indicator-appmenu", "hud-usage-log.sqlite", NULL);
46 gboolean db_exists = g_file_test(cachefile, G_FILE_TEST_EXISTS);
47
48 if (!db_exists) {
49 g_warning("There is no HUD usage log: %s", cachefile);
50 return 1;
51 }
52
53 sqlite3 * db;
54 int open_status = sqlite3_open(cachefile, &db);
55
56 if (open_status != SQLITE_OK) {
57 g_warning("Error opening usage DB: %s", cachefile);
58 sqlite3_close(db);
59 return 1;
60 }
61
62 gchar * domain = NULL;
63 if (argv == 3) {
64 domain = argc[2];
65 }
66
67 dump_app_info(argc[1], domain, db);
68
69 sqlite3_close(db);
70 g_free(cachefile);
71
72 return 0;
73}
740
=== removed file 'src/hud-list-applications'
--- src/hud-list-applications 2012-12-03 17:40:45 +0000
+++ src/hud-list-applications 1970-01-01 00:00:00 +0000
@@ -1,11 +0,0 @@
1#!/bin/sh
2
3if [ -n $HUD_CACHE_DIR ]; then
4 HUD_CACHE_DIR=~/.cache
5fi;
6
7FINAL_DIR="$HUD_CACHE_DIR/indicator-appmenu"
8
9if test -e $FINAL_DIR/hud-usage-log.sqlite; then
10 sqlite3 $FINAL_DIR/hud-usage-log.sqlite "select distinct application from usage"
11fi
120
=== removed file 'src/hud-service.c'
--- src/hud-service.c 2013-01-22 20:39:37 +0000
+++ src/hud-service.c 1970-01-01 00:00:00 +0000
@@ -1,335 +0,0 @@
1/*
2 * Copyright © 2012 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Author: Ryan Lortie <desrt@desrt.ca>
17 */
18
19#define G_LOG_DOMAIN "hud-service"
20
21#include "config.h"
22
23#include <glib.h>
24#include <gio/gio.h>
25#include <stdlib.h>
26#include <locale.h>
27#include <libintl.h>
28
29#include "hudappindicatorsource.h"
30#include "hudindicatorsource.h"
31#include "hudwebappsource.h"
32#include "hudwindowsource.h"
33#include "huddebugsource.h"
34#include "hudsourcelist.h"
35#include "hudsettings.h"
36
37#include "hud.interface.h"
38#include "shared-values.h"
39#include "hudquery.h"
40
41/* The return value of 'StartQuery' and the signal parameters for
42 * 'UpdatedQuery' are the same, so use a utility function for both.
43 */
44GVariant *
45describe_query (HudQuery *query)
46{
47 GVariantBuilder builder;
48 gint n, i;
49
50 n = hud_query_get_n_results (query);
51
52 g_variant_builder_init (&builder, G_VARIANT_TYPE ("(sa(sssssv)v)"));
53
54 /* Target */
55 g_variant_builder_add (&builder, "s", "");
56
57 /* List of results */
58 g_variant_builder_open (&builder, G_VARIANT_TYPE ("a(sssssv)"));
59 for (i = 0; i < n; i++)
60 {
61 HudResult *result = hud_query_get_result_by_index (query, i);
62 HudItem *item;
63
64 item = hud_result_get_item (result);
65
66 g_variant_builder_add (&builder, "(sssssv)",
67 hud_result_get_html_description (result),
68 hud_item_get_app_icon (item),
69 hud_item_get_item_icon (item),
70 "" /* complete text */ , "" /* accel */,
71 g_variant_new_uint64 (hud_item_get_id (item)));
72 }
73 g_variant_builder_close (&builder);
74
75 /* Query key */
76 g_variant_builder_add (&builder, "v", hud_query_get_query_key (query));
77
78 return g_variant_builder_end (&builder);
79}
80
81static void
82query_changed (HudQuery *query,
83 gpointer user_data)
84{
85 GDBusConnection *connection = user_data;
86
87 g_debug ("emit UpdatedQuery signal");
88
89 g_dbus_connection_emit_signal (connection, NULL, DBUS_PATH,
90 DBUS_IFACE, "UpdatedQuery",
91 describe_query (query), NULL);
92}
93
94static GVariant *
95unpack_platform_data (GVariant *parameters)
96{
97 GVariant *platform_data;
98 gchar *startup_id;
99 guint32 timestamp;
100
101 g_variant_get_child (parameters, 1, "u", &timestamp);
102 startup_id = g_strdup_printf ("_TIME%u", timestamp);
103 platform_data = g_variant_new_parsed ("{'desktop-startup-id': < %s >}", startup_id);
104 g_free (startup_id);
105
106 return g_variant_ref_sink (platform_data);
107}
108
109static gboolean
110drop_query_timeout (gpointer user_data)
111{
112 g_object_unref (user_data);
113
114 return G_SOURCE_REMOVE;
115}
116
117static void
118bus_method (GDBusConnection *connection,
119 const gchar *sender,
120 const gchar *object_path,
121 const gchar *interface_name,
122 const gchar *method_name,
123 GVariant *parameters,
124 GDBusMethodInvocation *invocation,
125 gpointer user_data)
126{
127 HudSource *source = user_data;
128
129 if (g_str_equal (method_name, "StartQuery"))
130 {
131 const gchar *search_string;
132 gint num_results;
133 HudQuery *query;
134
135 g_variant_get (parameters, "(&si)", &search_string, &num_results);
136 g_debug ("'StartQuery' from %s: '%s', %d", sender, search_string, num_results);
137 query = hud_query_new (source, search_string, num_results);
138 g_signal_connect_object (query, "changed", G_CALLBACK (query_changed), connection, 0);
139 g_dbus_method_invocation_return_value (invocation, describe_query (query));
140 g_object_unref (query);
141 }
142
143 else if (g_str_equal (method_name, "ExecuteQuery"))
144 {
145 GVariant *platform_data;
146 GVariant *item_key;
147 guint64 key_value;
148 HudItem *item;
149
150 g_variant_get_child (parameters, 0, "v", &item_key);
151
152 if (!g_variant_is_of_type (item_key, G_VARIANT_TYPE_UINT64))
153 {
154 g_debug ("'ExecuteQuery' from %s: incorrect item key (not uint64)", sender);
155 g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
156 "item key has invalid format");
157 g_variant_unref (item_key);
158 return;
159 }
160
161 key_value = g_variant_get_uint64 (item_key);
162 g_variant_unref (item_key);
163
164 item = hud_item_lookup (key_value);
165 g_debug ("'ExecuteQuery' from %s, item #%"G_GUINT64_FORMAT": %p", sender, key_value, item);
166
167 if (item == NULL)
168 {
169 g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
170 "item specified by item key does not exist");
171 return;
172 }
173
174 platform_data = unpack_platform_data (parameters);
175 hud_item_activate (item, platform_data);
176 g_variant_unref (platform_data);
177
178 g_dbus_method_invocation_return_value (invocation, NULL);
179 }
180
181 else if (g_str_equal (method_name, "CloseQuery"))
182 {
183 GVariant *query_key;
184 HudQuery *query;
185
186 g_debug ("Got 'CloseQuery' from %s", sender);
187
188 g_variant_get (parameters, "(v)", &query_key);
189 query = hud_query_lookup (query_key);
190 g_variant_unref (query_key);
191
192 if (query != NULL)
193 {
194 g_signal_handlers_disconnect_by_func (query, query_changed, connection);
195 /* Unity does 'CloseQuery' immediately followed by
196 * 'StartQuery' on every keystroke. Delay the destruction of
197 * the query for a moment just in case a 'StartQuery' is on the
198 * way.
199 *
200 * That way we can avoid allowing the use count to drop to
201 * zero only to be increased again back to 1. This prevents a
202 * bunch of dbusmenu "closed"/"opened" calls being sent.
203 */
204 g_timeout_add (1000, drop_query_timeout, g_object_ref (query));
205 hud_query_close (query);
206 }
207
208 /* always success -- they may have just been closing a timed out query */
209 g_dbus_method_invocation_return_value (invocation, NULL);
210 }
211}
212
213static GMainLoop *mainloop = NULL;
214
215static GDBusInterfaceInfo *
216get_iface_info (void)
217{
218 GDBusInterfaceInfo *iface_info;
219 GDBusNodeInfo *node_info;
220 GError *error = NULL;
221
222 node_info = g_dbus_node_info_new_for_xml (hud_interface, &error);
223 g_assert_no_error (error);
224
225 iface_info = g_dbus_node_info_lookup_interface (node_info, DBUS_IFACE);
226 g_assert (iface_info != NULL);
227
228 g_dbus_interface_info_ref (iface_info);
229 g_dbus_node_info_unref (node_info);
230
231 return iface_info;
232}
233
234static void
235bus_acquired_cb (GDBusConnection *connection,
236 const gchar *name,
237 gpointer user_data)
238{
239 HudSource *source = user_data;
240 GDBusInterfaceVTable vtable = {
241 bus_method
242 };
243 GError *error = NULL;
244
245 g_debug ("Bus acquired (guid %s)", g_dbus_connection_get_guid (connection));
246
247 if (!g_dbus_connection_register_object (connection, DBUS_PATH, get_iface_info (), &vtable, source, NULL, &error))
248 {
249 g_warning ("Unable to register path '"DBUS_PATH"': %s", error->message);
250 g_main_loop_quit (mainloop);
251 g_error_free (error);
252 }
253}
254
255static void
256name_acquired_cb (GDBusConnection *connection,
257 const gchar *name,
258 gpointer user_data)
259{
260 g_debug ("Acquired bus name '%s'", name);
261}
262
263static void
264name_lost_cb (GDBusConnection *connection,
265 const gchar *name,
266 gpointer user_data)
267{
268 g_warning ("Unable to get name '%s'", name);
269 g_main_loop_quit (mainloop);
270}
271
272int
273main (int argc, char **argv)
274{
275 HudWindowSource *window_source;
276 HudSourceList *source_list;
277
278 setlocale (LC_ALL, "");
279 bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
280 textdomain (GETTEXT_PACKAGE);
281
282 hud_settings_init ();
283
284 source_list = hud_source_list_new ();
285
286 /* we will eventually pull GtkMenu out of this, so keep it around */
287 window_source = hud_window_source_new ();
288 hud_source_list_add (source_list, HUD_SOURCE (window_source));
289
290 {
291 HudIndicatorSource *source;
292
293 source = hud_indicator_source_new ();
294 hud_source_list_add (source_list, HUD_SOURCE (source));
295 g_object_unref (source);
296 }
297
298 {
299 HudAppIndicatorSource *source;
300
301 source = hud_app_indicator_source_new ();
302 hud_source_list_add (source_list, HUD_SOURCE (source));
303 g_object_unref (source);
304 }
305
306 {
307 HudWebappSource *source;
308
309 source = hud_webapp_source_new (window_source);
310 hud_source_list_add (source_list, HUD_SOURCE (source));
311
312 g_object_unref (G_OBJECT (source));
313 }
314
315 if (getenv ("HUD_DEBUG_SOURCE"))
316 {
317 HudDebugSource *source;
318
319 source = hud_debug_source_new ();
320 hud_source_list_add (source_list, HUD_SOURCE (source));
321 g_object_unref (source);
322 }
323
324 g_bus_own_name (G_BUS_TYPE_SESSION, DBUS_NAME, G_BUS_NAME_OWNER_FLAGS_NONE,
325 bus_acquired_cb, name_acquired_cb, name_lost_cb, source_list, NULL);
326
327 mainloop = g_main_loop_new (NULL, FALSE);
328 g_main_loop_run (mainloop);
329 g_main_loop_unref (mainloop);
330
331 g_object_unref (window_source);
332 g_object_unref (source_list);
333
334 return 0;
335}
3360
=== removed file 'src/hud-verify-app-info.c'
--- src/hud-verify-app-info.c 2013-01-22 20:39:37 +0000
+++ src/hud-verify-app-info.c 1970-01-01 00:00:00 +0000
@@ -1,100 +0,0 @@
1/*
2Verify the validity of the App Info file to make sure it parses
3
4Copyright 2011 Canonical Ltd.
5
6Authors:
7 Ted Gould <ted@canonical.com>
8
9This program is free software: you can redistribute it and/or modify it
10under the terms of the GNU General Public License version 3, as published
11by the Free Software Foundation.
12
13This program is distributed in the hope that it will be useful, but
14WITHOUT ANY WARRANTY; without even the implied warranties of
15MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
16PURPOSE. See the GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License along
19with this program. If not, see <http://www.gnu.org/licenses/>.
20*/
21
22#include <unistd.h>
23#include <glib-object.h>
24#include <glib/gstdio.h>
25#include "load-app-info.h"
26#include "create-db.h"
27
28static void
29build_db (sqlite3 * db)
30{
31 /* Create the table */
32 int exec_status = SQLITE_OK;
33 gchar * failstring = NULL;
34 exec_status = sqlite3_exec(db,
35 create_db,
36 NULL, NULL, &failstring);
37 if (exec_status != SQLITE_OK) {
38 g_warning("Unable to create table: %s", failstring);
39 }
40
41 /* Import data from the system */
42
43 return;
44}
45
46int
47main (int argv, char * argc[])
48{
49 gboolean passed = TRUE;
50
51 if (argv != 2) {
52 g_printerr("Usage: %s <app-info file path>\n", argc[0]);
53 return 1;
54 }
55
56 gchar * filename = NULL;
57 gint tmpfile = g_file_open_tmp("hud-verify-app-info-temp-db-XXXXXX", &filename, NULL);
58
59 if (tmpfile < 0) {
60 passed = FALSE;
61 } else {
62
63 close(tmpfile);
64 /* NOTE: there is a small security bug here in that we're closing the
65 file and reopening it, so the temp isn't really guaranteed to be
66 safe. But, I don't think we're really worried about security in this
67 utility. */
68
69 sqlite3 * db = NULL;
70 int open_status = sqlite3_open(filename, &db);
71
72 if (open_status != SQLITE_OK) {
73 g_warning("Error opening usage DB: %s", filename);
74 passed = FALSE;
75 } else {
76
77 /* Create the table in the DB */
78 build_db(db);
79
80 passed = load_app_info(argc[1], db);
81
82 sqlite3_close(db);
83 }
84 }
85
86 if (filename != NULL) {
87 if (g_getenv("HUD_VERIFY_NO_UNLINK") == NULL) {
88 g_unlink(filename);
89 } else {
90 g_print("Temp db '%s' not deleted\n", filename);
91 }
92 g_free(filename);
93 }
94
95 if (passed) {
96 return 0;
97 } else {
98 return 1;
99 }
100}
1010
=== removed file 'src/hud.xml'
--- src/hud.xml 2012-12-03 17:40:45 +0000
+++ src/hud.xml 1970-01-01 00:00:00 +0000
@@ -1,37 +0,0 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<node name="/">
3 <interface name="com.canonical.hud">
4<!-- Properties -->
5 <!-- None -->
6
7<!-- Functions -->
8 <method name="StartQuery">
9 <!-- in -->
10 <arg type="s" name="query" direction="in" />
11 <arg type="i" name="entries" direction="in" />
12 <!-- out -->
13 <arg type="s" name="target" direction="out" />
14 <arg type="a(sssssv)" name="suggestions" direction="out" />
15 <arg type="v" name="querykey" direction="out" />
16 </method>
17
18 <method name="ExecuteQuery">
19 <arg type="v" name="key" direction="in" />
20 <arg type="u" name="timestamp" direction="in" />
21 </method>
22
23 <method name="CloseQuery">
24 <arg type="v" name="querykey" direction="in" />
25 </method>
26
27<!-- Signals -->
28 <signal name="UpdatedQuery">
29 <arg type="s" name="target" direction="out" />
30 <arg type="a(sssssv)" name="suggestions" direction="out" />
31 <arg type="v" name="querykey" direction="out" />
32 </signal>
33
34<!-- End of interesting stuff -->
35
36 </interface>
37</node>
380
=== removed file 'src/hudappindicatorsource.c'
--- src/hudappindicatorsource.c 2012-12-03 17:40:45 +0000
+++ src/hudappindicatorsource.c 1970-01-01 00:00:00 +0000
@@ -1,432 +0,0 @@
1/*
2 * Copyright © 2012 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors: Ryan Lortie <desrt@desrt.ca>
17 * Ted Gould <ted@canonical.com>
18 */
19
20#define G_LOG_DOMAIN "hudappindicatorsource"
21
22#include "hudappindicatorsource.h"
23
24#include <glib/gi18n.h>
25#include <gio/gio.h>
26
27#include "hudsettings.h"
28#include "huddbusmenucollector.h"
29#include "hudsource.h"
30
31/**
32 * SECTION:hudappindicatorsource
33 * @title: HudAppIndicatorSource
34 * @short_description: a #HudSource to search through the application
35 * indicators
36 *
37 * #HudAppIndicatorSource searches through the menus of application
38 * indicators.
39 **/
40
41/**
42 * HudAppIndicatorSource:
43 *
44 * This is an opaque structure type.
45 **/
46
47#define APP_INDICATOR_SERVICE_BUS_NAME "com.canonical.indicator.application"
48#define APP_INDICATOR_SERVICE_OBJECT_PATH "/com/canonical/indicator/application/service"
49#define APP_INDICATOR_SERVICE_IFACE "com.canonical.indicator.application.service"
50
51struct _HudAppIndicatorSource
52{
53 GObject parent_instance;
54
55 GSequence *indicators;
56 guint subscription;
57 GCancellable *cancellable;
58 gint use_count;
59 gboolean ready;
60};
61
62typedef GObjectClass HudAppIndicatorSourceClass;
63
64static void hud_app_indicator_source_iface_init (HudSourceInterface *iface);
65G_DEFINE_TYPE_WITH_CODE (HudAppIndicatorSource, hud_app_indicator_source, G_TYPE_OBJECT,
66 G_IMPLEMENT_INTERFACE (HUD_TYPE_SOURCE, hud_app_indicator_source_iface_init))
67
68static void
69hud_app_indicator_source_collector_changed (HudSource *collector,
70 gpointer user_data)
71{
72 HudAppIndicatorSource *source = user_data;
73
74 hud_source_changed (HUD_SOURCE (source));
75}
76
77static void
78hud_app_indicator_source_add_indicator (HudAppIndicatorSource *source,
79 GVariant *description)
80{
81 HudDbusmenuCollector *collector;
82 const gchar *dbus_name;
83 const gchar *dbus_path;
84 GSequenceIter *iter;
85 const gchar *id;
86 const gchar *icon_name;
87 gint32 position;
88 gchar *title;
89
90 g_variant_get_child (description, 0, "&s", &icon_name);
91 g_variant_get_child (description, 1, "i", &position);
92 g_variant_get_child (description, 2, "&s", &dbus_name);
93 g_variant_get_child (description, 3, "&o", &dbus_path);
94 g_variant_get_child (description, 8, "&s", &id);
95 g_variant_get_child (description, 9, "s", &title);
96
97 if (title[0] == '\0')
98 {
99 g_free (title);
100 /* TRANSLATORS: This is used for Application indicators that
101 are not providing a title string. The '%s' represents the
102 unique ID that the app indicator provides, but it is usually
103 the package name and not generally human readable. An example
104 for Network Manager would be 'nm-applet'. */
105 title = g_strdup_printf(_("Untitled Indicator (%s)"), id);
106 }
107 g_debug ("adding appindicator %s at %d ('%s', %s, %s, %s)", id, position, title, icon_name, dbus_name, dbus_path);
108
109 collector = hud_dbusmenu_collector_new_for_endpoint (id, title, icon_name,
110 hud_settings.indicator_penalty,
111 dbus_name, dbus_path);
112 g_signal_connect (collector, "changed", G_CALLBACK (hud_app_indicator_source_collector_changed), source);
113
114 /* If query is active, mark new app indicator as used. */
115 if (source->use_count)
116 hud_source_use (HUD_SOURCE (collector));
117
118 iter = g_sequence_get_iter_at_pos (source->indicators, position);
119 g_sequence_insert_before (iter, collector);
120 g_free (title);
121}
122
123static void
124hud_app_indicator_source_remove_indicator (HudAppIndicatorSource *source,
125 GVariant *description)
126{
127 GSequenceIter *iter;
128 gint32 position;
129
130 g_variant_get_child (description, 0, "i", &position);
131
132 g_debug ("removing appindicator at %d", position);
133
134 iter = g_sequence_get_iter_at_pos (source->indicators, position);
135 if (!g_sequence_iter_is_end (iter))
136 {
137 HudDbusmenuCollector *collector;
138
139 collector = g_sequence_get (iter);
140 g_signal_handlers_disconnect_by_func (collector, hud_app_indicator_source_collector_changed, source);
141 /* Drop use count if we added one... */
142 if (source->use_count)
143 hud_source_unuse (HUD_SOURCE (collector));
144 g_sequence_remove (iter);
145 }
146}
147
148static void
149hud_app_indicator_source_dbus_signal (GDBusConnection *connection,
150 const gchar *sender_name,
151 const gchar *object_path,
152 const gchar *interface_name,
153 const gchar *signal_name,
154 GVariant *parameters,
155 gpointer user_data)
156{
157 HudAppIndicatorSource *source = user_data;
158
159 g_debug ("got signal");
160
161 if (!source->ready)
162 {
163 g_debug ("not ready, so ignoring signal");
164 return;
165 }
166
167 if (g_str_equal (signal_name, "ApplicationAdded"))
168 {
169 if (!g_variant_is_of_type (parameters, G_VARIANT_TYPE ("(sisossssss)")))
170 return;
171
172 hud_app_indicator_source_add_indicator (source, parameters);
173 hud_source_changed (HUD_SOURCE (source));
174 }
175
176 else if (g_str_equal (signal_name, "ApplicationRemoved"))
177 {
178 if (!g_variant_is_of_type (parameters, G_VARIANT_TYPE ("(i)")))
179 return;
180
181 hud_app_indicator_source_remove_indicator (source, parameters);
182 hud_source_changed (HUD_SOURCE (source));
183 }
184
185 else if (g_str_equal (signal_name, "ApplicationTitleChanged"))
186 {
187 GSequenceIter *iter;
188 const gchar *title;
189 gint32 position;
190
191 if (!g_variant_is_of_type (parameters, G_VARIANT_TYPE ("(is)")))
192 return;
193
194 g_variant_get (parameters, "(i&s)", &position, &title);
195
196 g_debug ("changing title of appindicator at %d to '%s'", position, title);
197
198 iter = g_sequence_get_iter_at_pos (source->indicators, position);
199 if (!g_sequence_iter_is_end (iter))
200 {
201 HudDbusmenuCollector *collector;
202
203 collector = g_sequence_get (iter);
204 hud_dbusmenu_collector_set_prefix (collector, title);
205 }
206 }
207
208 else if (g_str_equal (signal_name, "ApplicationIconChanged"))
209 {
210 GSequenceIter *iter;
211 const gchar *icon;
212 gint32 position;
213
214 if (!g_variant_is_of_type (parameters, G_VARIANT_TYPE ("(iss)")))
215 return;
216
217 g_variant_get (parameters, "(i&ss)", &position, &icon, NULL);
218
219 g_debug ("changing icon of appindicator at %d to '%s'", position, icon);
220
221 iter = g_sequence_get_iter_at_pos (source->indicators, position);
222 if (!g_sequence_iter_is_end (iter))
223 {
224 HudDbusmenuCollector *collector;
225
226 collector = g_sequence_get (iter);
227 hud_dbusmenu_collector_set_icon (collector, icon);
228 }
229 }
230}
231
232static void
233hud_app_indicator_source_ready (GObject *connection,
234 GAsyncResult *result,
235 gpointer user_data)
236{
237 HudAppIndicatorSource *source = user_data;
238 GError *error = NULL;
239 GVariant *reply;
240
241 g_debug ("GetApplications returned");
242
243 g_clear_object (&source->cancellable);
244
245 reply = g_dbus_connection_call_finish (G_DBUS_CONNECTION (connection), result, &error);
246
247 if (reply)
248 {
249 GVariant *description;
250 GVariantIter *iter;
251
252 g_assert (!source->ready);
253 source->ready = TRUE;
254
255 g_debug ("going ready");
256
257 g_variant_get (reply, "(a(sisossssss))", &iter);
258 while ((description = g_variant_iter_next_value (iter)))
259 {
260 hud_app_indicator_source_add_indicator (source, description);
261 g_variant_unref (description);
262 }
263 g_variant_iter_free (iter);
264 g_variant_unref (reply);
265
266 hud_source_changed (HUD_SOURCE (source));
267 }
268 else
269 {
270 g_warning ("GetApplications returned an error: %s", error->message);
271 g_error_free (error);
272 }
273
274 g_object_unref (source);
275
276 g_debug ("done handling GetApplications reply");
277}
278
279static void
280hud_app_indicator_source_name_appeared (GDBusConnection *connection,
281 const gchar *name,
282 const gchar *name_owner,
283 gpointer user_data)
284{
285 HudAppIndicatorSource *source = user_data;
286
287 g_debug ("name appeared (owner is %s)", name_owner);
288
289 g_assert (source->subscription == 0);
290 source->subscription = g_dbus_connection_signal_subscribe (connection, name_owner,
291 APP_INDICATOR_SERVICE_IFACE, NULL,
292 APP_INDICATOR_SERVICE_OBJECT_PATH, NULL,
293 G_DBUS_SIGNAL_FLAGS_NONE,
294 hud_app_indicator_source_dbus_signal,
295 source, NULL);
296
297 g_assert (source->cancellable == NULL);
298 source->cancellable = g_cancellable_new ();
299 g_dbus_connection_call (connection, name_owner, APP_INDICATOR_SERVICE_OBJECT_PATH, APP_INDICATOR_SERVICE_IFACE,
300 "GetApplications", NULL, G_VARIANT_TYPE ("(a(sisossssss))"),
301 G_DBUS_CALL_FLAGS_NONE, -1, source->cancellable,
302 hud_app_indicator_source_ready, g_object_ref (source));
303}
304
305static void
306hud_app_indicator_source_name_vanished (GDBusConnection *connection,
307 const gchar *name,
308 gpointer user_data)
309{
310 HudAppIndicatorSource *source = user_data;
311
312 g_debug ("name vanished");
313
314 if (source->subscription > 0)
315 {
316 g_dbus_connection_signal_unsubscribe (connection, source->subscription);
317 source->subscription = 0;
318 }
319
320 if (source->cancellable)
321 {
322 g_cancellable_cancel (source->cancellable);
323 g_clear_object (&source->cancellable);
324 }
325
326 if (source->ready)
327 {
328 GSequenceIter *iter;
329
330 source->ready = FALSE;
331
332 iter = g_sequence_get_begin_iter (source->indicators);
333 while (!g_sequence_iter_is_end (iter))
334 {
335 HudDbusmenuCollector *collector;
336 GSequenceIter *next;
337
338 collector = g_sequence_get (iter);
339 g_signal_handlers_disconnect_by_func (collector, hud_app_indicator_source_collector_changed, source);
340 next = g_sequence_iter_next (iter);
341 g_sequence_remove (iter);
342 iter = next;
343 }
344
345 hud_source_changed (HUD_SOURCE (source));
346 }
347}
348
349static void
350hud_app_indicator_source_use (HudSource *hud_source)
351{
352 HudAppIndicatorSource *source = HUD_APP_INDICATOR_SOURCE (hud_source);
353
354 if (source->use_count == 0)
355 g_sequence_foreach (source->indicators, (GFunc) hud_source_use, NULL);
356
357 source->use_count++;
358}
359
360static void
361hud_app_indicator_source_unuse (HudSource *hud_source)
362{
363 HudAppIndicatorSource *source = HUD_APP_INDICATOR_SOURCE (hud_source);
364
365 g_return_if_fail (source->use_count > 0);
366
367 source->use_count--;
368
369 if (source->use_count == 0)
370 g_sequence_foreach (source->indicators, (GFunc) hud_source_unuse, NULL);
371}
372
373static void
374hud_app_indicator_source_search (HudSource *hud_source,
375 GPtrArray *results_array,
376 HudTokenList *search_tokens)
377{
378 HudAppIndicatorSource *source = HUD_APP_INDICATOR_SOURCE (hud_source);
379 GSequenceIter *iter;
380
381 iter = g_sequence_get_begin_iter (source->indicators);
382
383 while (!g_sequence_iter_is_end (iter))
384 {
385 hud_source_search (g_sequence_get (iter), results_array, search_tokens);
386 iter = g_sequence_iter_next (iter);
387 }
388}
389
390static void
391hud_app_indicator_source_finalize (GObject *object)
392{
393 g_assert_not_reached ();
394}
395
396static void
397hud_app_indicator_source_init (HudAppIndicatorSource *source)
398{
399 g_debug ("online");
400
401 source->indicators = g_sequence_new (g_object_unref);
402 g_bus_watch_name (G_BUS_TYPE_SESSION, APP_INDICATOR_SERVICE_BUS_NAME, G_BUS_NAME_WATCHER_FLAGS_NONE,
403 hud_app_indicator_source_name_appeared, hud_app_indicator_source_name_vanished,
404 g_object_ref (source), g_object_unref);
405}
406
407static void
408hud_app_indicator_source_iface_init (HudSourceInterface *iface)
409{
410 iface->use = hud_app_indicator_source_use;
411 iface->unuse = hud_app_indicator_source_unuse;
412 iface->search = hud_app_indicator_source_search;
413}
414
415static void
416hud_app_indicator_source_class_init (HudAppIndicatorSourceClass *class)
417{
418 class->finalize = hud_app_indicator_source_finalize;
419}
420
421/**
422 * hud_app_indicator_source_new:
423 *
424 * Creates a #HudAppIndicatorSource.
425 *
426 * Returns: a new #HudAppIndicatorSource
427 **/
428HudAppIndicatorSource *
429hud_app_indicator_source_new (void)
430{
431 return g_object_new (HUD_TYPE_APP_INDICATOR_SOURCE, NULL);
432}
4330
=== removed file 'src/hudappindicatorsource.h'
--- src/hudappindicatorsource.h 2012-12-03 17:40:45 +0000
+++ src/hudappindicatorsource.h 1970-01-01 00:00:00 +0000
@@ -1,36 +0,0 @@
1/*
2 * Copyright © 2012 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Author: Ryan Lortie <desrt@desrt.ca>
17 */
18
19#ifndef __HUD_APP_INDICATOR_SOURCE_H__
20#define __HUD_APP_INDICATOR_SOURCE_H__
21
22#include <glib-object.h>
23
24#define HUD_TYPE_APP_INDICATOR_SOURCE (hud_app_indicator_source_get_type ())
25#define HUD_APP_INDICATOR_SOURCE(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \
26 HUD_TYPE_APP_INDICATOR_SOURCE, HudAppIndicatorSource))
27#define HUD_IS_APP_INDICATOR_SOURCE(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \
28 HUD_TYPE_APP_INDICATOR_SOURCE))
29
30typedef struct _HudAppIndicatorSource HudAppIndicatorSource;
31
32GType hud_app_indicator_source_get_type (void);
33
34HudAppIndicatorSource * hud_app_indicator_source_new (void);
35
36#endif /* __HUD_APP_INDICATOR_SOURCE_H__ */
370
=== removed file 'src/hudappmenuregistrar.c'
--- src/hudappmenuregistrar.c 2012-12-03 17:40:45 +0000
+++ src/hudappmenuregistrar.c 1970-01-01 00:00:00 +0000
@@ -1,507 +0,0 @@
1/*
2 * Copyright © 2012 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Author: Ryan Lortie <desrt@desrt.ca>
17 */
18
19#define G_LOG_DOMAIN "hudappmenuregistrar"
20
21#include "hudappmenuregistrar.h"
22
23#include <gio/gio.h>
24
25/**
26 * SECTION:hudappmenuregistrar
27 * @title: HudAppMenuRegistrar
28 * @short_description: client for the com.canonical.AppMenu.Registrar
29 * D-Bus service
30 *
31 * The #HudAppMenuRegistrar is a singleton object that monitors the
32 * com.canonical.AppMenu.Registrar D-Bus service.
33 *
34 * On instantiation, a D-Bus name watch is setup for the registrar.
35 * When the registrar is found to exist, a local copy is made of the
36 * windows and menus that the registrar knows about. Change
37 * notifications are also monitored to keep the local cache in sync.
38 *
39 * After that point, all queries for information from the registrar are
40 * satisfied from the local cache, without blocking.
41 *
42 * Information is acquired from #HudAppMenuRegistrar by using
43 * hud_app_menu_registrar_add_observer(). This immediately calls a
44 * callback with the initial information and makes future calls to the
45 * same callback if the information is found to have changed.
46 *
47 * If the registrar is offline or the information is not yet available
48 * at the time of the original query, the window will initially be
49 * reported as having no menu but a change notification will arrive when
50 * the proper information becomes available.
51 **/
52
53/**
54 * HudAppMenuRegistrar:
55 *
56 * This is an opaque structure type.
57 **/
58
59#define APPMENU_REGISTRAR_BUS_NAME "com.canonical.AppMenu.Registrar"
60#define APPMENU_REGISTRAR_OBJECT_PATH "/com/canonical/AppMenu/Registrar"
61#define APPMENU_REGISTRAR_IFACE "com.canonical.AppMenu.Registrar"
62
63typedef struct
64{
65 HudAppMenuRegistrarObserverFunc callback;
66 gpointer user_data;
67} HudAppMenuRegistrarObserver;
68
69typedef struct
70{
71 guint xid;
72 gchar *bus_name;
73 gchar *object_path;
74 GSList *observers;
75} HudAppMenuRegistrarWindow;
76
77struct _HudAppMenuRegistrar
78{
79 GObject parent_instance;
80
81 guint subscription;
82 GCancellable *cancellable;
83 GHashTable *windows;
84 gboolean notifying;
85 gboolean ready;
86};
87
88typedef GObjectClass HudAppMenuRegistrarClass;
89
90G_DEFINE_TYPE (HudAppMenuRegistrar, hud_app_menu_registrar, G_TYPE_OBJECT)
91
92static void
93hud_app_menu_registrar_window_free (gpointer user_data)
94{
95 HudAppMenuRegistrarWindow *window = user_data;
96
97 g_assert (window->bus_name == NULL);
98 g_assert (window->object_path == NULL);
99 g_assert (window->observers == NULL);
100
101 g_debug ("free window instance for %u", window->xid);
102
103 g_slice_free (HudAppMenuRegistrarWindow, window);
104}
105
106static HudAppMenuRegistrarWindow *
107hud_app_menu_registrar_get_window (HudAppMenuRegistrar *registrar,
108 guint xid)
109{
110 HudAppMenuRegistrarWindow *window;
111
112 window = g_hash_table_lookup (registrar->windows, GINT_TO_POINTER (xid));
113
114 if (!window)
115 {
116 window = g_slice_new0 (HudAppMenuRegistrarWindow);
117 window->xid = xid;
118
119 g_debug ("create window instance for %u", xid);
120 g_hash_table_insert (registrar->windows, GINT_TO_POINTER (xid), window);
121 }
122
123 return window;
124}
125
126static void
127hud_app_menu_registrar_possibly_free_window (HudAppMenuRegistrar *registrar,
128 HudAppMenuRegistrarWindow *window)
129{
130 if (window->bus_name == NULL && window->observers == NULL)
131 g_hash_table_remove (registrar->windows, GINT_TO_POINTER (window->xid));
132}
133
134static void
135hud_app_menu_registrar_notify_window_observers (HudAppMenuRegistrar *registrar,
136 HudAppMenuRegistrarWindow *window)
137{
138 GSList *node;
139
140 registrar->notifying = TRUE;
141
142 for (node = window->observers; node; node = node->next)
143 {
144 HudAppMenuRegistrarObserver *observer = node->data;
145
146 g_debug ("notifying %p about %u", observer->user_data, window->xid);
147 (* observer->callback) (registrar, window->xid, window->bus_name, window->object_path, observer->user_data);
148 }
149
150 registrar->notifying = FALSE;
151}
152
153static void
154hud_app_menu_registrar_dbus_signal (GDBusConnection *connection,
155 const gchar *sender_name,
156 const gchar *object_path,
157 const gchar *interface_name,
158 const gchar *signal_name,
159 GVariant *parameters,
160 gpointer user_data)
161{
162 HudAppMenuRegistrar *registrar = user_data;
163
164 g_debug ("got signal");
165
166 if (!registrar->ready)
167 {
168 g_debug ("not ready, so ignoring signal");
169 return;
170 }
171
172 if (g_str_equal (signal_name, "WindowRegistered"))
173 {
174 HudAppMenuRegistrarWindow *window;
175 guint xid;
176
177 if (!g_variant_is_of_type (parameters, G_VARIANT_TYPE ("(uso)")))
178 return;
179
180 g_variant_get_child (parameters, 0, "u", &xid);
181 window = hud_app_menu_registrar_get_window (registrar, xid);
182
183 g_free (window->bus_name);
184 g_variant_get_child (parameters, 1, "s", &window->bus_name);
185 g_free (window->object_path);
186 g_variant_get_child (parameters, 2, "o", &window->object_path);
187
188 g_debug ("xid %u is now at (%s, %s)", xid, window->bus_name, window->object_path);
189
190 hud_app_menu_registrar_notify_window_observers (registrar, window);
191 }
192
193 else if (g_str_equal (signal_name, "WindowUnregistered"))
194 {
195 HudAppMenuRegistrarWindow *window;
196 guint xid;
197
198 if (!g_variant_is_of_type (parameters, G_VARIANT_TYPE ("(u)")))
199 return;
200
201 g_variant_get (parameters, 0, "u", &xid);
202
203 g_debug ("xid %u disappeared", xid);
204
205 window = hud_app_menu_registrar_get_window (registrar, xid);
206
207 g_free (window->bus_name);
208 window->bus_name = NULL;
209 g_free (window->object_path);
210 window->object_path = NULL;
211
212 hud_app_menu_registrar_notify_window_observers (registrar, window);
213
214 hud_app_menu_registrar_possibly_free_window (registrar, window);
215 }
216}
217
218static void
219hud_app_menu_registrar_ready (GObject *source,
220 GAsyncResult *result,
221 gpointer user_data)
222{
223 HudAppMenuRegistrar *registrar = user_data;
224 GError *error = NULL;
225 GVariant *reply;
226
227 g_debug ("GetMenus returned");
228
229 g_clear_object (&registrar->cancellable);
230
231 reply = g_dbus_connection_call_finish (G_DBUS_CONNECTION (source), result, &error);
232
233 if (reply)
234 {
235 GVariantIter *iter;
236 const gchar *bus_name;
237 const gchar *object_path;
238 guint xid;
239
240 g_assert (!registrar->ready);
241 registrar->ready = TRUE;
242
243 g_debug ("going ready");
244
245 g_variant_get (reply, "(a(uso))", &iter);
246
247 while (g_variant_iter_next (iter, "(u&s&o)", &xid, &bus_name, &object_path))
248 {
249 HudAppMenuRegistrarWindow *window;
250
251 window = hud_app_menu_registrar_get_window (registrar, xid);
252
253 /* we were not ready until now, so we expect this to be unset */
254 g_assert (window->bus_name == NULL);
255
256 window->bus_name = g_strdup (bus_name);
257 window->object_path = g_strdup (object_path);
258
259 hud_app_menu_registrar_notify_window_observers (registrar, window);
260 }
261
262 g_variant_iter_free (iter);
263 g_variant_unref (reply);
264 }
265 else
266 {
267 g_warning ("GetMenus returned an error: %s", error->message);
268 g_error_free (error);
269 }
270
271 g_object_unref (registrar);
272
273 g_debug ("done handling GetMenus reply");
274}
275
276static void
277hud_app_menu_registrar_name_appeared (GDBusConnection *connection,
278 const gchar *name,
279 const gchar *name_owner,
280 gpointer user_data)
281{
282 HudAppMenuRegistrar *registrar = user_data;
283
284 g_debug ("name appeared (owner is %s)", name_owner);
285
286 g_assert (registrar->subscription == 0);
287 registrar->subscription = g_dbus_connection_signal_subscribe (connection, name_owner,
288 APPMENU_REGISTRAR_IFACE, NULL,
289 APPMENU_REGISTRAR_OBJECT_PATH, NULL,
290 G_DBUS_SIGNAL_FLAGS_NONE,
291 hud_app_menu_registrar_dbus_signal,
292 registrar, NULL);
293
294 g_assert (registrar->cancellable == NULL);
295 registrar->cancellable = g_cancellable_new ();
296 g_dbus_connection_call (connection, name_owner, APPMENU_REGISTRAR_OBJECT_PATH,
297 APPMENU_REGISTRAR_IFACE, "GetMenus", NULL, G_VARIANT_TYPE ("(a(uso))"),
298 G_DBUS_CALL_FLAGS_NONE, -1, registrar->cancellable,
299 hud_app_menu_registrar_ready, g_object_ref (registrar));
300}
301
302static void
303hud_app_menu_registrar_name_vanished (GDBusConnection *connection,
304 const gchar *name,
305 gpointer user_data)
306{
307 HudAppMenuRegistrar *registrar = user_data;
308
309 g_debug ("name vanished");
310
311 if (registrar->subscription > 0)
312 {
313 g_dbus_connection_signal_unsubscribe (connection, registrar->subscription);
314 registrar->subscription = 0;
315 }
316
317 if (registrar->cancellable)
318 {
319 g_cancellable_cancel (registrar->cancellable);
320 g_clear_object (&registrar->cancellable);
321 }
322
323 if (registrar->ready)
324 {
325 GHashTableIter iter;
326 gpointer value;
327
328 registrar->ready = FALSE;
329
330 g_hash_table_iter_init (&iter, registrar->windows);
331 while (g_hash_table_iter_next (&iter, NULL, &value))
332 {
333 HudAppMenuRegistrarWindow *window = value;
334
335 g_free (window->bus_name);
336 window->bus_name = NULL;
337 g_free (window->object_path);
338 window->object_path = NULL;
339
340 hud_app_menu_registrar_notify_window_observers (registrar, window);
341
342 /* Cannot go the normal route here because we are iterating... */
343 if (window->observers == NULL)
344 g_hash_table_iter_remove (&iter);
345 }
346 }
347}
348
349static void
350hud_app_menu_registrar_finalize (GObject *object)
351{
352 /* This is an immortal singleton. If we're here, we have trouble. */
353 g_assert_not_reached ();
354}
355
356static void
357hud_app_menu_registrar_init (HudAppMenuRegistrar *registrar)
358{
359 g_debug ("online");
360
361 registrar->windows = g_hash_table_new_full (NULL, NULL, NULL, hud_app_menu_registrar_window_free);
362 g_bus_watch_name (G_BUS_TYPE_SESSION, APPMENU_REGISTRAR_BUS_NAME, G_BUS_NAME_WATCHER_FLAGS_NONE,
363 hud_app_menu_registrar_name_appeared, hud_app_menu_registrar_name_vanished,
364 g_object_ref (registrar), g_object_unref);
365}
366
367static void
368hud_app_menu_registrar_class_init (HudAppMenuRegistrarClass *class)
369{
370 class->finalize = hud_app_menu_registrar_finalize;
371}
372
373/**
374 * HudAppMenuRegistrarObserverFunc:
375 * @registrar: the #HudAppMenuRegistrar
376 * @xid: the xid that we are notifying about
377 * @bus_name: the bus name for the dbusmenu, or %NULL
378 * @object_path: the object path for the dbusmenu, or %NULL
379 * @user_data: the data pointer
380 *
381 * Notifies about the initial values for or changes to the bus name and
382 * object path at which to find the dbusmenu for @xid.
383 *
384 * You should pass the values of @bus_name and @object_path to
385 * dbusmenu_client_new() to get started.
386 *
387 * If no menu is available then @bus_name and @object_path will both be
388 * given as %NULL.
389 **/
390
391/**
392 * hud_app_menu_registrar_add_observer:
393 * @registrar: the #HudAppMenuRegistrar
394 * @xid: the xid to begin observing
395 * @callback: a #HudAppMenuRegistrarObserverFunc
396 * @user_data: user data for @callback
397 *
398 * Begins observing @xid.
399 *
400 * @callback will be called exactly once before the function returns
401 * with a set of initial values (the bus name and object path at which
402 * to find the menu for the window).
403 *
404 * If the location of the menu for @xid changes (including being created
405 * or destroyed) then @callback will be called each time an update is
406 * required.
407 *
408 * It is possible that the values are not initially known because they
409 * have not yet been retreived from the registrar or because the
410 * registrar is not running. In this case, %NULL values will be
411 * provided initially and @callback will be invoked again when the
412 * real values are known.
413 *
414 * Call hud_app_menu_registrar_remove_observer() to when you are no
415 * longer interested in @xid.
416 **/
417void
418hud_app_menu_registrar_add_observer (HudAppMenuRegistrar *registrar,
419 guint xid,
420 HudAppMenuRegistrarObserverFunc callback,
421 gpointer user_data)
422{
423 HudAppMenuRegistrarObserver *observer;
424 HudAppMenuRegistrarWindow *window;
425
426 g_return_if_fail (xid != 0);
427 g_return_if_fail (callback != NULL);
428 g_return_if_fail (!registrar->notifying);
429
430 g_debug ("observer added for xid %u (%p)", xid, user_data);
431
432 observer = g_slice_new (HudAppMenuRegistrarObserver);
433 observer->callback = callback;
434 observer->user_data = user_data;
435
436 window = hud_app_menu_registrar_get_window (registrar, xid);
437 window->observers = g_slist_prepend (window->observers, observer);
438
439 /* send the first update */
440 (* callback) (registrar, xid, window->bus_name, window->object_path, user_data);
441}
442
443/**
444 * hud_app_menu_registrar_remove_observer:
445 * @registrar: the #HudAppMenuRegistrar
446 * @xid: the xid to begin observing
447 * @callback: a #HudAppMenuRegistrarObserverFunc
448 * @user_data: user data for @callback
449 *
450 * Reverses the effect of a previous call to
451 * hud_app_menu_registrar_add_observer().
452 *
453 * @callback and @user_data must be exactly equal to the values passed
454 * to that function.
455 *
456 * One call does not remove all instances of @callback and @user_data.
457 * You need to call this function the same number of times that you
458 * called hud_app_menu_registrar_add_observer().
459 **/
460void
461hud_app_menu_registrar_remove_observer (HudAppMenuRegistrar *registrar,
462 guint xid,
463 HudAppMenuRegistrarObserverFunc callback,
464 gpointer user_data)
465{
466 HudAppMenuRegistrarWindow *window;
467 GSList **node;
468
469 g_return_if_fail (xid != 0);
470 g_return_if_fail (callback != NULL);
471 g_return_if_fail (!registrar->notifying);
472
473 g_debug ("observer removed for xid %u (%p)", xid, user_data);
474
475 window = hud_app_menu_registrar_get_window (registrar, xid);
476 for (node = &window->observers; *node; node = &(*node)->next)
477 {
478 HudAppMenuRegistrarObserver *observer = (*node)->data;
479
480 if (observer->callback == callback && observer->user_data == user_data)
481 {
482 g_slice_free (HudAppMenuRegistrarObserver, observer);
483 *node = g_slist_delete_link (*node, *node);
484 break;
485 }
486 }
487
488 hud_app_menu_registrar_possibly_free_window (registrar, window);
489}
490
491/**
492 * hud_app_menu_registrar_get:
493 *
494 * Gets the singleton instance of #HudAppMenuRegistrar.
495 *
496 * Returns: (transfer none): the instance
497 **/
498HudAppMenuRegistrar *
499hud_app_menu_registrar_get (void)
500{
501 static HudAppMenuRegistrar *singleton;
502
503 if (!singleton)
504 singleton = g_object_new (HUD_TYPE_APP_MENU_REGISTRAR, NULL);
505
506 return singleton;
507}
5080
=== removed file 'src/hudappmenuregistrar.h'
--- src/hudappmenuregistrar.h 2012-12-03 17:40:45 +0000
+++ src/hudappmenuregistrar.h 1970-01-01 00:00:00 +0000
@@ -1,53 +0,0 @@
1/*
2 * Copyright © 2012 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Author: Ryan Lortie <desrt@desrt.ca>
17 */
18
19#ifndef __HUD_APP_MENU_REGISTRAR_H__
20#define __HUD_APP_MENU_REGISTRAR_H__
21
22#include <glib-object.h>
23
24#define HUD_TYPE_APP_MENU_REGISTRAR (hud_app_menu_registrar_get_type ())
25#define HUD_APP_MENU_REGISTRAR(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \
26 HUD_TYPE_APP_MENU_REGISTRAR, \
27 HudAppMenuRegistrar))
28#define HUD_IS_APP_MENU_REGISTRAR(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \
29 HUD_TYPE_APP_MENU_REGISTRAR))
30
31typedef struct _HudAppMenuRegistrar HudAppMenuRegistrar;
32
33GType hud_app_menu_registrar_get_type (void);
34
35HudAppMenuRegistrar * hud_app_menu_registrar_get (void);
36
37typedef void (* HudAppMenuRegistrarObserverFunc) (HudAppMenuRegistrar *registrar,
38 guint xid,
39 const gchar *bus_name,
40 const gchar *object_path,
41 gpointer user_data);
42
43void hud_app_menu_registrar_add_observer (HudAppMenuRegistrar *registrar,
44 guint xid,
45 HudAppMenuRegistrarObserverFunc callback,
46 gpointer user_data);
47
48void hud_app_menu_registrar_remove_observer (HudAppMenuRegistrar *registrar,
49 guint xid,
50 HudAppMenuRegistrarObserverFunc callback,
51 gpointer user_data);
52
53#endif /* __HUD_APP_MENU_REGISTRAR_H__ */
540
=== removed file 'src/huddbusmenucollector.c'
--- src/huddbusmenucollector.c 2012-12-03 17:40:45 +0000
+++ src/huddbusmenucollector.c 1970-01-01 00:00:00 +0000
@@ -1,679 +0,0 @@
1/*
2 * Copyright © 2012 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors: Ryan Lortie <desrt@desrt.ca>
17 * Ted Gould <ted@canonical.com>
18 */
19
20#define G_LOG_DOMAIN "huddbusmenucollector"
21
22#include "huddbusmenucollector.h"
23
24#include <libdbusmenu-glib/client.h>
25#include <string.h>
26
27#include "hudappmenuregistrar.h"
28#include "hudresult.h"
29#include "hudsource.h"
30
31/**
32 * SECTION:huddbusmenucollector
33 * @title: HudDbusmenuCollector
34 * @short_description: a #HudSource that collects #HudItems from
35 * Dbusmenu
36 *
37 * The #HudDbusmenuCollector collects menu items from a #DbusmenuClient.
38 *
39 * There are two modes of operation.
40 *
41 * In the simple mode, the collector is created with a specified
42 * endpoint using hud_dbusmenu_collector_new_for_endpoint(). A
43 * #DbusmenuClient is constructed using this endpoint and the collector
44 * constructs #HudItems for the contents of the menu found there. This
45 * mode is intended for use with indicators.
46 *
47 * For menus associated with application windows (ie: menubars), we must
48 * consult the AppMenu registrar in order to discover the endpoint to
49 * use. This second mode of the collector is used by calling
50 * hud_dbusmenu_collector_new_for_window().
51 **/
52
53/**
54 * HudDbusmenuCollector:
55 *
56 * This is an opaque structure type.
57 **/
58
59typedef struct
60{
61 HudItem parent_instance;
62
63 DbusmenuMenuitem *menuitem;
64 gboolean is_opened;
65} HudDbusmenuItem;
66
67typedef HudItemClass HudDbusmenuItemClass;
68
69G_DEFINE_TYPE (HudDbusmenuItem, hud_dbusmenu_item, HUD_TYPE_ITEM)
70
71static void
72hud_dbusmenu_item_activate (HudItem *hud_item,
73 GVariant *platform_data)
74{
75 HudDbusmenuItem *item = (HudDbusmenuItem *) hud_item;
76 const gchar *startup_id;
77 guint32 timestamp = 0;
78
79 if (g_variant_lookup (platform_data, "desktop-startup-id", "&s", &startup_id))
80 {
81 const gchar *time_tag;
82
83 if ((time_tag = strstr (startup_id, "_TIME")))
84 {
85 gint64 result;
86
87 result = g_ascii_strtoll (time_tag + 5, NULL, 10);
88
89 if (0 <= result && result <= G_MAXINT32)
90 timestamp = result;
91 }
92 }
93
94 dbusmenu_menuitem_handle_event(item->menuitem, DBUSMENU_MENUITEM_EVENT_ACTIVATED, NULL, timestamp);
95}
96
97static void
98hud_dbusmenu_item_finalize (GObject *object)
99{
100 HudDbusmenuItem *item = (HudDbusmenuItem *) object;
101
102 g_object_unref (item->menuitem);
103
104 G_OBJECT_CLASS (hud_dbusmenu_item_parent_class)
105 ->finalize (object);
106}
107
108static void
109hud_dbusmenu_item_init (HudDbusmenuItem *item)
110{
111}
112
113static void
114hud_dbusmenu_item_class_init (HudDbusmenuItemClass *class)
115{
116 GObjectClass *gobject_class = G_OBJECT_CLASS (class);
117
118 gobject_class->finalize = hud_dbusmenu_item_finalize;
119 class->activate = hud_dbusmenu_item_activate;
120}
121
122static const gchar *
123hud_dbusmenu_item_get_label_property (const gchar *type)
124{
125 static const gchar * const property_table[][2] =
126 {
127 { DBUSMENU_CLIENT_TYPES_DEFAULT, DBUSMENU_MENUITEM_PROP_LABEL },
128 /* Indicator Messages */
129 { "application-item", DBUSMENU_MENUITEM_PROP_LABEL },
130 { "indicator-item", "indicator-label" },
131 /* Indicator Datetime */
132 { "appointment-item", "appointment-label" },
133 { "timezone-item", "timezone-name" },
134 /* Indicator Sound */
135 { "x-canonical-sound-menu-player-metadata-type", "x-canonical-sound-menu-player-metadata-player-name" },
136 { "x-canonical-sound-menu-mute-type", DBUSMENU_MENUITEM_PROP_LABEL },
137 /* Indicator User */
138 { "x-canonical-user-item", "user-item-name" }
139 };
140 static GHashTable *property_hash;
141
142 if G_UNLIKELY (property_hash == NULL)
143 {
144 gint i;
145
146 property_hash = g_hash_table_new (g_str_hash, g_str_equal);
147
148 for (i = 0; i < G_N_ELEMENTS (property_table); i++)
149 g_hash_table_insert (property_hash, (gpointer) property_table[i][0], (gpointer) property_table[i][1]);
150 }
151
152 if (type == NULL)
153 return DBUSMENU_MENUITEM_PROP_LABEL;
154
155 return g_hash_table_lookup (property_hash, type);
156}
157
158
159static HudDbusmenuItem *
160hud_dbusmenu_item_new (HudStringList *context,
161 const gchar *desktop_file,
162 const gchar *icon,
163 DbusmenuMenuitem *menuitem)
164{
165 HudStringList *tokens;
166 HudDbusmenuItem *item;
167 const gchar *type;
168 const gchar *prop;
169 gboolean enabled;
170
171 type = dbusmenu_menuitem_property_get (menuitem, DBUSMENU_MENUITEM_PROP_TYPE);
172 prop = hud_dbusmenu_item_get_label_property (type);
173
174 if (prop && dbusmenu_menuitem_property_exist (menuitem, prop))
175 {
176 const gchar *label;
177
178 label = dbusmenu_menuitem_property_get (menuitem, prop);
179 tokens = hud_string_list_cons_label (label, context);
180 enabled = TRUE;
181 }
182 else
183 {
184 tokens = hud_string_list_ref (context);
185 enabled = FALSE;
186 }
187
188 if (enabled)
189 enabled &= !dbusmenu_menuitem_property_exist (menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE) ||
190 dbusmenu_menuitem_property_get_bool (menuitem, DBUSMENU_MENUITEM_PROP_VISIBLE);
191
192 if (enabled)
193 enabled &= !dbusmenu_menuitem_property_exist (menuitem, DBUSMENU_MENUITEM_PROP_ENABLED) ||
194 dbusmenu_menuitem_property_get_bool (menuitem, DBUSMENU_MENUITEM_PROP_ENABLED);
195
196 if (enabled)
197 enabled &= !dbusmenu_menuitem_property_exist (menuitem, DBUSMENU_MENUITEM_PROP_CHILD_DISPLAY);
198
199 item = hud_item_construct (hud_dbusmenu_item_get_type (), tokens, desktop_file, icon, enabled);
200 item->menuitem = g_object_ref (menuitem);
201
202 hud_string_list_unref (tokens);
203
204 return item;
205}
206
207struct _HudDbusmenuCollector
208{
209 GObject parent_instance;
210
211 DbusmenuClient *client;
212 DbusmenuMenuitem *root;
213 gchar *application_id;
214 HudStringList *prefix;
215 gchar *icon;
216 GHashTable *items;
217 guint penalty;
218 guint xid;
219 gboolean alive;
220 gint use_count;
221 gboolean reentrance_check;
222};
223
224typedef GObjectClass HudDbusmenuCollectorClass;
225
226static void hud_dbusmenu_collector_iface_init (HudSourceInterface *iface);
227G_DEFINE_TYPE_WITH_CODE (HudDbusmenuCollector, hud_dbusmenu_collector, G_TYPE_OBJECT,
228 G_IMPLEMENT_INTERFACE (HUD_TYPE_SOURCE, hud_dbusmenu_collector_iface_init))
229
230static void
231hud_dbusmenu_collector_open_submenu (gpointer key,
232 gpointer value,
233 gpointer user_data)
234{
235 DbusmenuMenuitem *menuitem = key;
236 HudDbusmenuItem *item = value;
237
238 if (dbusmenu_menuitem_property_exist (menuitem, DBUSMENU_MENUITEM_PROP_CHILD_DISPLAY))
239 {
240 dbusmenu_menuitem_handle_event (menuitem, DBUSMENU_MENUITEM_EVENT_OPENED, NULL, 0);
241 item->is_opened = TRUE;
242 }
243}
244
245static void
246hud_dbusmenu_collector_close_submenu (gpointer key,
247 gpointer value,
248 gpointer user_data)
249{
250 DbusmenuMenuitem *menuitem = key;
251 HudDbusmenuItem *item = value;
252
253 if (item->is_opened)
254 {
255 dbusmenu_menuitem_handle_event (menuitem, DBUSMENU_MENUITEM_EVENT_CLOSED, NULL, 0);
256 item->is_opened = FALSE;
257 }
258}
259
260static void
261hud_dbusmenu_collector_use (HudSource *source)
262{
263 HudDbusmenuCollector *collector = HUD_DBUSMENU_COLLECTOR (source);
264
265 collector->reentrance_check = TRUE;
266
267 if (collector->use_count == 0)
268 g_hash_table_foreach (collector->items, hud_dbusmenu_collector_open_submenu, NULL);
269
270 collector->use_count++;
271
272 collector->reentrance_check = FALSE;
273}
274
275static void
276hud_dbusmenu_collector_unuse (HudSource *source)
277{
278 HudDbusmenuCollector *collector = HUD_DBUSMENU_COLLECTOR (source);
279
280 g_return_if_fail (collector->use_count > 0);
281
282 collector->reentrance_check = TRUE;
283
284 collector->use_count--;
285
286 if (collector->use_count == 0)
287 g_hash_table_foreach (collector->items, hud_dbusmenu_collector_close_submenu, NULL);
288
289 collector->reentrance_check = FALSE;
290}
291
292static void
293hud_dbusmenu_collector_search (HudSource *source,
294 GPtrArray *results_array,
295 HudTokenList *search_string)
296{
297 HudDbusmenuCollector *collector = HUD_DBUSMENU_COLLECTOR (source);
298 GHashTableIter iter;
299 gpointer item;
300
301 g_hash_table_iter_init (&iter, collector->items);
302 while (g_hash_table_iter_next (&iter, NULL, &item))
303 {
304 HudResult *result;
305
306 result = hud_result_get_if_matched (item, search_string, collector->penalty);
307 if (result)
308 g_ptr_array_add (results_array, result);
309 }
310}
311
312static void
313hud_dbusmenu_collector_add_item (HudDbusmenuCollector *collector,
314 HudStringList *context,
315 DbusmenuMenuitem *menuitem);
316static void
317hud_dbusmenu_collector_remove_item (HudDbusmenuCollector *collector,
318 DbusmenuMenuitem *menuitem);
319
320static void
321hud_dbusmenu_collector_child_added (DbusmenuMenuitem *menuitem,
322 DbusmenuMenuitem *child,
323 guint position,
324 gpointer user_data)
325{
326 HudDbusmenuCollector *collector = user_data;
327 HudStringList *context;
328 HudItem *item;
329
330 g_assert (!collector->reentrance_check);
331
332 item = g_hash_table_lookup (collector->items, menuitem);
333 g_assert (item != NULL);
334
335 context = hud_item_get_tokens (item);
336
337 hud_dbusmenu_collector_add_item (collector, context, child);
338}
339
340static void
341hud_dbusmenu_collector_child_removed (DbusmenuMenuitem *menuitem,
342 DbusmenuMenuitem *child,
343 gpointer user_data)
344{
345 HudDbusmenuCollector *collector = user_data;
346
347 g_assert (!collector->reentrance_check);
348
349 hud_dbusmenu_collector_remove_item (collector, child);
350}
351
352static void
353hud_dbusmenu_collector_property_changed (DbusmenuMenuitem *menuitem,
354 const gchar *property_name,
355 GVariant *new_value,
356 gpointer user_data)
357{
358 HudDbusmenuCollector *collector = user_data;
359 DbusmenuMenuitem *parent;
360 HudStringList *context;
361 HudDbusmenuItem *item;
362 gboolean was_open;
363
364 g_assert (!collector->reentrance_check);
365
366 parent = dbusmenu_menuitem_get_parent (menuitem);
367
368 if (parent)
369 {
370 HudItem *parentitem;
371
372 parentitem = g_hash_table_lookup (collector->items, parent);
373 context = hud_item_get_tokens (parentitem);
374 }
375 else
376 context = collector->prefix;
377
378 item = g_hash_table_lookup (collector->items, menuitem);
379 was_open = item->is_opened;
380 g_hash_table_remove (collector->items, menuitem);
381
382 item = hud_dbusmenu_item_new (context, collector->application_id, collector->icon, menuitem);
383
384 if (collector->use_count && !was_open && dbusmenu_menuitem_property_exist (menuitem, DBUSMENU_MENUITEM_PROP_CHILD_DISPLAY))
385 {
386 dbusmenu_menuitem_handle_event (menuitem, DBUSMENU_MENUITEM_EVENT_OPENED, NULL, 0);
387 item->is_opened = TRUE;
388 }
389
390 g_hash_table_insert (collector->items, menuitem, item);
391
392 hud_source_changed (HUD_SOURCE (collector));
393}
394
395static void
396hud_dbusmenu_collector_add_item (HudDbusmenuCollector *collector,
397 HudStringList *context,
398 DbusmenuMenuitem *menuitem)
399{
400 HudDbusmenuItem *item;
401 GList *child;
402
403 item = hud_dbusmenu_item_new (context, collector->application_id, collector->icon, menuitem);
404 context = hud_item_get_tokens (HUD_ITEM (item));
405
406 g_signal_connect (menuitem, "property-changed", G_CALLBACK (hud_dbusmenu_collector_property_changed), collector);
407 g_signal_connect (menuitem, "child-added", G_CALLBACK (hud_dbusmenu_collector_child_added), collector);
408 g_signal_connect (menuitem, "child-removed", G_CALLBACK (hud_dbusmenu_collector_child_removed), collector);
409
410 /* If we're actively being queried and we add a new submenu item, open it. */
411 if (collector->use_count && dbusmenu_menuitem_property_exist (menuitem, DBUSMENU_MENUITEM_PROP_CHILD_DISPLAY))
412 {
413 dbusmenu_menuitem_handle_event (menuitem, DBUSMENU_MENUITEM_EVENT_OPENED, NULL, 0);
414 item->is_opened = TRUE;
415 }
416
417 g_hash_table_insert (collector->items, menuitem, item);
418
419 for (child = dbusmenu_menuitem_get_children (menuitem); child; child = child->next)
420 hud_dbusmenu_collector_add_item (collector, context, child->data);
421
422 if (collector->alive)
423 hud_source_changed (HUD_SOURCE (collector));
424}
425
426static void
427hud_dbusmenu_collector_remove_item (HudDbusmenuCollector *collector,
428 DbusmenuMenuitem *menuitem)
429{
430 GList *child;
431
432 g_signal_handlers_disconnect_by_func (menuitem, hud_dbusmenu_collector_property_changed, collector);
433 g_signal_handlers_disconnect_by_func (menuitem, hud_dbusmenu_collector_child_added, collector);
434 g_signal_handlers_disconnect_by_func (menuitem, hud_dbusmenu_collector_child_removed, collector);
435 g_hash_table_remove (collector->items, menuitem);
436
437 for (child = dbusmenu_menuitem_get_children (menuitem); child; child = child->next)
438 hud_dbusmenu_collector_remove_item (collector, child->data);
439
440 if (collector->alive)
441 hud_source_changed (HUD_SOURCE (collector));
442}
443
444static void
445hud_dbusmenu_collector_setup_root (HudDbusmenuCollector *collector,
446 DbusmenuMenuitem *root)
447{
448 if (collector->root)
449 {
450 /* If the collector has the submenus opened, close them before we
451 * remove them all. The use_count being non-zero will cause them
452 * to be reopened as they are added back below (if they will be).
453 */
454 if (collector->use_count > 0)
455 g_hash_table_foreach (collector->items, hud_dbusmenu_collector_close_submenu, NULL);
456
457 hud_dbusmenu_collector_remove_item (collector, collector->root);
458 g_clear_object (&collector->root);
459 }
460
461 if (root)
462 {
463 hud_dbusmenu_collector_add_item (collector, collector->prefix, root);
464 collector->root = g_object_ref (root);
465 }
466}
467
468static void
469hud_dbusmenu_collector_root_changed (DbusmenuClient *client,
470 DbusmenuMenuitem *root,
471 gpointer user_data)
472{
473 HudDbusmenuCollector *collector = user_data;
474
475 g_assert (!collector->reentrance_check);
476
477 hud_dbusmenu_collector_setup_root (collector, root);
478}
479
480static void
481hud_dbusmenu_collector_setup_endpoint (HudDbusmenuCollector *collector,
482 const gchar *bus_name,
483 const gchar *object_path)
484{
485 g_debug ("endpoint is %s %s", bus_name, object_path);
486
487 if (collector->client)
488 {
489 g_signal_handlers_disconnect_by_func (collector->client, hud_dbusmenu_collector_root_changed, collector);
490 hud_dbusmenu_collector_setup_root (collector, NULL);
491 g_clear_object (&collector->client);
492 }
493
494 if (bus_name && object_path)
495 {
496 collector->client = dbusmenu_client_new (bus_name, object_path);
497 g_signal_connect_object (collector->client, "root-changed",
498 G_CALLBACK (hud_dbusmenu_collector_root_changed), collector, 0);
499 hud_dbusmenu_collector_setup_root (collector, dbusmenu_client_get_root (collector->client));
500 }
501}
502
503static void
504hud_dbusmenu_collector_registrar_observer_func (HudAppMenuRegistrar *registrar,
505 guint xid,
506 const gchar *bus_name,
507 const gchar *object_path,
508 gpointer user_data)
509{
510 HudDbusmenuCollector *collector = user_data;
511
512 hud_dbusmenu_collector_setup_endpoint (collector, bus_name, object_path);
513}
514
515
516static void
517hud_dbusmenu_collector_finalize (GObject *object)
518{
519 HudDbusmenuCollector *collector = HUD_DBUSMENU_COLLECTOR (object);
520
521 if (collector->xid)
522 hud_app_menu_registrar_remove_observer (hud_app_menu_registrar_get (), collector->xid,
523 hud_dbusmenu_collector_registrar_observer_func, collector);
524
525 /* remove all the items without firing change signals */
526 collector->alive = FALSE;
527 hud_dbusmenu_collector_setup_endpoint (collector, NULL, NULL);
528
529 /* make sure the table is empty before we free it */
530 g_assert (g_hash_table_size (collector->items) == 0);
531 g_hash_table_unref (collector->items);
532
533 g_free (collector->application_id);
534 g_free (collector->icon);
535
536 hud_string_list_unref (collector->prefix);
537 g_clear_object (&collector->client);
538
539 G_OBJECT_CLASS (hud_dbusmenu_collector_parent_class)
540 ->finalize (object);
541}
542
543static void
544hud_dbusmenu_collector_init (HudDbusmenuCollector *collector)
545{
546 collector->items = g_hash_table_new_full (NULL, NULL, NULL, g_object_unref);
547}
548
549static void
550hud_dbusmenu_collector_iface_init (HudSourceInterface *iface)
551{
552 iface->use = hud_dbusmenu_collector_use;
553 iface->unuse = hud_dbusmenu_collector_unuse;
554 iface->search = hud_dbusmenu_collector_search;
555}
556
557static void
558hud_dbusmenu_collector_class_init (HudDbusmenuCollectorClass *class)
559{
560 class->finalize = hud_dbusmenu_collector_finalize;
561}
562
563/**
564 * hud_dbusmenu_collector_new_for_endpoint:
565 * @application_id: a unique identifier for the application
566 * @prefix: the title to prefix to all items
567 * @icon: the icon for the appliction
568 * @penalty: the penalty to apply to all results
569 * @bus_name: a D-Bus bus name
570 * @object_path: an object path at the destination given by @bus_name
571 *
572 * Creates a new #HudDbusmenuCollector for the specified endpoint.
573 *
574 * Internally, a #DbusmenuClient is created for this endpoint. Searches
575 * are performed against the contents of those menus.
576 *
577 * This call is intended to be used for indicators.
578 *
579 * If @prefix is non-%NULL (which, for indicators, it ought to be), then
580 * it is prefixed to every item created by the collector.
581 *
582 * If @penalty is non-zero then all results returned from the collector
583 * have their distance increased by a percentage equal to the penalty.
584 * This allows items from indicators to score lower than they would
585 * otherwise.
586 *
587 * Returns: a new #HudDbusmenuCollector
588 **/
589HudDbusmenuCollector *
590hud_dbusmenu_collector_new_for_endpoint (const gchar *application_id,
591 const gchar *prefix,
592 const gchar *icon,
593 guint penalty,
594 const gchar *bus_name,
595 const gchar *object_path)
596{
597 HudDbusmenuCollector *collector;
598
599 collector = g_object_new (HUD_TYPE_DBUSMENU_COLLECTOR, NULL);
600 collector->application_id = g_strdup (application_id);
601 collector->icon = g_strdup (icon);
602 if (prefix)
603 collector->prefix = hud_string_list_cons (prefix, NULL);
604 collector->penalty = penalty;
605 hud_dbusmenu_collector_setup_endpoint (collector, bus_name, object_path);
606
607 collector->alive = TRUE;
608
609 return collector;
610}
611
612/**
613 * hud_dbusmenu_collector_new_for_window:
614 * @window: a #BamfWindow
615 *
616 * Creates a new #HudDbusmenuCollector for the endpoint indicated by the
617 * #HudAppMenuRegistrar for @window.
618 *
619 * This call is intended to be used for application menus.
620 *
621 * Returns: a new #HudDbusmenuCollector
622 **/
623HudDbusmenuCollector *
624hud_dbusmenu_collector_new_for_window (BamfWindow *window,
625 const gchar *desktop_file,
626 const gchar *icon)
627{
628 HudDbusmenuCollector *collector;
629
630 collector = g_object_new (HUD_TYPE_DBUSMENU_COLLECTOR, NULL);
631 collector->application_id = g_strdup (desktop_file);
632 collector->icon = g_strdup (icon);
633 collector->xid = bamf_window_get_xid (window);
634 g_debug ("dbusmenu on %d", collector->xid);
635 hud_app_menu_registrar_add_observer (hud_app_menu_registrar_get (), collector->xid,
636 hud_dbusmenu_collector_registrar_observer_func, collector);
637
638 collector->alive = TRUE;
639
640 return collector;
641}
642
643/**
644 * hud_dbusmenu_collector_set_prefix:
645 * @collector: a #HudDbusmenuCollector
646 * @prefix: the new prefix to use
647 *
648 * Changes the prefix applied to all items of the collector.
649 *
650 * This will involve destroying all of the items and recreating them
651 * (since each item's prefix has to be changed).
652 **/
653void
654hud_dbusmenu_collector_set_prefix (HudDbusmenuCollector *collector,
655 const gchar *prefix)
656{
657 hud_string_list_unref (collector->prefix);
658 collector->prefix = hud_string_list_cons (prefix, NULL);
659 hud_dbusmenu_collector_setup_root (collector, collector->root);
660}
661
662/**
663 * hud_dbusmenu_collector_set_icon:
664 * @collector: a #HudDbusmenuCollector
665 * @icon: the application icon
666 *
667 * Changes the application icon used for all items of the collector.
668 *
669 * This will involve destroying all of the items and recreating them
670 * (since each item's icon has to be changed).
671 **/
672void
673hud_dbusmenu_collector_set_icon (HudDbusmenuCollector *collector,
674 const gchar *icon)
675{
676 g_free (collector->icon);
677 collector->icon = g_strdup (icon);
678 hud_dbusmenu_collector_setup_root (collector, collector->root);
679}
6800
=== removed file 'src/huddbusmenucollector.h'
--- src/huddbusmenucollector.h 2012-12-03 17:40:45 +0000
+++ src/huddbusmenucollector.h 1970-01-01 00:00:00 +0000
@@ -1,48 +0,0 @@
1/*
2 * Copyright © 2012 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Author: Ryan Lortie <desrt@desrt.ca>
17 */
18
19#ifndef __HUD_DBUSMENU_COLLECTOR_H__
20#define __HUD_DBUSMENU_COLLECTOR_H__
21
22#include <libbamf/libbamf.h>
23
24#define HUD_TYPE_DBUSMENU_COLLECTOR (hud_dbusmenu_collector_get_type ())
25#define HUD_DBUSMENU_COLLECTOR(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \
26 HUD_TYPE_DBUSMENU_COLLECTOR, HudDbusmenuCollector))
27#define HUD_IS_DBUSMENU_COLLECTOR(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \
28 HUD_TYPE_DBUSMENU_COLLECTOR))
29
30typedef struct _HudDbusmenuCollector HudDbusmenuCollector;
31
32GType hud_dbusmenu_collector_get_type (void);
33
34HudDbusmenuCollector * hud_dbusmenu_collector_new_for_endpoint (const gchar *application_id,
35 const gchar *prefix,
36 const gchar *icon,
37 guint penalty,
38 const gchar *bus_name,
39 const gchar *object_path);
40HudDbusmenuCollector * hud_dbusmenu_collector_new_for_window (BamfWindow *window,
41 const gchar *desktop_file,
42 const gchar *icon);
43void hud_dbusmenu_collector_set_prefix (HudDbusmenuCollector *collector,
44 const gchar *prefix);
45void hud_dbusmenu_collector_set_icon (HudDbusmenuCollector *collector,
46 const gchar *icon);
47
48#endif /* __HUD_DBUSMENU_COLLECTOR_H__ */
490
=== removed file 'src/huddebugsource.c'
--- src/huddebugsource.c 2012-12-03 17:40:45 +0000
+++ src/huddebugsource.c 1970-01-01 00:00:00 +0000
@@ -1,168 +0,0 @@
1/*
2 * Copyright © 2012 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Author: Ryan Lortie <desrt@desrt.ca>
17 */
18
19#include "huddebugsource.h"
20
21#include "hudsource.h"
22#include "hudresult.h"
23
24/**
25 * SECTION:huddebugsource
26 * @title: HudDebugSource
27 * @short_description: a source to assist with debugging
28 *
29 * #HudDebugSource is a source for debugging purposes. It is not
30 * enabled by default but you can have it added to the global list of
31 * sources by setting the HUD_DEBUG_SOURCE environment variable.
32 *
33 * Presently it creates a #HudItem corresponding to the current date and
34 * time (and updates it as the time changes).
35 **/
36
37/**
38 * HudDebugSource:
39 *
40 * This is an opaque structure type.
41 **/
42
43struct _HudDebugSource
44{
45 GObject parent_instance;
46
47 HudItem *item;
48 gint use_count;
49 gint timeout;
50};
51
52typedef GObjectClass HudDebugSourceClass;
53
54static void hud_debug_source_iface_init (HudSourceInterface *iface);
55G_DEFINE_TYPE_WITH_CODE (HudDebugSource, hud_debug_source, G_TYPE_OBJECT,
56 G_IMPLEMENT_INTERFACE (HUD_TYPE_SOURCE, hud_debug_source_iface_init))
57
58static gboolean
59hud_debug_source_timeout (gpointer user_data)
60{
61 HudDebugSource *source = user_data;
62 HudStringList *tokens;
63 GDateTime *now;
64 gchar *time;
65
66 g_clear_object (&source->item);
67
68 now = g_date_time_new_now_local ();
69 time = g_date_time_format (now, "hud-debug time: %c");
70 tokens = hud_string_list_cons (time, NULL);
71 g_date_time_unref (now);
72 g_free (time);
73
74 source->item = hud_item_new (tokens, NULL, NULL, TRUE);
75 hud_string_list_unref (tokens);
76
77 hud_source_changed (HUD_SOURCE (source));
78
79 return TRUE;
80}
81
82static void
83hud_debug_source_use (HudSource *hud_source)
84{
85 HudDebugSource *source = HUD_DEBUG_SOURCE (hud_source);
86
87 if (source->use_count == 0)
88 source->timeout = g_timeout_add (1000, hud_debug_source_timeout, source);
89
90 source->use_count++;
91}
92
93static void
94hud_debug_source_unuse (HudSource *hud_source)
95{
96 HudDebugSource *source = HUD_DEBUG_SOURCE (hud_source);
97
98 source->use_count--;
99
100 if (source->use_count == 0)
101 {
102 g_source_remove (source->timeout);
103 source->timeout = 0;
104 }
105}
106
107static void
108hud_debug_source_search (HudSource *hud_source,
109 GPtrArray *results_array,
110 HudTokenList *search_string)
111{
112 HudDebugSource *source = HUD_DEBUG_SOURCE (hud_source);
113
114 if (source->item)
115 {
116 HudResult *result;
117
118 result = hud_result_get_if_matched (source->item, search_string, 0);
119 if (result != NULL)
120 g_ptr_array_add (results_array, result);
121 }
122}
123
124static void
125hud_debug_source_finalize (GObject *object)
126{
127 HudDebugSource *source = HUD_DEBUG_SOURCE (object);
128
129 g_clear_object (&source->item);
130
131 if (source->timeout)
132 g_source_remove (source->timeout);
133
134 G_OBJECT_CLASS (hud_debug_source_parent_class)
135 ->finalize (object);
136}
137
138static void
139hud_debug_source_init (HudDebugSource *source)
140{
141}
142
143static void
144hud_debug_source_iface_init (HudSourceInterface *iface)
145{
146 iface->use = hud_debug_source_use;
147 iface->unuse = hud_debug_source_unuse;
148 iface->search = hud_debug_source_search;
149}
150
151static void
152hud_debug_source_class_init (HudDebugSourceClass *class)
153{
154 class->finalize = hud_debug_source_finalize;
155}
156
157/**
158 * hud_debug_source_new:
159 *
160 * Creates a #HudDebugSource.
161 *
162 * Returns: a new empty #HudDebugSource
163 **/
164HudDebugSource *
165hud_debug_source_new (void)
166{
167 return g_object_new (HUD_TYPE_DEBUG_SOURCE, NULL);
168}
1690
=== removed file 'src/huddebugsource.h'
--- src/huddebugsource.h 2012-12-03 17:40:45 +0000
+++ src/huddebugsource.h 1970-01-01 00:00:00 +0000
@@ -1,36 +0,0 @@
1/*
2 * Copyright © 2012 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Author: Ryan Lortie <desrt@desrt.ca>
17 */
18
19#ifndef __HUD_DEBUG_SOURCE_H__
20#define __HUD_DEBUG_SOURCE_H__
21
22#include <glib-object.h>
23
24#define HUD_TYPE_DEBUG_SOURCE (hud_debug_source_get_type ())
25#define HUD_DEBUG_SOURCE(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \
26 HUD_TYPE_DEBUG_SOURCE, HudDebugSource))
27#define HUD_IS_DEBUG_SOURCE(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \
28 HUD_TYPE_DEBUG_SOURCE))
29
30typedef struct _HudDebugSource HudDebugSource;
31
32GType hud_debug_source_get_type (void);
33
34HudDebugSource * hud_debug_source_new (void);
35
36#endif /* __HUD_DEBUG_SOURCE_H__ */
370
=== removed file 'src/hudindicatorsource.c'
--- src/hudindicatorsource.c 2012-12-03 17:40:45 +0000
+++ src/hudindicatorsource.c 1970-01-01 00:00:00 +0000
@@ -1,286 +0,0 @@
1/*
2 * Copyright © 2012 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors: Ryan Lortie <desrt@desrt.ca>
17 * Ted Gould <ted@canonical.com>
18 */
19
20#include "hudindicatorsource.h"
21
22#include <glib/gi18n.h>
23#include <gio/gio.h>
24
25#include "hudsettings.h"
26#include "huddbusmenucollector.h"
27#include "hudmenumodelcollector.h"
28#include "hudsource.h"
29
30/**
31 * SECTION:hudindicatorsource
32 * @title:HudIndicatorSource
33 * @short_description: a #HudSource to search through the menus of
34 * indicators
35 *
36 * #HudIndicatorSource searches through the menu items of the
37 * indicators.
38 **/
39
40/**
41 * HudIndicatorSource:
42 *
43 * This is an opaque structure type.
44 **/
45
46typedef struct
47{
48 const gchar *dbus_name;
49 const gchar *dbus_menu_path;
50 const gchar *indicator_name;
51 const gchar *user_visible_name;
52 const gchar *icon;
53 gboolean uses_gmenumodel;
54} IndicatorInfo;
55
56static const IndicatorInfo indicator_info[] = {
57 {
58 .dbus_name = "com.canonical.indicator.datetime",
59 .dbus_menu_path = "/com/canonical/indicator/datetime/menu",
60 .indicator_name = "indicator-datetime",
61 .user_visible_name = N_("Date"),
62 .icon = "office-calendar"
63 },
64 {
65 .dbus_name = "com.canonical.indicator.session",
66 .dbus_menu_path = "/com/canonical/indicator/session/menu",
67 .indicator_name = "indicator-session-device",
68 .user_visible_name = N_("Device"),
69 .icon = "system-devices-panel"
70 },
71 {
72 .dbus_name = "com.canonical.indicator.session",
73 .dbus_menu_path = "/com/canonical/indicator/users/menu",
74 .indicator_name = "indicator-session-user",
75 .user_visible_name = N_("Users"),
76 .icon = "avatar-default"
77 },
78 {
79 .dbus_name = "com.canonical.indicator.sound",
80 .dbus_menu_path = "/com/canonical/indicator/sound/menu",
81 .indicator_name = "indicator-sound",
82 .user_visible_name = N_("Sound"),
83 .icon = "audio-volume-high-panel"
84 },
85 {
86 .dbus_name = "com.canonical.indicator.messages",
87 .dbus_menu_path = "/com/canonical/indicator/messages/menu",
88 .indicator_name = "indicator-messages",
89 .user_visible_name = N_("Messages"),
90 .icon = "indicator-messages",
91 .uses_gmenumodel = TRUE
92 }
93};
94
95typedef struct
96{
97 const IndicatorInfo *info;
98 HudIndicatorSource *source;
99 HudSource *collector;
100} HudIndicatorSourceIndicator;
101
102struct _HudIndicatorSource
103{
104 GObject parent_instance;
105
106 HudIndicatorSourceIndicator *indicators;
107 gint n_indicators;
108 gint use_count;
109};
110
111typedef GObjectClass HudIndicatorSourceClass;
112
113static void hud_indicator_source_iface_init (HudSourceInterface *iface);
114G_DEFINE_TYPE_WITH_CODE (HudIndicatorSource, hud_indicator_source, G_TYPE_OBJECT,
115 G_IMPLEMENT_INTERFACE (HUD_TYPE_SOURCE, hud_indicator_source_iface_init))
116
117static void
118hud_indicator_source_use (HudSource *hud_source)
119{
120 HudIndicatorSource *source = HUD_INDICATOR_SOURCE (hud_source);
121 gint i;
122
123 if (source->use_count == 0)
124 {
125 for (i = 0; i < source->n_indicators; i++)
126 if (source->indicators[i].collector)
127 hud_source_use (source->indicators[i].collector);
128 }
129
130 source->use_count++;
131}
132
133static void
134hud_indicator_source_unuse (HudSource *hud_source)
135{
136 HudIndicatorSource *source = HUD_INDICATOR_SOURCE (hud_source);
137 gint i;
138
139 g_return_if_fail (source->use_count > 0);
140
141 source->use_count--;
142
143 if (source->use_count == 0)
144 {
145 for (i = 0; i < source->n_indicators; i++)
146 if (source->indicators[i].collector)
147 hud_source_unuse (source->indicators[i].collector);
148 }
149}
150
151static void
152hud_indicator_source_search (HudSource *hud_source,
153 GPtrArray *results_array,
154 HudTokenList *search_string)
155{
156 HudIndicatorSource *source = HUD_INDICATOR_SOURCE (hud_source);
157 gint i;
158
159 for (i = 0; i < source->n_indicators; i++)
160 if (source->indicators[i].collector)
161 hud_source_search (source->indicators[i].collector, results_array, search_string);
162}
163
164static void
165hud_indicator_source_finalize (GObject *object)
166{
167 g_assert_not_reached ();
168}
169
170static void
171hud_indicator_source_collector_changed (HudSource *source,
172 gpointer user_data)
173{
174 HudIndicatorSourceIndicator *indicator = user_data;
175
176 hud_source_changed (HUD_SOURCE (indicator->source));
177}
178
179static void
180hud_indicator_source_name_appeared (GDBusConnection *connection,
181 const gchar *name,
182 const gchar *name_owner,
183 gpointer user_data)
184{
185 HudIndicatorSourceIndicator *indicator = user_data;
186
187 if (indicator->info->uses_gmenumodel)
188 {
189 HudMenuModelCollector *collector;
190
191 collector = hud_menu_model_collector_new_for_endpoint (indicator->info->indicator_name,
192 _(indicator->info->user_visible_name),
193 indicator->info->icon,
194 hud_settings.indicator_penalty,
195 name_owner,
196 indicator->info->dbus_menu_path);
197
198 indicator->collector = HUD_SOURCE (collector);
199 }
200 else
201 {
202 HudDbusmenuCollector *collector;
203
204 collector = hud_dbusmenu_collector_new_for_endpoint (indicator->info->indicator_name,
205 _(indicator->info->user_visible_name),
206 indicator->info->icon,
207 hud_settings.indicator_penalty,
208 name_owner, indicator->info->dbus_menu_path);
209 indicator->collector = HUD_SOURCE (collector);
210 }
211
212 g_signal_connect (indicator->collector, "changed",
213 G_CALLBACK (hud_indicator_source_collector_changed), indicator);
214
215 /* Set initial use count on new indicator if query is active. */
216 if (indicator->source->use_count)
217 hud_source_use (indicator->collector);
218
219 hud_source_changed (HUD_SOURCE (indicator->source));
220}
221
222static void
223hud_indicator_source_name_vanished (GDBusConnection *connection,
224 const gchar *name,
225 gpointer user_data)
226{
227 HudIndicatorSourceIndicator *indicator = user_data;
228
229 if (indicator->collector)
230 {
231 g_signal_handlers_disconnect_by_func (indicator->collector, hud_indicator_source_collector_changed, indicator);
232 /* Drop our use count on dying indicator (if any) */
233 if (indicator->source->use_count)
234 hud_source_unuse (indicator->collector);
235 g_clear_object (&indicator->collector);
236 }
237
238 hud_source_changed (HUD_SOURCE (indicator->source));
239}
240
241static void
242hud_indicator_source_init (HudIndicatorSource *source)
243{
244 gint i;
245
246 source->n_indicators = G_N_ELEMENTS (indicator_info);
247 source->indicators = g_new0 (HudIndicatorSourceIndicator, source->n_indicators);
248
249 for (i = 0; i < source->n_indicators; i++)
250 {
251 HudIndicatorSourceIndicator *indicator = &source->indicators[i];
252
253 indicator->info = &indicator_info[i];
254 indicator->source = source;
255
256 g_bus_watch_name (G_BUS_TYPE_SESSION, indicator->info->dbus_name, G_BUS_NAME_WATCHER_FLAGS_NONE,
257 hud_indicator_source_name_appeared, hud_indicator_source_name_vanished, indicator, NULL);
258 }
259}
260
261static void
262hud_indicator_source_iface_init (HudSourceInterface *iface)
263{
264 iface->use = hud_indicator_source_use;
265 iface->unuse = hud_indicator_source_unuse;
266 iface->search = hud_indicator_source_search;
267}
268
269static void
270hud_indicator_source_class_init (HudIndicatorSourceClass *class)
271{
272 class->finalize = hud_indicator_source_finalize;
273}
274
275/**
276 * hud_indicator_source_new:
277 *
278 * Creates a #HudIndicatorSource.
279 *
280 * Returns: a new #HudIndicatorSource
281 **/
282HudIndicatorSource *
283hud_indicator_source_new (void)
284{
285 return g_object_new (HUD_TYPE_INDICATOR_SOURCE, NULL);
286}
2870
=== removed file 'src/hudindicatorsource.h'
--- src/hudindicatorsource.h 2012-12-03 17:40:45 +0000
+++ src/hudindicatorsource.h 1970-01-01 00:00:00 +0000
@@ -1,36 +0,0 @@
1/*
2 * Copyright © 2012 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Author: Ryan Lortie <desrt@desrt.ca>
17 */
18
19#ifndef __HUD_INDICATOR_SOURCE_H__
20#define __HUD_INDICATOR_SOURCE_H__
21
22#include <glib-object.h>
23
24#define HUD_TYPE_INDICATOR_SOURCE (hud_indicator_source_get_type ())
25#define HUD_INDICATOR_SOURCE(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \
26 HUD_TYPE_INDICATOR_SOURCE, HudIndicatorSource))
27#define HUD_IS_INDICATOR_SOURCE(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \
28 HUD_TYPE_INDICATOR_SOURCE))
29
30typedef struct _HudIndicatorSource HudIndicatorSource;
31
32GType hud_indicator_source_get_type (void);
33
34HudIndicatorSource * hud_indicator_source_new (void);
35
36#endif /* __HUD_INDICATOR_SOURCE_H__ */
370
=== removed file 'src/huditem.c'
--- src/huditem.c 2012-12-03 17:40:45 +0000
+++ src/huditem.c 1970-01-01 00:00:00 +0000
@@ -1,343 +0,0 @@
1/*
2 * Copyright © 2012 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Author: Ryan Lortie <desrt@desrt.ca>
17 */
18
19#include "huditem.h"
20
21#include "usage-tracker.h"
22#include "hudtoken.h"
23
24/**
25 * SECTION:huditem
26 * @title: HudItem
27 * @short_description: a user-interesting item that can be activated
28 *
29 * A #HudItem represents a user-interesting action that can be activated
30 * from the Hud user interface.
31 **/
32
33/**
34 * HudItem:
35 *
36 * This is an opaque structure type.
37 **/
38
39/**
40 * HudItemClass:
41 * @parent_class: the #GObjectClass
42 * @activate: virtual function pointer for hud_item_activate()
43 *
44 * This is the class vtable for #HudItem.
45 **/
46
47static GHashTable *hud_item_table;
48static guint64 hud_item_next_id;
49
50struct _HudItemPrivate
51{
52 GObject parent_instance;
53
54 gchar *desktop_file;
55
56 HudTokenList *token_list;
57 HudStringList *tokens;
58 gchar *usage_tag;
59 gchar *app_icon;
60 gboolean enabled;
61 guint usage;
62 guint64 id;
63};
64
65G_DEFINE_TYPE (HudItem, hud_item, G_TYPE_OBJECT)
66
67static void
68hud_item_finalize (GObject *object)
69{
70 HudItem *item = HUD_ITEM (object);
71
72 g_hash_table_remove (hud_item_table, &item->priv->id);
73 hud_token_list_free (item->priv->token_list);
74 hud_string_list_unref (item->priv->tokens);
75 g_free (item->priv->desktop_file);
76 g_free (item->priv->app_icon);
77 g_free (item->priv->usage_tag);
78
79 G_OBJECT_CLASS (hud_item_parent_class)
80 ->finalize (object);
81}
82
83static void
84hud_item_init (HudItem *item)
85{
86 item->priv = G_TYPE_INSTANCE_GET_PRIVATE (item, HUD_TYPE_ITEM, HudItemPrivate);
87}
88
89static void
90hud_item_class_init (HudItemClass *class)
91{
92 GObjectClass *gobject_class = G_OBJECT_CLASS (class);
93
94 hud_item_table = g_hash_table_new (g_int64_hash, g_int64_equal);
95
96 gobject_class->finalize = hud_item_finalize;
97
98 g_type_class_add_private (class, sizeof (HudItemPrivate));
99}
100
101static void
102hud_item_format_tokens (GString *string,
103 HudStringList *tokens)
104{
105 HudStringList *tail;
106
107 tail = hud_string_list_get_tail (tokens);
108
109 if (tail)
110 {
111 hud_item_format_tokens (string, tail);
112 g_string_append (string, "||");
113 }
114
115 g_string_append (string, hud_string_list_get_head (tokens));
116}
117
118static void
119hud_item_setup_usage (HudItem *item)
120{
121 GString *tag;
122
123 if (item->priv->tokens && item->priv->enabled)
124 {
125 tag = g_string_new (NULL);
126 hud_item_format_tokens (tag, item->priv->tokens);
127 item->priv->usage_tag = g_string_free (tag, FALSE);
128 item->priv->usage = usage_tracker_get_usage (usage_tracker_get_instance (),
129 item->priv->desktop_file, item->priv->usage_tag);
130 }
131}
132
133/**
134 * hud_item_construct:
135 * @g_type: a #GType
136 * @tokens: the search tokens for the item
137 * @desktop_file: the desktop file of the provider of the item
138 * @app_icon: the icon name for the application that created this item
139 * @enabled: if the item is enabled
140 *
141 * This is the Vala-style chain-up constructor corresponding to
142 * hud_item_new(). @g_type must be a subtype of #HudItem.
143 *
144 * Only subclasses of #HudItem should call this.
145 *
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches