Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show desktop entry descriptions in results #10

Merged
merged 3 commits into from
Jul 28, 2024
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
188 changes: 125 additions & 63 deletions src/jogg-application-window.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
#include "jogg-application.h"
#include "jogg-application-window.h"
#include "jogg-result.h"
#include "jogg-result-widget.h"

#include <gio/gdesktopappinfo.h>

struct _JoggApplicationWindow
{
GtkApplicationWindow parent_instance;

GtkSizeGroup *size_group;
GtkSingleSelection *model;
GtkFilterListModel *filter_model;
GListStore *applications;
Expand All @@ -24,6 +26,7 @@ struct _JoggApplicationWindow
GtkWidget *results_revealer;
GtkWidget *results_scrolled_window;
GtkWidget *results;
GtkWidget *list_item_factory;
};

G_DEFINE_TYPE ( JoggApplicationWindow
Expand All @@ -32,10 +35,11 @@ G_DEFINE_TYPE ( JoggApplicationWindow
);

static gboolean
jogg_application_window_transform_n_items (GBinding *binding,
const GValue *from_value,
GValue *to_value,
gpointer user_data)
jogg_application_window_transform_n_items ( GBinding *binding
, const GValue *from_value
, GValue *to_value
, gpointer user_data
)
{
guint n_items;

Expand All @@ -47,9 +51,10 @@ jogg_application_window_transform_n_items (GBinding *binding,
}

static void
jogg_application_window_results_revealer_on_notify_reveal_child (GObject *self,
GParamSpec *pspec,
gpointer user_data)
jogg_application_window_results_revealer_on_notify_reveal_child ( GObject *self
, GParamSpec *pspec
, gpointer user_data
)
{
JoggApplicationWindow *window;

Expand All @@ -62,9 +67,10 @@ jogg_application_window_results_revealer_on_notify_reveal_child (GObject *sel
}

static void
jogg_application_window_results_revealer_on_notify_child_revealed (GObject *self,
GParamSpec *pspec,
gpointer user_data)
jogg_application_window_results_revealer_on_notify_child_revealed ( GObject *self
, GParamSpec *pspec
, gpointer user_data
)
{
JoggApplicationWindow *window;

Expand Down Expand Up @@ -104,8 +110,9 @@ jogg_application_window_search_entry_on_activate ( GtkSearchEntry *self
}

static void
jogg_application_window_search_entry_on_search_changed (GtkSearchEntry *self,
gpointer user_data)
jogg_application_window_search_entry_on_search_changed ( GtkSearchEntry *self
, gpointer user_data
)
{
JoggApplicationWindow *window = NULL;
size_t n = 0;
Expand All @@ -129,9 +136,10 @@ jogg_application_window_search_entry_on_search_changed (GtkSearchEntry *self,
}

static void
jogg_application_window_revealer_on_child_revealed (GObject *self,
GParamSpec *pspec,
gpointer user_data)
jogg_application_window_revealer_on_child_revealed ( GObject *self
, GParamSpec *pspec
, gpointer user_data
)
{
(void) pspec;

Expand Down Expand Up @@ -163,15 +171,17 @@ jogg_application_window_quit (JoggApplicationWindow *self)

static void
jogg_application_window_search_entry_on_stop_search ( GtkSearchEntry *self
, gpointer user_data)
, gpointer user_data
)
{
jogg_application_window_quit (JOGG_APPLICATION_WINDOW (user_data));
}

static void
jogg_application_window_results_on_activate ( GtkListView *self
, guint position
, gpointer user_data)
, gpointer user_data
)
{
GtkSelectionModel *model = NULL;
JoggResult *item = NULL;
Expand All @@ -198,7 +208,8 @@ jogg_application_window_results_on_activate ( GtkListView *self
static gint
jogg_application_window_result_sort_func ( gconstpointer a
, gconstpointer b
, gpointer user_data)
, gpointer user_data
)
{
return jogg_result_compare (a, b);
}
Expand Down Expand Up @@ -266,6 +277,40 @@ jogg_application_window_search_entry_on_key_pressed ( GtkEventControllerKey *sel
return GDK_EVENT_STOP;
}

static void
jogg_application_window_list_item_factory_on_setup ( GtkSignalListItemFactory *
, GObject *object
, gpointer user_data
)
{
JoggApplicationWindow *self = NULL;
GtkWidget *widget = NULL;

self = user_data;
widget = jogg_result_widget_new ();

gtk_list_item_set_child (GTK_LIST_ITEM (object), widget);
gtk_list_item_set_focusable (GTK_LIST_ITEM (object), FALSE);
gtk_size_group_add_widget (self->size_group, widget);
}

static void
jogg_application_window_list_item_factory_on_bind ( GtkSignalListItemFactory *
, GObject *object
, gpointer user_data
)
{
GtkWidget *widget = NULL;
GObject *item = NULL;

widget = gtk_list_item_get_child (GTK_LIST_ITEM (object));
item = gtk_list_item_get_item (GTK_LIST_ITEM (object));

jogg_result_widget_set_result ( JOGG_RESULT_WIDGET (widget)
, JOGG_RESULT (item)
);
}

static void
jogg_application_window_init (JoggApplicationWindow *self)
{
Expand All @@ -289,13 +334,6 @@ jogg_application_window_init (JoggApplicationWindow *self)
, G_CALLBACK (jogg_application_window_search_entry_on_activate)
, self
);
#if 0
g_signal_connect ( self->search_entry
, "next-match"
, G_CALLBACK (jogg_application_window_search_entry_on_next_match)
, self
);
#endif
g_signal_connect ( self->search_entry
, "search-changed"
, G_CALLBACK (jogg_application_window_search_entry_on_search_changed)
Expand All @@ -321,6 +359,16 @@ jogg_application_window_init (JoggApplicationWindow *self)
, G_CALLBACK (jogg_application_window_results_on_activate)
, self
);
g_signal_connect ( self->list_item_factory
, "setup"
, G_CALLBACK (jogg_application_window_list_item_factory_on_setup)
, self
);
g_signal_connect ( self->list_item_factory
, "bind"
, G_CALLBACK (jogg_application_window_list_item_factory_on_bind)
, self
);

gtk_search_entry_set_key_capture_widget ( GTK_SEARCH_ENTRY (self->search_entry)
, self->results
Expand Down Expand Up @@ -355,9 +403,10 @@ jogg_application_window_map (GtkWidget *self)
}

static gboolean
jogg_application_window_on_escape_pressed (GtkWidget *widget,
GVariant *args,
gpointer user_data)
jogg_application_window_on_escape_pressed ( GtkWidget *widget
, GVariant *args
, gpointer user_data
)
{
jogg_application_window_quit (JOGG_APPLICATION_WINDOW (widget));

Expand Down Expand Up @@ -385,48 +434,61 @@ jogg_application_window_class_init (JoggApplicationWindowClass *klass)
, NULL
);

gtk_widget_class_bind_template_child ( widget_class
, JoggApplicationWindow
, size_group
);
gtk_widget_class_bind_template_child ( widget_class
, JoggApplicationWindow
, model
);
gtk_widget_class_bind_template_child (widget_class,
JoggApplicationWindow,
filter_model);
gtk_widget_class_bind_template_child (widget_class,
JoggApplicationWindow,
applications);
gtk_widget_class_bind_template_child (widget_class,
JoggApplicationWindow,
custom_sorter);
gtk_widget_class_bind_template_child (widget_class,
JoggApplicationWindow,
revealer);
gtk_widget_class_bind_template_child (widget_class,
JoggApplicationWindow,
revealer_box);
gtk_widget_class_bind_template_child (widget_class,
JoggApplicationWindow,
search_entry);
gtk_widget_class_bind_template_child (widget_class,
JoggApplicationWindow,
results_revealer);
gtk_widget_class_bind_template_child (widget_class,
JoggApplicationWindow,
results_scrolled_window);
gtk_widget_class_bind_template_child (widget_class,
JoggApplicationWindow,
results);

gtk_widget_class_bind_template_callback (widget_class,
jogg_application_window_search_entry_on_search_changed);
gtk_widget_class_bind_template_callback (widget_class,
jogg_application_window_search_entry_on_stop_search);
gtk_widget_class_bind_template_child ( widget_class
, JoggApplicationWindow
, filter_model
);
gtk_widget_class_bind_template_child ( widget_class
, JoggApplicationWindow
, applications
);
gtk_widget_class_bind_template_child ( widget_class
, JoggApplicationWindow
, custom_sorter
);
gtk_widget_class_bind_template_child ( widget_class
, JoggApplicationWindow
, revealer
);
gtk_widget_class_bind_template_child ( widget_class
, JoggApplicationWindow
, revealer_box
);
gtk_widget_class_bind_template_child ( widget_class
, JoggApplicationWindow
, search_entry
);
gtk_widget_class_bind_template_child ( widget_class
, JoggApplicationWindow
, results_revealer
);
gtk_widget_class_bind_template_child ( widget_class
, JoggApplicationWindow
, results_scrolled_window
);
gtk_widget_class_bind_template_child ( widget_class
, JoggApplicationWindow
, results
);
gtk_widget_class_bind_template_child ( widget_class
, JoggApplicationWindow
, list_item_factory
);
}

JoggApplicationWindow *
jogg_application_window_new (JoggApplication *app)
{
return g_object_new (JOGG_TYPE_APPLICATION_WINDOW,
"application", app,
NULL);
return g_object_new ( JOGG_TYPE_APPLICATION_WINDOW
, "application" , app
, NULL
);
}
8 changes: 4 additions & 4 deletions src/jogg-application.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ jogg_application_app_info_search ( JoggApplication *self
JoggApplication *
jogg_application_new (void)
{
return g_object_new (JOGG_TYPE_APPLICATION,
"application-id", "engineering.baltic.jogg",
"flags", G_APPLICATION_DEFAULT_FLAGS,
NULL);
return g_object_new ( JOGG_TYPE_APPLICATION
, "application-id", "engineering.baltic.jogg"
, "flags", G_APPLICATION_DEFAULT_FLAGS
, NULL);
}
Loading