Merge lp:~3v1n0/bamf/desktopless-webapps-fix into lp:bamf/0.4

Proposed by Marco Trevisan (Treviño) on 2012-04-26
Status: Merged
Approved by: Marco Trevisan (Treviño) on 2012-05-22
Approved revision: 470
Merged at revision: 465
Proposed branch: lp:~3v1n0/bamf/desktopless-webapps-fix
Merge into: lp:bamf/0.4
Diff against target: 111 lines (+28/-16)
2 files modified
src/bamf-application.c (+16/-11)
src/bamf-matcher.c (+12/-5)
To merge this branch: bzr merge lp:~3v1n0/bamf/desktopless-webapps-fix
Reviewer Review Type Date Requested Status
Jason Smith (community) 2012-04-26 Approve on 2012-05-22
Review via email: mp+103608@code.launchpad.net

Commit message

BamfMatcher: match chromium web applications with no .desktop file as new applications

Description of the change

Chromium applications with no desktop file are matched as new applications anyway...

To post a comment you must log in.
Jason Smith (jassmith) wrote :

Line 22 of the diff could be after the short circuit to save some spare computations. Other than that, good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/bamf-application.c'
2--- src/bamf-application.c 2012-03-16 19:39:34 +0000
3+++ src/bamf-application.c 2012-04-26 06:28:24 +0000
4@@ -300,17 +300,20 @@
5
6 gboolean
7 bamf_application_contains_similar_to_window (BamfApplication *self,
8- BamfWindow *window)
9+ BamfWindow *bamf_window)
10 {
11- gboolean result = FALSE;
12- const char *class, *owned_class;
13 GList *children, *l;
14 BamfView *child;
15
16 g_return_val_if_fail (BAMF_IS_APPLICATION (self), FALSE);
17- g_return_val_if_fail (BAMF_IS_WINDOW (window), FALSE);
18-
19- class = bamf_legacy_window_get_class_name (bamf_window_get_window (window));
20+ g_return_val_if_fail (BAMF_IS_WINDOW (bamf_window), FALSE);
21+
22+ BamfLegacyWindow *window = bamf_window_get_window (bamf_window);
23+ const char *window_class = bamf_legacy_window_get_class_name (window);
24+ const char *instance_name = bamf_legacy_window_get_class_instance_name (window);
25+
26+ if (!window_class || !instance_name)
27+ return FALSE;
28
29 children = bamf_view_get_children (BAMF_VIEW (self));
30 for (l = children; l; l = l->next)
31@@ -320,16 +323,18 @@
32 if (!BAMF_IS_WINDOW (child))
33 continue;
34
35- owned_class = bamf_legacy_window_get_class_name (bamf_window_get_window (BAMF_WINDOW (child)));
36+ window = bamf_window_get_window (BAMF_WINDOW (child));
37+ const char *owned_win_class = bamf_legacy_window_get_class_name (window);
38+ const char *owned_instance = bamf_legacy_window_get_class_instance_name (window);
39
40- if (g_strcmp0 (class, owned_class) == 0)
41+ if (g_strcmp0 (window_class, owned_win_class) == 0 &&
42+ g_strcmp0 (instance_name, owned_instance) == 0)
43 {
44- result = TRUE;
45- break;
46+ return TRUE;
47 }
48 }
49
50- return result;
51+ return FALSE;
52 }
53
54 gboolean
55
56=== modified file 'src/bamf-matcher.c'
57--- src/bamf-matcher.c 2012-04-20 17:36:00 +0000
58+++ src/bamf-matcher.c 2012-04-26 06:28:24 +0000
59@@ -1528,7 +1528,7 @@
60 is_web_app_window (BamfMatcher *self, BamfLegacyWindow *window)
61 {
62 const char *window_class = bamf_legacy_window_get_class_name (window);
63- const char *instance_name = bamf_legacy_window_get_class_instance_name(window);
64+ const char *instance_name = bamf_legacy_window_get_class_instance_name (window);
65
66 // Chrome/Chromium uses url wm_class strings to represent its web apps.
67 // These apps will still have the same parent pid and hints as the main chrome
68@@ -1541,12 +1541,14 @@
69 gboolean valid_app = FALSE;
70
71 if (g_strcmp0 (window_class, "Google-chrome") == 0 &&
72- g_strcmp0 (instance_name, "google-chrome") != 0)
73+ g_strcmp0 (instance_name, "google-chrome") != 0 &&
74+ !g_str_has_prefix (instance_name, "Google-chrome"))
75 {
76 valid_app = TRUE;
77 }
78 else if (g_strcmp0 (window_class, "Chromium-browser") == 0 &&
79- g_strcmp0 (instance_name, "chromium-browser") != 0)
80+ g_strcmp0 (instance_name, "chromium-browser") != 0 &&
81+ !g_str_has_prefix (instance_name, "Chromium-browser"))
82 {
83 valid_app = TRUE;
84 }
85@@ -1635,11 +1637,16 @@
86 const char *instance_name = bamf_legacy_window_get_class_instance_name (window);
87 gboolean known_desktop_class = bamf_matcher_has_instance_class_desktop_file (self, instance_name);
88
89+ if (!known_desktop_class)
90+ {
91+ known_desktop_class = is_web_app_window (self, window);
92+ }
93+
94 if (desktop_file)
95 {
96 desktop_class = g_hash_table_lookup (priv->desktop_class_table, desktop_file);
97
98- if (!known_desktop_class || g_strcmp0 (desktop_class, desktop_file) == 0)
99+ if (!known_desktop_class || g_strcmp0 (desktop_class, instance_name) == 0)
100 {
101 desktop_files = g_list_prepend (desktop_files, desktop_file);
102 }
103@@ -1730,7 +1737,7 @@
104 }
105 }
106 }
107-
108+
109 desktop_files = g_list_insert_before (desktop_files, last, desktop_file);
110 }
111 else

Subscribers

People subscribed via source and target branches