aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/table/e-tree.c
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2008-04-30 19:24:14 +0800
committerMilan Crha <mcrha@src.gnome.org>2008-04-30 19:24:14 +0800
commit183729a6e097be1959bf66507f2bc140cc17cd75 (patch)
tree6ff50e9e7b2cb7797e3e32f9796b2259395eaf54 /widgets/table/e-tree.c
parentbe98f84cbdf8536fe980e3b4216085003fcbce1e (diff)
downloadgsoc2013-evolution-183729a6e097be1959bf66507f2bc140cc17cd75.tar.gz
gsoc2013-evolution-183729a6e097be1959bf66507f2bc140cc17cd75.tar.zst
gsoc2013-evolution-183729a6e097be1959bf66507f2bc140cc17cd75.zip
** Fix for bug #528288
2008-04-30 Milan Crha <mcrha@redhat.com> ** Fix for bug #528288 * widgets/misc/e-filter-bar.c: (get_property): Do not return any query with empty text from search bar. * widgets/table/e-tree.h: (e_tree_set_info_message): * widgets/table/e-tree.c: (struct ETreePriv), (et_dispose), (e_tree_init), (tree_size_allocate), (e_tree_set_info_message): Allow setting info message into the tree. It doesn't check whether the tree is empty or not, so take care of that. * mail/em-folder-browser.c: (emfb_init), (em_folder_browser_show_wide): Ensure minimum size for preview and message list. * mail/em-folder-browser.c: (get_view_query): Distinguish between no filter and custom filter. * mail/message-list.c: (regen_list_done): Set info message to tree when no message shown in a list. svn path=/trunk/; revision=35459
Diffstat (limited to 'widgets/table/e-tree.c')
-rw-r--r--widgets/table/e-tree.c71
1 files changed, 71 insertions, 0 deletions
diff --git a/widgets/table/e-tree.c b/widgets/table/e-tree.c
index 7617f25f05..631824a86b 100644
--- a/widgets/table/e-tree.c
+++ b/widgets/table/e-tree.c
@@ -36,7 +36,9 @@
#include "e-util/e-util.h"
#include "e-util/e-util-marshal.h"
#include "misc/e-canvas.h"
+#include "misc/e-canvas-utils.h"
#include "misc/e-canvas-background.h"
+#include "text/e-text.h"
#include "e-table-column-specification.h"
#include "e-table-header-item.h"
@@ -139,6 +141,9 @@ struct ETreePriv {
int table_cell_change_id;
int table_rows_delete_id;
+ GnomeCanvasItem *info_text;
+ guint info_text_resize_id;
+
GnomeCanvas *header_canvas, *table_canvas;
GnomeCanvasItem *header_item, *root;
@@ -421,6 +426,11 @@ et_dispose (GObject *object)
g_object_weak_unref (G_OBJECT(et->priv->last_drop_context), context_destroyed, et);
et->priv->last_drop_context = NULL;
+ if (et->priv->info_text)
+ gtk_object_destroy (GTK_OBJECT (et->priv->info_text));
+ et->priv->info_text = NULL;
+ et->priv->info_text_resize_id = 0;
+
gtk_widget_destroy (GTK_WIDGET (et->priv->table_canvas));
g_free(et->priv);
@@ -597,6 +607,9 @@ e_tree_init (ETree *e_tree)
#endif
e_tree->priv->spec = NULL;
+ e_tree->priv->info_text = NULL;
+ e_tree->priv->info_text_resize_id = 0;
+
e_tree->priv->header_canvas = NULL;
e_tree->priv->table_canvas = NULL;
@@ -3363,3 +3376,61 @@ e_tree_class_init (ETreeClass *class)
gal_a11y_e_tree_init ();
}
+static void
+tree_size_allocate (GtkWidget *widget, GtkAllocation *alloc, ETree *tree)
+{
+ double width;
+
+ g_return_if_fail (tree != NULL);
+ g_return_if_fail (tree->priv != NULL);
+ g_return_if_fail (tree->priv->info_text != NULL);
+
+ gnome_canvas_get_scroll_region (GNOME_CANVAS (tree->priv->table_canvas), NULL, NULL, &width, NULL);
+
+ width -= 60.0;
+
+ g_object_set (tree->priv->info_text, "width", width, "clip_width", width, NULL);
+}
+
+/**
+ * e_tree_set_info_message:
+ * @tree: #ETree instance
+ * @info_message: Message to set. Can be NULL.
+ *
+ * Creates an info message in table area, or removes old.
+ **/
+void
+e_tree_set_info_message (ETree *tree, const char *info_message)
+{
+ g_return_if_fail (tree != NULL);
+ g_return_if_fail (tree->priv != NULL);
+
+ if (!tree->priv->info_text && (!info_message || !*info_message))
+ return;
+
+ if (!info_message || !*info_message) {
+ g_signal_handler_disconnect (tree, tree->priv->info_text_resize_id);
+ gtk_object_destroy (GTK_OBJECT (tree->priv->info_text));
+ tree->priv->info_text = NULL;
+ return;
+ }
+
+ if (!tree->priv->info_text) {
+ tree->priv->info_text = gnome_canvas_item_new (GNOME_CANVAS_GROUP (gnome_canvas_root (tree->priv->table_canvas)),
+ e_text_get_type (),
+ "anchor", GTK_ANCHOR_NW,
+ "line_wrap", TRUE,
+ "clip", TRUE,
+ "justification", GTK_JUSTIFY_LEFT,
+ "text", info_message,
+ "draw_background", FALSE,
+ "width", (double) GTK_WIDGET (tree->priv->table_canvas)->allocation.width - 60.0,
+ "clip_width", (double) GTK_WIDGET (tree->priv->table_canvas)->allocation.width - 60.0,
+ NULL);
+
+ e_canvas_item_move_absolute (tree->priv->info_text, 30, 30);
+
+ tree->priv->info_text_resize_id = g_signal_connect (tree, "size_allocate", G_CALLBACK (tree_size_allocate), tree);
+ } else
+ gnome_canvas_item_set (tree->priv->info_text, "text", info_message, NULL);
+}