[evolution] I#1319 - Address book: Provide feedback when searching in the List View
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] I#1319 - Address book: Provide feedback when searching in the List View
- Date: Tue, 12 Jan 2021 10:08:29 +0000 (UTC)
commit 6b66603a6879269f8b2d816b513c34c3afc293cd
Author: Milan Crha <mcrha redhat com>
Date: Tue Jan 12 11:07:26 2021 +0100
I#1319 - Address book: Provide feedback when searching in the List View
Closes https://gitlab.gnome.org/GNOME/evolution/-/issues/1319
src/addressbook/gui/widgets/e-addressbook-view.c | 25 +++++++
src/e-util/e-table.c | 90 ++++++++++++++++++++++++
src/e-util/e-table.h | 5 ++
3 files changed, 120 insertions(+)
---
diff --git a/src/addressbook/gui/widgets/e-addressbook-view.c
b/src/addressbook/gui/widgets/e-addressbook-view.c
index 206d7bda96..610d30115a 100644
--- a/src/addressbook/gui/widgets/e-addressbook-view.c
+++ b/src/addressbook/gui/widgets/e-addressbook-view.c
@@ -908,6 +908,23 @@ e_addressbook_view_selectable_init (ESelectableInterface *iface)
iface->select_all = addressbook_view_select_all;
}
+static void
+update_empty_message (EAddressbookView *view)
+{
+ EAddressbookModel *model;
+ GtkWidget *widget;
+ const gchar *msg = NULL;
+
+ model = e_addressbook_view_get_model (view);
+
+ if (model && e_addressbook_model_can_stop (model) &&
+ !e_addressbook_model_contact_count (model))
+ msg = _("Searching for the Contacts…");
+
+ widget = gtk_bin_get_child (GTK_BIN (view));
+ e_table_set_info_message (E_TABLE (widget), msg);
+}
+
GtkWidget *
e_addressbook_view_new (EShellView *shell_view,
ESource *source)
@@ -935,6 +952,12 @@ e_addressbook_view_new (EShellView *shell_view,
g_signal_connect_swapped (
view->priv->model, "writable-status",
G_CALLBACK (command_state_change), view);
+ g_signal_connect_object (
+ view->priv->model, "contact-added",
+ G_CALLBACK (update_empty_message), view, G_CONNECT_SWAPPED | G_CONNECT_AFTER);
+ g_signal_connect_object (
+ view->priv->model, "contacts-removed",
+ G_CALLBACK (update_empty_message), view, G_CONNECT_SWAPPED | G_CONNECT_AFTER);
return widget;
}
@@ -1095,6 +1118,8 @@ static void
command_state_change (EAddressbookView *view)
{
g_signal_emit (view, signals[COMMAND_STATE_CHANGE], 0);
+
+ update_empty_message (view);
}
static void
diff --git a/src/e-util/e-table.c b/src/e-util/e-table.c
index fb9994bcde..05bea36703 100644
--- a/src/e-util/e-table.c
+++ b/src/e-util/e-table.c
@@ -38,6 +38,7 @@
#include <libgnomecanvas/libgnomecanvas.h>
#include "e-canvas-background.h"
+#include "e-canvas-utils.h"
#include "e-canvas-vbox.h"
#include "e-canvas.h"
#include "e-table-click-to-add.h"
@@ -47,6 +48,7 @@
#include "e-table-header-utils.h"
#include "e-table-subset.h"
#include "e-table-utils.h"
+#include "e-text.h"
#include "e-unicode.h"
#include "e-misc-utils.h"
#include "gal-a11y-e-table.h"
@@ -63,6 +65,11 @@
#define e_table_item_leave_edit_(x) (e_table_item_leave_edit((x)))
#endif
+struct _ETablePrivate {
+ GnomeCanvasItem *info_text;
+ guint info_text_resize_id;
+};
+
enum {
CURSOR_CHANGE,
CURSOR_ACTIVATED,
@@ -170,6 +177,7 @@ static void scroll_on (ETable *et, guint scroll_direction);
static void e_table_scrollable_init (GtkScrollableInterface *iface);
G_DEFINE_TYPE_WITH_CODE (ETable, e_table, GTK_TYPE_TABLE,
+ G_ADD_PRIVATE (ETable)
G_IMPLEMENT_INTERFACE (GTK_TYPE_SCROLLABLE, e_table_scrollable_init))
static void
@@ -343,6 +351,12 @@ et_dispose (GObject *object)
et_disconnect_model (et);
+ if (et->priv->info_text != NULL) {
+ g_object_run_dispose (G_OBJECT (et->priv->info_text));
+ et->priv->info_text = NULL;
+ }
+ et->priv->info_text_resize_id = 0;
+
if (et->search) {
if (et->search_search_id)
g_signal_handler_disconnect (
@@ -542,6 +556,8 @@ et_finalize (GObject *object)
static void
e_table_init (ETable *e_table)
{
+ e_table->priv = e_table_get_instance_private (e_table);
+
gtk_widget_set_can_focus (GTK_WIDGET (e_table), TRUE);
gtk_table_set_homogeneous (GTK_TABLE (e_table), FALSE);
@@ -3591,3 +3607,77 @@ e_table_customize_view (ETable *table)
if (table->header_item)
e_table_header_item_customize_view (E_TABLE_HEADER_ITEM (table->header_item));
}
+
+static void
+table_size_allocate (GtkWidget *widget,
+ GtkAllocation *alloc,
+ ETable *table)
+{
+ gdouble width;
+
+ g_return_if_fail (E_IS_TABLE (table));
+ g_return_if_fail (table->priv->info_text != NULL);
+
+ gnome_canvas_get_scroll_region (
+ GNOME_CANVAS (table->table_canvas),
+ NULL, NULL, &width, NULL);
+
+ width -= 60.0;
+
+ g_object_set (table->priv->info_text,
+ "width", width,
+ "clip_width", width,
+ NULL);
+}
+
+/**
+ * e_table_set_info_message:
+ * @table: #ETable instance
+ * @info_message: Message to set. Can be NULL.
+ *
+ * Creates an info message in table area, or removes old.
+ **/
+void
+e_table_set_info_message (ETable *table,
+ const gchar *info_message)
+{
+ GtkAllocation allocation;
+ GtkWidget *widget;
+
+ g_return_if_fail (E_IS_TABLE (table));
+
+ if (!table->priv->info_text && (!info_message || !*info_message))
+ return;
+
+ if (!info_message || !*info_message) {
+ g_signal_handler_disconnect (table, table->priv->info_text_resize_id);
+ g_object_run_dispose (G_OBJECT (table->priv->info_text));
+ table->priv->info_text = NULL;
+ return;
+ }
+
+ widget = GTK_WIDGET (table->table_canvas);
+ gtk_widget_get_allocation (widget, &allocation);
+
+ if (!table->priv->info_text) {
+ if (allocation.width > 60) {
+ table->priv->info_text = gnome_canvas_item_new (
+ GNOME_CANVAS_GROUP (gnome_canvas_root (table->table_canvas)),
+ e_text_get_type (),
+ "line_wrap", TRUE,
+ "clip", TRUE,
+ "justification", GTK_JUSTIFY_LEFT,
+ "text", info_message,
+ "width", (gdouble) allocation.width - 60.0,
+ "clip_width", (gdouble) allocation.width - 60.0,
+ NULL);
+
+ e_canvas_item_move_absolute (table->priv->info_text, 30, 30);
+
+ table->priv->info_text_resize_id = g_signal_connect_object (
+ table, "size_allocate",
+ G_CALLBACK (table_size_allocate), table, 0);
+ }
+ } else
+ gnome_canvas_item_set (table->priv->info_text, "text", info_message, NULL);
+}
diff --git a/src/e-util/e-table.h b/src/e-util/e-table.h
index 5cdc229075..3deb4b3b31 100644
--- a/src/e-util/e-table.h
+++ b/src/e-util/e-table.h
@@ -66,6 +66,7 @@
G_BEGIN_DECLS
typedef struct _ETable ETable;
+typedef struct _ETablePrivate ETablePrivate;
typedef struct _ETableClass ETableClass;
typedef struct _ETableDragSourceSite ETableDragSourceSite;
@@ -79,6 +80,8 @@ typedef enum {
struct _ETable {
GtkTable parent;
+ ETablePrivate *priv;
+
ETableModel *model;
ETableHeader *full_header, *header;
@@ -379,6 +382,8 @@ void e_table_freeze_state_change (ETable *table);
void e_table_thaw_state_change (ETable *table);
gboolean e_table_is_editing (ETable *table);
void e_table_customize_view (ETable *table);
+void e_table_set_info_message (ETable *table,
+ const gchar *info_message);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]