Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 42 additions & 3 deletions src/bazaar-daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -530,9 +530,48 @@ method_activate_result (sd_bus_message *m,
static int
method_launch_search (sd_bus_message *m, void *userdata, sd_bus_error *ret_error)
{
_cleanup_ (strv_freep) char **terms = NULL;
// TODO: Actually open search in app with the terms
launch_app (NULL, 0);
_cleanup_ (strv_freep) char **terms = NULL;
_cleanup_ (generic_freep) char *joined = NULL;
_cleanup_ (generic_freep) char *arg = NULL;
char *args[1] = { NULL };
uint32_t timestamp = 0;
size_t len = 0;
int n_terms = 0;
int i = 0;
int r = 0;

r = sd_bus_message_read_strv (m, &terms);
if (r < 0)
return r;

r = sd_bus_message_read (m, "u", &timestamp);
if (r < 0)
return r;

n_terms = strv_count_local (terms);
if (n_terms == 0)
{
launch_app (NULL, 0);
return sd_bus_reply_method_return (m, NULL);
}

for (i = 0; i < n_terms; i++)
len += strlen (terms[i]) + 1;

joined = malloc (len);
joined[0] = '\0';
for (i = 0; i < n_terms; i++)
{
strcat (joined, terms[i]);
if (i + 1 < n_terms)
strcat (joined, " ");
}

arg = malloc (strlen ("--search-for=") + strlen (joined) + 1);
sprintf (arg, "--search-for=%s", joined);

args[0] = arg;
launch_app (args, 1);

return sd_bus_reply_method_return (m, NULL);
}
Expand Down
15 changes: 14 additions & 1 deletion src/bz-application.c
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ bz_application_command_line (GApplication *app,
g_auto (GStrv) content_configs_strv = NULL;
g_auto (GStrv) locations = NULL;
gboolean preview_metainfo = FALSE;
g_autofree char *search_term = NULL;

GOptionEntry main_entries[] = {
{ "help", 0, 0, G_OPTION_ARG_NONE, &help, "Print help" },
Expand All @@ -475,6 +476,7 @@ bz_application_command_line (GApplication *app,
/* Here for backwards compat */
{ "extra-content-config", 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &content_configs_strv, "Add an extra yaml file with which to configure the app browser (backwards compat)" },
{ "preview-metainfo", 0, 0, G_OPTION_ARG_NONE, &preview_metainfo, "Preview a metainfo file by selecting it via file dialog" },
{ "search-for", 0, 0, G_OPTION_ARG_STRING, &search_term, "Open search with this term" },
{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &locations, "flatpakref file to open" },
{ NULL }
};
Expand Down Expand Up @@ -572,7 +574,7 @@ bz_application_command_line (GApplication *app,

if (!preview_metainfo)
{
if (locations == NULL || *locations == NULL)
if ((locations == NULL || *locations == NULL) && search_term == NULL)
new_window (self);
else
get_or_create_window (self);
Expand All @@ -594,6 +596,17 @@ bz_application_command_line (GApplication *app,
dex_future_disown (g_steal_pointer (&future));
}

if (search_term != NULL)
{
GtkWindow *window = NULL;

window = get_or_create_window (self);
if (adw_application_window_get_visible_dialog (ADW_APPLICATION_WINDOW (window)) != NULL)
window = new_window (self);

bz_window_search (BZ_WINDOW (window), search_term);
}

return EXIT_SUCCESS;
}

Expand Down
Loading