|
|
@@ -43,7 +43,6 @@ struct _IridiumWindow
|
|
|
GtkWidget *main_pane;
|
|
|
GtkSearchBar *search_bar;
|
|
|
GtkSearchEntry *search_entry;
|
|
|
- GtkToggleButton *toggle_html_view;
|
|
|
GtkRevealer *notification_revealer;
|
|
|
WebKitWebView *html_view;
|
|
|
GBinding *title_binding;
|
|
|
@@ -116,11 +115,29 @@ on_note_selected (IridiumWindow *self, IridiumNoteRow *row, gpointer user_data)
|
|
|
}
|
|
|
|
|
|
static void
|
|
|
-search_activated (GAction *action, GVariant *param, IridiumWindow *self)
|
|
|
+search_activated (GSimpleAction *action, GVariant *param, gpointer user_data)
|
|
|
{
|
|
|
+ IridiumWindow *self;
|
|
|
+
|
|
|
+ self = IRIDIUM_WINDOW (user_data);
|
|
|
gtk_search_bar_set_search_mode (self->search_bar, !gtk_search_bar_get_search_mode (self->search_bar));
|
|
|
}
|
|
|
|
|
|
+static void
|
|
|
+preview_toggled (GSimpleAction *action, GVariant *param, gpointer user_data)
|
|
|
+{
|
|
|
+ IridiumWindow *self;
|
|
|
+ GVariant *state;
|
|
|
+ gboolean visible;
|
|
|
+
|
|
|
+ self = IRIDIUM_WINDOW (user_data);
|
|
|
+ state = g_action_get_state (G_ACTION (action));
|
|
|
+ visible = !g_variant_get_boolean (state);
|
|
|
+ g_simple_action_set_state (action, g_variant_new_boolean (visible));
|
|
|
+ gtk_widget_set_visible (GTK_WIDGET (self->html_view), visible);
|
|
|
+ g_variant_unref (state);
|
|
|
+}
|
|
|
+
|
|
|
static gboolean
|
|
|
note_visible (IridiumNoteRow *row, IridiumWindow *window)
|
|
|
{
|
|
|
@@ -310,7 +327,6 @@ iridium_window_class_init (IridiumWindowClass *klass)
|
|
|
gtk_widget_class_bind_template_child (widget_class, IridiumWindow, search_bar);
|
|
|
gtk_widget_class_bind_template_child (widget_class, IridiumWindow, search_entry);
|
|
|
gtk_widget_class_bind_template_child (widget_class, IridiumWindow, html_view);
|
|
|
- gtk_widget_class_bind_template_child (widget_class, IridiumWindow, toggle_html_view);
|
|
|
gtk_widget_class_bind_template_child (widget_class, IridiumWindow, notification_revealer);
|
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, on_tag_selected);
|
|
|
@@ -326,12 +342,16 @@ iridium_window_init (IridiumWindow *self)
|
|
|
GtkSourceLanguageManager *manager;
|
|
|
GtkStyleProvider *provider;
|
|
|
GtkSourceBuffer *buffer;
|
|
|
- GSimpleAction *action;
|
|
|
GBytes *style_data;
|
|
|
WebKitUserContentManager *content_manager;
|
|
|
WebKitUserStyleSheet *stylesheet;
|
|
|
GError *error = NULL;
|
|
|
|
|
|
+ static GActionEntry entries[] = {
|
|
|
+ { "search", search_activated, NULL, NULL, NULL },
|
|
|
+ { "preview", NULL, NULL, "false", preview_toggled },
|
|
|
+ };
|
|
|
+
|
|
|
gtk_widget_init_template (GTK_WIDGET (self));
|
|
|
|
|
|
self->settings = g_settings_new ("net.bloerg.Iridium");
|
|
|
@@ -348,13 +368,8 @@ iridium_window_init (IridiumWindow *self)
|
|
|
webkit_user_content_manager_add_style_sheet (content_manager, stylesheet);
|
|
|
g_bytes_unref (style_data);
|
|
|
|
|
|
- action = g_simple_action_new ("search", NULL);
|
|
|
- g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (action));
|
|
|
- g_signal_connect (action, "activate", G_CALLBACK (search_activated), self);
|
|
|
- g_object_unref (action);
|
|
|
+ g_action_map_add_action_entries (G_ACTION_MAP (self), entries, G_N_ELEMENTS (entries), self);
|
|
|
|
|
|
- g_object_bind_property (self->toggle_html_view, "active",
|
|
|
- self->html_view, "visible", G_BINDING_DEFAULT);
|
|
|
gtk_search_bar_connect_entry (self->search_bar, GTK_ENTRY (self->search_entry));
|
|
|
|
|
|
manager = gtk_source_language_manager_get_default ();
|