Commit a7183465 authored by Adrien Plazas's avatar Adrien Plazas
Browse files

Merge branch 'librem5-3-34-1' into pureos/sloppy

parents 6680f6f0 13d5ab17
......@@ -484,7 +484,7 @@ ephy_embed_prefs_init (gpointer user_data)
guint i;
webkit_settings = webkit_settings_new_with_settings ("enable-developer-extras", TRUE,
"enable-fullscreen", TRUE,
"enable-fullscreen", FALSE,
"enable-javascript", TRUE,
"enable-dns-prefetching", TRUE,
"enable-mediasource", TRUE,
......
......@@ -138,6 +138,8 @@ ephy_add_bookmark_popover_init (EphyAddBookmarkPopover *self)
g_signal_connect (self, "closed",
G_CALLBACK (ephy_add_bookmark_popover_closed_cb),
NULL);
gtk_widget_set_hexpand (GTK_WIDGET (self), TRUE);
}
GtkWidget *
......
......@@ -171,6 +171,8 @@ ephy_bookmark_properties_grid_create_tag_widget (EphyBookmarkPropertiesGrid *sel
label_text = default_tag ? _(EPHY_BOOKMARKS_FAVORITES_TAG) : tag;
label = gtk_label_new (label_text);
gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
gtk_label_set_max_width_chars (GTK_LABEL (label), 10);
gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
if (!default_tag) {
......
......@@ -246,6 +246,9 @@ create_tag_row (const char *tag)
label = gtk_label_new (tag);
}
gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
gtk_label_set_xalign (GTK_LABEL (label), 0);
gtk_box_pack_start (GTK_BOX (box), image, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (box), label, TRUE, FALSE, 0);
......
......@@ -38,14 +38,12 @@ typedef enum {
} Timespan;
struct _ClearDataDialog {
GtkDialog parent_instance;
EphyDataDialog parent_instance;
GtkWidget *clear_button;
GtkWidget *treeview;
GtkTreeModel *treestore;
GtkTreeModelFilter *treemodelfilter;
GtkWidget *timespan_combo;
GtkWidget *search_entry;
GtkSpinner *spinner;
GtkStack *stack;
......@@ -61,7 +59,7 @@ enum {
SENSITIVE_COLUMN
};
G_DEFINE_TYPE (ClearDataDialog, clear_data_dialog, GTK_TYPE_DIALOG)
G_DEFINE_TYPE (ClearDataDialog, clear_data_dialog, EPHY_TYPE_DATA_DIALOG)
#define PERSISTENT_DATA_TYPES WEBKIT_WEBSITE_DATA_DISK_CACHE | \
WEBKIT_WEBSITE_DATA_OFFLINE_APPLICATION_CACHE | \
......@@ -141,7 +139,7 @@ website_data_fetched_cb (WebKitWebsiteDataManager *manager,
return;
}
gtk_widget_set_sensitive (dialog->clear_button, TRUE);
ephy_data_dialog_set_has_data (EPHY_DATA_DIALOG (dialog), TRUE);
gtk_stack_set_visible_child_name (dialog->stack, "view");
treestore = GTK_TREE_STORE (dialog->treestore);
......@@ -191,9 +189,7 @@ all_children_visible (GtkTreeModel *model,
}
static void
clear_data_dialog_response_cb (GtkDialog *widget,
int response,
ClearDataDialog *dialog)
on_clear_all_clicked (ClearDataDialog *dialog)
{
GtkTreeIter top_iter;
WebKitWebsiteDataTypes types_to_clear = 0;
......@@ -201,11 +197,6 @@ clear_data_dialog_response_cb (GtkDialog *widget,
WebKitWebsiteDataTypes types_to_remove = 0;
GTimeSpan timespan;
if (response != GTK_RESPONSE_OK) {
gtk_widget_destroy (GTK_WIDGET (dialog));
return;
}
if (!gtk_tree_model_get_iter_first (dialog->treestore, &top_iter)) {
gtk_widget_destroy (GTK_WIDGET (dialog));
return;
......@@ -361,8 +352,7 @@ timespan_combo_changed_cb (GtkComboBox *combo,
}
static void
search_entry_changed_cb (GtkSearchEntry *entry,
ClearDataDialog *dialog)
search_text_changed_cb (ClearDataDialog *dialog)
{
gtk_tree_model_filter_refilter (dialog->treemodelfilter);
}
......@@ -379,7 +369,7 @@ row_visible_func (GtkTreeModel *model,
if (gtk_tree_model_iter_has_child (model, iter))
return TRUE;
search_text = gtk_entry_get_text (GTK_ENTRY (dialog->search_entry));
search_text = ephy_data_dialog_get_search_text (EPHY_DATA_DIALOG (dialog));
if (!search_text || search_text[0] == '\0')
return TRUE;
......@@ -427,18 +417,16 @@ clear_data_dialog_class_init (ClearDataDialogClass *klass)
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/epiphany/gtk/clear-data-dialog.ui");
gtk_widget_class_bind_template_child (widget_class, ClearDataDialog, clear_button);
gtk_widget_class_bind_template_child (widget_class, ClearDataDialog, treeview);
gtk_widget_class_bind_template_child (widget_class, ClearDataDialog, treestore);
gtk_widget_class_bind_template_child (widget_class, ClearDataDialog, treemodelfilter);
gtk_widget_class_bind_template_child (widget_class, ClearDataDialog, timespan_combo);
gtk_widget_class_bind_template_child (widget_class, ClearDataDialog, search_entry);
gtk_widget_class_bind_template_child (widget_class, ClearDataDialog, spinner);
gtk_widget_class_bind_template_child (widget_class, ClearDataDialog, stack);
gtk_widget_class_bind_template_callback (widget_class, item_toggled_cb);
gtk_widget_class_bind_template_callback (widget_class, timespan_combo_changed_cb);
gtk_widget_class_bind_template_callback (widget_class, clear_data_dialog_response_cb);
gtk_widget_class_bind_template_callback (widget_class, search_entry_changed_cb);
gtk_widget_class_bind_template_callback (widget_class, on_clear_all_clicked);
gtk_widget_class_bind_template_callback (widget_class, search_text_changed_cb);
}
static void
......@@ -454,7 +442,6 @@ clear_data_dialog_init (ClearDataDialog *dialog)
gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->timespan_combo),
dialog->timespan);
gtk_widget_set_sensitive (dialog->clear_button, FALSE);
gtk_spinner_start (dialog->spinner);
gtk_stack_set_visible_child_name (dialog->stack, "spinner");
......
......@@ -23,10 +23,12 @@
#include <glib-object.h>
#include <gtk/gtk.h>
#include "ephy-data-dialog.h"
G_BEGIN_DECLS
#define EPHY_TYPE_CLEAR_DATA_DIALOG (clear_data_dialog_get_type ())
G_DECLARE_FINAL_TYPE (ClearDataDialog, clear_data_dialog, EPHY, CLEAR_DATA_DIALOG, GtkDialog)
G_DECLARE_FINAL_TYPE (ClearDataDialog, clear_data_dialog, EPHY, CLEAR_DATA_DIALOG, EphyDataDialog)
G_END_DECLS
......@@ -2,6 +2,7 @@
/*
* Copyright © 2013 Red Hat, Inc.
* Copyright © 2019 Jan-Michael Brummer
* Copyright © 2019 Purism SPC
*
* This file is part of Epiphany.
*
......@@ -34,21 +35,16 @@
#include "cookies-dialog.h"
struct _EphyCookiesDialog {
GtkDialog parent_instance;
EphyDataDialog parent_instance;
GtkWidget *cookies_listbox;
GtkWidget *search_bar;
GtkWidget *search_entry;
GActionGroup *action_group;
WebKitWebsiteDataManager *data_manager;
gboolean filled;
char *search_text;
};
G_DEFINE_TYPE (EphyCookiesDialog, ephy_cookies_dialog, GTK_TYPE_DIALOG)
G_DEFINE_TYPE (EphyCookiesDialog, ephy_cookies_dialog, EPHY_TYPE_DATA_DIALOG)
static void populate_model (EphyCookiesDialog *self);
......@@ -69,26 +65,10 @@ static void
reload_model (EphyCookiesDialog *self)
{
clear_listbox (self->cookies_listbox);
self->filled = FALSE;
ephy_data_dialog_set_has_data (EPHY_DATA_DIALOG (self), FALSE);
populate_model (self);
}
static void
ephy_cookies_dialog_dispose (GObject *object)
{
EphyCookiesDialog *self = EPHY_COOKIES_DIALOG (object);
g_clear_pointer (&self->search_text, g_free);
G_OBJECT_CLASS (ephy_cookies_dialog_parent_class)->dispose (object);
}
static void
ephy_cookies_dialog_finalize (GObject *object)
{
g_free (EPHY_COOKIES_DIALOG (object)->search_text);
G_OBJECT_CLASS (ephy_cookies_dialog_parent_class)->finalize (object);
}
static void
forget_clicked (GtkButton *button,
gpointer user_data)
......@@ -111,15 +91,9 @@ forget_clicked (GtkButton *button,
}
static void
on_search_entry_changed (GtkSearchEntry *entry,
EphyCookiesDialog *self)
on_search_text_changed (EphyCookiesDialog *self)
{
const char *text;
text = gtk_entry_get_text (GTK_ENTRY (entry));
g_free (self->search_text);
self->search_text = g_strdup (text);
ephy_data_dialog_set_has_search_results (EPHY_DATA_DIALOG (self), FALSE);
gtk_list_box_invalidate_filter (GTK_LIST_BOX (self->cookies_listbox));
}
......@@ -137,22 +111,16 @@ forget_all (GSimpleAction *action,
static void
ephy_cookies_dialog_class_init (EphyCookiesDialogClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->dispose = ephy_cookies_dialog_dispose;
object_class->finalize = ephy_cookies_dialog_finalize;
g_type_ensure (WEBKIT_TYPE_WEBSITE_DATA);
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/epiphany/gtk/cookies-dialog.ui");
gtk_widget_class_bind_template_child (widget_class, EphyCookiesDialog, cookies_listbox);
gtk_widget_class_bind_template_child (widget_class, EphyCookiesDialog, search_bar);
gtk_widget_class_bind_template_child (widget_class, EphyCookiesDialog, search_entry);
gtk_widget_class_bind_template_callback (widget_class, on_search_entry_changed);
gtk_widget_class_bind_template_callback (widget_class, on_search_text_changed);
}
static void
......@@ -198,13 +166,13 @@ get_domains_with_cookies_cb (WebKitWebsiteDataManager *data_manager,
/* The list items have been consumed, so we need only to free the list. */
g_list_free (data_list);
self->filled = TRUE;
ephy_data_dialog_set_has_data (EPHY_DATA_DIALOG (self), TRUE);
}
static void
populate_model (EphyCookiesDialog *self)
{
g_assert (self->filled == FALSE);
g_assert (!ephy_data_dialog_get_has_data (EPHY_DATA_DIALOG (self)));
webkit_website_data_manager_fetch (self->data_manager,
WEBKIT_WEBSITE_DATA_COOKIES,
......@@ -233,11 +201,16 @@ filter_func (GtkListBoxRow *row,
gpointer user_data)
{
EphyCookiesDialog *self = EPHY_COOKIES_DIALOG (user_data);
const gchar *search_text = ephy_data_dialog_get_search_text (EPHY_DATA_DIALOG (self));
gboolean result = TRUE;
if (search_text)
result = !!strstr (hdy_action_row_get_title (HDY_ACTION_ROW (row)), search_text);
if (self->search_text)
return !!strstr (hdy_action_row_get_title (HDY_ACTION_ROW (row)), self->search_text);
if (result)
ephy_data_dialog_set_has_search_results (EPHY_DATA_DIALOG (self), TRUE);
return TRUE;
return result;
}
static void
......@@ -258,14 +231,10 @@ ephy_cookies_dialog_init (EphyCookiesDialog *self)
gtk_list_box_set_header_func (GTK_LIST_BOX (self->cookies_listbox), hdy_list_box_separator_header, NULL, NULL);
gtk_list_box_set_filter_func (GTK_LIST_BOX (self->cookies_listbox), filter_func, self, NULL);
hdy_search_bar_connect_entry (HDY_SEARCH_BAR (self->search_bar), GTK_ENTRY (self->search_entry));
}
EphyCookiesDialog *
ephy_cookies_dialog_new (void)
{
return g_object_new (EPHY_TYPE_COOKIES_DIALOG,
"use-header-bar", TRUE,
NULL);
return g_object_new (EPHY_TYPE_COOKIES_DIALOG, NULL);
}
......@@ -20,10 +20,12 @@
#pragma once
#include "ephy-data-dialog.h"
G_BEGIN_DECLS
#define EPHY_TYPE_COOKIES_DIALOG (ephy_cookies_dialog_get_type ())
G_DECLARE_FINAL_TYPE (EphyCookiesDialog, ephy_cookies_dialog, EPHY, COOKIES_DIALOG, GtkDialog);
G_DECLARE_FINAL_TYPE (EphyCookiesDialog, ephy_cookies_dialog, EPHY, COOKIES_DIALOG, EphyDataDialog);
EphyCookiesDialog *ephy_cookies_dialog_new (void);
......
/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* Copyright © 2019 Purism SPC
*
* This file is part of Epiphany.
*
* Epiphany is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Epiphany is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Epiphany. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "ephy-data-dialog.h"
#include <ctype.h>
#include <glib/gi18n.h>
#define HANDY_USE_UNSTABLE_API
#include <handy.h>
typedef struct {
GtkWidget *box;
GtkWidget *child;
GtkWidget *clear_all_button;
GtkWidget *search_bar;
GtkWidget *search_entry;
GtkWidget *search_button;
GtkWidget *stack;
GtkWidget *empty_title_label;
GtkWidget *empty_description_label;
gboolean has_data : 1;
gboolean has_search_results : 1;
gboolean can_clear : 1;
char *search_text;
} EphyDataDialogPrivate;
G_DEFINE_TYPE_WITH_PRIVATE (EphyDataDialog, ephy_data_dialog, GTK_TYPE_WINDOW)
enum {
PROP_0,
PROP_CLEAR_ALL_ACTION_NAME,
PROP_CLEAR_ALL_ACTION_TARGET,
PROP_CLEAR_ALL_DESCRIPTION,
PROP_SEARCH_DESCRIPTION,
PROP_EMPTY_TITLE,
PROP_EMPTY_DESCRIPTION,
PROP_SEARCH_TEXT,
PROP_HAS_DATA,
PROP_HAS_SEARCH_RESULTS,
PROP_CAN_CLEAR,
LAST_PROP,
};
static GParamSpec *obj_properties[LAST_PROP];
enum {
CLEAR_ALL_CLICKED,
LAST_SIGNAL,
};
static gint signals[LAST_SIGNAL] = { 0 };
static void
update (EphyDataDialog *self)
{
EphyDataDialogPrivate *priv = ephy_data_dialog_get_instance_private (self);
gboolean has_data = priv->has_data && priv->child && gtk_widget_get_visible (priv->child);
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->search_button))) {
if (has_data && priv->has_search_results)
gtk_stack_set_visible_child (GTK_STACK (priv->stack), priv->child);
else
gtk_stack_set_visible_child_name (GTK_STACK (priv->stack), "no-results");
} else {
if (has_data)
gtk_stack_set_visible_child (GTK_STACK (priv->stack), priv->child);
else
gtk_stack_set_visible_child_name (GTK_STACK (priv->stack), "empty");
}
gtk_widget_set_sensitive (priv->clear_all_button, has_data && priv->can_clear);
gtk_widget_set_sensitive (priv->search_button, has_data);
}
static void
on_clear_all_button_clicked (EphyDataDialog *self)
{
g_signal_emit (self, signals[CLEAR_ALL_CLICKED], 0);
}
static void
on_search_entry_changed (GtkSearchEntry *entry,
EphyDataDialog *self)
{
EphyDataDialogPrivate *priv = ephy_data_dialog_get_instance_private (self);
const char *text;
text = gtk_entry_get_text (GTK_ENTRY (entry));
g_free (priv->search_text);
priv->search_text = g_strdup (text);
g_object_notify_by_pspec (G_OBJECT (self), obj_properties[PROP_SEARCH_TEXT]);
}
static gboolean
on_key_press_event (EphyDataDialog *self,
GdkEvent *event,
gpointer user_data)
{
EphyDataDialogPrivate *priv = ephy_data_dialog_get_instance_private (self);
GdkEventKey *key = (GdkEventKey *)event;
gint result;
result = hdy_search_bar_handle_event (HDY_SEARCH_BAR (priv->search_bar), event);
if (result == GDK_EVENT_STOP)
return result;
if (key->keyval == GDK_KEY_Escape) {
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->search_button)))
gtk_widget_destroy (GTK_WIDGET (self));
else
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->search_button), FALSE);
} else if (isprint (key->keyval))
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->search_button), TRUE);
return result;
}
static void
ephy_data_dialog_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
EphyDataDialog *self = EPHY_DATA_DIALOG (object);
EphyDataDialogPrivate *priv = ephy_data_dialog_get_instance_private (self);
switch (prop_id) {
case PROP_CLEAR_ALL_ACTION_NAME:
gtk_actionable_set_action_name (GTK_ACTIONABLE (priv->clear_all_button), g_value_get_string (value));
break;
case PROP_CLEAR_ALL_ACTION_TARGET:
gtk_actionable_set_action_target_value (GTK_ACTIONABLE (priv->clear_all_button), g_value_get_variant (value));
break;
case PROP_CLEAR_ALL_DESCRIPTION:
ephy_data_dialog_set_clear_all_description (self, g_value_get_string (value));
break;
case PROP_SEARCH_DESCRIPTION:
gtk_entry_set_placeholder_text (GTK_ENTRY (priv->search_entry), g_value_get_string (value));
atk_object_set_description (gtk_widget_get_accessible (GTK_WIDGET (self)), g_value_get_string (value));
break;
case PROP_EMPTY_TITLE:
gtk_label_set_text (GTK_LABEL (priv->empty_title_label), g_value_get_string (value));
break;
case PROP_EMPTY_DESCRIPTION:
gtk_label_set_text (GTK_LABEL (priv->empty_description_label), g_value_get_string (value));
break;
case PROP_HAS_DATA:
ephy_data_dialog_set_has_data (self, g_value_get_boolean (value));
break;
case PROP_HAS_SEARCH_RESULTS:
ephy_data_dialog_set_has_search_results (self, g_value_get_boolean (value));
break;
case PROP_CAN_CLEAR:
ephy_data_dialog_set_can_clear (self, g_value_get_boolean (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
ephy_data_dialog_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
EphyDataDialog *self = EPHY_DATA_DIALOG (object);
EphyDataDialogPrivate *priv = ephy_data_dialog_get_instance_private (self);
switch (prop_id) {
case PROP_CLEAR_ALL_ACTION_NAME:
g_value_set_string (value, gtk_actionable_get_action_name (GTK_ACTIONABLE (priv->clear_all_button)));
break;
case PROP_CLEAR_ALL_ACTION_TARGET:
g_value_set_variant (value, gtk_actionable_get_action_target_value (GTK_ACTIONABLE (priv->clear_all_button)));
break;
case PROP_CLEAR_ALL_DESCRIPTION:
g_value_set_string (value, ephy_data_dialog_get_clear_all_description (self));
break;
case PROP_SEARCH_DESCRIPTION:
g_value_set_string (value, gtk_entry_get_placeholder_text (GTK_ENTRY (priv->search_entry)));
break;
case PROP_EMPTY_TITLE:
g_value_set_string (value, gtk_label_get_text (GTK_LABEL (priv->empty_title_label)));
break;
case PROP_EMPTY_DESCRIPTION:
g_value_set_string (value, gtk_label_get_text (GTK_LABEL (priv->empty_description_label)));
break;
case PROP_SEARCH_TEXT:
g_value_set_string (value, ephy_data_dialog_get_search_text (self));
break;
case PROP_HAS_DATA:
g_value_set_boolean (value, ephy_data_dialog_get_has_data (self));
break;
case PROP_HAS_SEARCH_RESULTS:
g_value_set_boolean (value, ephy_data_dialog_get_has_search_results (self));
break;
case PROP_CAN_CLEAR:
g_value_set_boolean (value, ephy_data_dialog_get_can_clear (self));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
ephy_data_dialog_finalize (GObject *object)
{
EphyDataDialog *self = EPHY_DATA_DIALOG (object);
EphyDataDialogPrivate *priv = ephy_data_dialog_get_instance_private (self);
g_free (priv->search_text);
G_OBJECT_CLASS (ephy_data_dialog_parent_class)->finalize (object);
}
static void
ephy_data_dialog_add (GtkContainer *container,
GtkWidget *child)
{
EphyDataDialog *self = EPHY_DATA_DIALOG (container);
EphyDataDialogPrivate *priv = ephy_data_dialog_get_instance_private (self);
if (!priv->box) {
GTK_CONTAINER_CLASS (ephy_data_dialog_parent_class)->add (container, child);
return;
}
g_assert (!priv->child);
priv->child = child;
gtk_container_add (GTK_CONTAINER (priv->stack), child);
update (self);
}
static void
ephy_data_dialog_class_init (EphyDataDialogClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
object_class->set_property = ephy_data_dialog_set_property;
object_class->get_property = ephy_data_dialog_get_property;
object_class->finalize = ephy_data_dialog_finalize;
container_class->add = ephy_data_dialog_add;
obj_properties[PROP_CLEAR_ALL_ACTION_NAME] =
g_param_spec_string ("clear-all-action-name",
_("'Clear all' action name"),
_("The name of the action associated to the 'Clear all' button"),
NULL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
obj_properties[PROP_CLEAR_ALL_ACTION_TARGET] =
g_param_spec_variant ("clear-all-action-target",
_("'Clear all' action target value"),
_("The parameter for 'Clear all' action invocations"),
G_VARIANT_TYPE_ANY, NULL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
obj_properties[PROP_CLEAR_ALL_DESCRIPTION] =
g_param_spec_string ("clear-all-description",
_("'Clear all' description"),
_("The description of the 'Clear all' action"),
NULL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
obj_properties[PROP_SEARCH_DESCRIPTION] =
g_param_spec_string ("search-description",
_("'Search' description"),
_("The description of the 'Search' action"),