30
30
* You don't normally need to use this constructor yourself. The
31
31
* LauncherEntryRemoteModel will do that for you when needed.
33
LauncherEntryRemote::LauncherEntryRemote(const gchar *dbus_name, GVariant *val)
33
LauncherEntryRemote::LauncherEntryRemote(const gchar* dbus_name, GVariant* val)
36
GVariantIter *prop_iter;
38
g_return_if_fail (dbus_name != NULL);
39
g_return_if_fail (val != NULL);
41
_dbus_name = g_strdup (dbus_name);
36
GVariantIter* prop_iter;
38
g_return_if_fail(dbus_name != NULL);
39
g_return_if_fail(val != NULL);
41
_dbus_name = g_strdup(dbus_name);
44
_count = G_GINT64_CONSTANT (0);
44
_count = G_GINT64_CONSTANT(0);
48
48
_emblem_visible = FALSE;
49
49
_count_visible = FALSE;
50
50
_progress_visible = FALSE;
54
g_variant_ref_sink (val);
55
g_variant_get (val, "(sa{sv})", &app_uri, &prop_iter);
54
g_variant_ref_sink(val);
55
g_variant_get(val, "(sa{sv})", &app_uri, &prop_iter);
57
57
_app_uri = app_uri; // steal ref
61
g_variant_iter_free (prop_iter);
62
g_variant_unref (val);
61
g_variant_iter_free(prop_iter);
65
65
LauncherEntryRemote::~LauncherEntryRemote()
87
g_object_unref (_quicklist);
87
g_object_unref(_quicklist);
176
176
LauncherEntryRemote::SetDBusName(const gchar* dbus_name)
180
if (g_strcmp0 (_dbus_name, dbus_name) == 0)
180
if (g_strcmp0(_dbus_name, dbus_name) == 0)
183
183
old_name = _dbus_name;
184
_dbus_name = g_strdup (dbus_name);
184
_dbus_name = g_strdup(dbus_name);
186
186
/* Remove the quicklist since we can't know if it it'll be valid on the
187
187
* new name, and we certainly don't want the quicklist to operate on a
188
188
* different name than the rest of the launcher API */
191
dbus_name_changed.emit (this, old_name);
191
dbus_name_changed.emit(this, old_name);
196
196
LauncherEntryRemote::SetEmblem(const gchar* emblem)
198
if (g_strcmp0 (_emblem, emblem) == 0)
198
if (g_strcmp0(_emblem, emblem) == 0)
204
_emblem = g_strdup (emblem);
205
emblem_changed.emit (this);
204
_emblem = g_strdup(emblem);
205
emblem_changed.emit(this);
232
232
* To unset the quicklist pass in a NULL path or empty string.
235
LauncherEntryRemote::SetQuicklistPath(const gchar *dbus_path)
235
LauncherEntryRemote::SetQuicklistPath(const gchar* dbus_path)
237
237
/* Replace "" with NULL to simplify the logic below */
238
if (g_strcmp0 ("", dbus_path) == 0)
238
if (g_strcmp0("", dbus_path) == 0)
243
243
/* Check if existing quicklist have exact same path
244
244
* and ignore the change in that case */
248
g_object_get(_quicklist, DBUSMENU_CLIENT_PROP_DBUS_OBJECT, &ql_path, NULL);
249
if (g_strcmp0(dbus_path, ql_path) == 0)
248
g_object_get (_quicklist, DBUSMENU_CLIENT_PROP_DBUS_OBJECT, &ql_path, NULL);
249
if (g_strcmp0 (dbus_path, ql_path) == 0)
255
/* Prepare for a new quicklist */
257
g_object_unref (_quicklist);
255
/* Prepare for a new quicklist */
257
g_object_unref(_quicklist);
259
259
else if (_quicklist == NULL && dbus_path == NULL)
262
262
if (dbus_path != NULL)
263
_quicklist = dbusmenu_client_new (_dbus_name, dbus_path);
263
_quicklist = dbusmenu_client_new(_dbus_name, dbus_path);
265
265
_quicklist = NULL;
267
quicklist_changed.emit (this);
267
quicklist_changed.emit(this);
274
274
* To unset the quicklist for this entry pass in NULL as the quicklist to set.
277
LauncherEntryRemote::SetQuicklist(DbusmenuClient *quicklist)
277
LauncherEntryRemote::SetQuicklist(DbusmenuClient* quicklist)
279
279
/* Check if existing quicklist have exact same path as the new one
280
280
* and ignore the change in that case. We also assert that the quicklist
281
281
* uses the same name as the connection owning this launcher entry */
284
gchar *ql_path, *new_ql_path, *new_ql_name;
285
g_object_get (_quicklist, DBUSMENU_CLIENT_PROP_DBUS_OBJECT, &ql_path, NULL);
287
if (quicklist == NULL)
294
g_object_get (quicklist, DBUSMENU_CLIENT_PROP_DBUS_OBJECT, &new_ql_path, NULL);
295
g_object_get (quicklist, DBUSMENU_CLIENT_PROP_DBUS_NAME, &new_ql_name, NULL);
298
if (quicklist != NULL && g_strcmp0 (new_ql_name, _dbus_name) != 0)
300
g_critical ("Mismatch between quicklist- and launcher entry owner:"
301
"%s and %s respectively", new_ql_name, _dbus_name);
303
g_free (new_ql_path);
304
g_free (new_ql_name);
308
if (g_strcmp0 (new_ql_path, ql_path) == 0)
311
g_free (new_ql_path);
312
g_free (new_ql_name);
316
/* Prepare for a new quicklist */
318
g_free (new_ql_path);
319
g_free (new_ql_name);
320
g_object_unref (_quicklist);
284
gchar* ql_path, *new_ql_path, *new_ql_name;
285
g_object_get(_quicklist, DBUSMENU_CLIENT_PROP_DBUS_OBJECT, &ql_path, NULL);
287
if (quicklist == NULL)
294
g_object_get(quicklist, DBUSMENU_CLIENT_PROP_DBUS_OBJECT, &new_ql_path, NULL);
295
g_object_get(quicklist, DBUSMENU_CLIENT_PROP_DBUS_NAME, &new_ql_name, NULL);
298
if (quicklist != NULL && g_strcmp0(new_ql_name, _dbus_name) != 0)
300
g_critical("Mismatch between quicklist- and launcher entry owner:"
301
"%s and %s respectively", new_ql_name, _dbus_name);
308
if (g_strcmp0(new_ql_path, ql_path) == 0)
316
/* Prepare for a new quicklist */
320
g_object_unref(_quicklist);
322
322
else if (_quicklist == NULL && quicklist == NULL)
325
325
if (quicklist == NULL)
326
326
_quicklist = NULL;
328
_quicklist = (DbusmenuClient *) g_object_ref (quicklist);
328
_quicklist = (DbusmenuClient*) g_object_ref(quicklist);
330
quicklist_changed.emit (this);
330
quicklist_changed.emit(this);
339
339
_emblem_visible = visible;
340
emblem_visible_changed.emit (this);
340
emblem_visible_changed.emit(this);
344
344
LauncherEntryRemote::SetCountVisible(gboolean visible)
346
346
if (_count_visible == visible)
349
349
_count_visible = visible;
350
count_visible_changed.emit (this);
350
count_visible_changed.emit(this);
354
354
LauncherEntryRemote::SetProgressVisible(gboolean visible)
356
356
if (_progress_visible == visible)
359
359
_progress_visible = visible;
360
progress_visible_changed.emit (this);
360
progress_visible_changed.emit(this);
364
LauncherEntryRemote::SetUrgent (gboolean urgent)
364
LauncherEntryRemote::SetUrgent(gboolean urgent)
366
366
if (_urgent == urgent)
369
369
_urgent = urgent;
370
urgent_changed.emit (this);
370
urgent_changed.emit(this);
374
374
* Set all properties from 'other' on 'this'.
377
LauncherEntryRemote::Update(LauncherEntryRemote *other)
377
LauncherEntryRemote::Update(LauncherEntryRemote* other)
379
379
/* It's important that we update the DBus name first since it might
380
380
* unset the quicklist if it changes */
381
SetDBusName (other->DBusName ());
383
SetEmblem (other->Emblem ());
384
SetCount (other->Count ());
385
SetProgress (other->Progress ());
386
SetQuicklist (other->Quicklist());
387
SetUrgent (other->Urgent ());
389
SetEmblemVisible (other->EmblemVisible ());
390
SetCountVisible(other->CountVisible ());
381
SetDBusName(other->DBusName());
383
SetEmblem(other->Emblem());
384
SetCount(other->Count());
385
SetProgress(other->Progress());
386
SetQuicklist(other->Quicklist());
387
SetUrgent(other->Urgent());
389
SetEmblemVisible(other->EmblemVisible());
390
SetCountVisible(other->CountVisible());
391
391
SetProgressVisible(other->ProgressVisible());
396
396
* any properties to 'this'.
399
LauncherEntryRemote::Update(GVariantIter *prop_iter)
399
LauncherEntryRemote::Update(GVariantIter* prop_iter)
402
const gchar *prop_value_s;
403
GVariant *prop_value;
405
g_return_if_fail (prop_iter != NULL);
407
while (g_variant_iter_loop (prop_iter, "{sv}", &prop_key, &prop_value))
409
if (g_str_equal ("emblem", prop_key))
411
prop_value_s = g_variant_get_string (prop_value, NULL);
412
SetEmblem (prop_value_s);
414
else if (g_str_equal ("count", prop_key))
415
SetCount (g_variant_get_int64 (prop_value));
416
else if (g_str_equal ("progress", prop_key))
417
SetProgress (g_variant_get_double (prop_value));
418
else if (g_str_equal ("emblem-visible", prop_key))
419
SetEmblemVisible (g_variant_get_boolean (prop_value));
420
else if (g_str_equal ("count-visible", prop_key))
421
SetCountVisible (g_variant_get_boolean (prop_value));
422
else if (g_str_equal ("progress-visible", prop_key))
423
SetProgressVisible (g_variant_get_boolean (prop_value));
424
else if (g_str_equal ("urgent", prop_key))
425
SetUrgent (g_variant_get_boolean (prop_value));
426
else if (g_str_equal ("quicklist", prop_key))
428
/* The value is the object path of the dbusmenu */
429
prop_value_s = g_variant_get_string (prop_value, NULL);
430
SetQuicklistPath (prop_value_s);
402
const gchar* prop_value_s;
403
GVariant* prop_value;
405
g_return_if_fail(prop_iter != NULL);
407
while (g_variant_iter_loop(prop_iter, "{sv}", &prop_key, &prop_value))
409
if (g_str_equal("emblem", prop_key))
411
prop_value_s = g_variant_get_string(prop_value, NULL);
412
SetEmblem(prop_value_s);
414
else if (g_str_equal("count", prop_key))
415
SetCount(g_variant_get_int64(prop_value));
416
else if (g_str_equal("progress", prop_key))
417
SetProgress(g_variant_get_double(prop_value));
418
else if (g_str_equal("emblem-visible", prop_key))
419
SetEmblemVisible(g_variant_get_boolean(prop_value));
420
else if (g_str_equal("count-visible", prop_key))
421
SetCountVisible(g_variant_get_boolean(prop_value));
422
else if (g_str_equal("progress-visible", prop_key))
423
SetProgressVisible(g_variant_get_boolean(prop_value));
424
else if (g_str_equal("urgent", prop_key))
425
SetUrgent(g_variant_get_boolean(prop_value));
426
else if (g_str_equal("quicklist", prop_key))
428
/* The value is the object path of the dbusmenu */
429
prop_value_s = g_variant_get_string(prop_value, NULL);
430
SetQuicklistPath(prop_value_s);