36
33
#include <gio/gdesktopappinfo.h>
38
#define TYPE_GS_LIST gs_list_get_type()
40
static gpointer gs_list_copy (gpointer boxed)
42
return g_memdup (boxed, sizeof (GSList));
45
GType gs_list_get_type (void)
47
static GType type = 0;
50
type = g_boxed_type_register_static ("GSList",
51
gs_list_copy, g_free);
65
PROP_DESKTOP_FILE_PATH,
82
static guint application_signals[LAST_SIGNAL] = { 0 };
84
G_DEFINE_TYPE (LauncherApplication, launcher_application, G_TYPE_OBJECT);
85
#define LAUNCHER_APPLICATION_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE(obj, \
86
LAUNCHER_TYPE_APPLICATION, LauncherApplicationPrivate))
88
struct _LauncherApplicationWindow
94
struct _LauncherApplicationPrivate
35
struct _LauncherApplication
39
WnckApplication *wnckapp;
100
gchar *desktop_file_path;
101
gchar *unique_string;
113
on_application_closed (WnckScreen *screen,
114
WnckApplication *app,
115
LauncherApplication *application);
118
launcher_application_init (LauncherApplication *object)
120
LauncherApplicationPrivate *priv;
122
priv = object->priv = LAUNCHER_APPLICATION_GET_PRIVATE (object);
123
priv->running = FALSE;
124
priv->favorite = FALSE;
126
priv->screen = wnck_screen_get_default ();
127
g_signal_connect (priv->screen, "application-closed",
128
G_CALLBACK (on_application_closed), object);
130
priv->windows = g_hash_table_new (g_direct_hash, g_direct_equal);
134
launcher_application_finalize (GObject *object)
136
LauncherApplication *app = LAUNCHER_APPLICATION (object);
137
LauncherApplicationPrivate *priv;
139
priv = LAUNCHER_APPLICATION_GET_PRIVATE (app);
140
g_hash_table_destroy (priv->windows);
142
G_OBJECT_CLASS (launcher_application_parent_class)->finalize (object);
147
launcher_application_set_property (GObject *object,
152
LauncherApplication *application = LAUNCHER_APPLICATION(object);
153
g_return_if_fail (LAUNCHER_IS_APPLICATION (application));
159
if (application->priv->name)
160
g_free(application->priv->name);
161
application->priv->name = g_value_dup_string(value);
164
if (application->priv->exec)
165
g_free(application->priv->exec);
166
application->priv->exec = g_value_dup_string(value);
169
if (application->priv->icon_name)
170
g_free(application->priv->icon_name);
171
application->priv->icon_name = g_value_dup_string(value);
174
if (application->priv->comment)
175
g_free(application->priv->comment);
176
application->priv->comment = g_value_dup_string(value);
178
case PROP_DESKTOP_FILE_PATH:
179
launcher_application_set_desktop_file(application,
180
g_value_dup_string(value));
182
case PROP_UNIQUE_STRING:
184
case PROP_CATEGORIES:
185
application->priv->categories = g_value_get_boxed(value);
188
application->priv->running = g_value_get_boolean(value);
191
application->priv->favorite = g_value_get_boolean(value);
193
case PROP_WNCKAPPLICATIONS:
194
application->priv->wnck_apps = g_value_get_boxed(value);
197
application->priv->focused = g_value_get_boolean (value);
200
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
206
launcher_application_get_property (GObject *object,
211
LauncherApplication *application = LAUNCHER_APPLICATION(object);
212
LauncherApplicationPrivate *priv = application->priv;
214
g_return_if_fail (LAUNCHER_IS_APPLICATION (application));
219
g_value_set_string(value, priv->name);
222
g_value_set_string(value, priv->exec);
225
g_value_set_string(value, priv->icon_name);
228
g_value_set_string(value, priv->comment);
230
case PROP_DESKTOP_FILE_PATH:
231
g_value_set_string(value, priv->desktop_file_path);
233
case PROP_UNIQUE_STRING:
236
str = launcher_application_get_unique_string(application);
237
g_value_set_string(value, str);
240
case PROP_CATEGORIES:
241
g_value_set_boxed(value, &priv->categories);
244
g_value_set_boolean(value, priv->running);
247
g_value_set_boolean(value, priv->favorite);
249
case PROP_WNCKAPPLICATIONS:
250
g_value_set_object(value, priv->wnck_apps);
254
gboolean focused = FALSE;
255
focused = launcher_application_get_focused (application);
256
g_value_set_boolean (value, priv->focused);
260
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
266
launcher_application_opened (LauncherApplication *self,
267
WnckApplication *wnckapp)
269
/* TODO: Add default signal handler implementation here */
273
launcher_application_closed (LauncherApplication *self,
274
WnckApplication *wnckapp)
276
/* TODO: Add default signal handler implementation here */
280
launcher_application_class_init (LauncherApplicationClass *klass)
282
GObjectClass* object_class = G_OBJECT_CLASS (klass);
284
g_type_class_add_private (object_class, sizeof (LauncherApplicationPrivate));
286
object_class->finalize = launcher_application_finalize;
287
object_class->set_property = launcher_application_set_property;
288
object_class->get_property = launcher_application_get_property;
290
klass->opened = launcher_application_opened;
291
klass->closed = launcher_application_closed;
293
g_object_class_install_property (object_class,
295
g_param_spec_string ("name",
297
"name of the application",
301
g_object_class_install_property (object_class,
303
g_param_spec_string ("exec",
305
"the exec thats called in order to launch the application",
309
g_object_class_install_property (object_class,
311
g_param_spec_string ("icon-name",
313
"the standard \"icon-name\" for this application",
317
g_object_class_install_property (object_class,
319
g_param_spec_string ("comment",
321
"a general comment about the application, usually helpful information",
325
g_object_class_install_property (object_class,
326
PROP_DESKTOP_FILE_PATH,
327
g_param_spec_string ("desktop_file_path",
329
"the path to the desktop file accociated with this application",
331
G_PARAM_READABLE|G_PARAM_WRITABLE));
333
g_object_class_install_property (object_class,
335
g_param_spec_string ("unique_string",
337
"A Unique string to identify this application",
340
g_object_class_install_property (object_class,
342
g_param_spec_boxed ("categories",
344
"a list of LauncherCategories that this application is listed inside",
348
g_object_class_install_property (object_class,
350
g_param_spec_boolean ("running",
352
"Returns TRUE if the application is running",
354
G_PARAM_READABLE|G_PARAM_WRITABLE));
356
g_object_class_install_property (object_class,
358
g_param_spec_boolean ("focused",
360
"returns TRUE if the application contains a focused window",
362
G_PARAM_READABLE|G_PARAM_WRITABLE));
364
g_object_class_install_property (object_class,
366
g_param_spec_boolean ("favorite",
368
"returns TRUE if the application is listed as a favorite application",
372
g_object_class_install_property (object_class,
373
PROP_WNCKAPPLICATIONS,
374
g_param_spec_boxed ("wnckapps",
376
"a list of WnckApplication objects that this Application current has",
380
application_signals[OPENED] =
381
g_signal_new ("opened",
382
G_OBJECT_CLASS_TYPE (klass),
384
G_STRUCT_OFFSET (LauncherApplicationClass, opened),
386
g_cclosure_marshal_VOID__POINTER,
387
G_TYPE_NONE, 1, G_TYPE_POINTER
390
application_signals[CLOSED] =
391
g_signal_new ("closed",
392
G_OBJECT_CLASS_TYPE (klass),
394
G_STRUCT_OFFSET (LauncherApplicationClass, closed),
396
g_cclosure_marshal_VOID__POINTER,
397
G_TYPE_NONE, 1, WNCK_TYPE_APPLICATION
50
launcher_application_get_type (void)
52
static GType _launcher_application_type = 0;
54
if (G_UNLIKELY (_launcher_application_type == 0))
56
_launcher_application_type =
57
g_boxed_type_register_static ("LauncherApplication",
58
(GBoxedCopyFunc) launcher_application_copy,
59
(GBoxedFreeFunc) launcher_application_free);
63
return _launcher_application_type;
407
on_application_closed (WnckScreen *screen,
408
WnckApplication *app,
409
LauncherApplication *application)
414
WnckApplication *found_app = NULL;
415
/* when *any* application closes we do a quick check to see if its this one
416
* thus we need to make this check as quick and easy as possible
418
g_return_if_fail (LAUNCHER_IS_APPLICATION (application));
419
g_return_if_fail (WNCK_IS_APPLICATION (app));
421
/* we need to go though and check each wnckapp in this launcherapplication
422
* to see if the pid's match
424
wnck_pid = wnck_application_get_pid (app);
425
for (a = application->priv->wnck_apps; a; a = a->next)
427
WnckApplication *store_app = a->data;
428
app_pid = wnck_application_get_pid (store_app);
429
if (wnck_pid == app_pid)
431
found_app = store_app;
439
// we get here then we have the wnckapplication in our store
440
application->priv->wnck_apps = g_slist_remove(application->priv->wnck_apps,
442
g_object_unref (found_app);
444
// do we have any apps in our store? if so, we are running!
445
if (application->priv->wnck_apps != NULL)
447
g_object_set (G_OBJECT (application),
452
g_object_set (G_OBJECT (application),
457
g_object_set (G_OBJECT (application),
461
// we are closing apprently, lets emit a signal about that :-)
462
g_signal_emit (application, application_signals[CLOSED], 0, app);
70
* launcher_application_new_from_info:
71
* @name: string containing application name
72
* @comment: string containing application comment
73
* @icon_name: string containing icon_name for application
74
* @exec_path: string containing the path to the executable
75
* @desktop_file: string containing the path to the desktop file for this application
77
* Creates a new #LauncherApplication object with the given information
79
* Returns: a new #LauncherApplication
472
81
LauncherApplication *
473
launcher_application_new (void)
82
launcher_application_new_from_info (const gchar *name,
84
const gchar *icon_name,
85
const gchar *exec_path,
86
const gchar *desktop_file)
475
88
LauncherApplication *application;
477
application = g_object_new (LAUNCHER_TYPE_APPLICATION,
90
application = g_slice_new0 (LauncherApplication);
92
if (application != NULL)
94
application->ref_count = 1;
96
application->name = g_strdup (name);
97
application->comment = g_strdup (comment);
98
application->icon_name = g_strdup (icon_name);
99
application->exec_path = g_strdup (exec_path);
100
application->desktop_file = g_strdup (desktop_file);
480
104
return application;
484
* launcher_application_new_from_wnck_app:
108
* launcher_application_new_from-wnck_app:
485
109
* @app: A #WnckApplication object
487
111
* creates a new #LauncherApplication object based on information from @app
492
116
LauncherApplication *application;
494
application = g_object_new (LAUNCHER_TYPE_APPLICATION,
497
launcher_application_add_wnckapp (application, app);
502
* launcher_application_new_from_destkop_file
503
* @desktop_file: the file path to the desktop file used to build the application
505
* This will create a new #LauncherApplication object using the information
506
* contained within the given desktop file at @desktop_file
508
* Returns: (transfer full) A new #LauncherApplication object
510
LauncherApplication *
511
launcher_application_new_from_desktop_file (const gchar *desktop_file)
513
LauncherApplication *application;
514
/* we can now make our application */
515
application = g_object_new (LAUNCHER_TYPE_APPLICATION,
516
"desktop_file_path", desktop_file,
528
* launcher_application_launch
529
* @application: a #LauncherApplication object
530
* @error: a #GError error
532
* This method will attempt to launch the application using the exec string
535
* Returns: A truth value dictating whether the launching was successful
538
launcher_application_launch (LauncherApplication *application, GError **error)
118
application = g_slice_new0 (LauncherApplication);
120
if (application != NULL)
122
application->ref_count = 1;
124
application->wnckapp = app;
125
application->name = g_strdup (wnck_application_get_name (app));
126
application->icon_name = g_strdup (wnck_application_get_icon_name (app));
133
* launcher_application_copy:
134
* @app: A #LauncherApplication
136
* makes a copy of @app
138
* Returns: A new #LauncherApplication copy of @app
140
LauncherApplication *
141
launcher_application_copy (const LauncherApplication *application)
143
if (G_LIKELY (application != NULL))
145
LauncherApplication *ret = NULL;
147
ret = g_slice_new0 (LauncherApplication);
148
/*FIXME: Update for real copy */
155
* launcher_application_free:
156
* @app: a #LauncherApplication
158
* free's @app and its information
161
launcher_application_free (LauncherApplication *application)
163
if (G_LIKELY (application != NULL))
165
g_free (application->name);
166
g_free (application->match_name);
167
g_free (application->comment);
168
g_free (application->icon_name);
169
g_free (application->exec_path);
170
g_free (application->desktop_file);
172
g_slice_free (LauncherApplication, application);
178
* launcher_application_ref:
179
* @app: a #LauncherApplication
181
* increases the reference count of @app
183
* Returns: the same @app or NULL
185
LauncherApplication *
186
launcher_application_ref (LauncherApplication *application)
188
g_return_val_if_fail (application, NULL);
189
g_return_val_if_fail (application->ref_count > 0, NULL);
191
g_atomic_int_inc (&application->ref_count);
197
* launcher_application_unref:
198
* @app: A #LauncherApplication
200
* unreferences the #LauncherApplication, reducing its reference count
203
launcher_application_unref (LauncherApplication *application)
205
g_return_if_fail (application);
206
g_return_if_fail (application->ref_count > 0);
208
if (G_UNLIKELY (g_atomic_int_dec_and_test (&application->ref_count)))
210
launcher_application_free (application);
215
* launcher_application_set_wnckapp:
216
* @app: a #LauncherApplication
217
* @wnckapp: a #WnckApplication object
219
* Sets this #LauncherApplication to use the given #WnckApplication
222
launcher_application_set_wnckapp (LauncherApplication *application,
223
WnckApplication *wnckapp)
225
g_return_if_fail (application);
226
application->wnckapp = wnckapp;
230
* launcher_application_get_wnckapp:
231
* @app: a #LauncherApplication
233
* Provides the #WnckApplication used for this #LauncherApplication object
235
* Returns: a #WnckApplication or NULL
238
launcher_application_get_wnckapp (LauncherApplication *application)
240
g_return_val_if_fail (application, NULL);
241
return application->wnckapp;
245
* launcher_application_get_name:
246
* @app: a #LauncherApplication object
248
* Retrives the name of the application @app
250
* Returns: a string containing the name
253
launcher_application_get_name (LauncherApplication *application)
255
g_return_val_if_fail (application, NULL);
256
return application->name;
260
* launcher_application_get_comment:
261
* @app: A #LauncherApplication object
263
* Retrives the comment assigned to the given @app object
265
* Returns: A string containing the comment
268
launcher_application_get_comment (LauncherApplication *application)
270
g_return_val_if_fail (application, NULL);
271
return application->comment;
275
launcher_application_get_icon_name (LauncherApplication *application)
277
g_return_val_if_fail (application, NULL);
278
return application->icon_name;
282
launcher_application_get_exec_string (LauncherApplication *application)
284
g_return_val_if_fail (application, NULL);
285
return application->exec_path;
289
launcher_application_get_desktop_file (LauncherApplication *application)
291
g_return_val_if_fail (application, NULL);
292
return application->desktop_file;
296
launcher_application_get_match_name (LauncherApplication *application)
298
g_return_val_if_fail (application, NULL);
300
if (!application->match_name)
301
application->match_name = g_utf8_strdown (application->name, -1);
303
return application->match_name;
307
* launcher_application_launch:
308
* @app: A #LauncherApplication object
309
* @err: A pointer to a GError object
311
* Launches the application contained within @app, will raise an error if there is a problem
314
launcher_application_launch (LauncherApplication *app, GError **error)
540
316
GDesktopAppInfo *info;
542
gchar *desktop_file_path;
543
317
GdkAppLaunchContext *context;
545
g_return_val_if_fail (application, FALSE);
546
g_return_val_if_fail (*error == NULL, FALSE);
548
g_object_get(application, "desktop_file_path", &desktop_file_path, NULL);
319
g_return_if_fail (app);
320
g_return_if_fail (*error == NULL);
550
info = g_desktop_app_info_new_from_filename (desktop_file_path);
322
info = g_desktop_app_info_new_from_filename (app->desktop_file);
556
328
quark = g_quark_from_static_string ("launcher_application_launch_error");
558
330
*error = g_error_new (quark, 1, "Unable to load GDesktopAppInfo for %s",
563
335
context = gdk_app_launch_context_new ();
564
336
gdk_app_launch_context_set_screen (context, gdk_screen_get_default ());
565
337
gdk_app_launch_context_set_timestamp (context, GDK_CURRENT_TIME);
567
g_object_get(application, "icon-name", &icon_name, NULL);
568
gdk_app_launch_context_set_icon_name (context, icon_name);
338
gdk_app_launch_context_set_icon_name (context, app->icon_name);
570
340
g_app_info_launch ((GAppInfo *)info, NULL, (GAppLaunchContext*)context,
573
343
g_object_unref (context);
574
344
g_object_unref (info);
580
* launcher_application_get_unique_string
581
* @app: a #LauncherApplication
583
* Provides a unique string that can be used to identify this application
585
* Returns: a unique string
588
launcher_application_get_unique_string (LauncherApplication *application)
590
g_return_val_if_fail (application, NULL);
591
if (!application->priv->unique_string)
592
application->priv->unique_string = g_utf8_strdown (application->priv->name,
595
return application->priv->unique_string;
599
* launcher_application_get_wnckapp:
600
* @app: a #LauncherApplication
602
* Provides a list of #WnckApplications associated with this @app
604
* Returns: (transfer none): a #GSList containing #WnckApplications
607
launcher_application_get_wnckapps (LauncherApplication *application)
609
g_return_val_if_fail (application, NULL);
611
return application->priv->wnck_apps;
615
* launcher_application_add_wnckapp
616
* @application: a #LauncherApplication object
617
* @wnck_app: a #WnckApplication object
619
* This method will add @wnck_app to @application and associate it with
620
* the various signals @application has.
623
launcher_application_add_wnckapp (LauncherApplication *application,
624
WnckApplication *wnck_app)
628
g_return_if_fail (application);
629
g_return_if_fail (wnck_app);
631
/* first i guess we need to check to make sure that
632
* this WnckApplication does not already exist in the list
633
* of wnckapplications
635
pid = wnck_application_get_pid (wnck_app);
636
for (a = application->priv->wnck_apps; a; a = a->next)
638
WnckApplication *app = a->data;
639
if (wnck_application_get_pid (app) == pid)
643
application->priv->wnck_apps = g_slist_append(application->priv->wnck_apps,
645
g_object_ref(wnck_app);
647
// we emit the opened signal here
648
g_signal_emit (application, application_signals[OPENED], 0, wnck_app);
650
g_object_set (G_OBJECT (application),
657
* launcher_application_get_name:
658
* @application: a #LauncherApplication object
660
* Retrives the name of the application @application
662
* Returns: a string containing the name
665
launcher_application_get_name (LauncherApplication *application)
667
g_return_val_if_fail (application, NULL);
669
return application->priv->name;
673
* launcher_application_get_comment:
674
* @application: A #LauncherApplication object
676
* Retrives the comment assigned to the given @application object
678
* Returns: A string containing the comment
681
launcher_application_get_comment (LauncherApplication *application)
683
g_return_val_if_fail (application, NULL);
685
return application->priv->comment;
689
* launcher_application_get_icon_name
690
* @application: A #LauncherApplication object
692
* provides an icon-name associated with the application
694
* Returns: an icon-name string
697
launcher_application_get_icon_name (LauncherApplication *application)
699
g_return_val_if_fail (application, NULL);
701
return application->priv->icon_name;
705
* launcher_application_get_exec_string
706
* @application: A #LauncherApplication
708
* provides the executionable string for the application
710
* Returns: a string representing the excutionable string
713
launcher_application_get_exec_string (LauncherApplication *application)
715
g_return_val_if_fail (application, NULL);
717
return application->priv->exec;
721
* launcher_application_get_desktop_file
722
* @application: A #LauncherApplication
724
* provides the desktop file path for the application
726
* Returns: a string that contains the path to the desktop file for this application
729
launcher_application_get_desktop_file (LauncherApplication *application)
731
g_return_val_if_fail (application, NULL);
733
return application->priv->desktop_file_path;
737
* launcher_application_set_desktop_file_path
738
* @application: A #LauncherApplication
739
* @desktop_file: A string describing the path to a desktop file
741
* sets the desktop file for this application and will also regenerate its
746
launcher_application_set_desktop_file (LauncherApplication *application,
749
GKeyFile *desktop_keyfile;
750
GError *error = NULL;
753
gchar *comment = NULL;
754
gchar *icon_name = NULL;
756
g_return_if_fail (application);
757
g_return_if_fail (desktop_file);
759
desktop_keyfile = g_key_file_new ();
760
g_key_file_load_from_file (desktop_keyfile, desktop_file, 0, &error);
764
g_warning ("launcher-application.c: Unable to read from desktop file %s: %s",
767
g_error_free (error);
771
name = g_key_file_get_locale_string (desktop_keyfile,
772
G_KEY_FILE_DESKTOP_GROUP,
773
G_KEY_FILE_DESKTOP_KEY_NAME,
778
g_warning ("Unable to read from desktop file %s: %s",
781
g_error_free (error);
786
icon_name = g_key_file_get_string (desktop_keyfile,
787
G_KEY_FILE_DESKTOP_GROUP,
788
G_KEY_FILE_DESKTOP_KEY_ICON,
791
exec = g_key_file_get_string (desktop_keyfile,
792
G_KEY_FILE_DESKTOP_GROUP,
793
G_KEY_FILE_DESKTOP_KEY_EXEC,
796
comment = g_key_file_get_locale_string (desktop_keyfile,
797
G_KEY_FILE_DESKTOP_GROUP,
798
G_KEY_FILE_DESKTOP_KEY_COMMENT,
804
g_warning ("Unable to read comment from desktop file %s: %s",
807
g_error_free (error);
811
application->priv->name = name;
812
application->priv->icon_name = icon_name;
813
application->priv->exec = exec;
814
application->priv->comment = comment;
815
application->priv->desktop_file_path = desktop_file;
822
* launcher_application_get_running
823
* @application: A #LauncherApplication
825
* Method to tell if the @application is currently running or not
827
* Returns: A Truth value
830
launcher_application_get_running (LauncherApplication *application)
832
g_return_val_if_fail (application, FALSE);
834
return application->priv->running;
838
* launcher_application_get_running
839
* @application: A #LauncherApplication
841
* Method to tell if the @application is a favorite or not
843
* Returns: A Truth value
846
launcher_application_get_favorite (LauncherApplication *application)
848
g_return_val_if_fail (application, FALSE);
850
return application->priv->favorite;
854
* launcher_application_get_categories
855
* @application: A #LauncherApplication
857
* provides the categories that @application is associated with
859
* Returns: (transfer none): A GSList * of categories
862
launcher_application_get_categories (LauncherApplication *application)
864
g_return_val_if_fail(application, NULL);
866
return application->priv->categories;
870
* launcher_application_get_focused
871
* @application: A #LauncherApplication
873
* provides a method that will return true if any of this @applicaiton's windows
874
* are currently "focused"
876
* Returns: a gboolean value
879
launcher_application_get_focused (LauncherApplication *application)
881
g_return_val_if_fail (application, FALSE);
883
return application->priv->focused;
887
* launcher_application_set_focused
888
* @application: A #LauncherApplication
889
* @window: A #WnckWindow
891
* provides a mechanism to set @application as focused by providing it the
892
* focused @window (or null), this does not focus said @window - passing null
893
* will not use the window tracking feature
897
launcher_application_set_focused (LauncherApplication *application,
900
g_return_if_fail (application);
901
LauncherApplicationWindow *founditem;
904
g_get_current_time (&timeval);
908
g_object_set (G_OBJECT (application),
914
founditem = g_hash_table_lookup (application->priv->windows,
919
founditem->timestamp.tv_sec = timeval.tv_sec;
920
founditem->timestamp.tv_usec = timeval.tv_usec;
924
founditem = g_slice_new (LauncherApplicationWindow);
925
founditem->window = window;
926
founditem->timestamp.tv_sec = timeval.tv_sec;
927
founditem->timestamp.tv_usec = timeval.tv_usec;
928
g_hash_table_insert (application->priv->windows, window, founditem);
931
g_object_set (G_OBJECT (application),
937
get_latest_window(LauncherApplication *app)
939
// attempts to find the last focused wnckwindow
940
WnckWindow *founditem = NULL;
945
best_time.tv_sec = 0;
946
best_time.tv_usec = 0;
948
g_hash_table_iter_init (&iter, app->priv->windows);
949
while (g_hash_table_iter_next (&iter, &key, &value))
951
LauncherApplicationWindow *appwin = (LauncherApplicationWindow *)value;
952
if (WNCK_IS_WINDOW (appwin->window))
954
WnckWindowType type = wnck_window_get_window_type (appwin->window);
956
if (type == WNCK_WINDOW_DESKTOP ||
957
type == WNCK_WINDOW_DOCK ||
958
type == WNCK_WINDOW_TOOLBAR ||
959
type == WNCK_WINDOW_MENU ||
960
type == WNCK_WINDOW_SPLASHSCREEN)
964
if (appwin->timestamp.tv_sec > best_time.tv_sec)
966
if (appwin->timestamp.tv_usec > best_time.tv_usec)
968
best_time.tv_sec = appwin->timestamp.tv_sec;
969
best_time.tv_usec = appwin->timestamp.tv_usec;
970
founditem = appwin->window;
976
// our window no longer exists, remove it from the table
977
g_hash_table_remove (app->priv->windows, key);
986
* launcher_application_show
987
* @application: a #LauncherApplication
989
* this method will focus the latest un-minimized window this @application has
990
* all this @application's windows are minimized then this method will
991
* unminimize them all
994
launcher_application_show (LauncherApplication *application)
996
g_return_if_fail (application);
997
g_return_if_fail (application->priv->wnck_apps);
1000
* for now i am just grabbing the first wnckwindow we find thats not
1001
* minimized, really we need to track what windows are focused so we know
1002
* the last focused window
1007
WnckWindow *found_window = NULL;
1009
// get the last focused window
1010
found_window = get_latest_window (application);
1013
/* just show this window */
1014
wnck_window_activate (found_window, gtk_get_current_event_time ());
1017
/* either there were no windows or all windows were minimized, so
1020
for (a = application->priv->wnck_apps; a; a = a->next)
1022
WnckApplication *app = a->data;
1024
for (w = wnck_application_get_windows (app); w; w = w->next)
1026
WnckWindow *window = w->data;
1027
wnck_window_activate (window, gtk_get_current_event_time ());