~ubuntu-branches/ubuntu/wily/xfce4-appfinder/wily-proposed

« back to all changes in this revision

Viewing changes to src/xfce4-appfinder.c

  • Committer: Bazaar Package Importer
  • Author(s): Simon Huggins, Yves-Alexis Perez, Simon Huggins
  • Date: 2007-11-27 16:39:17 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20071127163917-b6no7r2t7ee1gy0h
Tags: 4.4.2-1
[ Yves-Alexis Perez ]
* New upstream release.
* debian/menu: switch to new menu policy.
* debian/rules: don't ignore all make errors at clean stage.

[ Simon Huggins ]
* debian/control: Move fake Homepage field to a real one now dpkg
  supports it.
* Add Vcs-* headers to debian/control

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
#include <libxfce4util/libxfce4util.h>
28
28
#include <libxfcegui4/libxfcegui4.h>
29
29
#include <string.h>
30
 
 
31
 
#include "inline-icon.h"
32
30
#include "xfce4-appfinder.h"
33
31
 
34
32
enum {
99
97
                                               
100
98
                                                                                              
101
99
static gint           xfce_appfinder_signals[LAST_SIGNAL] = { 0 };
102
 
static gchar        **desktop_entries_paths;
103
 
static gint           desktop_path_number = 0;
 
100
static GPtrArray *    desktop_entries_paths;
104
101
static gint           showedcat = APPFINDER_ALL;
105
102
 
106
103
/* What to search for in .desktop files */
463
460
    gint    napps;
464
461
    gchar **applnk;
465
462
    gint    napplnk;
466
 
    gint    i, n;
 
463
    gint    n;
467
464
    
468
465
    applications = xfce_resource_lookup_all (XFCE_RESOURCE_DATA, "applications/");
469
 
    for (napplications = 0; applications[napplications] != NULL; ++napplications);
470
466
    
471
467
    apps = xfce_resource_lookup_all (XFCE_RESOURCE_DATA, "apps/");
472
 
    for (napps = 0; apps[napps] != NULL; ++napps);
473
468
    
474
469
    applnk = xfce_resource_lookup_all (XFCE_RESOURCE_DATA, "applnk/");
475
 
    for (napplnk = 0; applnk[napplnk] != NULL; ++napplnk);
476
 
    
477
 
    desktop_entries_paths = g_new0 (gchar *, 2 * napplications + napps + napplnk + 6);
478
 
    i = 0;
479
 
    
480
 
    desktop_entries_paths[i++] = xfce_get_homefile (".gnome", "share", "apps", NULL);
481
 
    desktop_entries_paths[i++] = xfce_get_homefile (".kde", "share", "applnk", NULL);
 
470
    
 
471
    desktop_entries_paths = g_ptr_array_new ();
 
472
    
 
473
    g_ptr_array_add (desktop_entries_paths, (gpointer) xfce_get_homefile (".gnome", "share", "apps", NULL));
 
474
    g_ptr_array_add (desktop_entries_paths,  (gpointer) xfce_get_homefile (".kde", "share", "applnk", NULL));
482
475
    if ((kdedir = g_getenv("KDEDIR")) != NULL)
483
476
    {
484
 
        desktop_entries_paths[i++] = g_build_filename (kdedir, "share",  "applications",  "kde", NULL); 
 
477
        g_ptr_array_add (desktop_entries_paths, (gpointer) g_build_filename (kdedir, "share",  "applications",  "kde", NULL)); 
485
478
    }
486
479
 
487
480
    /* FreeBSD Gnome stuff */
488
 
    desktop_entries_paths[i++] = g_build_filename ("/usr", "X11R6", "share", "gnome", "applications", NULL);
 
481
    g_ptr_array_add (desktop_entries_paths, (gpointer) g_build_filename ("/usr", "X11R6", "share", "gnome", "applications", NULL));
489
482
 
490
483
    /* /usr/global stuff */
491
 
    desktop_entries_paths[i++] = g_build_filename ("/usr", "global", "share", "applications", NULL);
 
484
    g_ptr_array_add (desktop_entries_paths, (gpointer) g_build_filename ("/usr", "global", "share", "applications", NULL));
492
485
    
493
 
    for (n = 0; n < napplications; ++n)
 
486
    for (n = 0; applications[n] != NULL; ++n)
494
487
    {
495
 
        desktop_entries_paths[i++] = applications[n];
496
 
        desktop_entries_paths[i++] = g_build_filename (applications[n], "kde", NULL);
 
488
        g_ptr_array_add (desktop_entries_paths, (gpointer) applications[n]);
 
489
        g_ptr_array_add (desktop_entries_paths, (gpointer) g_build_filename (applications[n], "kde", NULL));
497
490
    }
498
491
    g_free (applications);
499
492
    
500
 
    for (n = 0; n < napps; ++i, ++n)
 
493
    for (n = 0; apps[n] != NULL; ++n)
501
494
    {
502
 
        desktop_entries_paths[i] = apps[n];
 
495
        g_ptr_array_add (desktop_entries_paths, (gpointer) apps[n]);
503
496
    }
504
497
    g_free (apps);
505
498
    
506
 
    for (n = 0; n < napplnk; ++i, ++n)
 
499
    for (n = 0; applnk[n] != NULL; ++n)
507
500
    {
508
 
        desktop_entries_paths[i] = applnk[n];
 
501
        g_ptr_array_add (desktop_entries_paths, (gpointer) applnk[n]);
509
502
    }
510
503
    g_free (applnk);
511
 
    
512
 
    desktop_path_number = n;
513
504
}
514
505
 
515
506
static gchar *get_path_from_name(gchar *name, XfceAppfinder *appfinder)
582
573
        {
583
574
            gtk_list_store_append(GTK_LIST_STORE(gtk_tree_view_get_model (GTK_TREE_VIEW(af->appsTree))), &iter);
584
575
            gtk_list_store_set(GTK_LIST_STORE(gtk_tree_view_get_model (GTK_TREE_VIEW(af->appsTree))),
585
 
                                &iter, APPLICATION_TREE_ICON, xfce_inline_icon_at_size (default_icon_data_48_48, 24, 24),
 
576
                                &iter, APPLICATION_TREE_ICON, xfce_themed_icon_load("xfce4-appfinder", 24),
586
577
                                APPLICATION_TREE_TEXT, _("No items available"), -1);
587
578
            gtk_widget_set_sensitive(af->appsTree, FALSE);
588
579
        }
622
613
    {
623
614
        gtk_list_store_append(GTK_LIST_STORE(gtk_tree_view_get_model (GTK_TREE_VIEW(appfinder->appsTree))), &iter);
624
615
        gtk_list_store_set(GTK_LIST_STORE(gtk_tree_view_get_model (GTK_TREE_VIEW(appfinder->appsTree))),
625
 
                            &iter, APPLICATION_TREE_ICON, xfce_inline_icon_at_size (default_icon_data_48_48, 24, 24),
 
616
                            &iter, APPLICATION_TREE_ICON, xfce_themed_icon_load("xfce4-appfinder", 24),
626
617
                            APPLICATION_TREE_TEXT, _("Sorry, no match for searched text."), -1);
627
618
        gtk_widget_set_sensitive(appfinder->appsTree, FALSE);
628
619
    }
747
738
    gchar                    *filename  = NULL;
748
739
    gchar                    *fullpath  = NULL;
749
740
    GDir                     *dir;
750
 
    gint                      n         = desktop_path_number - 1;
751
741
    gint                      i         = 0; /* A counter for general use */
752
742
    
753
743
    hash = g_hash_table_new ((GHashFunc) g_str_hash, (GEqualFunc) g_str_equal);
754
744
    
755
 
    while (desktop_entries_paths[i]!=NULL)
 
745
    while (i<desktop_entries_paths->len)
756
746
    {
757
 
        if ((dir = g_dir_open (desktop_entries_paths[i], 0, NULL))!=NULL)
 
747
        if ((dir = g_dir_open ((gchar *) g_ptr_array_index(desktop_entries_paths,i), 0, NULL))!=NULL)
758
748
        {
759
749
            while ((filename = (gchar *)g_dir_read_name(dir))!=NULL)
760
750
            {
761
 
                fullpath = g_build_filename(desktop_entries_paths[i], filename, NULL);
 
751
                fullpath = g_build_filename(g_ptr_array_index(desktop_entries_paths,i), filename, NULL);
762
752
                if (g_str_has_suffix(filename, ".desktop"))
763
753
                {
764
754
                    dentry = xfce_desktop_entry_new (fullpath, dotDesktopKeys, 7);
820
810
                }
821
811
                else if (g_file_test(fullpath, G_FILE_TEST_IS_DIR))
822
812
                {
823
 
                    desktop_entries_paths[n] = fullpath;
824
 
                    desktop_entries_paths[n] = NULL;
 
813
                    g_ptr_array_add(desktop_entries_paths, (gpointer) fullpath);
825
814
                }
826
815
            }
827
816
            g_dir_close(dir);