aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2002-11-25 08:12:09 +0800
committerMichael Zucci <zucchi@src.gnome.org>2002-11-25 08:12:09 +0800
commit2fd9ea3c7ee9d1847c9c0fed6538f95a284a301c (patch)
tree40d8477d2c687e5ffb6531cb956d8fa8cc75c995
parentbc01d3ac62f6f65f4d04ec439fc1ade0a355f879 (diff)
downloadgsoc2013-evolution-2fd9ea3c7ee9d1847c9c0fed6538f95a284a301c.tar
gsoc2013-evolution-2fd9ea3c7ee9d1847c9c0fed6538f95a284a301c.tar.gz
gsoc2013-evolution-2fd9ea3c7ee9d1847c9c0fed6538f95a284a301c.tar.bz2
gsoc2013-evolution-2fd9ea3c7ee9d1847c9c0fed6538f95a284a301c.tar.lz
gsoc2013-evolution-2fd9ea3c7ee9d1847c9c0fed6538f95a284a301c.tar.xz
gsoc2013-evolution-2fd9ea3c7ee9d1847c9c0fed6538f95a284a301c.tar.zst
gsoc2013-evolution-2fd9ea3c7ee9d1847c9c0fed6538f95a284a301c.zip
rewrote most of this. Just use gtkfileselection directly, no
2002-11-22 Not Zed <NotZed@Ximian.com> * e-msg-composer-select-file.c: rewrote most of this. Just use gtkfileselection directly, no e-file-selector, much smaller/simpler. 2002-11-21 Not Zed <NotZed@Ximian.com> * e-msg-composer-attachment-bar.c (remove_attachment): fix g_signal_emit params, detail in wrong spot. (add_common): Same. * e-icon-list.c (icon_new_from_pixbuf): remove the 'use_broken_event_handling' set. (emit_select): Add detail to signal emit. (text_changed): Same. * e-msg-composer.c (subject_changed_cb): Duh! dont free subject & simplify logic a little. svn path=/trunk/; revision=18904
-rw-r--r--composer/ChangeLog15
-rw-r--r--composer/e-icon-list.c18
-rw-r--r--composer/e-msg-composer-attachment-bar.c6
-rw-r--r--composer/e-msg-composer-select-file.c275
4 files changed, 91 insertions, 223 deletions
diff --git a/composer/ChangeLog b/composer/ChangeLog
index 68bb062759..fae9f682d1 100644
--- a/composer/ChangeLog
+++ b/composer/ChangeLog
@@ -1,5 +1,20 @@
+2002-11-22 Not Zed <NotZed@Ximian.com>
+
+ * e-msg-composer-select-file.c: rewrote most of this. Just use
+ gtkfileselection directly, no e-file-selector, much
+ smaller/simpler.
+
2002-11-21 Not Zed <NotZed@Ximian.com>
+ * e-msg-composer-attachment-bar.c (remove_attachment): fix
+ g_signal_emit params, detail in wrong spot.
+ (add_common): Same.
+
+ * e-icon-list.c (icon_new_from_pixbuf): remove the
+ 'use_broken_event_handling' set.
+ (emit_select): Add detail to signal emit.
+ (text_changed): Same.
+
* e-msg-composer.c (subject_changed_cb): Duh! dont free subject &
simplify logic a little.
diff --git a/composer/e-icon-list.c b/composer/e-icon-list.c
index 561cd3f81f..4b198e56aa 100644
--- a/composer/e-icon-list.c
+++ b/composer/e-icon-list.c
@@ -530,6 +530,7 @@ emit_select (Eil *eil, int sel, int i, GdkEvent *event)
{
g_signal_emit (eil,
eil_signals[sel ? SELECT_ICON : UNSELECT_ICON],
+ 0,
i,
event);
}
@@ -941,7 +942,7 @@ text_changed (GnomeCanvasItem *item, Icon *icon)
idx = eil_icon_to_index (eil, icon);
g_signal_emit (GTK_OBJECT (eil),
- eil_signals[TEXT_CHANGED],
+ eil_signals[TEXT_CHANGED], 0,
idx, gnome_icon_text_item_get_text (icon->text),
&accept);
@@ -1012,10 +1013,6 @@ icon_new_from_pixbuf (EIconList *eil, GdkPixbuf *im,
gnome_icon_text_item_get_type (),
NULL));
- gnome_canvas_item_set (GNOME_CANVAS_ITEM (icon->text),
- "use_broken_event_handling", FALSE,
- NULL);
-
/* FIXME: Use GTK+ font. */
gnome_icon_text_item_configure (icon->text,
0, 0, priv->icon_width,
@@ -1980,12 +1977,6 @@ eil_init (Eil *eil)
eil->_priv->selection_mode = GTK_SELECTION_SINGLE;
eil->_priv->dirty = TRUE;
-
-#if 0
- /* FIXME: This needs to be moved into a constructor because of gtklayout changes? */
- gnome_canvas_set_scroll_region (GNOME_CANVAS (eil), 0.0, 0.0, 1000000.0, 1000000.0);
- gnome_canvas_scroll_to (GNOME_CANVAS (eil), 0, 0);
-#endif
}
/**
@@ -2049,7 +2040,6 @@ e_icon_list_set_icon_width (EIconList *eil, int w)
eil_scrollbar_adjust (eil);
}
-
/**
* e_icon_list_construct:
* @eil: An icon list.
@@ -2071,8 +2061,10 @@ e_icon_list_construct (EIconList *eil, guint icon_width, int flags)
e_icon_list_set_icon_width (eil, icon_width);
priv->is_editable = (flags & E_ICON_LIST_IS_EDITABLE) != 0;
priv->static_text = (flags & E_ICON_LIST_STATIC_TEXT) != 0;
-}
+ gnome_canvas_set_scroll_region (GNOME_CANVAS (eil), 0.0, 0.0, 1000000.0, 1000000.0);
+ gnome_canvas_scroll_to (GNOME_CANVAS (eil), 0, 0);
+}
/**
* e_icon_list_new: [constructor]
diff --git a/composer/e-msg-composer-attachment-bar.c b/composer/e-msg-composer-attachment-bar.c
index 7f51203b15..01438e82a8 100644
--- a/composer/e-msg-composer-attachment-bar.c
+++ b/composer/e-msg-composer-attachment-bar.c
@@ -148,7 +148,7 @@ add_common (EMsgComposerAttachmentBar *bar,
update (bar);
- g_signal_emit (bar, 0, signals[CHANGED]);
+ g_signal_emit (bar, signals[CHANGED], 0);
}
static void
@@ -194,7 +194,7 @@ remove_attachment (EMsgComposerAttachmentBar *bar,
g_object_unref(attachment);
- g_signal_emit (GTK_OBJECT (bar), 0, signals[CHANGED]);
+ g_signal_emit (bar, signals[CHANGED], 0);
}
@@ -664,6 +664,8 @@ init (EMsgComposerAttachmentBar *bar)
#warning "FIXME: check icon_hight calculation with pango_font"
icon_height = icon_size + pango_font_description_get_size(GTK_WIDGET (bar)->style->font_desc)*2;
icon_size += 24;
+
+ printf("set size %d,%d\n", icon_size*4, icon_height);
gtk_widget_set_size_request (GTK_WIDGET (bar), icon_size * 4, icon_height);
}
diff --git a/composer/e-msg-composer-select-file.c b/composer/e-msg-composer-select-file.c
index 6e5fa20afb..c70178737a 100644
--- a/composer/e-msg-composer-select-file.c
+++ b/composer/e-msg-composer-select-file.c
@@ -2,6 +2,7 @@
/*
* Authors: Ettore Perazzoli <ettore@ximian.com>
* Jeffrey Stedfast <fejj@ximian.com>
+ * Michael Zucchi <notzed@ximian.com>
*
* Copyright 2002 Ximian, Inc. (www.ximian.com)
*
@@ -31,213 +32,55 @@
#include <gtk/gtkfilesel.h>
#include <gtk/gtkmain.h>
#include <gtk/gtksignal.h>
-#include <gal/widgets/e-file-selection.h>
#include <libgnomeui/gnome-uidefs.h>
#include <libgnomeui/gnome-window-icon.h>
#include "e-msg-composer-select-file.h"
-
-typedef struct _FileSelectionInfo {
- GtkWidget *widget;
- GtkToggleButton *inline_checkbox;
- gboolean multiple;
- GPtrArray *selected_files;
-} FileSelectionInfo;
-
-static void
-confirm (FileSelectionInfo *info)
-{
- char **file_list;
- int i;
-
- file_list = e_file_selection_get_filenames (E_FILE_SELECTION (info->widget));
-
- if (!info->selected_files)
- info->selected_files = g_ptr_array_new ();
-
- for (i = 0; file_list[i]; i++)
- g_ptr_array_add (info->selected_files, file_list[i]);
-
- g_free (file_list);
-
- gtk_widget_hide (info->widget);
-
- gtk_main_quit ();
-}
-
-static void
-cancel (FileSelectionInfo *info)
-{
- g_assert (info->selected_files == NULL);
-
- gtk_widget_hide (info->widget);
-
- gtk_main_quit ();
-}
-
-
-/* Callbacks. */
-
-static void
-ok_clicked_cb (GtkWidget *widget, void *data)
-{
- FileSelectionInfo *info;
-
- info = (FileSelectionInfo *) data;
- confirm (info);
-}
-
-static void
-cancel_clicked_cb (GtkWidget *widget, void *data)
-{
- FileSelectionInfo *info;
-
- info = (FileSelectionInfo *) data;
- cancel (info);
-}
-
-static int
-delete_event_cb (GtkWidget *widget, GdkEventAny *event, void *data)
-{
- FileSelectionInfo *info;
-
- info = (FileSelectionInfo *) data;
- cancel (info);
-
- return TRUE;
-}
-
-static void
-composer_hide_cb (GtkWidget *widget, gpointer user_data)
-{
- FileSelectionInfo *info;
-
- info = (FileSelectionInfo *) user_data;
- if (GTK_WIDGET_VISIBLE (info->widget))
- cancel (info);
-}
-
-/* Setup. */
-
-static FileSelectionInfo *
-create_file_selection (EMsgComposer *composer, gboolean multiple)
+static GtkFileSelection *
+run_selector(EMsgComposer *composer, const char *title, int multi, gboolean *showinline_p)
{
- FileSelectionInfo *info;
- GtkWidget *widget;
- GtkWidget *ok_button;
- GtkWidget *cancel_button;
- GtkWidget *inline_checkbox;
- GtkWidget *box;
+ GtkFileSelection *selection;
+ GtkWidget *showinline = NULL;
+ GPtrArray *list = NULL;
char *path;
-
- info = g_new (FileSelectionInfo, 1);
-
- widget = e_file_selection_new (NULL);
- gtk_window_set_wmclass (GTK_WINDOW (widget), "fileselection",
- "Evolution:composer");
- gnome_window_icon_set_from_file (GTK_WINDOW (widget), EVOLUTION_DATADIR
- "/images/evolution/compose-message.png");
-
- path = g_strdup_printf ("%s/", g_get_home_dir ());
- gtk_file_selection_set_filename (GTK_FILE_SELECTION (widget), path);
- g_free (path);
-
- gtk_object_set (GTK_OBJECT (widget), "multiple", multiple, NULL);
-
- ok_button = GTK_FILE_SELECTION (widget)->ok_button;
- cancel_button = GTK_FILE_SELECTION (widget)->cancel_button;
-
- g_signal_connect((ok_button),
- "clicked", G_CALLBACK (ok_clicked_cb), info);
- g_signal_connect((cancel_button),
- "clicked", G_CALLBACK (cancel_clicked_cb), info);
- g_signal_connect((widget), "delete_event",
- G_CALLBACK (delete_event_cb), info);
-
- g_signal_connect((composer), "hide",
- G_CALLBACK (composer_hide_cb), info);
-
- inline_checkbox = gtk_check_button_new_with_label (_("Suggest automatic display of attachment"));
- box = gtk_widget_get_ancestor (GTK_FILE_SELECTION (widget)->selection_entry, GTK_TYPE_BOX);
- gtk_box_pack_end (GTK_BOX (box), inline_checkbox, FALSE, FALSE, 4);
-
- info->widget = widget;
- info->multiple = multiple;
- info->selected_files = NULL;
- info->inline_checkbox = GTK_TOGGLE_BUTTON (inline_checkbox);
-
- return info;
-}
-static void
-file_selection_info_destroy_notify (void *data)
-{
- FileSelectionInfo *info;
- int i;
-
- info = (FileSelectionInfo *) data;
-
- if (info->widget != NULL)
- gtk_widget_destroy (GTK_WIDGET (info->widget));
-
- if (info->selected_files) {
- for (i = 0; i < info->selected_files->len; i++)
- g_free (info->selected_files->pdata[i]);
-
- g_ptr_array_free (info->selected_files, TRUE);
+ selection = (GtkFileSelection *)gtk_file_selection_new(title);
+ gtk_window_set_transient_for((GtkWindow *)selection, (GtkWindow *)composer);
+ gtk_window_set_wmclass((GtkWindow *)selection, "fileselection", "Evolution:composer");
+ gtk_window_set_modal((GtkWindow *)selection, TRUE);
+ gnome_window_icon_set_from_file((GtkWindow *)selection, EVOLUTION_DATADIR "/images/evolution/compose-message.png");
+ gtk_file_selection_set_select_multiple((GtkFileSelection *)selection, multi);
+
+ /* restore last path used */
+ path = g_object_get_data((GObject *)composer, "attach_path");
+ if (path == NULL) {
+ path = g_strdup_printf("%s/", g_get_home_dir());
+ gtk_file_selection_set_filename(selection, path);
+ g_free(path);
+ } else {
+ gtk_file_selection_set_filename(selection, path);
}
-
- g_free (info);
-}
-
-static GPtrArray *
-select_file_internal (EMsgComposer *composer,
- const char *title,
- gboolean multiple,
- gboolean *inline_p)
-{
- FileSelectionInfo *info;
- GPtrArray *files;
-
- g_return_val_if_fail (E_IS_MSG_COMPOSER (composer), NULL);
-
- info = gtk_object_get_data (GTK_OBJECT (composer),
- "e-msg-composer-file-selection-info");
-
- if (info == NULL) {
- info = create_file_selection (composer, multiple);
- gtk_object_set_data_full (GTK_OBJECT (composer),
- "e-msg-composer-file-selection-info", info,
- file_selection_info_destroy_notify);
- gtk_window_set_modal((GtkWindow *)info->widget, TRUE);
+ if (showinline_p) {
+ showinline = gtk_check_button_new_with_label (_("Suggest automatic display of attachment"));
+ gtk_widget_show (showinline);
+ gtk_box_pack_end (GTK_BOX (selection->main_vbox), showinline, FALSE, FALSE, 4);
}
-
- if (GTK_WIDGET_VISIBLE (info->widget))
- return NULL; /* Busy! */
-
- gtk_window_set_title (GTK_WINDOW (info->widget), title);
- if (inline_p)
- gtk_widget_show (GTK_WIDGET (info->inline_checkbox));
- else
- gtk_widget_hide (GTK_WIDGET (info->inline_checkbox));
- gtk_widget_show (info->widget);
-
- GDK_THREADS_ENTER();
- gtk_main ();
- GDK_THREADS_LEAVE();
-
- files = info->selected_files;
- info->selected_files = NULL;
-
- if (inline_p) {
- *inline_p = gtk_toggle_button_get_active (info->inline_checkbox);
- gtk_toggle_button_set_active (info->inline_checkbox, FALSE);
+
+ if (gtk_dialog_run((GtkDialog *)selection) == GTK_RESPONSE_OK) {
+ if (showinline_p)
+ *showinline_p = gtk_toggle_button_get_active((GtkToggleButton *)showinline);
+ path = g_path_get_dirname(gtk_file_selection_get_filename(selection));
+ g_object_set_data_full((GObject *)composer, "attach_path", g_strdup_printf("%s/", path), g_free);
+ g_free(path);
+ } else {
+ gtk_widget_destroy((GtkWidget *)selection);
+ selection = NULL;
}
-
- return files;
+
+ return selection;
}
/**
@@ -252,24 +95,40 @@ select_file_internal (EMsgComposer *composer,
* cancelled.
**/
char *
-e_msg_composer_select_file (EMsgComposer *composer,
- const char *title)
+e_msg_composer_select_file (EMsgComposer *composer, const char *title)
{
- GPtrArray *files;
- char *filename = NULL;
-
- files = select_file_internal (composer, title, FALSE, NULL);
- if (files) {
- filename = files->pdata[0];
- g_ptr_array_free (files, FALSE);
+ GtkFileSelection *selection;
+ char *name = NULL;
+
+ selection = run_selector(composer, _("Attach file(s)"), TRUE, NULL);
+ if (selection) {
+ name = g_strdup(gtk_file_selection_get_filename(selection));
+ gtk_widget_destroy((GtkWidget *)selection);
}
-
- return filename;
+
+ return name;
}
GPtrArray *
-e_msg_composer_select_file_attachments (EMsgComposer *composer,
- gboolean *inline_p)
+e_msg_composer_select_file_attachments (EMsgComposer *composer, gboolean *showinline_p)
{
- return select_file_internal (composer, _("Attach a file"), TRUE, inline_p);
+ GtkFileSelection *selection;
+ GPtrArray *list = NULL;
+ char **files;
+ int i;
+
+ selection = run_selector(composer, _("Attach file(s)"), TRUE, showinline_p);
+ if (selection) {
+
+ list = g_ptr_array_new();
+ files = gtk_file_selection_get_selections(selection);
+ for (i=0;files[i];i++)
+ g_ptr_array_add(list, g_strdup(files[i]));
+
+ g_strfreev(files);
+ gtk_widget_destroy((GtkWidget *)selection);
+ }
+
+ return list;
}
+