~3v1n0/bamf/libbamf-safer-factory-rematch

« back to all changes in this revision

Viewing changes to src/bamf-application.c

Daemon, BamfApplication: Use the default icon if there is not one defined in the desktop file.. Fixes: https://bugs.launchpad.net/bugs/886778. Approved by Marco Trevisan (Treviño).

Show diffs side-by-side

added added

removed removed

Lines of Context:
140
140
      name = g_strdup (g_app_info_get_display_name (G_APP_INFO (desktop)));
141
141
 
142
142
      if (gicon)
143
 
        icon = g_icon_to_string (gicon);
 
143
        {
 
144
          icon = g_icon_to_string (gicon);
 
145
        }
 
146
      else
 
147
        {
 
148
          icon = g_strdup ("application-default-icon");
 
149
        }
144
150
 
145
151
      if (g_key_file_has_key(keyfile, G_KEY_FILE_DESKTOP_GROUP, STUB_KEY, NULL))
146
152
        {
151
157
                                                           G_KEY_FILE_DESKTOP_GROUP,
152
158
                                                           STUB_KEY, NULL);
153
159
        }
154
 
      
 
160
 
155
161
      if (g_key_file_has_key (keyfile, G_KEY_FILE_DESKTOP_GROUP, "X-GNOME-FullName", NULL))
156
162
        {
157
163
          /* Grab the better name if its available */
158
164
          gchar *fullname = NULL;
159
 
          error = NULL; 
 
165
          error = NULL;
160
166
          fullname = g_key_file_get_locale_string (keyfile,
161
167
                                                   G_KEY_FILE_DESKTOP_GROUP,
162
168
                                                   "X-GNOME-FullName", NULL,
184
190
          view = l->data;
185
191
          if (!BAMF_IS_WINDOW (view))
186
192
            continue;
187
 
          
 
193
 
188
194
          window = BAMF_WINDOW (view);
189
 
          
 
195
 
190
196
          do
191
197
            {
192
198
              class = bamf_legacy_window_get_class_name (bamf_window_get_window (window));
208
214
 
209
215
          name = g_strdup (bamf_legacy_window_get_name (bamf_window_get_window (window)));
210
216
        }
211
 
        
 
217
 
212
218
      if (!icon)
213
219
        {
214
220
          if (window)
215
221
            {
216
222
              icon = g_strdup (bamf_legacy_window_save_mini_icon (bamf_window_get_window (window)));
217
223
            }
218
 
          
 
224
 
219
225
          if (!icon)
220
226
            {
221
227
              icon = g_strdup ("application-default-icon");
394
400
      if (!BAMF_IS_WINDOW (child))
395
401
        continue;
396
402
 
397
 
      return g_strdup_printf ("application%s", 
 
403
      return g_strdup_printf ("application%s",
398
404
                              bamf_legacy_window_get_class_name (bamf_window_get_window (BAMF_WINDOW (child))));
399
405
    }
400
 
  
 
406
 
401
407
  return g_strdup_printf ("application%p", view);
402
408
}
403
409
 
416
422
        continue;
417
423
 
418
424
      running = TRUE;
419
 
      
 
425
 
420
426
      if (BAMF_IS_INDICATOR (view))
421
427
        visible = TRUE;
422
428
 
504
510
 
505
511
  matcher = bamf_matcher_get_default ();
506
512
  favs = bamf_matcher_get_favorites (matcher);
507
 
  
 
513
 
508
514
  if (favs)
509
515
    {
510
516
      for (l = favs; l; l = l->next)
549
555
  priv->desktop_file_list = g_list_reverse (priv->desktop_file_list);
550
556
 
551
557
  desktop_file = bamf_application_favorite_from_list (self, priv->desktop_file_list);
552
 
  
 
558
 
553
559
  /* items, after reversing them, are in priority order */
554
560
  if (!desktop_file)
555
561
    desktop_file = list->data;
583
589
matcher_favorites_changed (BamfMatcher *matcher, BamfApplication *self)
584
590
{
585
591
  char *new_desktop_file = NULL;
586
 
  
 
592
 
587
593
  g_return_if_fail (BAMF_IS_APPLICATION (self));
588
594
  g_return_if_fail (BAMF_IS_MATCHER (matcher));
589
 
  
 
595
 
590
596
  new_desktop_file = bamf_application_favorite_from_list (self, self->priv->desktop_file_list);
591
597
 
592
598
  if (new_desktop_file)
670
676
      g_free (priv->desktop_file);
671
677
      priv->desktop_file = NULL;
672
678
    }
673
 
    
 
679
 
674
680
  if (priv->desktop_file_list)
675
681
    {
676
682
      g_list_free_full (priv->desktop_file_list, g_free);
748
754
  bamf_dbus_item_object_skeleton_set_application (BAMF_DBUS_ITEM_OBJECT_SKELETON (self),
749
755
                                                  priv->dbus_iface);
750
756
 
751
 
  g_signal_connect (G_OBJECT (bamf_matcher_get_default ()), "favorites-changed", 
 
757
  g_signal_connect (G_OBJECT (bamf_matcher_get_default ()), "favorites-changed",
752
758
                    (GCallback) matcher_favorites_changed, self);
753
759
}
754
760
 
800
806
{
801
807
  BamfApplication *application;
802
808
  application = (BamfApplication *) g_object_new (BAMF_TYPE_APPLICATION, NULL);
803
 
  
 
809
 
804
810
  bamf_application_set_desktop_file_from_list (application, desktop_files);
805
 
  
806
 
  return application;  
 
811
 
 
812
  return application;
807
813
}
808
814
 
809
815
BamfApplication *