search: Open event from search results
And this finally hooks up the last missing bit from the search engine: opening events from search results. All the necessary plumbing is there for extending search with other commands or results, such as go to date, etc.
This commit is contained in:
@@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
#include "gcal-context.h"
|
#include "gcal-context.h"
|
||||||
#include "gcal-search-button.h"
|
#include "gcal-search-button.h"
|
||||||
|
#include "gcal-search-hit.h"
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
@@ -119,6 +120,14 @@ on_search_entry_changed_cb (GcalSearchButton *self)
|
|||||||
g_object_ref (self));
|
g_object_ref (self));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_search_entry_suggestion_activated_cb (DzlSuggestionEntry *entry,
|
||||||
|
GcalSearchHit *search_hit,
|
||||||
|
GcalSearchButton *self)
|
||||||
|
{
|
||||||
|
gcal_search_hit_activate (search_hit, GTK_WIDGET (self));
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_unfocus_action_activated_cb (GSimpleAction *action,
|
on_unfocus_action_activated_cb (GSimpleAction *action,
|
||||||
GVariant *param,
|
GVariant *param,
|
||||||
@@ -257,6 +266,11 @@ gcal_search_button_init (GcalSearchButton *self)
|
|||||||
G_CALLBACK (on_search_entry_changed_cb),
|
G_CALLBACK (on_search_entry_changed_cb),
|
||||||
self,
|
self,
|
||||||
G_CONNECT_SWAPPED);
|
G_CONNECT_SWAPPED);
|
||||||
|
g_signal_connect_object (entry,
|
||||||
|
"suggestion-activated",
|
||||||
|
G_CALLBACK (on_search_entry_suggestion_activated_cb),
|
||||||
|
self,
|
||||||
|
0);
|
||||||
|
|
||||||
dzl_suggestion_entry_set_position_func (entry,
|
dzl_suggestion_entry_set_position_func (entry,
|
||||||
position_suggestion_popover_func,
|
position_suggestion_popover_func,
|
||||||
|
|||||||
@@ -107,8 +107,6 @@ search_func (GTask *task,
|
|||||||
start,
|
start,
|
||||||
end);
|
end);
|
||||||
|
|
||||||
//e_cal_data_model_unsubscribe (self->data_model, E_CAL_DATA_MODEL_SUBSCRIBER (model));
|
|
||||||
|
|
||||||
g_task_return_pointer (task, g_steal_pointer (&model), g_object_unref);
|
g_task_return_pointer (task, g_steal_pointer (&model), g_object_unref);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,8 +62,7 @@ set_event (GcalSearchHitEvent *self,
|
|||||||
dzl_suggestion_set_id (suggestion, gcal_event_get_uid (event));
|
dzl_suggestion_set_id (suggestion, gcal_event_get_uid (event));
|
||||||
dzl_suggestion_set_title (suggestion, gcal_event_get_summary (event));
|
dzl_suggestion_set_title (suggestion, gcal_event_get_summary (event));
|
||||||
|
|
||||||
/* FIXME: use a better date description */
|
date_string = gcal_event_format_date (event);
|
||||||
date_string = g_date_time_format (gcal_event_get_date_start (event), "%x %X %z");
|
|
||||||
dzl_suggestion_set_subtitle (suggestion, date_string);
|
dzl_suggestion_set_subtitle (suggestion, date_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,6 +97,25 @@ gcal_search_hit_event_get_icon_surface (DzlSuggestion *suggestion,
|
|||||||
* GcalSearchHit interface
|
* GcalSearchHit interface
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
gcal_search_hit_event_activate (GcalSearchHit *search_hit,
|
||||||
|
GtkWidget *for_widget)
|
||||||
|
{
|
||||||
|
GcalSearchHitEvent *self;
|
||||||
|
GApplication *application;
|
||||||
|
const gchar *event_uid;
|
||||||
|
|
||||||
|
self = GCAL_SEARCH_HIT_EVENT (search_hit);
|
||||||
|
event_uid = gcal_event_get_uid (self->event);
|
||||||
|
|
||||||
|
application = g_application_get_default ();
|
||||||
|
g_assert (application != NULL);
|
||||||
|
|
||||||
|
g_action_group_activate_action (G_ACTION_GROUP (application),
|
||||||
|
"open-event",
|
||||||
|
g_variant_new_string (event_uid));
|
||||||
|
}
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
gcal_search_hit_event_get_priority (GcalSearchHit *search_hit)
|
gcal_search_hit_event_get_priority (GcalSearchHit *search_hit)
|
||||||
{
|
{
|
||||||
@@ -125,6 +143,7 @@ gcal_search_hit_event_compare (GcalSearchHit *a,
|
|||||||
static void
|
static void
|
||||||
gcal_search_hit_interface_init (GcalSearchHitInterface *iface)
|
gcal_search_hit_interface_init (GcalSearchHitInterface *iface)
|
||||||
{
|
{
|
||||||
|
iface->activate = gcal_search_hit_event_activate;
|
||||||
iface->get_priority = gcal_search_hit_event_get_priority;
|
iface->get_priority = gcal_search_hit_event_get_priority;
|
||||||
iface->compare = gcal_search_hit_event_compare;
|
iface->compare = gcal_search_hit_event_compare;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,16 @@ gcal_search_hit_default_init (GcalSearchHitInterface *iface)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gcal_search_hit_activate (GcalSearchHit *self,
|
||||||
|
GtkWidget *for_widget)
|
||||||
|
{
|
||||||
|
g_return_if_fail (GCAL_IS_SEARCH_HIT (self));
|
||||||
|
g_return_if_fail (GCAL_SEARCH_HIT_GET_IFACE (self)->activate);
|
||||||
|
|
||||||
|
GCAL_SEARCH_HIT_GET_IFACE (self)->activate (self, for_widget);
|
||||||
|
}
|
||||||
|
|
||||||
gint
|
gint
|
||||||
gcal_search_hit_get_priority (GcalSearchHit *self)
|
gcal_search_hit_get_priority (GcalSearchHit *self)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -31,12 +31,18 @@ struct _GcalSearchHitInterface
|
|||||||
{
|
{
|
||||||
GTypeInterface parent;
|
GTypeInterface parent;
|
||||||
|
|
||||||
|
void (*activate) (GcalSearchHit *self,
|
||||||
|
GtkWidget *for_widget);
|
||||||
|
|
||||||
gint (*get_priority) (GcalSearchHit *self);
|
gint (*get_priority) (GcalSearchHit *self);
|
||||||
|
|
||||||
gint (*compare) (GcalSearchHit *a,
|
gint (*compare) (GcalSearchHit *a,
|
||||||
GcalSearchHit *b);
|
GcalSearchHit *b);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void gcal_search_hit_activate (GcalSearchHit *self,
|
||||||
|
GtkWidget *for_widget);
|
||||||
|
|
||||||
gint gcal_search_hit_get_priority (GcalSearchHit *self);
|
gint gcal_search_hit_get_priority (GcalSearchHit *self);
|
||||||
|
|
||||||
gint gcal_search_hit_compare (GcalSearchHit *a,
|
gint gcal_search_hit_compare (GcalSearchHit *a,
|
||||||
|
|||||||
Reference in New Issue
Block a user