Use GnomeIconList instead of EIconList so we don't have to maintain an

2003-03-11  Jeffrey Stedfast  <fejj@ximian.com>

	* e-msg-composer-attachment-bar.c: Use GnomeIconList instead of
	EIconList so we don't have to maintain an exact copy/paste of
	GnomeIconList ourselves. I don't udnerstand why we ever did.

	* e-icon-list.[c,h]: Removed.

svn path=/trunk/; revision=20251
This commit is contained in:
Jeffrey Stedfast
2003-03-11 16:48:53 +00:00
committed by Jeffrey Stedfast
parent 2e204d829b
commit c15a1c9677
6 changed files with 72 additions and 2889 deletions

View File

@ -1,3 +1,11 @@
2003-03-11 Jeffrey Stedfast <fejj@ximian.com>
* e-msg-composer-attachment-bar.c: Use GnomeIconList instead of
EIconList so we don't have to maintain an exact copy/paste of
GnomeIconList ourselves. I don't udnerstand why we ever did.
* e-icon-list.[c,h]: Removed.
2003-03-11 Not Zed <NotZed@Ximian.com>
* evolution-composer.c (evolution_composer_new): add

View File

@ -84,8 +84,6 @@ libcomposer_la_SOURCES = \
e-msg-composer-select-file.h \
e-msg-composer.c \
e-msg-composer.h \
e-icon-list.c \
e-icon-list.h \
evolution-composer.c \
evolution-composer.h \
listener.c \

File diff suppressed because it is too large Load Diff

View File

