7 #include <gtk/gtkmain.h>
8 #include <gtk/gtkdialog.h>
9 #include <gtk/gtkstock.h>
12 #include "launcher-item.h"
14 static std::string appdir = "/usr/share/applications";
16 int main(int argc, char *argv[]) {
17 gtk_init(&argc, &argv);
19 DIR *handle = opendir(appdir.c_str());
26 while ((entry = readdir(handle)) != 0) {
27 if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) {
31 LauncherItem *item = new LauncherItem();
33 if (item->load(appdir + "/" + entry->d_name)) {
34 std::cout << "Loaded " << entry->d_name << std::endl;
36 std::cout << "Failed to load " << entry->d_name << std::endl;
39 apps.push_back(std::pair<std::string, LauncherItem *>(entry->d_name, item));
43 SLAList sla_list(26, apps);
45 GtkDialog *dialog = GTK_DIALOG(gtk_dialog_new_with_buttons("Launcher settings", 0, (GtkDialogFlags)(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT), GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, 0));
47 gtk_container_add(GTK_CONTAINER(dialog->vbox), sla_list.getWidget());
49 if (gtk_dialog_run(dialog) == GTK_RESPONSE_ACCEPT) {
50 for (LauncherItems::const_iterator it = apps.begin(); it != apps.end(); ++it) {
51 std::cout << it->first << (it->second->isEnabled() ? " active" : " passive") << std::endl;
55 gtk_widget_destroy(GTK_WIDGET(dialog));
58 std::cerr << "Cannot list applications directory" << std::endl;