rendered paste bodyheres the search api for the menu from main-menu-engine.c:
void
main_menu_engine_execute_search (MainMenuEngine * engine,
const gchar * search_string)
{
MainMenuEnginePrivate *priv = MAIN_MENU_ENGINE_GET_PRIVATE (engine);
const gchar *cmd_template;
GString *cmd;
gint pivot;
gchar **argv;
GError *error = NULL;
if (strlen (search_string) < 1)
return;
cmd_template = priv->conf->search_command;
if (!cmd_template || strlen (cmd_template) < 1) {
g_warning ("could not find search command!\n");
return;
}
pivot = strstr (cmd_template, "SEARCH_STRING") - cmd_template;
cmd = g_string_new_len (cmd_template, pivot);
g_string_append (cmd, search_string);
g_string_append (cmd,
&cmd_template [pivot + strlen ("SEARCH_STRING")]);
argv = g_strsplit (cmd->str, " ", -1);
g_string_free (cmd, TRUE);
g_spawn_async (NULL,
argv,
NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, &error);
if (error) {
g_warning ("error: [%s]\n", error->message);
g_error_free (error);
}
g_strfreev (argv);
main_menu_ui_reset_search (priv->ui);
main_menu_ui_close (priv->ui, FALSE);
}
and the vanilla code from the main-menu-ui:
static GtkWidget *
create_search_widget (MainMenuUI * ui, GtkSizeGroup * label_group)
{
MainMenuUIPrivate *priv = MAIN_MENU_UI_GET_PRIVATE (ui);
GtkWidget *hbox;
GtkWidget *search_label;
GtkWidget *search_entry;
hbox = gtk_hbox_new (FALSE, 12);
search_label = get_section_header_label (_("Search:"));
gtk_misc_set_alignment (GTK_MISC (search_label), 0.0, 0.5);
gtk_size_group_add_widget (label_group, search_label);
gtk_box_pack_start (GTK_BOX (hbox), search_label, FALSE, FALSE, 0);
search_entry = gtk_entry_new ();
gtk_box_pack_start (GTK_BOX (hbox), search_entry, TRUE, TRUE, 0);
g_signal_connect (G_OBJECT (search_entry),
"activate",
G_CALLBACK (search_entry_activate_cb), ui);
priv->search_entry = GTK_ENTRY (search_entry);
return hbox;
}
to witch I inserted this addition (after the priv->search_enty = blah):
search_button = gtk_button_new_with_label (_("Find Now"));
image = gtk_image_new_from_icon_name ("system-search",
GTK_ICON_SIZE_MENU);
gtk_button_set_image (GTK_BUTTON (search_button), image);
gtk_widget_show (search_button);
g_signal_connect (search_button, "activate",
G_CALLBACK (search_button_activate_cb),
ui);
gtk_box_pack_end (GTK_BOX (hbox), search_button, FALSE,
FALSE, 0);
and the code from the search bars cb:
static void
search_entry_activate_cb (GtkEntry * entry_widget, gpointer user_data)
{
MainMenuUIPrivate *priv = MAIN_MENU_UI_GET_PRIVATE (user_data);
main_menu_engine_execute_search (priv->engine,
gtk_entry_get_text (entry_widget));
}
Now... intitially I tried to adapt the legacy api from the old search button by redefining it in the new api... adding a redundant search function and tying the button cb to it... but because the legacy cb used
static void
emit_search_callback (GtkWidget * widget, gpointer search_bar)
{
emit_search (search_bar);
}
... for the button, (unedited example... I just redid the cb name and the pointers/widget type)... i get a warning for to few args and a dead button