Merge lp:~h4writer/awn/taskmanager-rewrite into lp:~awn-core/awn/trunk-rewrite
- taskmanager-rewrite
- Merge into trunk-rewrite
Status: | Merged |
---|---|
Approved by: | Michal Hruby |
Approved revision: | 953 |
Merged at revision: | not available |
Proposed branch: | lp:~h4writer/awn/taskmanager-rewrite |
Merge into: | lp:~awn-core/awn/trunk-rewrite |
Diff against target: | None lines |
To merge this branch: | bzr merge lp:~h4writer/awn/taskmanager-rewrite |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
haytjes | Approve | ||
Michal Hruby (community) | Approve | ||
moonbeam | overview | Approve | |
Mark Lee | superreview | Needs Information | |
Review via email: mp+8033@code.launchpad.net |
Commit message
Description of the change
Mark Lee (malept) wrote : | # |
moonbeam (rcryderman) wrote : | # |
I'm not going to do a detailed review of this, purely based upon the extent of the modifications. A quick overview doesn't show anything particularly egregious, though I'm sure there are issues (but the current taskmanager code probably has even more fundamental ones). I think we are best served getting this merge, the sooner the better, get it tested and shake out the bugs (and any find design issues).
haytjes (h4writer) wrote : | # |
> === modified file 'applets/
> --- applets/
> +++ applets/
> @@ -17,14 +17,18 @@
> task-drag-
> task-icon.c \
> task-icon.h \
> + task-item.c \
> + task-item.h \
> + task-window.c \
> + task-window.h \
> task-launcher.c \
> task-launcher.h \
> task-manager.c \
> task-manager.h \
> + task-manager-
> + task-manager-
> task-settings.c \
> task-settings.h \
> - task-window.c \
> - task-window.h \
> $(builddir)
> $(builddir)
> xutils.c \
> ====
>
> Why did task-window.* move?
No particularly reason why it has moved. (I think I have removed it accidentally and then added again on the wrong place)
>
> === modified file 'applets/
> --- applets/
> +++ applets/
> @@ -13,7 +13,7 @@
> * You should have received a copy of the GNU General Public License
> * along with this program. If not, see <http://
> *
> - * Authored by Neil Jagdish Patel <email address hidden>
> + * Authored by Hannes Verschore <email address hidden>
> *
> */
>
> ====
>
> Any particular reason why you removed Neil as author here (and
> applets/
Reason: I have made those files and if there are problems with them they should contact me. I copied the license when creating the file, but forgot to change the author.
>
> In general, you should make sure that all of the code that you commented out
> (instead of deleted) should be annotated with the reason why you're commenting
> it.
I think the only code that is commented out is the code for refreshing the launcher list. The code still need to get adapted so it works. I leave the code there for adapting later on.
Mark Lee (malept) wrote : | # |
> > === modified file 'applets/
> > --- applets/
> > +++ applets/
> > @@ -17,14 +17,18 @@
> > task-drag-
> > task-icon.c \
> > task-icon.h \
> > + task-item.c \
> > + task-item.h \
> > + task-window.c \
> > + task-window.h \
> > task-launcher.c \
> > task-launcher.h \
> > task-manager.c \
> > task-manager.h \
> > + task-manager-
> > + task-manager-
> > task-settings.c \
> > task-settings.h \
> > - task-window.c \
> > - task-window.h \
> > $(builddir)
> > $(builddir)
> > xutils.c \
> > ====
> >
> > Why did task-window.* move?
>
> No particularly reason why it has moved. (I think I have removed it
> accidentally and then added again on the wrong place)
Once the task-window.* entries are moved back (make sure you use tabs, not spaces), I have no objection to merging to rewrite.
haytjes (h4writer) wrote : | # |
> > > === modified file 'applets/
> > > --- applets/
> > > +++ applets/
> > > @@ -17,14 +17,18 @@
> > > task-drag-
> > > task-icon.c \
> > > task-icon.h \
> > > + task-item.c \
> > > + task-item.h \
> > > + task-window.c \
> > > + task-window.h \
> > > task-launcher.c \
> > > task-launcher.h \
> > > task-manager.c \
> > > task-manager.h \
> > > + task-manager-
> > > + task-manager-
> > > task-settings.c \
> > > task-settings.h \
> > > - task-window.c \
> > > - task-window.h \
> > > $(builddir)
> > > $(builddir)
> > > xutils.c \
> > > ====
> > >
> > > Why did task-window.* move?
> >
> > No particularly reason why it has moved. (I think I have removed it
> > accidentally and then added again on the wrong place)
>
> Once the task-window.* entries are moved back (make sure you use tabs, not
> spaces), I have no objection to merging to rewrite.
I will adjust it. But currently I'm doing a vacation job and I'm not home tonight. So it will be tomorrow evening. I will ask dolfje to do tonight, but I'm not sure if he will do it.
Michal Hruby (mhr3) wrote : | # |
I basically agree with moonbeam, this is way too big to be reviewed into detail, so I'd also say let's merge it and solve the problems as they come up...
Anyway, I did notice one small issue:
681 + if (priv->
682 + {
683 + awn_overlayable
684 + AWN_OVERLAY (priv->
685 + g_object_unref (priv->
686 + priv->overlay_text = NULL;
687 + }
Overlays are initially unowned, so you do not need to unref them (the remove_overlay method will destroy them).
haytjes (h4writer) wrote : | # |
> I basically agree with moonbeam, this is way too big to be reviewed into
> detail, so I'd also say let's merge it and solve the problems as they come
> up...
>
> Anyway, I did notice one small issue:
>
> 681 + if (priv->
> 682 + {
> 683 + awn_overlayable
> 684 + AWN_OVERLAY (priv->
> 685 + g_object_unref (priv->
> 686 + priv->overlay_text = NULL;
> 687 + }
>
> Overlays are initially unowned, so you do not need to unref them (the
> remove_overlay method will destroy them).
Ah, good to know. I was really doubting about it.
haytjes (h4writer) wrote : | # |
Sorry that it takes so long. I have problems with creating time to work on it. I had 30min yesterday and I thought I could do those tiny adjustments within time, but it didn't worked :(. (A bit strange). I didn't investigate yet what the problem was, why it didn't work, but I will check tonight and commit it.
haytjes (h4writer) wrote : | # |
Sorry that it takes so long. I have problems with creating time to work on it. I had 30min yesterday and I thought I could do those tiny adjustments within time, but it didn't worked :(. (A bit strange). I didn't investigate yet what the problem was, why it didn't work, but I will check tonight and commit it.
haytjes (h4writer) : | # |
Preview Diff
1 | === modified file 'applets/taskmanager/Makefile.am' | |||
2 | --- applets/taskmanager/Makefile.am 2009-05-19 01:06:12 +0000 | |||
3 | +++ applets/taskmanager/Makefile.am 2009-06-26 11:00:10 +0000 | |||
4 | @@ -17,14 +17,18 @@ | |||
5 | 17 | task-drag-indicator.h \ | 17 | task-drag-indicator.h \ |
6 | 18 | task-icon.c \ | 18 | task-icon.c \ |
7 | 19 | task-icon.h \ | 19 | task-icon.h \ |
8 | 20 | task-item.c \ | ||
9 | 21 | task-item.h \ | ||
10 | 22 | task-window.c \ | ||
11 | 23 | task-window.h \ | ||
12 | 20 | task-launcher.c \ | 24 | task-launcher.c \ |
13 | 21 | task-launcher.h \ | 25 | task-launcher.h \ |
14 | 22 | task-manager.c \ | 26 | task-manager.c \ |
15 | 23 | task-manager.h \ | 27 | task-manager.h \ |
16 | 28 | task-manager-api-wrapper.c \ | ||
17 | 29 | task-manager-api-wrapper.h \ | ||
18 | 24 | task-settings.c \ | 30 | task-settings.c \ |
19 | 25 | task-settings.h \ | 31 | task-settings.h \ |
20 | 26 | task-window.c \ | ||
21 | 27 | task-window.h \ | ||
22 | 28 | $(builddir)/taskmanager-marshal.c \ | 32 | $(builddir)/taskmanager-marshal.c \ |
23 | 29 | $(builddir)/taskmanager-marshal.h \ | 33 | $(builddir)/taskmanager-marshal.h \ |
24 | 30 | xutils.c \ | 34 | xutils.c \ |
25 | 31 | 35 | ||
26 | === modified file 'applets/taskmanager/task-drag-indicator.c' | |||
27 | --- applets/taskmanager/task-drag-indicator.c 2009-06-19 09:35:43 +0000 | |||
28 | +++ applets/taskmanager/task-drag-indicator.c 2009-06-20 14:17:54 +0000 | |||
29 | @@ -13,7 +13,7 @@ | |||
30 | 13 | * You should have received a copy of the GNU General Public License | 13 | * You should have received a copy of the GNU General Public License |
31 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
32 | 15 | * | 15 | * |
34 | 16 | * Authored by Neil Jagdish Patel <njpatel@gmail.com> | 16 | * Authored by Hannes Verschore <hv1989@gmail.com> |
35 | 17 | * | 17 | * |
36 | 18 | */ | 18 | */ |
37 | 19 | 19 | ||
38 | @@ -151,6 +151,12 @@ | |||
39 | 151 | GtkWidget *drag_indicator = NULL; | 151 | GtkWidget *drag_indicator = NULL; |
40 | 152 | 152 | ||
41 | 153 | drag_indicator = g_object_new (TASK_TYPE_DRAG_INDICATOR, NULL); | 153 | drag_indicator = g_object_new (TASK_TYPE_DRAG_INDICATOR, NULL); |
42 | 154 | gtk_widget_hide (drag_indicator); | ||
43 | 155 | |||
44 | 156 | //BUG: AwnApplet calls upon start gtk_widget_show_all. So even when gtk_widget_hide | ||
45 | 157 | // gets called, it will get shown. So I'm forcing it to not listen to | ||
46 | 158 | // 'gtk_widget_show_all' with this function. FIXME: improve AwnApplet | ||
47 | 159 | gtk_widget_set_no_show_all (drag_indicator, TRUE); | ||
48 | 154 | 160 | ||
49 | 155 | return drag_indicator; | 161 | return drag_indicator; |
50 | 156 | } | 162 | } |
51 | 157 | 163 | ||
52 | === modified file 'applets/taskmanager/task-drag-indicator.h' | |||
53 | --- applets/taskmanager/task-drag-indicator.h 2009-05-27 15:57:06 +0000 | |||
54 | +++ applets/taskmanager/task-drag-indicator.h 2009-06-20 14:17:54 +0000 | |||
55 | @@ -13,7 +13,7 @@ | |||
56 | 13 | * You should have received a copy of the GNU General Public License | 13 | * You should have received a copy of the GNU General Public License |
57 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
58 | 15 | * | 15 | * |
60 | 16 | * Authored by Neil Jagdish Patel <njpatel@gmail.com> | 16 | * Authored by Hannes Verschore <hv1989@gmail.com> |
61 | 17 | * | 17 | * |
62 | 18 | */ | 18 | */ |
63 | 19 | 19 | ||
64 | 20 | 20 | ||
65 | === modified file 'applets/taskmanager/task-icon.c' | |||
66 | --- applets/taskmanager/task-icon.c 2009-06-19 09:35:43 +0000 | |||
67 | +++ applets/taskmanager/task-icon.c 2009-06-26 11:00:10 +0000 | |||
68 | @@ -14,6 +14,7 @@ | |||
69 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
70 | 15 | * | 15 | * |
71 | 16 | * Authored by Neil Jagdish Patel <njpatel@gmail.com> | 16 | * Authored by Neil Jagdish Patel <njpatel@gmail.com> |
72 | 17 | * Hannes Verschore <hv1989@gmail.com> | ||
73 | 17 | * | 18 | * |
74 | 18 | */ | 19 | */ |
75 | 19 | 20 | ||
76 | @@ -33,7 +34,7 @@ | |||
77 | 33 | #include "task-launcher.h" | 34 | #include "task-launcher.h" |
78 | 34 | #include "task-settings.h" | 35 | #include "task-settings.h" |
79 | 35 | 36 | ||
81 | 36 | G_DEFINE_TYPE (TaskIcon, task_icon, AWN_TYPE_ICON) | 37 | G_DEFINE_TYPE (TaskIcon, task_icon, AWN_TYPE_THEMED_ICON) |
82 | 37 | 38 | ||
83 | 38 | #define TASK_ICON_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj),\ | 39 | #define TASK_ICON_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj),\ |
84 | 39 | TASK_TYPE_ICON, \ | 40 | TASK_TYPE_ICON, \ |
85 | @@ -41,7 +42,27 @@ | |||
86 | 41 | 42 | ||
87 | 42 | struct _TaskIconPrivate | 43 | struct _TaskIconPrivate |
88 | 43 | { | 44 | { |
90 | 44 | GSList *windows; | 45 | //List containing the TaskItems |
91 | 46 | GSList *items; | ||
92 | 47 | |||
93 | 48 | //The number of TaskItems that get shown | ||
94 | 49 | guint shown_items; | ||
95 | 50 | |||
96 | 51 | //The number of TaskWindows (subclass of TaskItem) that needs attention | ||
97 | 52 | guint needs_attention; | ||
98 | 53 | |||
99 | 54 | //The number of TaskWindows (subclass of TaskItem) that have the active state. | ||
100 | 55 | guint is_active; | ||
101 | 56 | |||
102 | 57 | //The main item being used for the icon (and if alone for the text) | ||
103 | 58 | TaskItem *main_item; | ||
104 | 59 | |||
105 | 60 | //Whetever this icon is visible or not | ||
106 | 61 | gboolean visible; | ||
107 | 62 | |||
108 | 63 | //An overlay for showing number of items | ||
109 | 64 | AwnOverlayText *overlay_text; | ||
110 | 65 | |||
111 | 45 | GdkPixbuf *icon; | 66 | GdkPixbuf *icon; |
112 | 46 | GtkWidget *dialog; | 67 | GtkWidget *dialog; |
113 | 47 | 68 | ||
114 | @@ -64,13 +85,12 @@ | |||
115 | 64 | { | 85 | { |
116 | 65 | PROP_0, | 86 | PROP_0, |
117 | 66 | 87 | ||
118 | 67 | PROP_WINDOW, | ||
119 | 68 | PROP_DRAGGABLE | 88 | PROP_DRAGGABLE |
120 | 69 | }; | 89 | }; |
121 | 70 | 90 | ||
122 | 71 | enum | 91 | enum |
123 | 72 | { | 92 | { |
125 | 73 | ENSURE_LAYOUT, | 93 | VISIBLE_CHANGED, |
126 | 74 | 94 | ||
127 | 75 | SOURCE_DRAG_FAIL, | 95 | SOURCE_DRAG_FAIL, |
128 | 76 | SOURCE_DRAG_BEGIN, | 96 | SOURCE_DRAG_BEGIN, |
129 | @@ -113,7 +133,7 @@ | |||
130 | 113 | static gboolean task_icon_dialog_unfocus (GtkWidget *widget, | 133 | static gboolean task_icon_dialog_unfocus (GtkWidget *widget, |
131 | 114 | GdkEventFocus *event, | 134 | GdkEventFocus *event, |
132 | 115 | gpointer null); | 135 | gpointer null); |
134 | 116 | /* Dnd 'source' forwards */ | 136 | /* Dnd forwards */ |
135 | 117 | static void task_icon_drag_data_get (GtkWidget *widget, | 137 | static void task_icon_drag_data_get (GtkWidget *widget, |
136 | 118 | GdkDragContext *context, | 138 | GdkDragContext *context, |
137 | 119 | GtkSelectionData *selection_data, | 139 | GtkSelectionData *selection_data, |
138 | @@ -148,6 +168,9 @@ | |||
139 | 148 | guint time); | 168 | guint time); |
140 | 149 | 169 | ||
141 | 150 | static gboolean _update_geometry(GtkWidget *widget); | 170 | static gboolean _update_geometry(GtkWidget *widget); |
142 | 171 | static gboolean task_icon_refresh_geometry (TaskIcon *icon); | ||
143 | 172 | static void task_icon_refresh_visible (TaskIcon *icon); | ||
144 | 173 | static void task_icon_search_main_item (TaskIcon *icon); | ||
145 | 151 | 174 | ||
146 | 152 | /* GObject stuff */ | 175 | /* GObject stuff */ |
147 | 153 | static void | 176 | static void |
148 | @@ -161,11 +184,6 @@ | |||
149 | 161 | 184 | ||
150 | 162 | switch (prop_id) | 185 | switch (prop_id) |
151 | 163 | { | 186 | { |
152 | 164 | case PROP_WINDOW: | ||
153 | 165 | g_value_set_object (value, | ||
154 | 166 | priv->windows ? priv->windows->data : NULL); | ||
155 | 167 | break; | ||
156 | 168 | |||
157 | 169 | case PROP_DRAGGABLE: | 187 | case PROP_DRAGGABLE: |
158 | 170 | g_value_set_boolean (value, priv->draggable); | 188 | g_value_set_boolean (value, priv->draggable); |
159 | 171 | break; | 189 | break; |
160 | @@ -185,10 +203,6 @@ | |||
161 | 185 | 203 | ||
162 | 186 | switch (prop_id) | 204 | switch (prop_id) |
163 | 187 | { | 205 | { |
164 | 188 | case PROP_WINDOW: | ||
165 | 189 | task_icon_append_window (icon, g_value_get_object (value)); | ||
166 | 190 | break; | ||
167 | 191 | |||
168 | 192 | case PROP_DRAGGABLE: | 206 | case PROP_DRAGGABLE: |
169 | 193 | task_icon_set_draggable (icon, g_value_get_boolean (value)); | 207 | task_icon_set_draggable (icon, g_value_get_boolean (value)); |
170 | 194 | break; | 208 | break; |
171 | @@ -198,10 +212,15 @@ | |||
172 | 198 | } | 212 | } |
173 | 199 | } | 213 | } |
174 | 200 | 214 | ||
175 | 215 | /** | ||
176 | 216 | * Finalize the object and remove the list of windows, | ||
177 | 217 | * the list of launchers and the timer of update_geometry. | ||
178 | 218 | */ | ||
179 | 201 | static void | 219 | static void |
180 | 202 | task_icon_dispose (GObject *object) | 220 | task_icon_dispose (GObject *object) |
181 | 203 | { | 221 | { |
182 | 204 | TaskIconPrivate *priv = TASK_ICON_GET_PRIVATE (object); | 222 | TaskIconPrivate *priv = TASK_ICON_GET_PRIVATE (object); |
183 | 223 | |||
184 | 205 | /*this needs to be done in dispose, not finalize, due to idiosyncracies of | 224 | /*this needs to be done in dispose, not finalize, due to idiosyncracies of |
185 | 206 | AwnDialog*/ | 225 | AwnDialog*/ |
186 | 207 | if (priv->dialog) | 226 | if (priv->dialog) |
187 | @@ -209,6 +228,7 @@ | |||
188 | 209 | gtk_widget_destroy (priv->dialog); | 228 | gtk_widget_destroy (priv->dialog); |
189 | 210 | priv->dialog = NULL; | 229 | priv->dialog = NULL; |
190 | 211 | } | 230 | } |
191 | 231 | |||
192 | 212 | G_OBJECT_CLASS (task_icon_parent_class)->dispose (object); | 232 | G_OBJECT_CLASS (task_icon_parent_class)->dispose (object); |
193 | 213 | } | 233 | } |
194 | 214 | 234 | ||
195 | @@ -218,13 +238,15 @@ | |||
196 | 218 | TaskIconPrivate *priv = TASK_ICON_GET_PRIVATE (object); | 238 | TaskIconPrivate *priv = TASK_ICON_GET_PRIVATE (object); |
197 | 219 | 239 | ||
198 | 220 | /* FIXME Check to see if icon needs to be unreffed */ | 240 | /* FIXME Check to see if icon needs to be unreffed */ |
200 | 221 | if (priv->windows) | 241 | if (priv->items) |
201 | 222 | { | 242 | { |
204 | 223 | g_slist_free (priv->windows); | 243 | g_slist_free (priv->items); |
205 | 224 | priv->windows = NULL; | 244 | priv->items = NULL; |
206 | 225 | } | 245 | } |
207 | 226 | if(priv->update_geometry_id) | 246 | if(priv->update_geometry_id) |
208 | 247 | { | ||
209 | 227 | g_source_remove(priv->update_geometry_id); | 248 | g_source_remove(priv->update_geometry_id); |
210 | 249 | } | ||
211 | 228 | 250 | ||
212 | 229 | G_OBJECT_CLASS (task_icon_parent_class)->finalize (object); | 251 | G_OBJECT_CLASS (task_icon_parent_class)->finalize (object); |
213 | 230 | } | 252 | } |
214 | @@ -234,13 +256,27 @@ | |||
215 | 234 | { | 256 | { |
216 | 235 | TaskIconPrivate *priv = TASK_ICON (object)->priv; | 257 | TaskIconPrivate *priv = TASK_ICON (object)->priv; |
217 | 236 | GtkWidget *widget = GTK_WIDGET(object); | 258 | GtkWidget *widget = GTK_WIDGET(object); |
219 | 237 | 259 | ||
220 | 260 | if ( G_OBJECT_CLASS (task_icon_parent_class)->constructed) | ||
221 | 261 | { | ||
222 | 262 | G_OBJECT_CLASS (task_icon_parent_class)->constructed (object); | ||
223 | 263 | } | ||
224 | 264 | |||
225 | 265 | //update geometry of icon every second. | ||
226 | 238 | priv->update_geometry_id = g_timeout_add_seconds (1, (GSourceFunc)_update_geometry, widget); | 266 | priv->update_geometry_id = g_timeout_add_seconds (1, (GSourceFunc)_update_geometry, widget); |
227 | 239 | } | 267 | } |
229 | 240 | 268 | ||
230 | 269 | /** | ||
231 | 270 | * Checks if the position of the widget has changed. | ||
232 | 271 | * Upon change it asks the icon to refresh. | ||
233 | 272 | * returns: TRUE when succeeds | ||
234 | 273 | * FALSE when widget isn't an icon | ||
235 | 274 | */ | ||
236 | 241 | static gboolean | 275 | static gboolean |
237 | 242 | _update_geometry(GtkWidget *widget) | 276 | _update_geometry(GtkWidget *widget) |
238 | 243 | { | 277 | { |
239 | 278 | return TRUE; //TODO solve | ||
240 | 279 | |||
241 | 244 | gint x,y; | 280 | gint x,y; |
242 | 245 | TaskIconPrivate *priv; | 281 | TaskIconPrivate *priv; |
243 | 246 | GdkWindow *win; | 282 | GdkWindow *win; |
244 | @@ -251,6 +287,7 @@ | |||
245 | 251 | 287 | ||
246 | 252 | win = gtk_widget_get_window (widget); | 288 | win = gtk_widget_get_window (widget); |
247 | 253 | gdk_window_get_origin (win, &x, &y); | 289 | gdk_window_get_origin (win, &x, &y); |
248 | 290 | |||
249 | 254 | if(priv->old_x != x || priv->old_y != y) | 291 | if(priv->old_x != x || priv->old_y != y) |
250 | 255 | { | 292 | { |
251 | 256 | priv->old_x = x; | 293 | priv->old_x = x; |
252 | @@ -260,7 +297,86 @@ | |||
253 | 260 | 297 | ||
254 | 261 | return TRUE; | 298 | return TRUE; |
255 | 262 | } | 299 | } |
257 | 263 | 300 | ||
258 | 301 | /** | ||
259 | 302 | * Set the icon geometry of the windows in a task-icon. | ||
260 | 303 | * This equals to the minimize position of the window. | ||
261 | 304 | * TODO: not done (part2) | ||
262 | 305 | */ | ||
263 | 306 | static gboolean | ||
264 | 307 | task_icon_refresh_geometry (TaskIcon *icon) | ||
265 | 308 | { | ||
266 | 309 | TaskSettings *settings; | ||
267 | 310 | TaskIconPrivate *priv; | ||
268 | 311 | GtkWidget *widget; | ||
269 | 312 | GdkWindow *win; | ||
270 | 313 | GSList *w; | ||
271 | 314 | gint x, y, ww, width, height; | ||
272 | 315 | gint i = 0, len = 0; | ||
273 | 316 | |||
274 | 317 | g_return_val_if_fail (TASK_IS_ICON (icon), FALSE); | ||
275 | 318 | |||
276 | 319 | priv = icon->priv; | ||
277 | 320 | widget = GTK_WIDGET (icon); | ||
278 | 321 | |||
279 | 322 | //get the position of the widget | ||
280 | 323 | win = gtk_widget_get_window (widget); | ||
281 | 324 | gdk_window_get_origin (win, &x, &y); | ||
282 | 325 | |||
283 | 326 | settings = task_settings_get_default (); | ||
284 | 327 | |||
285 | 328 | switch (settings->orient) | ||
286 | 329 | { | ||
287 | 330 | case AWN_ORIENTATION_RIGHT: | ||
288 | 331 | case AWN_ORIENTATION_LEFT: | ||
289 | 332 | ww = GTK_WIDGET (icon)->allocation.height; | ||
290 | 333 | break; | ||
291 | 334 | case AWN_ORIENTATION_TOP: | ||
292 | 335 | case AWN_ORIENTATION_BOTTOM: | ||
293 | 336 | ww = GTK_WIDGET (icon)->allocation.width; | ||
294 | 337 | break; | ||
295 | 338 | default: | ||
296 | 339 | g_error ("Orientation isn't right, left, top, bottom ??"); | ||
297 | 340 | break; | ||
298 | 341 | } | ||
299 | 342 | |||
300 | 343 | /* FIXME: Do something clever here to allow the user to "scrub" the icon | ||
301 | 344 | * for the windows. | ||
302 | 345 | */ | ||
303 | 346 | len = g_slist_length (priv->items); | ||
304 | 347 | ww = ww/len; | ||
305 | 348 | for (w = priv->items; w; w = w->next) | ||
306 | 349 | { | ||
307 | 350 | if (!TASK_IS_WINDOW (w->data)) continue; | ||
308 | 351 | |||
309 | 352 | TaskWindow *window = TASK_WINDOW (w->data); | ||
310 | 353 | |||
311 | 354 | switch (settings->orient) | ||
312 | 355 | { | ||
313 | 356 | case AWN_ORIENTATION_RIGHT: | ||
314 | 357 | width = settings->panel_size+settings->offset; | ||
315 | 358 | height = ww + (i*ww); | ||
316 | 359 | break; | ||
317 | 360 | case AWN_ORIENTATION_LEFT: | ||
318 | 361 | width = settings->panel_size+settings->offset; | ||
319 | 362 | height = ww + (i*ww); | ||
320 | 363 | break; | ||
321 | 364 | case AWN_ORIENTATION_TOP: | ||
322 | 365 | width = ww + (i*ww); | ||
323 | 366 | height = settings->panel_size+settings->offset; | ||
324 | 367 | break; | ||
325 | 368 | default: | ||
326 | 369 | width = ww + (i*ww); | ||
327 | 370 | height = settings->panel_size+settings->offset; | ||
328 | 371 | break; | ||
329 | 372 | } | ||
330 | 373 | task_window_set_icon_geometry (window, x, y, | ||
331 | 374 | width, | ||
332 | 375 | height); | ||
333 | 376 | i++; | ||
334 | 377 | } | ||
335 | 378 | return FALSE; | ||
336 | 379 | } | ||
337 | 264 | 380 | ||
338 | 265 | static void | 381 | static void |
339 | 266 | task_icon_class_init (TaskIconClass *klass) | 382 | task_icon_class_init (TaskIconClass *klass) |
340 | @@ -272,7 +388,7 @@ | |||
341 | 272 | obj_class->constructed = task_icon_constructed; | 388 | obj_class->constructed = task_icon_constructed; |
342 | 273 | obj_class->set_property = task_icon_set_property; | 389 | obj_class->set_property = task_icon_set_property; |
343 | 274 | obj_class->get_property = task_icon_get_property; | 390 | obj_class->get_property = task_icon_get_property; |
345 | 275 | obj_class->dispose = task_icon_dispose; | 391 | obj_class->dispose = task_icon_dispose; |
346 | 276 | obj_class->finalize = task_icon_finalize; | 392 | obj_class->finalize = task_icon_finalize; |
347 | 277 | 393 | ||
348 | 278 | wid_class->configure_event = task_icon_configure_event; | 394 | wid_class->configure_event = task_icon_configure_event; |
349 | @@ -285,15 +401,7 @@ | |||
350 | 285 | wid_class->drag_leave = task_icon_dest_drag_leave; | 401 | wid_class->drag_leave = task_icon_dest_drag_leave; |
351 | 286 | wid_class->drag_data_received = task_icon_dest_drag_data_received; | 402 | wid_class->drag_data_received = task_icon_dest_drag_data_received; |
352 | 287 | 403 | ||
353 | 288 | |||
354 | 289 | /* Install properties first */ | 404 | /* Install properties first */ |
355 | 290 | pspec = g_param_spec_object ("taskwindow", | ||
356 | 291 | "TaskWindow", | ||
357 | 292 | "TaskWindow", | ||
358 | 293 | TASK_TYPE_WINDOW, | ||
359 | 294 | G_PARAM_READWRITE); | ||
360 | 295 | g_object_class_install_property (obj_class, PROP_WINDOW, pspec); | ||
361 | 296 | |||
362 | 297 | pspec = g_param_spec_boolean ("draggable", | 405 | pspec = g_param_spec_boolean ("draggable", |
363 | 298 | "Draggable", | 406 | "Draggable", |
364 | 299 | "TaskIcon is draggable?", | 407 | "TaskIcon is draggable?", |
365 | @@ -302,11 +410,11 @@ | |||
366 | 302 | g_object_class_install_property (obj_class, PROP_DRAGGABLE, pspec); | 410 | g_object_class_install_property (obj_class, PROP_DRAGGABLE, pspec); |
367 | 303 | 411 | ||
368 | 304 | /* Install signals */ | 412 | /* Install signals */ |
371 | 305 | _icon_signals[ENSURE_LAYOUT] = | 413 | _icon_signals[VISIBLE_CHANGED] = |
372 | 306 | g_signal_new ("ensure-layout", | 414 | g_signal_new ("visible_changed", |
373 | 307 | G_OBJECT_CLASS_TYPE (obj_class), | 415 | G_OBJECT_CLASS_TYPE (obj_class), |
374 | 308 | G_SIGNAL_RUN_LAST, | 416 | G_SIGNAL_RUN_LAST, |
376 | 309 | G_STRUCT_OFFSET (TaskIconClass, ensure_layout), | 417 | G_STRUCT_OFFSET (TaskIconClass, visible_changed), |
377 | 310 | NULL, NULL, | 418 | NULL, NULL, |
378 | 311 | g_cclosure_marshal_VOID__VOID, | 419 | g_cclosure_marshal_VOID__VOID, |
379 | 312 | G_TYPE_NONE, 0); | 420 | G_TYPE_NONE, 0); |
380 | @@ -368,11 +476,17 @@ | |||
381 | 368 | g_signal_connect (G_OBJECT (priv->dialog),"focus-out-event", | 476 | g_signal_connect (G_OBJECT (priv->dialog),"focus-out-event", |
382 | 369 | G_CALLBACK (task_icon_dialog_unfocus),NULL); | 477 | G_CALLBACK (task_icon_dialog_unfocus),NULL); |
383 | 370 | priv->icon = NULL; | 478 | priv->icon = NULL; |
385 | 371 | priv->windows = NULL; | 479 | priv->items = NULL; |
386 | 372 | priv->drag_tag = 0; | 480 | priv->drag_tag = 0; |
387 | 373 | priv->drag_motion = FALSE; | 481 | priv->drag_motion = FALSE; |
388 | 374 | priv->gets_dragged = FALSE; | 482 | priv->gets_dragged = FALSE; |
389 | 375 | priv->update_geometry_id = 0; | 483 | priv->update_geometry_id = 0; |
390 | 484 | priv->shown_items = 0; | ||
391 | 485 | priv->needs_attention = 0; | ||
392 | 486 | priv->is_active = 0; | ||
393 | 487 | priv->main_item = NULL; | ||
394 | 488 | priv->visible = FALSE; | ||
395 | 489 | priv->overlay_text = NULL; | ||
396 | 376 | 490 | ||
397 | 377 | awn_icon_set_orientation (AWN_ICON (icon), AWN_ORIENTATION_BOTTOM); | 491 | awn_icon_set_orientation (AWN_ICON (icon), AWN_ORIENTATION_BOTTOM); |
398 | 378 | 492 | ||
399 | @@ -394,88 +508,46 @@ | |||
400 | 394 | GDK_ACTION_MOVE); | 508 | GDK_ACTION_MOVE); |
401 | 395 | } | 509 | } |
402 | 396 | 510 | ||
403 | 511 | /** | ||
404 | 512 | * Creates a new TaskIcon, hides it and returns it. | ||
405 | 513 | * (Hiding is because there are no visible TaskItems yet in the TaskIcon) | ||
406 | 514 | */ | ||
407 | 397 | GtkWidget * | 515 | GtkWidget * |
409 | 398 | task_icon_new_for_window (TaskWindow *window) | 516 | task_icon_new () |
410 | 399 | { | 517 | { |
418 | 400 | GtkWidget *icon = NULL; | 518 | GtkWidget *icon = g_object_new (TASK_TYPE_ICON, NULL); |
419 | 401 | 519 | gtk_widget_hide (icon); | |
420 | 402 | g_return_val_if_fail (TASK_IS_WINDOW (window), NULL); | 520 | |
421 | 403 | 521 | //BUG: AwnApplet calls upon start gtk_widget_show_all. So even when gtk_widget_hide | |
422 | 404 | icon = g_object_new (TASK_TYPE_ICON, | 522 | // gets called, it will get shown. So I'm forcing it to not listen to |
423 | 405 | "taskwindow", window, | 523 | // 'gtk_widget_show_all' with this function. FIXME: improve AwnApplet |
424 | 406 | NULL); | 524 | gtk_widget_set_no_show_all (icon, TRUE); |
425 | 525 | |||
426 | 407 | return icon; | 526 | return icon; |
427 | 408 | } | 527 | } |
428 | 409 | 528 | ||
431 | 410 | /* | 529 | /** |
432 | 411 | * Public Functions | 530 | * The name of the main TaskItem in this TaskIcon changed. |
433 | 531 | * So update the tooltip text. | ||
434 | 412 | */ | 532 | */ |
491 | 413 | gboolean | 533 | static void |
492 | 414 | task_icon_is_skip_taskbar (TaskIcon *icon) | 534 | on_main_item_name_changed (TaskItem *item, |
493 | 415 | { | 535 | const gchar *name, |
494 | 416 | g_return_val_if_fail (TASK_IS_ICON (icon), FALSE); | 536 | TaskIcon *icon) |
439 | 417 | |||
440 | 418 | /*if (TASK_IS_LAUNCHER_WINDOW (icon->priv->windows->data)) | ||
441 | 419 | return FALSE;*/ | ||
442 | 420 | |||
443 | 421 | if (icon->priv->windows) | ||
444 | 422 | return task_window_is_hidden (icon->priv->windows->data); | ||
445 | 423 | |||
446 | 424 | return FALSE; | ||
447 | 425 | } | ||
448 | 426 | |||
449 | 427 | gboolean | ||
450 | 428 | task_icon_is_in_viewport (TaskIcon *icon, WnckWorkspace *space) | ||
451 | 429 | { | ||
452 | 430 | g_return_val_if_fail (TASK_IS_ICON (icon), FALSE); | ||
453 | 431 | |||
454 | 432 | /*if (TASK_IS_LAUNCHER_WINDOW (icon->priv->windows->data)) | ||
455 | 433 | return TRUE;*/ | ||
456 | 434 | |||
457 | 435 | if (icon->priv->windows) | ||
458 | 436 | return task_window_is_on_workspace (icon->priv->windows->data, space); | ||
459 | 437 | |||
460 | 438 | return TRUE; | ||
461 | 439 | } | ||
462 | 440 | |||
463 | 441 | static void | ||
464 | 442 | window_closed (TaskIcon *icon, TaskWindow *old_window) | ||
465 | 443 | { | ||
466 | 444 | TaskIconPrivate *priv; | ||
467 | 445 | |||
468 | 446 | g_return_if_fail (TASK_IS_ICON (icon)); | ||
469 | 447 | g_return_if_fail (TASK_IS_WINDOW (old_window)); | ||
470 | 448 | priv = icon->priv; | ||
471 | 449 | |||
472 | 450 | if (! TASK_IS_LAUNCHER(old_window)) | ||
473 | 451 | { | ||
474 | 452 | priv->windows = g_slist_remove (priv->windows, old_window); | ||
475 | 453 | } | ||
476 | 454 | |||
477 | 455 | if (g_slist_length (priv->windows) == 0) | ||
478 | 456 | { | ||
479 | 457 | gtk_widget_destroy (GTK_WIDGET (icon)); | ||
480 | 458 | } | ||
481 | 459 | else | ||
482 | 460 | { | ||
483 | 461 | /* Load up with new icon etc */ | ||
484 | 462 | } | ||
485 | 463 | } | ||
486 | 464 | |||
487 | 465 | static void | ||
488 | 466 | on_window_name_changed (TaskWindow *window, | ||
489 | 467 | const gchar *name, | ||
490 | 468 | TaskIcon *icon) | ||
495 | 469 | { | 537 | { |
496 | 470 | g_return_if_fail (TASK_IS_ICON (icon)); | 538 | g_return_if_fail (TASK_IS_ICON (icon)); |
497 | 471 | 539 | ||
498 | 472 | awn_icon_set_tooltip_text (AWN_ICON (icon), name); | 540 | awn_icon_set_tooltip_text (AWN_ICON (icon), name); |
499 | 473 | } | 541 | } |
500 | 474 | 542 | ||
501 | 543 | /** | ||
502 | 544 | * The icon of the main TaskItem in this TaskIcon changed. | ||
503 | 545 | * So update the icon of the TaskIcon (AwnIcon). | ||
504 | 546 | */ | ||
505 | 475 | static void | 547 | static void |
509 | 476 | on_window_icon_changed (TaskWindow *window, | 548 | on_main_item_icon_changed (TaskItem *item, |
510 | 477 | GdkPixbuf *pixbuf, | 549 | GdkPixbuf *pixbuf, |
511 | 478 | TaskIcon *icon) | 550 | TaskIcon *icon) |
512 | 479 | { | 551 | { |
513 | 480 | TaskIconPrivate *priv; | 552 | TaskIconPrivate *priv; |
514 | 481 | 553 | ||
515 | @@ -490,263 +562,460 @@ | |||
516 | 490 | awn_icon_set_from_pixbuf (AWN_ICON (icon), priv->icon); | 562 | awn_icon_set_from_pixbuf (AWN_ICON (icon), priv->icon); |
517 | 491 | } | 563 | } |
518 | 492 | 564 | ||
519 | 565 | /** | ||
520 | 566 | * The visibility of the main TaskItem in this TaskIcon changed. | ||
521 | 567 | * Because normally the main TaskItem should always be visible, | ||
522 | 568 | * it searches after a new main TaskItem. | ||
523 | 569 | */ | ||
524 | 570 | static void | ||
525 | 571 | on_main_item_visible_changed (TaskItem *item, | ||
526 | 572 | gboolean visible, | ||
527 | 573 | TaskIcon *icon) | ||
528 | 574 | { | ||
529 | 575 | g_return_if_fail (TASK_IS_ICON (icon)); | ||
530 | 576 | |||
531 | 577 | /* the main TaskItem should have been visible, so if | ||
532 | 578 | the main TaskItem becomes visible only now, | ||
533 | 579 | it indicates a bug. | ||
534 | 580 | FIXME: this is possible atm in TaskWindow */ | ||
535 | 581 | if (visible) return; | ||
536 | 582 | |||
537 | 583 | task_icon_search_main_item (icon); | ||
538 | 584 | } | ||
539 | 585 | |||
540 | 586 | /** | ||
541 | 587 | * Notify that the icon that a window is closed. The window gets | ||
542 | 588 | * removed from the list and when this icon doesn't has any | ||
543 | 589 | * launchers and no windows it will get destroyed. | ||
544 | 590 | */ | ||
545 | 591 | static void | ||
546 | 592 | _destroyed_task_item (TaskIcon *icon, TaskItem *old_item) | ||
547 | 593 | { | ||
548 | 594 | TaskIconPrivate *priv; | ||
549 | 595 | |||
550 | 596 | g_return_if_fail (TASK_IS_ICON (icon)); | ||
551 | 597 | g_return_if_fail (TASK_IS_ITEM (old_item)); | ||
552 | 598 | |||
553 | 599 | priv = icon->priv; | ||
554 | 600 | priv->items = g_slist_remove (priv->items, old_item); | ||
555 | 601 | |||
556 | 602 | if (old_item == priv->main_item) | ||
557 | 603 | { | ||
558 | 604 | task_icon_search_main_item (icon); | ||
559 | 605 | } | ||
560 | 606 | |||
561 | 607 | task_icon_refresh_visible (icon); | ||
562 | 608 | |||
563 | 609 | if (g_slist_length (priv->items) == 0) | ||
564 | 610 | { | ||
565 | 611 | gtk_widget_destroy (GTK_WIDGET (icon)); | ||
566 | 612 | } | ||
567 | 613 | else | ||
568 | 614 | { | ||
569 | 615 | /* TODO: Load up with new icon etc */ | ||
570 | 616 | } | ||
571 | 617 | } | ||
572 | 618 | |||
573 | 619 | /** | ||
574 | 620 | * Searches for a new main item. | ||
575 | 621 | * A main item is used for displaying its icon and also the text (if there is only one item) | ||
576 | 622 | * Attention: this function doesn't check if it is needed to switch to a new main item. | ||
577 | 623 | */ | ||
578 | 624 | static void | ||
579 | 625 | task_icon_search_main_item (TaskIcon *icon) | ||
580 | 626 | { | ||
581 | 627 | TaskIconPrivate *priv; | ||
582 | 628 | GSList *i; | ||
583 | 629 | TaskItem *main_item = NULL; | ||
584 | 630 | |||
585 | 631 | g_return_if_fail (TASK_IS_ICON (icon)); | ||
586 | 632 | |||
587 | 633 | priv = icon->priv; | ||
588 | 634 | |||
589 | 635 | for (i = priv->items; i; i = i->next) | ||
590 | 636 | { | ||
591 | 637 | TaskItem *item = i->data; | ||
592 | 638 | |||
593 | 639 | if (!task_item_is_visible (item)) continue; | ||
594 | 640 | |||
595 | 641 | main_item = item; | ||
596 | 642 | break; | ||
597 | 643 | } | ||
598 | 644 | |||
599 | 645 | //remove signals of old main_item | ||
600 | 646 | if (priv->main_item) | ||
601 | 647 | { | ||
602 | 648 | g_signal_handlers_disconnect_by_func(priv->main_item, | ||
603 | 649 | G_CALLBACK (on_main_item_name_changed), icon); | ||
604 | 650 | g_signal_handlers_disconnect_by_func(priv->main_item, | ||
605 | 651 | G_CALLBACK (on_main_item_icon_changed), icon); | ||
606 | 652 | g_signal_handlers_disconnect_by_func(priv->main_item, | ||
607 | 653 | G_CALLBACK (on_main_item_visible_changed), icon); | ||
608 | 654 | priv->main_item = NULL; | ||
609 | 655 | } | ||
610 | 656 | |||
611 | 657 | if (main_item) | ||
612 | 658 | { | ||
613 | 659 | priv->main_item = main_item; | ||
614 | 660 | priv->icon = task_item_get_icon (priv->main_item); | ||
615 | 661 | awn_icon_set_from_pixbuf (AWN_ICON (icon), priv->icon); | ||
616 | 662 | awn_icon_set_tooltip_text (AWN_ICON (icon), | ||
617 | 663 | task_item_get_name (priv->main_item)); | ||
618 | 664 | g_signal_connect (priv->main_item, "name-changed", | ||
619 | 665 | G_CALLBACK (on_main_item_name_changed), icon); | ||
620 | 666 | g_signal_connect (priv->main_item, "icon-changed", | ||
621 | 667 | G_CALLBACK (on_main_item_icon_changed), icon); | ||
622 | 668 | g_signal_connect (priv->main_item, "visible-changed", | ||
623 | 669 | G_CALLBACK (on_main_item_visible_changed), icon); | ||
624 | 670 | } | ||
625 | 671 | } | ||
626 | 672 | |||
627 | 673 | /** | ||
628 | 674 | * | ||
629 | 675 | */ | ||
630 | 676 | static void | ||
631 | 677 | task_icon_refresh_visible (TaskIcon *icon) | ||
632 | 678 | { | ||
633 | 679 | TaskIconPrivate *priv; | ||
634 | 680 | GSList *w; | ||
635 | 681 | guint count = 0; | ||
636 | 682 | guint count_windows = 0; | ||
637 | 683 | |||
638 | 684 | g_return_if_fail (TASK_IS_ICON (icon)); | ||
639 | 685 | |||
640 | 686 | priv = icon->priv; | ||
641 | 687 | |||
642 | 688 | for (w = priv->items; w; w = w->next) | ||
643 | 689 | { | ||
644 | 690 | TaskItem *item = w->data; | ||
645 | 691 | |||
646 | 692 | if (!task_item_is_visible (item)) continue; | ||
647 | 693 | count++; | ||
648 | 694 | |||
649 | 695 | if (!TASK_IS_WINDOW (item)) continue; | ||
650 | 696 | count_windows++; | ||
651 | 697 | } | ||
652 | 698 | |||
653 | 699 | awn_icon_set_indicator_count (AWN_ICON (icon), (count_windows>0) ? 1 : 0); | ||
654 | 700 | |||
655 | 701 | if (count != priv->shown_items) | ||
656 | 702 | { | ||
657 | 703 | g_debug("shown items changed: %i", count); | ||
658 | 704 | |||
659 | 705 | if (count > 1) | ||
660 | 706 | { | ||
661 | 707 | if (!priv->overlay_text) | ||
662 | 708 | { | ||
663 | 709 | priv->overlay_text = awn_overlay_text_new (); | ||
664 | 710 | awn_overlayable_add_overlay (AWN_OVERLAYABLE (icon), | ||
665 | 711 | AWN_OVERLAY (priv->overlay_text)); | ||
666 | 712 | g_object_set (G_OBJECT (priv->overlay_text), | ||
667 | 713 | "gravity", GDK_GRAVITY_SOUTH_EAST, | ||
668 | 714 | "font-sizing", AWN_FONT_SIZE_LARGE, | ||
669 | 715 | "text_color_astr", "#FFFFFFFF", | ||
670 | 716 | "apply-effects", TRUE, | ||
671 | 717 | NULL); | ||
672 | 718 | } | ||
673 | 719 | gchar* count_str = g_strdup_printf ("%i",count); | ||
674 | 720 | g_object_set (G_OBJECT (priv->overlay_text), | ||
675 | 721 | "text", count_str, | ||
676 | 722 | NULL); | ||
677 | 723 | g_free (count_str); | ||
678 | 724 | } | ||
679 | 725 | else | ||
680 | 726 | { | ||
681 | 727 | if (priv->overlay_text) | ||
682 | 728 | { | ||
683 | 729 | awn_overlayable_remove_overlay (AWN_OVERLAYABLE (icon), | ||
684 | 730 | AWN_OVERLAY (priv->overlay_text)); | ||
685 | 731 | g_object_unref (priv->overlay_text); | ||
686 | 732 | priv->overlay_text = NULL; | ||
687 | 733 | } | ||
688 | 734 | } | ||
689 | 735 | |||
690 | 736 | if (count == 0) | ||
691 | 737 | { | ||
692 | 738 | priv->visible = FALSE; | ||
693 | 739 | } | ||
694 | 740 | else | ||
695 | 741 | { | ||
696 | 742 | if (!priv->main_item) | ||
697 | 743 | task_icon_search_main_item (icon); | ||
698 | 744 | |||
699 | 745 | priv->visible = TRUE; | ||
700 | 746 | } | ||
701 | 747 | |||
702 | 748 | g_signal_emit (icon, _icon_signals[VISIBLE_CHANGED], 0); | ||
703 | 749 | } | ||
704 | 750 | |||
705 | 751 | priv->shown_items = count; | ||
706 | 752 | } | ||
707 | 753 | |||
708 | 754 | /** | ||
709 | 755 | * The 'active' state of a TaskWindow changed. | ||
710 | 756 | * If this is the only TaskWindow that's active, | ||
711 | 757 | * the TaskIcon will get an active state. | ||
712 | 758 | * If it the last TaskWindow that isn't active anymore | ||
713 | 759 | * the TaskIcon will get an inactive state too. | ||
714 | 760 | * STATE: adjusted | ||
715 | 761 | * PROBLEM: It shouldn't get called when the state didn't change. | ||
716 | 762 | Else the count of windows that need have the active state will be off. | ||
717 | 763 | */ | ||
718 | 493 | static void | 764 | static void |
719 | 494 | on_window_active_changed (TaskWindow *window, | 765 | on_window_active_changed (TaskWindow *window, |
720 | 495 | gboolean is_active, | 766 | gboolean is_active, |
721 | 496 | TaskIcon *icon) | 767 | TaskIcon *icon) |
722 | 497 | { | 768 | { |
723 | 769 | TaskIconPrivate *priv; | ||
724 | 770 | GSList *w; | ||
725 | 771 | guint count = 0; | ||
726 | 772 | |||
727 | 498 | g_return_if_fail (TASK_IS_ICON (icon)); | 773 | g_return_if_fail (TASK_IS_ICON (icon)); |
728 | 499 | 774 | ||
730 | 500 | awn_icon_set_is_active (AWN_ICON (icon), is_active); | 775 | priv = icon->priv; |
731 | 776 | |||
732 | 777 | for (w = priv->items; w; w = w->next) | ||
733 | 778 | { | ||
734 | 779 | TaskItem *item = w->data; | ||
735 | 780 | |||
736 | 781 | if (!TASK_IS_WINDOW (item)) continue; | ||
737 | 782 | if (!task_item_is_visible (item)) continue; | ||
738 | 783 | if (!task_window_is_active (TASK_WINDOW (item))) continue; | ||
739 | 784 | |||
740 | 785 | count++; | ||
741 | 786 | } | ||
742 | 787 | |||
743 | 788 | if (priv->is_active == 0 && count == 1) | ||
744 | 789 | { | ||
745 | 790 | awn_icon_set_is_active (AWN_ICON (icon), TRUE); | ||
746 | 791 | } | ||
747 | 792 | else if (priv->is_active == 1 && count == 0) | ||
748 | 793 | { | ||
749 | 794 | awn_icon_set_is_active (AWN_ICON (icon), FALSE); | ||
750 | 795 | } | ||
751 | 796 | |||
752 | 797 | priv->is_active = count; | ||
753 | 501 | } | 798 | } |
754 | 502 | 799 | ||
755 | 800 | /** | ||
756 | 801 | * The 'needs attention' state of a window changed. | ||
757 | 802 | * If a window needs attention and there isn't one yet, it will | ||
758 | 803 | * start the animation. When every window don't need attention anymore | ||
759 | 804 | * it will stop the animation. | ||
760 | 805 | * STATE: adjusted | ||
761 | 806 | * TODO: h4writer - check if it is possible to interupt animation mid-air, | ||
762 | 807 | * and let it start again, if there is a 2nd/3rd window that needs attention. | ||
763 | 808 | * BUG: when icon becomes visible again it needs to be checked if it needs attention again. | ||
764 | 809 | */ | ||
765 | 503 | static void | 810 | static void |
766 | 504 | on_window_needs_attention_changed (TaskWindow *window, | 811 | on_window_needs_attention_changed (TaskWindow *window, |
767 | 505 | gboolean needs_attention, | 812 | gboolean needs_attention, |
768 | 506 | TaskIcon *icon) | 813 | TaskIcon *icon) |
769 | 507 | { | 814 | { |
770 | 815 | TaskIconPrivate *priv; | ||
771 | 816 | GSList *w; | ||
772 | 817 | guint count = 0; | ||
773 | 818 | |||
774 | 508 | g_return_if_fail (TASK_IS_ICON (icon)); | 819 | g_return_if_fail (TASK_IS_ICON (icon)); |
775 | 509 | 820 | ||
777 | 510 | if (needs_attention) | 821 | priv = icon->priv; |
778 | 822 | |||
779 | 823 | for (w = priv->items; w; w = w->next) | ||
780 | 824 | { | ||
781 | 825 | TaskItem *item = w->data; | ||
782 | 826 | |||
783 | 827 | if (!TASK_IS_WINDOW (item)) continue; | ||
784 | 828 | if (!task_item_is_visible (item)) continue; | ||
785 | 829 | if (!task_window_needs_attention (TASK_WINDOW (item))) continue; | ||
786 | 830 | |||
787 | 831 | count++; | ||
788 | 832 | } | ||
789 | 833 | |||
790 | 834 | if (priv->needs_attention == 0 && count == 1) | ||
791 | 835 | { | ||
792 | 511 | awn_icon_set_effect (AWN_ICON (icon),AWN_EFFECT_ATTENTION); | 836 | awn_icon_set_effect (AWN_ICON (icon),AWN_EFFECT_ATTENTION); |
795 | 512 | else | 837 | } |
796 | 513 | awn_effects_stop (awn_overlayable_get_effects (AWN_OVERLAYABLE (icon)), | 838 | else if (priv->needs_attention == 1 && count == 0) |
797 | 839 | { | ||
798 | 840 | awn_effects_stop (awn_overlayable_get_effects (AWN_OVERLAYABLE (icon)), | ||
799 | 514 | AWN_EFFECT_ATTENTION); | 841 | AWN_EFFECT_ATTENTION); |
808 | 515 | } | 842 | } |
801 | 516 | |||
802 | 517 | static void | ||
803 | 518 | on_window_workspace_changed (TaskWindow *window, | ||
804 | 519 | WnckWorkspace *space, | ||
805 | 520 | TaskIcon *icon) | ||
806 | 521 | { | ||
807 | 522 | g_return_if_fail (TASK_IS_ICON (icon)); | ||
809 | 523 | 843 | ||
826 | 524 | g_signal_emit (icon, _icon_signals[ENSURE_LAYOUT], 0); | 844 | priv->needs_attention = count; |
827 | 525 | } | 845 | } |
828 | 526 | 846 | ||
829 | 527 | static void | 847 | /** |
830 | 528 | on_window_message_changed (TaskWindow *window, | 848 | * When the progress of a TaskWindow has changed, |
831 | 529 | const gchar *message, | 849 | * it will recalculate the process of all the |
832 | 530 | TaskIcon *icon) | 850 | * TaskWindows this TaskIcon contains. |
833 | 531 | { | 851 | * STATE: adjusted |
834 | 532 | g_return_if_fail (TASK_IS_ICON (icon)); | 852 | */ |
835 | 533 | 853 | static void | |
836 | 534 | awn_icon_set_message (AWN_ICON (icon), message); | 854 | on_window_progress_changed (TaskWindow *window, |
837 | 535 | } | 855 | gfloat adjusted_progress, |
822 | 536 | |||
823 | 537 | static void | ||
824 | 538 | on_window_progress_changed (TaskWindow *window, | ||
825 | 539 | gfloat progress, | ||
838 | 540 | TaskIcon *icon) | 856 | TaskIcon *icon) |
839 | 541 | { | 857 | { |
920 | 542 | g_return_if_fail (TASK_IS_ICON (icon)); | 858 | TaskIconPrivate *priv; |
921 | 543 | 859 | GSList *w; | |
922 | 544 | awn_icon_set_progress (AWN_ICON (icon), progress); | 860 | gfloat progress = 0; |
923 | 545 | } | 861 | guint len = 0; |
924 | 546 | 862 | ||
925 | 547 | static void | 863 | g_return_if_fail (TASK_IS_ICON (icon)); |
926 | 548 | on_window_hidden_changed (TaskWindow *window, | 864 | |
927 | 549 | gboolean is_hidden, | 865 | priv = icon->priv; |
928 | 550 | TaskIcon *icon) | 866 | |
929 | 551 | { | 867 | for (w = priv->items; w; w = w->next) |
930 | 552 | g_return_if_fail (TASK_IS_ICON (icon)); | 868 | { |
931 | 553 | 869 | TaskItem *item = w->data; | |
932 | 554 | g_signal_emit (icon, _icon_signals[ENSURE_LAYOUT], 0); | 870 | |
933 | 555 | } | 871 | if (!TASK_IS_WINDOW (item)) continue; |
934 | 556 | 872 | if (!task_item_is_visible (item)) continue; | |
935 | 557 | static void | 873 | |
936 | 558 | on_window_running_changed (TaskWindow *window, | 874 | if (progress != -1) |
937 | 559 | gboolean is_running, | 875 | { |
938 | 560 | TaskIcon *icon) | 876 | progress += task_window_get_progress (TASK_WINDOW (item)); |
939 | 561 | { | 877 | len++; |
940 | 562 | g_return_if_fail (TASK_IS_ICON (icon)); | 878 | } |
941 | 563 | awn_icon_set_indicator_count (AWN_ICON (icon), is_running ? 1 : 0); | 879 | } |
942 | 564 | } | 880 | |
943 | 565 | 881 | awn_icon_set_progress (AWN_ICON (icon), progress/len); | |
944 | 566 | void | 882 | } |
945 | 567 | task_icon_remove_window (TaskIcon *icon, | 883 | |
946 | 568 | WnckWindow *window) | 884 | /** |
947 | 569 | { | 885 | * When a TaskWindow becomes visible or invisible, |
948 | 570 | GSList * w; | 886 | * update the number of shown windows. |
949 | 571 | TaskIconPrivate *priv; | 887 | * If because of that the icon has no shown TaskWindows |
950 | 572 | 888 | * anymore it will get hidden. If there was no shown | |
951 | 573 | g_return_if_fail (TASK_IS_ICON (icon)); | 889 | * TaskWindow and now the first one gets visible, |
952 | 574 | g_return_if_fail (WNCK_IS_WINDOW (window)); | 890 | * then show TaskIcon. |
953 | 575 | priv = icon->priv; | 891 | * STATE: adjusted |
954 | 576 | for (w = priv->windows;w;w=w->next) | 892 | */ |
955 | 577 | { | 893 | static void |
956 | 578 | TaskWindow * task_win = w->data; | 894 | on_item_visible_changed (TaskItem *item, |
957 | 579 | if (! TASK_IS_WINDOW(task_win) ) | 895 | gfloat visible, |
958 | 580 | { | 896 | TaskIcon *icon) |
959 | 581 | continue; | 897 | { |
960 | 582 | } | 898 | g_return_if_fail (TASK_IS_ICON (icon)); |
961 | 583 | if (task_win->priv->window == window) | 899 | g_return_if_fail (TASK_IS_ITEM (item)); |
962 | 584 | { | 900 | |
963 | 585 | g_assert (TASK_IS_WINDOW(task_win)); | 901 | task_icon_refresh_visible (icon); |
964 | 586 | if (! TASK_IS_LAUNCHER(task_win) ) | 902 | } |
965 | 587 | { | 903 | |
966 | 588 | priv->windows = g_slist_remove (priv->windows, task_win); | 904 | /** |
967 | 589 | } | 905 | * Public Functions |
968 | 590 | } | 906 | */ |
969 | 591 | } | 907 | |
970 | 592 | } | 908 | /** |
971 | 593 | 909 | * Returns whetever this icon should be visible. | |
972 | 594 | /* | 910 | * (That means it should contain atleast 1 visible item) |
973 | 595 | FIXME 2nd arg isn't the WnckWindow | 911 | */ |
974 | 596 | */ | 912 | gboolean |
975 | 597 | static void | 913 | task_icon_is_visible (TaskIcon *icon) |
976 | 598 | _task_icon_launcher_change (TaskLauncher * launcher, | 914 | { |
977 | 599 | WnckWindow * wnck_win, | 915 | g_return_val_if_fail (TASK_IS_ICON (icon), FALSE); |
978 | 600 | TaskIcon * icon) | 916 | |
979 | 601 | { | 917 | return icon->priv->visible; |
980 | 602 | GtkWidget * grouped_icon = NULL; | 918 | } |
981 | 603 | if (wnck_win) | 919 | |
982 | 604 | { | 920 | /** |
983 | 605 | TaskWindow * taskwin = task_window_new (TASK_WINDOW(launcher)->priv->window); | 921 | * Returns whetever this icon contains atleast one (visible?) launcher. |
984 | 606 | grouped_icon = task_icon_new_for_window (taskwin); | 922 | * TODO: adapt TaskIcon so it has a guint with the numbers of TaskLaunchers/TaskWindows |
985 | 607 | gtk_widget_show (grouped_icon); | 923 | */ |
986 | 608 | gtk_container_add (GTK_CONTAINER(icon->priv->dialog),grouped_icon); | 924 | gboolean |
987 | 609 | } | 925 | task_icon_contains_launcher (TaskIcon *icon) |
988 | 610 | 926 | { | |
989 | 611 | } | 927 | TaskIconPrivate *priv; |
990 | 612 | 928 | GSList *w; | |
991 | 613 | void | 929 | |
992 | 614 | task_icon_append_window (TaskIcon *icon, | 930 | g_return_val_if_fail (TASK_IS_ICON (icon), FALSE); |
993 | 615 | TaskWindow *window) | 931 | |
994 | 616 | { | 932 | priv = icon->priv; |
995 | 617 | TaskIconPrivate *priv; | 933 | |
996 | 618 | gboolean first_window = FALSE; | 934 | for (w = priv->items; w; w = w->next) |
997 | 619 | static gboolean recursing = FALSE; | 935 | { |
998 | 620 | 936 | TaskItem *item = w->data; | |
999 | 621 | g_assert (window); | 937 | |
1000 | 938 | if (!task_item_is_visible (item)) continue; | ||
1001 | 939 | |||
1002 | 940 | if (TASK_IS_LAUNCHER (item)) | ||
1003 | 941 | return TRUE; | ||
1004 | 942 | } | ||
1005 | 943 | return FALSE; | ||
1006 | 944 | } | ||
1007 | 945 | |||
1008 | 946 | guint | ||
1009 | 947 | task_icon_match_item (TaskIcon *icon, | ||
1010 | 948 | TaskItem *item_to_match) | ||
1011 | 949 | { | ||
1012 | 950 | TaskIconPrivate *priv; | ||
1013 | 951 | GSList *w; | ||
1014 | 952 | guint max_score = 0; | ||
1015 | 953 | |||
1016 | 954 | g_return_val_if_fail (TASK_IS_ICON (icon), 0); | ||
1017 | 955 | g_return_val_if_fail (TASK_IS_ITEM (item_to_match), 0); | ||
1018 | 956 | |||
1019 | 957 | priv = icon->priv; | ||
1020 | 958 | |||
1021 | 959 | for (w = priv->items; w; w = w->next) | ||
1022 | 960 | { | ||
1023 | 961 | TaskItem *item = w->data; | ||
1024 | 962 | guint score; | ||
1025 | 963 | |||
1026 | 964 | if (!task_item_is_visible (item)) continue; | ||
1027 | 965 | |||
1028 | 966 | score = task_item_match (item, item_to_match); | ||
1029 | 967 | if (score > max_score) | ||
1030 | 968 | max_score = score; | ||
1031 | 969 | } | ||
1032 | 970 | |||
1033 | 971 | return max_score; | ||
1034 | 972 | } | ||
1035 | 973 | |||
1036 | 974 | /** | ||
1037 | 975 | * Adds a TaskWindow to this task-icon | ||
1038 | 976 | */ | ||
1039 | 977 | void | ||
1040 | 978 | task_icon_append_item (TaskIcon *icon, | ||
1041 | 979 | TaskItem *item) | ||
1042 | 980 | { | ||
1043 | 981 | TaskIconPrivate *priv; | ||
1044 | 982 | |||
1045 | 983 | g_assert (item); | ||
1046 | 622 | g_assert (icon); | 984 | g_assert (icon); |
1047 | 623 | g_return_if_fail (TASK_IS_ICON (icon)); | 985 | g_return_if_fail (TASK_IS_ICON (icon)); |
1049 | 624 | g_return_if_fail (TASK_IS_WINDOW (window)); | 986 | g_return_if_fail (TASK_IS_ITEM (item)); |
1050 | 987 | |||
1051 | 625 | priv = icon->priv; | 988 | priv = icon->priv; |
1052 | 626 | 989 | ||
1062 | 627 | /* Is this the first, main, window of this icon? */ | 990 | priv->items = g_slist_append (priv->items, item); |
1063 | 628 | if (priv->windows == NULL) | 991 | gtk_widget_show_all (GTK_WIDGET (item)); |
1064 | 629 | first_window = TRUE; | 992 | gtk_container_add (GTK_CONTAINER (priv->dialog), GTK_WIDGET (item)); |
1065 | 630 | 993 | ||
1066 | 631 | priv->windows = g_slist_append (priv->windows, window); | 994 | g_object_weak_ref (G_OBJECT (item), (GWeakNotify)_destroyed_task_item, icon); |
1067 | 632 | g_object_weak_ref (G_OBJECT (window), (GWeakNotify)window_closed, icon); | 995 | |
1068 | 633 | 996 | task_icon_refresh_visible (icon); | |
1069 | 634 | /* If it's the first window, let's set-up our icon accordingly */ | 997 | |
1070 | 635 | if (first_window) | 998 | /* Connect item signals */ |
1071 | 999 | g_signal_connect (item, "visible-changed", | ||
1072 | 1000 | G_CALLBACK (on_item_visible_changed), icon); | ||
1073 | 1001 | |||
1074 | 1002 | /* Connect window signals */ | ||
1075 | 1003 | if (TASK_IS_WINDOW (item)) | ||
1076 | 636 | { | 1004 | { |
1092 | 637 | priv->icon = task_window_get_icon (window); | 1005 | TaskWindow *window = TASK_WINDOW (item); |
1078 | 638 | awn_icon_set_from_pixbuf (AWN_ICON (icon), priv->icon); | ||
1079 | 639 | |||
1080 | 640 | awn_icon_set_tooltip_text (AWN_ICON (icon), task_window_get_name (window)); | ||
1081 | 641 | on_window_needs_attention_changed (window, | ||
1082 | 642 | task_window_needs_attention (window), | ||
1083 | 643 | icon); | ||
1084 | 644 | |||
1085 | 645 | awn_icon_set_indicator_count (AWN_ICON (icon), | ||
1086 | 646 | task_window_get_is_running (window) ? 1 : 0); | ||
1087 | 647 | |||
1088 | 648 | g_signal_connect (window, "name-changed", | ||
1089 | 649 | G_CALLBACK (on_window_name_changed), icon); | ||
1090 | 650 | g_signal_connect (window, "icon-changed", | ||
1091 | 651 | G_CALLBACK (on_window_icon_changed), icon); | ||
1093 | 652 | g_signal_connect (window, "active-changed", | 1006 | g_signal_connect (window, "active-changed", |
1094 | 653 | G_CALLBACK (on_window_active_changed), icon); | 1007 | G_CALLBACK (on_window_active_changed), icon); |
1095 | 654 | g_signal_connect (window, "needs-attention", | 1008 | g_signal_connect (window, "needs-attention", |
1096 | 655 | G_CALLBACK (on_window_needs_attention_changed), icon); | 1009 | G_CALLBACK (on_window_needs_attention_changed), icon); |
1097 | 656 | g_signal_connect (window, "workspace-changed", | ||
1098 | 657 | G_CALLBACK (on_window_workspace_changed), icon); | ||
1099 | 658 | g_signal_connect (window, "message-changed", | ||
1100 | 659 | G_CALLBACK (on_window_message_changed), icon); | ||
1101 | 660 | g_signal_connect (window, "progress-changed", | 1010 | g_signal_connect (window, "progress-changed", |
1102 | 661 | G_CALLBACK (on_window_progress_changed), icon); | 1011 | G_CALLBACK (on_window_progress_changed), icon); |
1191 | 662 | g_signal_connect (window, "hidden-changed", | 1012 | } |
1192 | 663 | G_CALLBACK (on_window_hidden_changed), icon); | 1013 | } |
1193 | 664 | g_signal_connect (window, "running-changed", | 1014 | |
1194 | 665 | G_CALLBACK (on_window_running_changed), icon); | 1015 | /** |
1195 | 666 | } | 1016 | * |
1196 | 667 | 1017 | * TODO: h4writer - adjust 2nd round | |
1197 | 668 | if (!recursing) | 1018 | */ |
1110 | 669 | { | ||
1111 | 670 | recursing = TRUE; | ||
1112 | 671 | GtkWidget * grouped_icon = NULL; | ||
1113 | 672 | if (!TASK_IS_LAUNCHER(window)) | ||
1114 | 673 | { | ||
1115 | 674 | g_assert (window->priv->window); | ||
1116 | 675 | grouped_icon = task_icon_new_for_window (window); | ||
1117 | 676 | } | ||
1118 | 677 | else if (TASK_IS_LAUNCHER(window) ) | ||
1119 | 678 | { | ||
1120 | 679 | TaskWindowPrivate *win_priv = window->priv; | ||
1121 | 680 | g_signal_connect (G_OBJECT(window),"notify::taskwindow", | ||
1122 | 681 | G_CALLBACK(_task_icon_launcher_change),icon); | ||
1123 | 682 | if (win_priv->window) | ||
1124 | 683 | { | ||
1125 | 684 | TaskWindow * taskwin = task_window_new (win_priv->window); | ||
1126 | 685 | grouped_icon = task_icon_new_for_window (taskwin); | ||
1127 | 686 | } | ||
1128 | 687 | } | ||
1129 | 688 | if (grouped_icon) | ||
1130 | 689 | { | ||
1131 | 690 | gtk_container_add (GTK_CONTAINER(priv->dialog),grouped_icon); | ||
1132 | 691 | // g_object_weak_ref (G_OBJECT (window), (GWeakNotify)window_closed, grouped_icon); | ||
1133 | 692 | gtk_widget_show (grouped_icon); | ||
1134 | 693 | } | ||
1135 | 694 | } | ||
1136 | 695 | recursing = FALSE; | ||
1137 | 696 | } | ||
1138 | 697 | |||
1139 | 698 | gboolean | ||
1140 | 699 | task_icon_is_launcher (TaskIcon *icon) | ||
1141 | 700 | { | ||
1142 | 701 | TaskIconPrivate *priv; | ||
1143 | 702 | |||
1144 | 703 | g_return_val_if_fail (TASK_IS_ICON (icon), FALSE); | ||
1145 | 704 | priv = icon->priv; | ||
1146 | 705 | |||
1147 | 706 | if (priv->windows) | ||
1148 | 707 | { | ||
1149 | 708 | /* For now do it this way ?! */ | ||
1150 | 709 | if (TASK_IS_LAUNCHER (priv->windows->data)) | ||
1151 | 710 | return TRUE; | ||
1152 | 711 | } | ||
1153 | 712 | return FALSE; | ||
1154 | 713 | } | ||
1155 | 714 | |||
1156 | 715 | TaskLauncher* | ||
1157 | 716 | task_icon_get_launcher (TaskIcon *icon) | ||
1158 | 717 | { | ||
1159 | 718 | TaskIconPrivate *priv; | ||
1160 | 719 | |||
1161 | 720 | g_return_val_if_fail (TASK_IS_ICON (icon), FALSE); | ||
1162 | 721 | priv = icon->priv; | ||
1163 | 722 | |||
1164 | 723 | if (priv->windows) | ||
1165 | 724 | { | ||
1166 | 725 | /* For now do it this way ?! */ | ||
1167 | 726 | if (TASK_IS_LAUNCHER (priv->windows->data)) | ||
1168 | 727 | return TASK_LAUNCHER(priv->windows->data); | ||
1169 | 728 | } | ||
1170 | 729 | return NULL; | ||
1171 | 730 | } | ||
1172 | 731 | |||
1173 | 732 | TaskWindow* | ||
1174 | 733 | task_icon_get_window (TaskIcon *icon) | ||
1175 | 734 | { | ||
1176 | 735 | TaskIconPrivate *priv; | ||
1177 | 736 | |||
1178 | 737 | g_return_val_if_fail (TASK_IS_ICON (icon), FALSE); | ||
1179 | 738 | priv = icon->priv; | ||
1180 | 739 | |||
1181 | 740 | if (priv->windows) | ||
1182 | 741 | { | ||
1183 | 742 | /* For now do it this way ?! */ | ||
1184 | 743 | // if (TASK_IS_WINDOW (priv->windows->data)) | ||
1185 | 744 | return TASK_WINDOW(priv->windows->data); | ||
1186 | 745 | } | ||
1187 | 746 | return NULL; | ||
1188 | 747 | } | ||
1189 | 748 | |||
1190 | 749 | |||
1198 | 750 | void | 1019 | void |
1199 | 751 | task_icon_refresh_icon (TaskIcon *icon) | 1020 | task_icon_refresh_icon (TaskIcon *icon) |
1200 | 752 | { | 1021 | { |
1201 | @@ -755,87 +1024,9 @@ | |||
1202 | 755 | g_return_if_fail (TASK_IS_ICON (icon)); | 1024 | g_return_if_fail (TASK_IS_ICON (icon)); |
1203 | 756 | priv = icon->priv; | 1025 | priv = icon->priv; |
1204 | 757 | 1026 | ||
1206 | 758 | if (priv->windows && priv->windows->data) | 1027 | if (priv->items && priv->items->data) |
1207 | 759 | awn_icon_set_from_pixbuf (AWN_ICON (icon), | 1028 | awn_icon_set_from_pixbuf (AWN_ICON (icon), |
1287 | 760 | task_window_get_icon (priv->windows->data)); | 1029 | task_item_get_icon (priv->items->data)); |
1209 | 761 | } | ||
1210 | 762 | |||
1211 | 763 | gboolean | ||
1212 | 764 | task_icon_refresh_geometry (TaskIcon *icon) | ||
1213 | 765 | { | ||
1214 | 766 | TaskSettings *settings; | ||
1215 | 767 | TaskIconPrivate *priv; | ||
1216 | 768 | GtkWidget *widget; | ||
1217 | 769 | GdkWindow *win; | ||
1218 | 770 | GSList *w; | ||
1219 | 771 | gint x, y, ww, width, height; | ||
1220 | 772 | gint i = 0, len = 0; | ||
1221 | 773 | |||
1222 | 774 | g_return_val_if_fail (TASK_IS_ICON (icon), FALSE); | ||
1223 | 775 | priv = icon->priv; | ||
1224 | 776 | |||
1225 | 777 | widget = GTK_WIDGET (icon); | ||
1226 | 778 | |||
1227 | 779 | //get the position of the widget | ||
1228 | 780 | win = gtk_widget_get_window (widget); | ||
1229 | 781 | gdk_window_get_origin (win, &x, &y); | ||
1230 | 782 | |||
1231 | 783 | settings = task_settings_get_default (); | ||
1232 | 784 | |||
1233 | 785 | switch (settings->orient) | ||
1234 | 786 | { | ||
1235 | 787 | case AWN_ORIENTATION_RIGHT: | ||
1236 | 788 | //x += settings->panel_size; | ||
1237 | 789 | ww = GTK_WIDGET (icon)->allocation.height; | ||
1238 | 790 | break; | ||
1239 | 791 | case AWN_ORIENTATION_LEFT: | ||
1240 | 792 | //x += settings->offset; | ||
1241 | 793 | ww = GTK_WIDGET (icon)->allocation.height; | ||
1242 | 794 | break; | ||
1243 | 795 | case AWN_ORIENTATION_TOP: | ||
1244 | 796 | //y += settings->offset; | ||
1245 | 797 | ww = GTK_WIDGET (icon)->allocation.width; | ||
1246 | 798 | break; | ||
1247 | 799 | default: | ||
1248 | 800 | //y += settings->panel_size; | ||
1249 | 801 | ww = GTK_WIDGET (icon)->allocation.width; | ||
1250 | 802 | break; | ||
1251 | 803 | } | ||
1252 | 804 | |||
1253 | 805 | /* FIXME: Do something clever here to allow the user to "scrub" the icon | ||
1254 | 806 | * for the windows. | ||
1255 | 807 | */ | ||
1256 | 808 | len = g_slist_length (priv->windows); | ||
1257 | 809 | ww = ww/len; | ||
1258 | 810 | for (w = priv->windows; w; w = w->next) | ||
1259 | 811 | { | ||
1260 | 812 | TaskWindow *window = w->data; | ||
1261 | 813 | switch (settings->orient) | ||
1262 | 814 | { | ||
1263 | 815 | case AWN_ORIENTATION_RIGHT: | ||
1264 | 816 | width = settings->panel_size+settings->offset; | ||
1265 | 817 | height = ww + (i*ww); | ||
1266 | 818 | break; | ||
1267 | 819 | case AWN_ORIENTATION_LEFT: | ||
1268 | 820 | width = settings->panel_size+settings->offset; | ||
1269 | 821 | height = ww + (i*ww); | ||
1270 | 822 | break; | ||
1271 | 823 | case AWN_ORIENTATION_TOP: | ||
1272 | 824 | width = ww + (i*ww); | ||
1273 | 825 | height = settings->panel_size+settings->offset; | ||
1274 | 826 | break; | ||
1275 | 827 | default: | ||
1276 | 828 | width = ww + (i*ww); | ||
1277 | 829 | height = settings->panel_size+settings->offset; | ||
1278 | 830 | break; | ||
1279 | 831 | } | ||
1280 | 832 | task_window_set_icon_geometry (window, x, y, | ||
1281 | 833 | width, | ||
1282 | 834 | height); | ||
1283 | 835 | i++; | ||
1284 | 836 | } | ||
1285 | 837 | |||
1286 | 838 | return FALSE; | ||
1288 | 839 | } | 1030 | } |
1289 | 840 | 1031 | ||
1290 | 841 | /* | 1032 | /* |
1291 | @@ -861,78 +1052,146 @@ | |||
1292 | 861 | return TRUE; | 1052 | return TRUE; |
1293 | 862 | } | 1053 | } |
1294 | 863 | 1054 | ||
1295 | 1055 | /** | ||
1296 | 1056 | * Whenever there is a release event on the TaskIcon it will do the proper actions. | ||
1297 | 1057 | * left click: - start launcher = has no (visible) windows | ||
1298 | 1058 | * - activate window = when there is only one (visible) window | ||
1299 | 1059 | * - show dialog = when there are multiple (visible) windows | ||
1300 | 1060 | * middle click: - start launcher | ||
1301 | 1061 | * Returns: TRUE to stop other handlers from being invoked for the event. | ||
1302 | 1062 | * FALSE to propagate the event further. | ||
1303 | 1063 | * TODO: h4writer - adjust | ||
1304 | 1064 | */ | ||
1305 | 864 | static gboolean | 1065 | static gboolean |
1306 | 865 | task_icon_button_release_event (GtkWidget *widget, | 1066 | task_icon_button_release_event (GtkWidget *widget, |
1307 | 866 | GdkEventButton *event) | 1067 | GdkEventButton *event) |
1308 | 867 | { | 1068 | { |
1309 | 868 | TaskIconPrivate *priv; | 1069 | TaskIconPrivate *priv; |
1311 | 869 | gint len; | 1070 | TaskIcon *icon; |
1312 | 870 | 1071 | ||
1313 | 871 | g_return_val_if_fail (TASK_IS_ICON (widget), FALSE); | 1072 | g_return_val_if_fail (TASK_IS_ICON (widget), FALSE); |
1319 | 872 | priv = TASK_ICON (widget)->priv; | 1073 | |
1320 | 873 | 1074 | icon = TASK_ICON (widget); | |
1321 | 874 | len = g_slist_length (priv->windows); | 1075 | priv = icon->priv; |
1322 | 875 | 1076 | ||
1323 | 876 | if (event->button == 1) | 1077 | switch (event->button) |
1324 | 877 | { | 1078 | { |
1339 | 878 | if(priv->gets_dragged) | 1079 | case 1: // left click: (start launcher || activate window || show dialog) |
1340 | 879 | { | 1080 | |
1341 | 880 | return FALSE; | 1081 | if(priv->gets_dragged) return FALSE; |
1342 | 881 | } | 1082 | |
1343 | 882 | if (len == 1) | 1083 | if (priv->shown_items == 0) |
1344 | 883 | { | 1084 | { |
1345 | 884 | task_window_activate (priv->windows->data, event->time); | 1085 | g_critical ("TaskIcon: The icons shouldn't contain a visible (and clickable) icon"); |
1346 | 885 | return TRUE; | 1086 | return FALSE; |
1347 | 886 | } | 1087 | } |
1348 | 887 | else if (len > 1) | 1088 | else if (priv->shown_items == 1) |
1349 | 888 | { | 1089 | { |
1350 | 889 | if (GTK_WIDGET_VISIBLE(priv->dialog) ) | 1090 | GSList *w; |
1351 | 890 | { | 1091 | /* Find the window/launcher that is shown */ |
1352 | 891 | gtk_widget_hide (priv->dialog); | 1092 | for (w = priv->items; w; w = w->next) |
1353 | 1093 | { | ||
1354 | 1094 | TaskItem *item = w->data; | ||
1355 | 1095 | |||
1356 | 1096 | if (!task_item_is_visible (item)) continue; | ||
1357 | 1097 | |||
1358 | 1098 | task_item_left_click (item, event); | ||
1359 | 1099 | |||
1360 | 1100 | break; | ||
1361 | 1101 | } | ||
1362 | 1102 | return TRUE; | ||
1363 | 892 | } | 1103 | } |
1364 | 893 | else | 1104 | else |
1365 | 894 | { | 1105 | { |
1367 | 895 | gtk_widget_show_all (priv->dialog); | 1106 | GSList *w; |
1368 | 1107 | for (w = priv->items; w; w = w->next) | ||
1369 | 1108 | { | ||
1370 | 1109 | TaskItem *item = w->data; | ||
1371 | 1110 | |||
1372 | 1111 | if (!task_item_is_visible (item)) continue; | ||
1373 | 1112 | |||
1374 | 1113 | g_debug ("clicked on: %s", task_item_get_name (item)); | ||
1375 | 1114 | } | ||
1376 | 1115 | |||
1377 | 1116 | //TODO: move to hover? | ||
1378 | 1117 | if (GTK_WIDGET_VISIBLE (priv->dialog) ) | ||
1379 | 1118 | { | ||
1380 | 1119 | gtk_widget_hide (priv->dialog); | ||
1381 | 1120 | } | ||
1382 | 1121 | else | ||
1383 | 1122 | { | ||
1384 | 1123 | gtk_widget_show (priv->dialog); | ||
1385 | 1124 | } | ||
1386 | 896 | } | 1125 | } |
1397 | 897 | } | 1126 | break; |
1398 | 898 | } | 1127 | |
1399 | 899 | else if (event->button == 2) | 1128 | case 2: // middle click: start launcher |
1400 | 900 | { | 1129 | |
1401 | 901 | if (len >= 1 && TASK_IS_LAUNCHER (priv->windows->data)) | 1130 | g_warning ("TaskIcon: FIXME: No support for starting launcher on middle click"); |
1402 | 902 | { | 1131 | |
1403 | 903 | task_launcher_middle_click (priv->windows->data, event); | 1132 | //TODO: start launcher |
1404 | 904 | return TRUE; | 1133 | /*if (len >= 1 && TASK_IS_LAUNCHER (priv->windows->data)) |
1405 | 905 | } | 1134 | { |
1406 | 906 | } | 1135 | task_launcher_middle_click (priv->windows->data, event); |
1407 | 1136 | return TRUE; | ||
1408 | 1137 | }*/ | ||
1409 | 1138 | |||
1410 | 1139 | break; | ||
1411 | 1140 | |||
1412 | 1141 | default: | ||
1413 | 1142 | break; | ||
1414 | 1143 | } | ||
1415 | 1144 | |||
1416 | 907 | return FALSE; | 1145 | return FALSE; |
1417 | 908 | } | 1146 | } |
1418 | 909 | 1147 | ||
1419 | 1148 | /** | ||
1420 | 1149 | * Whenever there is a press event on the TaskIcon it will do the proper actions. | ||
1421 | 1150 | * right click: - show the context menu if there is only one (visible) window | ||
1422 | 1151 | * Returns: TRUE to stop other handlers from being invoked for the event. | ||
1423 | 1152 | * FALSE to propagate the event further. | ||
1424 | 1153 | */ | ||
1425 | 910 | static gboolean | 1154 | static gboolean |
1426 | 911 | task_icon_button_press_event (GtkWidget *widget, | 1155 | task_icon_button_press_event (GtkWidget *widget, |
1427 | 912 | GdkEventButton *event) | 1156 | GdkEventButton *event) |
1428 | 913 | { | 1157 | { |
1429 | 914 | TaskIconPrivate *priv; | 1158 | TaskIconPrivate *priv; |
1431 | 915 | guint len; | 1159 | TaskIcon *icon; |
1432 | 916 | 1160 | ||
1433 | 917 | g_return_val_if_fail (TASK_IS_ICON (widget), FALSE); | 1161 | g_return_val_if_fail (TASK_IS_ICON (widget), FALSE); |
1437 | 918 | priv = TASK_ICON (widget)->priv; | 1162 | |
1438 | 919 | 1163 | icon = TASK_ICON (widget); | |
1439 | 920 | if (event->button != 3) | 1164 | priv = icon->priv; |
1440 | 1165 | |||
1441 | 1166 | if (event->button != 3) return FALSE; | ||
1442 | 1167 | |||
1443 | 1168 | if (priv->shown_items == 0) | ||
1444 | 1169 | { | ||
1445 | 1170 | g_critical ("TaskIcon: The icons shouldn't contain a visible (and clickable) icon"); | ||
1446 | 921 | return FALSE; | 1171 | return FALSE; |
1451 | 922 | 1172 | } | |
1452 | 923 | len = g_slist_length (priv->windows); | 1173 | else if (priv->shown_items == 1) |
1449 | 924 | |||
1450 | 925 | if (len == 1) | ||
1453 | 926 | { | 1174 | { |
1456 | 927 | /* We can just ask the window to popup as normal */ | 1175 | GSList *w; |
1457 | 928 | task_window_popup_context_menu (priv->windows->data, event); | 1176 | |
1458 | 1177 | /* Find the window/launcher that is shown */ | ||
1459 | 1178 | for (w = priv->items; w; w = w->next) | ||
1460 | 1179 | { | ||
1461 | 1180 | TaskItem *item = w->data; | ||
1462 | 1181 | |||
1463 | 1182 | if (!task_item_is_visible (item)) continue; | ||
1464 | 1183 | |||
1465 | 1184 | task_item_right_click (item, event); | ||
1466 | 1185 | |||
1467 | 1186 | break; | ||
1468 | 1187 | } | ||
1469 | 929 | return TRUE; | 1188 | return TRUE; |
1470 | 930 | } | 1189 | } |
1471 | 931 | else | 1190 | else |
1472 | 932 | { | 1191 | { |
1473 | 933 | g_warning ("TaskIcon: FIXME: No support for multiple windows right-click"); | 1192 | g_warning ("TaskIcon: FIXME: No support for multiple windows right-click"); |
1474 | 1193 | return FALSE; | ||
1475 | 934 | } | 1194 | } |
1476 | 935 | return FALSE; | ||
1477 | 936 | } | 1195 | } |
1478 | 937 | 1196 | ||
1479 | 938 | static gboolean | 1197 | static gboolean |
1480 | @@ -976,6 +1235,9 @@ | |||
1481 | 976 | //g_debug("draggable:%d", draggable); | 1235 | //g_debug("draggable:%d", draggable); |
1482 | 977 | } | 1236 | } |
1483 | 978 | 1237 | ||
1484 | 1238 | /** | ||
1485 | 1239 | * TODO: h4writer - second stage | ||
1486 | 1240 | */ | ||
1487 | 979 | static gboolean | 1241 | static gboolean |
1488 | 980 | drag_timeout (TaskIcon *icon) | 1242 | drag_timeout (TaskIcon *icon) |
1489 | 981 | { | 1243 | { |
1490 | @@ -984,12 +1246,12 @@ | |||
1491 | 984 | g_return_val_if_fail (TASK_IS_ICON (icon), FALSE); | 1246 | g_return_val_if_fail (TASK_IS_ICON (icon), FALSE); |
1492 | 985 | priv = icon->priv; | 1247 | priv = icon->priv; |
1493 | 986 | 1248 | ||
1495 | 987 | if (priv->drag_motion == FALSE) | 1249 | /* if (priv->drag_motion == FALSE) |
1496 | 988 | return FALSE; | 1250 | return FALSE; |
1497 | 989 | else if (priv->windows->data) | 1251 | else if (priv->windows->data) |
1498 | 990 | if (!task_window_is_active(priv->windows->data)) | 1252 | if (!task_window_is_active(priv->windows->data)) |
1499 | 991 | task_window_activate (priv->windows->data, priv->drag_time); | 1253 | task_window_activate (priv->windows->data, priv->drag_time); |
1501 | 992 | 1254 | */ | |
1502 | 993 | return FALSE; | 1255 | return FALSE; |
1503 | 994 | } | 1256 | } |
1504 | 995 | 1257 | ||
1505 | @@ -1104,9 +1366,11 @@ | |||
1506 | 1104 | { | 1366 | { |
1507 | 1105 | /* If it is a launcher it should show that it accepts the drag. | 1367 | /* If it is a launcher it should show that it accepts the drag. |
1508 | 1106 | Else only the the timeout should get set to activate the window. */ | 1368 | Else only the the timeout should get set to activate the window. */ |
1512 | 1107 | if (!priv->windows || !TASK_IS_LAUNCHER (priv->windows->data)) | 1369 | |
1513 | 1108 | gdk_drag_status (context, GDK_ACTION_DEFAULT, t); | 1370 | //TODO: h4writer - 2nd round |
1514 | 1109 | else | 1371 | //if (!priv->items || !TASK_IS_LAUNCHER (priv->items->data)) |
1515 | 1372 | // gdk_drag_status (context, GDK_ACTION_DEFAULT, t); | ||
1516 | 1373 | //else | ||
1517 | 1110 | gdk_drag_status (context, GDK_ACTION_COPY, t); | 1374 | gdk_drag_status (context, GDK_ACTION_COPY, t); |
1518 | 1111 | return TRUE; | 1375 | return TRUE; |
1519 | 1112 | } | 1376 | } |
1520 | @@ -1151,7 +1415,7 @@ | |||
1521 | 1151 | TaskIconPrivate *priv; | 1415 | TaskIconPrivate *priv; |
1522 | 1152 | GSList *list; | 1416 | GSList *list; |
1523 | 1153 | GError *error; | 1417 | GError *error; |
1525 | 1154 | TaskLauncher *launcher; | 1418 | //TaskLauncher *launcher; |
1526 | 1155 | GdkAtom target; | 1419 | GdkAtom target; |
1527 | 1156 | gchar *target_name; | 1420 | gchar *target_name; |
1528 | 1157 | gchar *sdata_data; | 1421 | gchar *sdata_data; |
1529 | @@ -1170,13 +1434,14 @@ | |||
1530 | 1170 | } | 1434 | } |
1531 | 1171 | 1435 | ||
1532 | 1172 | /* If we are not a launcher, we don't care about this */ | 1436 | /* If we are not a launcher, we don't care about this */ |
1540 | 1173 | if (!priv->windows || !TASK_IS_LAUNCHER (priv->windows->data)) | 1437 | //TODO: h4writer - 2nd round |
1541 | 1174 | { | 1438 | //if (!priv->windows || !TASK_IS_LAUNCHER (priv->windows->data)) |
1542 | 1175 | gtk_drag_finish (context, FALSE, FALSE, time_); | 1439 | //{ |
1543 | 1176 | return; | 1440 | // gtk_drag_finish (context, FALSE, FALSE, time_); |
1544 | 1177 | } | 1441 | // return; |
1545 | 1178 | 1442 | //} | |
1546 | 1179 | launcher = priv->windows->data; | 1443 | // |
1547 | 1444 | //launcher = priv->windows->data; | ||
1548 | 1180 | 1445 | ||
1549 | 1181 | sdata_data = (gchar*)gtk_selection_data_get_data (sdata); | 1446 | sdata_data = (gchar*)gtk_selection_data_get_data (sdata); |
1550 | 1182 | 1447 | ||
1551 | @@ -1197,10 +1462,10 @@ | |||
1552 | 1197 | //FIXME: I think this function returns always FALSE (haytjes) | 1462 | //FIXME: I think this function returns always FALSE (haytjes) |
1553 | 1198 | // and I also think this isn't a bad idea to allow too. | 1463 | // and I also think this isn't a bad idea to allow too. |
1554 | 1199 | // I often drop a url on firefox, even when it is already open. | 1464 | // I often drop a url on firefox, even when it is already open. |
1559 | 1200 | if (task_launcher_has_window (launcher)) | 1465 | //if (task_launcher_has_windows (launcher)) |
1560 | 1201 | { | 1466 | //{ |
1561 | 1202 | gtk_drag_finish (context, FALSE, FALSE, time_); | 1467 | // gtk_drag_finish (context, FALSE, FALSE, time_); |
1562 | 1203 | } | 1468 | //} |
1563 | 1204 | 1469 | ||
1564 | 1205 | error = NULL; | 1470 | error = NULL; |
1565 | 1206 | list = awn_vfs_get_pathlist_from_string (sdata_data, &error); | 1471 | list = awn_vfs_get_pathlist_from_string (sdata_data, &error); |
1566 | @@ -1212,7 +1477,7 @@ | |||
1567 | 1212 | return; | 1477 | return; |
1568 | 1213 | } | 1478 | } |
1569 | 1214 | 1479 | ||
1571 | 1215 | task_launcher_launch_with_data (launcher, list); | 1480 | //task_launcher_launch_with_data (launcher, list); |
1572 | 1216 | 1481 | ||
1573 | 1217 | g_slist_foreach (list, (GFunc)g_free, NULL); | 1482 | g_slist_foreach (list, (GFunc)g_free, NULL); |
1574 | 1218 | g_slist_free (list); | 1483 | g_slist_free (list); |
1575 | 1219 | 1484 | ||
1576 | === modified file 'applets/taskmanager/task-icon.h' | |||
1577 | --- applets/taskmanager/task-icon.h 2009-05-27 15:57:06 +0000 | |||
1578 | +++ applets/taskmanager/task-icon.h 2009-06-22 13:16:54 +0000 | |||
1579 | @@ -14,7 +14,7 @@ | |||
1580 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1581 | 15 | * | 15 | * |
1582 | 16 | * Authored by Neil Jagdish Patel <njpatel@gmail.com> | 16 | * Authored by Neil Jagdish Patel <njpatel@gmail.com> |
1584 | 17 | * | 17 | * Hannes Verschore <hv1989@gmail.com> |
1585 | 18 | */ | 18 | */ |
1586 | 19 | 19 | ||
1587 | 20 | #ifndef _TASK_ICON_H_ | 20 | #ifndef _TASK_ICON_H_ |
1588 | @@ -24,6 +24,7 @@ | |||
1589 | 24 | #include <gtk/gtk.h> | 24 | #include <gtk/gtk.h> |
1590 | 25 | #include <libawn/libawn.h> | 25 | #include <libawn/libawn.h> |
1591 | 26 | 26 | ||
1592 | 27 | #include "task-item.h" | ||
1593 | 27 | #include "task-window.h" | 28 | #include "task-window.h" |
1594 | 28 | #include "task-launcher.h" | 29 | #include "task-launcher.h" |
1595 | 29 | 30 | ||
1596 | @@ -50,19 +51,19 @@ | |||
1597 | 50 | 51 | ||
1598 | 51 | struct _TaskIcon | 52 | struct _TaskIcon |
1599 | 52 | { | 53 | { |
1601 | 53 | AwnIcon parent; | 54 | AwnThemedIcon parent; |
1602 | 54 | 55 | ||
1603 | 55 | TaskIconPrivate *priv; | 56 | TaskIconPrivate *priv; |
1604 | 56 | }; | 57 | }; |
1605 | 57 | 58 | ||
1606 | 58 | struct _TaskIconClass | 59 | struct _TaskIconClass |
1607 | 59 | { | 60 | { |
1609 | 60 | AwnIconClass parent_class; | 61 | AwnThemedIconClass parent_class; |
1610 | 61 | 62 | ||
1611 | 62 | /*< vtable, not signals >*/ | 63 | /*< vtable, not signals >*/ |
1612 | 63 | 64 | ||
1613 | 64 | /*< signals >*/ | 65 | /*< signals >*/ |
1615 | 65 | void (*ensure_layout) (TaskIcon *icon); | 66 | void (*visible_changed) (TaskIcon *icon); |
1616 | 66 | void (*source_drag_fail) (TaskIcon *icon); | 67 | void (*source_drag_fail) (TaskIcon *icon); |
1617 | 67 | void (*source_drag_begin) (TaskIcon *icon); | 68 | void (*source_drag_begin) (TaskIcon *icon); |
1618 | 68 | void (*source_drag_end) (TaskIcon *icon); | 69 | void (*source_drag_end) (TaskIcon *icon); |
1619 | @@ -72,27 +73,24 @@ | |||
1620 | 72 | 73 | ||
1621 | 73 | GType task_icon_get_type (void) G_GNUC_CONST; | 74 | GType task_icon_get_type (void) G_GNUC_CONST; |
1622 | 74 | 75 | ||
1644 | 75 | GtkWidget* task_icon_new_for_window (TaskWindow *window); | 76 | GtkWidget* task_icon_new (); |
1645 | 76 | 77 | ||
1646 | 77 | gboolean task_icon_is_skip_taskbar (TaskIcon *icon); | 78 | gboolean task_icon_is_visible (TaskIcon *icon); |
1647 | 78 | 79 | gboolean task_icon_contains_launcher (TaskIcon *icon); | |
1648 | 79 | gboolean task_icon_is_in_viewport (TaskIcon *icon, | 80 | |
1649 | 80 | WnckWorkspace *space); | 81 | void task_icon_append_item (TaskIcon *icon, |
1650 | 81 | 82 | TaskItem *item); | |
1651 | 82 | void task_icon_append_window (TaskIcon *icon, | 83 | void task_icon_remove_item (TaskIcon *icon, |
1652 | 83 | TaskWindow *window); | 84 | TaskItem *item); |
1653 | 84 | void task_icon_remove_window (TaskIcon *icon, | 85 | guint task_icon_match_item (TaskIcon *icon, |
1654 | 85 | WnckWindow *window); | 86 | TaskItem *item); |
1655 | 86 | gboolean task_icon_is_launcher (TaskIcon *icon); | 87 | |
1656 | 87 | TaskLauncher* task_icon_get_launcher (TaskIcon *icon); | 88 | //void task_icon_remove_windows (TaskIcon *icon); |
1657 | 88 | TaskWindow* task_icon_get_window (TaskIcon *icon); | 89 | |
1658 | 89 | 90 | void task_icon_refresh_icon (TaskIcon *icon); | |
1659 | 90 | void task_icon_refresh_icon (TaskIcon *icon); | 91 | |
1660 | 91 | 92 | void task_icon_set_draggable (TaskIcon *icon, | |
1661 | 92 | gboolean task_icon_refresh_geometry (TaskIcon *icon); | 93 | gboolean draggable); |
1641 | 93 | |||
1642 | 94 | void task_icon_set_draggable (TaskIcon *icon, | ||
1643 | 95 | gboolean draggable); | ||
1662 | 96 | 94 | ||
1663 | 97 | #endif /* _TASK_ICON_H_ */ | 95 | #endif /* _TASK_ICON_H_ */ |
1664 | 98 | 96 | ||
1665 | 99 | 97 | ||
1666 | === added file 'applets/taskmanager/task-item.c' | |||
1667 | --- applets/taskmanager/task-item.c 1970-01-01 00:00:00 +0000 | |||
1668 | +++ applets/taskmanager/task-item.c 2009-06-28 01:53:46 +0000 | |||
1669 | @@ -0,0 +1,301 @@ | |||
1670 | 1 | /* | ||
1671 | 2 | * Copyright (C) 2008 Neil Jagdish Patel <njpatel@gmail.com> | ||
1672 | 3 | * | ||
1673 | 4 | * This program is free software: you can redistribute it and/or modify | ||
1674 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
1675 | 6 | * published by the Free Software Foundation. | ||
1676 | 7 | * | ||
1677 | 8 | * This program is distributed in the hope that it will be useful, | ||
1678 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1679 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1680 | 11 | * GNU General Public License for more details. | ||
1681 | 12 | * | ||
1682 | 13 | * You should have received a copy of the GNU General Public License | ||
1683 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1684 | 15 | * | ||
1685 | 16 | * Authored by Hannes Verschore <hv1989@gmail.com> | ||
1686 | 17 | * | ||
1687 | 18 | */ | ||
1688 | 19 | |||
1689 | 20 | #include "task-item.h" | ||
1690 | 21 | |||
1691 | 22 | #include <libawn/libawn.h> | ||
1692 | 23 | |||
1693 | 24 | G_DEFINE_ABSTRACT_TYPE (TaskItem, task_item, GTK_TYPE_EVENT_BOX) | ||
1694 | 25 | |||
1695 | 26 | #define TASK_ITEM_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj),\ | ||
1696 | 27 | TASK_TYPE_ITEM, \ | ||
1697 | 28 | TaskItemPrivate)) | ||
1698 | 29 | |||
1699 | 30 | struct _TaskItemPrivate | ||
1700 | 31 | { | ||
1701 | 32 | GtkWidget *box; | ||
1702 | 33 | GtkWidget *name; | ||
1703 | 34 | GtkWidget *icon; | ||
1704 | 35 | }; | ||
1705 | 36 | |||
1706 | 37 | enum | ||
1707 | 38 | { | ||
1708 | 39 | PROP_0 | ||
1709 | 40 | }; | ||
1710 | 41 | |||
1711 | 42 | enum | ||
1712 | 43 | { | ||
1713 | 44 | NAME_CHANGED, | ||
1714 | 45 | ICON_CHANGED, | ||
1715 | 46 | VISIBLE_CHANGED, | ||
1716 | 47 | |||
1717 | 48 | LAST_SIGNAL | ||
1718 | 49 | }; | ||
1719 | 50 | static guint32 _item_signals[LAST_SIGNAL] = { 0 }; | ||
1720 | 51 | |||
1721 | 52 | /* Forwards */ | ||
1722 | 53 | static void task_item_name_changed (TaskItem *item, const gchar *name); | ||
1723 | 54 | static void task_item_icon_changed (TaskItem *item, GdkPixbuf *icon); | ||
1724 | 55 | static void task_item_visible_changed (TaskItem *item, gboolean visible); | ||
1725 | 56 | |||
1726 | 57 | static gboolean task_item_button_release_event (GtkWidget *widget, | ||
1727 | 58 | GdkEventButton *event); | ||
1728 | 59 | static gboolean task_item_button_press_event (GtkWidget *widget, | ||
1729 | 60 | GdkEventButton *event); | ||
1730 | 61 | |||
1731 | 62 | /* GObject stuff */ | ||
1732 | 63 | static void | ||
1733 | 64 | task_item_class_init (TaskItemClass *klass) | ||
1734 | 65 | { | ||
1735 | 66 | //GParamSpec *pspec; | ||
1736 | 67 | GObjectClass *obj_class = G_OBJECT_CLASS (klass); | ||
1737 | 68 | GtkWidgetClass *wid_class = GTK_WIDGET_CLASS (klass); | ||
1738 | 69 | |||
1739 | 70 | wid_class->button_release_event = task_item_button_release_event; | ||
1740 | 71 | wid_class->button_press_event = task_item_button_press_event; | ||
1741 | 72 | |||
1742 | 73 | /* We implement the necessary funtions for a normal item */ | ||
1743 | 74 | klass->get_name = NULL; | ||
1744 | 75 | klass->get_icon = NULL; | ||
1745 | 76 | klass->is_visible = NULL; | ||
1746 | 77 | klass->match = NULL; | ||
1747 | 78 | |||
1748 | 79 | /* Install signals */ | ||
1749 | 80 | _item_signals[NAME_CHANGED] = | ||
1750 | 81 | g_signal_new ("name-changed", | ||
1751 | 82 | G_OBJECT_CLASS_TYPE (obj_class), | ||
1752 | 83 | G_SIGNAL_RUN_LAST, | ||
1753 | 84 | G_STRUCT_OFFSET (TaskItemClass, name_changed), | ||
1754 | 85 | NULL, NULL, | ||
1755 | 86 | g_cclosure_marshal_VOID__STRING, | ||
1756 | 87 | G_TYPE_NONE, | ||
1757 | 88 | 1, G_TYPE_STRING); | ||
1758 | 89 | |||
1759 | 90 | _item_signals[ICON_CHANGED] = | ||
1760 | 91 | g_signal_new ("icon-changed", | ||
1761 | 92 | G_OBJECT_CLASS_TYPE (obj_class), | ||
1762 | 93 | G_SIGNAL_RUN_LAST, | ||
1763 | 94 | G_STRUCT_OFFSET (TaskItemClass, icon_changed), | ||
1764 | 95 | NULL, NULL, | ||
1765 | 96 | g_cclosure_marshal_VOID__OBJECT, | ||
1766 | 97 | G_TYPE_NONE, | ||
1767 | 98 | 1, GDK_TYPE_PIXBUF); | ||
1768 | 99 | |||
1769 | 100 | _item_signals[VISIBLE_CHANGED] = | ||
1770 | 101 | g_signal_new ("visible-changed", | ||
1771 | 102 | G_OBJECT_CLASS_TYPE (obj_class), | ||
1772 | 103 | G_SIGNAL_RUN_LAST, | ||
1773 | 104 | G_STRUCT_OFFSET (TaskItemClass, visible_changed), | ||
1774 | 105 | NULL, NULL, | ||
1775 | 106 | g_cclosure_marshal_VOID__BOOLEAN, | ||
1776 | 107 | G_TYPE_NONE, | ||
1777 | 108 | 1, G_TYPE_BOOLEAN); | ||
1778 | 109 | |||
1779 | 110 | g_type_class_add_private (obj_class, sizeof (TaskItemPrivate)); | ||
1780 | 111 | } | ||
1781 | 112 | |||
1782 | 113 | static void | ||
1783 | 114 | task_item_init (TaskItem *item) | ||
1784 | 115 | { | ||
1785 | 116 | TaskItemPrivate *priv; | ||
1786 | 117 | |||
1787 | 118 | /* get and save private struct */ | ||
1788 | 119 | priv = item->priv = TASK_ITEM_GET_PRIVATE (item); | ||
1789 | 120 | |||
1790 | 121 | /* let this eventbox listen to every events */ | ||
1791 | 122 | gtk_event_box_set_above_child (GTK_EVENT_BOX (item), TRUE); | ||
1792 | 123 | |||
1793 | 124 | /* create content */ | ||
1794 | 125 | priv->box = gtk_hbox_new (FALSE, 10); | ||
1795 | 126 | gtk_container_add (GTK_CONTAINER (item), priv->box); | ||
1796 | 127 | |||
1797 | 128 | priv->icon = awn_icon_new (); | ||
1798 | 129 | gtk_box_pack_start (GTK_BOX (priv->box), priv->icon, FALSE, FALSE, 0); | ||
1799 | 130 | |||
1800 | 131 | priv->name = gtk_label_new (""); | ||
1801 | 132 | gtk_box_pack_start (GTK_BOX (priv->box), priv->name, TRUE, FALSE, 10); | ||
1802 | 133 | |||
1803 | 134 | /* connect to signals */ | ||
1804 | 135 | g_signal_connect (G_OBJECT (item), "name-changed", | ||
1805 | 136 | G_CALLBACK (task_item_name_changed), NULL); | ||
1806 | 137 | g_signal_connect (G_OBJECT (item), "icon-changed", | ||
1807 | 138 | G_CALLBACK (task_item_icon_changed), NULL); | ||
1808 | 139 | g_signal_connect (G_OBJECT (item), "visible-changed", | ||
1809 | 140 | G_CALLBACK (task_item_visible_changed), NULL); | ||
1810 | 141 | } | ||
1811 | 142 | |||
1812 | 143 | static gboolean | ||
1813 | 144 | task_item_button_release_event (GtkWidget *widget, | ||
1814 | 145 | GdkEventButton *event) | ||
1815 | 146 | { | ||
1816 | 147 | g_return_val_if_fail (TASK_IS_ITEM (widget), FALSE); | ||
1817 | 148 | |||
1818 | 149 | task_item_left_click (TASK_ITEM (widget), event); | ||
1819 | 150 | |||
1820 | 151 | return TRUE; | ||
1821 | 152 | } | ||
1822 | 153 | |||
1823 | 154 | static gboolean | ||
1824 | 155 | task_item_button_press_event (GtkWidget *widget, | ||
1825 | 156 | GdkEventButton *event) | ||
1826 | 157 | { | ||
1827 | 158 | g_return_val_if_fail (TASK_IS_ITEM (widget), FALSE); | ||
1828 | 159 | |||
1829 | 160 | if (event->button != 3) return FALSE; | ||
1830 | 161 | |||
1831 | 162 | task_item_right_click (TASK_ITEM (widget), event); | ||
1832 | 163 | |||
1833 | 164 | return TRUE; | ||
1834 | 165 | } | ||
1835 | 166 | |||
1836 | 167 | static void | ||
1837 | 168 | task_item_name_changed (TaskItem *item, const gchar *name) | ||
1838 | 169 | { | ||
1839 | 170 | TaskItemPrivate *priv = TASK_ITEM_GET_PRIVATE (item); | ||
1840 | 171 | |||
1841 | 172 | gtk_label_set_text (GTK_LABEL (priv->name), name); | ||
1842 | 173 | } | ||
1843 | 174 | |||
1844 | 175 | |||
1845 | 176 | static void | ||
1846 | 177 | task_item_icon_changed (TaskItem *item, GdkPixbuf *icon) | ||
1847 | 178 | { | ||
1848 | 179 | TaskItemPrivate *priv = TASK_ITEM_GET_PRIVATE (item); | ||
1849 | 180 | |||
1850 | 181 | awn_icon_set_from_pixbuf (AWN_ICON (priv->icon), icon); | ||
1851 | 182 | } | ||
1852 | 183 | |||
1853 | 184 | static void | ||
1854 | 185 | task_item_visible_changed (TaskItem *item, gboolean visible) | ||
1855 | 186 | { | ||
1856 | 187 | if (visible) | ||
1857 | 188 | gtk_widget_show (GTK_WIDGET (item)); | ||
1858 | 189 | else | ||
1859 | 190 | gtk_widget_hide (GTK_WIDGET (item)); | ||
1860 | 191 | } | ||
1861 | 192 | |||
1862 | 193 | /** | ||
1863 | 194 | * Public functions | ||
1864 | 195 | */ | ||
1865 | 196 | |||
1866 | 197 | const gchar * | ||
1867 | 198 | task_item_get_name (TaskItem *item) | ||
1868 | 199 | { | ||
1869 | 200 | TaskItemClass *klass; | ||
1870 | 201 | |||
1871 | 202 | g_return_val_if_fail (TASK_IS_ITEM (item), NULL); | ||
1872 | 203 | |||
1873 | 204 | klass = TASK_ITEM_GET_CLASS (item); | ||
1874 | 205 | g_return_val_if_fail (klass->get_name, NULL); | ||
1875 | 206 | |||
1876 | 207 | return klass->get_name (item); | ||
1877 | 208 | } | ||
1878 | 209 | |||
1879 | 210 | GdkPixbuf * | ||
1880 | 211 | task_item_get_icon (TaskItem *item) | ||
1881 | 212 | { | ||
1882 | 213 | TaskItemClass *klass; | ||
1883 | 214 | |||
1884 | 215 | g_return_val_if_fail (TASK_IS_ITEM (item), NULL); | ||
1885 | 216 | |||
1886 | 217 | klass = TASK_ITEM_GET_CLASS (item); | ||
1887 | 218 | g_return_val_if_fail (klass->get_icon, NULL); | ||
1888 | 219 | |||
1889 | 220 | return klass->get_icon (item); | ||
1890 | 221 | } | ||
1891 | 222 | |||
1892 | 223 | gboolean | ||
1893 | 224 | task_item_is_visible (TaskItem *item) | ||
1894 | 225 | { | ||
1895 | 226 | TaskItemClass *klass; | ||
1896 | 227 | |||
1897 | 228 | g_return_val_if_fail (TASK_IS_ITEM (item), FALSE); | ||
1898 | 229 | |||
1899 | 230 | klass = TASK_ITEM_GET_CLASS (item); | ||
1900 | 231 | g_return_val_if_fail (klass->is_visible, FALSE); | ||
1901 | 232 | |||
1902 | 233 | return klass->is_visible (item); | ||
1903 | 234 | } | ||
1904 | 235 | |||
1905 | 236 | void | ||
1906 | 237 | task_item_left_click (TaskItem *item, GdkEventButton *event) | ||
1907 | 238 | { | ||
1908 | 239 | TaskItemClass *klass; | ||
1909 | 240 | |||
1910 | 241 | g_return_if_fail (TASK_IS_ITEM (item)); | ||
1911 | 242 | |||
1912 | 243 | klass = TASK_ITEM_GET_CLASS (item); | ||
1913 | 244 | g_return_if_fail (klass->left_click); | ||
1914 | 245 | |||
1915 | 246 | klass->left_click (item, event); | ||
1916 | 247 | } | ||
1917 | 248 | |||
1918 | 249 | void | ||
1919 | 250 | task_item_right_click (TaskItem *item, GdkEventButton *event) | ||
1920 | 251 | { | ||
1921 | 252 | TaskItemClass *klass; | ||
1922 | 253 | |||
1923 | 254 | g_return_if_fail (TASK_IS_ITEM (item)); | ||
1924 | 255 | |||
1925 | 256 | klass = TASK_ITEM_GET_CLASS (item); | ||
1926 | 257 | g_return_if_fail (klass->right_click); | ||
1927 | 258 | |||
1928 | 259 | klass->right_click (item, event); | ||
1929 | 260 | } | ||
1930 | 261 | |||
1931 | 262 | guint | ||
1932 | 263 | task_item_match (TaskItem *item, TaskItem *item_to_match) | ||
1933 | 264 | { | ||
1934 | 265 | TaskItemClass *klass; | ||
1935 | 266 | |||
1936 | 267 | g_return_val_if_fail (TASK_IS_ITEM (item), 0); | ||
1937 | 268 | |||
1938 | 269 | klass = TASK_ITEM_GET_CLASS (item); | ||
1939 | 270 | g_return_val_if_fail (klass->match, 0); | ||
1940 | 271 | |||
1941 | 272 | return klass->match (item, item_to_match); | ||
1942 | 273 | } | ||
1943 | 274 | |||
1944 | 275 | /** | ||
1945 | 276 | * Protected functions (used only by derived classes) | ||
1946 | 277 | */ | ||
1947 | 278 | |||
1948 | 279 | void | ||
1949 | 280 | task_item_emit_name_changed (TaskItem *item, const gchar *name) | ||
1950 | 281 | { | ||
1951 | 282 | g_return_if_fail (TASK_IS_ITEM (item)); | ||
1952 | 283 | |||
1953 | 284 | g_signal_emit (item, _item_signals[NAME_CHANGED], 0, name); | ||
1954 | 285 | } | ||
1955 | 286 | |||
1956 | 287 | void | ||
1957 | 288 | task_item_emit_icon_changed (TaskItem *item, GdkPixbuf *icon) | ||
1958 | 289 | { | ||
1959 | 290 | g_return_if_fail (TASK_IS_ITEM (item)); | ||
1960 | 291 | |||
1961 | 292 | g_signal_emit (item, _item_signals[ICON_CHANGED], 0, icon); | ||
1962 | 293 | } | ||
1963 | 294 | |||
1964 | 295 | void | ||
1965 | 296 | task_item_emit_visible_changed (TaskItem *item, gboolean visible) | ||
1966 | 297 | { | ||
1967 | 298 | g_return_if_fail (TASK_IS_ITEM (item)); | ||
1968 | 299 | |||
1969 | 300 | g_signal_emit (item, _item_signals[VISIBLE_CHANGED], 0, visible); | ||
1970 | 301 | } | ||
1971 | 0 | \ No newline at end of file | 302 | \ No newline at end of file |
1972 | 1 | 303 | ||
1973 | === added file 'applets/taskmanager/task-item.h' | |||
1974 | --- applets/taskmanager/task-item.h 1970-01-01 00:00:00 +0000 | |||
1975 | +++ applets/taskmanager/task-item.h 2009-06-20 10:58:03 +0000 | |||
1976 | @@ -0,0 +1,98 @@ | |||
1977 | 1 | /* | ||
1978 | 2 | * Copyright (C) 2008 Neil Jagdish Patel <njpatel@gmail.com> | ||
1979 | 3 | * | ||
1980 | 4 | * This program is free software: you can redistribute it and/or modify | ||
1981 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
1982 | 6 | * published by the Free Software Foundation. | ||
1983 | 7 | * | ||
1984 | 8 | * This program is distributed in the hope that it will be useful, | ||
1985 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1986 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1987 | 11 | * GNU General Public License for more details. | ||
1988 | 12 | * | ||
1989 | 13 | * You should have received a copy of the GNU General Public License | ||
1990 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1991 | 15 | * | ||
1992 | 16 | * Authored by Hannes Verschore <hv1989@gmail.com> | ||
1993 | 17 | * | ||
1994 | 18 | */ | ||
1995 | 19 | |||
1996 | 20 | #ifndef _TASK_ITEM_H_ | ||
1997 | 21 | #define _TASK_ITEM_H_ | ||
1998 | 22 | |||
1999 | 23 | #include <glib-object.h> | ||
2000 | 24 | #include <gtk/gtk.h> | ||
2001 | 25 | |||
2002 | 26 | G_BEGIN_DECLS | ||
2003 | 27 | |||
2004 | 28 | #define TASK_TYPE_ITEM (task_item_get_type ()) | ||
2005 | 29 | |||
2006 | 30 | #define TASK_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),\ | ||
2007 | 31 | TASK_TYPE_ITEM, TaskItem)) | ||
2008 | 32 | |||
2009 | 33 | #define TASK_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),\ | ||
2010 | 34 | TASK_TYPE_ITEM, TaskItemClass)) | ||
2011 | 35 | |||
2012 | 36 | #define TASK_IS_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),\ | ||
2013 | 37 | TASK_TYPE_ITEM)) | ||
2014 | 38 | |||
2015 | 39 | #define TASK_IS_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),\ | ||
2016 | 40 | TASK_TYPE_ITEM)) | ||
2017 | 41 | |||
2018 | 42 | #define TASK_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),\ | ||
2019 | 43 | TASK_TYPE_ITEM, TaskItemClass)) | ||
2020 | 44 | |||
2021 | 45 | typedef struct _TaskItem TaskItem; | ||
2022 | 46 | typedef struct _TaskItemClass TaskItemClass; | ||
2023 | 47 | typedef struct _TaskItemPrivate TaskItemPrivate; | ||
2024 | 48 | |||
2025 | 49 | struct _TaskItem | ||
2026 | 50 | { | ||
2027 | 51 | GtkBox parent; | ||
2028 | 52 | |||
2029 | 53 | TaskItemPrivate *priv; | ||
2030 | 54 | }; | ||
2031 | 55 | |||
2032 | 56 | struct _TaskItemClass | ||
2033 | 57 | { | ||
2034 | 58 | GtkBoxClass parent_class; | ||
2035 | 59 | |||
2036 | 60 | /*< vtable, not signals >*/ | ||
2037 | 61 | const gchar * (*get_name) (TaskItem *item); | ||
2038 | 62 | GdkPixbuf * (*get_icon) (TaskItem *item); | ||
2039 | 63 | gboolean (*is_visible) (TaskItem *item); | ||
2040 | 64 | void (*left_click) (TaskItem *item, GdkEventButton *event); | ||
2041 | 65 | void (*right_click) (TaskItem *item, GdkEventButton *event); | ||
2042 | 66 | guint (*match) (TaskItem *item, TaskItem *item_to_match); | ||
2043 | 67 | |||
2044 | 68 | /*< signals >*/ | ||
2045 | 69 | void (*name_changed) (TaskItem *item, const gchar *name); | ||
2046 | 70 | void (*icon_changed) (TaskItem *item, GdkPixbuf *icon); | ||
2047 | 71 | void (*visible_changed) (TaskItem *item, gboolean visible); | ||
2048 | 72 | }; | ||
2049 | 73 | |||
2050 | 74 | GType task_item_get_type (void) G_GNUC_CONST; | ||
2051 | 75 | |||
2052 | 76 | const gchar * task_item_get_name (TaskItem *item); | ||
2053 | 77 | GdkPixbuf * task_item_get_icon (TaskItem *item); | ||
2054 | 78 | gboolean task_item_is_visible (TaskItem *item); | ||
2055 | 79 | void task_item_left_click (TaskItem *item, GdkEventButton *event); | ||
2056 | 80 | void task_item_right_click (TaskItem *item, GdkEventButton *event); | ||
2057 | 81 | guint task_item_match (TaskItem *item, TaskItem *item_to_match); | ||
2058 | 82 | |||
2059 | 83 | //TODO: 2nd round: implement | ||
2060 | 84 | //const gchar * task_item_get_name (TaskItem *item); | ||
2061 | 85 | //void task_item_set_name (TaskItem *item, | ||
2062 | 86 | // const gchar *name); | ||
2063 | 87 | //GdkPixbuf * task_item_get_icon (TaskItem *item); | ||
2064 | 88 | //void task_item_update_icon (TaskItem *item, | ||
2065 | 89 | // GdkPixbuf *pixbuf); | ||
2066 | 90 | |||
2067 | 91 | /* These should be "protected" (used only by derived classes) */ | ||
2068 | 92 | void task_item_emit_name_changed (TaskItem *item, const gchar *name); | ||
2069 | 93 | void task_item_emit_icon_changed (TaskItem *item, GdkPixbuf *icon); | ||
2070 | 94 | void task_item_emit_visible_changed (TaskItem *item, gboolean visible); | ||
2071 | 95 | |||
2072 | 96 | G_END_DECLS | ||
2073 | 97 | |||
2074 | 98 | #endif /* _TASK_ITEM_H_ */ | ||
2075 | 0 | 99 | ||
2076 | === modified file 'applets/taskmanager/task-launcher.c' | |||
2077 | --- applets/taskmanager/task-launcher.c 2009-04-18 00:36:20 +0000 | |||
2078 | +++ applets/taskmanager/task-launcher.c 2009-06-20 14:17:54 +0000 | |||
2079 | @@ -14,7 +14,7 @@ | |||
2080 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2081 | 15 | * | 15 | * |
2082 | 16 | * Authored by Neil Jagdish Patel <njpatel@gmail.com> | 16 | * Authored by Neil Jagdish Patel <njpatel@gmail.com> |
2084 | 17 | * | 17 | * Hannes Verschore <hv1989@gmail.com> |
2085 | 18 | */ | 18 | */ |
2086 | 19 | 19 | ||
2087 | 20 | #include <stdio.h> | 20 | #include <stdio.h> |
2088 | @@ -28,19 +28,18 @@ | |||
2089 | 28 | #include <libawn/libawn.h> | 28 | #include <libawn/libawn.h> |
2090 | 29 | 29 | ||
2091 | 30 | #include "task-launcher.h" | 30 | #include "task-launcher.h" |
2092 | 31 | #include "task-item.h" | ||
2093 | 31 | #include "task-window.h" | 32 | #include "task-window.h" |
2094 | 32 | 33 | ||
2095 | 33 | #include "task-settings.h" | 34 | #include "task-settings.h" |
2096 | 34 | #include "xutils.h" | 35 | #include "xutils.h" |
2097 | 35 | 36 | ||
2099 | 36 | G_DEFINE_TYPE (TaskLauncher, task_launcher, TASK_TYPE_WINDOW) | 37 | G_DEFINE_TYPE (TaskLauncher, task_launcher, TASK_TYPE_ITEM) |
2100 | 37 | 38 | ||
2101 | 38 | #define TASK_LAUNCHER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj),\ | 39 | #define TASK_LAUNCHER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj),\ |
2102 | 39 | TASK_TYPE_LAUNCHER, \ | 40 | TASK_TYPE_LAUNCHER, \ |
2103 | 40 | TaskLauncherPrivate)) | 41 | TaskLauncherPrivate)) |
2104 | 41 | 42 | ||
2105 | 42 | #define GET_WINDOW_PRIVATE(obj) (TASK_WINDOW(obj)->priv) | ||
2106 | 43 | |||
2107 | 44 | struct _TaskLauncherPrivate | 43 | struct _TaskLauncherPrivate |
2108 | 45 | { | 44 | { |
2109 | 46 | gchar *path; | 45 | gchar *path; |
2110 | @@ -59,15 +58,15 @@ | |||
2111 | 59 | }; | 58 | }; |
2112 | 60 | 59 | ||
2113 | 61 | /* Forwards */ | 60 | /* Forwards */ |
2123 | 62 | static gint _get_pid (TaskWindow *window); | 61 | static const gchar * _get_name (TaskItem *item); |
2124 | 63 | static const gchar * _get_name (TaskWindow *window); | 62 | static GdkPixbuf * _get_icon (TaskItem *item); |
2125 | 64 | static GdkPixbuf * _get_icon (TaskWindow *window); | 63 | static gboolean _is_visible (TaskItem *item); |
2126 | 65 | static gboolean _is_on_workspace (TaskWindow *window, | 64 | static void _left_click (TaskItem *item, |
2127 | 66 | WnckWorkspace *space); | 65 | GdkEventButton *event); |
2128 | 67 | static void _activate (TaskWindow *window, | 66 | static void _right_click (TaskItem *item, |
2129 | 68 | guint32 timestamp); | 67 | GdkEventButton *event); |
2130 | 69 | static void _popup_menu (TaskWindow *window, | 68 | static guint _match (TaskItem *item, |
2131 | 70 | GtkMenu *menu); | 69 | TaskItem *item_to_match); |
2132 | 71 | 70 | ||
2133 | 72 | static void task_launcher_set_desktop_file (TaskLauncher *launcher, | 71 | static void task_launcher_set_desktop_file (TaskLauncher *launcher, |
2134 | 73 | const gchar *path); | 72 | const gchar *path); |
2135 | @@ -115,19 +114,19 @@ | |||
2136 | 115 | task_launcher_class_init (TaskLauncherClass *klass) | 114 | task_launcher_class_init (TaskLauncherClass *klass) |
2137 | 116 | { | 115 | { |
2138 | 117 | GParamSpec *pspec; | 116 | GParamSpec *pspec; |
2141 | 118 | GObjectClass *obj_class = G_OBJECT_CLASS (klass); | 117 | GObjectClass *obj_class = G_OBJECT_CLASS (klass); |
2142 | 119 | TaskWindowClass *win_class = TASK_WINDOW_CLASS (klass); | 118 | TaskItemClass *item_class = TASK_ITEM_CLASS (klass); |
2143 | 120 | 119 | ||
2144 | 121 | obj_class->set_property = task_launcher_set_property; | 120 | obj_class->set_property = task_launcher_set_property; |
2145 | 122 | obj_class->get_property = task_launcher_get_property; | 121 | obj_class->get_property = task_launcher_get_property; |
2146 | 123 | 122 | ||
2147 | 124 | /* We implement the necessary funtions for a normal window */ | 123 | /* We implement the necessary funtions for a normal window */ |
2154 | 125 | win_class->get_pid = _get_pid; | 124 | item_class->get_name = _get_name; |
2155 | 126 | win_class->get_name = _get_name; | 125 | item_class->get_icon = _get_icon; |
2156 | 127 | win_class->get_icon = _get_icon; | 126 | item_class->is_visible = _is_visible; |
2157 | 128 | win_class->is_on_workspace = _is_on_workspace; | 127 | item_class->match = _match; |
2158 | 129 | win_class->activate = _activate; | 128 | item_class->left_click = _left_click; |
2159 | 130 | win_class->popup_menu = _popup_menu; | 129 | item_class->right_click = _right_click; |
2160 | 131 | 130 | ||
2161 | 132 | /* Install properties */ | 131 | /* Install properties */ |
2162 | 133 | pspec = g_param_spec_string ("desktopfile", | 132 | pspec = g_param_spec_string ("desktopfile", |
2163 | @@ -151,19 +150,19 @@ | |||
2164 | 151 | priv->item = NULL; | 150 | priv->item = NULL; |
2165 | 152 | } | 151 | } |
2166 | 153 | 152 | ||
2168 | 154 | TaskLauncher * | 153 | TaskItem * |
2169 | 155 | task_launcher_new_for_desktop_file (const gchar *path) | 154 | task_launcher_new_for_desktop_file (const gchar *path) |
2170 | 156 | { | 155 | { |
2172 | 157 | TaskLauncher *win = NULL; | 156 | TaskItem *item = NULL; |
2173 | 158 | 157 | ||
2174 | 159 | if (!g_file_test (path, G_FILE_TEST_EXISTS)) | 158 | if (!g_file_test (path, G_FILE_TEST_EXISTS)) |
2175 | 160 | return NULL; | 159 | return NULL; |
2176 | 161 | 160 | ||
2180 | 162 | win = g_object_new (TASK_TYPE_LAUNCHER, | 161 | item = g_object_new (TASK_TYPE_LAUNCHER, |
2181 | 163 | "desktopfile", path, | 162 | "desktopfile", path, |
2182 | 164 | NULL); | 163 | NULL); |
2183 | 165 | 164 | ||
2185 | 166 | return win; | 165 | return item; |
2186 | 167 | } | 166 | } |
2187 | 168 | 167 | ||
2188 | 169 | const gchar * | 168 | const gchar * |
2189 | @@ -178,6 +177,8 @@ | |||
2190 | 178 | task_launcher_set_desktop_file (TaskLauncher *launcher, const gchar *path) | 177 | task_launcher_set_desktop_file (TaskLauncher *launcher, const gchar *path) |
2191 | 179 | { | 178 | { |
2192 | 180 | TaskLauncherPrivate *priv; | 179 | TaskLauncherPrivate *priv; |
2193 | 180 | TaskSettings * s = task_settings_get_default (); | ||
2194 | 181 | GdkPixbuf *pixbuf; | ||
2195 | 181 | gchar * exec_key = NULL; | 182 | gchar * exec_key = NULL; |
2196 | 182 | gchar * needle = NULL; | 183 | gchar * needle = NULL; |
2197 | 183 | 184 | ||
2198 | @@ -210,194 +211,161 @@ | |||
2199 | 210 | priv->exec = exec_key; | 211 | priv->exec = exec_key; |
2200 | 211 | priv->icon_name = awn_desktop_item_get_icon_name (priv->item); | 212 | priv->icon_name = awn_desktop_item_get_icon_name (priv->item); |
2201 | 212 | 213 | ||
2202 | 214 | task_item_emit_name_changed (TASK_ITEM (launcher), priv->name); | ||
2203 | 215 | pixbuf = awn_desktop_item_get_icon (priv->item, s->panel_size); | ||
2204 | 216 | task_item_emit_icon_changed (TASK_ITEM (launcher), pixbuf); | ||
2205 | 217 | g_object_unref (pixbuf); | ||
2206 | 218 | task_item_emit_visible_changed (TASK_ITEM (launcher), TRUE); | ||
2207 | 219 | |||
2208 | 213 | g_debug ("LAUNCHER: %s", priv->name); | 220 | g_debug ("LAUNCHER: %s", priv->name); |
2209 | 214 | } | 221 | } |
2210 | 215 | 222 | ||
2211 | 216 | /* | 223 | /* |
2212 | 217 | * Implemented functions for a standard window without a launcher | 224 | * Implemented functions for a standard window without a launcher |
2213 | 218 | */ | 225 | */ |
2214 | 219 | static gint | ||
2215 | 220 | _get_pid (TaskWindow *window) | ||
2216 | 221 | { | ||
2217 | 222 | TaskLauncher *launcher = TASK_LAUNCHER (window); | ||
2218 | 223 | |||
2219 | 224 | if (WNCK_IS_WINDOW (window->priv->window)) | ||
2220 | 225 | { | ||
2221 | 226 | gint value = -1; | ||
2222 | 227 | value = wnck_window_get_pid (window->priv->window); | ||
2223 | 228 | value = value ? value : -1; | ||
2224 | 229 | return value; | ||
2225 | 230 | } | ||
2226 | 231 | else | ||
2227 | 232 | { | ||
2228 | 233 | return launcher->priv->pid; | ||
2229 | 234 | } | ||
2230 | 235 | } | ||
2231 | 236 | |||
2232 | 237 | static const gchar * | 226 | static const gchar * |
2234 | 238 | _get_name (TaskWindow *window) | 227 | _get_name (TaskItem *item) |
2235 | 239 | { | 228 | { |
2246 | 240 | TaskLauncher *launcher = TASK_LAUNCHER (window); | 229 | return TASK_LAUNCHER (item)->priv->name; |
2237 | 241 | |||
2238 | 242 | if (WNCK_IS_WINDOW (window->priv->window)) | ||
2239 | 243 | { | ||
2240 | 244 | return wnck_window_get_name (window->priv->window); | ||
2241 | 245 | } | ||
2242 | 246 | else | ||
2243 | 247 | { | ||
2244 | 248 | return launcher->priv->name; | ||
2245 | 249 | } | ||
2247 | 250 | } | 230 | } |
2248 | 251 | 231 | ||
2249 | 252 | static GdkPixbuf * | 232 | static GdkPixbuf * |
2251 | 253 | _get_icon (TaskWindow *window) | 233 | _get_icon (TaskItem *item) |
2252 | 254 | { | 234 | { |
2253 | 255 | TaskLauncher *launcher = TASK_LAUNCHER (window); | ||
2254 | 256 | TaskSettings *s = task_settings_get_default (); | 235 | TaskSettings *s = task_settings_get_default (); |
2255 | 257 | 236 | ||
2265 | 258 | if (WNCK_IS_WINDOW (window->priv->window)) | 237 | return awn_desktop_item_get_icon (TASK_LAUNCHER (item)->priv->item, s->panel_size); |
2257 | 259 | { | ||
2258 | 260 | return _wnck_get_icon_at_size (window->priv->window, | ||
2259 | 261 | s->panel_size, s->panel_size); | ||
2260 | 262 | } | ||
2261 | 263 | else | ||
2262 | 264 | { | ||
2263 | 265 | return awn_desktop_item_get_icon (launcher->priv->item, s->panel_size); | ||
2264 | 266 | } | ||
2266 | 267 | } | 238 | } |
2267 | 268 | 239 | ||
2271 | 269 | static gboolean | 240 | static gboolean |
2272 | 270 | _is_on_workspace (TaskWindow *window, | 241 | _is_visible (TaskItem *item) |
2270 | 271 | WnckWorkspace *space) | ||
2273 | 272 | { | 242 | { |
2274 | 273 | return TRUE; | 243 | return TRUE; |
2275 | 274 | } | 244 | } |
2276 | 275 | 245 | ||
2298 | 276 | static void | 246 | /** |
2299 | 277 | _activate (TaskWindow *window, | 247 | * Match the launcher with the provided window. |
2300 | 278 | guint32 timestamp) | 248 | * The higher the number it returns the more it matches the window. |
2301 | 279 | { | 249 | * 100 = definitly matches |
2302 | 280 | TaskLauncher *launcher = TASK_LAUNCHER (window); | 250 | * 0 = doesn't match |
2282 | 281 | GError *error = NULL; | ||
2283 | 282 | |||
2284 | 283 | launcher->priv->pid = awn_desktop_item_launch (launcher->priv->item, | ||
2285 | 284 | NULL, &error); | ||
2286 | 285 | |||
2287 | 286 | if (error) | ||
2288 | 287 | { | ||
2289 | 288 | g_warning ("Unable to launch %s: %s", | ||
2290 | 289 | launcher->priv->name, | ||
2291 | 290 | error->message); | ||
2292 | 291 | g_error_free (error); | ||
2293 | 292 | } | ||
2294 | 293 | } | ||
2295 | 294 | |||
2296 | 295 | /* | ||
2297 | 296 | * Public functions | ||
2303 | 297 | */ | 251 | */ |
2319 | 298 | gboolean | 252 | static guint |
2320 | 299 | task_launcher_has_window (TaskLauncher *launcher) | 253 | _match (TaskItem *item, |
2321 | 300 | { | 254 | TaskItem *item_to_match) |
2307 | 301 | g_return_val_if_fail (TASK_IS_LAUNCHER (launcher), TRUE); | ||
2308 | 302 | |||
2309 | 303 | if (WNCK_IS_WINDOW (TASK_WINDOW (launcher)->priv->window)) | ||
2310 | 304 | return TRUE; | ||
2311 | 305 | return FALSE; | ||
2312 | 306 | } | ||
2313 | 307 | |||
2314 | 308 | gboolean | ||
2315 | 309 | task_launcher_try_match (TaskLauncher *launcher, | ||
2316 | 310 | gint pid, | ||
2317 | 311 | const gchar *res_name, | ||
2318 | 312 | const gchar *class_name) | ||
2322 | 313 | { | 255 | { |
2323 | 314 | TaskLauncherPrivate *priv; | 256 | TaskLauncherPrivate *priv; |
2326 | 315 | 257 | TaskLauncher *launcher; | |
2327 | 316 | g_return_val_if_fail (launcher, FALSE); | 258 | TaskWindow *window; |
2328 | 259 | gchar *res_name = NULL; | ||
2329 | 260 | gchar *class_name = NULL; | ||
2330 | 261 | gchar *temp; | ||
2331 | 262 | gint pid; | ||
2332 | 263 | |||
2333 | 264 | g_return_val_if_fail (TASK_IS_LAUNCHER(item), 0); | ||
2334 | 265 | |||
2335 | 266 | if (!TASK_IS_WINDOW (item_to_match)) return 0; | ||
2336 | 267 | |||
2337 | 268 | launcher = TASK_LAUNCHER (item); | ||
2338 | 317 | priv = launcher->priv; | 269 | priv = launcher->priv; |
2339 | 270 | |||
2340 | 271 | window = TASK_WINDOW (item_to_match); | ||
2341 | 318 | 272 | ||
2342 | 319 | /* Try simple pid-match first */ | 273 | /* Try simple pid-match first */ |
2343 | 274 | pid = task_window_get_pid(window); | ||
2344 | 320 | if ( pid && (priv->pid == pid)) | 275 | if ( pid && (priv->pid == pid)) |
2346 | 321 | return TRUE; | 276 | return 100; |
2347 | 322 | 277 | ||
2348 | 323 | /* Now try resource name, which should (hopefully) be 99% of the cases */ | 278 | /* Now try resource name, which should (hopefully) be 99% of the cases */ |
2350 | 324 | if ( res_name && strlen(res_name) && priv->exec) | 279 | task_window_get_wm_class(window, &res_name, &class_name); |
2351 | 280 | |||
2352 | 281 | if (res_name) | ||
2353 | 325 | { | 282 | { |
2356 | 326 | if ( g_strstr_len (priv->exec, strlen (priv->exec), res_name) || | 283 | temp = res_name; |
2357 | 327 | g_strstr_len (res_name, strlen (res_name), priv->exec)) | 284 | res_name = g_utf8_strdown (temp, -1); |
2358 | 285 | g_free (temp); | ||
2359 | 286 | |||
2360 | 287 | if ( strlen(res_name) && priv->exec) | ||
2361 | 328 | { | 288 | { |
2363 | 329 | return TRUE; | 289 | if ( g_strstr_len (priv->exec, strlen (priv->exec), res_name) || |
2364 | 290 | g_strstr_len (res_name, strlen (res_name), priv->exec)) | ||
2365 | 291 | { | ||
2366 | 292 | g_free (res_name); | ||
2367 | 293 | g_free (class_name); | ||
2368 | 294 | return 70; | ||
2369 | 295 | } | ||
2370 | 330 | } | 296 | } |
2371 | 331 | } | 297 | } |
2373 | 332 | 298 | ||
2374 | 333 | /* Try a class_name to exec line match */ | 299 | /* Try a class_name to exec line match */ |
2442 | 334 | if ( class_name && strlen(class_name) && priv->exec) | 300 | if (class_name) |
2443 | 335 | { | 301 | { |
2444 | 336 | if (g_strstr_len (priv->exec, strlen (priv->exec), class_name)) | 302 | temp = class_name; |
2445 | 337 | return TRUE; | 303 | class_name = g_utf8_strdown (temp, -1); |
2446 | 338 | } | 304 | g_free (temp); |
2447 | 339 | 305 | ||
2448 | 340 | return FALSE; | 306 | if (strlen(class_name) && priv->exec) |
2449 | 341 | } | 307 | { |
2450 | 342 | 308 | if (g_strstr_len (priv->exec, strlen (priv->exec), class_name)) | |
2451 | 343 | static void | 309 | { |
2452 | 344 | on_window_closed (TaskLauncher *launcher, WnckWindow *old_window) | 310 | g_free (res_name); |
2453 | 345 | { | 311 | g_free (class_name); |
2454 | 346 | TaskWindowPrivate *priv; | 312 | return 50; |
2455 | 347 | TaskSettings *s = task_settings_get_default (); | 313 | } |
2456 | 348 | GdkPixbuf *pixbuf; | 314 | } |
2457 | 349 | 315 | } | |
2458 | 350 | g_return_if_fail (TASK_IS_LAUNCHER (launcher)); | 316 | |
2459 | 351 | priv = TASK_WINDOW (launcher)->priv; | 317 | g_free (res_name); |
2460 | 352 | 318 | g_free (class_name); | |
2461 | 353 | /* NULLify the window pointer */ | 319 | return 0; |
2462 | 354 | priv->window = NULL; | 320 | } |
2463 | 355 | 321 | ||
2464 | 356 | /* Reset name */ | 322 | static void |
2465 | 357 | task_window_set_name (TASK_WINDOW (launcher), launcher->priv->name); | 323 | _left_click (TaskItem *item, GdkEventButton *event) |
2466 | 358 | 324 | { | |
2467 | 359 | /* Reset icon */ | 325 | TaskLauncherPrivate *priv; |
2468 | 360 | pixbuf = xutils_get_named_icon (launcher->priv->icon_name, | 326 | TaskLauncher *launcher; |
2469 | 361 | s->panel_size, s->panel_size); | 327 | GError *error = NULL; |
2470 | 362 | 328 | ||
2471 | 363 | task_window_update_icon (TASK_WINDOW (launcher), pixbuf); | 329 | g_return_if_fail (TASK_IS_LAUNCHER (item)); |
2472 | 364 | 330 | ||
2473 | 365 | g_object_unref (pixbuf); | 331 | launcher = TASK_LAUNCHER (item); |
2474 | 366 | } | 332 | priv = launcher->priv; |
2475 | 367 | 333 | ||
2476 | 368 | void | 334 | priv->pid = awn_desktop_item_launch (priv->item, NULL, &error); |
2477 | 369 | task_launcher_set_window (TaskLauncher *launcher, | 335 | |
2478 | 370 | WnckWindow *window) | 336 | if (error) |
2479 | 371 | { | 337 | { |
2480 | 372 | g_return_if_fail (TASK_IS_LAUNCHER (launcher)); | 338 | g_warning ("Unable to launch %s: %s", |
2481 | 373 | g_return_if_fail (WNCK_IS_WINDOW (window)); | 339 | task_item_get_name (item), |
2482 | 374 | 340 | error->message); | |
2483 | 375 | g_object_set (launcher, "taskwindow", window, NULL); | 341 | g_error_free (error); |
2484 | 376 | 342 | } | |
2485 | 377 | task_window_set_name (TASK_WINDOW (launcher), wnck_window_get_name (window)); | 343 | } |
2486 | 378 | 344 | ||
2487 | 379 | g_object_weak_ref (G_OBJECT (window), | 345 | static void |
2488 | 380 | (GWeakNotify)on_window_closed, | 346 | _right_click (TaskItem *item, GdkEventButton *event) |
2489 | 381 | launcher); | 347 | { |
2490 | 382 | } | 348 | TaskLauncherPrivate *priv; |
2491 | 383 | 349 | TaskLauncher *launcher; | |
2492 | 384 | static void | 350 | GtkWidget *menu_item, |
2493 | 385 | _popup_menu (TaskWindow *window, | 351 | *menu; |
2494 | 386 | GtkMenu *menu) | 352 | |
2495 | 387 | { | 353 | g_return_if_fail (TASK_IS_LAUNCHER (item)); |
2496 | 388 | TaskWindowPrivate *priv; | 354 | |
2497 | 389 | GtkWidget *item; | 355 | launcher = TASK_LAUNCHER (item); |
2498 | 390 | 356 | priv = launcher->priv; | |
2499 | 391 | g_return_if_fail (TASK_IS_WINDOW (window)); | 357 | |
2500 | 392 | priv = window->priv; | 358 | menu = gtk_menu_new (); |
2501 | 393 | 359 | menu_item = gtk_image_menu_item_new_from_stock (GTK_STOCK_EXECUTE, NULL); | |
2502 | 394 | if (!WNCK_IS_WINDOW (priv->window)) | 360 | gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item); |
2503 | 395 | { | 361 | gtk_widget_show (menu_item); |
2504 | 396 | item = gtk_image_menu_item_new_from_stock (GTK_STOCK_EXECUTE, NULL); | 362 | gtk_menu_popup (GTK_MENU (menu), NULL, NULL, |
2505 | 397 | gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); | 363 | NULL, NULL, event->button, event->time); |
2506 | 398 | gtk_widget_show (item); | 364 | } |
2507 | 399 | } | 365 | |
2508 | 400 | } | 366 | /* |
2509 | 367 | * Public functions | ||
2510 | 368 | */ | ||
2511 | 401 | 369 | ||
2512 | 402 | void | 370 | void |
2513 | 403 | task_launcher_launch_with_data (TaskLauncher *launcher, | 371 | task_launcher_launch_with_data (TaskLauncher *launcher, |
2514 | @@ -429,10 +397,7 @@ | |||
2515 | 429 | g_return_if_fail (TASK_IS_LAUNCHER (launcher)); | 397 | g_return_if_fail (TASK_IS_LAUNCHER (launcher)); |
2516 | 430 | priv = launcher->priv; | 398 | priv = launcher->priv; |
2517 | 431 | 399 | ||
2522 | 432 | if (WNCK_IS_WINDOW (TASK_WINDOW (launcher)->priv->window)) | 400 | priv->pid = awn_desktop_item_launch (priv->item, NULL, &error); |
2519 | 433 | awn_desktop_item_launch (priv->item, NULL, &error); | ||
2520 | 434 | else | ||
2521 | 435 | priv->pid = awn_desktop_item_launch (priv->item, NULL, &error); | ||
2523 | 436 | 401 | ||
2524 | 437 | if (error) | 402 | if (error) |
2525 | 438 | { | 403 | { |
2526 | 439 | 404 | ||
2527 | === modified file 'applets/taskmanager/task-launcher.h' | |||
2528 | --- applets/taskmanager/task-launcher.h 2008-12-26 15:19:53 +0000 | |||
2529 | +++ applets/taskmanager/task-launcher.h 2009-06-20 14:17:54 +0000 | |||
2530 | @@ -14,6 +14,7 @@ | |||
2531 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2532 | 15 | * | 15 | * |
2533 | 16 | * Authored by Neil Jagdish Patel <njpatel@gmail.com> | 16 | * Authored by Neil Jagdish Patel <njpatel@gmail.com> |
2534 | 17 | * Hannes Verschore <hv1989@gmail.com> | ||
2535 | 17 | * | 18 | * |
2536 | 18 | */ | 19 | */ |
2537 | 19 | 20 | ||
2538 | @@ -24,7 +25,7 @@ | |||
2539 | 24 | #include <gtk/gtk.h> | 25 | #include <gtk/gtk.h> |
2540 | 25 | #include <libwnck/libwnck.h> | 26 | #include <libwnck/libwnck.h> |
2541 | 26 | 27 | ||
2543 | 27 | #include "task-window.h" | 28 | #include "task-item.h" |
2544 | 28 | 29 | ||
2545 | 29 | #define TASK_TYPE_LAUNCHER (task_launcher_get_type ()) | 30 | #define TASK_TYPE_LAUNCHER (task_launcher_get_type ()) |
2546 | 30 | 31 | ||
2547 | @@ -49,38 +50,24 @@ | |||
2548 | 49 | 50 | ||
2549 | 50 | struct _TaskLauncher | 51 | struct _TaskLauncher |
2550 | 51 | { | 52 | { |
2552 | 52 | TaskWindow parent; | 53 | TaskItem parent; |
2553 | 53 | 54 | ||
2554 | 54 | TaskLauncherPrivate *priv; | 55 | TaskLauncherPrivate *priv; |
2555 | 55 | }; | 56 | }; |
2556 | 56 | 57 | ||
2557 | 57 | struct _TaskLauncherClass | 58 | struct _TaskLauncherClass |
2558 | 58 | { | 59 | { |
2560 | 59 | TaskWindowClass parent_class; | 60 | TaskItemClass parent_class; |
2561 | 60 | 61 | ||
2562 | 61 | /*< signals >*/ | 62 | /*< signals >*/ |
2563 | 62 | void (*launcher0) (void); | ||
2564 | 63 | void (*launcher1) (void); | ||
2565 | 64 | void (*launcher2) (void); | ||
2566 | 65 | void (*launcher3) (void); | ||
2567 | 66 | }; | 63 | }; |
2568 | 67 | 64 | ||
2569 | 68 | GType task_launcher_get_type (void) G_GNUC_CONST; | 65 | GType task_launcher_get_type (void) G_GNUC_CONST; |
2570 | 69 | 66 | ||
2572 | 70 | TaskLauncher * task_launcher_new_for_desktop_file (const gchar *path); | 67 | TaskItem * task_launcher_new_for_desktop_file (const gchar *path); |
2573 | 71 | 68 | ||
2574 | 72 | const gchar * task_launcher_get_desktop_path (TaskLauncher *launcher); | 69 | const gchar * task_launcher_get_desktop_path (TaskLauncher *launcher); |
2575 | 73 | 70 | ||
2576 | 74 | gboolean task_launcher_has_window (TaskLauncher *launcher); | ||
2577 | 75 | |||
2578 | 76 | gboolean task_launcher_try_match (TaskLauncher *launcher, | ||
2579 | 77 | gint pid, | ||
2580 | 78 | const gchar *res_name, | ||
2581 | 79 | const gchar *class_name); | ||
2582 | 80 | |||
2583 | 81 | void task_launcher_set_window (TaskLauncher *launcher, | ||
2584 | 82 | WnckWindow *window); | ||
2585 | 83 | |||
2586 | 84 | void task_launcher_launch_with_data (TaskLauncher *launcher, | 71 | void task_launcher_launch_with_data (TaskLauncher *launcher, |
2587 | 85 | GSList *list); | 72 | GSList *list); |
2588 | 86 | 73 | ||
2589 | 87 | 74 | ||
2590 | === added file 'applets/taskmanager/task-manager-api-wrapper.c' | |||
2591 | --- applets/taskmanager/task-manager-api-wrapper.c 1970-01-01 00:00:00 +0000 | |||
2592 | +++ applets/taskmanager/task-manager-api-wrapper.c 2009-06-26 11:00:10 +0000 | |||
2593 | @@ -0,0 +1,509 @@ | |||
2594 | 1 | /* | ||
2595 | 2 | * Copyright (C) 2008 Neil Jagdish Patel <njpatel@gmail.com> | ||
2596 | 3 | * | ||
2597 | 4 | * This program is free software: you can redistribute it and/or modify | ||
2598 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
2599 | 6 | * published by the Free Software Foundation. | ||
2600 | 7 | * | ||
2601 | 8 | * This program is distributed in the hope that it will be useful, | ||
2602 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
2603 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
2604 | 11 | * GNU General Public License for more details. | ||
2605 | 12 | * | ||
2606 | 13 | * You should have received a copy of the GNU General Public License | ||
2607 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2608 | 15 | * | ||
2609 | 16 | * Authored by Hannes Verschore <hv1989@gmail.com> | ||
2610 | 17 | */ | ||
2611 | 18 | |||
2612 | 19 | |||
2613 | 20 | #include "task-manager-api-wrapper.h" | ||
2614 | 21 | |||
2615 | 22 | #include <libawn/libawn.h> | ||
2616 | 23 | |||
2617 | 24 | G_DEFINE_TYPE (TaskManagerApiWrapper, task_manager_api_wrapper, G_TYPE_OBJECT) | ||
2618 | 25 | |||
2619 | 26 | #define TASK_MANAGER_API_WRAPPER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj),\ | ||
2620 | 27 | TASK_TYPE_MANAGER_API_WRAPPER, \ | ||
2621 | 28 | TaskManagerApiWrapperPrivate)) | ||
2622 | 29 | |||
2623 | 30 | struct _TaskManagerApiWrapperPrivate | ||
2624 | 31 | { | ||
2625 | 32 | TaskManager *manager; | ||
2626 | 33 | }; | ||
2627 | 34 | |||
2628 | 35 | enum | ||
2629 | 36 | { | ||
2630 | 37 | PROP_0, | ||
2631 | 38 | PROP_MANAGER | ||
2632 | 39 | }; | ||
2633 | 40 | |||
2634 | 41 | /* GObject stuff */ | ||
2635 | 42 | |||
2636 | 43 | static void | ||
2637 | 44 | task_manager_api_wrapper_set_manager (TaskManagerApiWrapper *wrapper, | ||
2638 | 45 | TaskManager *manager) | ||
2639 | 46 | { | ||
2640 | 47 | g_return_if_fail (TASK_IS_MANAGER_API_WRAPPER (wrapper)); | ||
2641 | 48 | g_return_if_fail (TASK_IS_MANAGER (manager)); | ||
2642 | 49 | |||
2643 | 50 | wrapper->priv->manager = manager; | ||
2644 | 51 | } | ||
2645 | 52 | |||
2646 | 53 | static void | ||
2647 | 54 | task_manager_api_wrapper_get_property (GObject *object, | ||
2648 | 55 | guint prop_id, | ||
2649 | 56 | GValue *value, | ||
2650 | 57 | GParamSpec *pspec) | ||
2651 | 58 | { | ||
2652 | 59 | TaskManagerApiWrapper *wrapper = TASK_MANAGER_API_WRAPPER (object); | ||
2653 | 60 | |||
2654 | 61 | switch (prop_id) | ||
2655 | 62 | { | ||
2656 | 63 | case PROP_MANAGER: | ||
2657 | 64 | g_value_set_object (value, wrapper->priv->manager); | ||
2658 | 65 | break; | ||
2659 | 66 | |||
2660 | 67 | default: | ||
2661 | 68 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); | ||
2662 | 69 | } | ||
2663 | 70 | } | ||
2664 | 71 | |||
2665 | 72 | static void | ||
2666 | 73 | task_manager_api_wrapper_set_property (GObject *object, | ||
2667 | 74 | guint prop_id, | ||
2668 | 75 | const GValue *value, | ||
2669 | 76 | GParamSpec *pspec) | ||
2670 | 77 | { | ||
2671 | 78 | TaskManagerApiWrapper *wrapper = TASK_MANAGER_API_WRAPPER (object); | ||
2672 | 79 | |||
2673 | 80 | switch (prop_id) | ||
2674 | 81 | { | ||
2675 | 82 | case PROP_MANAGER: | ||
2676 | 83 | task_manager_api_wrapper_set_manager (wrapper, g_value_get_object (value)); | ||
2677 | 84 | break; | ||
2678 | 85 | |||
2679 | 86 | default: | ||
2680 | 87 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); | ||
2681 | 88 | } | ||
2682 | 89 | } | ||
2683 | 90 | |||
2684 | 91 | /* GObject stuff */ | ||
2685 | 92 | static void | ||
2686 | 93 | task_manager_api_wrapper_class_init (TaskManagerApiWrapperClass *klass) | ||
2687 | 94 | { | ||
2688 | 95 | GParamSpec *pspec; | ||
2689 | 96 | GObjectClass *obj_class = G_OBJECT_CLASS (klass); | ||
2690 | 97 | |||
2691 | 98 | obj_class->set_property = task_manager_api_wrapper_set_property; | ||
2692 | 99 | obj_class->get_property = task_manager_api_wrapper_get_property; | ||
2693 | 100 | |||
2694 | 101 | /* Install properties */ | ||
2695 | 102 | pspec = g_param_spec_object ("manager", | ||
2696 | 103 | "Manager", | ||
2697 | 104 | "TaskManager", | ||
2698 | 105 | TASK_TYPE_MANAGER, | ||
2699 | 106 | G_PARAM_READWRITE); | ||
2700 | 107 | g_object_class_install_property (obj_class, PROP_MANAGER, pspec); | ||
2701 | 108 | |||
2702 | 109 | g_type_class_add_private (obj_class, sizeof (TaskManagerApiWrapperPrivate)); | ||
2703 | 110 | } | ||
2704 | 111 | |||
2705 | 112 | static void | ||
2706 | 113 | task_manager_api_wrapper_init (TaskManagerApiWrapper *wrapper) | ||
2707 | 114 | { | ||
2708 | 115 | TaskManagerApiWrapperPrivate *priv; | ||
2709 | 116 | |||
2710 | 117 | /* get and save private struct */ | ||
2711 | 118 | priv = wrapper->priv = TASK_MANAGER_API_WRAPPER_GET_PRIVATE (wrapper); | ||
2712 | 119 | priv->manager = NULL; | ||
2713 | 120 | } | ||
2714 | 121 | |||
2715 | 122 | |||
2716 | 123 | TaskManagerApiWrapper * | ||
2717 | 124 | task_manager_api_wrapper_new (TaskManager *manager) | ||
2718 | 125 | { | ||
2719 | 126 | TaskManagerApiWrapper *wrapper = NULL; | ||
2720 | 127 | |||
2721 | 128 | wrapper = g_object_new (TASK_TYPE_MANAGER_API_WRAPPER, | ||
2722 | 129 | "manager", manager, | ||
2723 | 130 | NULL); | ||
2724 | 131 | |||
2725 | 132 | return wrapper; | ||
2726 | 133 | } | ||
2727 | 134 | |||
2728 | 135 | gboolean | ||
2729 | 136 | task_manager_api_wrapper_set_task_icon_by_name (TaskManagerApiWrapper *wrapper, | ||
2730 | 137 | gchar *name, | ||
2731 | 138 | gchar *icon_path, | ||
2732 | 139 | GError **error) | ||
2733 | 140 | { | ||
2734 | 141 | TaskManagerApiWrapperPrivate *priv; | ||
2735 | 142 | gboolean succeeded; | ||
2736 | 143 | GValue window = {0}; | ||
2737 | 144 | GHashTable *hints; | ||
2738 | 145 | const gchar *key = "icon-file"; | ||
2739 | 146 | GValue value = {0}; | ||
2740 | 147 | |||
2741 | 148 | g_return_val_if_fail (TASK_IS_MANAGER_API_WRAPPER (wrapper), FALSE); | ||
2742 | 149 | |||
2743 | 150 | priv = wrapper->priv; | ||
2744 | 151 | |||
2745 | 152 | g_value_init (&window, G_TYPE_STRING); | ||
2746 | 153 | g_value_set_string (&window, name); | ||
2747 | 154 | |||
2748 | 155 | g_value_init (&value, G_TYPE_STRING); | ||
2749 | 156 | g_value_set_string (&value, icon_path); | ||
2750 | 157 | |||
2751 | 158 | hints = g_hash_table_new (g_str_hash, g_str_equal); | ||
2752 | 159 | g_hash_table_insert (hints, (gpointer)key, &value); | ||
2753 | 160 | |||
2754 | 161 | succeeded = task_manager_update (priv->manager, | ||
2755 | 162 | &window, | ||
2756 | 163 | hints, | ||
2757 | 164 | error); | ||
2758 | 165 | g_value_unset (&window); | ||
2759 | 166 | g_value_unset (&value); | ||
2760 | 167 | g_hash_table_destroy (hints); | ||
2761 | 168 | |||
2762 | 169 | return succeeded; | ||
2763 | 170 | } | ||
2764 | 171 | |||
2765 | 172 | gboolean | ||
2766 | 173 | task_manager_api_wrapper_unset_task_icon_by_name (TaskManagerApiWrapper *wrapper, | ||
2767 | 174 | gchar *name, | ||
2768 | 175 | GError **error) | ||
2769 | 176 | { | ||
2770 | 177 | TaskManagerApiWrapperPrivate *priv; | ||
2771 | 178 | gboolean succeeded; | ||
2772 | 179 | GValue window = {0}; | ||
2773 | 180 | GHashTable *hints; | ||
2774 | 181 | const gchar *key = "icon-file"; | ||
2775 | 182 | GValue value = {0}; | ||
2776 | 183 | |||
2777 | 184 | g_return_val_if_fail (TASK_IS_MANAGER_API_WRAPPER (wrapper), FALSE); | ||
2778 | 185 | |||
2779 | 186 | priv = wrapper->priv; | ||
2780 | 187 | |||
2781 | 188 | g_value_init (&window, G_TYPE_STRING); | ||
2782 | 189 | g_value_set_string (&window, name); | ||
2783 | 190 | |||
2784 | 191 | g_value_init (&value, G_TYPE_STRING); | ||
2785 | 192 | g_value_set_string (&value, ""); | ||
2786 | 193 | |||
2787 | 194 | hints = g_hash_table_new (g_str_hash, g_str_equal); | ||
2788 | 195 | g_hash_table_insert (hints, (gpointer)key, &value); | ||
2789 | 196 | |||
2790 | 197 | succeeded = task_manager_update (priv->manager, | ||
2791 | 198 | &window, | ||
2792 | 199 | hints, | ||
2793 | 200 | error); | ||
2794 | 201 | g_value_unset (&window); | ||
2795 | 202 | g_value_unset (&value); | ||
2796 | 203 | g_hash_table_destroy (hints); | ||
2797 | 204 | |||
2798 | 205 | return succeeded; | ||
2799 | 206 | } | ||
2800 | 207 | |||
2801 | 208 | gboolean | ||
2802 | 209 | task_manager_api_wrapper_set_info_by_name (TaskManagerApiWrapper *wrapper, | ||
2803 | 210 | gchar *name, | ||
2804 | 211 | gchar *info, | ||
2805 | 212 | GError **error) | ||
2806 | 213 | { | ||
2807 | 214 | TaskManagerApiWrapperPrivate *priv; | ||
2808 | 215 | gboolean succeeded; | ||
2809 | 216 | GValue window = {0}; | ||
2810 | 217 | GHashTable *hints; | ||
2811 | 218 | const gchar *key = "message"; | ||
2812 | 219 | GValue value = {0}; | ||
2813 | 220 | |||
2814 | 221 | g_return_val_if_fail (TASK_IS_MANAGER_API_WRAPPER (wrapper), FALSE); | ||
2815 | 222 | |||
2816 | 223 | priv = wrapper->priv; | ||
2817 | 224 | |||
2818 | 225 | g_value_init (&window, G_TYPE_STRING); | ||
2819 | 226 | g_value_set_string (&window, name); | ||
2820 | 227 | |||
2821 | 228 | g_value_init (&value, G_TYPE_STRING); | ||
2822 | 229 | g_value_set_string (&value, info); | ||
2823 | 230 | |||
2824 | 231 | hints = g_hash_table_new (g_str_hash, g_str_equal); | ||
2825 | 232 | g_hash_table_insert (hints, (gpointer)key, &value); | ||
2826 | 233 | |||
2827 | 234 | succeeded = task_manager_update (priv->manager, | ||
2828 | 235 | &window, | ||
2829 | 236 | hints, | ||
2830 | 237 | error); | ||
2831 | 238 | g_value_unset (&window); | ||
2832 | 239 | g_value_unset (&value); | ||
2833 | 240 | g_hash_table_destroy (hints); | ||
2834 | 241 | |||
2835 | 242 | return succeeded; | ||
2836 | 243 | } | ||
2837 | 244 | |||
2838 | 245 | gboolean | ||
2839 | 246 | task_manager_api_wrapper_unset_info_by_name (TaskManagerApiWrapper *wrapper, | ||
2840 | 247 | gchar *name, | ||
2841 | 248 | GError **error) | ||
2842 | 249 | { | ||
2843 | 250 | TaskManagerApiWrapperPrivate *priv; | ||
2844 | 251 | gboolean succeeded; | ||
2845 | 252 | GValue window = {0}; | ||
2846 | 253 | GHashTable *hints; | ||
2847 | 254 | const gchar *key = "message"; | ||
2848 | 255 | GValue value = {0}; | ||
2849 | 256 | |||
2850 | 257 | g_return_val_if_fail (TASK_IS_MANAGER_API_WRAPPER (wrapper), FALSE); | ||
2851 | 258 | |||
2852 | 259 | priv = wrapper->priv; | ||
2853 | 260 | |||
2854 | 261 | g_value_init (&window, G_TYPE_STRING); | ||
2855 | 262 | g_value_set_string (&window, name); | ||
2856 | 263 | |||
2857 | 264 | g_value_init (&value, G_TYPE_STRING); | ||
2858 | 265 | g_value_set_string (&value, ""); | ||
2859 | 266 | |||
2860 | 267 | hints = g_hash_table_new (g_str_hash, g_str_equal); | ||
2861 | 268 | g_hash_table_insert (hints, (gpointer)key, &value); | ||
2862 | 269 | |||
2863 | 270 | succeeded = task_manager_update (priv->manager, | ||
2864 | 271 | &window, | ||
2865 | 272 | hints, | ||
2866 | 273 | error); | ||
2867 | 274 | g_value_unset (&window); | ||
2868 | 275 | g_value_unset (&value); | ||
2869 | 276 | g_hash_table_destroy (hints); | ||
2870 | 277 | |||
2871 | 278 | return succeeded; | ||
2872 | 279 | } | ||
2873 | 280 | |||
2874 | 281 | gboolean | ||
2875 | 282 | task_manager_api_wrapper_set_progress_by_name (TaskManagerApiWrapper *wrapper, | ||
2876 | 283 | gchar *name, | ||
2877 | 284 | gint progress, | ||
2878 | 285 | GError **error) | ||
2879 | 286 | { | ||
2880 | 287 | TaskManagerApiWrapperPrivate *priv; | ||
2881 | 288 | gboolean succeeded; | ||
2882 | 289 | GValue window = {0}; | ||
2883 | 290 | GHashTable *hints; | ||
2884 | 291 | const gchar *key = "message"; | ||
2885 | 292 | GValue value = {0}; | ||
2886 | 293 | |||
2887 | 294 | g_return_val_if_fail (TASK_IS_MANAGER_API_WRAPPER (wrapper), FALSE); | ||
2888 | 295 | |||
2889 | 296 | priv = wrapper->priv; | ||
2890 | 297 | |||
2891 | 298 | g_value_init (&window, G_TYPE_STRING); | ||
2892 | 299 | g_value_set_string (&window, name); | ||
2893 | 300 | |||
2894 | 301 | //difference between old and new api | ||
2895 | 302 | //unsetting progress indicator by setting progress to -1; | ||
2896 | 303 | if (progress == 100) progress = -1; | ||
2897 | 304 | |||
2898 | 305 | g_value_init (&value, G_TYPE_INT); | ||
2899 | 306 | g_value_set_int (&value, progress); | ||
2900 | 307 | |||
2901 | 308 | hints = g_hash_table_new (g_str_hash, g_str_equal); | ||
2902 | 309 | g_hash_table_insert (hints, (gpointer)key, &value); | ||
2903 | 310 | |||
2904 | 311 | succeeded = task_manager_update (priv->manager, | ||
2905 | 312 | &window, | ||
2906 | 313 | hints, | ||
2907 | 314 | error); | ||
2908 | 315 | g_value_unset (&window); | ||
2909 | 316 | g_value_unset (&value); | ||
2910 | 317 | g_hash_table_destroy (hints); | ||
2911 | 318 | |||
2912 | 319 | return succeeded; | ||
2913 | 320 | } | ||
2914 | 321 | |||
2915 | 322 | /* XID variants */ | ||
2916 | 323 | |||
2917 | 324 | gboolean | ||
2918 | 325 | task_manager_api_wrapper_set_task_icon_by_xid (TaskManagerApiWrapper *wrapper, | ||
2919 | 326 | gint64 xid, | ||
2920 | 327 | gchar *icon_path, | ||
2921 | 328 | GError **error) | ||
2922 | 329 | { | ||
2923 | 330 | TaskManagerApiWrapperPrivate *priv; | ||
2924 | 331 | gboolean succeeded; | ||
2925 | 332 | GValue window = {0}; | ||
2926 | 333 | GHashTable *hints; | ||
2927 | 334 | const gchar *key = "icon-file"; | ||
2928 | 335 | GValue value = {0}; | ||
2929 | 336 | |||
2930 | 337 | g_return_val_if_fail (TASK_IS_MANAGER_API_WRAPPER (wrapper), FALSE); | ||
2931 | 338 | |||
2932 | 339 | priv = wrapper->priv; | ||
2933 | 340 | |||
2934 | 341 | g_value_init (&window, G_TYPE_INT64); | ||
2935 | 342 | g_value_set_int64 (&window, xid); | ||
2936 | 343 | |||
2937 | 344 | g_value_init (&value, G_TYPE_STRING); | ||
2938 | 345 | g_value_set_string (&value, icon_path); | ||
2939 | 346 | |||
2940 | 347 | hints = g_hash_table_new (g_str_hash, g_str_equal); | ||
2941 | 348 | g_hash_table_insert (hints, (gpointer)key, &value); | ||
2942 | 349 | |||
2943 | 350 | succeeded = task_manager_update (priv->manager, | ||
2944 | 351 | &window, | ||
2945 | 352 | hints, | ||
2946 | 353 | error); | ||
2947 | 354 | g_value_unset (&window); | ||
2948 | 355 | g_value_unset (&value); | ||
2949 | 356 | g_hash_table_destroy (hints); | ||
2950 | 357 | |||
2951 | 358 | return succeeded; | ||
2952 | 359 | } | ||
2953 | 360 | |||
2954 | 361 | gboolean | ||
2955 | 362 | task_manager_api_wrapper_unset_task_icon_by_xid (TaskManagerApiWrapper *wrapper, | ||
2956 | 363 | gint64 xid, | ||
2957 | 364 | GError **error) | ||
2958 | 365 | { | ||
2959 | 366 | TaskManagerApiWrapperPrivate *priv; | ||
2960 | 367 | gboolean succeeded; | ||
2961 | 368 | GValue window = {0}; | ||
2962 | 369 | GHashTable *hints; | ||
2963 | 370 | const gchar *key = "icon-file"; | ||
2964 | 371 | GValue value = {0}; | ||
2965 | 372 | |||
2966 | 373 | g_return_val_if_fail (TASK_IS_MANAGER_API_WRAPPER (wrapper), FALSE); | ||
2967 | 374 | |||
2968 | 375 | priv = wrapper->priv; | ||
2969 | 376 | |||
2970 | 377 | g_value_init (&window, G_TYPE_INT64); | ||
2971 | 378 | g_value_set_int64 (&window, xid); | ||
2972 | 379 | |||
2973 | 380 | g_value_init (&value, G_TYPE_STRING); | ||
2974 | 381 | g_value_set_string (&value, ""); | ||
2975 | 382 | |||
2976 | 383 | hints = g_hash_table_new (g_str_hash, g_str_equal); | ||
2977 | 384 | g_hash_table_insert (hints, (gpointer)key, &value); | ||
2978 | 385 | |||
2979 | 386 | succeeded = task_manager_update (priv->manager, | ||
2980 | 387 | &window, | ||
2981 | 388 | hints, | ||
2982 | 389 | error); | ||
2983 | 390 | g_value_unset (&window); | ||
2984 | 391 | g_value_unset (&value); | ||
2985 | 392 | g_hash_table_destroy (hints); | ||
2986 | 393 | |||
2987 | 394 | return succeeded; | ||
2988 | 395 | } | ||
2989 | 396 | |||
2990 | 397 | gboolean | ||
2991 | 398 | task_manager_api_wrapper_set_info_by_xid (TaskManagerApiWrapper *wrapper, | ||
2992 | 399 | gint64 xid, | ||
2993 | 400 | gchar *info, | ||
2994 | 401 | GError **error) | ||
2995 | 402 | { | ||
2996 | 403 | TaskManagerApiWrapperPrivate *priv; | ||
2997 | 404 | gboolean succeeded; | ||
2998 | 405 | GValue window = {0}; | ||
2999 | 406 | GHashTable *hints; | ||
3000 | 407 | const gchar *key = "message"; | ||
3001 | 408 | GValue value = {0}; | ||
3002 | 409 | |||
3003 | 410 | g_return_val_if_fail (TASK_IS_MANAGER_API_WRAPPER (wrapper), FALSE); | ||
3004 | 411 | |||
3005 | 412 | priv = wrapper->priv; | ||
3006 | 413 | |||
3007 | 414 | g_value_init (&window, G_TYPE_INT64); | ||
3008 | 415 | g_value_set_int64 (&window, xid); | ||
3009 | 416 | |||
3010 | 417 | g_value_init (&value, G_TYPE_STRING); | ||
3011 | 418 | g_value_set_string (&value, info); | ||
3012 | 419 | |||
3013 | 420 | hints = g_hash_table_new (g_str_hash, g_str_equal); | ||
3014 | 421 | g_hash_table_insert (hints, (gpointer)key, &value); | ||
3015 | 422 | |||
3016 | 423 | succeeded = task_manager_update (priv->manager, | ||
3017 | 424 | &window, | ||
3018 | 425 | hints, | ||
3019 | 426 | error); | ||
3020 | 427 | g_value_unset (&window); | ||
3021 | 428 | g_value_unset (&value); | ||
3022 | 429 | g_hash_table_destroy (hints); | ||
3023 | 430 | |||
3024 | 431 | return succeeded; | ||
3025 | 432 | } | ||
3026 | 433 | |||
3027 | 434 | gboolean | ||
3028 | 435 | task_manager_api_wrapper_unset_info_by_xid (TaskManagerApiWrapper *wrapper, | ||
3029 | 436 | gint64 xid, | ||
3030 | 437 | GError **error) | ||
3031 | 438 | { | ||
3032 | 439 | TaskManagerApiWrapperPrivate *priv; | ||
3033 | 440 | gboolean succeeded; | ||
3034 | 441 | GValue window = {0}; | ||
3035 | 442 | GHashTable *hints; | ||
3036 | 443 | const gchar *key = "message"; | ||
3037 | 444 | GValue value = {0}; | ||
3038 | 445 | |||
3039 | 446 | g_return_val_if_fail (TASK_IS_MANAGER_API_WRAPPER (wrapper), FALSE); | ||
3040 | 447 | |||
3041 | 448 | priv = wrapper->priv; | ||
3042 | 449 | |||
3043 | 450 | g_value_init (&window, G_TYPE_INT64); | ||
3044 | 451 | g_value_set_int64 (&window, xid); | ||
3045 | 452 | |||
3046 | 453 | g_value_init (&value, G_TYPE_STRING); | ||
3047 | 454 | g_value_set_string (&value, ""); | ||
3048 | 455 | |||
3049 | 456 | hints = g_hash_table_new (g_str_hash, g_str_equal); | ||
3050 | 457 | g_hash_table_insert (hints, (gpointer)key, &value); | ||
3051 | 458 | |||
3052 | 459 | succeeded = task_manager_update (priv->manager, | ||
3053 | 460 | &window, | ||
3054 | 461 | hints, | ||
3055 | 462 | error); | ||
3056 | 463 | g_value_unset (&window); | ||
3057 | 464 | g_value_unset (&value); | ||
3058 | 465 | g_hash_table_destroy (hints); | ||
3059 | 466 | |||
3060 | 467 | return succeeded; | ||
3061 | 468 | } | ||
3062 | 469 | |||
3063 | 470 | gboolean | ||
3064 | 471 | task_manager_api_wrapper_set_progress_by_xid (TaskManagerApiWrapper *wrapper, | ||
3065 | 472 | gint64 xid, | ||
3066 | 473 | gint progress, | ||
3067 | 474 | GError **error) | ||
3068 | 475 | { | ||
3069 | 476 | TaskManagerApiWrapperPrivate *priv; | ||
3070 | 477 | gboolean succeeded; | ||
3071 | 478 | GValue window = {0}; | ||
3072 | 479 | GHashTable *hints; | ||
3073 | 480 | const gchar *key = "message"; | ||
3074 | 481 | GValue value = {0}; | ||
3075 | 482 | |||
3076 | 483 | g_return_val_if_fail (TASK_IS_MANAGER_API_WRAPPER (wrapper), FALSE); | ||
3077 | 484 | |||
3078 | 485 | priv = wrapper->priv; | ||
3079 | 486 | |||
3080 | 487 | g_value_init (&window, G_TYPE_INT64); | ||
3081 | 488 | g_value_set_int64 (&window, xid); | ||
3082 | 489 | |||
3083 | 490 | //difference between old and new api | ||
3084 | 491 | //unsetting progress indicator by setting progress to -1; | ||
3085 | 492 | if (progress == 100) progress = -1; | ||
3086 | 493 | |||
3087 | 494 | g_value_init (&value, G_TYPE_INT); | ||
3088 | 495 | g_value_set_int (&value, progress); | ||
3089 | 496 | |||
3090 | 497 | hints = g_hash_table_new (g_str_hash, g_str_equal); | ||
3091 | 498 | g_hash_table_insert (hints, (gpointer)key, &value); | ||
3092 | 499 | |||
3093 | 500 | succeeded = task_manager_update (priv->manager, | ||
3094 | 501 | &window, | ||
3095 | 502 | hints, | ||
3096 | 503 | error); | ||
3097 | 504 | g_value_unset (&window); | ||
3098 | 505 | g_value_unset (&value); | ||
3099 | 506 | g_hash_table_destroy (hints); | ||
3100 | 507 | |||
3101 | 508 | return succeeded; | ||
3102 | 509 | } | ||
3103 | 0 | 510 | ||
3104 | === added file 'applets/taskmanager/task-manager-api-wrapper.h' | |||
3105 | --- applets/taskmanager/task-manager-api-wrapper.h 1970-01-01 00:00:00 +0000 | |||
3106 | +++ applets/taskmanager/task-manager-api-wrapper.h 2009-06-26 11:00:10 +0000 | |||
3107 | @@ -0,0 +1,125 @@ | |||
3108 | 1 | /* | ||
3109 | 2 | * Copyright (C) 2008 Neil Jagdish Patel <njpatel@gmail.com> | ||
3110 | 3 | * | ||
3111 | 4 | * This program is free software: you can redistribute it and/or modify | ||
3112 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
3113 | 6 | * published by the Free Software Foundation. | ||
3114 | 7 | * | ||
3115 | 8 | * This program is distributed in the hope that it will be useful, | ||
3116 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3117 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3118 | 11 | * GNU General Public License for more details. | ||
3119 | 12 | * | ||
3120 | 13 | * You should have received a copy of the GNU General Public License | ||
3121 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3122 | 15 | * | ||
3123 | 16 | * Authored by Hannes Verschore <hv1989@gmail.com> | ||
3124 | 17 | */ | ||
3125 | 18 | |||
3126 | 19 | #ifndef _TASK_MANAGER_API_WRAPPER_H_ | ||
3127 | 20 | #define _TASK_MANAGER_API_WRAPPER_H_ | ||
3128 | 21 | |||
3129 | 22 | #include <glib-object.h> | ||
3130 | 23 | #include <libawn/libawn.h> | ||
3131 | 24 | |||
3132 | 25 | #include "task-manager.h" | ||
3133 | 26 | |||
3134 | 27 | #define TASK_TYPE_MANAGER_API_WRAPPER (task_manager_api_wrapper_get_type ()) | ||
3135 | 28 | |||
3136 | 29 | #define TASK_MANAGER_API_WRAPPER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),\ | ||
3137 | 30 | TASK_TYPE_MANAGER_API_WRAPPER, TaskManagerApiWrapper)) | ||
3138 | 31 | |||
3139 | 32 | #define TASK_MANAGER_API_WRAPPER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),\ | ||
3140 | 33 | TASK_TYPE_MANAGER_API_WRAPPER, TaskManagerApiWrapperClass)) | ||
3141 | 34 | |||
3142 | 35 | #define TASK_IS_MANAGER_API_WRAPPER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),\ | ||
3143 | 36 | TASK_TYPE_MANAGER_API_WRAPPER)) | ||
3144 | 37 | |||
3145 | 38 | #define TASK_IS_MANAGER_API_WRAPPER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),\ | ||
3146 | 39 | TASK_TYPE_MANAGER_API_WRAPPER)) | ||
3147 | 40 | |||
3148 | 41 | #define TASK_MANAGER_API_WRAPPER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),\ | ||
3149 | 42 | TASK_TYPE_MANAGER_API_WRAPPER, TaskManagerApiWrapperClass)) | ||
3150 | 43 | |||
3151 | 44 | typedef struct _TaskManagerApiWrapper TaskManagerApiWrapper; | ||
3152 | 45 | typedef struct _TaskManagerApiWrapperClass TaskManagerApiWrapperClass; | ||
3153 | 46 | typedef struct _TaskManagerApiWrapperPrivate TaskManagerApiWrapperPrivate; | ||
3154 | 47 | |||
3155 | 48 | struct _TaskManagerApiWrapper | ||
3156 | 49 | { | ||
3157 | 50 | GObject parent; | ||
3158 | 51 | |||
3159 | 52 | TaskManagerApiWrapperPrivate *priv; | ||
3160 | 53 | }; | ||
3161 | 54 | |||
3162 | 55 | struct _TaskManagerApiWrapperClass | ||
3163 | 56 | { | ||
3164 | 57 | GObjectClass parent_class; | ||
3165 | 58 | }; | ||
3166 | 59 | |||
3167 | 60 | GType task_manager_api_wrapper_get_type (void) G_GNUC_CONST; | ||
3168 | 61 | |||
3169 | 62 | TaskManagerApiWrapper * task_manager_api_wrapper_new (TaskManager *manager); | ||
3170 | 63 | |||
3171 | 64 | /* name variants */ | ||
3172 | 65 | |||
3173 | 66 | gboolean | ||
3174 | 67 | task_manager_api_wrapper_set_task_icon_by_name (TaskManagerApiWrapper *wrapper, | ||
3175 | 68 | gchar *name, | ||
3176 | 69 | gchar *icon_path, | ||
3177 | 70 | GError **error); | ||
3178 | 71 | |||
3179 | 72 | gboolean | ||
3180 | 73 | task_manager_api_wrapper_unset_task_icon_by_name (TaskManagerApiWrapper *wrapper, | ||
3181 | 74 | gchar *name, | ||
3182 | 75 | GError **error); | ||
3183 | 76 | |||
3184 | 77 | gboolean | ||
3185 | 78 | task_manager_api_wrapper_set_info_by_name (TaskManagerApiWrapper *wrapper, | ||
3186 | 79 | gchar *name, | ||
3187 | 80 | gchar *info, | ||
3188 | 81 | GError **error); | ||
3189 | 82 | |||
3190 | 83 | gboolean | ||
3191 | 84 | task_manager_api_wrapper_unset_info_by_name (TaskManagerApiWrapper *wrapper, | ||
3192 | 85 | gchar *name, | ||
3193 | 86 | GError **error); | ||
3194 | 87 | |||
3195 | 88 | gboolean | ||
3196 | 89 | task_manager_api_wrapper_set_progress_by_name (TaskManagerApiWrapper *wrapper, | ||
3197 | 90 | gchar *name, | ||
3198 | 91 | gint progress, | ||
3199 | 92 | GError **error); | ||
3200 | 93 | |||
3201 | 94 | /* XID variants */ | ||
3202 | 95 | |||
3203 | 96 | gboolean | ||
3204 | 97 | task_manager_api_wrapper_set_task_icon_by_xid (TaskManagerApiWrapper *wrapper, | ||
3205 | 98 | gint64 xid, | ||
3206 | 99 | gchar *icon_path, | ||
3207 | 100 | GError **error); | ||
3208 | 101 | |||
3209 | 102 | gboolean | ||
3210 | 103 | task_manager_api_wrapper_unset_task_icon_by_xid (TaskManagerApiWrapper *wrapper, | ||
3211 | 104 | gint64 xid, | ||
3212 | 105 | GError **error); | ||
3213 | 106 | |||
3214 | 107 | gboolean | ||
3215 | 108 | task_manager_api_wrapper_set_info_by_xid (TaskManagerApiWrapper *wrapper, | ||
3216 | 109 | gint64 xid, | ||
3217 | 110 | gchar *info, | ||
3218 | 111 | GError **error); | ||
3219 | 112 | |||
3220 | 113 | gboolean | ||
3221 | 114 | task_manager_api_wrapper_unset_info_by_xid (TaskManagerApiWrapper *wrapper, | ||
3222 | 115 | gint64 xid, | ||
3223 | 116 | GError **error); | ||
3224 | 117 | |||
3225 | 118 | gboolean | ||
3226 | 119 | task_manager_api_wrapper_set_progress_by_xid (TaskManagerApiWrapper *wrapper, | ||
3227 | 120 | gint64 xid, | ||
3228 | 121 | gint progress, | ||
3229 | 122 | GError **error); | ||
3230 | 123 | |||
3231 | 124 | #endif /* _TASK_MANAGER_API_WRAPPER_H_ */ | ||
3232 | 125 | |||
3233 | 0 | 126 | ||
3234 | === modified file 'applets/taskmanager/task-manager.c' | |||
3235 | --- applets/taskmanager/task-manager.c 2009-06-11 05:04:21 +0000 | |||
3236 | +++ applets/taskmanager/task-manager.c 2009-06-28 01:53:46 +0000 | |||
3237 | @@ -14,7 +14,7 @@ | |||
3238 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3239 | 15 | * | 15 | * |
3240 | 16 | * Authored by Neil Jagdish Patel <njpatel@gmail.com> | 16 | * Authored by Neil Jagdish Patel <njpatel@gmail.com> |
3242 | 17 | * | 17 | * Hannes Verschore <hv1989@gmail.com> |
3243 | 18 | */ | 18 | */ |
3244 | 19 | 19 | ||
3245 | 20 | #include <stdio.h> | 20 | #include <stdio.h> |
3246 | @@ -29,9 +29,9 @@ | |||
3247 | 29 | 29 | ||
3248 | 30 | #include "task-drag-indicator.h" | 30 | #include "task-drag-indicator.h" |
3249 | 31 | #include "task-icon.h" | 31 | #include "task-icon.h" |
3251 | 32 | #include "task-launcher.h" | 32 | //#include "task-launcher.h" |
3252 | 33 | //#include "task-window.h" | ||
3253 | 33 | #include "task-settings.h" | 34 | #include "task-settings.h" |
3254 | 34 | #include "task-window.h" | ||
3255 | 35 | #include "xutils.h" | 35 | #include "xutils.h" |
3256 | 36 | 36 | ||
3257 | 37 | G_DEFINE_TYPE (TaskManager, task_manager, AWN_TYPE_APPLET) | 37 | G_DEFINE_TYPE (TaskManager, task_manager, AWN_TYPE_APPLET) |
3258 | @@ -48,17 +48,15 @@ | |||
3259 | 48 | TaskSettings *settings; | 48 | TaskSettings *settings; |
3260 | 49 | WnckScreen *screen; | 49 | WnckScreen *screen; |
3261 | 50 | 50 | ||
3262 | 51 | |||
3263 | 52 | /* Dragging properties */ | 51 | /* Dragging properties */ |
3264 | 53 | TaskIcon *dragged_icon; | 52 | TaskIcon *dragged_icon; |
3265 | 54 | TaskDragIndicator *drag_indicator; | 53 | TaskDragIndicator *drag_indicator; |
3266 | 55 | gint drag_timeout; | 54 | gint drag_timeout; |
3267 | 56 | 55 | ||
3268 | 57 | /* This is what the icons are packed into */ | 56 | /* This is what the icons are packed into */ |
3270 | 58 | GtkWidget *box; | 57 | GtkWidget *box; |
3271 | 59 | GSList *icons; | 58 | GSList *icons; |
3272 | 60 | GSList *windows; | 59 | GSList *windows; |
3273 | 61 | GSList *launchers; | ||
3274 | 62 | GHashTable *win_table; | 60 | GHashTable *win_table; |
3275 | 63 | 61 | ||
3276 | 64 | /* Properties */ | 62 | /* Properties */ |
3277 | @@ -66,7 +64,7 @@ | |||
3278 | 66 | gboolean show_all_windows; | 64 | gboolean show_all_windows; |
3279 | 67 | gboolean only_show_launchers; | 65 | gboolean only_show_launchers; |
3280 | 68 | gboolean drag_and_drop; | 66 | gboolean drag_and_drop; |
3282 | 69 | gint grouping_mode; | 67 | gint match_strength; |
3283 | 70 | }; | 68 | }; |
3284 | 71 | 69 | ||
3285 | 72 | enum | 70 | enum |
3286 | @@ -77,30 +75,20 @@ | |||
3287 | 77 | PROP_ONLY_SHOW_LAUNCHERS, | 75 | PROP_ONLY_SHOW_LAUNCHERS, |
3288 | 78 | PROP_LAUNCHER_PATHS, | 76 | PROP_LAUNCHER_PATHS, |
3289 | 79 | PROP_DRAG_AND_DROP, | 77 | PROP_DRAG_AND_DROP, |
3301 | 80 | PROP_GROUPING_MODE | 78 | PROP_MATCH_STRENGTH |
3291 | 81 | }; | ||
3292 | 82 | |||
3293 | 83 | enum | ||
3294 | 84 | { | ||
3295 | 85 | GROUPING_NONE, | ||
3296 | 86 | GROUPING_UTIL, | ||
3297 | 87 | GROUPING_PID, | ||
3298 | 88 | GROUPING_WNCK_APP, | ||
3299 | 89 | GROUPING_WMCLASS, | ||
3300 | 90 | GROUPING_END | ||
3302 | 91 | }; | 79 | }; |
3303 | 92 | 80 | ||
3304 | 93 | /* Forwards */ | 81 | /* Forwards */ |
3306 | 94 | static void ensure_layout (TaskManager *manager); | 82 | static void update_icon_visible (TaskManager *manager, |
3307 | 83 | TaskIcon *icon); | ||
3308 | 84 | static void on_icon_visible_changed (TaskManager *manager, | ||
3309 | 85 | TaskIcon *icon); | ||
3310 | 95 | static void on_window_opened (WnckScreen *screen, | 86 | static void on_window_opened (WnckScreen *screen, |
3311 | 96 | WnckWindow *window, | 87 | WnckWindow *window, |
3312 | 97 | TaskManager *manager); | 88 | TaskManager *manager); |
3313 | 98 | static void on_active_window_changed (WnckScreen *screen, | 89 | static void on_active_window_changed (WnckScreen *screen, |
3314 | 99 | WnckWindow *old_window, | 90 | WnckWindow *old_window, |
3315 | 100 | TaskManager *manager); | 91 | TaskManager *manager); |
3316 | 101 | static void on_wnck_window_closed (WnckScreen *screen, | ||
3317 | 102 | WnckWindow *window, | ||
3318 | 103 | TaskManager *manager); | ||
3319 | 104 | static void task_manager_set_show_all_windows (TaskManager *manager, | 92 | static void task_manager_set_show_all_windows (TaskManager *manager, |
3320 | 105 | gboolean show_all); | 93 | gboolean show_all); |
3321 | 106 | static void task_manager_set_show_only_launchers (TaskManager *manager, | 94 | static void task_manager_set_show_only_launchers (TaskManager *manager, |
3322 | @@ -110,14 +98,15 @@ | |||
3323 | 110 | static void task_manager_set_drag_and_drop (TaskManager *manager, | 98 | static void task_manager_set_drag_and_drop (TaskManager *manager, |
3324 | 111 | gboolean drag_and_drop); | 99 | gboolean drag_and_drop); |
3325 | 112 | 100 | ||
3328 | 113 | static void task_manager_set_grouping_mode (TaskManager *manager, | 101 | static void task_manager_set_match_strength (TaskManager *manager, |
3329 | 114 | gint drag_and_drop); | 102 | gint drag_and_drop); |
3330 | 115 | 103 | ||
3331 | 116 | static void task_manager_orient_changed (AwnApplet *applet, | 104 | static void task_manager_orient_changed (AwnApplet *applet, |
3332 | 117 | AwnOrientation orient); | 105 | AwnOrientation orient); |
3333 | 118 | static void task_manager_size_changed (AwnApplet *applet, | 106 | static void task_manager_size_changed (AwnApplet *applet, |
3334 | 119 | gint size); | 107 | gint size); |
3335 | 120 | 108 | ||
3336 | 109 | |||
3337 | 121 | /* D&D Forwards */ | 110 | /* D&D Forwards */ |
3338 | 122 | static void _drag_dest_motion (TaskManager *manager, | 111 | static void _drag_dest_motion (TaskManager *manager, |
3339 | 123 | gint x, | 112 | gint x, |
3340 | @@ -163,9 +152,9 @@ | |||
3341 | 163 | case PROP_DRAG_AND_DROP: | 152 | case PROP_DRAG_AND_DROP: |
3342 | 164 | g_value_set_boolean (value, manager->priv->drag_and_drop); | 153 | g_value_set_boolean (value, manager->priv->drag_and_drop); |
3343 | 165 | break; | 154 | break; |
3347 | 166 | 155 | ||
3348 | 167 | case PROP_GROUPING_MODE: | 156 | case PROP_MATCH_STRENGTH: |
3349 | 168 | g_value_set_int (value, manager->priv->grouping_mode); | 157 | g_value_set_int (value, manager->priv->match_strength); |
3350 | 169 | break; | 158 | break; |
3351 | 170 | 159 | ||
3352 | 171 | default: | 160 | default: |
3353 | @@ -200,11 +189,10 @@ | |||
3354 | 200 | case PROP_DRAG_AND_DROP: | 189 | case PROP_DRAG_AND_DROP: |
3355 | 201 | task_manager_set_drag_and_drop (manager, | 190 | task_manager_set_drag_and_drop (manager, |
3356 | 202 | g_value_get_boolean (value)); | 191 | g_value_get_boolean (value)); |
3362 | 203 | break; | 192 | |
3363 | 204 | 193 | case PROP_MATCH_STRENGTH: | |
3364 | 205 | case PROP_GROUPING_MODE: | 194 | task_manager_set_match_strength (manager, |
3365 | 206 | task_manager_set_grouping_mode (manager, | 195 | g_value_get_int (value)); |
3361 | 207 | g_value_get_int (value)); | ||
3366 | 208 | break; | 196 | break; |
3367 | 209 | 197 | ||
3368 | 210 | 198 | ||
3369 | @@ -250,8 +238,8 @@ | |||
3370 | 250 | AWN_CONFIG_CLIENT_DEFAULT_GROUP, "drag_and_drop", | 238 | AWN_CONFIG_CLIENT_DEFAULT_GROUP, "drag_and_drop", |
3371 | 251 | object, "drag_and_drop"); | 239 | object, "drag_and_drop"); |
3372 | 252 | awn_config_bridge_bind (bridge, priv->client, | 240 | awn_config_bridge_bind (bridge, priv->client, |
3375 | 253 | AWN_CONFIG_CLIENT_DEFAULT_GROUP, "grouping_mode", | 241 | AWN_CONFIG_CLIENT_DEFAULT_GROUP, "match_strength", |
3376 | 254 | object, "grouping_mode"); | 242 | object, "match_strength"); |
3377 | 255 | } | 243 | } |
3378 | 256 | 244 | ||
3379 | 257 | static void | 245 | static void |
3380 | @@ -296,14 +284,14 @@ | |||
3381 | 296 | G_PARAM_CONSTRUCT | G_PARAM_READWRITE); | 284 | G_PARAM_CONSTRUCT | G_PARAM_READWRITE); |
3382 | 297 | g_object_class_install_property (obj_class, PROP_DRAG_AND_DROP, pspec); | 285 | g_object_class_install_property (obj_class, PROP_DRAG_AND_DROP, pspec); |
3383 | 298 | 286 | ||
3392 | 299 | pspec = g_param_spec_int ("grouping_mode", | 287 | pspec = g_param_spec_int ("match_strength", |
3393 | 300 | "grouping_mode", | 288 | "match_strength", |
3394 | 301 | "Window Grouping Mode", | 289 | "How radical matching is applied for grouping items", |
3395 | 302 | 0, | 290 | 0, |
3396 | 303 | GROUPING_END-1, | 291 | 99, |
3397 | 304 | 0, | 292 | 0, |
3398 | 305 | G_PARAM_READWRITE); | 293 | G_PARAM_READWRITE); |
3399 | 306 | g_object_class_install_property (obj_class, PROP_GROUPING_MODE, pspec); | 294 | g_object_class_install_property (obj_class, PROP_MATCH_STRENGTH, pspec); |
3400 | 307 | 295 | ||
3401 | 308 | g_type_class_add_private (obj_class, sizeof (TaskManagerPrivate)); | 296 | g_type_class_add_private (obj_class, sizeof (TaskManagerPrivate)); |
3402 | 309 | } | 297 | } |
3403 | @@ -342,12 +330,6 @@ | |||
3404 | 342 | G_CALLBACK (on_window_opened), manager); | 330 | G_CALLBACK (on_window_opened), manager); |
3405 | 343 | g_signal_connect (priv->screen, "active-window-changed", | 331 | g_signal_connect (priv->screen, "active-window-changed", |
3406 | 344 | G_CALLBACK (on_active_window_changed), manager); | 332 | G_CALLBACK (on_active_window_changed), manager); |
3407 | 345 | g_signal_connect_swapped (priv->screen, "active-workspace-changed", | ||
3408 | 346 | G_CALLBACK (ensure_layout), manager); | ||
3409 | 347 | g_signal_connect_swapped (priv->screen, "viewports-changed", | ||
3410 | 348 | G_CALLBACK (ensure_layout), manager); | ||
3411 | 349 | g_signal_connect (priv->screen, "window-closed", | ||
3412 | 350 | G_CALLBACK(on_wnck_window_closed),manager); | ||
3413 | 351 | } | 333 | } |
3414 | 352 | 334 | ||
3415 | 353 | AwnApplet * | 335 | AwnApplet * |
3416 | @@ -411,80 +393,15 @@ | |||
3417 | 411 | } | 393 | } |
3418 | 412 | 394 | ||
3419 | 413 | /* | 395 | /* |
3420 | 414 | * The guts of the show or hide logic | ||
3421 | 415 | */ | ||
3422 | 416 | static void | ||
3423 | 417 | ensure_layout (TaskManager *manager) | ||
3424 | 418 | { | ||
3425 | 419 | TaskManagerPrivate *priv = manager->priv; | ||
3426 | 420 | WnckWorkspace *space; | ||
3427 | 421 | GSList *i; | ||
3428 | 422 | |||
3429 | 423 | space = wnck_screen_get_active_workspace (priv->screen); | ||
3430 | 424 | |||
3431 | 425 | if (!WNCK_IS_WORKSPACE (space)) | ||
3432 | 426 | { | ||
3433 | 427 | return; | ||
3434 | 428 | } | ||
3435 | 429 | |||
3436 | 430 | /* Go through all the TaskIcons to make sure that they should be shown */ | ||
3437 | 431 | for (i = priv->icons; i; i = i->next) | ||
3438 | 432 | { | ||
3439 | 433 | TaskIcon *icon = i->data; | ||
3440 | 434 | |||
3441 | 435 | if (!TASK_IS_ICON (icon)) | ||
3442 | 436 | continue; | ||
3443 | 437 | |||
3444 | 438 | /* If the icon gets dragged, it shouldn't be shown */ | ||
3445 | 439 | if( icon == priv->dragged_icon ) | ||
3446 | 440 | { | ||
3447 | 441 | gtk_widget_hide (GTK_WIDGET (icon)); | ||
3448 | 442 | continue; | ||
3449 | 443 | } | ||
3450 | 444 | |||
3451 | 445 | /* Show launchers regardless of workspace */ | ||
3452 | 446 | if (task_icon_is_launcher (icon)) | ||
3453 | 447 | { | ||
3454 | 448 | gtk_widget_show (GTK_WIDGET (icon)); | ||
3455 | 449 | continue; | ||
3456 | 450 | } | ||
3457 | 451 | |||
3458 | 452 | /* FIXME: Add support for start-up notification icons too */ | ||
3459 | 453 | |||
3460 | 454 | /* | ||
3461 | 455 | * Only show normal window icons if a) the use wants to see them and b) if | ||
3462 | 456 | * they are on the correct workspace | ||
3463 | 457 | */ | ||
3464 | 458 | if (priv->only_show_launchers) | ||
3465 | 459 | { | ||
3466 | 460 | gtk_widget_hide (GTK_WIDGET (icon)); | ||
3467 | 461 | } | ||
3468 | 462 | else if (task_icon_is_skip_taskbar (icon)) | ||
3469 | 463 | { | ||
3470 | 464 | gtk_widget_hide (GTK_WIDGET (icon)); | ||
3471 | 465 | } | ||
3472 | 466 | else if (task_icon_is_in_viewport (icon, space)) | ||
3473 | 467 | { | ||
3474 | 468 | gtk_widget_show (GTK_WIDGET (icon)); | ||
3475 | 469 | } | ||
3476 | 470 | else if (priv->show_all_windows) | ||
3477 | 471 | { | ||
3478 | 472 | gtk_widget_show (GTK_WIDGET (icon)); | ||
3479 | 473 | } | ||
3480 | 474 | else | ||
3481 | 475 | { | ||
3482 | 476 | gtk_widget_hide (GTK_WIDGET (icon)); | ||
3483 | 477 | } | ||
3484 | 478 | } | ||
3485 | 479 | |||
3486 | 480 | /* Hide drag_indicator if there is no AwnIcon currently dragged */ | ||
3487 | 481 | if(priv->dragged_icon == NULL) | ||
3488 | 482 | gtk_widget_hide (GTK_WIDGET(priv->drag_indicator)); | ||
3489 | 483 | } | ||
3490 | 484 | |||
3491 | 485 | /* | ||
3492 | 486 | * WNCK_SCREEN CALLBACKS | 396 | * WNCK_SCREEN CALLBACKS |
3493 | 487 | */ | 397 | */ |
3494 | 398 | |||
3495 | 399 | /** | ||
3496 | 400 | * This signal is only connected for windows which were of type normal/utility | ||
3497 | 401 | * and were initially "skip-tasklist". If they are not skip-tasklist anymore | ||
3498 | 402 | * we treat them as newly opened windows. | ||
3499 | 403 | * STATE: done | ||
3500 | 404 | */ | ||
3501 | 488 | static void | 405 | static void |
3502 | 489 | on_window_state_changed (WnckWindow *window, | 406 | on_window_state_changed (WnckWindow *window, |
3503 | 490 | WnckWindowState changed_mask, | 407 | WnckWindowState changed_mask, |
3504 | @@ -493,10 +410,7 @@ | |||
3505 | 493 | { | 410 | { |
3506 | 494 | g_return_if_fail (TASK_IS_MANAGER (manager)); | 411 | g_return_if_fail (TASK_IS_MANAGER (manager)); |
3507 | 495 | 412 | ||
3512 | 496 | /* This signal is only connected for windows which were of type normal/utility | 413 | // test if they don't skip-tasklist anymore |
3509 | 497 | * and were initially "skip-tasklist". If they are not skip-tasklist anymore | ||
3510 | 498 | * we treat them as newly opened windows | ||
3511 | 499 | */ | ||
3513 | 500 | if (!wnck_window_is_skip_tasklist (window)) | 414 | if (!wnck_window_is_skip_tasklist (window)) |
3514 | 501 | { | 415 | { |
3515 | 502 | g_signal_handlers_disconnect_by_func (window, | 416 | g_signal_handlers_disconnect_by_func (window, |
3516 | @@ -506,315 +420,145 @@ | |||
3517 | 506 | } | 420 | } |
3518 | 507 | } | 421 | } |
3519 | 508 | 422 | ||
3520 | 423 | /** | ||
3521 | 424 | * The active WnckWindow has changed. | ||
3522 | 425 | * Retrieve the TaskWindows and update there active state | ||
3523 | 426 | */ | ||
3524 | 509 | static void | 427 | static void |
3820 | 510 | on_wnck_window_closed (WnckScreen *screen, WnckWindow *window, TaskManager *manager) | 428 | on_active_window_changed (WnckScreen *screen, |
3821 | 511 | { | 429 | WnckWindow *old_window, |
3822 | 512 | GSList *i; | 430 | TaskManager *manager) |
3823 | 513 | TaskManagerPrivate *priv = manager->priv; | 431 | { |
3824 | 514 | for (i = priv->icons; i; i = i->next) | 432 | TaskManagerPrivate *priv; |
3825 | 515 | { | 433 | WnckWindow *active = NULL; |
3826 | 516 | TaskIcon *taskicon = i->data; | 434 | TaskWindow *taskwin = NULL; |
3827 | 517 | if (!TASK_IS_ICON (taskicon)) | 435 | TaskWindow *old_taskwin = NULL; |
3828 | 518 | continue; | 436 | |
3829 | 519 | task_icon_remove_window (taskicon, window); | 437 | g_return_if_fail (TASK_IS_MANAGER (manager)); |
3830 | 520 | } | 438 | priv = manager->priv; |
3831 | 521 | } | 439 | |
3832 | 522 | 440 | active = wnck_screen_get_active_window (priv->screen); | |
3833 | 523 | static gboolean | 441 | |
3834 | 524 | check_wmclass(TaskWindow *taskwin,gchar * win_res_name, gchar *win_class_name) | 442 | if (WNCK_IS_WINDOW (old_window)) |
3835 | 525 | { | 443 | old_taskwin = (TaskWindow *)g_object_get_qdata (G_OBJECT (old_window), |
3836 | 526 | gboolean result; | 444 | win_quark); |
3837 | 527 | gchar *temp; | 445 | if (WNCK_IS_WINDOW (active)) |
3838 | 528 | gchar *res_name = NULL; | 446 | taskwin = (TaskWindow *)g_object_get_qdata (G_OBJECT (active), win_quark); |
3839 | 529 | gchar *class_name = NULL; | 447 | |
3840 | 530 | 448 | if (TASK_IS_WINDOW (old_taskwin)) | |
3841 | 531 | _wnck_get_wmclass (task_window_get_xid (taskwin), &res_name, &class_name); | 449 | task_window_set_is_active (old_taskwin, FALSE); |
3842 | 532 | if (res_name) | 450 | if (TASK_IS_WINDOW (taskwin)) |
3843 | 533 | { | 451 | task_window_set_is_active (taskwin, TRUE); |
3844 | 534 | temp = res_name; | 452 | } |
3845 | 535 | res_name = g_utf8_strdown (temp, -1); | 453 | |
3846 | 536 | g_free (temp); | 454 | /** |
3847 | 537 | } | 455 | * When the property 'show_all_windows' is False, |
3848 | 538 | 456 | * workspace switches are monitored. Whenever one happens | |
3849 | 539 | if (class_name) | 457 | * all TaskWindows are notified. |
3850 | 540 | { | 458 | */ |
3851 | 541 | temp = class_name; | 459 | static void |
3852 | 542 | class_name = g_utf8_strdown (temp, -1); | 460 | on_workspace_changed (TaskManager *manager) //... has more arguments |
3853 | 543 | g_free (temp); | 461 | { |
3854 | 544 | } | 462 | TaskManagerPrivate *priv; |
3855 | 545 | result = ( | 463 | GSList *w; |
3856 | 546 | (g_strcmp0 (res_name,win_res_name)==0) | 464 | WnckWorkspace *space; |
3857 | 547 | || | 465 | |
3858 | 548 | (g_strcmp0 (class_name,win_class_name)==0) | 466 | g_return_if_fail (TASK_IS_MANAGER (manager)); |
3859 | 549 | ); | 467 | |
3860 | 550 | g_free (res_name); | 468 | priv = manager->priv; |
3861 | 551 | g_free (class_name); | 469 | space = wnck_screen_get_active_workspace (priv->screen); |
3862 | 552 | 470 | ||
3863 | 553 | return result; | 471 | for (w = priv->windows; w; w = w->next) |
3864 | 554 | } | 472 | { |
3865 | 555 | 473 | TaskWindow *window = w->data; | |
3866 | 556 | static gboolean | 474 | |
3867 | 557 | try_to_place_window_by_wmclass (TaskManager *manager, WnckWindow *window) | 475 | if (!TASK_IS_WINDOW (window)) continue; |
3868 | 558 | { | 476 | |
3869 | 559 | GSList *i; | 477 | task_window_set_active_workspace (window, space); |
3870 | 560 | TaskManagerPrivate *priv = manager->priv; | 478 | } |
3871 | 561 | gchar *temp; | 479 | } |
3872 | 562 | gchar *res_name = NULL; | 480 | |
3873 | 563 | gchar *class_name = NULL; | 481 | /* |
3874 | 564 | 482 | * TASK_ICON CALLBACKS | |
3875 | 565 | /* Grab the appropriete info */ | 483 | */ |
3876 | 566 | _wnck_get_wmclass (wnck_window_get_xid (window), &res_name, &class_name); | 484 | |
3877 | 567 | 485 | static void | |
3878 | 568 | if (res_name) | 486 | update_icon_visible (TaskManager *manager, TaskIcon *icon) |
3879 | 569 | { | 487 | { |
3880 | 570 | temp = res_name; | 488 | TaskManagerPrivate *priv; |
3881 | 571 | res_name = g_utf8_strdown (temp, -1); | 489 | |
3882 | 572 | g_free (temp); | 490 | g_return_if_fail (TASK_IS_MANAGER (manager)); |
3883 | 573 | } | 491 | |
3884 | 574 | 492 | priv = manager->priv; | |
3885 | 575 | if (class_name) | 493 | |
3886 | 576 | { | 494 | if (task_icon_is_visible (icon)) |
3887 | 577 | temp = class_name; | 495 | { |
3888 | 578 | class_name = g_utf8_strdown (temp, -1); | 496 | if (priv->only_show_launchers && !task_icon_contains_launcher (icon)) |
3889 | 579 | g_free (temp); | 497 | { |
3890 | 580 | } | 498 | gtk_widget_hide (GTK_WIDGET (icon)); |
3891 | 581 | 499 | } | |
3892 | 582 | for (i = priv->icons; i; i = i->next) | 500 | else |
3893 | 583 | { | 501 | { |
3894 | 584 | TaskIcon *taskicon = i->data; | 502 | if (!GTK_WIDGET_VISIBLE (icon)) |
3895 | 585 | TaskWindow *taskwin = NULL; | 503 | { |
3896 | 586 | 504 | awn_effects_start_ex (awn_overlayable_get_effects (AWN_OVERLAYABLE (icon)), | |
3897 | 587 | if (!TASK_IS_ICON (taskicon)) | 505 | AWN_EFFECT_OPENING, 1, FALSE, FALSE); |
3898 | 588 | continue; | 506 | gtk_widget_show (GTK_WIDGET (icon)); |
3899 | 589 | 507 | } | |
3900 | 590 | taskwin = task_icon_get_window(taskicon); | 508 | } |
3901 | 591 | 509 | } | |
3902 | 592 | if ( check_wmclass (taskwin,res_name,class_name) ) | 510 | else |
3903 | 593 | { | 511 | { |
3904 | 594 | task_icon_append_window (taskicon, task_window_new (window)); | 512 | gtk_widget_hide (GTK_WIDGET (icon)); |
3905 | 595 | g_object_set_qdata (G_OBJECT (window), win_quark, taskwin); | 513 | } |
3906 | 596 | g_free (res_name); | 514 | } |
3907 | 597 | g_free (class_name); | 515 | |
3908 | 598 | return TRUE; | 516 | static void |
3909 | 599 | } | 517 | on_icon_visible_changed (TaskManager *manager, TaskIcon *icon) |
3910 | 600 | } | 518 | { |
3911 | 601 | 519 | g_return_if_fail (TASK_IS_MANAGER (manager)); | |
3912 | 602 | g_free (res_name); | 520 | |
3913 | 603 | g_free (class_name); | 521 | update_icon_visible (manager, icon); |
3914 | 604 | return FALSE; | 522 | } |
3915 | 605 | } | 523 | |
3916 | 606 | 524 | /** | |
3917 | 607 | static gboolean | 525 | * This function gets called whenever a task-window gets finalized. |
3918 | 608 | try_to_place_window_by_wnck_app (TaskManager *manager, WnckWindow *window) | 526 | * It removes the task-window from the list. |
3919 | 609 | { | 527 | * State: done |
3920 | 610 | TaskManagerPrivate *priv = manager->priv; | 528 | */ |
3921 | 611 | GSList *i; | 529 | static void |
3922 | 612 | WnckApplication *taskwin_app; | 530 | window_closed (TaskManager *manager, GObject *old_item) |
3923 | 613 | 531 | { | |
3924 | 614 | for (i = priv->icons; i; i = i->next) | 532 | TaskManagerPrivate *priv; |
3925 | 615 | { | 533 | |
3926 | 616 | TaskIcon *taskicon = i->data; | 534 | g_return_if_fail (TASK_IS_MANAGER (manager)); |
3927 | 617 | TaskWindow *taskwin = NULL; | 535 | |
3928 | 618 | 536 | priv = manager->priv; | |
3929 | 619 | if (!TASK_IS_ICON (taskicon)) | 537 | priv->windows = g_slist_remove (priv->windows, old_item); |
3930 | 620 | continue; | 538 | } |
3931 | 621 | 539 | ||
3932 | 622 | taskwin = task_icon_get_window(taskicon); | 540 | /** |
3933 | 623 | taskwin_app = task_window_get_application (taskwin); | 541 | * This function gets called whenever a task-icon gets finalized. |
3934 | 624 | if ( taskwin_app && (taskwin_app == wnck_window_get_application (window))) | 542 | * It removes the task-icon from the gslist and update layout |
3935 | 625 | { | 543 | * (so it gets removed from the bar) |
3936 | 626 | task_icon_append_window (taskicon, task_window_new (window)); | 544 | * State: done |
3937 | 627 | g_object_set_qdata (G_OBJECT (window), win_quark, taskwin); | 545 | */ |
3643 | 628 | return TRUE; | ||
3644 | 629 | } | ||
3645 | 630 | } | ||
3646 | 631 | |||
3647 | 632 | return FALSE; | ||
3648 | 633 | } | ||
3649 | 634 | |||
3650 | 635 | static gboolean | ||
3651 | 636 | try_to_place_window_by_pid (TaskManager *manager, WnckWindow *window) | ||
3652 | 637 | { | ||
3653 | 638 | TaskManagerPrivate *priv = manager->priv; | ||
3654 | 639 | GSList *i; | ||
3655 | 640 | gint taskwin_pid = -1; | ||
3656 | 641 | gint matches = 0; | ||
3657 | 642 | |||
3658 | 643 | for (i = priv->icons; i; i = i->next) | ||
3659 | 644 | { | ||
3660 | 645 | TaskIcon *taskicon = i->data; | ||
3661 | 646 | TaskWindow *taskwin = NULL; | ||
3662 | 647 | |||
3663 | 648 | if (!TASK_IS_ICON (taskicon)) | ||
3664 | 649 | continue; | ||
3665 | 650 | |||
3666 | 651 | taskwin = task_icon_get_window(taskicon); | ||
3667 | 652 | taskwin_pid = task_window_get_pid (taskwin); | ||
3668 | 653 | if ( taskwin_pid && (taskwin_pid == wnck_window_get_pid (window))) | ||
3669 | 654 | { | ||
3670 | 655 | if (matches) | ||
3671 | 656 | { | ||
3672 | 657 | task_icon_append_window (taskicon, task_window_new (window)); | ||
3673 | 658 | g_object_set_qdata (G_OBJECT (window), win_quark, taskwin); | ||
3674 | 659 | return TRUE; | ||
3675 | 660 | } | ||
3676 | 661 | matches++; | ||
3677 | 662 | } | ||
3678 | 663 | } | ||
3679 | 664 | return FALSE; | ||
3680 | 665 | } | ||
3681 | 666 | |||
3682 | 667 | static gboolean | ||
3683 | 668 | try_to_place_util_window (TaskManager *manager, WnckWindow *window) | ||
3684 | 669 | { | ||
3685 | 670 | WnckWindowType type = wnck_window_get_window_type (window); | ||
3686 | 671 | TaskManagerPrivate *priv = manager->priv; | ||
3687 | 672 | GSList *w; | ||
3688 | 673 | gint taskwin_pid = -1; | ||
3689 | 674 | gint matches = 0; | ||
3690 | 675 | |||
3691 | 676 | if ( (type != WNCK_WINDOW_UTILITY) && (type != WNCK_WINDOW_DIALOG) ) | ||
3692 | 677 | { | ||
3693 | 678 | return FALSE; | ||
3694 | 679 | } | ||
3695 | 680 | |||
3696 | 681 | for (w = priv->icons; w; w = w->next) | ||
3697 | 682 | { | ||
3698 | 683 | TaskIcon *taskicon = w->data; | ||
3699 | 684 | TaskWindow *taskwin = NULL; | ||
3700 | 685 | |||
3701 | 686 | if (!TASK_IS_ICON (taskicon)) | ||
3702 | 687 | continue; | ||
3703 | 688 | |||
3704 | 689 | taskwin = task_icon_get_window(taskicon); | ||
3705 | 690 | taskwin_pid = task_window_get_pid (taskwin); | ||
3706 | 691 | if ( taskwin_pid && (taskwin_pid == wnck_window_get_pid (window))) | ||
3707 | 692 | { | ||
3708 | 693 | if (matches) | ||
3709 | 694 | { | ||
3710 | 695 | task_icon_append_window (taskicon, task_window_new (window)); | ||
3711 | 696 | g_object_set_qdata (G_OBJECT (window), win_quark, taskwin); | ||
3712 | 697 | return TRUE; | ||
3713 | 698 | } | ||
3714 | 699 | matches++; | ||
3715 | 700 | } | ||
3716 | 701 | } | ||
3717 | 702 | return FALSE; | ||
3718 | 703 | } | ||
3719 | 704 | |||
3720 | 705 | static gboolean | ||
3721 | 706 | try_to_place_window (TaskManager *manager, WnckWindow *window) | ||
3722 | 707 | { | ||
3723 | 708 | TaskManagerPrivate *priv = manager->priv; | ||
3724 | 709 | gboolean result = FALSE; | ||
3725 | 710 | switch(priv->grouping_mode) | ||
3726 | 711 | { | ||
3727 | 712 | case GROUPING_WMCLASS: /*Fall through*/ | ||
3728 | 713 | result =result?result:try_to_place_window_by_wmclass(manager,window); | ||
3729 | 714 | case GROUPING_WNCK_APP:/*Fall through*/ | ||
3730 | 715 | result =result?result:try_to_place_window_by_wnck_app(manager,window); | ||
3731 | 716 | case GROUPING_PID: /*Don't Fall through*/ | ||
3732 | 717 | result =result?result:try_to_place_window_by_pid(manager,window); | ||
3733 | 718 | break; | ||
3734 | 719 | case GROUPING_UTIL:/*Don't Fall through*/ | ||
3735 | 720 | result =result?result:try_to_place_util_window(manager,window); | ||
3736 | 721 | break; | ||
3737 | 722 | case GROUPING_NONE: | ||
3738 | 723 | break; | ||
3739 | 724 | default: | ||
3740 | 725 | g_assert_not_reached(); | ||
3741 | 726 | } | ||
3742 | 727 | return result; | ||
3743 | 728 | } | ||
3744 | 729 | |||
3745 | 730 | static gboolean | ||
3746 | 731 | try_to_match_window_to_launcher (TaskManager *manager, WnckWindow *window) | ||
3747 | 732 | { | ||
3748 | 733 | TaskManagerPrivate *priv = manager->priv; | ||
3749 | 734 | GSList *l; | ||
3750 | 735 | gchar *temp; | ||
3751 | 736 | gchar *res_name = NULL; | ||
3752 | 737 | gchar *class_name = NULL; | ||
3753 | 738 | gint pid; | ||
3754 | 739 | gboolean res = FALSE; | ||
3755 | 740 | |||
3756 | 741 | /* Grab the appropriete info */ | ||
3757 | 742 | pid = wnck_window_get_pid (window); | ||
3758 | 743 | _wnck_get_wmclass (wnck_window_get_xid (window), &res_name, &class_name); | ||
3759 | 744 | |||
3760 | 745 | if (res_name) | ||
3761 | 746 | { | ||
3762 | 747 | temp = res_name; | ||
3763 | 748 | res_name = g_utf8_strdown (temp, -1); | ||
3764 | 749 | g_free (temp); | ||
3765 | 750 | } | ||
3766 | 751 | |||
3767 | 752 | if (class_name) | ||
3768 | 753 | { | ||
3769 | 754 | temp = class_name; | ||
3770 | 755 | class_name = g_utf8_strdown (temp, -1); | ||
3771 | 756 | g_free (temp); | ||
3772 | 757 | } | ||
3773 | 758 | |||
3774 | 759 | /* Try and match */ | ||
3775 | 760 | for (l = priv->launchers; l; l = l->next) | ||
3776 | 761 | { | ||
3777 | 762 | TaskLauncher *launcher = l->data; | ||
3778 | 763 | |||
3779 | 764 | if (!TASK_IS_LAUNCHER (launcher)) | ||
3780 | 765 | continue; | ||
3781 | 766 | |||
3782 | 767 | if (task_launcher_has_window (launcher)) | ||
3783 | 768 | continue; | ||
3784 | 769 | |||
3785 | 770 | if (!task_launcher_try_match (launcher, pid, res_name, class_name)) | ||
3786 | 771 | continue; | ||
3787 | 772 | |||
3788 | 773 | /* As it matched this launcher, we can set the window to the launcher and | ||
3789 | 774 | * get on with it | ||
3790 | 775 | */ | ||
3791 | 776 | task_launcher_set_window (launcher, window); | ||
3792 | 777 | g_object_set_qdata (G_OBJECT (window), win_quark, launcher); | ||
3793 | 778 | res = TRUE; | ||
3794 | 779 | } | ||
3795 | 780 | g_free (res_name); | ||
3796 | 781 | g_free (class_name); | ||
3797 | 782 | |||
3798 | 783 | return res; | ||
3799 | 784 | } | ||
3800 | 785 | |||
3801 | 786 | static gboolean | ||
3802 | 787 | try_to_match_window_to_sn_context (TaskManager *manager, WnckWindow *window) | ||
3803 | 788 | { | ||
3804 | 789 | return FALSE; | ||
3805 | 790 | } | ||
3806 | 791 | |||
3807 | 792 | static void | ||
3808 | 793 | window_closed (TaskManager *manager, GObject *old_window) | ||
3809 | 794 | { | ||
3810 | 795 | TaskManagerPrivate *priv; | ||
3811 | 796 | |||
3812 | 797 | g_return_if_fail (TASK_IS_MANAGER (manager)); | ||
3813 | 798 | priv = manager->priv; | ||
3814 | 799 | |||
3815 | 800 | priv->windows = g_slist_remove (priv->windows, old_window); | ||
3816 | 801 | |||
3817 | 802 | ensure_layout (manager); | ||
3818 | 803 | } | ||
3819 | 804 | |||
3938 | 805 | static void | 546 | static void |
3939 | 806 | icon_closed (TaskManager *manager, GObject *old_icon) | 547 | icon_closed (TaskManager *manager, GObject *old_icon) |
3940 | 807 | { | 548 | { |
3941 | 808 | TaskManagerPrivate *priv; | 549 | TaskManagerPrivate *priv; |
3942 | 809 | 550 | ||
3943 | 810 | g_return_if_fail (TASK_IS_MANAGER (manager)); | 551 | g_return_if_fail (TASK_IS_MANAGER (manager)); |
3944 | 552 | |||
3945 | 811 | priv = manager->priv; | 553 | priv = manager->priv; |
3946 | 812 | |||
3947 | 813 | priv->icons = g_slist_remove (priv->icons, old_icon); | 554 | priv->icons = g_slist_remove (priv->icons, old_icon); |
3948 | 814 | |||
3949 | 815 | ensure_layout (manager); | ||
3950 | 816 | } | 555 | } |
3951 | 817 | 556 | ||
3952 | 557 | /** | ||
3953 | 558 | * Whenever a new window gets opened it will try to place it | ||
3954 | 559 | * in an awn-icon or will create a new awn-icon. | ||
3955 | 560 | * State: adjusted | ||
3956 | 561 | */ | ||
3957 | 818 | static void | 562 | static void |
3958 | 819 | on_window_opened (WnckScreen *screen, | 563 | on_window_opened (WnckScreen *screen, |
3959 | 820 | WnckWindow *window, | 564 | WnckWindow *window, |
3960 | @@ -822,13 +566,17 @@ | |||
3961 | 822 | { | 566 | { |
3962 | 823 | TaskManagerPrivate *priv; | 567 | TaskManagerPrivate *priv; |
3963 | 824 | GtkWidget *icon; | 568 | GtkWidget *icon; |
3965 | 825 | TaskWindow *taskwin; | 569 | TaskItem *item; |
3966 | 826 | WnckWindowType type; | 570 | WnckWindowType type; |
3967 | 571 | GSList *w; | ||
3968 | 572 | TaskIcon *match = NULL; | ||
3969 | 573 | gint match_score = 0; | ||
3970 | 574 | gint max_match_score = 0; | ||
3971 | 827 | 575 | ||
3972 | 828 | g_return_if_fail (TASK_IS_MANAGER (manager)); | 576 | g_return_if_fail (TASK_IS_MANAGER (manager)); |
3973 | 829 | g_return_if_fail (WNCK_IS_WINDOW (window)); | 577 | g_return_if_fail (WNCK_IS_WINDOW (window)); |
3974 | 578 | |||
3975 | 830 | priv = manager->priv; | 579 | priv = manager->priv; |
3976 | 831 | |||
3977 | 832 | type = wnck_window_get_window_type (window); | 580 | type = wnck_window_get_window_type (window); |
3978 | 833 | 581 | ||
3979 | 834 | switch (type) | 582 | switch (type) |
3980 | @@ -855,84 +603,52 @@ | |||
3981 | 855 | return; | 603 | return; |
3982 | 856 | } | 604 | } |
3983 | 857 | 605 | ||
4062 | 858 | /* | 606 | // create a new TaskWindow containing the WnckWindow |
4063 | 859 | */ | 607 | item = task_window_new (window); |
4064 | 860 | 608 | g_object_set_qdata (G_OBJECT (window), win_quark, TASK_WINDOW (item)); | |
4065 | 861 | if ( priv->grouping_mode && try_to_place_window (manager,window)) | 609 | |
4066 | 862 | { | 610 | priv->windows = g_slist_append (priv->windows, item); |
4067 | 863 | g_debug ("WINDOW PLACED: %s", wnck_window_get_name (window)); | 611 | g_object_weak_ref (G_OBJECT (item), (GWeakNotify)window_closed, manager); |
4068 | 864 | return; | 612 | |
4069 | 865 | } | 613 | // see if there is a icon that matches |
4070 | 866 | 614 | for (w = priv->icons; w; w = w->next) | |
4071 | 867 | /* Okay, time to check the launchers if we can get a match */ | 615 | { |
4072 | 868 | if (try_to_match_window_to_launcher (manager, window)) | 616 | TaskIcon *taskicon = w->data; |
4073 | 869 | { | 617 | |
4074 | 870 | g_debug ("WINDOW MATCHED: %s", wnck_window_get_name (window)); | 618 | if (!TASK_IS_ICON (taskicon)) continue; |
4075 | 871 | return; | 619 | |
4076 | 872 | } | 620 | match_score = task_icon_match_item (taskicon, item); |
4077 | 873 | 621 | if (match_score > max_match_score) | |
4078 | 874 | /* Try the startup-notification windows */ | 622 | { |
4079 | 875 | if (try_to_match_window_to_sn_context (manager, window)) | 623 | max_match_score = match_score; |
4080 | 876 | { | 624 | match = taskicon; |
4081 | 877 | g_debug ("WINDOW STARTUP: %s", wnck_window_get_name (window)); | 625 | } |
4082 | 878 | return; | 626 | } |
4083 | 879 | } | 627 | |
4084 | 880 | 628 | g_debug("Matching score: %i, must be bigger then:%i, groups: %i", max_match_score, 99-priv->match_strength, max_match_score > 99-priv->match_strength); | |
4085 | 881 | /* | 629 | |
4086 | 882 | * We couldn't append the window to a pre-existing TaskWindow, so we'll need | 630 | if (max_match_score > 99-priv->match_strength) |
4087 | 883 | * to make a new one | 631 | { |
4088 | 884 | */ | 632 | task_icon_append_item (match, item); |
4089 | 885 | taskwin = task_window_new (window); | 633 | } |
4090 | 886 | priv->windows = g_slist_append (priv->windows, taskwin); | 634 | else |
4091 | 887 | g_object_weak_ref (G_OBJECT (taskwin), (GWeakNotify)window_closed, manager); | 635 | { |
4092 | 888 | g_object_set_qdata (G_OBJECT (window), win_quark, taskwin); | 636 | icon = task_icon_new(); |
4093 | 889 | 637 | task_icon_append_item (TASK_ICON (icon), item); | |
4094 | 890 | /* If we've come this far, the window deserves a spot on the task-manager! | 638 | |
4095 | 891 | * Time to create a TaskIcon for it | 639 | priv->icons = g_slist_append (priv->icons, icon); |
4096 | 892 | */ | 640 | gtk_container_add (GTK_CONTAINER (priv->box), icon); |
4097 | 893 | icon = task_icon_new_for_window (taskwin); | 641 | |
4098 | 894 | gtk_container_add (GTK_CONTAINER (priv->box), icon); | 642 | /* reordening through D&D */ |
4099 | 895 | gtk_widget_show (icon); | 643 | if(priv->drag_and_drop) |
4100 | 896 | 644 | _drag_add_signals(manager, icon); | |
4101 | 897 | priv->icons = g_slist_append (priv->icons, icon); | 645 | |
4102 | 898 | g_signal_connect_swapped (icon, "ensure_layout", | 646 | g_object_weak_ref (G_OBJECT (icon), (GWeakNotify)icon_closed, manager); |
4103 | 899 | G_CALLBACK (ensure_layout), manager); | 647 | g_signal_connect_swapped (icon, "visible-changed", |
4104 | 900 | 648 | G_CALLBACK (on_icon_visible_changed), manager); | |
4105 | 901 | /* reordening through D&D */ | 649 | |
4106 | 902 | if(priv->drag_and_drop) | 650 | update_icon_visible (manager, TASK_ICON (icon)); |
4107 | 903 | _drag_add_signals(manager, icon); | 651 | } |
4030 | 904 | |||
4031 | 905 | g_object_weak_ref (G_OBJECT (icon), (GWeakNotify)icon_closed, manager); | ||
4032 | 906 | |||
4033 | 907 | /* Finally, make sure all is well on the taskbar */ | ||
4034 | 908 | ensure_layout (manager); | ||
4035 | 909 | } | ||
4036 | 910 | |||
4037 | 911 | static void | ||
4038 | 912 | on_active_window_changed (WnckScreen *screen, | ||
4039 | 913 | WnckWindow *old_window, | ||
4040 | 914 | TaskManager *manager) | ||
4041 | 915 | { | ||
4042 | 916 | TaskManagerPrivate *priv; | ||
4043 | 917 | WnckWindow *active = NULL; | ||
4044 | 918 | TaskWindow *taskwin = NULL; | ||
4045 | 919 | TaskWindow *old_taskwin = NULL; | ||
4046 | 920 | |||
4047 | 921 | g_return_if_fail (TASK_IS_MANAGER (manager)); | ||
4048 | 922 | priv = manager->priv; | ||
4049 | 923 | |||
4050 | 924 | active = wnck_screen_get_active_window (priv->screen); | ||
4051 | 925 | |||
4052 | 926 | if (WNCK_IS_WINDOW (old_window)) | ||
4053 | 927 | old_taskwin = (TaskWindow *)g_object_get_qdata (G_OBJECT (old_window), | ||
4054 | 928 | win_quark); | ||
4055 | 929 | if (WNCK_IS_WINDOW (active)) | ||
4056 | 930 | taskwin = (TaskWindow *)g_object_get_qdata (G_OBJECT (active), win_quark); | ||
4057 | 931 | |||
4058 | 932 | if (TASK_IS_WINDOW (old_taskwin)) | ||
4059 | 933 | task_window_set_is_active (old_taskwin, FALSE); | ||
4060 | 934 | if (TASK_IS_WINDOW (taskwin)) | ||
4061 | 935 | task_window_set_is_active (taskwin, TRUE); | ||
4108 | 936 | } | 652 | } |
4109 | 937 | 653 | ||
4110 | 938 | /* | 654 | /* |
4111 | @@ -942,26 +658,86 @@ | |||
4112 | 942 | task_manager_set_show_all_windows (TaskManager *manager, | 658 | task_manager_set_show_all_windows (TaskManager *manager, |
4113 | 943 | gboolean show_all) | 659 | gboolean show_all) |
4114 | 944 | { | 660 | { |
4115 | 661 | TaskManagerPrivate *priv; | ||
4116 | 662 | GSList *w; | ||
4117 | 663 | WnckWorkspace *space = NULL; | ||
4118 | 664 | |||
4119 | 945 | g_return_if_fail (TASK_IS_MANAGER (manager)); | 665 | g_return_if_fail (TASK_IS_MANAGER (manager)); |
4120 | 666 | |||
4121 | 667 | priv = manager->priv; | ||
4122 | 668 | |||
4123 | 669 | if (priv->show_all_windows == show_all) return; | ||
4124 | 670 | |||
4125 | 946 | manager->priv->show_all_windows = show_all; | 671 | manager->priv->show_all_windows = show_all; |
4126 | 947 | 672 | ||
4129 | 948 | ensure_layout (manager); | 673 | if (show_all) |
4130 | 949 | 674 | { | |
4131 | 675 | // Remove signals of workspace changes | ||
4132 | 676 | g_signal_handlers_disconnect_by_func(priv->screen, | ||
4133 | 677 | G_CALLBACK (on_workspace_changed), | ||
4134 | 678 | manager); | ||
4135 | 679 | |||
4136 | 680 | // Set workspace to NULL, so TaskWindows aren't tied to workspaces anymore | ||
4137 | 681 | space = NULL; | ||
4138 | 682 | } | ||
4139 | 683 | else | ||
4140 | 684 | { | ||
4141 | 685 | // Add signals to WnckScreen for workspace changes | ||
4142 | 686 | g_signal_connect_swapped (priv->screen, "viewports-changed", | ||
4143 | 687 | G_CALLBACK (on_workspace_changed), manager); | ||
4144 | 688 | g_signal_connect_swapped (priv->screen, "active-workspace-changed", | ||
4145 | 689 | G_CALLBACK (on_workspace_changed), manager); | ||
4146 | 690 | |||
4147 | 691 | // Retrieve the current active workspace | ||
4148 | 692 | space = wnck_screen_get_active_workspace (priv->screen); | ||
4149 | 693 | } | ||
4150 | 694 | |||
4151 | 695 | /* Update the workspace for every TaskWindow. | ||
4152 | 696 | * NULL if the windows aren't tied to a workspace anymore */ | ||
4153 | 697 | for (w = priv->windows; w; w = w->next) | ||
4154 | 698 | { | ||
4155 | 699 | TaskWindow *window = w->data; | ||
4156 | 700 | if (!TASK_IS_WINDOW (window)) continue; | ||
4157 | 701 | task_window_set_active_workspace (window, space); | ||
4158 | 702 | } | ||
4159 | 703 | |||
4160 | 950 | g_debug ("%s", show_all ? "showing all windows":"not showing all windows"); | 704 | g_debug ("%s", show_all ? "showing all windows":"not showing all windows"); |
4161 | 951 | } | 705 | } |
4162 | 952 | 706 | ||
4163 | 707 | /** | ||
4164 | 708 | * The property 'show_only_launchers' changed. | ||
4165 | 709 | * So update the property and update the visiblity of every icon. | ||
4166 | 710 | */ | ||
4167 | 953 | static void | 711 | static void |
4168 | 954 | task_manager_set_show_only_launchers (TaskManager *manager, | 712 | task_manager_set_show_only_launchers (TaskManager *manager, |
4170 | 955 | gboolean show_only) | 713 | gboolean only_show_launchers) |
4171 | 956 | { | 714 | { |
4172 | 715 | TaskManagerPrivate *priv; | ||
4173 | 716 | GSList *w; | ||
4174 | 717 | |||
4175 | 957 | g_return_if_fail (TASK_IS_MANAGER (manager)); | 718 | g_return_if_fail (TASK_IS_MANAGER (manager)); |
4181 | 958 | manager->priv->only_show_launchers = show_only; | 719 | |
4182 | 959 | 720 | priv = manager->priv; | |
4183 | 960 | ensure_layout (manager); | 721 | priv->only_show_launchers = only_show_launchers; |
4184 | 961 | 722 | ||
4185 | 962 | g_debug ("%s", show_only ? "only show launchers":"show everything"); | 723 | for (w = priv->icons; w; w = w->next) |
4186 | 724 | { | ||
4187 | 725 | TaskIcon *icon = w->data; | ||
4188 | 726 | |||
4189 | 727 | if (!TASK_IS_ICON (icon)) continue; | ||
4190 | 728 | |||
4191 | 729 | update_icon_visible (manager, icon); | ||
4192 | 730 | } | ||
4193 | 731 | |||
4194 | 732 | g_debug ("%s", only_show_launchers ? "only show launchers":"show everything"); | ||
4195 | 963 | } | 733 | } |
4196 | 964 | 734 | ||
4197 | 735 | /** | ||
4198 | 736 | * Checks when launchers got added/removed in the list in gconf/file. | ||
4199 | 737 | * It removes the launchers from the task-icons and add those | ||
4200 | 738 | * that aren't already on the bar. | ||
4201 | 739 | * State: partial - TODO: refresh of a list | ||
4202 | 740 | */ | ||
4203 | 965 | static void | 741 | static void |
4204 | 966 | task_manager_refresh_launcher_paths (TaskManager *manager, | 742 | task_manager_refresh_launcher_paths (TaskManager *manager, |
4205 | 967 | GSList *list) | 743 | GSList *list) |
4206 | @@ -979,41 +755,23 @@ | |||
4207 | 979 | for (d = list; d; d = d->next) | 755 | for (d = list; d; d = d->next) |
4208 | 980 | { | 756 | { |
4209 | 981 | GtkWidget *icon; | 757 | GtkWidget *icon; |
4229 | 982 | TaskLauncher *launcher = NULL; | 758 | TaskItem *launcher = NULL; |
4211 | 983 | GSList *l; | ||
4212 | 984 | |||
4213 | 985 | for (l = priv->launchers; l; l = l->next) | ||
4214 | 986 | { | ||
4215 | 987 | TaskLauncher *launch = l->data; | ||
4216 | 988 | |||
4217 | 989 | if (!TASK_IS_LAUNCHER (launch)) | ||
4218 | 990 | continue; | ||
4219 | 991 | |||
4220 | 992 | if (g_strcmp0 (d->data, task_launcher_get_desktop_path (launch)) == 0) | ||
4221 | 993 | { | ||
4222 | 994 | launcher = launch; | ||
4223 | 995 | break; | ||
4224 | 996 | } | ||
4225 | 997 | } | ||
4226 | 998 | |||
4227 | 999 | if (TASK_IS_LAUNCHER (launcher)) | ||
4228 | 1000 | continue; | ||
4230 | 1001 | 759 | ||
4231 | 1002 | launcher = task_launcher_new_for_desktop_file (d->data); | 760 | launcher = task_launcher_new_for_desktop_file (d->data); |
4232 | 1003 | 761 | ||
4235 | 1004 | if (!launcher) | 762 | if (!launcher) continue; |
4234 | 1005 | continue; | ||
4236 | 1006 | 763 | ||
4240 | 1007 | priv->launchers = g_slist_append (priv->launchers, launcher); | 764 | icon = task_icon_new (); |
4241 | 1008 | 765 | task_icon_append_item (TASK_ICON (icon), launcher); | |
4239 | 1009 | icon = task_icon_new_for_window (TASK_WINDOW (launcher)); | ||
4242 | 1010 | gtk_container_add (GTK_CONTAINER (priv->box), icon); | 766 | gtk_container_add (GTK_CONTAINER (priv->box), icon); |
4243 | 1011 | gtk_widget_show (icon); | ||
4244 | 1012 | 767 | ||
4245 | 1013 | priv->icons = g_slist_append (priv->icons, icon); | 768 | priv->icons = g_slist_append (priv->icons, icon); |
4248 | 1014 | g_signal_connect_swapped (icon, "ensure_layout", | 769 | |
4247 | 1015 | G_CALLBACK (ensure_layout), manager); | ||
4249 | 1016 | g_object_weak_ref (G_OBJECT (icon), (GWeakNotify)icon_closed, manager); | 770 | g_object_weak_ref (G_OBJECT (icon), (GWeakNotify)icon_closed, manager); |
4250 | 771 | g_signal_connect_swapped (icon, "visible-changed", | ||
4251 | 772 | G_CALLBACK (on_icon_visible_changed), manager); | ||
4252 | 773 | |||
4253 | 774 | update_icon_visible (manager, TASK_ICON (icon)); | ||
4254 | 1017 | 775 | ||
4255 | 1018 | /* reordening through D&D */ | 776 | /* reordening through D&D */ |
4256 | 1019 | if(priv->drag_and_drop) | 777 | if(priv->drag_and_drop) |
4257 | @@ -1023,19 +781,14 @@ | |||
4258 | 1023 | for (d = list; d; d = d->next) | 781 | for (d = list; d; d = d->next) |
4259 | 1024 | g_free (d->data); | 782 | g_free (d->data); |
4260 | 1025 | g_slist_free (list); | 783 | g_slist_free (list); |
4261 | 1026 | |||
4262 | 1027 | /* Finally, make sure all is well on the taskbar */ | ||
4263 | 1028 | ensure_layout (manager); | ||
4264 | 1029 | } | 784 | } |
4265 | 1030 | 785 | ||
4266 | 1031 | static void | 786 | static void |
4269 | 1032 | task_manager_set_grouping_mode (TaskManager *manager, | 787 | task_manager_set_match_strength (TaskManager *manager, |
4270 | 1033 | gint grouping_mode) | 788 | gint match_strength) |
4271 | 1034 | { | 789 | { |
4272 | 1035 | g_return_if_fail (TASK_IS_MANAGER (manager)); | 790 | g_return_if_fail (TASK_IS_MANAGER (manager)); |
4276 | 1036 | manager->priv->grouping_mode = grouping_mode; | 791 | manager->priv->match_strength = match_strength; |
4274 | 1037 | |||
4275 | 1038 | ensure_layout (manager); | ||
4277 | 1039 | } | 792 | } |
4278 | 1040 | 793 | ||
4279 | 1041 | static void | 794 | static void |
4280 | @@ -1049,37 +802,189 @@ | |||
4281 | 1049 | 802 | ||
4282 | 1050 | priv->drag_and_drop = drag_and_drop; | 803 | priv->drag_and_drop = drag_and_drop; |
4283 | 1051 | 804 | ||
4284 | 805 | //connect or dissconnect the dragging signals | ||
4285 | 806 | for (i = priv->icons; i; i = i->next) | ||
4286 | 807 | { | ||
4287 | 808 | TaskIcon *icon = i->data; | ||
4288 | 809 | |||
4289 | 810 | if (!TASK_IS_ICON (icon)) continue; | ||
4290 | 811 | |||
4291 | 812 | if(drag_and_drop) | ||
4292 | 813 | { | ||
4293 | 814 | _drag_add_signals (manager, GTK_WIDGET(icon)); | ||
4294 | 815 | } | ||
4295 | 816 | else | ||
4296 | 817 | { | ||
4297 | 818 | //FIXME: Stop any ongoing move | ||
4298 | 819 | _drag_remove_signals (manager, GTK_WIDGET(icon)); | ||
4299 | 820 | } | ||
4300 | 821 | } | ||
4301 | 1052 | if(drag_and_drop) | 822 | if(drag_and_drop) |
4302 | 1053 | { | 823 | { |
4303 | 1054 | //connect to the dragging signals | ||
4304 | 1055 | for (i = priv->icons; i; i = i->next) | ||
4305 | 1056 | { | ||
4306 | 1057 | TaskIcon *icon = i->data; | ||
4307 | 1058 | |||
4308 | 1059 | if (!TASK_IS_ICON (icon)) continue; | ||
4309 | 1060 | |||
4310 | 1061 | _drag_add_signals (manager, GTK_WIDGET(icon)); | ||
4311 | 1062 | } | ||
4312 | 1063 | _drag_add_signals (manager, GTK_WIDGET(priv->drag_indicator)); | 824 | _drag_add_signals (manager, GTK_WIDGET(priv->drag_indicator)); |
4313 | 1064 | } | 825 | } |
4314 | 1065 | else | 826 | else |
4315 | 1066 | { | 827 | { |
4316 | 1067 | //disconnect the dragging signals | ||
4317 | 1068 | for (i = priv->icons; i; i = i->next) | ||
4318 | 1069 | { | ||
4319 | 1070 | TaskIcon *icon = i->data; | ||
4320 | 1071 | |||
4321 | 1072 | if (!TASK_IS_ICON (icon)) continue; | ||
4322 | 1073 | |||
4323 | 1074 | _drag_remove_signals (manager, GTK_WIDGET(icon)); | ||
4324 | 1075 | } | ||
4325 | 1076 | _drag_remove_signals (manager, GTK_WIDGET(priv->drag_indicator)); | 828 | _drag_remove_signals (manager, GTK_WIDGET(priv->drag_indicator)); |
4326 | 1077 | //FIXME: Stop any ongoing move | ||
4327 | 1078 | } | 829 | } |
4328 | 1079 | 830 | ||
4329 | 1080 | g_debug("%s", drag_and_drop?"D&D is on":"D&D is off"); | 831 | g_debug("%s", drag_and_drop?"D&D is on":"D&D is off"); |
4330 | 1081 | } | 832 | } |
4331 | 1082 | 833 | ||
4332 | 834 | /** | ||
4333 | 835 | * D-BUS functionality | ||
4334 | 836 | */ | ||
4335 | 837 | |||
4336 | 838 | gboolean | ||
4337 | 839 | task_manager_get_capabilities (TaskManager *manager, | ||
4338 | 840 | GStrv *supported_keys, | ||
4339 | 841 | GError **error) | ||
4340 | 842 | { | ||
4341 | 843 | const gchar *known_keys[] = | ||
4342 | 844 | { | ||
4343 | 845 | "icon-file", | ||
4344 | 846 | "progress", | ||
4345 | 847 | "message", | ||
4346 | 848 | "visible", | ||
4347 | 849 | NULL | ||
4348 | 850 | }; | ||
4349 | 851 | |||
4350 | 852 | *supported_keys = g_strdupv ((char **)known_keys); | ||
4351 | 853 | |||
4352 | 854 | return TRUE; | ||
4353 | 855 | } | ||
4354 | 856 | |||
4355 | 857 | /** | ||
4356 | 858 | * Find the window that corresponds to the given window name. | ||
4357 | 859 | * First try to match the application name, then the normal name. | ||
4358 | 860 | */ | ||
4359 | 861 | static TaskWindow* | ||
4360 | 862 | _match_name (TaskManager *manager, const gchar* window) | ||
4361 | 863 | { | ||
4362 | 864 | TaskManagerPrivate *priv; | ||
4363 | 865 | WnckApplication *wnck_app = NULL; | ||
4364 | 866 | const gchar *name = NULL; | ||
4365 | 867 | GSList *w; | ||
4366 | 868 | |||
4367 | 869 | g_return_val_if_fail (TASK_IS_MANAGER (manager), FALSE); | ||
4368 | 870 | priv = manager->priv; | ||
4369 | 871 | |||
4370 | 872 | for (w = priv->windows; w; w = w->next) | ||
4371 | 873 | { | ||
4372 | 874 | TaskWindow *taskwindow = w->data; | ||
4373 | 875 | |||
4374 | 876 | if (!TASK_IS_WINDOW (taskwindow)) continue; | ||
4375 | 877 | |||
4376 | 878 | wnck_app = task_window_get_application (taskwindow); | ||
4377 | 879 | if (WNCK_IS_APPLICATION(wnck_app)) | ||
4378 | 880 | { | ||
4379 | 881 | name = wnck_application_get_name(wnck_app); | ||
4380 | 882 | if (name && strcmp (window, name) == 0) | ||
4381 | 883 | return taskwindow; | ||
4382 | 884 | } | ||
4383 | 885 | |||
4384 | 886 | name = task_window_get_name (taskwindow); | ||
4385 | 887 | if (name && strcmp (window, name) == 0) | ||
4386 | 888 | return taskwindow; | ||
4387 | 889 | } | ||
4388 | 890 | |||
4389 | 891 | return NULL; | ||
4390 | 892 | } | ||
4391 | 893 | |||
4392 | 894 | /** | ||
4393 | 895 | * Find the window that corresponds to the given xid | ||
4394 | 896 | */ | ||
4395 | 897 | static TaskWindow* | ||
4396 | 898 | _match_xid (TaskManager *manager, gint64 window) | ||
4397 | 899 | { | ||
4398 | 900 | TaskManagerPrivate *priv; | ||
4399 | 901 | gint64 xid; | ||
4400 | 902 | GSList *w; | ||
4401 | 903 | |||
4402 | 904 | g_return_val_if_fail (TASK_IS_MANAGER (manager), FALSE); | ||
4403 | 905 | priv = manager->priv; | ||
4404 | 906 | |||
4405 | 907 | for (w = priv->windows; w; w = w->next) | ||
4406 | 908 | { | ||
4407 | 909 | TaskWindow *taskwindow = w->data; | ||
4408 | 910 | |||
4409 | 911 | if (!TASK_IS_WINDOW (taskwindow)) continue; | ||
4410 | 912 | |||
4411 | 913 | xid = task_window_get_xid (taskwindow); | ||
4412 | 914 | if (xid && window == xid) | ||
4413 | 915 | return taskwindow; | ||
4414 | 916 | } | ||
4415 | 917 | |||
4416 | 918 | return NULL; | ||
4417 | 919 | } | ||
4418 | 920 | |||
4419 | 921 | gboolean | ||
4420 | 922 | task_manager_update (TaskManager *manager, | ||
4421 | 923 | GValue *window, | ||
4422 | 924 | GHashTable *hints, /* mappings from string to GValue */ | ||
4423 | 925 | GError **error) | ||
4424 | 926 | { | ||
4425 | 927 | TaskManagerPrivate *priv; | ||
4426 | 928 | TaskWindow *matched_window = NULL; | ||
4427 | 929 | |||
4428 | 930 | g_return_val_if_fail (TASK_IS_MANAGER (manager), FALSE); | ||
4429 | 931 | |||
4430 | 932 | priv = manager->priv; | ||
4431 | 933 | |||
4432 | 934 | if (G_VALUE_HOLDS_STRING (window)) | ||
4433 | 935 | { | ||
4434 | 936 | matched_window = _match_name (manager, g_value_get_string (window)); | ||
4435 | 937 | } | ||
4436 | 938 | else if (G_VALUE_HOLDS_INT64 (window)) | ||
4437 | 939 | { | ||
4438 | 940 | matched_window = _match_xid (manager, g_value_get_int64 (window)); | ||
4439 | 941 | } | ||
4440 | 942 | else | ||
4441 | 943 | { | ||
4442 | 944 | //G_ERROR stuff | ||
4443 | 945 | return FALSE; | ||
4444 | 946 | } | ||
4445 | 947 | |||
4446 | 948 | if (matched_window) | ||
4447 | 949 | { | ||
4448 | 950 | GHashTableIter iter; | ||
4449 | 951 | gpointer key, value; | ||
4450 | 952 | |||
4451 | 953 | g_hash_table_iter_init (&iter, hints); | ||
4452 | 954 | while (g_hash_table_iter_next (&iter, &key, &value)) | ||
4453 | 955 | { | ||
4454 | 956 | gchar *key_name = (gchar *)key; | ||
4455 | 957 | if (strcmp ("icon-file", key_name) == 0) | ||
4456 | 958 | { | ||
4457 | 959 | |||
4458 | 960 | } | ||
4459 | 961 | else if (strcmp ("progress", key_name) == 0) | ||
4460 | 962 | { | ||
4461 | 963 | |||
4462 | 964 | } | ||
4463 | 965 | else if (strcmp ("message", key_name) == 0) | ||
4464 | 966 | { | ||
4465 | 967 | |||
4466 | 968 | } | ||
4467 | 969 | else if (strcmp ("visible", key_name) == 0) | ||
4468 | 970 | { | ||
4469 | 971 | |||
4470 | 972 | } | ||
4471 | 973 | else | ||
4472 | 974 | { | ||
4473 | 975 | g_debug ("Taskmanager doesn't understand the key: %s", key_name); | ||
4474 | 976 | } | ||
4475 | 977 | } | ||
4476 | 978 | |||
4477 | 979 | return TRUE; | ||
4478 | 980 | } | ||
4479 | 981 | else | ||
4480 | 982 | { | ||
4481 | 983 | return FALSE; | ||
4482 | 984 | } | ||
4483 | 985 | } | ||
4484 | 986 | |||
4485 | 987 | |||
4486 | 1083 | /* | 988 | /* |
4487 | 1084 | * Position Icons through dragging | 989 | * Position Icons through dragging |
4488 | 1085 | */ | 990 | */ |
4489 | @@ -1212,11 +1117,11 @@ | |||
4490 | 1212 | TaskManagerPrivate *priv; | 1117 | TaskManagerPrivate *priv; |
4491 | 1213 | gint move_to; | 1118 | gint move_to; |
4492 | 1214 | GList* childs; | 1119 | GList* childs; |
4498 | 1215 | GSList* d; | 1120 | //GSList* d; |
4499 | 1216 | GSList* launchers = NULL; | 1121 | //GSList* launchers = NULL; |
4500 | 1217 | TaskLauncher* launcher; | 1122 | //TaskLauncher* launcher; |
4501 | 1218 | gchar* launcher_path; | 1123 | //gchar* launcher_path; |
4502 | 1219 | GError *err = NULL; | 1124 | //GError *err = NULL; |
4503 | 1220 | 1125 | ||
4504 | 1221 | g_return_if_fail (TASK_IS_MANAGER (manager)); | 1126 | g_return_if_fail (TASK_IS_MANAGER (manager)); |
4505 | 1222 | 1127 | ||
4506 | @@ -1252,7 +1157,7 @@ | |||
4507 | 1252 | // Update the position in the config (Gconf) if the AwnIcon is a launcher. | 1157 | // Update the position in the config (Gconf) if the AwnIcon is a launcher. |
4508 | 1253 | // FIXME: support multiple launchers in one AwnIcon? | 1158 | // FIXME: support multiple launchers in one AwnIcon? |
4509 | 1254 | 1159 | ||
4511 | 1255 | if (task_icon_is_launcher (priv->dragged_icon)) | 1160 | /* if (task_icon_is_launcher (priv->dragged_icon)) |
4512 | 1256 | { | 1161 | { |
4513 | 1257 | // get the updated list | 1162 | // get the updated list |
4514 | 1258 | childs = gtk_container_get_children (GTK_CONTAINER(priv->box)); | 1163 | childs = gtk_container_get_children (GTK_CONTAINER(priv->box)); |
4515 | @@ -1283,6 +1188,7 @@ | |||
4516 | 1283 | return; | 1188 | return; |
4517 | 1284 | } | 1189 | } |
4518 | 1285 | } | 1190 | } |
4519 | 1191 | */ | ||
4520 | 1286 | 1192 | ||
4521 | 1287 | priv->dragged_icon = NULL; | 1193 | priv->dragged_icon = NULL; |
4522 | 1288 | } | 1194 | } |
4523 | 1289 | 1195 | ||
4524 | === modified file 'applets/taskmanager/task-manager.h' | |||
4525 | --- applets/taskmanager/task-manager.h 2009-03-03 00:58:39 +0000 | |||
4526 | +++ applets/taskmanager/task-manager.h 2009-06-21 23:03:17 +0000 | |||
4527 | @@ -64,5 +64,14 @@ | |||
4528 | 64 | gint offset, | 64 | gint offset, |
4529 | 65 | gint height); | 65 | gint height); |
4530 | 66 | 66 | ||
4531 | 67 | gboolean task_manager_get_capabilities (TaskManager *manager, | ||
4532 | 68 | GStrv *supported_keys, | ||
4533 | 69 | GError **error); | ||
4534 | 70 | |||
4535 | 71 | gboolean task_manager_update (TaskManager *manager, | ||
4536 | 72 | GValue *window, | ||
4537 | 73 | GHashTable *hints, /* mappings from string to GValue */ | ||
4538 | 74 | GError **error); | ||
4539 | 75 | |||
4540 | 67 | #endif /* _TASK_MANAGER_H_ */ | 76 | #endif /* _TASK_MANAGER_H_ */ |
4541 | 68 | 77 | ||
4542 | 69 | 78 | ||
4543 | === removed file 'applets/taskmanager/task-window-private.h' | |||
4544 | --- applets/taskmanager/task-window-private.h 2009-03-24 16:39:41 +0000 | |||
4545 | +++ applets/taskmanager/task-window-private.h 1970-01-01 00:00:00 +0000 | |||
4546 | @@ -1,35 +0,0 @@ | |||
4547 | 1 | /* | ||
4548 | 2 | * Copyright (C) 2008 Neil Jagdish Patel <njpatel@gmail.com> | ||
4549 | 3 | * | ||
4550 | 4 | * This program is free software: you can redistribute it and/or modify | ||
4551 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
4552 | 6 | * published by the Free Software Foundation. | ||
4553 | 7 | * | ||
4554 | 8 | * This program is distributed in the hope that it will be useful, | ||
4555 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
4556 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
4557 | 11 | * GNU General Public License for more details. | ||
4558 | 12 | * | ||
4559 | 13 | * You should have received a copy of the GNU General Public License | ||
4560 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
4561 | 15 | * | ||
4562 | 16 | * Authored by Neil Jagdish Patel <njpatel@gmail.com> | ||
4563 | 17 | * | ||
4564 | 18 | */ | ||
4565 | 19 | |||
4566 | 20 | #define TASK_WINDOW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj),\ | ||
4567 | 21 | TASK_TYPE_WINDOW, \ | ||
4568 | 22 | TaskWindowPrivate)) | ||
4569 | 23 | |||
4570 | 24 | struct _TaskWindowPrivate | ||
4571 | 25 | { | ||
4572 | 26 | WnckWindow *window; | ||
4573 | 27 | |||
4574 | 28 | /* Properties */ | ||
4575 | 29 | gchar *message; | ||
4576 | 30 | gfloat progress; | ||
4577 | 31 | gboolean hidden; | ||
4578 | 32 | gboolean needs_attention; | ||
4579 | 33 | gboolean is_active; | ||
4580 | 34 | }; | ||
4581 | 35 | |||
4582 | 36 | 0 | ||
4583 | === modified file 'applets/taskmanager/task-window.c' | |||
4584 | --- applets/taskmanager/task-window.c 2009-06-11 05:04:21 +0000 | |||
4585 | +++ applets/taskmanager/task-window.c 2009-06-26 11:00:10 +0000 | |||
4586 | @@ -14,6 +14,7 @@ | |||
4587 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4588 | 15 | * | 15 | * |
4589 | 16 | * Authored by Neil Jagdish Patel <njpatel@gmail.com> | 16 | * Authored by Neil Jagdish Patel <njpatel@gmail.com> |
4590 | 17 | * Hannes Verschore <hv1989@gmail.com> | ||
4591 | 17 | * | 18 | * |
4592 | 18 | */ | 19 | */ |
4593 | 19 | 20 | ||
4594 | @@ -26,11 +27,33 @@ | |||
4595 | 26 | #include <libwnck/libwnck.h> | 27 | #include <libwnck/libwnck.h> |
4596 | 27 | 28 | ||
4597 | 28 | #include "task-window.h" | 29 | #include "task-window.h" |
4598 | 29 | #include "task-launcher.h" | ||
4599 | 30 | #include "task-settings.h" | 30 | #include "task-settings.h" |
4600 | 31 | #include "xutils.h" | 31 | #include "xutils.h" |
4601 | 32 | 32 | ||
4603 | 33 | G_DEFINE_TYPE (TaskWindow, task_window, G_TYPE_OBJECT) | 33 | G_DEFINE_TYPE (TaskWindow, task_window, TASK_TYPE_ITEM) |
4604 | 34 | |||
4605 | 35 | #define TASK_WINDOW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj),\ | ||
4606 | 36 | TASK_TYPE_WINDOW, \ | ||
4607 | 37 | TaskWindowPrivate)) | ||
4608 | 38 | |||
4609 | 39 | struct _TaskWindowPrivate | ||
4610 | 40 | { | ||
4611 | 41 | WnckWindow *window; | ||
4612 | 42 | |||
4613 | 43 | // Workspace where the window should be in, before being visible. | ||
4614 | 44 | // NULL if it isn't important | ||
4615 | 45 | WnckWorkspace *workspace; | ||
4616 | 46 | |||
4617 | 47 | // Is this window in the workspace. If workspace is NULL, this is always TRUE; | ||
4618 | 48 | gboolean in_workspace; | ||
4619 | 49 | |||
4620 | 50 | /* Properties */ | ||
4621 | 51 | gchar *message; | ||
4622 | 52 | gfloat progress; | ||
4623 | 53 | gboolean hidden; | ||
4624 | 54 | gboolean needs_attention; | ||
4625 | 55 | gboolean is_active; | ||
4626 | 56 | }; | ||
4627 | 34 | 57 | ||
4628 | 35 | enum | 58 | enum |
4629 | 36 | { | 59 | { |
4630 | @@ -40,27 +63,25 @@ | |||
4631 | 40 | 63 | ||
4632 | 41 | enum | 64 | enum |
4633 | 42 | { | 65 | { |
4634 | 43 | NAME_CHANGED, | ||
4635 | 44 | ICON_CHANGED, | ||
4636 | 45 | ACTIVE_CHANGED, | 66 | ACTIVE_CHANGED, |
4637 | 46 | NEEDS_ATTENTION, | 67 | NEEDS_ATTENTION, |
4638 | 47 | WORKSPACE_CHANGED, | 68 | WORKSPACE_CHANGED, |
4639 | 48 | MESSAGE_CHANGED, | 69 | MESSAGE_CHANGED, |
4640 | 49 | PROGRESS_CHANGED, | 70 | PROGRESS_CHANGED, |
4641 | 50 | HIDDEN_CHANGED, | 71 | HIDDEN_CHANGED, |
4642 | 51 | RUNNING_CHANGED, | ||
4643 | 52 | 72 | ||
4644 | 53 | LAST_SIGNAL | 73 | LAST_SIGNAL |
4645 | 54 | }; | 74 | }; |
4646 | 55 | static guint32 _window_signals[LAST_SIGNAL] = { 0 }; | 75 | static guint32 _window_signals[LAST_SIGNAL] = { 0 }; |
4647 | 56 | 76 | ||
4648 | 57 | /* Forwards */ | 77 | /* Forwards */ |
4655 | 58 | static WnckApplication * _get_application (TaskWindow *window); | 78 | static const gchar * _get_name (TaskItem *item); |
4656 | 59 | static gint _get_pid (TaskWindow *window); | 79 | static GdkPixbuf * _get_icon (TaskItem *item); |
4657 | 60 | static const gchar * _get_name (TaskWindow *window); | 80 | static gboolean _is_visible (TaskItem *item); |
4658 | 61 | static GdkPixbuf * _get_icon (TaskWindow *window); | 81 | static void _left_click (TaskItem *item, GdkEventButton *event); |
4659 | 62 | static gboolean _is_on_workspace (TaskWindow *window, | 82 | static void _right_click (TaskItem *item, GdkEventButton *event); |
4660 | 63 | WnckWorkspace *space); | 83 | static guint _match (TaskItem *item, TaskItem *item_to_match); |
4661 | 84 | |||
4662 | 64 | static void task_window_set_window (TaskWindow *window, | 85 | static void task_window_set_window (TaskWindow *window, |
4663 | 65 | WnckWindow *wnckwin); | 86 | WnckWindow *wnckwin); |
4664 | 66 | 87 | ||
4665 | @@ -104,51 +125,24 @@ | |||
4666 | 104 | } | 125 | } |
4667 | 105 | 126 | ||
4668 | 106 | static void | 127 | static void |
4669 | 107 | task_window_constructed (GObject *object) | ||
4670 | 108 | { | ||
4671 | 109 | /*TaskWindowPrivate *priv = TASK_WINDOW (object)->priv;*/ | ||
4672 | 110 | } | ||
4673 | 111 | |||
4674 | 112 | static void | ||
4675 | 113 | task_window_class_init (TaskWindowClass *klass) | 128 | task_window_class_init (TaskWindowClass *klass) |
4676 | 114 | { | 129 | { |
4681 | 115 | GParamSpec *pspec; | 130 | GParamSpec *pspec; |
4682 | 116 | GObjectClass *obj_class = G_OBJECT_CLASS (klass); | 131 | GObjectClass *obj_class = G_OBJECT_CLASS (klass); |
4683 | 117 | 132 | TaskItemClass *item_class = TASK_ITEM_CLASS (klass); | |
4684 | 118 | obj_class->constructed = task_window_constructed; | 133 | |
4685 | 119 | obj_class->set_property = task_window_set_property; | 134 | obj_class->set_property = task_window_set_property; |
4686 | 120 | obj_class->get_property = task_window_get_property; | 135 | obj_class->get_property = task_window_get_property; |
4697 | 121 | 136 | ||
4698 | 122 | /* We implement the necessary funtions for a normal window */ | 137 | /* We implement the necessary funtions for an item */ |
4699 | 123 | klass->get_application = _get_application; | 138 | item_class->get_name = _get_name; |
4700 | 124 | klass->get_pid = _get_pid; | 139 | item_class->get_icon = _get_icon; |
4701 | 125 | klass->get_name = _get_name; | 140 | item_class->is_visible = _is_visible; |
4702 | 126 | klass->get_icon = _get_icon; | 141 | item_class->left_click = _left_click; |
4703 | 127 | klass->is_on_workspace = _is_on_workspace; | 142 | item_class->right_click = _right_click; |
4704 | 128 | klass->activate = NULL; | 143 | item_class->match = _match; |
4705 | 129 | klass->popup_menu = NULL; | 144 | |
4696 | 130 | |||
4706 | 131 | /* Install signals */ | 145 | /* Install signals */ |
4707 | 132 | _window_signals[NAME_CHANGED] = | ||
4708 | 133 | g_signal_new ("name-changed", | ||
4709 | 134 | G_OBJECT_CLASS_TYPE (obj_class), | ||
4710 | 135 | G_SIGNAL_RUN_LAST, | ||
4711 | 136 | G_STRUCT_OFFSET (TaskWindowClass, name_changed), | ||
4712 | 137 | NULL, NULL, | ||
4713 | 138 | g_cclosure_marshal_VOID__STRING, | ||
4714 | 139 | G_TYPE_NONE, | ||
4715 | 140 | 1, G_TYPE_STRING); | ||
4716 | 141 | |||
4717 | 142 | _window_signals[ICON_CHANGED] = | ||
4718 | 143 | g_signal_new ("icon-changed", | ||
4719 | 144 | G_OBJECT_CLASS_TYPE (obj_class), | ||
4720 | 145 | G_SIGNAL_RUN_LAST, | ||
4721 | 146 | G_STRUCT_OFFSET (TaskWindowClass, icon_changed), | ||
4722 | 147 | NULL, NULL, | ||
4723 | 148 | g_cclosure_marshal_VOID__OBJECT, | ||
4724 | 149 | G_TYPE_NONE, | ||
4725 | 150 | 1, GDK_TYPE_PIXBUF); | ||
4726 | 151 | |||
4727 | 152 | _window_signals[ACTIVE_CHANGED] = | 146 | _window_signals[ACTIVE_CHANGED] = |
4728 | 153 | g_signal_new ("active-changed", | 147 | g_signal_new ("active-changed", |
4729 | 154 | G_OBJECT_CLASS_TYPE (obj_class), | 148 | G_OBJECT_CLASS_TYPE (obj_class), |
4730 | @@ -209,17 +203,6 @@ | |||
4731 | 209 | G_TYPE_NONE, | 203 | G_TYPE_NONE, |
4732 | 210 | 1, G_TYPE_BOOLEAN); | 204 | 1, G_TYPE_BOOLEAN); |
4733 | 211 | 205 | ||
4734 | 212 | _window_signals[RUNNING_CHANGED] = | ||
4735 | 213 | g_signal_new ("running-changed", | ||
4736 | 214 | G_OBJECT_CLASS_TYPE (obj_class), | ||
4737 | 215 | G_SIGNAL_RUN_LAST, | ||
4738 | 216 | G_STRUCT_OFFSET (TaskWindowClass, running_changed), | ||
4739 | 217 | NULL, NULL, | ||
4740 | 218 | g_cclosure_marshal_VOID__BOOLEAN, | ||
4741 | 219 | G_TYPE_NONE, | ||
4742 | 220 | 1, G_TYPE_BOOLEAN); | ||
4743 | 221 | |||
4744 | 222 | |||
4745 | 223 | /* Install properties */ | 206 | /* Install properties */ |
4746 | 224 | pspec = g_param_spec_object ("taskwindow", | 207 | pspec = g_param_spec_object ("taskwindow", |
4747 | 225 | "Window", | 208 | "Window", |
4748 | @@ -237,6 +220,8 @@ | |||
4749 | 237 | 220 | ||
4750 | 238 | priv = window->priv = TASK_WINDOW_GET_PRIVATE (window); | 221 | priv = window->priv = TASK_WINDOW_GET_PRIVATE (window); |
4751 | 239 | 222 | ||
4752 | 223 | priv->workspace = NULL; | ||
4753 | 224 | priv->in_workspace = TRUE; | ||
4754 | 240 | priv->message = NULL; | 225 | priv->message = NULL; |
4755 | 241 | priv->progress = 0; | 226 | priv->progress = 0; |
4756 | 242 | priv->hidden = FALSE; | 227 | priv->hidden = FALSE; |
4757 | @@ -244,14 +229,14 @@ | |||
4758 | 244 | priv->is_active = FALSE; | 229 | priv->is_active = FALSE; |
4759 | 245 | } | 230 | } |
4760 | 246 | 231 | ||
4762 | 247 | TaskWindow * | 232 | TaskItem * |
4763 | 248 | task_window_new (WnckWindow *window) | 233 | task_window_new (WnckWindow *window) |
4764 | 249 | { | 234 | { |
4766 | 250 | TaskWindow *win = NULL; | 235 | TaskItem *win = NULL; |
4767 | 251 | 236 | ||
4768 | 252 | win = g_object_new (TASK_TYPE_WINDOW, | 237 | win = g_object_new (TASK_TYPE_WINDOW, |
4771 | 253 | "taskwindow", window, | 238 | "taskwindow", window, |
4772 | 254 | NULL); | 239 | NULL); |
4773 | 255 | 240 | ||
4774 | 256 | return win; | 241 | return win; |
4775 | 257 | } | 242 | } |
4776 | @@ -262,11 +247,8 @@ | |||
4777 | 262 | */ | 247 | */ |
4778 | 263 | static void | 248 | static void |
4779 | 264 | window_closed (TaskWindow *window, WnckWindow *old_window) | 249 | window_closed (TaskWindow *window, WnckWindow *old_window) |
4785 | 265 | { | 250 | { |
4786 | 266 | g_signal_emit (window, _window_signals[RUNNING_CHANGED], 0, FALSE); | 251 | gtk_widget_destroy (GTK_WIDGET (window)); |
4782 | 267 | |||
4783 | 268 | if (!TASK_IS_LAUNCHER (window)) | ||
4784 | 269 | g_object_unref (G_OBJECT (window)); | ||
4787 | 270 | } | 252 | } |
4788 | 271 | 253 | ||
4789 | 272 | static void | 254 | static void |
4790 | @@ -278,8 +260,7 @@ | |||
4791 | 278 | g_return_if_fail (WNCK_IS_WINDOW (wnckwin)); | 260 | g_return_if_fail (WNCK_IS_WINDOW (wnckwin)); |
4792 | 279 | priv = window->priv; | 261 | priv = window->priv; |
4793 | 280 | 262 | ||
4796 | 281 | g_signal_emit (window, _window_signals[NAME_CHANGED], | 263 | task_item_emit_name_changed (TASK_ITEM (window), wnck_window_get_name (wnckwin)); |
4795 | 282 | 0, wnck_window_get_name (wnckwin)); | ||
4797 | 283 | } | 264 | } |
4798 | 284 | 265 | ||
4799 | 285 | static void | 266 | static void |
4800 | @@ -292,7 +273,7 @@ | |||
4801 | 292 | g_return_if_fail (WNCK_IS_WINDOW (wnckwin)); | 273 | g_return_if_fail (WNCK_IS_WINDOW (wnckwin)); |
4802 | 293 | 274 | ||
4803 | 294 | pixbuf = _wnck_get_icon_at_size (wnckwin, s->panel_size, s->panel_size); | 275 | pixbuf = _wnck_get_icon_at_size (wnckwin, s->panel_size, s->panel_size); |
4805 | 295 | task_window_update_icon (window, pixbuf); | 276 | task_item_emit_icon_changed (TASK_ITEM (window), pixbuf); |
4806 | 296 | g_object_unref (pixbuf); | 277 | g_object_unref (pixbuf); |
4807 | 297 | } | 278 | } |
4808 | 298 | 279 | ||
4809 | @@ -303,7 +284,17 @@ | |||
4810 | 303 | 284 | ||
4811 | 304 | g_return_if_fail (TASK_IS_WINDOW (window)); | 285 | g_return_if_fail (TASK_IS_WINDOW (window)); |
4812 | 305 | g_return_if_fail (WNCK_IS_WINDOW (wnckwin)); | 286 | g_return_if_fail (WNCK_IS_WINDOW (wnckwin)); |
4813 | 287 | |||
4814 | 306 | priv = window->priv; | 288 | priv = window->priv; |
4815 | 289 | if (priv->workspace==NULL) | ||
4816 | 290 | priv->in_workspace = TRUE; | ||
4817 | 291 | else | ||
4818 | 292 | priv->in_workspace = wnck_window_is_in_viewport (priv->window, priv->workspace); | ||
4819 | 293 | |||
4820 | 294 | if (priv->in_workspace && !priv->hidden) | ||
4821 | 295 | task_item_emit_visible_changed (TASK_ITEM (window), TRUE); | ||
4822 | 296 | else | ||
4823 | 297 | task_item_emit_visible_changed (TASK_ITEM (window), FALSE); | ||
4824 | 307 | 298 | ||
4825 | 308 | g_signal_emit (window, _window_signals[WORKSPACE_CHANGED], | 299 | g_signal_emit (window, _window_signals[WORKSPACE_CHANGED], |
4826 | 309 | 0, wnck_window_get_workspace (wnckwin)); | 300 | 0, wnck_window_get_workspace (wnckwin)); |
4827 | @@ -329,7 +320,11 @@ | |||
4828 | 329 | if (priv->hidden != hidden) | 320 | if (priv->hidden != hidden) |
4829 | 330 | { | 321 | { |
4830 | 331 | priv->hidden = hidden; | 322 | priv->hidden = hidden; |
4832 | 332 | g_signal_emit (window, _window_signals[HIDDEN_CHANGED], 0, hidden); | 323 | |
4833 | 324 | if (priv->in_workspace && !priv->hidden) | ||
4834 | 325 | task_item_emit_visible_changed (TASK_ITEM (window), TRUE); | ||
4835 | 326 | else | ||
4836 | 327 | task_item_emit_visible_changed (TASK_ITEM (window), FALSE); | ||
4837 | 333 | } | 328 | } |
4838 | 334 | 329 | ||
4839 | 335 | needs_attention = wnck_window_or_transient_needs_attention (wnckwin); | 330 | needs_attention = wnck_window_or_transient_needs_attention (wnckwin); |
4840 | @@ -342,14 +337,19 @@ | |||
4841 | 342 | } | 337 | } |
4842 | 343 | } | 338 | } |
4843 | 344 | 339 | ||
4844 | 340 | /** | ||
4845 | 341 | * TODO: remove old signals and weak_ref... | ||
4846 | 342 | */ | ||
4847 | 345 | static void | 343 | static void |
4848 | 346 | task_window_set_window (TaskWindow *window, WnckWindow *wnckwin) | 344 | task_window_set_window (TaskWindow *window, WnckWindow *wnckwin) |
4849 | 347 | { | 345 | { |
4850 | 348 | TaskWindowPrivate *priv; | 346 | TaskWindowPrivate *priv; |
4852 | 349 | 347 | GdkPixbuf *pixbuf; | |
4853 | 348 | TaskSettings *s = task_settings_get_default (); | ||
4854 | 349 | |||
4855 | 350 | g_return_if_fail (TASK_IS_WINDOW (window)); | 350 | g_return_if_fail (TASK_IS_WINDOW (window)); |
4856 | 351 | |||
4857 | 351 | priv = window->priv; | 352 | priv = window->priv; |
4858 | 352 | |||
4859 | 353 | priv->window = wnckwin; | 353 | priv->window = wnckwin; |
4860 | 354 | 354 | ||
4861 | 355 | g_object_weak_ref (G_OBJECT (priv->window), | 355 | g_object_weak_ref (G_OBJECT (priv->window), |
4862 | @@ -364,14 +364,33 @@ | |||
4863 | 364 | g_signal_connect (wnckwin, "state-changed", | 364 | g_signal_connect (wnckwin, "state-changed", |
4864 | 365 | G_CALLBACK (on_window_state_changed), window); | 365 | G_CALLBACK (on_window_state_changed), window); |
4865 | 366 | 366 | ||
4867 | 367 | g_signal_emit (window, _window_signals[RUNNING_CHANGED], 0, TRUE); | 367 | task_item_emit_name_changed (TASK_ITEM (window), wnck_window_get_name (wnckwin)); |
4868 | 368 | pixbuf = _wnck_get_icon_at_size (wnckwin, s->panel_size, s->panel_size); | ||
4869 | 369 | task_item_emit_icon_changed (TASK_ITEM (window), pixbuf); | ||
4870 | 370 | g_object_unref (pixbuf); | ||
4871 | 371 | task_item_emit_visible_changed (TASK_ITEM (window), TRUE); | ||
4872 | 368 | } | 372 | } |
4873 | 369 | 373 | ||
4874 | 370 | /* | 374 | /* |
4875 | 371 | * Public functions | 375 | * Public functions |
4876 | 372 | */ | 376 | */ |
4877 | 377 | |||
4878 | 378 | /** | ||
4879 | 379 | * Returns the name of the WnckWindow. | ||
4880 | 380 | */ | ||
4881 | 381 | const gchar * | ||
4882 | 382 | task_window_get_name (TaskWindow *window) | ||
4883 | 383 | { | ||
4884 | 384 | g_return_val_if_fail (TASK_IS_WINDOW (window), ""); | ||
4885 | 385 | |||
4886 | 386 | if (WNCK_IS_WINDOW (window->priv->window)) | ||
4887 | 387 | return wnck_window_get_name (window->priv->window); | ||
4888 | 388 | |||
4889 | 389 | return ""; | ||
4890 | 390 | } | ||
4891 | 391 | |||
4892 | 373 | WnckScreen * | 392 | WnckScreen * |
4894 | 374 | task_window_get_screen (TaskWindow *window) | 393 | task_window_get_screen (TaskWindow *window) |
4895 | 375 | { | 394 | { |
4896 | 376 | g_return_val_if_fail (TASK_IS_WINDOW (window), wnck_screen_get_default ()); | 395 | g_return_val_if_fail (TASK_IS_WINDOW (window), wnck_screen_get_default ()); |
4897 | 377 | 396 | ||
4898 | @@ -382,7 +401,7 @@ | |||
4899 | 382 | } | 401 | } |
4900 | 383 | 402 | ||
4901 | 384 | gulong | 403 | gulong |
4903 | 385 | task_window_get_xid (TaskWindow *window) | 404 | task_window_get_xid (TaskWindow *window) |
4904 | 386 | { | 405 | { |
4905 | 387 | g_return_val_if_fail (TASK_IS_WINDOW (window), 0); | 406 | g_return_val_if_fail (TASK_IS_WINDOW (window), 0); |
4906 | 388 | 407 | ||
4907 | @@ -393,29 +412,29 @@ | |||
4908 | 393 | } | 412 | } |
4909 | 394 | 413 | ||
4910 | 395 | gint | 414 | gint |
4912 | 396 | task_window_get_pid (TaskWindow *window) | 415 | task_window_get_pid (TaskWindow *window) |
4913 | 397 | { | 416 | { |
4922 | 398 | TaskWindowClass *klass; | 417 | g_return_val_if_fail (TASK_IS_WINDOW (window), -1); |
4923 | 399 | 418 | ||
4924 | 400 | g_return_val_if_fail (TASK_IS_WINDOW (window), -1); | 419 | gint pid = -1; |
4925 | 401 | 420 | if (WNCK_IS_WINDOW (window->priv->window)) | |
4926 | 402 | klass = TASK_WINDOW_GET_CLASS (window); | 421 | { |
4927 | 403 | g_return_val_if_fail (klass->get_pid, -1); | 422 | pid = wnck_window_get_pid (window->priv->window); |
4928 | 404 | 423 | pid = pid ? pid : -1; /* if the pid is 0 return -1. Bad wnck! Bad! */ | |
4929 | 405 | return klass->get_pid (window); | 424 | } |
4930 | 425 | |||
4931 | 426 | return pid; | ||
4932 | 406 | } | 427 | } |
4933 | 407 | 428 | ||
4934 | 408 | WnckApplication * | 429 | WnckApplication * |
4936 | 409 | task_window_get_application (TaskWindow *window) | 430 | task_window_get_application (TaskWindow *window) |
4937 | 410 | { | 431 | { |
4946 | 411 | TaskWindowClass *klass; | 432 | g_return_val_if_fail (TASK_IS_WINDOW (window), NULL); |
4947 | 412 | 433 | ||
4948 | 413 | g_return_val_if_fail (TASK_IS_WINDOW (window), NULL); | 434 | if (WNCK_IS_WINDOW (window->priv->window)) |
4949 | 414 | 435 | return wnck_window_get_application (window->priv->window); | |
4950 | 415 | klass = TASK_WINDOW_GET_CLASS (window); | 436 | |
4951 | 416 | g_return_val_if_fail (klass->get_application, NULL); | 437 | return NULL; |
4944 | 417 | |||
4945 | 418 | return klass->get_application (window); | ||
4952 | 419 | } | 438 | } |
4953 | 420 | 439 | ||
4954 | 421 | 440 | ||
4955 | @@ -424,7 +443,7 @@ | |||
4956 | 424 | gchar **res_name, | 443 | gchar **res_name, |
4957 | 425 | gchar **class_name) | 444 | gchar **class_name) |
4958 | 426 | { | 445 | { |
4960 | 427 | g_return_val_if_fail (TASK_IS_WINDOW (window), -1); | 446 | g_return_val_if_fail (TASK_IS_WINDOW (window), FALSE); |
4961 | 428 | 447 | ||
4962 | 429 | *res_name = NULL; | 448 | *res_name = NULL; |
4963 | 430 | *class_name = NULL; | 449 | *class_name = NULL; |
4964 | @@ -441,51 +460,6 @@ | |||
4965 | 441 | return FALSE; | 460 | return FALSE; |
4966 | 442 | } | 461 | } |
4967 | 443 | 462 | ||
4968 | 444 | const gchar * | ||
4969 | 445 | task_window_get_name (TaskWindow *window) | ||
4970 | 446 | { | ||
4971 | 447 | TaskWindowClass *klass; | ||
4972 | 448 | |||
4973 | 449 | g_return_val_if_fail (TASK_IS_WINDOW (window), NULL); | ||
4974 | 450 | |||
4975 | 451 | klass = TASK_WINDOW_GET_CLASS (window); | ||
4976 | 452 | g_return_val_if_fail (klass->get_name, NULL); | ||
4977 | 453 | |||
4978 | 454 | return klass->get_name (window); | ||
4979 | 455 | } | ||
4980 | 456 | |||
4981 | 457 | void | ||
4982 | 458 | task_window_set_name (TaskWindow *window, | ||
4983 | 459 | const gchar *name) | ||
4984 | 460 | { | ||
4985 | 461 | g_return_if_fail (TASK_IS_WINDOW (window)); | ||
4986 | 462 | |||
4987 | 463 | g_signal_emit (window, _window_signals[NAME_CHANGED], 0, name); | ||
4988 | 464 | } | ||
4989 | 465 | |||
4990 | 466 | GdkPixbuf * | ||
4991 | 467 | task_window_get_icon (TaskWindow *window) | ||
4992 | 468 | { | ||
4993 | 469 | TaskWindowClass *klass; | ||
4994 | 470 | |||
4995 | 471 | g_return_val_if_fail (TASK_IS_WINDOW (window), NULL); | ||
4996 | 472 | |||
4997 | 473 | klass = TASK_WINDOW_GET_CLASS (window); | ||
4998 | 474 | g_return_val_if_fail (klass->get_icon, NULL); | ||
4999 | 475 | |||
5000 | 476 | return klass->get_icon (window); |
=== modified file 'applets/ taskmanager/ Makefile. am' taskmanager/ Makefile. am 2009-05-19 01:06:12 +0000 taskmanager/ Makefile. am 2009-06-26 11:00:10 +0000
task-drag- indicator. h \
task-launcher. c \
task-launcher. h \
task-manager. c \
task-manager. h \ api-wrapper. c \ api-wrapper. h \
task-settings. c \
task-settings. h \
$(builddir) /taskmanager- marshal. c \
$(builddir) /taskmanager- marshal. h \
--- applets/
+++ applets/
@@ -17,14 +17,18 @@
task-icon.c \
task-icon.h \
+ task-item.c \
+ task-item.h \
+ task-window.c \
+ task-window.h \
+ task-manager-
+ task-manager-
- task-window.c \
- task-window.h \
xutils.c \
====
Why did task-window.* move?
=== modified file 'applets/ taskmanager/ task-drag- indicator. c' taskmanager/ task-drag- indicator. c 2009-06-19 09:35:43 +0000 taskmanager/ task-drag- indicator. c 2009-06-20 14:17:54 +0000 www.gnu. org/licenses/>.
--- applets/
+++ applets/
@@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://
*
- * Authored by Neil Jagdish Patel <email address hidden>
+ * Authored by Hannes Verschore <email address hidden>
*
*/
====
Any particular reason why you removed Neil as author here (and applets/ taskmanager/ task-drag- indicator. h)?
In general, you should make sure that all of the code that you commented out (instead of deleted) should be annotated with the reason why you're commenting it.