aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2004-03-02 07:03:33 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2004-03-02 07:03:33 +0800
commit7d30dc9ea66f0019306f62af15eb576474cc321d (patch)
tree5948938889c01bb1717f7b924afd34b8074b3787 /mail
parentff18c9c70d7309713fa4483dd3707e9243b1af1a (diff)
downloadgsoc2013-evolution-7d30dc9ea66f0019306f62af15eb576474cc321d.tar
gsoc2013-evolution-7d30dc9ea66f0019306f62af15eb576474cc321d.tar.gz
gsoc2013-evolution-7d30dc9ea66f0019306f62af15eb576474cc321d.tar.bz2
gsoc2013-evolution-7d30dc9ea66f0019306f62af15eb576474cc321d.tar.lz
gsoc2013-evolution-7d30dc9ea66f0019306f62af15eb576474cc321d.tar.xz
gsoc2013-evolution-7d30dc9ea66f0019306f62af15eb576474cc321d.tar.zst
gsoc2013-evolution-7d30dc9ea66f0019306f62af15eb576474cc321d.zip
Connect to the folder-activated signal. (folder_activated_cb): Call
2004-03-01 Jeffrey Stedfast <fejj@ximian.com> * em-folder-selector.c (em_folder_selector_construct): Connect to the folder-activated signal. (folder_activated_cb): Call gtk_dialog_response() with GTK_RESPONSE_OK. Fixes bug #54793. * em-folder-tree.c (emft_tree_row_activated): New callback to emit the "folder-activated" signal which is needed to fix bug #54793. (emft_tree_button_press): Handle button1 double-clicks too (also for bug #54793). (emft_tree_button_press): On right-click, we also want to select the folder the user right-clicked on. Fixes bug #54772. svn path=/trunk/; revision=24928
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog14
-rw-r--r--mail/em-folder-selector.c13
-rw-r--r--mail/em-folder-tree.c64
-rw-r--r--mail/em-folder-tree.h1
4 files changed, 83 insertions, 9 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index fd0a0db56a..ed43fdc827 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,17 @@
+2004-03-01 Jeffrey Stedfast <fejj@ximian.com>
+
+ * em-folder-selector.c (em_folder_selector_construct): Connect to
+ the folder-activated signal.
+ (folder_activated_cb): Call gtk_dialog_response() with
+ GTK_RESPONSE_OK. Fixes bug #54793.
+
+ * em-folder-tree.c (emft_tree_row_activated): New callback to emit
+ the "folder-activated" signal which is needed to fix bug #54793.
+ (emft_tree_button_press): Handle button1 double-clicks too (also
+ for bug #54793).
+ (emft_tree_button_press): On right-click, we also want to select
+ the folder the user right-clicked on. Fixes bug #54772.
+
2004-02-27 Jeffrey Stedfast <fejj@ximian.com>
* em-mailer-prefs.c (em_mailer_prefs_construct): Fixed some
diff --git a/mail/em-folder-selector.c b/mail/em-folder-selector.c
index aeafa1abfc..66792f1556 100644
--- a/mail/em-folder-selector.c
+++ b/mail/em-folder-selector.c
@@ -175,6 +175,12 @@ folder_selected_cb (EMFolderTree *emft, const char *path, const char *uri, EMFol
gtk_dialog_set_response_sensitive (GTK_DIALOG (emfs), GTK_RESPONSE_OK, TRUE);
}
+static void
+folder_activated_cb (EMFolderTree *emft, const char *path, const char *uri, EMFolderSelector *emfs)
+{
+ gtk_dialog_response ((GtkDialog *) emfs, GTK_RESPONSE_OK);
+}
+
void
em_folder_selector_construct (EMFolderSelector *emfs, EMFolderTree *emft, guint32 flags, const char *title, const char *text)
{
@@ -204,6 +210,7 @@ em_folder_selector_construct (EMFolderSelector *emfs, EMFolderTree *emft, guint3
gtk_widget_show ((GtkWidget *) emft);
g_signal_connect (emfs->emft, "folder-selected", G_CALLBACK (folder_selected_cb), emfs);
+ g_signal_connect (emfs->emft, "folder-activated", G_CALLBACK (folder_activated_cb), emfs);
gtk_box_pack_end (GTK_BOX (GTK_DIALOG (emfs)->vbox), (GtkWidget *)emft, TRUE, TRUE, 6);
if (text != NULL) {
@@ -234,11 +241,11 @@ emfs_create_name_activate (GtkEntry *entry, EMFolderSelector *emfs)
{
if (emfs->name_entry->text_length > 0) {
const char *path, *text;
-
+
text = gtk_entry_get_text (emfs->name_entry);
path = em_folder_tree_get_selected_path (emfs->emft);
-
- if (text && path && !strchr(text, '/'))
+
+ if (text && path && !strchr (text, '/'))
g_signal_emit_by_name (emfs, "response", GTK_RESPONSE_OK);
}
}
diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c
index 58f6be9f60..0036de4a2c 100644
--- a/mail/em-folder-tree.c
+++ b/mail/em-folder-tree.c
@@ -83,6 +83,7 @@ struct _EMFolderTreePrivate {
};
enum {
+ FOLDER_ACTIVATED, /* aka double-clicked or user hit enter */
FOLDER_SELECTED,
LAST_SIGNAL
};
@@ -129,9 +130,10 @@ static void em_folder_tree_finalize (GObject *obj);
static gboolean emft_save_state (EMFolderTree *emft);
static void emft_queue_save_state (EMFolderTree *emft);
+static void emft_tree_row_activated (GtkTreeView *treeview, GtkTreePath *path, GtkTreeViewColumn *column, EMFolderTree *emft);
static void emft_tree_row_collapsed (GtkTreeView *treeview, GtkTreeIter *root, GtkTreePath *path, EMFolderTree *emft);
static void emft_tree_row_expanded (GtkTreeView *treeview, GtkTreeIter *root, GtkTreePath *path, EMFolderTree *emft);
-static gboolean emft_tree_button_press (GtkWidget *treeview, GdkEventButton *event, EMFolderTree *emft);
+static gboolean emft_tree_button_press (GtkTreeView *treeview, GdkEventButton *event, EMFolderTree *emft);
static void emft_tree_selection_changed (GtkTreeSelection *selection, EMFolderTree *emft);
struct _emft_selection_data {
@@ -187,6 +189,17 @@ em_folder_tree_class_init (EMFolderTreeClass *klass)
G_TYPE_NONE, 2,
G_TYPE_STRING,
G_TYPE_STRING);
+
+ signals[FOLDER_ACTIVATED] =
+ g_signal_new ("folder-activated",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (EMFolderTreeClass, folder_activated),
+ NULL, NULL,
+ em_marshal_VOID__STRING_STRING,
+ G_TYPE_NONE, 2,
+ G_TYPE_STRING,
+ G_TYPE_STRING);
}
static gboolean
@@ -395,6 +408,7 @@ em_folder_tree_construct (EMFolderTree *emft, EMFolderTreeModel *model)
g_signal_connect (priv->treeview, "row-expanded", G_CALLBACK (emft_tree_row_expanded), emft);
g_signal_connect (priv->treeview, "row-collapsed", G_CALLBACK (emft_tree_row_collapsed), emft);
+ g_signal_connect (priv->treeview, "row-activated", G_CALLBACK (emft_tree_row_activated), emft);
g_signal_connect (priv->treeview, "button-press-event", G_CALLBACK (emft_tree_button_press), emft);
selection = gtk_tree_view_get_selection ((GtkTreeView *) priv->treeview);
@@ -1551,6 +1565,30 @@ emft_tree_row_collapsed (GtkTreeView *treeview, GtkTreeIter *root, GtkTreePath *
emft_queue_save_state (emft);
}
+static void
+emft_tree_row_activated (GtkTreeView *treeview, GtkTreePath *tree_path, GtkTreeViewColumn *column, EMFolderTree *emft)
+{
+ struct _EMFolderTreePrivate *priv = emft->priv;
+ GtkTreeModel *model = (GtkTreeModel *) priv->model;
+ GtkTreeIter iter;
+ char *path, *uri;
+
+ if (!gtk_tree_model_get_iter (model, &iter, tree_path))
+ return;
+
+ gtk_tree_model_get (model, &iter, COL_STRING_FOLDER_PATH, &path,
+ COL_STRING_URI, &uri, -1);
+
+ g_free (priv->selected_uri);
+ priv->selected_uri = g_strdup (uri);
+
+ g_free (priv->selected_path);
+ priv->selected_path = g_strdup (path);
+
+ g_signal_emit (emft, signals[FOLDER_SELECTED], 0, path, uri);
+ g_signal_emit (emft, signals[FOLDER_ACTIVATED], 0, path, uri);
+}
+
#if 0
static void
emft_popup_view (GtkWidget *item, EMFolderTree *emft)
@@ -2205,13 +2243,13 @@ static EMPopupItem emft_popup_menu[] = {
};
static gboolean
-emft_tree_button_press (GtkWidget *treeview, GdkEventButton *event, EMFolderTree *emft)
+emft_tree_button_press (GtkTreeView *treeview, GdkEventButton *event, EMFolderTree *emft)
{
- struct _EMFolderTreePrivate *priv = emft->priv;
GtkTreeSelection *selection;
CamelStore *local, *store;
const char *folder_name;
EMPopupTarget *target;
+ GtkTreePath *tree_path;
GtkTreeModel *model;
GtkTreeIter iter;
GSList *menus = NULL;
@@ -2223,11 +2261,25 @@ emft_tree_button_press (GtkWidget *treeview, GdkEventButton *event, EMFolderTree
EMPopup *emp;
int i;
- if (event->button != 3)
+ if (event->button != 3 || !(event->button == 1 && event->type == GDK_2BUTTON_PRESS))
return FALSE;
+ /* select/focus the row that was right-clicked */
+ if (!gtk_tree_view_get_path_at_pos (treeview, (int) event->x, (int) event->y, &tree_path, NULL, NULL, NULL))
+ return FALSE;
+
+ gtk_tree_view_set_cursor (treeview, tree_path, NULL, FALSE);
+
+ if (event->button == 1 && event->type == GDK_2BUTTON_PRESS) {
+ emft_tree_row_activated (treeview, tree_path, NULL, emft);
+ gtk_tree_path_free (tree_path);
+ return TRUE;
+ }
+
+ gtk_tree_path_free (tree_path);
+
/* FIXME: we really need the folderinfo to build a proper menu */
- selection = gtk_tree_view_get_selection (priv->treeview);
+ selection = gtk_tree_view_get_selection (treeview);
emft_selection_get_selected (selection, &model, &iter);
gtk_tree_model_get (model, &iter, COL_POINTER_CAMEL_STORE, &store,
COL_STRING_URI, &uri, COL_STRING_FOLDER_PATH, &path,
@@ -2381,7 +2433,7 @@ em_folder_tree_set_selected (EMFolderTree *emft, const char *uri)
row = si->row;
top = NULL;
}
-
+
/* FIXME: this gets all the subfolders of our first loaded
* parent folder - ideally we'd only get what we needed, but
* it's probably not worth the effort */
diff --git a/mail/em-folder-tree.h b/mail/em-folder-tree.h
index 2742b9fe15..32f9b5518a 100644
--- a/mail/em-folder-tree.h
+++ b/mail/em-folder-tree.h
@@ -54,6 +54,7 @@ struct _EMFolderTreeClass {
GtkVBoxClass parent_class;
/* signals */
+ void (* folder_activated) (EMFolderTree *emft, const char *path, const char *uri);
void (* folder_selected) (EMFolderTree *emft, const char *path, const char *uri);
};