Commit e62a17be authored by Richard Hughes's avatar Richard Hughes
Browse files

Add a plugin that allows us to show applications installed locally

This fixes applications installed with jhbuild.
parent 248776ca
......@@ -163,6 +163,7 @@ gs_application_startup (GApplication *application)
gs_plugin_loader_set_enabled (app->plugin_loader, "desktopdb", TRUE);
gs_plugin_loader_set_enabled (app->plugin_loader, "datadir-apps", TRUE);
gs_plugin_loader_set_enabled (app->plugin_loader, "datadir-filename", TRUE);
gs_plugin_loader_set_enabled (app->plugin_loader, "datadir-filename-local", TRUE);
/* show the priority of each plugin */
gs_plugin_loader_dump_state (app->plugin_loader);
......
......@@ -29,6 +29,7 @@ plugin_LTLIBRARIES = \
libgs_plugin_appstream.la \
libgs_plugin_datadir_apps.la \
libgs_plugin_datadir_filename.la \
libgs_plugin_datadir_filename_local.la \
libgs_plugin_desktopdb.la \
libgs_plugin_dummy.la \
libgs_plugin_hardcoded-descriptions.la \
......@@ -117,4 +118,9 @@ libgs_plugin_datadir_filename_la_LIBADD = $(GS_PLUGIN_LIBS) $(GTK_LIBS)
libgs_plugin_datadir_filename_la_LDFLAGS = -module -avoid-version
libgs_plugin_datadir_filename_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(WARNINGFLAGS_C)
libgs_plugin_datadir_filename_local_la_SOURCES = gs-plugin-datadir-filename-local.c
libgs_plugin_datadir_filename_local_la_LIBADD = $(GS_PLUGIN_LIBS) $(GTK_LIBS)
libgs_plugin_datadir_filename_local_la_LDFLAGS = -module -avoid-version
libgs_plugin_datadir_filename_local_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(WARNINGFLAGS_C)
-include $(top_srcdir)/git.mk
......@@ -108,7 +108,7 @@ Overview: | <p>
Methods: | Search, AddUpdates, AddInstalled, AppInstall, AppRemove, AppUpdate
Requires: | `{package-id}`
Refines: | `nothing`
Refines: | `{package-id}`, `{package-name}`, `{package-summary}`, `{update-name}`, `{update-details}`
Refines: | `{package-id}`, `{package-name}`, `{package-summary}`, `{update-name}`, `{update-details}`, `{install-kind}`
### packagekit-refine ###
Uses the system PackageKit instance to return convert filenames to package-ids.
......@@ -157,3 +157,13 @@ Overview: | <p>
Methods: | `nothing`
Requires: | `nothing`
Refines: | `[id]->{datadir-desktop-filename}`
### datadir-filename-local ###
Sets any applications not installed with datadir or /usr as installed as these
might have been installed manually or using jhbuild.
Overview: | <p>
-------------|---
Methods: | `nothing`
Requires: | `nothing`
Refines: | `{datadir-desktop-filename}->[state]`, `{install-kind}`
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* Copyright (C) 2013 Richard Hughes <richard@hughsie.com>
*
* Licensed under the GNU General Public License Version 2
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <config.h>
#include <gs-plugin.h>
/**
* gs_plugin_get_name:
*/
const gchar *
gs_plugin_get_name (void)
{
return "datadir-filename-local";
}
/**
* gs_plugin_get_priority:
*/
gdouble
gs_plugin_get_priority (GsPlugin *plugin)
{
return 1.2f;
}
/**
* gs_plugin_refine:
*/
gboolean
gs_plugin_refine (GsPlugin *plugin,
GList *list,
GCancellable *cancellable,
GError **error)
{
const gchar *tmp;
GList *l;
GsApp *app;
for (l = list; l != NULL; l = l->next) {
app = GS_APP (l->data);
if (gs_app_get_state (app) != GS_APP_STATE_UNKNOWN)
continue;
tmp = gs_app_get_metadata_item (app, "datadir-desktop-filename");
if (tmp == NULL)
continue;
if (!g_str_has_prefix (tmp, "/usr")) {
/* FIXME: If the user tries to remove this, we don't
* have a way of removing jhbuilt packages other than
* from deleting the .desktop file */
g_debug ("Desktop file not in /usr, assuming installed");
gs_app_set_state (app, GS_APP_STATE_INSTALLED);
gs_app_set_kind (app, GS_APP_KIND_NORMAL);
gs_app_set_metadata (app, "install-kind", "local");
}
}
return TRUE;
}
......@@ -171,6 +171,7 @@ gs_plugin_packagekit_add_installed_results (GsPlugin *plugin,
gs_app_set_metadata (app,
"package-summary",
pk_package_get_summary (package));
gs_app_set_metadata (app, "install-kind", "package");
gs_app_set_version (app, pk_package_get_version (package));
switch (pk_package_get_info (package)) {
case PK_INFO_ENUM_INSTALLED:
......@@ -342,6 +343,7 @@ gs_plugin_packagekit_add_updates_results (GsPlugin *plugin,
gs_app_set_metadata (app, "package-name", split[PK_PACKAGE_ID_NAME]);
gs_app_set_metadata (app, "update-name", split[PK_PACKAGE_ID_NAME]);
gs_app_set_metadata (app, "update-details", update_text);
gs_app_set_metadata (app, "install-kind", "package");
gs_app_set_name (app, split[PK_PACKAGE_ID_NAME]);
gs_app_set_version (app, split[PK_PACKAGE_ID_VERSION]);
gs_app_set_state (app, GS_APP_STATE_UPDATABLE);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment