Commit 5fcf4144 authored by Kalev Lember's avatar Kalev Lember
Browse files

shell: Use new GsApp API to handle local files

Instead of abusing the (kind == GENERIC) test, use the new
gs_app_set/get_local_file() API. Apps without appdata, such as extra
packages that we show through the org.freedesktop.PackageKit session
service can also legitimately be of the GENERIC kind and as such we
can't use it to test if it's a local file.
parent 69f4b477
......@@ -602,11 +602,13 @@ filename_activated (GSimpleAction *action,
{
GsApplication *app = GS_APPLICATION (data);
const gchar *filename;
g_autoptr(GFile) file = NULL;
gs_application_initialize_ui (app);
g_variant_get (parameter, "(&s)", &filename);
gs_shell_show_filename (app->shell, filename);
file = g_file_new_for_path (filename);
gs_shell_show_local_file (app->shell, file);
}
static void
......
......@@ -1495,12 +1495,9 @@ gs_shell_details_file_to_app_cb (GObject *source,
}
void
gs_shell_details_set_filename (GsShellDetails *self, const gchar *filename)
gs_shell_details_set_local_file (GsShellDetails *self, GFile *file)
{
g_autoptr(GFile) file = NULL;
gs_shell_details_set_state (self, GS_SHELL_DETAILS_STATE_LOADING);
file = g_file_new_for_path (filename);
gs_plugin_loader_file_to_app_async (self->plugin_loader,
file,
GS_PLUGIN_REFINE_FLAGS_REQUIRE_ICON |
......
......@@ -39,8 +39,8 @@ G_DECLARE_FINAL_TYPE (GsShellDetails, gs_shell_details, GS, SHELL_DETAILS, GsPag
GsShellDetails *gs_shell_details_new (void);
void gs_shell_details_set_app (GsShellDetails *self,
GsApp *app);
void gs_shell_details_set_filename (GsShellDetails *self,
const gchar *filename);
void gs_shell_details_set_local_file(GsShellDetails *self,
GFile *file);
GsApp *gs_shell_details_get_app (GsShellDetails *self);
void gs_shell_details_setup (GsShellDetails *self,
GsShell *shell,
......
......@@ -340,12 +340,11 @@ gs_shell_change_mode (GsShell *shell,
break;
case GS_SHELL_MODE_DETAILS:
app = GS_APP (data);
if (gs_app_get_kind (app) != AS_APP_KIND_GENERIC ||
gs_app_get_source_default (app) == NULL) {
gs_shell_details_set_app (priv->shell_details, data);
if (gs_app_get_local_file (app) != NULL) {
gs_shell_details_set_local_file (priv->shell_details,
gs_app_get_local_file (app));
} else {
const gchar *tmp = gs_app_get_source_default (app);
gs_shell_details_set_filename (priv->shell_details, tmp);
gs_shell_details_set_app (priv->shell_details, data);
}
new_page = GS_PAGE (priv->shell_details);
break;
......@@ -1853,12 +1852,11 @@ gs_shell_show_search (GsShell *shell, const gchar *search)
}
void
gs_shell_show_filename (GsShell *shell, const gchar *filename)
gs_shell_show_local_file (GsShell *shell, GFile *file)
{
g_autoptr(GsApp) app = gs_app_new (NULL);
save_back_entry (shell);
gs_app_set_kind (app, AS_APP_KIND_GENERIC);
gs_app_add_source (app, filename);
gs_app_set_local_file (app, file);
gs_shell_change_mode (shell, GS_SHELL_MODE_DETAILS,
(gpointer) app, TRUE);
gs_shell_activate (shell);
......
......@@ -91,8 +91,8 @@ void gs_shell_show_category (GsShell *shell,
GsCategory *category);
void gs_shell_show_search (GsShell *shell,
const gchar *search);
void gs_shell_show_filename (GsShell *shell,
const gchar *filename);
void gs_shell_show_local_file (GsShell *shell,
GFile *file);
void gs_shell_show_search_result (GsShell *shell,
const gchar *id,
const gchar *search);
......
Markdown is supported
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