~noskcaj/ubuntu/vivid/xfce4-whiskermenu-plugin/1.4.3

« back to all changes in this revision

Viewing changes to src/favorites_page.cpp

  • Committer: Package Import Robot
  • Author(s): Yves-Alexis Perez, Jackson Doak
  • Date: 2013-11-09 00:31:47 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20131109003147-5o9092rpgh89xnj8
Tags: 1.2.0-1
[ Jackson Doak ]
* New upstream release
* Drop manpage, included upstream
* debian/docs: Install NEWS as the changelog, don't install CREDITS
* debian/control: Remove bad character from desciption

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
 
29
29
//-----------------------------------------------------------------------------
30
30
 
 
31
static bool f_remember_favorites = true;
 
32
 
31
33
static const std::string default_favorites[4] =
32
34
{
33
35
        "exo-terminal-emulator.desktop",
65
67
 
66
68
//-----------------------------------------------------------------------------
67
69
 
 
70
bool FavoritesPage::get_remember_favorites()
 
71
{
 
72
        return f_remember_favorites;
 
73
}
 
74
 
 
75
//-----------------------------------------------------------------------------
 
76
 
 
77
void FavoritesPage::set_remember_favorites(bool remember)
 
78
{
 
79
        f_remember_favorites = remember;
 
80
}
 
81
 
 
82
//-----------------------------------------------------------------------------
 
83
 
68
84
void FavoritesPage::extend_context_menu(GtkWidget* menu)
69
85
{
70
86
        GtkWidget* menuitem = gtk_separator_menu_item_new();
85
101
 
86
102
//-----------------------------------------------------------------------------
87
103
 
88
 
void FavoritesPage::sort(std::map<std::string, Launcher*>& items) const
 
104
bool FavoritesPage::remember_launcher(Launcher* launcher)
 
105
{
 
106
        return f_remember_favorites ? true : !contains(launcher);
 
107
}
 
108
 
 
109
//-----------------------------------------------------------------------------
 
110
 
 
111
void FavoritesPage::sort(std::vector<Launcher*>& items) const
89
112
{
90
113
        const std::vector<std::string>& desktop_ids = get_desktop_ids();
91
114
        for (std::vector<std::string>::const_iterator i = desktop_ids.begin(), end = desktop_ids.end(); i != end; ++i)
95
118
                {
96
119
                        continue;
97
120
                }
98
 
                gchar* collation_key = g_utf8_collate_key(launcher->get_text(), -1);
99
 
                items[collation_key] = launcher;
100
 
                g_free(collation_key);
 
121
                items.push_back(launcher);
101
122
        }
 
123
        std::sort(items.begin(), items.end(), &Element::less_than);
102
124
}
103
125
 
104
126
//-----------------------------------------------------------------------------
106
128
void FavoritesPage::sort_ascending()
107
129
{
108
130
        std::vector<std::string> desktop_ids;
109
 
        std::map<std::string, Launcher*> items;
 
131
        std::vector<Launcher*> items;
110
132
        sort(items);
111
 
        for (std::map<std::string, Launcher*>::const_iterator i = items.begin(), end = items.end(); i != end; ++i)
 
133
        for (std::vector<Launcher*>::const_iterator i = items.begin(), end = items.end(); i != end; ++i)
112
134
        {
113
 
                desktop_ids.push_back(i->second->get_desktop_id());
 
135
                desktop_ids.push_back((*i)->get_desktop_id());
114
136
        }
115
137
        set_desktop_ids(desktop_ids);
116
138
}
120
142
void FavoritesPage::sort_descending()
121
143
{
122
144
        std::vector<std::string> desktop_ids;
123
 
        std::map<std::string, Launcher*> items;
 
145
        std::vector<Launcher*> items;
124
146
        sort(items);
125
 
        for (std::map<std::string, Launcher*>::const_reverse_iterator i = items.rbegin(), end = items.rend(); i != end; ++i)
 
147
        for (std::vector<Launcher*>::const_reverse_iterator i = items.rbegin(), end = items.rend(); i != end; ++i)
126
148
        {
127
 
                desktop_ids.push_back(i->second->get_desktop_id());
 
149
                desktop_ids.push_back((*i)->get_desktop_id());
128
150
        }
129
151
        set_desktop_ids(desktop_ids);
130
152
}