@ -1,181 +0,0 @@
/*
* Copyright (C) 1998, 1999 Free Software Foundation
* Copyright (C) 2000 Red Hat, Inc.
* All rights reserved.
*
* This file is part of the Gnome Library.
*
* The Gnome Library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* The Gnome Library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with the Gnome Library; see the file COPYING.LIB. If not,
* write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
@NOTATION@
*/
/* GnomeIconList widget - scrollable icon list
*
*
* Authors:
* Federico Mena <federico@ximian.com>
* Miguel de Icaza <miguel@ximian.com>
*/
#ifndef _E_ICON_LIST_H_
#define _E_ICON_LIST_H_
#include <libgnomecanvas/gnome-canvas.h>
#ifdef __cplusplus
extern "C" {
#pragma }
#endif /* __cplusplus */
#define E_TYPE_ICON_LIST (e_icon_list_get_type ())
#define E_ICON_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_ICON_LIST, EIconList))
#define E_ICON_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_ICON_LIST, EIconListClass))
#define E_IS_ICON_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_ICON_LIST))
#define E_IS_ICON_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_ICON_LIST))
#define E_ICON_LIST_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), E_TYPE_ICON_LIST, EIconListClass))
typedef struct _EIconList EIconList;
typedef struct _EIconListPrivate EIconListPrivate;
typedef struct _EIconListClass EIconListClass;
typedef enum {
E_ICON_LIST_ICONS,
E_ICON_LIST_TEXT_BELOW,
E_ICON_LIST_TEXT_RIGHT
} EIconListMode;
/* This structure has been converted to use public and private parts. To avoid
* breaking binary compatibility, the slots for private fields have been
* replaced with padding. Please remove these fields when gnome-libs has
* reached another major version and it is "fine" to break binary compatibility.
*/
struct _EIconList {
GnomeCanvas canvas;
/*< private >*/
EIconListPrivate * _priv;
};
struct _EIconListClass {
GnomeCanvasClass parent_class;
void (*select_icon) (EIconList *gil, gint num, GdkEvent *event);
void (*unselect_icon) (EIconList *gil, gint num, GdkEvent *event);
gboolean (*text_changed) (EIconList *gil, gint num, const char *new_text);
};
enum {
E_ICON_LIST_IS_EDITABLE = 1 << 0,
E_ICON_LIST_STATIC_TEXT = 1 << 1
};
GType e_icon_list_get_type (void) G_GNUC_CONST;
GtkWidget *e_icon_list_new (guint icon_width,
int flags);
void e_icon_list_construct (EIconList *gil,
guint icon_width,
int flags);
/* To avoid excesive recomputes during insertion/deletion */
void e_icon_list_freeze (EIconList *gil);
void e_icon_list_thaw (EIconList *gil);
void e_icon_list_insert (EIconList *gil,
int idx,
const char *icon_filename,
const char *text);
void e_icon_list_insert_pixbuf (EIconList *gil,
int idx,
GdkPixbuf *im,
const char *icon_filename,
const char *text);
int e_icon_list_append (EIconList *gil,
const char *icon_filename,
const char *text);
int e_icon_list_append_pixbuf (EIconList *gil,
GdkPixbuf *im,
const char *icon_filename,
const char *text);
void e_icon_list_clear (EIconList *gil);
void e_icon_list_remove (EIconList *gil,
int idx);
guint e_icon_list_get_num_icons (EIconList *gil);
/* Managing the selection */
void e_icon_list_set_selection_mode (EIconList *gil,
GtkSelectionMode mode);
void e_icon_list_select_icon (EIconList *gil,
int idx);
void e_icon_list_unselect_icon (EIconList *gil,
int idx);
int e_icon_list_unselect_all (EIconList *gil);
GList * e_icon_list_get_selection (EIconList *gil);
/* Setting the spacing values */
void e_icon_list_set_icon_width (EIconList *gil,
int w);
void e_icon_list_set_row_spacing (EIconList *gil,
int pixels);
void e_icon_list_set_col_spacing (EIconList *gil,
int pixels);
void e_icon_list_set_text_spacing (EIconList *gil,
int pixels);
void e_icon_list_set_icon_border (EIconList *gil,
int pixels);
void e_icon_list_set_separators (EIconList *gil,
const char *sep);
/* Icon filename. */
gchar * e_icon_list_get_icon_filename (EIconList *gil,
int idx);
int e_icon_list_find_icon_from_filename (EIconList *gil,
const char *filename);
/* Attaching information to the icons */
void e_icon_list_set_icon_data (EIconList *gil,
int idx, gpointer data);
void e_icon_list_set_icon_data_full (EIconList *gil,
int idx, gpointer data,
GtkDestroyNotify destroy);
int e_icon_list_find_icon_from_data (EIconList *gil,
gpointer data);
gpointer e_icon_list_get_icon_data (EIconList *gil,
int idx);
/* Visibility */
void e_icon_list_moveto (EIconList *gil,
int idx, double yalign);
GtkVisibility e_icon_list_icon_is_visible (EIconList *gil,
int idx);
int e_icon_list_get_icon_at (EIconList *gil,
int x, int y);
int e_icon_list_get_items_per_line (EIconList *gil);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _GNOME_ICON_LIST_H_ */

View File

@ -42,8 +42,6 @@
#include "e-msg-composer-attachment.h"
#include "e-msg-composer-attachment-bar.h"
#include "e-icon-list.h"
#include <gal/util/e-iconv.h>
#include "camel/camel-data-wrapper.h"
@ -53,7 +51,7 @@
#include "camel/camel-mime-filter-bestenc.h"
#include "camel/camel-mime-part.h"
#define ICON_WIDTH 64
#define ICON_SEPARATORS " /-_"
#define ICON_SPACING 2
@ -63,7 +61,7 @@
#define ICON_TEXT_SPACING 2
static EIconListClass *parent_class = NULL;
static GnomeIconListClass *parent_class = NULL;
struct _EMsgComposerAttachmentBarPrivate {
GList *attachments;
@ -264,21 +262,21 @@ static void
update (EMsgComposerAttachmentBar *bar)
{
EMsgComposerAttachmentBarPrivate *priv;
EIconList *icon_list;
GnomeIconList *icon_list;
GList *p;
priv = bar->priv;
icon_list = E_ICON_LIST (bar);
icon_list = GNOME_ICON_LIST (bar);
e_icon_list_freeze (icon_list);
gnome_icon_list_freeze (icon_list);
e_icon_list_clear (icon_list);
gnome_icon_list_clear (icon_list);
/* FIXME could be faster, but we don't care. */
for (p = priv->attachments; p != NULL; p = p->next) {
EMsgComposerAttachment *attachment;
gchar *size_string, *label;
CamelContentType *content_type;
char *size_string, *label;
GdkPixbuf *pixbuf;
gboolean image;
const char *desc;
@ -374,15 +372,14 @@ update (EMsgComposerAttachmentBar *bar)
label = g_strdup (desc);
if (image) {
e_icon_list_append_pixbuf (icon_list, attachment->pixbuf_cache, NULL, label);
gnome_icon_list_append_pixbuf (icon_list, attachment->pixbuf_cache, NULL, label);
} else {
char *mime_type;
mime_type = header_content_type_simple (content_type);
pixbuf = pixbuf_for_mime_type (mime_type);
g_free (mime_type);
e_icon_list_append_pixbuf (icon_list, pixbuf,
NULL, label);
gnome_icon_list_append_pixbuf (icon_list, pixbuf, NULL, label);
if (pixbuf)
g_object_unref (pixbuf);
}
@ -390,30 +387,28 @@ update (EMsgComposerAttachmentBar *bar)
g_free (label);
}
e_icon_list_thaw (icon_list);
gnome_icon_list_thaw (icon_list);
}
static void
remove_selected (EMsgComposerAttachmentBar *bar)
{
EIconList *icon_list;
GnomeIconList *icon_list;
EMsgComposerAttachment *attachment;
GList *attachment_list;
GList *p;
gint num;
GList *attachment_list, *p;
int num;
icon_list = E_ICON_LIST (bar);
icon_list = GNOME_ICON_LIST (bar);
/* Weee! I am especially proud of this piece of cheesy code: it is
truly awful. But unless one attaches a huge number of files, it
will not be as greedy as intended. FIXME of course. */
attachment_list = NULL;
p = e_icon_list_get_selection (icon_list);
for (; p != NULL; p = p->next) {
p = gnome_icon_list_get_selection (icon_list);
for ( ; p != NULL; p = p->next) {
num = GPOINTER_TO_INT (p->data);
attachment = E_MSG_COMPOSER_ATTACHMENT
(g_list_nth (bar->priv->attachments, num)->data);
attachment = E_MSG_COMPOSER_ATTACHMENT (g_list_nth (bar->priv->attachments, num)->data);
attachment_list = g_list_prepend (attachment_list, attachment);
}
@ -428,14 +423,14 @@ remove_selected (EMsgComposerAttachmentBar *bar)
static void
edit_selected (EMsgComposerAttachmentBar *bar)
{
EIconList *icon_list;
GnomeIconList *icon_list;
EMsgComposerAttachment *attachment;
GList *selection;
gint num;
int num;
icon_list = E_ICON_LIST (bar);
icon_list = GNOME_ICON_LIST (bar);
selection = e_icon_list_get_selection (icon_list);
selection = gnome_icon_list_get_selection (icon_list);
num = GPOINTER_TO_INT (selection->data);
attachment = g_list_nth (bar->priv->attachments, num)->data;
@ -591,19 +586,19 @@ button_press_event (GtkWidget *widget,
GdkEventButton *event)
{
EMsgComposerAttachmentBar *bar;
EIconList *icon_list;
GnomeIconList *icon_list;
int icon_number;
bar = E_MSG_COMPOSER_ATTACHMENT_BAR (widget);
icon_list = E_ICON_LIST (widget);
icon_list = GNOME_ICON_LIST (widget);
if (event->button != 3)
return GTK_WIDGET_CLASS (parent_class)->button_press_event (widget, event);
icon_number = e_icon_list_get_icon_at (icon_list, event->x, event->y);
icon_number = gnome_icon_list_get_icon_at (icon_list, event->x, event->y);
if (icon_number >= 0) {
e_icon_list_select_icon (icon_list, icon_number);
gnome_icon_list_select_icon (icon_list, icon_number);
popup_icon_context_menu (bar, icon_number, event);
} else {
popup_context_menu (bar, event);
@ -616,17 +611,17 @@ button_press_event (GtkWidget *widget,
/* Initialization. */
static void
class_init (EMsgComposerAttachmentBarClass *class)
class_init (EMsgComposerAttachmentBarClass *klass)
{
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
EIconListClass *icon_list_class;
GnomeIconListClass *icon_list_class;
object_class = GTK_OBJECT_CLASS (class);
widget_class = GTK_WIDGET_CLASS (class);
icon_list_class = E_ICON_LIST_CLASS (class);
object_class = GTK_OBJECT_CLASS (klass);
widget_class = GTK_WIDGET_CLASS (klass);
icon_list_class = GNOME_ICON_LIST_CLASS (klass);
parent_class = g_type_class_ref (e_icon_list_get_type ());
parent_class = g_type_class_ref (gnome_icon_list_get_type ());
object_class->destroy = destroy;
@ -648,7 +643,7 @@ static void
init (EMsgComposerAttachmentBar *bar)
{
EMsgComposerAttachmentBarPrivate *priv;
priv = g_new (EMsgComposerAttachmentBarPrivate, 1);
priv->attachments = NULL;
@ -677,7 +672,7 @@ e_msg_composer_attachment_bar_get_type (void)
(GInstanceInitFunc) init,
};
type = g_type_register_static (E_TYPE_ICON_LIST, "EMsgComposerAttachmentBar", &info, 0);
type = g_type_register_static (GNOME_TYPE_ICON_LIST, "EMsgComposerAttachmentBar", &info, 0);
}
return type;
@ -687,36 +682,36 @@ GtkWidget *
e_msg_composer_attachment_bar_new (GtkAdjustment *adj)
{
EMsgComposerAttachmentBar *new;
EIconList *icon_list;
GnomeIconList *icon_list;
int width, height, icon_width, window_height;
PangoFontMetrics *metrics;
PangoContext *context;
new = g_object_new (e_msg_composer_attachment_bar_get_type (), NULL);
icon_list = E_ICON_LIST (new);
context = gtk_widget_get_pango_context(((GtkWidget *)new));
metrics = pango_context_get_metrics(context, ((GtkWidget *)new)->style->font_desc, pango_context_get_language(context));
width = PANGO_PIXELS(pango_font_metrics_get_approximate_char_width(metrics)) * 15;
/* This should be *2, but the icon list creates too much space above ... */
height = PANGO_PIXELS(pango_font_metrics_get_ascent(metrics) + pango_font_metrics_get_descent(metrics)) * 3;
pango_font_metrics_unref(metrics);
icon_width = ICON_WIDTH + ICON_SPACING + ICON_BORDER + ICON_TEXT_SPACING;
icon_width = MAX(icon_width, width);
icon_list = GNOME_ICON_LIST (new);
context = gtk_widget_get_pango_context ((GtkWidget *) new);
metrics = pango_context_get_metrics (context, ((GtkWidget *) new)->style->font_desc, pango_context_get_language (context));
width = PANGO_PIXELS (pango_font_metrics_get_approximate_char_width (metrics)) * 15;
/* This should be *2, but the icon list creates too much space above ... */
height = PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) + pango_font_metrics_get_descent (metrics)) * 3;
pango_font_metrics_unref (metrics);
icon_width = ICON_WIDTH + ICON_SPACING + ICON_BORDER + ICON_TEXT_SPACING;
icon_width = MAX (icon_width, width);
gnome_icon_list_construct (icon_list, icon_width, adj, 0);
e_icon_list_construct (icon_list, icon_width, 0);
window_height = ICON_WIDTH + ICON_SPACING + ICON_BORDER + ICON_TEXT_SPACING + height;
gtk_widget_set_size_request (GTK_WIDGET (new), icon_width * 4, window_height);
e_icon_list_set_separators (icon_list, ICON_SEPARATORS);
e_icon_list_set_row_spacing (icon_list, ICON_ROW_SPACING);
e_icon_list_set_col_spacing (icon_list, ICON_COL_SPACING);
e_icon_list_set_icon_border (icon_list, ICON_BORDER);
e_icon_list_set_text_spacing (icon_list, ICON_TEXT_SPACING);
e_icon_list_set_selection_mode (icon_list, GTK_SELECTION_MULTIPLE);
gnome_icon_list_set_separators (icon_list, ICON_SEPARATORS);
gnome_icon_list_set_row_spacing (icon_list, ICON_ROW_SPACING);
gnome_icon_list_set_col_spacing (icon_list, ICON_COL_SPACING);
gnome_icon_list_set_icon_border (icon_list, ICON_BORDER);
gnome_icon_list_set_text_spacing (icon_list, ICON_TEXT_SPACING);
gnome_icon_list_set_selection_mode (icon_list, GTK_SELECTION_MULTIPLE);
return GTK_WIDGET (new);
}

View File

@ -24,7 +24,8 @@
#ifndef __E_MSG_COMPOSER_ATTACHMENT_BAR_H__
#define __E_MSG_COMPOSER_ATTACHMENT_BAR_H__
#include "e-icon-list.h"
#include <libgnomeui/gnome-icon-list.h>
#include <camel/camel-multipart.h>
#ifdef __cplusplus
@ -43,30 +44,30 @@ extern "C" {
#define E_IS_MSG_COMPOSER_ATTACHMENT_BAR_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_MSG_COMPOSER_ATTACHMENT_BAR))
typedef struct _EMsgComposerAttachmentBar EMsgComposerAttachmentBar;
typedef struct _EMsgComposerAttachmentBarClass EMsgComposerAttachmentBarClass;
typedef struct _EMsgComposerAttachmentBarPrivate EMsgComposerAttachmentBarPrivate;
struct _EMsgComposerAttachmentBar {
EIconList parent;
GnomeIconList parent;
EMsgComposerAttachmentBarPrivate *priv;
};
typedef struct _EMsgComposerAttachmentBar EMsgComposerAttachmentBar;
struct _EMsgComposerAttachmentBarClass {
EIconListClass parent_class;
GnomeIconListClass parent_class;
void (* changed) (EMsgComposerAttachmentBar *bar);
};
typedef struct _EMsgComposerAttachmentBarClass EMsgComposerAttachmentBarClass;
GtkType e_msg_composer_attachment_bar_get_type (void);
GtkWidget *e_msg_composer_attachment_bar_new (GtkAdjustment *adj);
void e_msg_composer_attachment_bar_to_multipart (EMsgComposerAttachmentBar *bar, CamelMultipart *multipart,
const char *default_charset);
guint e_msg_composer_attachment_bar_get_num_attachments (EMsgComposerAttachmentBar *bar);
void e_msg_composer_attachment_bar_attach (EMsgComposerAttachmentBar *bar, const gchar *file_name);
void e_msg_composer_attachment_bar_attach (EMsgComposerAttachmentBar *bar, const char *file_name);
void e_msg_composer_attachment_bar_attach_mime_part (EMsgComposerAttachmentBar *bar, CamelMimePart *part);
#ifdef __cplusplus