aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Leach <jasonleach@usa.net>2001-01-27 23:18:34 +0800
committerJacob Leach <jleach@src.gnome.org>2001-01-27 23:18:34 +0800
commitfb5ba5787face95a2feede0edeb160302810cf58 (patch)
treeb5b5231d73dbfdcac75c043018233f88e1d66013
parent1d01cfbf2ee86a307e2aadd2946a4c1af37007f8 (diff)
downloadgsoc2013-evolution-fb5ba5787face95a2feede0edeb160302810cf58.tar
gsoc2013-evolution-fb5ba5787face95a2feede0edeb160302810cf58.tar.gz
gsoc2013-evolution-fb5ba5787face95a2feede0edeb160302810cf58.tar.bz2
gsoc2013-evolution-fb5ba5787face95a2feede0edeb160302810cf58.tar.lz
gsoc2013-evolution-fb5ba5787face95a2feede0edeb160302810cf58.tar.xz
gsoc2013-evolution-fb5ba5787face95a2feede0edeb160302810cf58.tar.zst
gsoc2013-evolution-fb5ba5787face95a2feede0edeb160302810cf58.zip
cvs remove all files in shortcut-bar/, this widget is now in gal, will be
2001-01-27 Jason Leach <jasonleach@usa.net> * cvs remove all files in shortcut-bar/, this widget is now in gal, will be maintained there. * Makefile.am (SUBDIRS): Remove shortcut-bar from here. svn path=/trunk/; revision=7857
-rw-r--r--widgets/ChangeLog7
-rw-r--r--widgets/Makefile.am1
-rw-r--r--widgets/shortcut-bar/.cvsignore8
-rw-r--r--widgets/shortcut-bar/ChangeLog328
-rw-r--r--widgets/shortcut-bar/LICENSE1
-rw-r--r--widgets/shortcut-bar/Makefile.am35
-rw-r--r--widgets/shortcut-bar/e-group-bar.c1556
-rw-r--r--widgets/shortcut-bar/e-group-bar.h172
-rw-r--r--widgets/shortcut-bar/e-icon-bar-bg-item.c374
-rw-r--r--widgets/shortcut-bar/e-icon-bar-bg-item.h72
-rw-r--r--widgets/shortcut-bar/e-icon-bar.c1644
-rw-r--r--widgets/shortcut-bar/e-icon-bar.h246
-rw-r--r--widgets/shortcut-bar/e-shortcut-bar.c799
-rw-r--r--widgets/shortcut-bar/e-shortcut-bar.h138
-rw-r--r--widgets/shortcut-bar/e-shortcut-model.c556
-rw-r--r--widgets/shortcut-bar/e-shortcut-model.h139
-rw-r--r--widgets/shortcut-bar/e-vscrolled-bar.c708
-rw-r--r--widgets/shortcut-bar/e-vscrolled-bar.h97
-rw-r--r--widgets/shortcut-bar/test-shortcut-bar.c658
19 files changed, 7 insertions, 7532 deletions
diff --git a/widgets/ChangeLog b/widgets/ChangeLog
index 4b6e59b038..f12a20f3be 100644
--- a/widgets/ChangeLog
+++ b/widgets/ChangeLog
@@ -1,3 +1,10 @@
+2001-01-27 Jason Leach <jasonleach@usa.net>
+
+ * cvs remove all files in shortcut-bar/, this widget is now in
+ gal, will be maintained there.
+
+ * Makefile.am (SUBDIRS): Remove shortcut-bar from here.
+
2001-01-25 Christopher James Lahey <clahey@helixcode.com>
* menus/gal-view-menus.c: Make this actually deploy the titles
diff --git a/widgets/Makefile.am b/widgets/Makefile.am
index ef07ea89e4..b5380daa7f 100644
--- a/widgets/Makefile.am
+++ b/widgets/Makefile.am
@@ -2,5 +2,4 @@
SUBDIRS = \
misc \
meeting-time-sel \
- shortcut-bar \
menus
diff --git a/widgets/shortcut-bar/.cvsignore b/widgets/shortcut-bar/.cvsignore
deleted file mode 100644
index d59175edcd..0000000000
--- a/widgets/shortcut-bar/.cvsignore
+++ /dev/null
@@ -1,8 +0,0 @@
-*.o
-libshortcut-bar.a
-Makefile
-Makefile.in
-.deps
-.libs
-.pure
-test-shortcut-bar
diff --git a/widgets/shortcut-bar/ChangeLog b/widgets/shortcut-bar/ChangeLog
deleted file mode 100644
index c97eeef07d..0000000000
--- a/widgets/shortcut-bar/ChangeLog
+++ /dev/null
@@ -1,328 +0,0 @@
-2000-12-25 Miguel de Icaza <miguel@helixcode.com>
-
- * e-icon-bar.c (e_icon_bar_add_item): Pass draw_background = FALSE
-
-2000-09-30 Damon Chaplin <damon@helixcode.com>
-
- * test-shortcut-bar.c: updated to use new EShortcutBar signals for DnD.
-
- * e-group-bar.c (e_group_bar_add_group): show the new windows if the
- EGroupBar is realized, handle the position argument properly, and
- fixed the window z-order code.
-
- * e-shortcut-bar.c (e_shortcut_bar_add_group): pass group_num to the
- e_group_bar_add_group() function.
-
- * e-icon-bar-bg-item.c (e_icon_bar_bg_item_draw): fixed SEGV when
- trying to drag into a group with no items.
-
-2000-09-28 Ettore Perazzoli <ettore@helixcode.com>
-
- * e-shortcut-bar.c (e_shortcut_bar_destroy): Disconnect the model
- before freeing the group array.
-
-2000-09-26 Ettore Perazzoli <ettore@helixcode.com>
-
- * e-shortcut-bar.c (e_shortcut_bar_on_drag_data_delete): Emit the
- signal correctly.
-
-2000-09-25 Ettore Perazzoli <ettore@helixcode.com>
-
- * e-shortcut-bar.c (e_shortcut_bar_destroy): Call
- `e_shortcut_bar_disconnect_model()'.
- (e_shortcut_bar_on_drag_data_received): Don't add the item to the
- model here; the view is only supposed to act as a view. Rather,
- emit the "dropped_shortcut" signal appropriately.
- (e_shortcut_bar_on_drag_data_delete): Likewise, don't remove the
- item from the model and emit "shortcut_dragged".
- (e_shortcut_bar_class_init): Install the "shortcut_dropped" and
- "shortcut_dragged" signals.
-
- * e-shortcut-bar.h: New signals "shortcut_dropped",
- "shortcut_dragged". "selected_item" changed to "item_selected".
-
-2000-09-18 Christopher James Lahey <clahey@helixcode.com>
-
- * Makefile.am: Added $(EXTRA_GNOME_CFLAGS) and
- $(EXTRA_GNOME_LIBS). Removed unneeded libraries.
-
- * e-icon-bar.c, e-icon-bar.h, e-shortcut-bar.c,
- e-shortcut-model.c, test-shortcut-bar.c: Fixed the #include lines
- to deal properly with gal.
-
-2000-08-16 Larry Ewing <lewing@helixcode.com>
-
- * e-icon-bar.c (e_icon_bar_init): remove COLOR_TEXT references.
-
-2000-08-16 Larry Ewing <lewing@helixcode.com>
-
- * e-icon-bar.h (enum): get rid of COLOR_TEXT.
- (struct _EIconBarItem): add pixbuf member to hold unmodified
- pixbuf.
-
- * e-icon-bar.c (e_icon_bar_style_set): update the image and the
- colors based on the new style.
- (e_icon_bar_add_item): store the full alpha pixbuf so that we can
- update the background color if the style changes. Use the style
- colors where appropriate.
- (e_icon_bar_on_editing_stopped): revert to style colors.
- (e_icon_bar_on_editing_started): use style fg instead of
- COLOR_TEXT.
-
- * e-shortcut-bar.c (e_shortcut_bar_add_group): add an #ifndef
- E_USE_STYLES around the call to e_shortcut_bar_set_canvas_style to
- allow people to test out the style stuff that is in progress.
-
-2000-07-16 Damon Chaplin <damon@helixcode.com>
-
- * e-shortcut-model.[hc]: new files implementing a simple model for
- the shortcuts, so we can have multiple views.
-
- * Makefile.am (libshortcut_bar_a_SOURCES): added e-shortcut-model.[hc]
-
- * e-shortcut-bar.h: updated to use the model.
-
- * e-icon-bar.c (e_icon_bar_item_pressed): set mouse_over_item_num as
- well as pressed_item_num to fix bug.
-
-2000-07-10 Ettore Perazzoli <ettore@helixcode.com>
-
- * e-group-bar.c (e_group_bar_add): Set `group_bar'.
-
-2000-06-19 Damon Chaplin <damon@helixcode.com>
-
- * e-icon-bar-bg-item.c:
- * e-icon-bar.c:
- * e-icon-bar.h:
- * e-vscrolled-bar.c: added support for scroll-wheels.
-
-2000-06-02 Christopher James Lahey <clahey@helixcode.com>
-
- * e-icon-bar.c: Free all the item data.
-
-2000-06-01 Ettore Perazzoli <ettore@helixcode.com>
-
- * e-shortcut-bar.c (e_shortcut_bar_get_view_type): New function.
-
-2000-05-25 Ettore Perazzoli <ettore@helixcode.com>
-
- * e-shortcut-bar.c (e_shortcut_bar_load_image): Leak plug: free
- pathname returned from `gnome_pixmap_file()'.
-
- * Makefile.am: Add `-I$(top_srcdir)'.
-
-2000-05-24 Christopher James Lahey <clahey@helixcode.com>
-
- * Makefile.am: Added libepaned.a.
-
- * test-shortcut-bar.c: Switched from GtkPaned to EPaned.
-
-2000-05-18 Damon Chaplin <damon@helixcode.com>
-
- * e-shortcut-bar.[hc]: new signals "added_item", "removed_item",
- "added_group", "removed_group". Note that the removed signals are
- emitted just before the item/group is actually removed.
-
- * test-shortcut-bar.c: updated to test the new signals, and ref'ed
- the pixbufs in the icon callback.
-
-2000-05-16 Ettore Perazzoli <ettore@helixcode.com>
-
- * e-clipped-label.c: Moved to $(top_srcdir)/widgets/misc.
- * e-clipped-label.h: Likewise.
- * Makefile.am: Updated accordingly.
-
-2000-05-07 Larry Ewing <lewing@helixcode.com>
-
- * e-icon-bar.h (struct _EIconBarItem): remove the no longer needed
- flatened_alpha member.
-
- * e-icon-bar.c (flatten_alpha): using ~rgb can cause visual
- artifacts.
- (e_icon_bar_add_item): fixup refcounting of the flattend pixbuf,
- the canvas item should hold the reference not us. Stop using
- item.flattened_alpha since it no longer exists.
- (e_icon_bar_remove_item): remove the unref since destroying the
- item will take care of that for us.
-
- * e-shortcut-bar.c (e_shortcut_bar_add_item): make sure to unref
- the image we get back, the icon bar will hold any references it
- needs.
- (e_shortcut_bar_get_image_from_url): ref the default image each
- time we return it so that references are counted correctly.
-
-2000-05-04 Ettore Perazzoli <ettore@helixcode.com>
-
- * e-shortcut-bar.h (E_TYPE_SHORTCUT_BAR): New #define.
-
-2000-05-04 Ettore Perazzoli <ettore@helixcode.com>
-
- * e-icon-bar-bg-item.c (e_icon_bar_bg_item_draw): Initialize
- `shadow' to placate compiler.
-
- * e-icon-bar.c (e_icon_bar_add_item): @text made const-safe.
-
- * e-shortcut-bar.c (e_shortcut_bar_add_group): @group_name made
- const-safe.
- (e_shortcut_bar_add_item): @item_url and @item_name made
- const-safe.
- (e_shortcut_bar_get_image_from_url): @item_url made const-safe.
- (e_shortcut_bar_load_image): @filename made const-safe.
-
-2000-05-04 Ettore Perazzoli <ettore@helixcode.com>
-
- * test-shortcut-bar.c (icon_callback): Adapted to the new
- `EShortcutBarIconCallback' typedef: get a @data parameter and get
- a const-safe @url.
-
- * e-shortcut-bar.c (e_shortcut_bar_set_icon_callback): New param
- @data. Set `icon_callback_data' to it.
- (e_shortcut_bar_get_image_from_url): Pass the callback data to the
- callback.
-
- * e-shortcut-bar.h: Changed `EShortcutBarIconCallback' to get a
- const-safe @url parameter and a new @data parameter as a closure.
- New member `data' in `EShortcutBar'.
-
-2000-05-02 Matt Loper <matt@helixcode.com>
-
- * Makefile.am: set G_LOG_DOMAIN.
-
-2000-04-16 Damon Chaplin <damon@helixcode.com>
-
- * test-shortcut-bar.c: added buttons to test moving/reordering groups.
-
- * e-shortcut-bar.c (e_shortcut_bar_on_drag_end): new function to free
- the dragged name & URL when the drag is finished.
-
- * e-group-bar.c (e_group_bar_get_increment): fixed bug when distance
- was 0. Should just return 0.
- (e_group_bar_set_current_group_num): added animate option and finished.
- (e_group_bar_unmap): called e_group_bar_stop_all_animation().
- (e_group_bar_reorder_group): finished.
-
- * e-icon-bar-text-item.[hc]: removed, since we now use EText.
-
-2000-04-15 Miguel de Icaza <miguel@gnu.org>
-
- * e-group-bar.c (e_group_bar_realize): Do not use the parent
- thingie, because it might be like anything. And anything can be
- like any visual, and we dont like want any visual here.
-
- * e-shortcut-bar.c
- (e_shortcut_bar_add_group): Apply some loving action when it comes
- to visuals and colormaps. Yes, we got one of those machines
- --again--. Sigh. This is what you get when you have been away
- from the Indy. The whole thing is breaking left and right.
-
- Hopefully, Gtk 1.4 fixes all of this, by always running in the
- slowest visual it can find.
-
-2000-04-11 Larry Ewing <lewing@helixcode.com>
-
- * e-icon-bar.c (flatten_alpha): update for
- new gdk-pixbuf.
-
-2000-03-31 Damon Chaplin <damon@helixcode.com>
-
- * e-shortcut-bar.[hc]: added support for a
- callback function to set the icons.
-
- * test-shortcut-bar.c: updated to use the
- callback function.
-
-2000-03-30 Dan Winship <danw@helixcode.com>
-
- * e-shortcut-bar.c: Sort of use the new
- pixmaps. This code needs to be restructured, but Damon is
- rumored to already be doing it.
-
-2000-03-27 Miguel de Icaza <miguel@gnu.org>
-
- * e-icon-bar.c (flatten_alpha): New function,
- used to flatten the images we get and composite them with the
- background.
- (e_icon_bar_add_item): One happy tigert comming.
-
-2000-03-21 Christopher James Lahey <clahey@helixcode.com>
-
- * e-icon-bar.c: Updated to fix a few bugs.
-
-2000-02-28 NotZed <NotZed@HelixCode.com>
-
- * Makefile.am (test_shortcut_bar_LDADD):
- Fixed references to eutil.
-
-2000-02-20 Damon Chaplin <damon@helixcode.com>
-
- * Makefile.am: added libetext.a and libeutil.a
- to test_shortcut_bar_LDADD, and got rid of e-icon-bar-text-item.[hc].
- I'll delete these soon.
-
- * e-icon-bar.c: changed to be a subclass of
- ECanvas and to use EText instead of EIconBarTextItem. Also set
- "width_set" & "height_set" of the GnomeCanvasPixbuf items so they
- work in the "Small Icon" view.
-
- * e-vscrolled-bar.c: use map/unmap instead of
- show/hide for the up & down buttons to avoid queueing resizes.
- Otherwise the scrolling starts off a bit jerky.
-
- * test-shortcut-bar.c: output a message when the
- main label is resized, just for info.
-
- * *.[hc]: updated my email address.
-
-2000-02-07 Damon Chaplin <damon@helixcode.com>
-
- * e-group-bar.c (e_group_bar_draw): finished.
-
- * e-icon-bar.c (e_icon_bar_item_released):
- check that an item was pressed.
-
-2000-01-26 bertrand <bertrand@helixcode.com>
-
- * e-icon-bar.c (e_icon_bar_recalc_item_positions):
- don't set the x_set and y_set
- arguments as don't exist in gdk-pixbuf
- anymore.
-
-2000-01-17 Chrsitopher James Lahey <clahey@helixcode.com>
-
- * Makefile.am: Added gnomecanvaspixbuf to the
- list of libraries used.
-
-2000-01-09 Miguel de Icaza <miguel@gnu.org>
-
- * e-icon-bar.c (e_icon_bar_init): Turn on anti-aliasing.
-
-2000-01-08 Miguel de Icaza <miguel@gnu.org>
-
- * e-icon-bar.c (e_icon_bar_add_item): Use
- GdkPixbuf here.
- (e_icon_bar_get_item_image): ditto and initialize image.
-
- * e-shortcut-bar.c (e_shortcut_bar_add_item):
- Use gdk-pixbuf.
-
-2000-01-14 Christopher James Lahey <clahey@helixcode.com>
-
- * e-shortcut-bar.c (e_shortcut_bar_add_item):
- Use e_bar_set_item_data.
-
- Drop item_url; Require image argument; Require user data
- argument.
-
-2000-01-09 Miguel de Icaza <miguel@gnu.org>
-
- * e-icon-bar.c (e_icon_bar_init): Turn on anti-aliasing.
-
-2000-01-08 Miguel de Icaza <miguel@gnu.org>
-
- * e-icon-bar.c (e_icon_bar_add_item): Use
- GdkPixbuf here.
- (e_icon_bar_get_item_image): ditto and initialize image.
-
- * e-shortcut-bar.c (e_shortcut_bar_add_item):
- Use gdk-pixbuf.
-
diff --git a/widgets/shortcut-bar/LICENSE b/widgets/shortcut-bar/LICENSE
deleted file mode 100644
index f58649ad9b..0000000000
--- a/widgets/shortcut-bar/LICENSE
+++ /dev/null
@@ -1 +0,0 @@
-This code is licensed under the terms of the GNU GPL \ No newline at end of file
diff --git a/widgets/shortcut-bar/Makefile.am b/widgets/shortcut-bar/Makefile.am
deleted file mode 100644
index 721b251fd7..0000000000
--- a/widgets/shortcut-bar/Makefile.am
+++ /dev/null
@@ -1,35 +0,0 @@
-
-noinst_LIBRARIES = libshortcut-bar.a
-noinst_PROGRAMS = test-shortcut-bar
-
-INCLUDES = \
- -I$(top_srcdir) \
- -I$(top_srcdir)/widgets/misc \
- -DEVOLUTION_VERSION=\""$(VERSION)"\" \
- $(EXTRA_GNOME_CFLAGS) \
- -DG_LOG_DOMAIN=\"shortcut-bar\"
-
-libshortcut_bar_a_SOURCES = \
- e-group-bar.c \
- e-group-bar.h \
- e-icon-bar-bg-item.c \
- e-icon-bar-bg-item.h \
- e-icon-bar.c \
- e-icon-bar.h \
- e-shortcut-bar.c \
- e-shortcut-bar.h \
- e-shortcut-model.c \
- e-shortcut-model.h \
- e-vscrolled-bar.c \
- e-vscrolled-bar.h
-
-test_shortcut_bar_SOURCES = \
- test-shortcut-bar.c
-
-test_shortcut_bar_LDADD = \
- ./libshortcut-bar.a \
- ../misc/libemiscwidgets.a \
- $(EXTRA_GNOME_LIBS)
-
-test_shortcut_bar_LDFLAGS = \
- `gnome-config --libs gdk_pixbuf gnomecanvaspixbuf`
diff --git a/widgets/shortcut-bar/e-group-bar.c b/widgets/shortcut-bar/e-group-bar.c
deleted file mode 100644
index b5aa471d0e..0000000000
--- a/widgets/shortcut-bar/e-group-bar.c
+++ /dev/null
@@ -1,1556 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- * Author :
- * Damon Chaplin <damon@helixcode.com>
- *
- * Copyright 1999, Helix Code, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-/*
- * EGroupBar displays a vertical bar with a number of Groups, which are viewed
- * one at a time by selecting the Group's button. When a different Group is
- * selected, it slides into view, and the old Group slides out.
- * It is typically used on the left of the main application window so users
- * can easily access particular features.
- *
- * It is implemented like GtkNotebook, i.e. the main widgets are the children
- * of the EGroupBar and the button widgets are treated specially like the
- * GtkNotebook tab labels.
- */
-
-#include <config.h>
-#include <math.h>
-#include <gnome.h>
-#include "e-group-bar.h"
-
-#define E_GROUP_BAR_SCROLL_TIMEOUT 10
-#define E_GROUP_BAR_MIN_STEP_SIZE 4
-
-#define E_GROUP_BAR_AUTO_SHOW_TIMEOUT 300
-
-
-static void e_group_bar_class_init (EGroupBarClass *class);
-static void e_group_bar_init (EGroupBar *group_bar);
-static void e_group_bar_destroy (GtkObject *object);
-static void e_group_bar_realize (GtkWidget *widget);
-static void e_group_bar_unrealize (GtkWidget *widget);
-static void e_group_bar_map (GtkWidget *widget);
-static void e_group_bar_unmap (GtkWidget *widget);
-static void e_group_bar_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
-static void e_group_bar_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
-static gint e_group_bar_expose (GtkWidget *widget,
- GdkEventExpose *event);
-static void e_group_bar_draw (GtkWidget *widget,
- GdkRectangle *area);
-static void e_group_bar_add (GtkContainer *container,
- GtkWidget *widget);
-static void e_group_bar_remove (GtkContainer *container,
- GtkWidget *widget);
-static void e_group_bar_forall (GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data);
-
-static void e_group_bar_create_group_button_window (EGroupBar *group_bar,
- gint group_num);
-static void e_group_bar_create_group_child_window (EGroupBar *group_bar,
- gint group_num);
-static gint e_group_bar_get_group_button_position (EGroupBar *group_bar,
- gint group_num);
-static gint e_group_bar_sum_button_heights (EGroupBar *group_bar,
- gint first,
- gint last);
-static gint e_group_bar_get_child_height (EGroupBar *group_bar);
-static gint e_group_bar_get_group_child_position (EGroupBar *group_bar,
- gint group_num);
-
-static void e_group_bar_on_button_clicked (GtkWidget *group_button,
- EGroupBar *group_bar);
-static gint e_group_bar_find_button (EGroupBar *group_bar,
- GtkWidget *group_button);
-static void e_group_bar_start_animation (EGroupBar *group_bar,
- gint group_num);
-static gboolean e_group_bar_timeout_handler (gpointer data);
-static gint e_group_bar_get_increment (EGroupBar *group_bar,
- gint window_y,
- gint window_target_y);
-static gboolean e_group_bar_on_button_drag_motion (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time,
- EGroupBar *group_bar);
-static void e_group_bar_on_button_drag_leave (GtkWidget *widget,
- GdkDragContext *context,
- guint time,
- EGroupBar *group_bar);
-static gboolean e_group_bar_auto_show (gpointer data);
-static void e_group_bar_stop_all_animation (EGroupBar *group_bar);
-
-
-static GtkContainerClass *parent_class;
-
-
-GtkType
-e_group_bar_get_type (void)
-{
- static GtkType e_group_bar_type = 0;
-
- if (!e_group_bar_type){
- GtkTypeInfo e_group_bar_info = {
- "EGroupBar",
- sizeof (EGroupBar),
- sizeof (EGroupBarClass),
- (GtkClassInitFunc) e_group_bar_class_init,
- (GtkObjectInitFunc) e_group_bar_init,
- NULL, /* reserved 1 */
- NULL, /* reserved 2 */
- (GtkClassInitFunc) NULL
- };
-
- parent_class = gtk_type_class (GTK_TYPE_CONTAINER);
- e_group_bar_type = gtk_type_unique (GTK_TYPE_CONTAINER,
- &e_group_bar_info);
- }
-
- return e_group_bar_type;
-}
-
-
-static void
-e_group_bar_class_init (EGroupBarClass *class)
-{
- GtkObjectClass *object_class;
- GtkWidgetClass *widget_class;
- GtkContainerClass *container_class;
-
- object_class = (GtkObjectClass *) class;
- widget_class = (GtkWidgetClass *) class;
- container_class = (GtkContainerClass *) class;
-
- /* Method override */
- object_class->destroy = e_group_bar_destroy;
-
- widget_class->realize = e_group_bar_realize;
- widget_class->unrealize = e_group_bar_unrealize;
- widget_class->map = e_group_bar_map;
- widget_class->unmap = e_group_bar_unmap;
- widget_class->size_request = e_group_bar_size_request;
- widget_class->size_allocate = e_group_bar_size_allocate;
- widget_class->expose_event = e_group_bar_expose;
- widget_class->draw = e_group_bar_draw;
-
- container_class->add = e_group_bar_add;
- container_class->remove = e_group_bar_remove;
- container_class->forall = e_group_bar_forall;
-}
-
-
-static void
-e_group_bar_init (EGroupBar *group_bar)
-{
-
- GTK_WIDGET_UNSET_FLAGS (group_bar, GTK_NO_WINDOW);
-
- /* We don't want child resizes to propagate up to the parent. */
- gtk_container_set_resize_mode (GTK_CONTAINER (group_bar),
- GTK_RESIZE_QUEUE);
-
- group_bar->children = g_array_new (FALSE, FALSE,
- sizeof (EGroupBarChild));
-
- group_bar->current_group_num = -1;
- group_bar->buttons_homogeneous = TRUE;
- group_bar->max_button_height = 0;
- group_bar->animation_timeout_id = 0;
-}
-
-
-/**
- * e_group_bar_new:
- * @Returns: a new #EGroupBar.
- *
- * Creates a new #EGroupBar.
- **/
-GtkWidget *
-e_group_bar_new (void)
-{
- GtkWidget *group_bar;
-
- group_bar = GTK_WIDGET (gtk_type_new (e_group_bar_get_type ()));
-
- return group_bar;
-}
-
-
-static void
-e_group_bar_destroy (GtkObject *object)
-{
- EGroupBar *group_bar;
-
- group_bar = E_GROUP_BAR (object);
-
- e_group_bar_stop_all_animation (group_bar);
-
- /* The parent GtkContainer class will automatically destroy all the
- child widgets, but it calls gtk_container_foreach() so we must not
- destroy our children array until after. */
- GTK_OBJECT_CLASS (parent_class)->destroy (object);
-
- g_array_free (group_bar->children, TRUE);
-}
-
-
-static void
-e_group_bar_realize (GtkWidget *widget)
-{
- EGroupBar *group_bar;
- EGroupBarChild *group;
- GdkWindowAttr attributes;
- gint attributes_mask;
- gint border_width, group_num;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (E_IS_GROUP_BAR (widget));
-
- group_bar = E_GROUP_BAR (widget);
- GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
-
- border_width = GTK_CONTAINER (group_bar)->border_width;
-
- attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = widget->allocation.x + border_width;
- attributes.y = widget->allocation.y + border_width;
- attributes.width = widget->allocation.width - 2 * border_width;
- attributes.height = widget->allocation.height - 2 * border_width;
- attributes.wclass = GDK_INPUT_OUTPUT;
- attributes.visual = gtk_widget_get_visual (widget);
- attributes.colormap = gtk_widget_get_colormap (widget);
- attributes.event_mask = gtk_widget_get_events (widget);
- attributes.event_mask |= (GDK_EXPOSURE_MASK);
-
- attributes_mask = GDK_WA_X | GDK_WA_Y
- | GDK_WA_VISUAL | GDK_WA_COLORMAP;
-
- widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
- &attributes, attributes_mask);
- gdk_window_set_user_data (widget->window, widget);
-
- widget->style = gtk_style_attach (widget->style, widget->window);
- gtk_style_set_background (widget->style, widget->window,
- GTK_STATE_NORMAL);
-
- gdk_window_set_back_pixmap (widget->window, NULL, FALSE);
-
- /* Create windows for all the buttons & group canvases. */
- for (group_num = 0;
- group_num < group_bar->children->len;
- group_num++) {
- group = &g_array_index (group_bar->children,
- EGroupBarChild, group_num);
- e_group_bar_create_group_button_window (group_bar, group_num);
- e_group_bar_create_group_child_window (group_bar, group_num);
- }
-}
-
-
-static void
-e_group_bar_unrealize (GtkWidget *widget)
-{
- EGroupBar *group_bar;
- EGroupBarChild *group;
- gint group_num;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (E_IS_GROUP_BAR (widget));
-
- group_bar = E_GROUP_BAR (widget);
-
- /* Destroy the windows for all the buttons & group canvases. */
- for (group_num = 0;
- group_num < group_bar->children->len;
- group_num++) {
- group = &g_array_index (group_bar->children,
- EGroupBarChild, group_num);
-
- if (group->button_window) {
- gdk_window_set_user_data (group->button_window, NULL);
- gdk_window_destroy (group->button_window);
- group->button_window = NULL;
- }
- if (group->child_window) {
- gdk_window_set_user_data (group->child_window, NULL);
- gdk_window_destroy (group->child_window);
- group->child_window = NULL;
- }
- }
-
- if (GTK_WIDGET_CLASS (parent_class)->unrealize)
- (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
-}
-
-
-static void
-e_group_bar_map (GtkWidget *widget)
-{
- EGroupBar *group_bar;
- EGroupBarChild *group;
- gint group_num;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (E_IS_GROUP_BAR (widget));
-
- group_bar = E_GROUP_BAR (widget);
-
- GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
-
- /* We do this in reverse order, and lower all the child windows, so
- the stacking order ends up correct. */
- for (group_num = group_bar->children->len - 1;
- group_num >= 0;
- group_num--) {
- group = &g_array_index (group_bar->children,
- EGroupBarChild, group_num);
-
- if (group->button_window) {
- gdk_window_show (group->button_window);
- }
-
- if (group->button
- && GTK_WIDGET_VISIBLE (group->button)
- && !GTK_WIDGET_MAPPED (group->button)) {
- gtk_widget_map (group->button);
- }
-
- if (group->child_window) {
- gdk_window_show (group->child_window);
- gdk_window_lower (group->child_window);
- }
-
- if (group->child
- && GTK_WIDGET_VISIBLE (group->child)
- && !GTK_WIDGET_MAPPED (group->child))
- gtk_widget_map (group->child);
- }
-
- gdk_window_show (widget->window);
-}
-
-
-static void
-e_group_bar_unmap (GtkWidget *widget)
-{
- EGroupBar *group_bar;
- EGroupBarChild *group;
- gint group_num;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (E_IS_GROUP_BAR (widget));
-
- group_bar = E_GROUP_BAR (widget);
-
- e_group_bar_stop_all_animation (group_bar);
-
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
-
- for (group_num = 0;
- group_num < group_bar->children->len;
- group_num++) {
- group = &g_array_index (group_bar->children,
- EGroupBarChild, group_num);
-
- if (group->button_window) {
- gdk_window_hide (group->button_window);
- }
-
- if (group->button
- && GTK_WIDGET_MAPPED (group->button))
- gtk_widget_unmap (group->button);
-
- if (group->child_window) {
- gdk_window_hide (group->child_window);
- }
-
- if (group->child
- && GTK_WIDGET_MAPPED (group->child))
- gtk_widget_unmap (group->child);
- }
-
- gdk_window_hide (widget->window);
-}
-
-
-static void
-e_group_bar_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
-{
- EGroupBar *group_bar;
- EGroupBarChild *group;
- gint group_num, max_child_height;
- GtkRequisition child_requisition;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (E_IS_GROUP_BAR (widget));
- g_return_if_fail (requisition != NULL);
-
- group_bar = E_GROUP_BAR (widget);
-
- /* We set the requisition width to the largest requested width of the
- child widgets. The requisition height is set to the sum of all the
- button heights plus the height of the largest child. */
- requisition->width = 0;
- requisition->height = 0;
-
- /* We have to call size_request on all children, even though we don't
- use the results, since some widgets like GtkLabel depend on it. */
- group_bar->max_button_height = 0;
- max_child_height = 0;
- for (group_num = 0;
- group_num < group_bar->children->len;
- group_num++) {
- group = &g_array_index (group_bar->children,
- EGroupBarChild, group_num);
-
- if (group->button) {
- gtk_widget_size_request (group->button,
- &child_requisition);
- group->button_height = child_requisition.height;
- } else {
- group->button_height = 0;
- }
-
- group_bar->max_button_height = MAX (group_bar->max_button_height, group->button_height);
- requisition->height += child_requisition.height;
-
- if (group->child) {
- gtk_widget_size_request (group->child,
- &child_requisition);
- max_child_height = MAX (max_child_height,
- child_requisition.height);
- requisition->width = MAX (requisition->width,
- child_requisition.width);
- }
- }
-
- requisition->height += max_child_height;
-
- /* Add on the standard container border widths. */
- requisition->width += GTK_CONTAINER (widget)->border_width * 2;
- requisition->height += GTK_CONTAINER (widget)->border_width * 2;
-}
-
-
-static void
-e_group_bar_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
-{
- EGroupBar *group_bar;
- EGroupBarChild *group;
- gint group_num, border_width, width, height, child_height, y;
- GtkAllocation button_allocation, child_allocation;
-
- group_bar = E_GROUP_BAR (widget);
-
- /* All child & button windows and widgets use the same width as the
- group bar minus the border width. */
- border_width = GTK_CONTAINER (widget)->border_width;
- width = allocation->width - border_width * 2;
- height = allocation->height - border_width * 2;
-
- widget->allocation = *allocation;
- if (GTK_WIDGET_REALIZED (widget))
- gdk_window_move_resize (widget->window,
- allocation->x + border_width,
- allocation->y + border_width,
- width, height);
-
- /* All the child widgets use the same height. */
- child_height = e_group_bar_get_child_height (group_bar);
-
- /* The buttons are always in the top-left of the button windows, and
- all have the same width. The height is calculated for each group. */
- button_allocation.x = 0;
- button_allocation.y = 0;
- button_allocation.width = width;
-
- /* The child widgets are always in the top-left of the child windows,
- and all have the same width and height. */
- child_allocation.x = 0;
- child_allocation.y = 0;
- child_allocation.width = width;
- child_allocation.height = child_height;
-
- /* Step through the groups, placing the windows as necessary, and
- allocating the areas for the child widgets. Note that if a button
- or child window is in the middle of an animation, we just resize it
- and update the target position, and let the animation continue. */
- for (group_num = 0;
- group_num < group_bar->children->len;
- group_num++) {
- group = &g_array_index (group_bar->children,
- EGroupBarChild, group_num);
-
- /* Calculate the y position of the button, which depends on
- the currently selected group and the button heights. */
- y = e_group_bar_get_group_button_position (group_bar, group_num);
- button_allocation.height = group_bar->buttons_homogeneous ? group_bar->max_button_height : group->button_height;
-
- if (GTK_WIDGET_REALIZED (group->button)) {
- if (group->button_window_in_animation) {
- gdk_window_resize (group->button_window,
- width, button_allocation.height);
- group->button_window_target_y = y;
- } else {
- gdk_window_move_resize (group->button_window,
- 0, y, width, button_allocation.height);
- }
- }
- gtk_widget_size_allocate (group->button, &button_allocation);
-
- if (GTK_WIDGET_REALIZED (group->child)) {
- if (group->child_window_in_animation) {
- gdk_window_resize (group->child_window,
- width, child_height);
- group->child_window_target_y = y + button_allocation.height;
- } else {
- gdk_window_move_resize (group->child_window,
- 0, y + button_allocation.height,
- width, child_height);
- }
- }
- gtk_widget_size_allocate (group->child, &child_allocation);
- }
-}
-
-
-static gint
-e_group_bar_expose (GtkWidget *widget,
- GdkEventExpose *event)
-{
- EGroupBar *group_bar;
- EGroupBarChild *group;
- GdkEventExpose child_event;
- gint group_num;
-
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (E_IS_GROUP_BAR (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- if (GTK_WIDGET_DRAWABLE (widget)) {
- group_bar = E_GROUP_BAR (widget);
-
- child_event = *event;
-
- for (group_num = 0;
- group_num < group_bar->children->len;
- group_num++) {
- group = &g_array_index (group_bar->children,
- EGroupBarChild, group_num);
-
- if (event->window == group->button_window
- && GTK_WIDGET_DRAWABLE (group->button)
- && GTK_WIDGET_NO_WINDOW (group->button)
- && gtk_widget_intersect (group->button, &event->area, &child_event.area))
- gtk_widget_event (group->button, (GdkEvent*) &child_event);
-
- if (event->window == group->child_window
- && GTK_WIDGET_DRAWABLE (group->child)
- && GTK_WIDGET_NO_WINDOW (group->child)
- && gtk_widget_intersect (group->child, &event->area, &child_event.area))
- gtk_widget_event (group->child, (GdkEvent*) &child_event);
- }
- }
-
- return FALSE;
-}
-
-
-static void
-e_group_bar_draw (GtkWidget *widget,
- GdkRectangle *area)
-{
- EGroupBar *group_bar;
- EGroupBarChild *group;
- gint group_num;
- GdkRectangle child_area;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (E_IS_GROUP_BAR (widget));
-
- if (GTK_WIDGET_DRAWABLE (widget)) {
- group_bar = E_GROUP_BAR (widget);
-
- for (group_num = 0;
- group_num < group_bar->children->len;
- group_num++) {
- group = &g_array_index (group_bar->children,
- EGroupBarChild, group_num);
-
- if (GTK_WIDGET_DRAWABLE (group->button)
- && gtk_widget_intersect (group->button, area, &child_area))
- gtk_widget_draw (group->button, &child_area);
-
- if (GTK_WIDGET_DRAWABLE (group->child)
- && gtk_widget_intersect (group->child, area, &child_area))
- gtk_widget_draw (group->child, &child_area);
- }
- }
-}
-
-
-static void
-e_group_bar_add (GtkContainer *container,
- GtkWidget *widget)
-{
- EGroupBar *group_bar;
- GtkWidget *button;
- gchar buffer[32];
-
- g_return_if_fail (container != NULL);
- g_return_if_fail (E_IS_GROUP_BAR (container));
- g_return_if_fail (widget != NULL);
-
- group_bar = E_GROUP_BAR (container);
-
- g_snprintf (buffer, sizeof (buffer), _("Group %i"),
- group_bar->children->len + 1);
- button = gtk_button_new_with_label (buffer);
- gtk_widget_show (button);
-
- e_group_bar_add_group (group_bar, widget, button, -1);
-}
-
-
-static void
-e_group_bar_remove (GtkContainer *container,
- GtkWidget *widget)
-{
- EGroupBar *group_bar;
- gint group_num;
-
- g_return_if_fail (container != NULL);
- g_return_if_fail (E_IS_GROUP_BAR (container));
- g_return_if_fail (widget != NULL);
-
- group_bar = E_GROUP_BAR (container);
-
- group_num = e_group_bar_get_group_num (group_bar, widget);
- e_group_bar_remove_group (group_bar, group_num);
-}
-
-
-static void
-e_group_bar_forall (GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data)
-{
- EGroupBar *group_bar;
- EGroupBarChild *group;
- gint group_num;
- GList *tmp_list;
-
- g_return_if_fail (container != NULL);
- g_return_if_fail (E_IS_GROUP_BAR (container));
- g_return_if_fail (callback != NULL);
-
- group_bar = E_GROUP_BAR (container);
-
- /* Note that drag-and-drop does not check the Z-order of widgets, so
- we have to iterate through them from top to bottom, or it will
- not work properly. We also have to use temporary lists so widgets
- can be safely destroyed while iterating. */
-
- if (include_internals) {
- tmp_list = NULL;
- for (group_num = group_bar->children->len - 1;
- group_num >= 0;
- group_num--) {
- group = &g_array_index (group_bar->children,
- EGroupBarChild, group_num);
-
- if (group->button)
- tmp_list = g_list_prepend (tmp_list,
- group->button);
- }
-
- g_list_foreach (tmp_list, (GFunc) callback, callback_data);
- g_list_free (tmp_list);
- }
-
- tmp_list = NULL;
- for (group_num = 0;
- group_num < group_bar->children->len;
- group_num++) {
- group = &g_array_index (group_bar->children,
- EGroupBarChild, group_num);
-
- if (group->child)
- tmp_list = g_list_prepend (tmp_list, group->child);
- }
- g_list_foreach (tmp_list, (GFunc) callback, callback_data);
- g_list_free (tmp_list);
-}
-
-
-static void
-e_group_bar_create_group_button_window (EGroupBar *group_bar,
- gint group_num)
-{
- EGroupBarChild *group;
- GtkWidget *widget;
- GdkWindowAttr attributes;
- gint attributes_mask;
- gint y, height, border_width;
-
- widget = GTK_WIDGET (group_bar);
-
- group = &g_array_index (group_bar->children,
- EGroupBarChild, group_num);
- y = e_group_bar_get_group_button_position (group_bar, group_num);
- height = group_bar->buttons_homogeneous ? group_bar->max_button_height
- : group->button_height;
- border_width = GTK_CONTAINER (group_bar)->border_width;
-
- attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = 0;
- attributes.y = y;
- attributes.width = widget->allocation.width - 2 * border_width;
- attributes.height = height;
- attributes.wclass = GDK_INPUT_OUTPUT;
- attributes.visual = gtk_widget_get_visual (widget);
- attributes.colormap = gtk_widget_get_colormap (widget);
- attributes.event_mask = gtk_widget_get_events (widget);
- attributes.event_mask |= (GDK_EXPOSURE_MASK);
-
- attributes_mask = GDK_WA_X | GDK_WA_Y
- | GDK_WA_VISUAL | GDK_WA_COLORMAP;
-
- group->button_window = gdk_window_new (widget->window, &attributes,
- attributes_mask);
- gdk_window_set_user_data (group->button_window, widget);
-
- gtk_widget_set_parent_window (group->button,
- group->button_window);
- gdk_window_set_back_pixmap (group->button_window, NULL, TRUE);
-}
-
-
-static void
-e_group_bar_create_group_child_window (EGroupBar *group_bar,
- gint group_num)
-{
- EGroupBarChild *group;
- GtkWidget *widget;
- GdkWindowAttr attributes;
- gint attributes_mask;
- gint y, height, border_width;
-
- widget = GTK_WIDGET (group_bar);
-
- group = &g_array_index (group_bar->children,
- EGroupBarChild, group_num);
- y = e_group_bar_get_group_button_position (group_bar, group_num);
- y += group_bar->buttons_homogeneous ? group_bar->max_button_height
- : group->button_height;
- height = e_group_bar_get_child_height (group_bar);
- border_width = GTK_CONTAINER (group_bar)->border_width;
-
- attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = 0;
- attributes.y = y;
- attributes.width = widget->allocation.width - 2 * border_width;
- attributes.height = height;
- attributes.wclass = GDK_INPUT_OUTPUT;
- attributes.visual = gtk_widget_get_visual (widget);
- attributes.colormap = gtk_widget_get_colormap (widget);
- attributes.event_mask = gtk_widget_get_events (widget);
- attributes.event_mask |= (GDK_EXPOSURE_MASK);
-
- attributes_mask = GDK_WA_X | GDK_WA_Y
- | GDK_WA_VISUAL | GDK_WA_COLORMAP;
-
- group->child_window = gdk_window_new (widget->window, &attributes,
- attributes_mask);
- gdk_window_set_user_data (group->child_window, widget);
-
- gtk_widget_set_parent_window (GTK_WIDGET (group->child),
- group->child_window);
- gdk_window_set_back_pixmap (group->child_window, NULL, TRUE);
-}
-
-
-/* This returns the y position of a group's button within the EGroupBar window.
- */
-static gint
-e_group_bar_get_group_button_position (EGroupBar *group_bar,
- gint group_num)
-{
- gint border_width, window_height, y;
-
- border_width = GTK_CONTAINER (group_bar)->border_width;
- window_height = GTK_WIDGET (group_bar)->allocation.height - 2 * border_width;
-
- if (group_num <= group_bar->current_group_num)
- y = e_group_bar_sum_button_heights (group_bar, 0, group_num - 1);
- else
- y = window_height - e_group_bar_sum_button_heights (group_bar, group_num, group_bar->children->len - 1);
-
- return y;
-}
-
-
-/* This returns the sum of all the buttons from first to last inclusive. */
-static gint
-e_group_bar_sum_button_heights (EGroupBar *group_bar, gint first, gint last)
-{
- EGroupBarChild *group;
- gint height, group_num;
-
- height = 0;
-
- if (group_bar->buttons_homogeneous)
- return (last - first + 1) * group_bar->max_button_height;
-
- for (group_num = first; group_num <= last; group_num++) {
- group = &g_array_index (group_bar->children,
- EGroupBarChild, group_num);
- height += group->button_height;
- }
-
- return height;
-}
-
-
-static gint
-e_group_bar_get_group_child_position (EGroupBar *group_bar,
- gint group_num)
-{
- EGroupBarChild *group;
- gint y;
-
- y = e_group_bar_get_group_button_position (group_bar, group_num);
- group = &g_array_index (group_bar->children,
- EGroupBarChild, group_num);
- y += group_bar->buttons_homogeneous ? group_bar->max_button_height
- : group->button_height;
-
- return y;
-}
-
-
-static gint
-e_group_bar_get_child_height (EGroupBar *group_bar)
-{
- EGroupBarChild *group;
- gint group_num;
-
- /* Start with the allocated height of the EGroupBar, less the border.*/
- group_bar->child_height = GTK_WIDGET (group_bar)->allocation.height;
- group_bar->child_height -= 2 * GTK_CONTAINER (group_bar)->border_width;
-
- /* Now subtract the heights of all the buttons. */
- if (group_bar->buttons_homogeneous) {
- group_bar->child_height -= group_bar->children->len * group_bar->max_button_height;
- } else {
- for (group_num = 0;
- group_num < group_bar->children->len;
- group_num++) {
- group = &g_array_index (group_bar->children,
- EGroupBarChild, group_num);
- group_bar->child_height -= group->button_height;
- }
- }
-
- return group_bar->child_height;
-}
-
-
-/*
- * Insertion, reordering and deletion of items.
- */
-
-/**
- * e_group_bar_add_group:
- * @group_bar: an #EGroupBar.
- * @child: the child widget to add.
- * @button: the button used to show the child widget.
- * @position: the new group's position, or -1 to place it last.
- * @Returns: the position of the new group.
- *
- * Adds a new group to a #EGroupBar at the given position.
- **/
-gint
-e_group_bar_add_group (EGroupBar *group_bar,
- GtkWidget *child,
- GtkWidget *button,
- gint position)
-{
- EGroupBarChild *group, empty_group, *tmp_group;
- gint group_num, tmp_group_num;
-
- g_return_val_if_fail (group_bar != NULL, -1);
- g_return_val_if_fail (E_IS_GROUP_BAR (group_bar), -1);
- g_return_val_if_fail (child != NULL, -1);
- g_return_val_if_fail (button != NULL, -1);
- g_return_val_if_fail (GTK_IS_BUTTON (button), -1);
-
- /* Append an empty group to the children array and get a pointer to
- it, so we can use it like a normal group. */
- if (position == -1)
- group_num = group_bar->children->len;
- else
- group_num = position;
- g_array_insert_val (group_bar->children, group_num, empty_group);
- group = &g_array_index (group_bar->children,
- EGroupBarChild, group_num);
-
- /* Initialize the group. */
- group->button = button;
- group->button_window = NULL;
- group->child = child;
- group->child_window = NULL;
- group->button_window_in_animation = FALSE;
- group->child_window_in_animation = FALSE;
- group->button_window_target_y = 0;
- group->child_window_target_y = 0;
-
- /* If we don't have a current group, set it to the first one.
- Move the currently shown group index forward if necessary. */
- if (group_bar->current_group_num == -1)
- group_bar->current_group_num = 0;
- else if (group_bar->current_group_num >= group_num)
- group_bar->current_group_num++;
-
- /* If the EGroupBar widget is realize, we need to create the child
- windows to put the button & child in. */
- if (GTK_WIDGET_REALIZED (group_bar)) {
- e_group_bar_create_group_button_window (group_bar, group_num);
- gdk_window_show (group->button_window);
-
- e_group_bar_create_group_child_window (group_bar, group_num);
- gdk_window_show (group->child_window);
-
- /* We need to lower all the child windows of the previous
- groups, in reverse order, to keep the stacking order
- correct. */
- for (tmp_group_num = group_num;
- tmp_group_num >= 0;
- tmp_group_num--) {
- tmp_group = &g_array_index (group_bar->children,
- EGroupBarChild,
- tmp_group_num);
- gdk_window_lower (tmp_group->child_window);
- }
- }
-
- gtk_widget_set_parent (group->button, GTK_WIDGET (group_bar));
- gtk_widget_set_parent (group->child, GTK_WIDGET (group_bar));
-
- if (GTK_WIDGET_REALIZED (group_bar)) {
- gtk_widget_realize (group->button);
- gtk_widget_realize (group->child);
- }
-
- if (GTK_WIDGET_VISIBLE (group_bar)
- && GTK_WIDGET_MAPPED (group_bar)) {
- if (group->button
- && GTK_WIDGET_VISIBLE (group->button)
- && !GTK_WIDGET_MAPPED (group->button)) {
- gtk_widget_map (group->button);
- gtk_widget_queue_resize (group->button);
- }
- if (group->child
- && GTK_WIDGET_VISIBLE (group->child)
- && !GTK_WIDGET_MAPPED (group->child)) {
- gtk_widget_map (group->child);
- gtk_widget_queue_resize (group->child);
- }
- }
-
- gtk_signal_connect (GTK_OBJECT (group->button), "clicked",
- GTK_SIGNAL_FUNC (e_group_bar_on_button_clicked),
- group_bar);
-
- gtk_signal_connect (GTK_OBJECT (group->button), "drag_motion",
- GTK_SIGNAL_FUNC (e_group_bar_on_button_drag_motion),
- group_bar);
- gtk_signal_connect (GTK_OBJECT (group->button), "drag_leave",
- GTK_SIGNAL_FUNC (e_group_bar_on_button_drag_leave),
- group_bar);
-
- return group_num;
-}
-
-
-/**
- * e_group_bar_reorder_group:
- * @group_bar: an #EGroupBar.
- * @group_num: the index of the group to move.
- * @new_position: the new position of the group.
- *
- * Moves a group to a new position within the #EGroupBar.
- **/
-void
-e_group_bar_reorder_group (EGroupBar *group_bar,
- gint group_num,
- gint new_position)
-{
- EGroupBarChild group, *tmp_group;
- gint tmp_group_num;
-
- g_return_if_fail (E_IS_GROUP_BAR (group_bar));
- g_return_if_fail (group_num >= 0);
- g_return_if_fail (group_num < group_bar->children->len);
-
- e_group_bar_stop_all_animation (group_bar);
-
- /* Copy the group. */
- group = g_array_index (group_bar->children,
- EGroupBarChild, group_num);
-
- /* Remove the group from its current position. */
- g_array_remove_index (group_bar->children, group_num);
-
- /* Copy the group into its new position. */
- g_array_insert_val (group_bar->children, new_position, group);
-
- /* We need to lower the groups' windows so they are in the correct
- z-order. We can skip unaffected windows. */
- for (tmp_group_num = MAX (group_num, new_position);
- tmp_group_num >= 0;
- tmp_group_num--) {
- tmp_group = &g_array_index (group_bar->children,
- EGroupBarChild, tmp_group_num);
- gdk_window_lower (tmp_group->child_window);
- }
-
- /* Queue a resize so the groups get layed out properly. */
- gtk_widget_queue_resize (GTK_WIDGET (group_bar));
-}
-
-
-/**
- * e_group_bar_remove_group:
- * @group_bar: an #EGroupBar.
- * @group_num: the index of the group to remove.
- *
- * Removes a group from an #EGroupBar.
- **/
-void
-e_group_bar_remove_group (EGroupBar *group_bar,
- gint group_num)
-{
- EGroupBarChild *group;
-
- g_return_if_fail (E_IS_GROUP_BAR (group_bar));
- g_return_if_fail (group_num >= 0);
- g_return_if_fail (group_num < group_bar->children->len);
-
- group = &g_array_index (group_bar->children,
- EGroupBarChild, group_num);
-
- /* Stop any animation. */
- e_group_bar_stop_all_animation (group_bar);
-
- gtk_widget_unparent (group->child);
- if (group->button)
- gtk_widget_unparent (group->button);
-
- if (group->button_window) {
- gdk_window_set_user_data (group->button_window, NULL);
- gdk_window_destroy (group->button_window);
- }
- if (group->child_window) {
- gdk_window_set_user_data (group->child_window, NULL);
- gdk_window_destroy (group->child_window);
- }
-
- g_array_remove_index (group_bar->children, group_num);
-
- /* Make sure the current group is valid. */
- if (group_bar->current_group_num >= group_bar->children->len)
- group_bar->current_group_num = group_bar->children->len - 1;
-
- gtk_widget_queue_resize (GTK_WIDGET (group_bar));
-}
-
-
-/*
- * Getting & setting the current group.
- */
-
-/**
- * e_group_bar_get_current_group_num:
- * @group_bar: an #EGroupBar.
- * @Returns: the index of the group currently displayed.
- *
- * Returns the index of the group currently displayed.
- **/
-gint
-e_group_bar_get_current_group_num (EGroupBar *group_bar)
-{
- g_return_val_if_fail (E_IS_GROUP_BAR (group_bar), -1);
-
- return group_bar->current_group_num;
-}
-
-
-/**
- * e_group_bar_set_current_group_num:
- * @group_bar: an #EGroupBar.
- * @animate: if TRUE, and the #EGroupBar is visible, the group will slide into
- * position, as if the group's button was pressed.
- * @Returns: the index of the group to display.
- *
- * Sets the group to display.
- **/
-void
-e_group_bar_set_current_group_num (EGroupBar *group_bar,
- gint group_num,
- gboolean animate)
-{
- g_return_if_fail (E_IS_GROUP_BAR (group_bar));
-
- /* If that already is the current group, just return. */
- if (group_bar->current_group_num == group_num)
- return;
-
- if (GTK_WIDGET_VISIBLE (group_bar)) {
- if (animate) {
- e_group_bar_start_animation (group_bar, group_num);
- } else {
- group_bar->current_group_num = group_num;
- e_group_bar_stop_all_animation (group_bar);
- gtk_widget_queue_resize (GTK_WIDGET (group_bar));
- }
- } else {
- /* The positions will be sorted out when the widget's size is
- allocated. */
- group_bar->current_group_num = group_num;
- gtk_widget_queue_resize (GTK_WIDGET (group_bar));
- }
-}
-
-
-/*
- * Getting groups and group numbers.
- */
-
-/**
- * e_group_bar_get_nth_group:
- * @group_bar: an #EGroupBar.
- * @group_num: the index of the group to get.
- * @Returns: the child widget at the given index.
- *
- * Returns the child widget at the given index.
- **/
-GtkWidget*
-e_group_bar_get_nth_group (EGroupBar *group_bar,
- gint group_num)
-{
- EGroupBarChild *group;
-
- g_return_val_if_fail (E_IS_GROUP_BAR (group_bar), NULL);
- g_return_val_if_fail (group_num >= 0, NULL);
- g_return_val_if_fail (group_num < group_bar->children->len, NULL);
-
- group = &g_array_index (group_bar->children,
- EGroupBarChild, group_num);
- return group->child;
-}
-
-
-/**
- * e_group_bar_get_group_num:
- * @group_bar: an #EGroupBar.
- * @child: the child widget to find.
- * @Returns: the index of the group containing the given widget.
- *
- * Returns the index of the group containing the given child widget.
- **/
-gint
-e_group_bar_get_group_num (EGroupBar *group_bar,
- GtkWidget *child)
-{
- EGroupBarChild *group;
- gint group_num;
-
- g_return_val_if_fail (E_IS_GROUP_BAR (group_bar), -1);
- g_return_val_if_fail (child != NULL, -1);
-
- for (group_num = 0;
- group_num < group_bar->children->len;
- group_num++) {
- group = &g_array_index (group_bar->children,
- EGroupBarChild, group_num);
-
- if (group->child == child)
- return group_num;
- }
-
- return -1;
-}
-
-
-/**
- * e_group_bar_set_group_button_label:
- * @group_bar: an #EGroupBar.
- * @group_num: the index of the group.
- * @label: the label widget to place in the group's button.
- *
- * Sets the label widget for the given group's button, replacing any existing
- * widget in the button.
- **/
-void
-e_group_bar_set_group_button_label (EGroupBar *group_bar,
- gint group_num,
- GtkWidget *label)
-{
- EGroupBarChild *group;
- GtkWidget *button_child;
-
- g_return_if_fail (E_IS_GROUP_BAR (group_bar));
- g_return_if_fail (group_num >= 0);
- g_return_if_fail (group_num < group_bar->children->len);
-
- group = &g_array_index (group_bar->children,
- EGroupBarChild, group_num);
-
- button_child = GTK_BIN (group->button)->child;
- if (button_child) {
- gtk_container_remove (GTK_CONTAINER (group->button),
- button_child);
- }
-
- if (label)
- gtk_container_add (GTK_CONTAINER (group->button), label);
-}
-
-
-/*
- * Getting & setting the EGroupBar options.
- */
-
-/**
- * e_group_bar_get_buttons_homogeneous:
- * @group_bar: an #EGroupBar.
- * @Returns: TRUE if the buttons are homoegeneous.
- *
- * Returns TRUE if the buttons are homogeneous (i.e. all have the same height).
- **/
-gboolean
-e_group_bar_get_buttons_homogeneous (EGroupBar *group_bar)
-{
- g_return_val_if_fail (E_IS_GROUP_BAR (group_bar), TRUE);
-
- return group_bar->buttons_homogeneous;
-}
-
-
-/**
- * e_group_bar_set_buttons_homogeneous:
- * @group_bar: an #EGroupBar.
- * @homogeneous: TRUE if the buttons should be homoegeneous.
- *
- * Specifies whether the buttons should be homogeneous. When set to TRUE all
- * the group buttons will be set to the same height (equal to the largest
- * requested height). When set to FALSE the buttons will use their own
- * individual requested heights.
- **/
-void
-e_group_bar_set_buttons_homogeneous (EGroupBar *group_bar,
- gboolean homogeneous)
-{
- g_return_if_fail (E_IS_GROUP_BAR (group_bar));
-
- /* Just return if the setting hasn't changed. */
- if (group_bar->buttons_homogeneous == homogeneous)
- return;
-
- group_bar->buttons_homogeneous = homogeneous;
-
- /* Update the position & sizes of the buttons. */
- gtk_widget_queue_resize (GTK_WIDGET (group_bar));
-}
-
-
-static void
-e_group_bar_on_button_clicked (GtkWidget *group_button,
- EGroupBar *group_bar)
-{
- gint group_num;
-
- /* Determine which group button was clicked. */
- group_num = e_group_bar_find_button (group_bar, group_button);
-
- if (group_num != -1)
- e_group_bar_start_animation (group_bar, group_num);
-}
-
-
-/* This returns the group containing the given button, or -1 if not found. */
-static gint
-e_group_bar_find_button (EGroupBar *group_bar,
- GtkWidget *group_button)
-{
- EGroupBarChild *group;
- gint group_num;
-
- /* Determine which group button was clicked. */
- for (group_num = 0;
- group_num < group_bar->children->len;
- group_num++) {
- group = &g_array_index (group_bar->children,
- EGroupBarChild, group_num);
- if (group->button == group_button)
- return group_num;
- }
-
- return -1;
-}
-
-
-static void
-e_group_bar_start_animation (EGroupBar *group_bar,
- gint group_num)
-{
- EGroupBarChild *group, *old_group;
- gint old_group_num, step;
-
- old_group_num = group_bar->current_group_num;
-
- /* Return if it is already the current group. */
- if (old_group_num == group_num)
- return;
-
- group_bar->current_group_num = group_num;
-
- /* Calculate the target y position of the new current group button
- and child, and map the child. */
- group = &g_array_index (group_bar->children,
- EGroupBarChild, group_num);
- group->button_window_target_y = e_group_bar_get_group_button_position (group_bar, group_num);
- group->button_window_in_animation = TRUE;
-
- group->child_window_target_y = e_group_bar_get_group_child_position (group_bar, group_num);
- group->child_window_in_animation = TRUE;
-
- /* Calculate the target y position of the current group button and
- child. */
- old_group = &g_array_index (group_bar->children,
- EGroupBarChild, old_group_num);
- old_group->button_window_target_y = e_group_bar_get_group_button_position (group_bar, old_group_num);
- old_group->button_window_in_animation = TRUE;
-
- old_group->child_window_target_y = e_group_bar_get_group_child_position (group_bar, old_group_num);
- old_group->child_window_in_animation = TRUE;
-
- /* We also need to animate the buttons in between the old group and the
- new group. */
- step = (old_group_num < group_num) ? 1 : -1;
- old_group_num += step;
- while (old_group_num != group_num) {
- old_group = &g_array_index (group_bar->children,
- EGroupBarChild, old_group_num);
- old_group->button_window_target_y = e_group_bar_get_group_button_position (group_bar, old_group_num);
- old_group->button_window_in_animation = TRUE;
-
- old_group->child_window_target_y = e_group_bar_get_group_child_position (group_bar, old_group_num);
- old_group->child_window_in_animation = TRUE;
-
- old_group_num += step;
- }
-
- /* Add a timeout handler if we haven't already got one. */
- if (group_bar->animation_timeout_id == 0) {
- group_bar->animation_timeout_id = g_timeout_add (E_GROUP_BAR_SCROLL_TIMEOUT, e_group_bar_timeout_handler, group_bar);
- }
-}
-
-
-static gboolean
-e_group_bar_timeout_handler (gpointer data)
-{
- EGroupBar *group_bar;
- EGroupBarChild *group;
- gint group_num, button_window_y, child_window_y;
- gboolean finished = TRUE;
-
- g_return_val_if_fail (E_IS_GROUP_BAR (data), FALSE);
-
- group_bar = E_GROUP_BAR (data);
-
- GDK_THREADS_ENTER ();
-
- for (group_num = 0;
- group_num < group_bar->children->len;
- group_num++) {
- group = &g_array_index (group_bar->children,
- EGroupBarChild, group_num);
-
- if (group->button_window_in_animation) {
- gdk_window_get_position (group->button_window, NULL,
- &button_window_y);
- button_window_y += e_group_bar_get_increment (group_bar, button_window_y, group->button_window_target_y);
- if (button_window_y == group->button_window_target_y)
- group->button_window_in_animation = FALSE;
- else
- finished = FALSE;
- gdk_window_move (group->button_window,
- 0, button_window_y);
- }
- if (group->child_window_in_animation) {
- gdk_window_get_position (group->child_window, NULL,
- &child_window_y);
- child_window_y += e_group_bar_get_increment (group_bar, child_window_y, group->child_window_target_y);
- if (child_window_y == group->child_window_target_y)
- group->child_window_in_animation = FALSE;
- else
- finished = FALSE;
- gdk_window_move (group->child_window,
- 0, child_window_y);
- }
-
- }
-
- if (finished)
- group_bar->animation_timeout_id = 0;
-
- GDK_THREADS_LEAVE ();
-
- return !finished;
-}
-
-
-static gint
-e_group_bar_get_increment (EGroupBar *group_bar,
- gint window_y,
- gint window_target_y)
-{
- gdouble percentage;
- gint distance, total_distance, step;
-
- total_distance = group_bar->child_height;
- distance = MIN (abs (window_target_y - window_y), total_distance);
-
- if (distance == 0)
- return 0;
-
- /* Convert the distance into an angle between -PI/2 and PI/2, so we can
- then do a cosine of it. */
- percentage = cos (M_PI * ((gdouble)distance / (gdouble)total_distance) - M_PI / 2);
-
- /* Now multiply by our maximum step size to get the step size. */
- step = percentage * total_distance / 6;
-
- /* Add it to the minimum step size, but don't go too far. */
- step = step + E_GROUP_BAR_MIN_STEP_SIZE;
- step = MIN (step, distance);
-
- if (window_target_y > window_y)
- return step;
- else
- return -step;
-}
-
-
-static gboolean
-e_group_bar_on_button_drag_motion (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time,
- EGroupBar *group_bar)
-{
- gint group_num;
-
- if (!group_bar->auto_show_timeout_id) {
- group_num = e_group_bar_find_button (group_bar, widget);
- if (group_num != -1) {
- group_bar->auto_show_timeout_id = gtk_timeout_add (E_GROUP_BAR_AUTO_SHOW_TIMEOUT, e_group_bar_auto_show, group_bar);
- group_bar->auto_show_group_num = group_num;
- }
- }
- return TRUE;
-}
-
-
-static void
-e_group_bar_on_button_drag_leave (GtkWidget *widget,
- GdkDragContext *context,
- guint time,
- EGroupBar *group_bar)
-{
- if (group_bar->auto_show_timeout_id) {
- gtk_timeout_remove (group_bar->auto_show_timeout_id);
- group_bar->auto_show_timeout_id = 0;
- }
-}
-
-
-static gboolean
-e_group_bar_auto_show (gpointer data)
-{
- EGroupBar *group_bar;
-
- g_return_val_if_fail (E_IS_GROUP_BAR (data), FALSE);
-
- group_bar = E_GROUP_BAR (data);
-
- GDK_THREADS_ENTER ();
-
- e_group_bar_start_animation (group_bar,
- group_bar->auto_show_group_num);
-
- group_bar->auto_show_timeout_id = 0;
-
- GDK_THREADS_LEAVE ();
-
- return FALSE;
-}
-
-
-/* This removes all timeouts and sets all 'in_animation' flags to FALSE. */
-static void
-e_group_bar_stop_all_animation (EGroupBar *group_bar)
-{
- EGroupBarChild *group;
- gint group_num;
-
- if (group_bar->animation_timeout_id) {
- g_source_remove (group_bar->animation_timeout_id);
- group_bar->animation_timeout_id = 0;
- }
- if (group_bar->auto_show_timeout_id) {
- g_source_remove (group_bar->auto_show_timeout_id);
- group_bar->auto_show_timeout_id = 0;
- }
-
- for (group_num = 0;
- group_num < group_bar->children->len;
- group_num++) {
- group = &g_array_index (group_bar->children,
- EGroupBarChild, group_num);
- group->button_window_in_animation = FALSE;
- group->child_window_in_animation = FALSE;
- }
-}
-
diff --git a/widgets/shortcut-bar/e-group-bar.h b/widgets/shortcut-bar/e-group-bar.h
deleted file mode 100644
index 62751174bb..0000000000
--- a/widgets/shortcut-bar/e-group-bar.h
+++ /dev/null
@@ -1,172 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- * Author :
- * Damon Chaplin <damon@helixcode.com>
- *
- * Copyright 1999, Helix Code, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-#ifndef _E_GROUP_BAR_H_
-#define _E_GROUP_BAR_H_
-
-#include <gtk/gtkcontainer.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-/*
- * EGroupBar displays a vertical bar with a number of Groups, which are viewed
- * one at a time by selecting the Group's button. When a different Group is
- * selected, it slides into view, and the old Group slides out.
- * It is typically used on the left of the main application window so users
- * can easily access particular features.
- *
- * It is implemented like GtkNotebook, i.e. the main widgets are the children
- * of the EGroupBar and the button widgets are treated specially like the
- * GtkNotebook tab labels.
- */
-
-/* This contains information on one item. */
-typedef struct _EGroupBarChild EGroupBarChild;
-struct _EGroupBarChild
-{
- /* This is the button used to select the group, and the window we use
- to move it around easily. */
- GtkWidget *button;
- GdkWindow *button_window;
- gint button_height;
-
- /* This is the child widget, which can be any widget added by the
- application, and the window we use to move it around easily. */
- GtkWidget *child;
- GdkWindow *child_window;
-
- /* These are TRUE if we are currently animating the windows. */
- gboolean button_window_in_animation;
- gboolean child_window_in_animation;
-
- /* These are the target y positions that the windows should eventually
- move to, used for animation. If we get a size_allocate we just
- update these and the animation can continue as normal.
- When a child window reaches its target position, it is unmapped if
- if it is not the current group (i.e. it has slid off screen). */
- gint button_window_target_y;
- gint child_window_target_y;
-};
-
-
-#define E_GROUP_BAR(obj) GTK_CHECK_CAST (obj, e_group_bar_get_type (), EGroupBar)
-#define E_GROUP_BAR_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, e_group_bar_get_type (), EGroupBarClass)
-#define E_IS_GROUP_BAR(obj) GTK_CHECK_TYPE (obj, e_group_bar_get_type ())
-
-
-typedef struct _EGroupBar EGroupBar;
-typedef struct _EGroupBarClass EGroupBarClass;
-
-struct _EGroupBar
-{
- GtkContainer container;
-
- /* This is an array of EGroupBarChild elements. */
- GArray *children;
-
- /* This is the group currently shown. */
- gint current_group_num;
-
- /* This is TRUE if all the buttons are allocated the same height. */
- gboolean buttons_homogeneous;
-
- /* This is the biggest requested height of all the buttons, which we
- use for all buttons when buttons_homogeneous is set. */
- gint max_button_height;
-
- /* This is the height of all the child windows & widgets. */
- gint child_height;
-
- /* The id of the source function for animation timeouts. If this is
- not 0 then we are in the middle of an animation. */
- guint animation_timeout_id;
-
- /* The id of the source function for automatically showing groups when
- the user drags over the group button, and the group to show. */
- guint auto_show_timeout_id;
- gint auto_show_group_num;
-};
-
-struct _EGroupBarClass
-{
- GtkContainerClass parent_class;
-};
-
-
-GtkType e_group_bar_get_type (void);
-GtkWidget* e_group_bar_new (void);
-
-/*
- * Insertion, reordering and deletion of items.
- */
-
-/* Adds a new group at the given position. If position is -1 it adds it as
- the last group. It returns the group number. */
-gint e_group_bar_add_group (EGroupBar *group_bar,
- GtkWidget *child,
- GtkWidget *button,
- gint position);
-void e_group_bar_reorder_group (EGroupBar *group_bar,
- gint group_num,
- gint new_position);
-void e_group_bar_remove_group (EGroupBar *group_bar,
- gint group_num);
-
-/*
- * Getting & setting the current group.
- */
-gint e_group_bar_get_current_group_num (EGroupBar *group_bar);
-void e_group_bar_set_current_group_num (EGroupBar *group_bar,
- gint group_num,
- gboolean animate);
-
-/*
- * Getting groups and group numbers.
- */
-GtkWidget* e_group_bar_get_nth_group (EGroupBar *group_bar,
- gint group_num);
-gint e_group_bar_get_group_num (EGroupBar *group_bar,
- GtkWidget *child);
-
-/*
- * Setting the group button label.
- */
-void e_group_bar_set_group_button_label (EGroupBar *group_bar,
- gint group_num,
- GtkWidget *label);
-
-/*
- * Getting & setting the EGroupBar options.
- */
-gboolean e_group_bar_get_buttons_homogeneous (EGroupBar *group_bar);
-void e_group_bar_set_buttons_homogeneous (EGroupBar *group_bar,
- gboolean homogeneous);
-
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* _E_GROUP_BAR_H_ */
diff --git a/widgets/shortcut-bar/e-icon-bar-bg-item.c b/widgets/shortcut-bar/e-icon-bar-bg-item.c
deleted file mode 100644
index 26da038a6e..0000000000
--- a/widgets/shortcut-bar/e-icon-bar-bg-item.c
+++ /dev/null
@@ -1,374 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- * Author :
- * Damon Chaplin <damon@helixcode.com>
- *
- * Copyright 1999, Helix Code, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-/*
- * EIconBarBgItem - A GnomeCanvasItem which covers the entire EIconBar.
- * It paints the rectangles around items when the mouse moves over them, and
- * the lines between items when dragging.
- */
-
-#include <config.h>
-#include "e-icon-bar-bg-item.h"
-#include "e-icon-bar.h"
-
-/* This is the size of the border around the icons, for the shadow. */
-#define E_ICON_BAR_LARGE_ICON_SHADOW_BORDER 2
-#define E_ICON_BAR_SMALL_ICON_SHADOW_BORDER 2
-
-/* These are for the horzontal bar when dragging. */
-#define E_ICON_BAR_BG_ITEM_BAR_HEIGHT 1
-#define E_ICON_BAR_BG_ITEM_BAR_OFFSET 2
-#define E_ICON_BAR_BG_ITEM_LARGE_ARROW_HEIGHT 8
-#define E_ICON_BAR_BG_ITEM_SMALL_ARROW_HEIGHT 4
-
-static void e_icon_bar_bg_item_class_init (EIconBarBgItemClass *class);
-static void e_icon_bar_bg_item_init (EIconBarBgItem *ibitem);
-
-static void e_icon_bar_bg_item_set_arg (GtkObject *o, GtkArg *arg,
- guint arg_id);
-static void e_icon_bar_bg_item_update (GnomeCanvasItem *item,
- double *affine,
- ArtSVP *clip_path, int flags);
-static void e_icon_bar_bg_item_draw (GnomeCanvasItem *item,
- GdkDrawable *drawable,
- int x, int y,
- int width, int height);
-static double e_icon_bar_bg_item_point (GnomeCanvasItem *item,
- double x, double y,
- int cx, int cy,
- GnomeCanvasItem **actual_item);
-static gint e_icon_bar_bg_item_event (GnomeCanvasItem *item,
- GdkEvent *event);
-static gint e_icon_bar_bg_item_button_press (EIconBarBgItem *ibitem,
- GdkEvent *event);
-static gint e_icon_bar_bg_item_button_release (EIconBarBgItem *ibitem,
- GdkEvent *event);
-static gint e_icon_bar_bg_item_motion_notify (EIconBarBgItem *ibitem,
- GdkEvent *event);
-
-static GnomeCanvasItemClass *parent_class;
-
-/* The arguments we take */
-enum {
- ARG_0,
- ARG_ICON_BAR
-};
-
-
-GtkType
-e_icon_bar_bg_item_get_type (void)
-{
- static GtkType e_icon_bar_bg_item_type = 0;
-
- if (!e_icon_bar_bg_item_type) {
- GtkTypeInfo e_icon_bar_bg_item_info = {
- "EIconBarBgItem",
- sizeof (EIconBarBgItem),
- sizeof (EIconBarBgItemClass),
- (GtkClassInitFunc) e_icon_bar_bg_item_class_init,
- (GtkObjectInitFunc) e_icon_bar_bg_item_init,
- NULL, /* reserved_1 */
- NULL, /* reserved_2 */
- (GtkClassInitFunc) NULL
- };
-
- e_icon_bar_bg_item_type = gtk_type_unique (gnome_canvas_item_get_type (), &e_icon_bar_bg_item_info);
- }
-
- return e_icon_bar_bg_item_type;
-}
-
-
-static void
-e_icon_bar_bg_item_class_init (EIconBarBgItemClass *class)
-{
- GtkObjectClass *object_class;
- GnomeCanvasItemClass *item_class;
-
- parent_class = gtk_type_class (gnome_canvas_item_get_type());
-
- object_class = (GtkObjectClass *) class;
- item_class = (GnomeCanvasItemClass *) class;
-
- gtk_object_add_arg_type ("EIconBarBgItem::icon_bar",
- GTK_TYPE_POINTER, GTK_ARG_WRITABLE,
- ARG_ICON_BAR);
-
- object_class->set_arg = e_icon_bar_bg_item_set_arg;
-
- /* GnomeCanvasItem method overrides */
- item_class->update = e_icon_bar_bg_item_update;
- item_class->draw = e_icon_bar_bg_item_draw;
- item_class->point = e_icon_bar_bg_item_point;
- item_class->event = e_icon_bar_bg_item_event;
-}
-
-
-static void
-e_icon_bar_bg_item_init (EIconBarBgItem *ibitem)
-{
- GnomeCanvasItem *item = GNOME_CANVAS_ITEM (ibitem);
-
- ibitem->icon_bar = NULL;
-
- item->x1 = 0;
- item->y1 = 0;
- item->x2 = 0;
- item->y2 = 0;
-}
-
-
-static void
-e_icon_bar_bg_item_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
-{
- GnomeCanvasItem *item;
- EIconBarBgItem *ibitem;
-
- item = GNOME_CANVAS_ITEM (o);
- ibitem = E_ICON_BAR_BG_ITEM (o);
-
- switch (arg_id){
- case ARG_ICON_BAR:
- ibitem->icon_bar = GTK_VALUE_POINTER (*arg);
- break;
- }
-}
-
-
-static void
-e_icon_bar_bg_item_update (GnomeCanvasItem *item,
- double *affine,
- ArtSVP *clip_path,
- int flags)
-{
- if (GNOME_CANVAS_ITEM_CLASS (parent_class)->update)
- (* GNOME_CANVAS_ITEM_CLASS (parent_class)->update) (item, affine, clip_path, flags);
-
- /* The grid covers the entire canvas area. */
- item->x1 = 0;
- item->y1 = 0;
- item->x2 = INT_MAX;
- item->y2 = INT_MAX;
-}
-
-
-/*
- * DRAWING ROUTINES - functions to paint the canvas item.
- */
-
-static void
-e_icon_bar_bg_item_draw (GnomeCanvasItem *canvas_item, GdkDrawable *drawable,
- int x, int y, int width, int height)
-{
- EIconBar *icon_bar;
- EIconBarItem *item;
- EIconBarBgItem *ibitem;
- GtkStyle *style;
- GdkGC *gc;
- GtkShadowType shadow;
- gint item_num, border, bar_x, bar_y, bar_w, i, arrow_height;
-
- ibitem = E_ICON_BAR_BG_ITEM (canvas_item);
- icon_bar = ibitem->icon_bar;
- g_return_if_fail (icon_bar != NULL);
- style = GTK_WIDGET (icon_bar)->style;
- shadow = GTK_SHADOW_NONE;
-
- /* Draw the highlight around the current highlight item. */
- item_num = -1;
- if (icon_bar->editing_item_num == -1) {
- if (icon_bar->pressed_item_num != -1) {
- item_num = icon_bar->pressed_item_num;
- if (icon_bar->pressed_item_num == icon_bar->mouse_over_item_num)
- shadow = GTK_SHADOW_IN;
- else
- shadow = GTK_SHADOW_OUT;
- } else if (icon_bar->mouse_over_item_num != -1) {
- item_num = icon_bar->mouse_over_item_num;
- shadow = GTK_SHADOW_OUT;
- }
- }
-
- if (item_num != -1) {
- item = &g_array_index (icon_bar->items, EIconBarItem,
- item_num);
-
- if (icon_bar->view_type == E_ICON_BAR_LARGE_ICONS)
- border = E_ICON_BAR_LARGE_ICON_SHADOW_BORDER;
- else
- border = E_ICON_BAR_SMALL_ICON_SHADOW_BORDER;
-
- gtk_draw_shadow (style, drawable, GTK_STATE_NORMAL, shadow,
- icon_bar->icon_x - border - x,
- item->icon_y - border - y,
- icon_bar->icon_w + border * 2 - 1,
- icon_bar->icon_h + border * 2 - 1);
- }
-
- /* Draw the bar between items when dragging, if needed. */
- if (icon_bar->in_drag && icon_bar->dragging_before_item_num != -1) {
- if (icon_bar->dragging_before_item_num < icon_bar->items->len) {
- item = &g_array_index (icon_bar->items, EIconBarItem,
- icon_bar->dragging_before_item_num);
- bar_y = 0;
- } else {
- /* We need to draw the bar after the last item. */
- if (icon_bar->items->len != 0) {
- item = &g_array_index (icon_bar->items,
- EIconBarItem,
- icon_bar->items->len - 1);
- bar_y = item->item_height + icon_bar->spacing;
- } else {
- item = NULL;
- bar_y = icon_bar->spacing;
- }
- }
-
- if (item) {
- if (icon_bar->view_type == E_ICON_BAR_LARGE_ICONS) {
- bar_y += item->icon_y;
- } else {
- bar_y += MIN (item->icon_y, item->text_y);
- }
- }
- bar_y -= y + icon_bar->spacing / 2;
-
- bar_x = E_ICON_BAR_BG_ITEM_BAR_OFFSET - x;
- bar_w = GTK_WIDGET (icon_bar)->allocation.width - 2 * E_ICON_BAR_BG_ITEM_BAR_OFFSET - 1;
-
- gc = GTK_WIDGET (icon_bar)->style->fg_gc[GTK_STATE_NORMAL];
-
- /* Draw the horizontal bar. */
- gdk_draw_rectangle (drawable, gc, TRUE,
- bar_x, bar_y,
- bar_w, E_ICON_BAR_BG_ITEM_BAR_HEIGHT);
-
- if (icon_bar->view_type == E_ICON_BAR_LARGE_ICONS)
- arrow_height = E_ICON_BAR_BG_ITEM_LARGE_ARROW_HEIGHT / 2;
- else
- arrow_height = E_ICON_BAR_BG_ITEM_SMALL_ARROW_HEIGHT / 2;
-
- /* Draw the arrows at the end of the lines. We use
- gdk_draw_line() to draw a series of vertical lines, since
- gdk_draw_polygon() produces odd results. */
- i = 0;
- while (arrow_height > 0) {
- gdk_draw_line (drawable, gc,
- bar_x + i,
- bar_y - arrow_height,
- bar_x + i,
- bar_y + arrow_height);
- gdk_draw_line (drawable, gc,
- bar_x + bar_w - i - 1,
- bar_y - arrow_height,
- bar_x + bar_w - i - 1,
- bar_y + arrow_height);
- arrow_height--;
- i++;
- }
- }
-}
-
-
-/* This is supposed to return the nearest item the the point and the distance.
- Since we are the only item we just return ourself and 0 for the distance.
- This is needed so that we get button/motion events. */
-static double
-e_icon_bar_bg_item_point (GnomeCanvasItem *item, double x, double y,
- int cx, int cy,
- GnomeCanvasItem **actual_item)
-{
- *actual_item = item;
- return 0.0;
-}
-
-
-static gint
-e_icon_bar_bg_item_event (GnomeCanvasItem *item, GdkEvent *event)
-{
- EIconBarBgItem *ibitem;
-
- ibitem = E_ICON_BAR_BG_ITEM (item);
-
- switch (event->type) {
- case GDK_BUTTON_PRESS:
- return e_icon_bar_bg_item_button_press (ibitem, event);
- case GDK_BUTTON_RELEASE:
- return e_icon_bar_bg_item_button_release (ibitem, event);
- case GDK_MOTION_NOTIFY:
- return e_icon_bar_bg_item_motion_notify (ibitem, event);
- default:
- break;
- }
-
- return FALSE;
-}
-
-
-static gint
-e_icon_bar_bg_item_button_press (EIconBarBgItem *ibitem,
- GdkEvent *event)
-{
- gint item_num;
-
- if (event->button.button == 4 || event->button.button == 5)
- return FALSE;
-
- item_num = e_icon_bar_find_item_at_position (ibitem->icon_bar,
- event->button.x,
- event->button.y,
- NULL);
- e_icon_bar_item_pressed (ibitem->icon_bar, item_num, event);
- return TRUE;
-}
-
-
-static gint
-e_icon_bar_bg_item_button_release (EIconBarBgItem *ibitem,
- GdkEvent *event)
-{
- gint item_num;
-
- item_num = e_icon_bar_find_item_at_position (ibitem->icon_bar,
- event->button.x,
- event->button.y,
- NULL);
- e_icon_bar_item_released (ibitem->icon_bar, item_num, event);
- return TRUE;
-}
-
-
-static gint
-e_icon_bar_bg_item_motion_notify (EIconBarBgItem *ibitem,
- GdkEvent *event)
-{
- gint item_num;
-
- item_num = e_icon_bar_find_item_at_position (ibitem->icon_bar,
- event->motion.x,
- event->motion.y,
- NULL);
- e_icon_bar_item_motion (ibitem->icon_bar, item_num, event);
- return TRUE;
-}
diff --git a/widgets/shortcut-bar/e-icon-bar-bg-item.h b/widgets/shortcut-bar/e-icon-bar-bg-item.h
deleted file mode 100644
index f8fa14f299..0000000000
--- a/widgets/shortcut-bar/e-icon-bar-bg-item.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- * Author :
- * Damon Chaplin <damon@helixcode.com>
- *
- * Copyright 1999, Helix Code, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-/*
- * EIconBarBgItem - A GnomeCanvasItem which covers the entire EIconBar.
- * It paints the rectangles around items when the mouse moves over them, and
- * the lines between items when dragging.
- */
-
-#ifndef _E_ICON_BAR_BG_ITEM_H_
-#define _E_ICON_BAR_BG_ITEM_H_
-
-#include <libgnomeui/gnome-canvas.h>
-
-#include "e-icon-bar.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-
-#define E_ICON_BAR_BG_ITEM(obj) (GTK_CHECK_CAST((obj), e_icon_bar_bg_item_get_type (), EIconBarBgItem))
-#define E_ICON_BAR_BG_ITEM_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), e_icon_bar_bg_item_get_type (), EIconBarBgItemClass))
-#define E_IS_ICON_BAR_BG_ITEM(o) (GTK_CHECK_TYPE((o), e_icon_bar_bg_item_get_type ()))
-
-
-typedef struct _EIconBarBgItem EIconBarBgItem;
-typedef struct _EIconBarBgItemClass EIconBarBgItemClass;
-
-struct _EIconBarBgItem
-{
- GnomeCanvasItem canvas_item;
-
- /* The parent EIconBar widget. */
- EIconBar *icon_bar;
-};
-
-
-struct _EIconBarBgItemClass
-{
- GnomeCanvasItemClass parent_class;
-};
-
-GtkType e_icon_bar_bg_item_get_type (void);
-
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* _E_ICON_BAR_BG_ITEM_H_ */
diff --git a/widgets/shortcut-bar/e-icon-bar.c b/widgets/shortcut-bar/e-icon-bar.c
deleted file mode 100644
index 81f1de7a06..0000000000
--- a/widgets/shortcut-bar/e-icon-bar.c
+++ /dev/null
@@ -1,1644 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- * Author :
- * Damon Chaplin <damon@helixcode.com>
- *
- * Copyright 1999, Helix Code, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-/*
- * EIconBar is a subclass of ECanvas for displaying a vertical column of
- * icons and descriptions. It provides 2 views - large icons and small icons.
- */
-
-#include <config.h>
-#include <gtk/gtkmain.h>
-#include <gtk/gtksignal.h>
-#include <gdk-pixbuf/gnome-canvas-pixbuf.h>
-#include "e-icon-bar.h"
-#include "e-icon-bar-bg-item.h"
-#include <gal/e-text/e-text.h>
-#include <gal/widgets/e-canvas-utils.h>
-
-/* These are the offsets of the icons & text in both views. Note that the
- shadow around icons is drawn in the space between items (as is the
- horizontal bar when dragging). */
-#define E_ICON_BAR_LARGE_ICON_SPACING 8 /* Spacing between items. */
-#define E_ICON_BAR_LARGE_ICON_WIDTH 48
-#define E_ICON_BAR_LARGE_ICON_HEIGHT 48
-#define E_ICON_BAR_LARGE_ICON_TEXT_X 4
-#define E_ICON_BAR_LARGE_ICON_TEXT_Y (E_ICON_BAR_LARGE_ICON_HEIGHT + 4)
-
-#define E_ICON_BAR_SMALL_ICON_SPACING 4 /* Spacing between items. */
-#define E_ICON_BAR_SMALL_ICON_WIDTH 24
-#define E_ICON_BAR_SMALL_ICON_HEIGHT 24
-#define E_ICON_BAR_SMALL_ICON_X 4
-#define E_ICON_BAR_SMALL_ICON_TEXT_X (E_ICON_BAR_SMALL_ICON_WIDTH + 6)
-
-/* The space we leave at the top or bottom of the bar when position an item
- while it is being edited. This is used since the EIconBar may be in a
- EScrolledBar which may show buttons at the top or bottom. */
-#define E_ICON_BAR_V_SPACE 22
-
-/* The number of pixels the mouse has to be moved with the button down before
- we start a drag. */
-#define E_ICON_BAR_DRAG_START_OFFSET 4
-
-/* This is the area at the top & bottom of the bar where we auto-scroll if the
- mouse goes into during a drag-and-drop operation. */
-#define E_ICON_BAR_DRAG_AUTO_SCROLL_OFFSET 16
-
-/* This is the time between each auto-scroll, when dragging. */
-#define E_ICON_BAR_SCROLL_TIMEOUT 30
-
-/* This is the number of timeouts we skip before we start scrolling. */
-#define E_ICON_BAR_SCROLL_DELAY 12
-
-
-static void e_icon_bar_class_init (EIconBarClass *class);
-static void e_icon_bar_init (EIconBar *icon_bar);
-static void e_icon_bar_destroy (GtkObject *object);
-static void e_icon_bar_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
-static gint e_icon_bar_leave_notify_event (GtkWidget *widget,
- GdkEventCrossing *event);
-static gint e_icon_bar_focus_in (GtkWidget *widget,
- GdkEventFocus *event);
-static gint e_icon_bar_focus_out (GtkWidget *widget,
- GdkEventFocus *event);
-static gint e_icon_bar_drag_motion (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time);
-static void e_icon_bar_drag_leave (GtkWidget *widget,
- GdkDragContext *context,
- guint time);
-static void e_icon_bar_set_dragging_before_item (EIconBar *icon_bar,
- gint before_item);
-static gboolean e_icon_bar_timeout_handler (gpointer data);
-
-static void e_icon_bar_recalc_common_positions (EIconBar *icon_bar);
-static gint e_icon_bar_recalc_item_positions (EIconBar *icon_bar);
-static void e_icon_bar_reflow (ECanvas *canvas);
-static gint e_icon_bar_find_item (EIconBar *icon_bar,
- GnomeCanvasItem *text_item);
-static gboolean e_icon_bar_on_item_event (GnomeCanvasItem *item,
- GdkEvent *event,
- EIconBar *icon_bar);
-
-static gboolean e_icon_bar_large_icons_intersects (EIconBar *icon_bar,
- EIconBarItem *item,
- gint x,
- gint y);
-static gboolean e_icon_bar_large_icons_is_before (EIconBar *icon_bar,
- EIconBarItem *item,
- gint x,
- gint y);
-static gboolean e_icon_bar_small_icons_intersects (EIconBar *icon_bar,
- EIconBarItem *item,
- gint x,
- gint y);
-static gboolean e_icon_bar_small_icons_is_before (EIconBar *icon_bar,
- EIconBarItem *item,
- gint x,
- gint y);
-static void e_icon_bar_on_editing_started (EIconBar *icon_bar,
- GnomeCanvasItem *item);
-static void e_icon_bar_on_editing_stopped (EIconBar *icon_bar,
- GnomeCanvasItem *item);
-static void e_icon_bar_ensure_edited_item_visible (EIconBar *icon_bar);
-static void e_icon_bar_update_highlight (EIconBar *icon_bar);
-static void e_icon_bar_vadjustment_value_changed (GtkAdjustment *adjustment,
- EIconBar *icon_bar);
-static void e_icon_bar_style_set (GtkWidget *widget, GtkStyle *previous_style);
-
-enum
-{
- ITEM_SELECTED,
- ITEM_DRAGGED,
- LAST_SIGNAL
-};
-
-static guint e_icon_bar_signals[LAST_SIGNAL] = {0};
-
-static ECanvasClass *parent_class;
-
-
-GtkType
-e_icon_bar_get_type (void)
-{
- static GtkType e_icon_bar_type = 0;
-
- if (!e_icon_bar_type){
- GtkTypeInfo e_icon_bar_info = {
- "EIconBar",
- sizeof (EIconBar),
- sizeof (EIconBarClass),
- (GtkClassInitFunc) e_icon_bar_class_init,
- (GtkObjectInitFunc) e_icon_bar_init,
- NULL, /* reserved 1 */
- NULL, /* reserved 2 */
- (GtkClassInitFunc) NULL
- };
-
- parent_class = gtk_type_class (e_canvas_get_type ());
- e_icon_bar_type = gtk_type_unique (e_canvas_get_type (),
- &e_icon_bar_info);
- }
-
- return e_icon_bar_type;
-}
-
-
-static void
-e_icon_bar_class_init (EIconBarClass *class)
-{
- GtkObjectClass *object_class;
- GtkWidgetClass *widget_class;
- ECanvasClass *ecanvas_class;
-
- object_class = (GtkObjectClass *) class;
- widget_class = (GtkWidgetClass *) class;
- ecanvas_class = E_CANVAS_CLASS( class );
-
- e_icon_bar_signals[ITEM_SELECTED] =
- gtk_signal_new ("item_selected",
- GTK_RUN_LAST | GTK_RUN_ACTION,
- object_class->type,
- GTK_SIGNAL_OFFSET (EIconBarClass,
- selected_item),
- gtk_marshal_NONE__POINTER_INT,
- GTK_TYPE_NONE, 2, GTK_TYPE_GDK_EVENT,
- GTK_TYPE_INT);
- e_icon_bar_signals[ITEM_DRAGGED] =
- gtk_signal_new ("item_dragged",
- GTK_RUN_LAST | GTK_RUN_ACTION,
- object_class->type,
- GTK_SIGNAL_OFFSET (EIconBarClass,
- dragged_item),
- gtk_marshal_NONE__POINTER_INT,
- GTK_TYPE_NONE, 2, GTK_TYPE_GDK_EVENT,
- GTK_TYPE_INT);
-
- gtk_object_class_add_signals (object_class, e_icon_bar_signals,
- LAST_SIGNAL);
-
- /* Method override */
- object_class->destroy = e_icon_bar_destroy;
-
- widget_class->size_allocate = e_icon_bar_size_allocate;
- widget_class->leave_notify_event = e_icon_bar_leave_notify_event;
- widget_class->focus_in_event = e_icon_bar_focus_in;
- widget_class->focus_out_event = e_icon_bar_focus_out;
- widget_class->drag_motion = e_icon_bar_drag_motion;
- widget_class->drag_leave = e_icon_bar_drag_leave;
- widget_class->style_set = e_icon_bar_style_set;
-
- ecanvas_class->reflow = e_icon_bar_reflow;
-
- class->selected_item = NULL;
-}
-
-
-static void
-e_icon_bar_init (EIconBar *icon_bar)
-{
- GdkColormap *colormap;
- gboolean success[E_ICON_BAR_COLOR_LAST];
- gint nfailed;
-
- icon_bar->view_type = E_ICON_BAR_LARGE_ICONS;
- icon_bar->items = g_array_new (FALSE, FALSE, sizeof (EIconBarItem));
- icon_bar->pressed_item_num = -1;
- icon_bar->mouse_over_item_num = -1;
- icon_bar->editing_item_num = -1;
- icon_bar->edit_rect_item = NULL;
- icon_bar->in_drag = FALSE;
- icon_bar->dragging_before_item_num = -1;
- icon_bar->icon_x = 0;
- icon_bar->icon_w = 0;
- icon_bar->icon_h = 0;
- icon_bar->text_x = 0;
- icon_bar->text_w = 5;
- icon_bar->auto_scroll_timeout_id = 0;
- icon_bar->vadjustment_value_changed_id = 0;
-
- /* Create the background item in the canvas, which handles selections
- and drag-and-drop. */
- gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (icon_bar)->root),
- e_icon_bar_bg_item_get_type (),
- "EIconBarBgItem::icon_bar", icon_bar,
- NULL);
-
- colormap = gtk_widget_get_colormap (GTK_WIDGET (icon_bar));
-
- icon_bar->colors[E_ICON_BAR_COLOR_EDITING_TEXT].red = 0;
- icon_bar->colors[E_ICON_BAR_COLOR_EDITING_TEXT].green = 0;
- icon_bar->colors[E_ICON_BAR_COLOR_EDITING_TEXT].blue = 0;
-
- icon_bar->colors[E_ICON_BAR_COLOR_EDITING_RECT].red = 65535;
- icon_bar->colors[E_ICON_BAR_COLOR_EDITING_RECT].green = 65535;
- icon_bar->colors[E_ICON_BAR_COLOR_EDITING_RECT].blue = 65535;
-
- icon_bar->colors[E_ICON_BAR_COLOR_EDITING_RECT_OUTLINE].red = 0;
- icon_bar->colors[E_ICON_BAR_COLOR_EDITING_RECT_OUTLINE].green = 0;
- icon_bar->colors[E_ICON_BAR_COLOR_EDITING_RECT_OUTLINE].blue = 0;
-
- nfailed = gdk_colormap_alloc_colors (colormap, icon_bar->colors,
- E_ICON_BAR_COLOR_LAST, FALSE,
- TRUE, success);
- if (nfailed)
- g_warning ("Failed to allocate all colors");
-}
-
-
-/**
- * e_icon_bar_new:
- * @Returns: A new #EIconBar.
- *
- * Creates a new #EIconBar.
- **/
-GtkWidget *
-e_icon_bar_new (void)
-{
- GtkWidget *icon_bar;
-
- icon_bar = GTK_WIDGET (gtk_type_new (e_icon_bar_get_type ()));
-
- return icon_bar;
-}
-
-
-static void
-e_icon_bar_destroy (GtkObject *object)
-{
- EIconBar *icon_bar;
- int item_num;
- EIconBarItem *item;
-
- icon_bar = E_ICON_BAR (object);
-
- for (item_num = 0; item_num < icon_bar->items->len; item_num++) {
- item = &g_array_index (icon_bar->items,
- EIconBarItem, item_num);
- if (item->destroy)
- item->destroy (item->data);
- }
-
- g_array_free (icon_bar->items, TRUE);
-
- if (icon_bar->auto_scroll_timeout_id != 0) {
- gtk_timeout_remove (icon_bar->auto_scroll_timeout_id);
- icon_bar->auto_scroll_timeout_id = 0;
- }
-
- GTK_OBJECT_CLASS (parent_class)->destroy (object);
-}
-
-
-static void
-e_icon_bar_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
-{
- EIconBar *icon_bar;
- gint canvas_width, canvas_height, height;
-#if 0
- g_print ("In e_icon_bar_size_allocate\n");
-#endif
- icon_bar = E_ICON_BAR (widget);
-
- GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
-
- canvas_width = GTK_WIDGET (icon_bar)->allocation.width;
- canvas_height = GTK_WIDGET (icon_bar)->allocation.height;
-
- /* Reset the y position and widths of all the items to the width of
- the canvas, and reset the button labels, so they fit. */
- e_icon_bar_recalc_common_positions (icon_bar);
- height = e_icon_bar_recalc_item_positions (icon_bar);
-
- gnome_canvas_set_scroll_region (GNOME_CANVAS (widget),
- 0, 0, canvas_width,
- MAX (height, canvas_height - 1));
-
- /* If we are editing an item, make sure it is visible. */
- e_icon_bar_ensure_edited_item_visible (icon_bar);
-
- GTK_LAYOUT (widget)->vadjustment->step_increment = 16;
- if (icon_bar->vadjustment_value_changed_id == 0)
- icon_bar->vadjustment_value_changed_id = gtk_signal_connect (GTK_OBJECT (GTK_LAYOUT (widget)->vadjustment), "value_changed", GTK_SIGNAL_FUNC (e_icon_bar_vadjustment_value_changed), icon_bar);
-
- e_icon_bar_update_highlight (icon_bar);
-}
-
-
-/* This sets all the item positions which are the same for all items in the
- group. */
-static void
-e_icon_bar_recalc_common_positions (EIconBar *icon_bar)
-{
- gint canvas_width;
-
- canvas_width = GTK_WIDGET (icon_bar)->allocation.width;
-
- if (icon_bar->view_type == E_ICON_BAR_LARGE_ICONS) {
- icon_bar->icon_x = (canvas_width - E_ICON_BAR_LARGE_ICON_WIDTH) / 2;
- icon_bar->icon_w = E_ICON_BAR_LARGE_ICON_WIDTH;
- icon_bar->icon_h = E_ICON_BAR_LARGE_ICON_HEIGHT;
-
- icon_bar->text_x = E_ICON_BAR_LARGE_ICON_TEXT_X;
- icon_bar->text_w = MAX (canvas_width - (E_ICON_BAR_LARGE_ICON_TEXT_X * 2), 5);
-
- icon_bar->spacing = E_ICON_BAR_LARGE_ICON_SPACING;
- } else {
- icon_bar->icon_x = E_ICON_BAR_SMALL_ICON_X;
- icon_bar->icon_w = E_ICON_BAR_SMALL_ICON_WIDTH;
- icon_bar->icon_h = E_ICON_BAR_SMALL_ICON_HEIGHT;
-
- icon_bar->text_x = E_ICON_BAR_SMALL_ICON_TEXT_X;
- icon_bar->text_w = MAX (canvas_width - E_ICON_BAR_SMALL_ICON_TEXT_X, 5);
-
- icon_bar->spacing = E_ICON_BAR_SMALL_ICON_SPACING;
- }
-}
-
-
-/* This recalculates the positions of all the items, according to the current
- view type and the height of the text items. */
-static gint
-e_icon_bar_recalc_item_positions (EIconBar *icon_bar)
-{
- EIconBarItem *item;
- gint y, item_num, text_h;
- gdouble x1, y1, x2, y2, text_x;
- GtkJustification justify;
- GtkAnchorType anchor;
- gint max_lines;
- GdkFont *font;
- gboolean line_wrap;
-
- if (icon_bar->view_type == E_ICON_BAR_LARGE_ICONS) {
- justify = GTK_JUSTIFY_CENTER;
- anchor = GTK_ANCHOR_N;
- max_lines = 2;
- text_x = icon_bar->text_x + (icon_bar->text_w / 2);
- line_wrap = TRUE;
-
- /*
- * Fixme: incorrect
- */
- font = GTK_WIDGET (icon_bar)->style->font;
- text_h = font->ascent + font->descent;
- } else {
- justify = GTK_JUSTIFY_LEFT;
- anchor = GTK_ANCHOR_NW;
- max_lines = 1;
- text_x = icon_bar->text_x;
- font = GTK_WIDGET (icon_bar)->style->font;
- text_h = font->ascent + font->descent;
- line_wrap = FALSE;
- }
-
- /* Now step through the items, setting the y positions. */
- y = icon_bar->spacing;
- for (item_num = 0; item_num < icon_bar->items->len; item_num++) {
- item = &g_array_index (icon_bar->items,
- EIconBarItem, item_num);
-
- if (icon_bar->view_type == E_ICON_BAR_LARGE_ICONS) {
- item->icon_y = y;
- item->text_y = y + E_ICON_BAR_LARGE_ICON_TEXT_Y;
- } else {
- item->text_height = text_h;
- item->item_height = MAX (text_h, E_ICON_BAR_SMALL_ICON_HEIGHT);
- item->icon_y = y + (item->item_height - E_ICON_BAR_SMALL_ICON_HEIGHT) / 2;
- item->text_y = y + (item->item_height - item->text_height) / 2;
- }
-
- gnome_canvas_item_set (item->text,
- "clip_width", (gdouble) (icon_bar->text_w),
- "justification", justify,
- "anchor", anchor,
- "max_lines", max_lines,
- "line_wrap", line_wrap,
- NULL);
- e_canvas_item_move_absolute(item->text,
- text_x, item->text_y);
-
- /* Get the text item's height. */
- gnome_canvas_item_get_bounds (item->text, &x1, &y1, &x2, &y2);
- item->text_x = x1;
- item->text_width = x2 - x1;
- item->text_height = y2 - y1;
-
- if (icon_bar->view_type == E_ICON_BAR_LARGE_ICONS) {
- item->item_height = E_ICON_BAR_LARGE_ICON_TEXT_Y
- + item->text_height;
- }
-
- gnome_canvas_item_set (item->image,
- "GnomeCanvasPixbuf::x", (gdouble)icon_bar->icon_x,
- "GnomeCanvasPixbuf::y", (gdouble)item->icon_y,
- "GnomeCanvasPixbuf::width_set", TRUE,
- "GnomeCanvasPixbuf::height_set", TRUE,
- "GnomeCanvasPixbuf::width", (gdouble)icon_bar->icon_w,
- "GnomeCanvasPixbuf::height", (gdouble)icon_bar->icon_h,
- NULL);
-
- y += item->item_height + icon_bar->spacing;
- }
-
- return y;
-}
-
-
-static gint
-e_icon_bar_leave_notify_event (GtkWidget *widget, GdkEventCrossing *event)
-{
- EIconBar *icon_bar;
-
- icon_bar = E_ICON_BAR (widget);
-
- GTK_WIDGET_CLASS (parent_class)->leave_notify_event (widget, event);
-
- /* Make sure no items are highlighted. */
- e_icon_bar_item_motion (icon_bar, -1, NULL);
-
- return FALSE;
-}
-
-
-static gint
-e_icon_bar_focus_in (GtkWidget *widget,
- GdkEventFocus *event)
-{
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (E_IS_ICON_BAR (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- GTK_WIDGET_CLASS (parent_class)->focus_in_event (widget, event);
- GTK_WIDGET_SET_FLAGS (widget, GTK_HAS_FOCUS);
- return FALSE;
-}
-
-
-static gint
-e_icon_bar_focus_out (GtkWidget *widget,
- GdkEventFocus *event)
-{
- g_return_val_if_fail (widget != NULL, FALSE);
- g_return_val_if_fail (E_IS_ICON_BAR (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
- GTK_WIDGET_CLASS (parent_class)->focus_out_event (widget, event);
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_HAS_FOCUS);
- return FALSE;
-}
-
-
-/**
- * e_icon_bar_set_view_type:
- * @icon_bar: An #EIconBar.
- * @view_type: The new view type, %E_ICON_BAR_LARGE_ICONS or
- * %E_ICON_BAR_SMALL_ICONS.
- *
- * Sets the view type of the #EIconBar.
- **/
-void
-e_icon_bar_set_view_type (EIconBar *icon_bar,
- EIconBarViewType view_type)
-{
- g_return_if_fail (E_IS_ICON_BAR (icon_bar));
-
- if (icon_bar->view_type == view_type)
- return;
-
- icon_bar->view_type = view_type;
-
- /* Queue a resize of the canvas, so everything is put in the right
- positions based on the new view type. */
- gtk_widget_queue_resize (GTK_WIDGET (icon_bar));
-}
-
-static GdkPixbuf *
-flatten_alpha (GdkPixbuf *image, guint rgb)
-{
- if (!image || !gdk_pixbuf_get_has_alpha (image))
- return NULL;
-
-
- return gdk_pixbuf_composite_color_simple (
- image,
- gdk_pixbuf_get_width (image),
- gdk_pixbuf_get_height (image),
- GDK_INTERP_NEAREST,
- 255,
- 32,
- rgb, rgb);
-}
-
-/*
- * Creates a 24-bits RGB value from a GdkColor
- */
-static guint
-rgb_from_gdk_color (GdkColor *color)
-{
- guint a =
- (((color->red >> 8) << 16) |
- ((color->green >> 8) << 8) |
- ((color->blue >> 8)));
-
- return a;
-}
-
-static void
-e_icon_bar_style_set (GtkWidget *widget, GtkStyle *previous_style) {
- EIconBar *icon_bar;
- EIconBarItem *item;
- gint item_num;
- GdkPixbuf *flattened;
- GtkStyle *style = widget->style;
- GdkColormap *colormap;
-
- colormap = gtk_widget_get_colormap (widget);
- gdk_color_alloc (colormap, &style->fg [GTK_STATE_NORMAL]);
-
- icon_bar = E_ICON_BAR (widget);
-
- for (item_num = 0; item_num < icon_bar->items->len; item_num++) {
-
- item = &g_array_index (icon_bar->items,
- EIconBarItem, item_num);
-
- flattened = flatten_alpha (item->pixbuf,
- rgb_from_gdk_color (&style->bg [GTK_STATE_NORMAL]));
-
- gnome_canvas_item_set(item->image,
- "GnomeCanvasPixbuf::pixbuf", flattened ? flattened : item->pixbuf,
- NULL);
- gnome_canvas_item_set (item->text,
- "font_gdk", style->font,
- "fill_color_gdk", &style->fg [GTK_STATE_NORMAL],
- NULL);
-
- if (flattened)
- /* the canvas item holds the reference now */
- gdk_pixbuf_unref (flattened);
-
- }
-
- e_icon_bar_recalc_item_positions (icon_bar);
-}
-
-
-/**
- * e_icon_bar_add_item:
- * @icon_bar: An #EIconBar.
- * @image: the new item's icon.
- * @text: the new item's text.
- * @position: the position to place the new item, or -1 to place it last.
- *
- * Adds an item to the #EIconBar at the given position.
- **/
-gint
-e_icon_bar_add_item (EIconBar *icon_bar,
- GdkPixbuf *image,
- const gchar *text,
- gint position)
-{
- EIconBarItem item;
- GtkJustification justify;
- GtkAnchorType anchor;
- gint max_lines, retval;
- GtkStyle *style;
- GdkFont *font;
- gdouble text_x, clip_height;
- GdkPixbuf *flattened = NULL;
-
- g_return_val_if_fail (E_IS_ICON_BAR (icon_bar), -1);
- g_return_val_if_fail (text != NULL, -1);
- g_return_val_if_fail (position >= -1, -1);
- g_return_val_if_fail (position <= (gint)icon_bar->items->len, -1);
-
- if (icon_bar->view_type == E_ICON_BAR_LARGE_ICONS) {
- justify = GTK_JUSTIFY_CENTER;
- anchor = GTK_ANCHOR_N;
- max_lines = 2;
- text_x = icon_bar->text_x + (icon_bar->text_w / 2);
- } else {
- justify = GTK_JUSTIFY_LEFT;
- anchor = GTK_ANCHOR_NW;
- max_lines = 1;
- text_x = icon_bar->text_x;
- }
-
- gtk_widget_ensure_style (GTK_WIDGET (icon_bar));
- style = GTK_WIDGET (icon_bar)->style;
- font = style->font;
- clip_height = max_lines * (font->ascent + font->descent);
- item.text = gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (icon_bar)->root),
- e_text_get_type (),
- "font_gdk", font,
- "fill_color_gdk", &style->fg [GTK_STATE_NORMAL],
- "use_ellipsis", TRUE,
- "anchor", anchor,
- "editable", TRUE,
- "justification", justify,
- "line_wrap", TRUE,
- "max_lines", max_lines,
- "clip", TRUE,
- "clip_width", (gdouble) (icon_bar->text_w),
- "clip_height", clip_height,
- "text", text,
- "draw_background", FALSE,
- NULL);
- e_canvas_item_move_absolute(item.text,
- text_x, 0);
-
- gtk_signal_connect (GTK_OBJECT (item.text), "event",
- GTK_SIGNAL_FUNC (e_icon_bar_on_item_event),
- icon_bar);
-
- item.pixbuf = image;
- gdk_pixbuf_ref (image);
-
- flattened = flatten_alpha (image,
- rgb_from_gdk_color (&style->bg [GTK_STATE_NORMAL]));
-
- item.image = gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (icon_bar)->root),
- gnome_canvas_pixbuf_get_type (),
- "GnomeCanvasPixbuf::pixbuf", flattened ? flattened : image,
- "GnomeCanvasPixbuf::width", (gdouble) icon_bar->icon_w,
- "GnomeCanvasPixbuf::height", (gdouble) icon_bar->icon_h,
- NULL);
-
-
- if (flattened)
- /* the canvas item holds the reference now */
- gdk_pixbuf_unref (flattened);
-
- gtk_signal_connect (GTK_OBJECT (item.image), "event",
- GTK_SIGNAL_FUNC (e_icon_bar_on_item_event),
- icon_bar);
-
- item.data = NULL;
- item.destroy = NULL;
-
- if (position == -1) {
- g_array_append_val (icon_bar->items, item);
- retval = icon_bar->items->len - 1;
- } else {
- g_array_insert_val (icon_bar->items, position, item);
- retval = position;
-
- /* FIXME: Should possibly update other indices. */
- if (icon_bar->dragged_item_num >= position)
- icon_bar->dragged_item_num++;
- }
-
- gtk_widget_queue_resize (GTK_WIDGET (icon_bar));
-
- return retval;
-}
-
-
-/**
- * e_icon_bar_reorder_item:
- * @icon_bar: An #EIconBar.
- * @item_num: The index of the item to move.
- * @new_position: The new position of the item, which is used after the item
- * has been removed from its current position. If @new_position is -1, the item
- * is placed last.
- *
- * Moves an item to a new position within the #EIconBar.
- **/
-void
-e_icon_bar_reorder_item (EIconBar *icon_bar,
- gint item_num,
- gint new_position)
-{
- EIconBarItem tmp_item;
-
- g_return_if_fail (E_IS_ICON_BAR (icon_bar));
- g_return_if_fail (item_num >= 0);
- g_return_if_fail (item_num < icon_bar->items->len);
- g_return_if_fail (new_position >= -1);
- g_return_if_fail (new_position < icon_bar->items->len);
-
- tmp_item = g_array_index (icon_bar->items, EIconBarItem, item_num);
- g_array_remove_index (icon_bar->items, item_num);
-
- if (new_position == -1)
- g_array_append_val (icon_bar->items, tmp_item);
- else
- g_array_insert_val (icon_bar->items, new_position, tmp_item);
-
- gtk_widget_queue_resize (GTK_WIDGET (icon_bar));
-}
-
-
-/**
- * e_icon_bar_remove_item:
- * @icon_bar: An #EIconBar.
- * @item_num: The index of the item to remove.
- *
- * Removes an item from the #EIconBar.
- **/
-void
-e_icon_bar_remove_item (EIconBar *icon_bar,
- gint item_num)
-{
- EIconBarItem *item;
-
- g_return_if_fail (E_IS_ICON_BAR (icon_bar));
- g_return_if_fail (item_num >= 0);
- g_return_if_fail (item_num < icon_bar->items->len);
-
- item = &g_array_index (icon_bar->items, EIconBarItem, item_num);
-
- if (item->destroy)
- item->destroy (item->data);
-
- gtk_object_destroy (GTK_OBJECT (item->text));
- gtk_object_destroy (GTK_OBJECT (item->image));
- gdk_pixbuf_unref (item->pixbuf);
-
- g_array_remove_index (icon_bar->items, item_num);
-
- gtk_widget_queue_resize (GTK_WIDGET (icon_bar));
-}
-
-
-/**
- * e_icon_bar_get_item_image:
- * @icon_bar: An #EIconBar.
- * @item_num: The index of the item.
- * @Returns: The icon of the given item.
- *
- * Returns the icon used for the given item.
- **/
-GdkPixbuf *
-e_icon_bar_get_item_image (EIconBar *icon_bar,
- gint item_num)
-{
- EIconBarItem *item;
- GdkPixbuf *image = NULL;
-
- g_return_val_if_fail (E_IS_ICON_BAR (icon_bar), NULL);
- g_return_val_if_fail (item_num >= 0, NULL);
- g_return_val_if_fail (item_num < icon_bar->items->len, NULL);
-
- item = &g_array_index (icon_bar->items, EIconBarItem, item_num);
- gtk_object_get (GTK_OBJECT (item->image),
- "GnomeCanvasPixbuf::pixbuf", &image,
- NULL);
- return image;
-}
-
-
-/**
- * e_icon_bar_set_item_image:
- * @icon_bar: An #EIconBar.
- * @item_num: The index of the item.
- * @image: The new icon to use for the given item.
- *
- * Sets the icon to use for the given item.
- **/
-void
-e_icon_bar_set_item_image (EIconBar *icon_bar,
- gint item_num,
- GdkPixbuf *image)
-{
- EIconBarItem *item;
-
- g_return_if_fail (E_IS_ICON_BAR (icon_bar));
- g_return_if_fail (item_num >= 0);
- g_return_if_fail (item_num < icon_bar->items->len);
-
- item = &g_array_index (icon_bar->items, EIconBarItem, item_num);
- gnome_canvas_item_set (item->image,
- "GnomeCanvasPixbuf::pixbuf", image,
- NULL);
-}
-
-
-/**
- * e_icon_bar_get_item_text:
- * @icon_bar: An #EIconBar.
- * @item_num: The index of the item.
- * @Returns: The text of the given item.
- *
- * Returns the text of the given item. This should be freed when no longer
- * needed.
- **/
-gchar*
-e_icon_bar_get_item_text (EIconBar *icon_bar,
- gint item_num)
-{
- EIconBarItem *item;
- gchar *text;
-
- g_return_val_if_fail (E_IS_ICON_BAR (icon_bar), NULL);
- g_return_val_if_fail (item_num >= 0, NULL);
- g_return_val_if_fail (item_num < icon_bar->items->len, NULL);
-
- item = &g_array_index (icon_bar->items, EIconBarItem, item_num);
- gtk_object_get (GTK_OBJECT (item->text),
- "EText::text", &text,
- NULL);
-
- return text;
-}
-
-
-/**
- * e_icon_bar_set_item_text:
- * @icon_bar: An #EIconBar.
- * @item_num: The index of the item.
- * @text: The new text for the given item.
- *
- * Sets the text of the given item.
- **/
-void
-e_icon_bar_set_item_text (EIconBar *icon_bar,
- gint item_num,
- gchar *text)
-{
- EIconBarItem *item;
-
- g_return_if_fail (E_IS_ICON_BAR (icon_bar));
- g_return_if_fail (item_num >= 0);
- g_return_if_fail (item_num < icon_bar->items->len);
-
- item = &g_array_index (icon_bar->items, EIconBarItem, item_num);
- gnome_canvas_item_set (item->text,
- "EText::text", text,
- NULL);
-}
-
-
-/**
- * e_icon_bar_get_item_data:
- * @icon_bar: An #EIconBar.
- * @item_num: The index of the item.
- * @Returns: The user data associated with the given item.
- *
- * Returns the user data associated with the given item.
- **/
-gpointer
-e_icon_bar_get_item_data (EIconBar *icon_bar,
- gint item_num)
-{
- EIconBarItem *item;
-
- g_return_val_if_fail (E_IS_ICON_BAR (icon_bar), NULL);
- g_return_val_if_fail (item_num >= 0, NULL);
- g_return_val_if_fail (item_num < icon_bar->items->len, NULL);
-
- item = &g_array_index (icon_bar->items, EIconBarItem, item_num);
- return item->data;
-}
-
-
-/**
- * e_icon_bar_set_item_data:
- * @icon_bar: An #EIconBar.
- * @item_num: The index of the item.
- * @data: The user data to set for the given item.
- *
- * Sets the user data of the given item.
- **/
-void
-e_icon_bar_set_item_data (EIconBar *icon_bar,
- gint item_num,
- gpointer data)
-{
- e_icon_bar_set_item_data_full (icon_bar, item_num, data, NULL);
-}
-
-
-/**
- * e_icon_bar_set_item_data_full:
- * @icon_bar: An #EIconBar.
- * @item_num: The index of the item.
- * @data: The user data to set for the given item.
- * @destroy: The function to free @data when the item is destroyed.
- *
- * Sets the user data of the given item, and the function to free the data
- * when the item is destroyed.
- **/
-void
-e_icon_bar_set_item_data_full (EIconBar *icon_bar,
- gint item_num,
- gpointer data,
- GtkDestroyNotify destroy)
-{
- EIconBarItem *item;
-
- g_return_if_fail (E_IS_ICON_BAR (icon_bar));
- g_return_if_fail (item_num >= 0);
- g_return_if_fail (item_num < icon_bar->items->len);
-
- item = &g_array_index (icon_bar->items, EIconBarItem, item_num);
-
- if (item->destroy)
- item->destroy (item->data);
-
- item->data = data;
- item->destroy = destroy;
-}
-
-
-static void
-e_icon_bar_reflow (ECanvas *canvas)
-{
-#if 0
- g_print ("In e_icon_bar_on_canvas_reflow\n");
- gtk_widget_queue_resize (GTK_WIDGET (canvas));
-#endif
-}
-
-
-/* This returns the index of the given item, or -1 if it isn't found. */
-static gint
-e_icon_bar_find_item (EIconBar *icon_bar,
- GnomeCanvasItem *canvas_item)
-{
- EIconBarItem *item;
- gint item_num;
-
- for (item_num = 0; item_num < icon_bar->items->len; item_num++) {
- item = &g_array_index (icon_bar->items,
- EIconBarItem, item_num);
-
- if (item->text == canvas_item || item->image == canvas_item) {
- return item_num;
- }
- }
-
- return -1;
-}
-
-
-/* When an item has a grab, it will get all events, so we need to use the
- position to find the real item. */
-static gboolean
-e_icon_bar_on_item_event (GnomeCanvasItem *item,
- GdkEvent *event,
- EIconBar *icon_bar)
-{
- gint item_num;
-
- switch (event->type) {
- case GDK_BUTTON_PRESS:
- if (event->button.button == 4 || event->button.button == 5)
- return FALSE;
-
- item_num = e_icon_bar_find_item_at_position (icon_bar,
- event->button.x,
- event->button.y,
- NULL);
- /* If the item is not being edited, we handle the event and
- stop the signal so the text editing isn't started. */
- if (icon_bar->editing_item_num == -1
- || icon_bar->editing_item_num != item_num) {
- e_icon_bar_item_pressed (icon_bar, item_num, event);
- gtk_signal_emit_stop_by_name (GTK_OBJECT (item),
- "event");
- return TRUE;
- }
- break;
- case GDK_BUTTON_RELEASE:
- item_num = e_icon_bar_find_item_at_position (icon_bar,
- event->button.x,
- event->button.y,
- NULL);
- /* If the item is not being edited, we handle the event and
- stop the signal so the text editing isn't started. */
- if (icon_bar->editing_item_num == -1
- || icon_bar->editing_item_num != item_num) {
- e_icon_bar_item_released (icon_bar, item_num, event);
- gtk_signal_emit_stop_by_name (GTK_OBJECT (item),
- "event");
- return TRUE;
- }
- break;
- case GDK_MOTION_NOTIFY:
- item_num = e_icon_bar_find_item_at_position (icon_bar,
- event->motion.x,
- event->motion.y,
- NULL);
- e_icon_bar_item_motion (icon_bar, item_num, event);
- return TRUE;
- case GDK_FOCUS_CHANGE:
- if (event->focus_change.in)
- e_icon_bar_on_editing_started (icon_bar, item);
- else
- e_icon_bar_on_editing_stopped (icon_bar, item);
-
- return FALSE;
- default:
- break;
- }
-
- return FALSE;
-}
-
-
-void
-e_icon_bar_item_pressed (EIconBar *icon_bar,
- gint item_num,
- GdkEvent *event)
-{
- gint button;
-
- /* If we are editing an item, and a different item (or anywhere outside
- an item) is clicked, stop the edit. If the item being edited is
- clicked we just return, since the user may be selecting text. */
- if (icon_bar->editing_item_num != -1) {
- if (icon_bar->editing_item_num != item_num) {
- e_icon_bar_stop_editing_item (icon_bar, TRUE);
- }
- return;
- }
-
- button = event->button.button;
-
- if (button == 1 && item_num != -1) {
- icon_bar->mouse_over_item_num = item_num;
- icon_bar->pressed_item_num = item_num;
- icon_bar->pressed_x = event->button.x;
- icon_bar->pressed_y = event->button.y;
- gtk_widget_queue_draw (GTK_WIDGET (icon_bar));
- } else if (button == 3) {
- gtk_signal_emit (GTK_OBJECT (icon_bar),
- e_icon_bar_signals[ITEM_SELECTED],
- event, item_num);
- }
-}
-
-
-void
-e_icon_bar_item_released (EIconBar *icon_bar,
- gint item_num,
- GdkEvent *event)
-{
- gint button;
-
- /* If we are editing an item, just return. */
- if (icon_bar->editing_item_num != -1)
- return;
-
- button = event->button.button;
-
- if (button == 1) {
- if (icon_bar->pressed_item_num != -1
- && icon_bar->pressed_item_num == icon_bar->mouse_over_item_num) {
- gtk_signal_emit (GTK_OBJECT (icon_bar),
- e_icon_bar_signals[ITEM_SELECTED],
- event, item_num);
- }
-
- icon_bar->pressed_item_num = -1;
- gtk_widget_queue_draw (GTK_WIDGET (icon_bar));
- }
-}
-
-
-void
-e_icon_bar_item_motion (EIconBar *icon_bar,
- gint item_num,
- GdkEvent *event)
-{
- gboolean need_redraw = TRUE;
-
- if (event && event->motion.state & GDK_BUTTON1_MASK
- && icon_bar->pressed_item_num != -1) {
- if (abs (event->motion.x - icon_bar->pressed_x) > E_ICON_BAR_DRAG_START_OFFSET
- || abs (event->motion.y - icon_bar->pressed_y) > E_ICON_BAR_DRAG_START_OFFSET) {
- icon_bar->dragged_item_num = icon_bar->pressed_item_num;
- gtk_signal_emit (GTK_OBJECT (icon_bar),
- e_icon_bar_signals[ITEM_DRAGGED],
- event, icon_bar->dragged_item_num);
-
- /* Don't show the button as pressed while dragging. */
- icon_bar->pressed_item_num = -1;
- gtk_widget_queue_draw (GTK_WIDGET (icon_bar));
- }
-
- return;
- }
-
- if (icon_bar->mouse_over_item_num == item_num)
- return;
-
- /* If we are editing an item, items aren't highlighted so we don't
- need a redraw. Also if an item is pressed, we only need a redraw if
- item_num or the old mouse_over_item_num is the pressed item. */
- if (icon_bar->editing_item_num != -1) {
- need_redraw = FALSE;
- } else if (icon_bar->pressed_item_num != -1) {
- if (icon_bar->pressed_item_num != item_num
- && icon_bar->pressed_item_num != icon_bar->mouse_over_item_num)
- need_redraw = FALSE;
- }
-
- icon_bar->mouse_over_item_num = item_num;
-
- if (need_redraw)
- gtk_widget_queue_draw (GTK_WIDGET (icon_bar));
-}
-
-
-/* This returns the index of the item at the given position on the EIconBar,
- or -1 if no item is found. If before_item is not NULL, it returns the
- item which the mouse is before, or -1 (for dragging). */
-gint
-e_icon_bar_find_item_at_position (EIconBar *icon_bar,
- gint x,
- gint y,
- gint *before_item)
-{
- EIconBarItem *item = NULL;
- gint item_num;
-
- if (before_item)
- *before_item = -1;
-
- for (item_num = 0; item_num < icon_bar->items->len; item_num++) {
- item = &g_array_index (icon_bar->items,
- EIconBarItem, item_num);
-
- if (icon_bar->view_type == E_ICON_BAR_LARGE_ICONS) {
- if (e_icon_bar_large_icons_intersects (icon_bar, item,
- x, y))
- return item_num;
-
- if (before_item
- && e_icon_bar_large_icons_is_before (icon_bar,
- item, x, y)) {
- *before_item = item_num;
- return -1;
- }
- } else {
- if (e_icon_bar_small_icons_intersects (icon_bar, item,
- x, y))
- return item_num;
-
- if (before_item
- && e_icon_bar_small_icons_is_before (icon_bar,
- item, x, y)) {
- *before_item = item_num;
- return -1;
- }
-
- }
-
- }
-
- /* If the mouse is below all the items, but inside the items' width,
- and before_item is not NULL, we set it to the number of items, so
- the dropped item would be added at the end. Note that this assumes
- that the item variable points to the last item in the EIconBar. */
- if (before_item) {
- if (icon_bar->view_type == E_ICON_BAR_LARGE_ICONS) {
- if (x < icon_bar->text_x
- || x >= icon_bar->text_x + icon_bar->text_w)
- return -1;
-
- if (item == NULL
- || y > item->icon_y + item->item_height)
- *before_item = icon_bar->items->len;
- } else {
- if (x < icon_bar->icon_x
- || x >= icon_bar->text_x + icon_bar->text_w)
- return -1;
-
- if (item == NULL) {
- *before_item = icon_bar->items->len;
- } else {
- gint max_y;
- max_y = MAX (item->icon_y + icon_bar->icon_h,
- item->text_y + item->text_height);
- if (y > max_y)
- *before_item = icon_bar->items->len;
- }
- }
- }
-
- return -1;
-}
-
-
-static gboolean
-e_icon_bar_large_icons_intersects (EIconBar *icon_bar,
- EIconBarItem *item,
- gint x,
- gint y)
-{
- if (y < item->icon_y || y >= item->text_y + item->text_height)
- return FALSE;
-
- if (y < item->icon_y + icon_bar->icon_h) {
- if (x < icon_bar->icon_x
- || x >= icon_bar->icon_x + icon_bar->icon_w)
- return FALSE;
- } else {
- if (x < item->text_x
- || x >= item->text_x + item->text_width)
- return FALSE;
- }
-
- return TRUE;
-}
-
-
-static gboolean
-e_icon_bar_large_icons_is_before (EIconBar *icon_bar,
- EIconBarItem *item,
- gint x,
- gint y)
-{
- if (y < item->icon_y - icon_bar->spacing
- || y >= item->icon_y)
- return FALSE;
-
- if (x < icon_bar->text_x || x >= icon_bar->text_x + icon_bar->text_w)
- return FALSE;
-
- return TRUE;
-}
-
-
-static gboolean
-e_icon_bar_small_icons_intersects (EIconBar *icon_bar,
- EIconBarItem *item,
- gint x,
- gint y)
-{
- gint min_y, max_y;
-
- min_y = MIN (item->icon_y, item->text_y);
- max_y = MAX (item->icon_y + icon_bar->icon_h,
- item->text_y + item->text_height);
-
- if (y < min_y || y >= max_y)
- return FALSE;
-
- if (x < icon_bar->icon_x || x >= item->text_x + item->text_width)
- return FALSE;
-
- return TRUE;
-}
-
-
-static gboolean
-e_icon_bar_small_icons_is_before (EIconBar *icon_bar,
- EIconBarItem *item,
- gint x,
- gint y)
-{
- gint min_y, max_y;
-
- max_y = MIN (item->icon_y, item->text_y);
- min_y = max_y - icon_bar->spacing;
-
- if (y < min_y || y >= max_y)
- return FALSE;
-
- if (x < icon_bar->icon_x || x >= icon_bar->text_x + icon_bar->text_w)
- return FALSE;
-
- return TRUE;
-}
-
-
-/**
- * e_icon_bar_start_editing_item:
- * @icon_bar: An #EIconBar.
- * @item_num: The index of the item.
- *
- * Turns the item into an editable text field so the user can rename it.
- * Editing is stopped automatically when the user hits 'Return' or clicks
- * outside the item. It can also be stopped explicitly by calling
- * e_icon_bar_stop_editing_item().
- **/
-void
-e_icon_bar_start_editing_item (EIconBar *icon_bar,
- gint item_num)
-{
- EIconBarItem *item;
-
- g_return_if_fail (E_IS_ICON_BAR (icon_bar));
- g_return_if_fail (item_num >= 0);
- g_return_if_fail (item_num < icon_bar->items->len);
-
- item = &g_array_index (icon_bar->items,
- EIconBarItem, item_num);
- e_canvas_item_grab_focus (item->text);
-}
-
-
-/**
- * e_icon_bar_stop_editing_item:
- * @icon_bar: An #EIconBar.
- * @accept: TRUE if the changes should be accepted, FALSE if the text should be
- * changed back to its state before the editing started.
- *
- * Stops the editing of the items, if any were being edited.
- **/
-void
-e_icon_bar_stop_editing_item (EIconBar *icon_bar,
- gboolean accept)
-{
- EIconBarItem *item;
- GtkWidget *toplevel;
-
- g_return_if_fail (E_IS_ICON_BAR (icon_bar));
-
- if (icon_bar->editing_item_num != -1) {
- item = &g_array_index (icon_bar->items, EIconBarItem,
- icon_bar->editing_item_num);
-
- toplevel = gtk_widget_get_toplevel (GTK_WIDGET (icon_bar));
- if (toplevel && GTK_IS_WINDOW (toplevel))
- gtk_window_set_focus (GTK_WINDOW (toplevel), NULL);
- }
-}
-
-
-static void
-e_icon_bar_on_editing_started (EIconBar *icon_bar,
- GnomeCanvasItem *item)
-{
- gint item_num;
- gdouble x1, y1, x2, y2;
-
- item_num = e_icon_bar_find_item (icon_bar, item);
- g_return_if_fail (item_num != -1);
-
- /* Turn off any highlighted item. */
- e_icon_bar_item_motion (icon_bar, -1, NULL);
-
- icon_bar->editing_item_num = item_num;
-
- e_icon_bar_ensure_edited_item_visible (icon_bar);
-
- /* Set the fg & bg colors. */
- gnome_canvas_item_set (item,
- "fill_color_gdk", &icon_bar->colors[E_ICON_BAR_COLOR_EDITING_TEXT],
- NULL);
-
- /* Create the edit rect if necessary. */
- if (!icon_bar->edit_rect_item) {
- icon_bar->edit_rect_item =
- gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (icon_bar)->root),
- gnome_canvas_rect_get_type(),
- "fill_color_gdk", &icon_bar->colors[E_ICON_BAR_COLOR_EDITING_RECT],
- "outline_color_gdk", &icon_bar->colors[E_ICON_BAR_COLOR_EDITING_RECT_OUTLINE],
- NULL);
- }
-
- gnome_canvas_item_get_bounds (item, &x1, &y1, &x2, &y2);
- gnome_canvas_item_set (icon_bar->edit_rect_item,
- "x1", x1 - 1,
- "y1", y1 - 1,
- "x2", x2 + 1,
- "y2", y2 + 1,
- NULL);
- gnome_canvas_item_show (icon_bar->edit_rect_item);
-
- /* Make sure the text item is on top. */
- gnome_canvas_item_raise_to_top (item);
-}
-
-
-static void
-e_icon_bar_on_editing_stopped (EIconBar *icon_bar,
- GnomeCanvasItem *item)
-{
- gint item_num;
-
- item_num = e_icon_bar_find_item (icon_bar, item);
- g_return_if_fail (item_num != -1);
-
- icon_bar->editing_item_num = -1;
-
- e_icon_bar_update_highlight (icon_bar);
-
- /* Reset the fg & bg colors. */
- gnome_canvas_item_set (item,
- "fill_color_gdk", &(GTK_WIDGET(icon_bar)->style->fg [GTK_STATE_NORMAL]),
- NULL);
-
- if (icon_bar->edit_rect_item) {
- gnome_canvas_item_hide (icon_bar->edit_rect_item);
- }
-}
-
-
-static void
-e_icon_bar_ensure_edited_item_visible (EIconBar *icon_bar)
-{
- EIconBarItem *item;
- gint scroll_x, scroll_y, min_scroll_y, max_scroll_y, new_scroll_y;
-
- if (icon_bar->editing_item_num == -1)
- return;
-
- item = &g_array_index (icon_bar->items,
- EIconBarItem, icon_bar->editing_item_num);
- gnome_canvas_get_scroll_offsets (GNOME_CANVAS (icon_bar),
- &scroll_x, &scroll_y);
-
- /* The minimum scroll y position is with the text right on the bottom
- of the display. */
- min_scroll_y = item->text_y + item->text_height + E_ICON_BAR_V_SPACE
- - GTK_WIDGET (icon_bar)->allocation.height;
- /* The maximum scroll y position is with the text at the top. */
- max_scroll_y = item->text_y - E_ICON_BAR_V_SPACE;
-
- new_scroll_y = MAX (scroll_y, min_scroll_y);
- new_scroll_y = MIN (new_scroll_y, max_scroll_y);
-
- if (new_scroll_y != scroll_y)
- gnome_canvas_scroll_to (GNOME_CANVAS (icon_bar),
- scroll_x, new_scroll_y);
-}
-
-
-/* This gets the mouse position and updates the highlight if necessary.
- It is called after items are added/deleted/scrolled/edited. */
-static void
-e_icon_bar_update_highlight (EIconBar *icon_bar)
-{
- GtkWidget *widget;
- gint x, y, item_num;
-
- widget = GTK_WIDGET (icon_bar);
-
- if (!widget->window)
- return;
-
- gdk_window_get_pointer (widget->window, &x, &y, NULL);
-
- if (x < 0 || y < 0
- || x > widget->allocation.width || y > widget->allocation.height)
- return;
-
- x += icon_bar->canvas.parent.layout.hadjustment->value;
- y += icon_bar->canvas.parent.layout.vadjustment->value;
- item_num = e_icon_bar_find_item_at_position (icon_bar, x, y, NULL);
- e_icon_bar_item_motion (icon_bar, item_num, NULL);
-}
-
-
-static gint
-e_icon_bar_drag_motion (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- guint time)
-{
- EIconBar *icon_bar;
- gint item_num, before_item, scroll_x, scroll_y;
-
- g_return_val_if_fail (E_IS_ICON_BAR (widget), FALSE);
-
- icon_bar = E_ICON_BAR (widget);
-
- icon_bar->in_drag = TRUE;
-
- /* Check if the mouse is over or between items, and if so highlight. */
- gnome_canvas_get_scroll_offsets (GNOME_CANVAS (icon_bar),
- &scroll_x, &scroll_y);
- item_num = e_icon_bar_find_item_at_position (icon_bar,
- x + scroll_x,
- y + scroll_y,
- &before_item);
- e_icon_bar_item_motion (icon_bar, item_num, NULL);
- e_icon_bar_set_dragging_before_item (icon_bar, before_item);
-
- /* Check if the mouse is at the top or bottom of the bar, and if it is
- scroll up/down. */
- if (y < E_ICON_BAR_DRAG_AUTO_SCROLL_OFFSET)
- icon_bar->scrolling_up = TRUE;
- else if (y >= widget->allocation.height - E_ICON_BAR_DRAG_AUTO_SCROLL_OFFSET)
- icon_bar->scrolling_up = FALSE;
- else {
- if (icon_bar->auto_scroll_timeout_id != 0) {
- gtk_timeout_remove (icon_bar->auto_scroll_timeout_id);
- icon_bar->auto_scroll_timeout_id = 0;
- }
- return FALSE;
- }
-
- if (icon_bar->auto_scroll_timeout_id == 0) {
- icon_bar->auto_scroll_timeout_id = g_timeout_add (E_ICON_BAR_SCROLL_TIMEOUT, e_icon_bar_timeout_handler, icon_bar);
- icon_bar->auto_scroll_delay = E_ICON_BAR_SCROLL_DELAY;
- }
-
- return FALSE;
-}
-
-
-static void
-e_icon_bar_drag_leave (GtkWidget *widget,
- GdkDragContext *context,
- guint time)
-{
- EIconBar *icon_bar;
-
- g_return_if_fail (E_IS_ICON_BAR (widget));
-
- icon_bar = E_ICON_BAR (widget);
-
- icon_bar->in_drag = FALSE;
-
- if (icon_bar->auto_scroll_timeout_id != 0) {
- gtk_timeout_remove (icon_bar->auto_scroll_timeout_id);
- icon_bar->auto_scroll_timeout_id = 0;
- }
-
- if (icon_bar->mouse_over_item_num != -1) {
- icon_bar->mouse_over_item_num = -1;
- gtk_widget_queue_draw (GTK_WIDGET (icon_bar));
- }
-}
-
-
-static void
-e_icon_bar_set_dragging_before_item (EIconBar *icon_bar,
- gint before_item)
-{
- if (icon_bar->dragging_before_item_num == before_item)
- return;
-
- icon_bar->dragging_before_item_num = before_item;
-
- gtk_widget_queue_draw (GTK_WIDGET (icon_bar));
-}
-
-
-static gboolean
-e_icon_bar_timeout_handler (gpointer data)
-{
- EIconBar *icon_bar;
- gint scroll_x, scroll_y, new_scroll_y;
- GtkAdjustment *adj;
-
- g_return_val_if_fail (E_IS_ICON_BAR (data), FALSE);
-
- icon_bar = E_ICON_BAR (data);
-
- GDK_THREADS_ENTER ();
-
- if (icon_bar->auto_scroll_delay > 0) {
- icon_bar->auto_scroll_delay--;
- GDK_THREADS_LEAVE ();
- return TRUE;
- }
-
- gnome_canvas_get_scroll_offsets (GNOME_CANVAS (icon_bar),
- &scroll_x, &scroll_y);
-
- adj = GTK_LAYOUT (icon_bar)->vadjustment;
-
- if (icon_bar->scrolling_up)
- new_scroll_y = MAX (scroll_y - adj->step_increment, 0);
- else
- new_scroll_y = MIN (scroll_y + adj->step_increment,
- adj->upper - adj->page_size);
-
- if (new_scroll_y != scroll_y)
- gnome_canvas_scroll_to (GNOME_CANVAS (icon_bar),
- scroll_x, new_scroll_y);
-
- GDK_THREADS_LEAVE ();
- return TRUE;
-}
-
-
-static void
-e_icon_bar_vadjustment_value_changed (GtkAdjustment *adjustment,
- EIconBar *icon_bar)
-{
- e_icon_bar_update_highlight (icon_bar);
-}
-
diff --git a/widgets/shortcut-bar/e-icon-bar.h b/widgets/shortcut-bar/e-icon-bar.h
deleted file mode 100644
index 47a806cae5..0000000000
--- a/widgets/shortcut-bar/e-icon-bar.h
+++ /dev/null
@@ -1,246 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- * Author :
- * Damon Chaplin <damon@helixcode.com>
- *
- * Copyright 1999, Helix Code, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-#ifndef _E_ICON_BAR_H_
-#define _E_ICON_BAR_H_
-
-#include <gdk_imlib.h>
-#include <gdk-pixbuf/gdk-pixbuf.h>
-#include <gal/widgets/e-canvas.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-/*
- * EIconBar is a subclass of GnomeCanvas for displaying a vertical column of
- * icons and descriptions. It provides 2 views - large icons and small icons.
- */
-
-
-/* This contains information on one item. */
-typedef struct _EIconBarItem EIconBarItem;
-struct _EIconBarItem
-{
- GnomeCanvasItem *text;
- GnomeCanvasItem *image;
-
- /* This holds the original pixbuf so that we can blend
- to the background if the style changes */
- GdkPixbuf *pixbuf;
-
- /* This is user data attached to the item, e.g. a URL. */
- gpointer data;
- GtkDestroyNotify destroy;
-
- /* This is the height of the item. */
- gint item_height;
-
- /* This is the actual x, width and height of the text, rather than
- the maximum allowed area. */
- gint text_x;
- gint text_width;
- gint text_height;
-
- gint icon_y, text_y;
-};
-
-
-/* These are the view types. Defaults to LARGE_ICONS. */
-typedef enum
-{
- E_ICON_BAR_LARGE_ICONS,
- E_ICON_BAR_SMALL_ICONS
-} EIconBarViewType;
-
-
-/* These index our colors array. */
-typedef enum
-{
- E_ICON_BAR_COLOR_EDITING_TEXT,
- E_ICON_BAR_COLOR_EDITING_RECT,
- E_ICON_BAR_COLOR_EDITING_RECT_OUTLINE,
-
- E_ICON_BAR_COLOR_LAST
-} EIconBarColors;
-
-
-#define E_ICON_BAR(obj) GTK_CHECK_CAST (obj, e_icon_bar_get_type (), EIconBar)
-#define E_ICON_BAR_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, e_icon_bar_get_type (), EIconBarClass)
-#define E_IS_ICON_BAR(obj) GTK_CHECK_TYPE (obj, e_icon_bar_get_type ())
-
-
-typedef struct _EIconBar EIconBar;
-typedef struct _EIconBarClass EIconBarClass;
-
-struct _EIconBar
-{
- ECanvas canvas;
-
- /* This specifies if we are using large icons or small icons. */
- EIconBarViewType view_type;
-
- /* This is an array of EIconBarItem elements. */
- GArray *items;
-
- /* This is the index of the item which has been pressed, or -1.
- It will be shown as pressed in while the mouse is over it. */
- gint pressed_item_num;
-
- /* This is the coordinates of where the button was pressed. If the
- mouse moves a certain distance with the button still pressed, we
- start a drag. */
- gint pressed_x;
- gint pressed_y;
-
- /* This is the index of the item the mouse is currently over, or -1.
- It will be highlighted unless one of the items is pressed. */
- gint mouse_over_item_num;
-
- /* This is the item that we are currently editing, or -1. */
- gint editing_item_num;
-
- /* This is a GnomeCanvasRect which is placed around the edited item. */
- GnomeCanvasItem *edit_rect_item;
-
- /* This is the index of the item which is being dragged, or -1.
- If the drag results in a move it will be deleted. */
- gint dragged_item_num;
-
- /* This is TRUE if we are dragging over this EIconBar. */
- gboolean in_drag;
-
- /* This is used in drag-and-drop to indicate the item which the mouse
- is currently before, e.g. if it is 1 then a dropped item would be
- inserted between items 0 and 1. It ranges from 0 to the number of
- items, or is -1 when the mouse is not dragging between items. */
- gint dragging_before_item_num;
-
- /* These are the common positions of all the items in the EIconBar. */
- gint icon_x, icon_w, icon_h, text_x, text_w, spacing;
-
- /* This is the source id of our auto-scroll timeout handler, used when
- in the middle of drag-and-drop operations. */
- gint auto_scroll_timeout_id;
- gint auto_scroll_delay;
- gboolean scrolling_up;
-
- /* Colors for drawing. */
- GdkColor colors[E_ICON_BAR_COLOR_LAST];
-
- /* Signal connection id for "value_changed" signal of vadjustment. */
- guint vadjustment_value_changed_id;
-};
-
-struct _EIconBarClass
-{
- ECanvasClass parent_class;
-
- void (*selected_item) (EIconBar *icon_bar,
- GdkEvent *event,
- gint item_num);
- void (*dragged_item) (EIconBar *icon_bar,
- GdkEvent *event,
- gint item_num);
-};
-
-
-GtkType e_icon_bar_get_type (void);
-GtkWidget* e_icon_bar_new (void);
-
-/* Sets the view type. */
-void e_icon_bar_set_view_type (EIconBar *icon_bar,
- EIconBarViewType view_type);
-
-/* Adds a new item to a group at the given position. If position is -1 it is
- added at the end. It returns the index of the item. */
-gint e_icon_bar_add_item (EIconBar *icon_bar,
- GdkPixbuf *image,
- const gchar *text,
- gint position);
-
-/* Reorders an item. Note that position refers to the new position to add the
- item after removing it from its current position. If position is -1 it is
- moved to the end of the bar. */
-void e_icon_bar_reorder_item (EIconBar *icon_bar,
- gint item_num,
- gint new_position);
-void e_icon_bar_remove_item (EIconBar *icon_bar,
- gint item_num);
-
-GdkPixbuf * e_icon_bar_get_item_image (EIconBar *icon_bar,
- gint item_num);
-void e_icon_bar_set_item_image (EIconBar *icon_bar,
- gint item_num,
- GdkPixbuf *image);
-
-gchar* e_icon_bar_get_item_text (EIconBar *icon_bar,
- gint item_num);
-void e_icon_bar_set_item_text (EIconBar *icon_bar,
- gint item_num,
- gchar *text);
-
-gpointer e_icon_bar_get_item_data (EIconBar *icon_bar,
- gint item_num);
-void e_icon_bar_set_item_data (EIconBar *icon_bar,
- gint item_num,
- gpointer data);
-void e_icon_bar_set_item_data_full (EIconBar *icon_bar,
- gint item_num,
- gpointer data,
- GtkDestroyNotify destroy);
-
-void e_icon_bar_start_editing_item (EIconBar *icon_bar,
- gint item_num);
-void e_icon_bar_stop_editing_item (EIconBar *icon_bar,
- gboolean accept);
-
-
-
-/*
- * INTERNAL FUNCTIONS - for use by EIconBarBgItem.
- */
-
-/* This returns the index of the item at the given position on the EIconBar,
- or -1 if no item is found. If before_item is not NULL, it returns the
- item which the mouse is before, or -1 (this is used for dragging). */
-gint e_icon_bar_find_item_at_position (EIconBar *icon_bar,
- gint x,
- gint y,
- gint *before_item);
-
-void e_icon_bar_item_pressed (EIconBar *icon_bar,
- gint item_num,
- GdkEvent *event);
-void e_icon_bar_item_released (EIconBar *icon_bar,
- gint item_num,
- GdkEvent *event);
-void e_icon_bar_item_motion (EIconBar *icon_bar,
- gint item_num,
- GdkEvent *event);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* _E_ICON_BAR_H_ */
diff --git a/widgets/shortcut-bar/e-shortcut-bar.c b/widgets/shortcut-bar/e-shortcut-bar.c
deleted file mode 100644
index 0e577c9207..0000000000
--- a/widgets/shortcut-bar/e-shortcut-bar.c
+++ /dev/null
@@ -1,799 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- * Author :
- * Damon Chaplin <damon@helixcode.com>
- *
- * Copyright 1999, Helix Code, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-/*
- * EShortcutBar displays a vertical bar with a number of Groups, each of which
- * contains any number of icons. It is used on the left of the main application
- * window so users can easily access items such as folders and files.
- *
- * The architecture is a bit complicated. EShortcutBar is a sublass of
- * EGroupBar (which supports a number of groups with buttons to slide them
- * into view). EShortcutBar places an EIconBar widget in each group page,
- * which displays an icon and name for each shortcut.
- */
-
-#include <config.h>
-#include <string.h>
-#include <gal/util/e-util.h>
-#include "e-shortcut-bar.h"
-#include "e-clipped-label.h"
-#include "e-vscrolled-bar.h"
-
-/* Drag and Drop stuff. */
-enum {
- TARGET_SHORTCUT
-};
-static GtkTargetEntry target_table[] = {
- { "E-SHORTCUT", 0, TARGET_SHORTCUT }
-};
-static guint n_targets = sizeof(target_table) / sizeof(target_table[0]);
-
-gboolean e_shortcut_bar_default_icon_loaded = FALSE;
-GdkPixbuf *e_shortcut_bar_default_icon = NULL;
-gchar *e_shortcut_bar_default_icon_filename = "gnome-folder.png";
-
-static void e_shortcut_bar_class_init (EShortcutBarClass *class);
-static void e_shortcut_bar_init (EShortcutBar *shortcut_bar);
-static void e_shortcut_bar_destroy (GtkObject *object);
-
-static void e_shortcut_bar_disconnect_model (EShortcutBar *shortcut_bar);
-
-static void e_shortcut_bar_on_model_destroyed (EShortcutModel *model,
- EShortcutBar *shortcut_bar);
-static void e_shortcut_bar_on_group_added (EShortcutModel *model,
- gint group_num,
- gchar *group_name,
- EShortcutBar *shortcut_bar);
-static void e_shortcut_bar_on_group_removed (EShortcutModel *model,
- gint group_num,
- EShortcutBar *shortcut_bar);
-static void e_shortcut_bar_on_item_added (EShortcutModel *model,
- gint group_num,
- gint item_num,
- gchar *item_url,
- gchar *item_name,
- EShortcutBar *shortcut_bar);
-static void e_shortcut_bar_on_item_removed (EShortcutModel *model,
- gint group_num,
- gint item_num,
- EShortcutBar *shortcut_bar);
-
-static gint e_shortcut_bar_add_group (EShortcutBar *shortcut_bar,
- gint position,
- const gchar *group_name);
-static void e_shortcut_bar_remove_group (EShortcutBar *shortcut_bar,
- gint group_num);
-static gint e_shortcut_bar_add_item (EShortcutBar *shortcut_bar,
- gint group_num,
- gint position,
- const gchar *item_url,
- const gchar *item_name);
-static void e_shortcut_bar_remove_item (EShortcutBar *shortcut_bar,
- gint group_num,
- gint item_num);
-
-
-static void e_shortcut_bar_set_canvas_style (EShortcutBar *shortcut_bar,
- GtkWidget *canvas);
-static void e_shortcut_bar_item_selected (EIconBar *icon_bar,
- GdkEvent *event,
- gint item_num,
- EShortcutBar *shortcut_bar);
-static void e_shortcut_bar_item_dragged (EIconBar *icon_bar,
- GdkEvent *event,
- gint item_num,
- EShortcutBar *shortcut_bar);
-static void e_shortcut_bar_on_drag_data_get (GtkWidget *widget,
- GdkDragContext *context,
- GtkSelectionData *selection_data,
- guint info,
- guint time,
- EShortcutBar *shortcut_bar);
-static void e_shortcut_bar_on_drag_data_received(GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- GtkSelectionData *data,
- guint info,
- guint time,
- EShortcutBar *shortcut_bar);
-static void e_shortcut_bar_on_drag_data_delete (GtkWidget *widget,
- GdkDragContext *context,
- EShortcutBar *shortcut_bar);
-static void e_shortcut_bar_on_drag_end (GtkWidget *widget,
- GdkDragContext *context,
- EShortcutBar *shortcut_bar);
-static void e_shortcut_bar_stop_editing (GtkWidget *button,
- EShortcutBar *shortcut_bar);
-static GdkPixbuf* e_shortcut_bar_get_image_from_url (EShortcutBar *shortcut_bar,
- const gchar *item_url);
-static GdkPixbuf* e_shortcut_bar_load_image (const gchar *filename);
-
-
-enum
-{
- ITEM_SELECTED,
- SHORTCUT_DROPPED,
- SHORTCUT_DRAGGED,
- LAST_SIGNAL
-};
-
-static guint e_shortcut_bar_signals[LAST_SIGNAL] = {0};
-
-static EGroupBarClass *parent_class;
-
-static void
-e_shortcut_bar_marshal_NONE__INT_INT_STRING_STRING (GtkObject *object,
- GtkSignalFunc func,
- gpointer func_data,
- GtkArg *args)
-{
- void (*rfunc) (GtkObject *, gint, gint, gchar *, gchar *, gpointer) = func;
-
- (*rfunc) (object,
- GTK_VALUE_INT (args[0]),
- GTK_VALUE_INT (args[1]),
- GTK_VALUE_STRING (args[2]),
- GTK_VALUE_STRING (args[3]),
- func_data);
-}
-
-E_MAKE_TYPE(e_shortcut_bar, "EShortcutBar", EShortcutBar,
- e_shortcut_bar_class_init, e_shortcut_bar_init,
- e_group_bar_get_type())
-
-
-static void
-e_shortcut_bar_class_init (EShortcutBarClass *class)
-{
- GtkObjectClass *object_class;
- GtkWidgetClass *widget_class;
-
- parent_class = gtk_type_class (e_group_bar_get_type ());
-
- object_class = (GtkObjectClass *) class;
- widget_class = (GtkWidgetClass *) class;
-
- e_shortcut_bar_signals[ITEM_SELECTED] =
- gtk_signal_new ("item_selected",
- GTK_RUN_LAST | GTK_RUN_ACTION,
- object_class->type,
- GTK_SIGNAL_OFFSET (EShortcutBarClass,
- item_selected),
- gtk_marshal_NONE__POINTER_INT_INT,
- GTK_TYPE_NONE, 3, GTK_TYPE_GDK_EVENT,
- GTK_TYPE_INT, GTK_TYPE_INT);
-
- e_shortcut_bar_signals[SHORTCUT_DROPPED] =
- gtk_signal_new ("shortcut_dropped",
- GTK_RUN_LAST | GTK_RUN_ACTION,
- object_class->type,
- GTK_SIGNAL_OFFSET (EShortcutBarClass, shortcut_dropped),
- e_shortcut_bar_marshal_NONE__INT_INT_STRING_STRING,
- GTK_TYPE_NONE, 4,
- GTK_TYPE_INT,
- GTK_TYPE_INT,
- GTK_TYPE_STRING,
- GTK_TYPE_STRING);
-
- e_shortcut_bar_signals[SHORTCUT_DRAGGED] =
- gtk_signal_new ("shortcut_dragged",
- GTK_RUN_LAST | GTK_RUN_ACTION,
- object_class->type,
- GTK_SIGNAL_OFFSET (EShortcutBarClass, shortcut_dragged),
- gtk_marshal_NONE__INT_INT,
- GTK_TYPE_NONE, 2,
- GTK_TYPE_INT,
- GTK_TYPE_INT);
-
- gtk_object_class_add_signals (object_class, e_shortcut_bar_signals,
- LAST_SIGNAL);
-
- /* Method override */
- object_class->destroy = e_shortcut_bar_destroy;
-}
-
-
-static void
-e_shortcut_bar_init (EShortcutBar *shortcut_bar)
-{
- shortcut_bar->groups = g_array_new (FALSE, FALSE,
- sizeof (EShortcutBarGroup));
-
- shortcut_bar->dragged_url = NULL;
- shortcut_bar->dragged_name = NULL;
-}
-
-
-GtkWidget *
-e_shortcut_bar_new (void)
-{
- GtkWidget *shortcut_bar;
-
- shortcut_bar = GTK_WIDGET (gtk_type_new (e_shortcut_bar_get_type ()));
-
- return shortcut_bar;
-}
-
-
-static void
-e_shortcut_bar_destroy (GtkObject *object)
-{
- EShortcutBar *shortcut_bar;
-
- shortcut_bar = E_SHORTCUT_BAR (object);
-
- e_shortcut_bar_disconnect_model (shortcut_bar);
-
- g_array_free (shortcut_bar->groups, TRUE);
-
- g_free (shortcut_bar->dragged_url);
- g_free (shortcut_bar->dragged_name);
-
- GTK_OBJECT_CLASS (parent_class)->destroy (object);
-}
-
-
-void
-e_shortcut_bar_set_model (EShortcutBar *shortcut_bar,
- EShortcutModel *model)
-{
- gint num_groups, group_num, num_items, item_num;
- gchar *group_name, *item_url, *item_name;
-
- /* Disconnect any existing model. */
- e_shortcut_bar_disconnect_model (shortcut_bar);
-
- shortcut_bar->model = model;
-
- if (!model)
- return;
-
- gtk_signal_connect (GTK_OBJECT (model), "destroy",
- GTK_SIGNAL_FUNC (e_shortcut_bar_on_model_destroyed),
- shortcut_bar);
- gtk_signal_connect (GTK_OBJECT (model), "group_added",
- GTK_SIGNAL_FUNC (e_shortcut_bar_on_group_added),
- shortcut_bar);
- gtk_signal_connect (GTK_OBJECT (model), "group_removed",
- GTK_SIGNAL_FUNC (e_shortcut_bar_on_group_removed),
- shortcut_bar);
- gtk_signal_connect (GTK_OBJECT (model), "item_added",
- GTK_SIGNAL_FUNC (e_shortcut_bar_on_item_added),
- shortcut_bar);
- gtk_signal_connect (GTK_OBJECT (model), "item_removed",
- GTK_SIGNAL_FUNC (e_shortcut_bar_on_item_removed),
- shortcut_bar);
-
- /* Add any items already in the model. */
- num_groups = e_shortcut_model_get_num_groups (model);
- for (group_num = 0; group_num < num_groups; group_num++) {
- group_name = e_shortcut_model_get_group_name (model,
- group_num);
- e_shortcut_bar_add_group (shortcut_bar, group_num, group_name);
- g_free (group_name);
-
- num_items = e_shortcut_model_get_num_items (model, group_num);
- for (item_num = 0; item_num < num_items; item_num++) {
- e_shortcut_model_get_item_info (model, group_num,
- item_num, &item_url,
- &item_name);
- e_shortcut_bar_add_item (shortcut_bar, group_num,
- item_num, item_url,
- item_name);
- g_free (item_url);
- g_free (item_name);
- }
- }
-}
-
-
-static void
-e_shortcut_bar_disconnect_model (EShortcutBar *shortcut_bar)
-{
- /* Remove all the current groups. */
- while (shortcut_bar->groups->len)
- e_shortcut_bar_remove_group (shortcut_bar, 0);
-
- if (shortcut_bar->model) {
- /* Disconnect all the signals in one go. */
- gtk_signal_disconnect_by_data (GTK_OBJECT (shortcut_bar->model), shortcut_bar);
- shortcut_bar->model = NULL;
- }
-}
-
-
-static void
-e_shortcut_bar_on_model_destroyed (EShortcutModel *model,
- EShortcutBar *shortcut_bar)
-{
- e_shortcut_bar_disconnect_model (shortcut_bar);
-}
-
-
-static void
-e_shortcut_bar_on_group_added (EShortcutModel *model,
- gint group_num,
- gchar *group_name,
- EShortcutBar *shortcut_bar)
-{
- e_shortcut_bar_add_group (shortcut_bar, group_num, group_name);
-}
-
-
-static void
-e_shortcut_bar_on_group_removed (EShortcutModel *model,
- gint group_num,
- EShortcutBar *shortcut_bar)
-{
- e_shortcut_bar_remove_group (shortcut_bar, group_num);
-}
-
-
-static void
-e_shortcut_bar_on_item_added (EShortcutModel *model,
- gint group_num,
- gint item_num,
- gchar *item_url,
- gchar *item_name,
- EShortcutBar *shortcut_bar)
-{
- e_shortcut_bar_add_item (shortcut_bar, group_num, item_num,
- item_url, item_name);
-}
-
-
-static void
-e_shortcut_bar_on_item_removed (EShortcutModel *model,
- gint group_num,
- gint item_num,
- EShortcutBar *shortcut_bar)
-{
- e_shortcut_bar_remove_item (shortcut_bar, group_num, item_num);
-}
-
-
-
-static gint
-e_shortcut_bar_add_group (EShortcutBar *shortcut_bar,
- gint position,
- const gchar *group_name)
-{
- EShortcutBarGroup *group, tmp_group;
- gint group_num;
- GtkWidget *button, *label;
-
- g_return_val_if_fail (E_IS_SHORTCUT_BAR (shortcut_bar), -1);
- g_return_val_if_fail (group_name != NULL, -1);
-
- gtk_widget_push_colormap (gdk_rgb_get_cmap ());
- gtk_widget_push_visual (gdk_rgb_get_visual ());
-
- group_num = position;
- g_array_insert_val (shortcut_bar->groups, group_num, tmp_group);
-
- group = &g_array_index (shortcut_bar->groups,
- EShortcutBarGroup, group_num);
-
- group->vscrolled_bar = e_vscrolled_bar_new (NULL);
- gtk_widget_show (group->vscrolled_bar);
- gtk_signal_connect (
- GTK_OBJECT (E_VSCROLLED_BAR (group->vscrolled_bar)->up_button),
- "pressed", GTK_SIGNAL_FUNC (e_shortcut_bar_stop_editing), shortcut_bar);
- gtk_signal_connect (
- GTK_OBJECT (E_VSCROLLED_BAR (group->vscrolled_bar)->down_button),
- "pressed", GTK_SIGNAL_FUNC (e_shortcut_bar_stop_editing), shortcut_bar);
-
- group->icon_bar = e_icon_bar_new ();
- gtk_widget_show (group->icon_bar);
- gtk_container_add (GTK_CONTAINER (group->vscrolled_bar),
- group->icon_bar);
- gtk_signal_connect (GTK_OBJECT (group->icon_bar), "item_selected",
- GTK_SIGNAL_FUNC (e_shortcut_bar_item_selected),
- shortcut_bar);
- gtk_signal_connect (GTK_OBJECT (group->icon_bar), "item_dragged",
- GTK_SIGNAL_FUNC (e_shortcut_bar_item_dragged),
- shortcut_bar);
- gtk_signal_connect (GTK_OBJECT (group->icon_bar), "drag_data_get",
- GTK_SIGNAL_FUNC (e_shortcut_bar_on_drag_data_get),
- shortcut_bar);
- gtk_signal_connect (GTK_OBJECT (group->icon_bar), "drag_data_received",
- GTK_SIGNAL_FUNC (e_shortcut_bar_on_drag_data_received),
- shortcut_bar);
- gtk_signal_connect (GTK_OBJECT (group->icon_bar), "drag_data_delete",
- GTK_SIGNAL_FUNC (e_shortcut_bar_on_drag_data_delete),
- shortcut_bar);
- gtk_signal_connect (GTK_OBJECT (group->icon_bar), "drag_end",
- GTK_SIGNAL_FUNC (e_shortcut_bar_on_drag_end),
- shortcut_bar);
-
-#ifndef E_USE_STYLES
- e_shortcut_bar_set_canvas_style (shortcut_bar, group->icon_bar);
-#endif
-
- button = gtk_button_new ();
- label = e_clipped_label_new (group_name);
- gtk_misc_set_alignment (GTK_MISC (label), 0.5, 0.5);
- gtk_widget_show (label);
- gtk_container_add (GTK_CONTAINER (button), label);
- gtk_widget_show (button);
- gtk_signal_connect (GTK_OBJECT (button), "clicked",
- GTK_SIGNAL_FUNC (e_shortcut_bar_stop_editing),
- shortcut_bar);
-
- gtk_drag_dest_set (GTK_WIDGET (group->icon_bar),
- GTK_DEST_DEFAULT_ALL,
- target_table, n_targets,
- GDK_ACTION_COPY | GDK_ACTION_MOVE);
- gtk_drag_dest_set (GTK_WIDGET (button),
- GTK_DEST_DEFAULT_ALL,
- target_table, n_targets,
- GDK_ACTION_COPY | GDK_ACTION_MOVE);
-
- e_group_bar_add_group (E_GROUP_BAR (shortcut_bar),
- group->vscrolled_bar, button, group_num);
-
- gtk_widget_pop_visual ();
- gtk_widget_pop_colormap ();
-
- return group_num;
-}
-
-
-static void
-e_shortcut_bar_remove_group (EShortcutBar *shortcut_bar,
- gint group_num)
-{
- e_group_bar_remove_group (E_GROUP_BAR (shortcut_bar), group_num);
- g_array_remove_index (shortcut_bar->groups, group_num);
-}
-
-
-static gint
-e_shortcut_bar_add_item (EShortcutBar *shortcut_bar,
- gint group_num,
- gint position,
- const gchar *item_url,
- const gchar *item_name)
-{
- EShortcutBarGroup *group;
- GdkPixbuf *image;
- gint item_num;
-
- g_return_val_if_fail (E_IS_SHORTCUT_BAR (shortcut_bar), -1);
- g_return_val_if_fail (group_num >= 0, -1);
- g_return_val_if_fail (group_num < shortcut_bar->groups->len, -1);
- g_return_val_if_fail (item_url != NULL, -1);
- g_return_val_if_fail (item_name != NULL, -1);
-
- image = e_shortcut_bar_get_image_from_url (shortcut_bar, item_url);
- group = &g_array_index (shortcut_bar->groups,
- EShortcutBarGroup, group_num);
-
- item_num = e_icon_bar_add_item (E_ICON_BAR (group->icon_bar),
- image, item_name, position);
- gdk_pixbuf_unref (image);
- e_icon_bar_set_item_data_full (E_ICON_BAR (group->icon_bar), item_num,
- g_strdup (item_url), g_free);
-
- return item_num;
-}
-
-
-static void
-e_shortcut_bar_remove_item (EShortcutBar *shortcut_bar,
- gint group_num,
- gint item_num)
-{
- EShortcutBarGroup *group;
-
- g_return_if_fail (E_IS_SHORTCUT_BAR (shortcut_bar));
- g_return_if_fail (group_num >= 0);
- g_return_if_fail (group_num < shortcut_bar->groups->len);
-
- group = &g_array_index (shortcut_bar->groups,
- EShortcutBarGroup, group_num);
-
- e_icon_bar_remove_item (E_ICON_BAR (group->icon_bar), item_num);
-}
-
-
-static void
-e_shortcut_bar_set_canvas_style (EShortcutBar *shortcut_bar,
- GtkWidget *canvas)
-{
- GtkRcStyle *rc_style;
-
- rc_style = gtk_rc_style_new ();
-
- rc_style->color_flags[GTK_STATE_NORMAL] = GTK_RC_FG | GTK_RC_BG;
- rc_style->fg[GTK_STATE_NORMAL].red = 65535;
- rc_style->fg[GTK_STATE_NORMAL].green = 65535;
- rc_style->fg[GTK_STATE_NORMAL].blue = 65535;
-
- rc_style->bg[GTK_STATE_NORMAL].red = 32512;
- rc_style->bg[GTK_STATE_NORMAL].green = 32512;
- rc_style->bg[GTK_STATE_NORMAL].blue = 32512;
-
- gtk_widget_modify_style (GTK_WIDGET (canvas), rc_style);
- gtk_rc_style_unref (rc_style);
-}
-
-
-void
-e_shortcut_bar_set_view_type (EShortcutBar *shortcut_bar,
- gint group_num,
- EIconBarViewType view_type)
-{
- EShortcutBarGroup *group;
-
- g_return_if_fail (E_IS_SHORTCUT_BAR (shortcut_bar));
- g_return_if_fail (group_num >= 0);
- g_return_if_fail (group_num < shortcut_bar->groups->len);
-
- group = &g_array_index (shortcut_bar->groups,
- EShortcutBarGroup, group_num);
-
- e_icon_bar_set_view_type (E_ICON_BAR (group->icon_bar), view_type);
-}
-
-
-EIconBarViewType
-e_shortcut_bar_get_view_type (EShortcutBar *shortcut_bar,
- gint group_num)
-{
- EShortcutBarGroup *group;
-
- g_return_val_if_fail (E_IS_SHORTCUT_BAR (shortcut_bar), E_ICON_BAR_SMALL_ICONS);
- g_return_val_if_fail (group_num >= 0, E_ICON_BAR_SMALL_ICONS);
- g_return_val_if_fail (group_num < shortcut_bar->groups->len, E_ICON_BAR_SMALL_ICONS);
-
- group = &g_array_index (shortcut_bar->groups,
- EShortcutBarGroup, group_num);
-
- return E_ICON_BAR (group->icon_bar)->view_type;
-}
-
-
-static void
-e_shortcut_bar_item_selected (EIconBar *icon_bar,
- GdkEvent *event,
- gint item_num,
- EShortcutBar *shortcut_bar)
-{
- gint group_num;
-
- group_num = e_group_bar_get_group_num (E_GROUP_BAR (shortcut_bar),
- GTK_WIDGET (icon_bar)->parent);
-
- gtk_signal_emit (GTK_OBJECT (shortcut_bar),
- e_shortcut_bar_signals[ITEM_SELECTED],
- event, group_num, item_num);
-}
-
-
-static void
-e_shortcut_bar_item_dragged (EIconBar *icon_bar,
- GdkEvent *event,
- gint item_num,
- EShortcutBar *shortcut_bar)
-{
- GtkTargetList *target_list;
- gint group_num;
-
- group_num = e_group_bar_get_group_num (E_GROUP_BAR (shortcut_bar),
- GTK_WIDGET (icon_bar)->parent);
-
- shortcut_bar->dragged_url = g_strdup (e_icon_bar_get_item_data (icon_bar, item_num));
- shortcut_bar->dragged_name = e_icon_bar_get_item_text (icon_bar, item_num);
-
- target_list = gtk_target_list_new (target_table, n_targets);
- gtk_drag_begin (GTK_WIDGET (icon_bar), target_list,
- GDK_ACTION_COPY | GDK_ACTION_MOVE,
- 1, event);
- gtk_target_list_unref (target_list);
-}
-
-
-static void
-e_shortcut_bar_on_drag_data_get (GtkWidget *widget,
- GdkDragContext *context,
- GtkSelectionData *selection_data,
- guint info,
- guint time,
- EShortcutBar *shortcut_bar)
-{
- gchar *data;
-
- if (info == TARGET_SHORTCUT) {
- data = g_strdup_printf ("%s%c%s", shortcut_bar->dragged_name,
- '\0', shortcut_bar->dragged_url);
- gtk_selection_data_set (selection_data, selection_data->target,
- 8, data,
- strlen (shortcut_bar->dragged_name)
- + strlen (shortcut_bar->dragged_url)
- + 2);
- g_free (data);
- }
-}
-
-
-static void
-e_shortcut_bar_on_drag_data_received (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- GtkSelectionData *data,
- guint info,
- guint time,
- EShortcutBar *shortcut_bar)
-{
- gchar *item_name, *item_url;
- EIconBar *icon_bar;
- gint position, group_num;
-
- icon_bar = E_ICON_BAR (widget);
- position = icon_bar->dragging_before_item_num;
-
- if ((data->length >= 0) && (data->format == 8)
- && position != -1) {
- item_name = data->data;
- item_url = item_name + strlen (item_name) + 1;
-
- group_num = e_group_bar_get_group_num (E_GROUP_BAR (shortcut_bar),
- GTK_WIDGET (icon_bar)->parent);
-
- gtk_signal_emit (GTK_OBJECT (shortcut_bar),
- e_shortcut_bar_signals[SHORTCUT_DROPPED],
- group_num, position, item_url, item_name);
-
- gtk_drag_finish (context, TRUE, TRUE, time);
- return;
- }
-
- gtk_drag_finish (context, FALSE, FALSE, time);
-}
-
-
-static void
-e_shortcut_bar_on_drag_data_delete (GtkWidget *widget,
- GdkDragContext *context,
- EShortcutBar *shortcut_bar)
-{
- EIconBar *icon_bar;
- gint group_num;
-
- icon_bar = E_ICON_BAR (widget);
-
- group_num = e_group_bar_get_group_num (E_GROUP_BAR (shortcut_bar),
- widget->parent);
-
- gtk_signal_emit (GTK_OBJECT (shortcut_bar), e_shortcut_bar_signals[SHORTCUT_DRAGGED],
- group_num, icon_bar->dragged_item_num);
-}
-
-
-static void
-e_shortcut_bar_on_drag_end (GtkWidget *widget,
- GdkDragContext *context,
- EShortcutBar *shortcut_bar)
-{
- g_free (shortcut_bar->dragged_name);
- shortcut_bar->dragged_name = NULL;
-
- g_free (shortcut_bar->dragged_url);
- shortcut_bar->dragged_url = NULL;
-}
-
-
-void
-e_shortcut_bar_start_editing_item (EShortcutBar *shortcut_bar,
- gint group_num,
- gint item_num)
-{
- EShortcutBarGroup *group;
-
- g_return_if_fail (E_IS_SHORTCUT_BAR (shortcut_bar));
- g_return_if_fail (group_num >= 0);
- g_return_if_fail (group_num < shortcut_bar->groups->len);
-
- group = &g_array_index (shortcut_bar->groups,
- EShortcutBarGroup, group_num);
-
- e_icon_bar_start_editing_item (E_ICON_BAR (group->icon_bar), item_num);
-}
-
-
-/* We stop editing any item when a scroll button is pressed. */
-static void
-e_shortcut_bar_stop_editing (GtkWidget *button,
- EShortcutBar *shortcut_bar)
-{
- EShortcutBarGroup *group;
- gint group_num;
-
- for (group_num = 0;
- group_num < shortcut_bar->groups->len;
- group_num++) {
- group = &g_array_index (shortcut_bar->groups,
- EShortcutBarGroup, group_num);
- e_icon_bar_stop_editing_item (E_ICON_BAR (group->icon_bar),
- TRUE);
- }
-}
-
-
-/* Sets the callback which is called to return the icon to use for a particular
- URL. */
-void
-e_shortcut_bar_set_icon_callback (EShortcutBar *shortcut_bar,
- EShortcutBarIconCallback cb,
- gpointer data)
-{
- shortcut_bar->icon_callback = cb;
- shortcut_bar->icon_callback_data = data;
-}
-
-
-static GdkPixbuf *
-e_shortcut_bar_get_image_from_url (EShortcutBar *shortcut_bar,
- const gchar *item_url)
-{
- GdkPixbuf *icon = NULL;
-
- if (shortcut_bar->icon_callback)
- icon = (*shortcut_bar->icon_callback) (shortcut_bar,
- item_url,
- shortcut_bar->icon_callback_data);
-
- if (!icon) {
- if (!e_shortcut_bar_default_icon_loaded) {
- e_shortcut_bar_default_icon_loaded = TRUE;
- e_shortcut_bar_default_icon = e_shortcut_bar_load_image (e_shortcut_bar_default_icon_filename);
- }
- icon = e_shortcut_bar_default_icon;
- /* ref the default icon each time we return it */
- gdk_pixbuf_ref (icon);
- }
-
- return icon;
-}
-
-
-static GdkPixbuf *
-e_shortcut_bar_load_image (const gchar *filename)
-{
- gchar *pathname;
- GdkPixbuf *image = NULL;
-
- pathname = gnome_pixmap_file (filename);
- if (pathname)
- image = gdk_pixbuf_new_from_file (pathname);
- else
- g_warning ("Couldn't find pixmap: %s", filename);
-
- g_free (pathname);
-
- return image;
-}
diff --git a/widgets/shortcut-bar/e-shortcut-bar.h b/widgets/shortcut-bar/e-shortcut-bar.h
deleted file mode 100644
index bfa33634e3..0000000000
--- a/widgets/shortcut-bar/e-shortcut-bar.h
+++ /dev/null
@@ -1,138 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- * Author :
- * Damon Chaplin <damon@helixcode.com>
- *
- * Copyright 1999, Helix Code, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-#ifndef _E_SHORTCUT_BAR_H_
-#define _E_SHORTCUT_BAR_H_
-
-#include "e-group-bar.h"
-#include "e-icon-bar.h"
-#include "e-shortcut-model.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-/*
- * EShortcutBar displays a vertical bar with a number of Groups, each of which
- * contains any number of icons. It is used on the left of the main application
- * window so users can easily access items such as folders and files.
- */
-
-typedef struct _EShortcutBar EShortcutBar;
-typedef struct _EShortcutBarClass EShortcutBarClass;
-
-
-typedef GdkPixbuf* (*EShortcutBarIconCallback) (EShortcutBar *shortcut_bar,
- const gchar *url,
- gpointer data);
-
-/* This contains information on one group. */
-typedef struct _EShortcutBarGroup EShortcutBarGroup;
-struct _EShortcutBarGroup
-{
- /* This is the EVScrolledBar which scrolls the group. */
- GtkWidget *vscrolled_bar;
-
- /* This is the icon bar containing the child items. */
- GtkWidget *icon_bar;
-};
-
-
-#define E_TYPE_SHORTCUT_BAR (e_shortcut_bar_get_type ())
-#define E_SHORTCUT_BAR(obj) GTK_CHECK_CAST (obj, e_shortcut_bar_get_type (), EShortcutBar)
-#define E_SHORTCUT_BAR_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, e_shortcut_bar_get_type (), EShortcutBarClass)
-#define E_IS_SHORTCUT_BAR(obj) GTK_CHECK_TYPE (obj, e_shortcut_bar_get_type ())
-
-
-struct _EShortcutBar
-{
- EGroupBar group_bar;
-
- /* This is the underlying model. */
- EShortcutModel *model;
-
- /* This is an array of EShortcutBarGroup elements. */
- GArray *groups;
-
- /* The callback which the application sets to return the icon to use
- for a given URL. */
- EShortcutBarIconCallback icon_callback;
-
- /* Closure for the callback. */
- gpointer icon_callback_data;
-
- gchar *dragged_url;
- gchar *dragged_name;
-};
-
-struct _EShortcutBarClass
-{
- EGroupBarClass parent_class;
-
- void (*item_selected) (EShortcutBar *shortcut_bar,
- GdkEvent *event,
- gint group_num,
- gint item_num);
-
- void (*shortcut_dropped) (EShortcutBar *shortcut_bar,
- gint group_num,
- gint position,
- const gchar *item_url,
- const char *item_name);
-
- void (*shortcut_dragged) (EShortcutBar *shortcut_bar,
- gint group_num,
- gint item_num);
-};
-
-
-GtkType e_shortcut_bar_get_type (void);
-GtkWidget* e_shortcut_bar_new (void);
-
-/* Sets the underlying model. */
-void e_shortcut_bar_set_model (EShortcutBar *shortcut_bar,
- EShortcutModel *shortcut_model);
-
-/* Sets/gets the view type for the group. */
-void e_shortcut_bar_set_view_type (EShortcutBar *shortcut_bar,
- gint group_num,
- EIconBarViewType view_type);
-EIconBarViewType e_shortcut_bar_get_view_type (EShortcutBar *shortcut_bar,
- gint group_num);
-
-void e_shortcut_bar_start_editing_item (EShortcutBar *shortcut_bar,
- gint group_num,
- gint item_num);
-
-/* Sets the callback which is called to return the icon to use for a particular
- URL. This callback must be set before any items are added. If the callback
- returns NULL the default icon is used. */
-void e_shortcut_bar_set_icon_callback (EShortcutBar *shortcut_bar,
- EShortcutBarIconCallback cb,
- gpointer data);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* _E_SHORTCUT_BAR_H_ */
diff --git a/widgets/shortcut-bar/e-shortcut-model.c b/widgets/shortcut-bar/e-shortcut-model.c
deleted file mode 100644
index 2151a4144b..0000000000
--- a/widgets/shortcut-bar/e-shortcut-model.c
+++ /dev/null
@@ -1,556 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- * Author :
- * Damon Chaplin <damon@helixcode.com>
- *
- * Copyright 1999, Helix Code, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-/*
- * EShortcutModel keeps track of a number of groups of shortcuts.
- * Each shortcut has a URL and a short textual name.
- * It is used as the model of the EShortcutBar.
- */
-
-#include <config.h>
-#include <gtk/gtksignal.h>
-#include <gal/util/e-util.h>
-#include "e-shortcut-model.h"
-
-/* This contains information on one item. */
-typedef struct _EShortcutModelItem EShortcutModelItem;
-struct _EShortcutModelItem
-{
- gchar *name;
- gchar *url;
-};
-
-
-/* This contains information on one group. */
-typedef struct _EShortcutModelGroup EShortcutModelGroup;
-struct _EShortcutModelGroup
-{
- gchar *name;
-
- /* An array of EShortcutModelItem. */
- GArray *items;
-};
-
-#define ESM_CLASS(e) ((EShortcutModelClass *)((GtkObject *)e)->klass)
-
-
-static void e_shortcut_model_class_init (EShortcutModelClass *class);
-static void e_shortcut_model_init (EShortcutModel *shortcut_model);
-static void e_shortcut_model_destroy (GtkObject *object);
-static void e_shortcut_model_free_group (EShortcutModel *shortcut_model,
- gint group_num);
-
-static void e_shortcut_model_real_add_group (EShortcutModel *shortcut_model,
- gint position,
- const gchar *group_name);
-static void e_shortcut_model_real_remove_group (EShortcutModel *shortcut_model,
- gint group_num);
-static void e_shortcut_model_real_add_item (EShortcutModel *shortcut_model,
- gint group_num,
- gint position,
- const gchar *item_url,
- const gchar *item_name);
-static void e_shortcut_model_real_remove_item (EShortcutModel *shortcut_model,
- gint group_num,
- gint item_num);
-
-static void e_shortcut_model_marshal1 (GtkObject *object,
- GtkSignalFunc func,
- gpointer func_data,
- GtkArg *args);
-static void e_shortcut_model_marshal2 (GtkObject *object,
- GtkSignalFunc func,
- gpointer func_data,
- GtkArg *args);
-
-static gint e_shortcut_model_real_get_num_groups(EShortcutModel *shortcut_model);
-static gint e_shortcut_model_real_get_num_items (EShortcutModel *shortcut_model,
- gint group_num);
-static gchar* e_shortcut_model_real_get_group_name (EShortcutModel *shortcut_model,
- gint group_num);
-static void e_shortcut_model_real_get_item_info (EShortcutModel *shortcut_model,
- gint group_num,
- gint item_num,
- gchar **item_url,
- gchar **item_name);
-
-enum
-{
- GROUP_ADDED,
- GROUP_REMOVED,
- ITEM_ADDED,
- ITEM_REMOVED,
-
- LAST_SIGNAL
-};
-
-static guint e_shortcut_model_signals[LAST_SIGNAL] = {0};
-
-static GtkObjectClass *parent_class;
-
-
-E_MAKE_TYPE(e_shortcut_model, "EShortcutModel", EShortcutModel,
- e_shortcut_model_class_init, e_shortcut_model_init,
- GTK_TYPE_OBJECT)
-
-
-static void
-e_shortcut_model_class_init (EShortcutModelClass *class)
-{
- GtkObjectClass *object_class;
-
- parent_class = gtk_type_class (GTK_TYPE_OBJECT);
-
- object_class = (GtkObjectClass *) class;
-
- e_shortcut_model_signals[GROUP_ADDED] =
- gtk_signal_new ("group_added",
- GTK_RUN_FIRST | GTK_RUN_ACTION,
- object_class->type,
- GTK_SIGNAL_OFFSET (EShortcutModelClass,
- group_added),
- e_shortcut_model_marshal1,
- GTK_TYPE_NONE, 2,
- GTK_TYPE_INT, GTK_TYPE_STRING);
-
- e_shortcut_model_signals[GROUP_REMOVED] =
- gtk_signal_new ("group_removed",
- GTK_RUN_FIRST | GTK_RUN_ACTION,
- object_class->type,
- GTK_SIGNAL_OFFSET (EShortcutModelClass,
- group_removed),
- gtk_marshal_NONE__INT,
- GTK_TYPE_NONE, 1,
- GTK_TYPE_INT);
-
- e_shortcut_model_signals[ITEM_ADDED] =
- gtk_signal_new ("item_added",
- GTK_RUN_FIRST | GTK_RUN_ACTION,
- object_class->type,
- GTK_SIGNAL_OFFSET (EShortcutModelClass,
- item_added),
- e_shortcut_model_marshal2,
- GTK_TYPE_NONE, 4,
- GTK_TYPE_INT, GTK_TYPE_INT,
- GTK_TYPE_STRING, GTK_TYPE_STRING);
-
- e_shortcut_model_signals[ITEM_REMOVED] =
- gtk_signal_new ("item_removed",
- GTK_RUN_FIRST | GTK_RUN_ACTION,
- object_class->type,
- GTK_SIGNAL_OFFSET (EShortcutModelClass,
- item_removed),
- gtk_marshal_NONE__INT_INT,
- GTK_TYPE_NONE, 2,
- GTK_TYPE_INT, GTK_TYPE_INT);
-
- gtk_object_class_add_signals (object_class, e_shortcut_model_signals,
- LAST_SIGNAL);
-
- /* Method override */
- object_class->destroy = e_shortcut_model_destroy;
-
- class->group_added = e_shortcut_model_real_add_group;
- class->group_removed = e_shortcut_model_real_remove_group;
- class->item_added = e_shortcut_model_real_add_item;
- class->item_removed = e_shortcut_model_real_remove_item;
-
- class->get_num_groups = e_shortcut_model_real_get_num_groups;
- class->get_num_items = e_shortcut_model_real_get_num_items;
- class->get_group_name = e_shortcut_model_real_get_group_name;
- class->get_item_info = e_shortcut_model_real_get_item_info;
-}
-
-
-static void
-e_shortcut_model_init (EShortcutModel *shortcut_model)
-{
- shortcut_model->groups = g_array_new (FALSE, FALSE,
- sizeof (EShortcutModelGroup));
-}
-
-
-EShortcutModel *
-e_shortcut_model_new (void)
-{
- EShortcutModel *shortcut_model;
-
- shortcut_model = E_SHORTCUT_MODEL (gtk_type_new (e_shortcut_model_get_type ()));
-
- return shortcut_model;
-}
-
-
-static void
-e_shortcut_model_destroy (GtkObject *object)
-{
- EShortcutModel *shortcut_model;
- gint num_groups, group_num;
-
- shortcut_model = E_SHORTCUT_MODEL (object);
-
- num_groups = shortcut_model->groups->len;
- for (group_num = 0; group_num < num_groups; group_num++)
- e_shortcut_model_free_group (shortcut_model, group_num);
-
- g_array_free (shortcut_model->groups, TRUE);
- shortcut_model->groups = NULL;
-
- GTK_OBJECT_CLASS (parent_class)->destroy (object);
-}
-
-
-static void
-e_shortcut_model_free_group (EShortcutModel *shortcut_model,
- gint group_num)
-{
- EShortcutModelGroup *group;
- EShortcutModelItem *item;
- gint item_num;
-
- group = &g_array_index (shortcut_model->groups,
- EShortcutModelGroup, group_num);
-
- g_free (group->name);
-
- for (item_num = 0; item_num < group->items->len; item_num++) {
- item = &g_array_index (group->items,
- EShortcutModelItem, item_num);
- g_free (item->name);
- g_free (item->url);
- }
-}
-
-
-gint
-e_shortcut_model_add_group (EShortcutModel *shortcut_model,
- gint position,
- const gchar *group_name)
-{
- g_return_val_if_fail (E_IS_SHORTCUT_MODEL (shortcut_model), -1);
- g_return_val_if_fail (group_name != NULL, -1);
-
- if (position == -1 || position > shortcut_model->groups->len)
- position = shortcut_model->groups->len;
-
- gtk_signal_emit (GTK_OBJECT (shortcut_model),
- e_shortcut_model_signals[GROUP_ADDED],
- position, group_name);
-
- return position;
-}
-
-
-static void
-e_shortcut_model_real_add_group (EShortcutModel *shortcut_model,
- gint group_num,
- const gchar *group_name)
-{
- EShortcutModelGroup *group, tmp_group;
-
- g_return_if_fail (E_IS_SHORTCUT_MODEL (shortcut_model));
- g_return_if_fail (group_num >= 0);
- g_return_if_fail (group_num <= shortcut_model->groups->len);
- g_return_if_fail (group_name != NULL);
-
- g_array_insert_val (shortcut_model->groups, group_num, tmp_group);
-
- group = &g_array_index (shortcut_model->groups,
- EShortcutModelGroup, group_num);
-
- group->name = g_strdup (group_name);
- group->items = g_array_new (FALSE, FALSE,
- sizeof (EShortcutModelItem));
-}
-
-
-void
-e_shortcut_model_remove_group (EShortcutModel *shortcut_model,
- gint group_num)
-{
- g_return_if_fail (E_IS_SHORTCUT_MODEL (shortcut_model));
- g_return_if_fail (group_num >= 0);
- g_return_if_fail (group_num < shortcut_model->groups->len);
-
- gtk_signal_emit (GTK_OBJECT (shortcut_model),
- e_shortcut_model_signals[GROUP_REMOVED],
- group_num);
-}
-
-
-static void
-e_shortcut_model_real_remove_group (EShortcutModel *shortcut_model,
- gint group_num)
-{
- g_return_if_fail (E_IS_SHORTCUT_MODEL (shortcut_model));
- g_return_if_fail (group_num >= 0);
- g_return_if_fail (group_num < shortcut_model->groups->len);
-
- e_shortcut_model_free_group (shortcut_model, group_num);
- g_array_remove_index (shortcut_model->groups, group_num);
-}
-
-
-gint
-e_shortcut_model_add_item (EShortcutModel *shortcut_model,
- gint group_num,
- gint position,
- const gchar *item_url,
- const gchar *item_name)
-{
- EShortcutModelGroup *group;
-
- g_return_val_if_fail (E_IS_SHORTCUT_MODEL (shortcut_model), -1);
- g_return_val_if_fail (group_num >= 0, -1);
- g_return_val_if_fail (group_num < shortcut_model->groups->len, -1);
- g_return_val_if_fail (item_url != NULL, -1);
- g_return_val_if_fail (item_name != NULL, -1);
-
- group = &g_array_index (shortcut_model->groups,
- EShortcutModelGroup, group_num);
-
- if (position == -1 || position > group->items->len)
- position = group->items->len;
-
- gtk_signal_emit (GTK_OBJECT (shortcut_model),
- e_shortcut_model_signals[ITEM_ADDED],
- group_num, position, item_url, item_name);
-
- return position;
-}
-
-
-static void
-e_shortcut_model_real_add_item (EShortcutModel *shortcut_model,
- gint group_num,
- gint item_num,
- const gchar *item_url,
- const gchar *item_name)
-{
- EShortcutModelGroup *group;
- EShortcutModelItem *item, tmp_item;
-
- g_return_if_fail (E_IS_SHORTCUT_MODEL (shortcut_model));
- g_return_if_fail (group_num >= 0);
- g_return_if_fail (group_num < shortcut_model->groups->len);
- g_return_if_fail (item_url != NULL);
- g_return_if_fail (item_name != NULL);
-
- group = &g_array_index (shortcut_model->groups,
- EShortcutModelGroup, group_num);
-
- g_return_if_fail (item_num >= 0);
- g_return_if_fail (item_num <= group->items->len);
-
- g_array_insert_val (group->items, item_num, tmp_item);
-
- item = &g_array_index (group->items,
- EShortcutModelItem, item_num);
-
- item->name = g_strdup (item_name);
- item->url = g_strdup (item_url);
-}
-
-
-void
-e_shortcut_model_remove_item (EShortcutModel *shortcut_model,
- gint group_num,
- gint item_num)
-{
- gtk_signal_emit (GTK_OBJECT (shortcut_model),
- e_shortcut_model_signals[ITEM_REMOVED],
- group_num, item_num);
-}
-
-
-static void
-e_shortcut_model_real_remove_item (EShortcutModel *shortcut_model,
- gint group_num,
- gint item_num)
-{
- EShortcutModelGroup *group;
- EShortcutModelItem *item;
-
- g_return_if_fail (E_IS_SHORTCUT_MODEL (shortcut_model));
- g_return_if_fail (group_num >= 0);
- g_return_if_fail (group_num < shortcut_model->groups->len);
-
- group = &g_array_index (shortcut_model->groups,
- EShortcutModelGroup, group_num);
-
- g_return_if_fail (item_num >= 0);
- g_return_if_fail (item_num < group->items->len);
-
- item = &g_array_index (group->items,
- EShortcutModelItem, item_num);
-
- g_free (item->name);
- g_free (item->url);
-
- g_array_remove_index (group->items, item_num);
-}
-
-
-static void
-e_shortcut_model_marshal1 (GtkObject *object,
- GtkSignalFunc func,
- gpointer func_data,
- GtkArg *args)
-{
- void (*rfunc) (GtkObject*, gint, gpointer, gpointer);
- rfunc = (void (*) (GtkObject*, gint, gpointer, gpointer)) func;
- (*rfunc) (object, GTK_VALUE_INT (args[0]), GTK_VALUE_STRING (args[1]),
- func_data);
-}
-
-
-static void
-e_shortcut_model_marshal2 (GtkObject *object,
- GtkSignalFunc func,
- gpointer func_data,
- GtkArg *args)
-{
- void (*rfunc) (GtkObject*, gint, gint, gpointer, gpointer, gpointer);
- rfunc = (void (*) (GtkObject*, gint, gint, gpointer, gpointer,
- gpointer)) func;
- (*rfunc) (object, GTK_VALUE_INT (args[0]), GTK_VALUE_INT (args[1]),
- GTK_VALUE_STRING (args[2]), GTK_VALUE_STRING (args[3]),
- func_data);
-}
-
-
-gint
-e_shortcut_model_get_num_groups (EShortcutModel *shortcut_model)
-{
- g_return_val_if_fail (E_IS_SHORTCUT_MODEL (shortcut_model), 0);
-
- return ESM_CLASS (shortcut_model)->get_num_groups (shortcut_model);
-}
-
-
-static gint
-e_shortcut_model_real_get_num_groups (EShortcutModel *shortcut_model)
-{
- return shortcut_model->groups->len;
-}
-
-
-gint
-e_shortcut_model_get_num_items (EShortcutModel *shortcut_model,
- gint group_num)
-{
- g_return_val_if_fail (E_IS_SHORTCUT_MODEL (shortcut_model), 0);
-
- return ESM_CLASS (shortcut_model)->get_num_items (shortcut_model,
- group_num);
-}
-
-
-static gint
-e_shortcut_model_real_get_num_items (EShortcutModel *shortcut_model,
- gint group_num)
-{
- EShortcutModelGroup *group;
-
- g_return_val_if_fail (group_num >= 0, 0);
- g_return_val_if_fail (group_num < shortcut_model->groups->len, 0);
-
- group = &g_array_index (shortcut_model->groups,
- EShortcutModelGroup, group_num);
-
- return group->items->len;
-}
-
-
-gchar*
-e_shortcut_model_get_group_name (EShortcutModel *shortcut_model,
- gint group_num)
-{
- g_return_val_if_fail (E_IS_SHORTCUT_MODEL (shortcut_model), NULL);
-
- return ESM_CLASS (shortcut_model)->get_group_name (shortcut_model,
- group_num);
-}
-
-
-static gchar*
-e_shortcut_model_real_get_group_name (EShortcutModel *shortcut_model,
- gint group_num)
-{
- EShortcutModelGroup *group;
-
- g_return_val_if_fail (group_num >= 0, NULL);
- g_return_val_if_fail (group_num < shortcut_model->groups->len, NULL);
-
- group = &g_array_index (shortcut_model->groups,
- EShortcutModelGroup, group_num);
-
- return g_strdup (group->name);
-}
-
-
-void
-e_shortcut_model_get_item_info (EShortcutModel *shortcut_model,
- gint group_num,
- gint item_num,
- gchar **item_url,
- gchar **item_name)
-{
- g_return_if_fail (E_IS_SHORTCUT_MODEL (shortcut_model));
-
- ESM_CLASS (shortcut_model)->get_item_info (shortcut_model,
- group_num, item_num,
- item_url, item_name);
-}
-
-
-static void
-e_shortcut_model_real_get_item_info (EShortcutModel *shortcut_model,
- gint group_num,
- gint item_num,
- gchar **item_url,
- gchar **item_name)
-{
- EShortcutModelGroup *group;
- EShortcutModelItem *item;
-
- g_return_if_fail (group_num >= 0);
- g_return_if_fail (group_num < shortcut_model->groups->len);
-
- group = &g_array_index (shortcut_model->groups,
- EShortcutModelGroup, group_num);
-
- g_return_if_fail (item_num >= 0);
- g_return_if_fail (item_num < group->items->len);
-
- item = &g_array_index (group->items,
- EShortcutModelItem, item_num);
-
- if (item_url)
- *item_url = g_strdup (item->url);
-
- if (item_name)
- *item_name = g_strdup (item->name);
-}
-
diff --git a/widgets/shortcut-bar/e-shortcut-model.h b/widgets/shortcut-bar/e-shortcut-model.h
deleted file mode 100644
index 402874ef09..0000000000
--- a/widgets/shortcut-bar/e-shortcut-model.h
+++ /dev/null
@@ -1,139 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- * Author :
- * Damon Chaplin <damon@helixcode.com>
- *
- * Copyright 1999, Helix Code, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-#ifndef _E_SHORTCUT_MODEL_H_
-#define _E_SHORTCUT_MODEL_H_
-
-#include <gtk/gtkobject.h>
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-/*
- * EShortcutModel keeps track of a number of groups of shortcuts.
- * Each shortcut has a URL and a short textual name.
- * It is used as the model of the EShortcutBar.
- */
-
-typedef struct _EShortcutModel EShortcutModel;
-typedef struct _EShortcutModelClass EShortcutModelClass;
-
-
-#define E_TYPE_SHORTCUT_MODEL (e_shortcut_model_get_type ())
-#define E_SHORTCUT_MODEL(obj) GTK_CHECK_CAST (obj, e_shortcut_model_get_type (), EShortcutModel)
-#define E_SHORTCUT_MODEL_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, e_shortcut_model_get_type (), EShortcutModelClass)
-#define E_IS_SHORTCUT_MODEL(obj) GTK_CHECK_TYPE (obj, e_shortcut_model_get_type ())
-
-
-struct _EShortcutModel
-{
- GtkObject object;
-
- /* This is a private array of EShortcutModelGroup elements. */
- GArray *groups;
-};
-
-struct _EShortcutModelClass
-{
- GtkObjectClass parent_class;
-
- /*
- * Signals - These act like virtual functions as well as notification
- * signals. The class function is run first and does the actual action.
- */
- void (*group_added) (EShortcutModel *shortcut_model,
- gint group_num,
- const gchar *group_name);
- void (*group_removed) (EShortcutModel *shortcut_model,
- gint group_num);
-
- void (*item_added) (EShortcutModel *shortcut_model,
- gint group_num,
- gint item_num,
- const gchar *item_url,
- const gchar *item_name);
- void (*item_removed) (EShortcutModel *shortcut_model,
- gint group_num,
- gint item_num);
-
- /*
- * Virtual methods.
- */
- gint (*get_num_groups) (EShortcutModel *shortcut_model);
- gint (*get_num_items) (EShortcutModel *shortcut_model,
- gint group_num);
- /* This returns a copy of the group name. */
- gchar* (*get_group_name) (EShortcutModel *shortcut_model,
- gint group_num);
- /* This returns a copy of the item url and name. */
- void (*get_item_info) (EShortcutModel *shortcut_model,
- gint group_num,
- gint item_num,
- gchar **item_url,
- gchar **item_name);
-};
-
-
-GtkType e_shortcut_model_get_type (void);
-EShortcutModel* e_shortcut_model_new (void);
-
-/* Adds a new group at the given position, or last if position is -1.
- It returns the index of the new group. */
-gint e_shortcut_model_add_group (EShortcutModel *shortcut_model,
- gint position,
- const gchar *group_name);
-void e_shortcut_model_remove_group (EShortcutModel *shortcut_model,
- gint group_num);
-
-/* Adds a new item to a group at the given position, or last if position is -1.
- It returns the index of the new item within the group. */
-gint e_shortcut_model_add_item (EShortcutModel *shortcut_model,
- gint group_num,
- gint position,
- const gchar *item_url,
- const gchar *item_name);
-
-void e_shortcut_model_remove_item (EShortcutModel *shortcut_model,
- gint group_num,
- gint item_num);
-
-gint e_shortcut_model_get_num_groups(EShortcutModel *shortcut_model);
-gint e_shortcut_model_get_num_items (EShortcutModel *shortcut_model,
- gint group_num);
-/* The group_name should be freed after use. */
-gchar* e_shortcut_model_get_group_name(EShortcutModel *shortcut_model,
- gint group_num);
-/* The item_url and item_name should be freed after use. */
-void e_shortcut_model_get_item_info (EShortcutModel *shortcut_model,
- gint group_num,
- gint item_num,
- gchar **item_url,
- gchar **item_name);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* _E_SHORTCUT_MODEL_H_ */
diff --git a/widgets/shortcut-bar/e-vscrolled-bar.c b/widgets/shortcut-bar/e-vscrolled-bar.c
deleted file mode 100644
index decfffc3e4..0000000000
--- a/widgets/shortcut-bar/e-vscrolled-bar.c
+++ /dev/null
@@ -1,708 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- * Author :
- * Damon Chaplin <damon@helixcode.com>
- *
- * Copyright 1999, Helix Code, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-/*
- * EVScrolledBar is like GtkScrolledWindow but only scrolls the child widget
- * vertically. It is intended for scrolling narrow vertical bars.
- */
-
-#include <config.h>
-#include <gtk/gtkarrow.h>
-#include <gtk/gtkbutton.h>
-#include <gtk/gtksignal.h>
-#include "e-vscrolled-bar.h"
-
-/* These are the offsets of the up & down buttons from the right and top/bottom
- of the widget. */
-#define E_VSCROLLED_BAR_BUTTON_X_OFFSET 2
-#define E_VSCROLLED_BAR_BUTTON_Y_OFFSET 2
-
-/* This is the time between scrolls. */
-#define E_VSCROLLED_BAR_SCROLL_TIMEOUT 20
-
-static void e_vscrolled_bar_class_init (EVScrolledBarClass *class);
-static void e_vscrolled_bar_init (EVScrolledBar *vscrolled_bar);
-static void e_vscrolled_bar_destroy (GtkObject *object);
-static void e_vscrolled_bar_finalize (GtkObject *object);
-static void e_vscrolled_bar_map (GtkWidget *widget);
-static void e_vscrolled_bar_unmap (GtkWidget *widget);
-static void e_vscrolled_bar_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
-static void e_vscrolled_bar_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
-static void e_vscrolled_bar_draw (GtkWidget *widget,
- GdkRectangle *area);
-static gint e_vscrolled_bar_button_press (GtkWidget *widget,
- GdkEventButton *event);
-static void e_vscrolled_bar_add (GtkContainer *container,
- GtkWidget *child);
-static void e_vscrolled_bar_remove (GtkContainer *container,
- GtkWidget *child);
-static void e_vscrolled_bar_forall (GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data);
-static void e_vscrolled_bar_adjustment_changed (GtkAdjustment *adjustment,
- gpointer data);
-static void e_vscrolled_bar_button_pressed (GtkWidget *button,
- EVScrolledBar *vscrolled_bar);
-static void e_vscrolled_bar_button_released (GtkWidget *button,
- EVScrolledBar *vscrolled_bar);
-static void e_vscrolled_bar_button_clicked (GtkWidget *button,
- EVScrolledBar *vscrolled_bar);
-static gboolean e_vscrolled_bar_timeout_handler (gpointer data);
-
-
-static GtkBinClass *parent_class;
-
-
-GtkType
-e_vscrolled_bar_get_type (void)
-{
- static GtkType e_vscrolled_bar_type = 0;
-
- if (!e_vscrolled_bar_type) {
- GtkTypeInfo e_vscrolled_bar_info = {
- "EVScrolledBar",
- sizeof (EVScrolledBar),
- sizeof (EVScrolledBarClass),
- (GtkClassInitFunc) e_vscrolled_bar_class_init,
- (GtkObjectInitFunc) e_vscrolled_bar_init,
- NULL, /* reserved 1 */
- NULL, /* reserved 2 */
- (GtkClassInitFunc) NULL
- };
-
- parent_class = gtk_type_class (GTK_TYPE_BIN);
- e_vscrolled_bar_type = gtk_type_unique (GTK_TYPE_BIN,
- &e_vscrolled_bar_info);
- }
-
- return e_vscrolled_bar_type;
-}
-
-
-static void
-e_vscrolled_bar_class_init (EVScrolledBarClass *class)
-{
- GtkObjectClass *object_class;
- GtkWidgetClass *widget_class;
- GtkContainerClass *container_class;
-
- object_class = (GtkObjectClass *) class;
- widget_class = (GtkWidgetClass *) class;
- container_class = (GtkContainerClass *) class;
-
- /* Method override */
- object_class->destroy = e_vscrolled_bar_destroy;
- object_class->finalize = e_vscrolled_bar_finalize;
-
- widget_class->map = e_vscrolled_bar_map;
- widget_class->unmap = e_vscrolled_bar_unmap;
- widget_class->size_request = e_vscrolled_bar_size_request;
- widget_class->size_allocate = e_vscrolled_bar_size_allocate;
- widget_class->draw = e_vscrolled_bar_draw;
- widget_class->button_press_event = e_vscrolled_bar_button_press;
-
- container_class->add = e_vscrolled_bar_add;
- container_class->remove = e_vscrolled_bar_remove;
- container_class->forall = e_vscrolled_bar_forall;
-}
-
-
-static void
-e_vscrolled_bar_init (EVScrolledBar *vscrolled_bar)
-{
- GtkWidget *arrow;
-
- GTK_WIDGET_SET_FLAGS (vscrolled_bar, GTK_NO_WINDOW);
-
- gtk_container_set_resize_mode (GTK_CONTAINER (vscrolled_bar),
- GTK_RESIZE_QUEUE);
-
- gtk_widget_push_composite_child ();
-
- vscrolled_bar->up_button = gtk_button_new ();
- gtk_widget_set_composite_name (vscrolled_bar->up_button,
- "up_button");
- gtk_widget_set_parent (vscrolled_bar->up_button,
- GTK_WIDGET (vscrolled_bar));
- arrow = gtk_arrow_new (GTK_ARROW_UP, GTK_SHADOW_OUT);
- gtk_misc_set_padding (GTK_MISC (arrow), 1, 1);
- gtk_widget_show (arrow);
- gtk_container_add (GTK_CONTAINER (vscrolled_bar->up_button), arrow);
- gtk_widget_show (vscrolled_bar->up_button);
- gtk_signal_connect_after (GTK_OBJECT (vscrolled_bar->up_button), "pressed", GTK_SIGNAL_FUNC (e_vscrolled_bar_button_pressed), vscrolled_bar);
- gtk_signal_connect_after (GTK_OBJECT (vscrolled_bar->up_button), "released", GTK_SIGNAL_FUNC (e_vscrolled_bar_button_released), vscrolled_bar);
- gtk_signal_connect (GTK_OBJECT (vscrolled_bar->up_button), "clicked", GTK_SIGNAL_FUNC (e_vscrolled_bar_button_clicked), vscrolled_bar);
-
- vscrolled_bar->down_button = gtk_button_new ();
- gtk_widget_set_composite_name (vscrolled_bar->up_button,
- "down_button");
- gtk_widget_set_parent (vscrolled_bar->down_button,
- GTK_WIDGET (vscrolled_bar));
- arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_OUT);
- gtk_misc_set_padding (GTK_MISC (arrow), 1, 1);
- gtk_widget_show (arrow);
- gtk_container_add (GTK_CONTAINER (vscrolled_bar->down_button), arrow);
- gtk_widget_show (vscrolled_bar->down_button);
- gtk_signal_connect_after (GTK_OBJECT (vscrolled_bar->down_button), "pressed", GTK_SIGNAL_FUNC (e_vscrolled_bar_button_pressed), vscrolled_bar);
- gtk_signal_connect_after (GTK_OBJECT (vscrolled_bar->down_button), "released", GTK_SIGNAL_FUNC (e_vscrolled_bar_button_released), vscrolled_bar);
- gtk_signal_connect (GTK_OBJECT (vscrolled_bar->down_button), "clicked", GTK_SIGNAL_FUNC (e_vscrolled_bar_button_clicked), vscrolled_bar);
-
- gtk_widget_pop_composite_child ();
-
- vscrolled_bar->adjustment = NULL;
- vscrolled_bar->timeout_id = 0;
- vscrolled_bar->scrolling_up = FALSE;
- vscrolled_bar->min_distance = -1.0;
- vscrolled_bar->button_pressed = FALSE;
-}
-
-
-/**
- * e_vscrolled_bar_new:
- *
- * @adjustment: The #GtkAdjustment to use for scrolling, or NULL.
- * @Return: A new #EVScrolledBar.
- *
- * Creates a new #EVScrolledBar with the given adjustment.
- **/
-GtkWidget *
-e_vscrolled_bar_new (GtkAdjustment *adjustment)
-{
- GtkWidget *vscrolled_bar;
-
- vscrolled_bar = GTK_WIDGET (gtk_type_new (e_vscrolled_bar_get_type ()));
- e_vscrolled_bar_set_adjustment (E_VSCROLLED_BAR (vscrolled_bar),
- adjustment);
-
- return vscrolled_bar;
-}
-
-
-static void
-e_vscrolled_bar_destroy (GtkObject *object)
-{
- EVScrolledBar *vscrolled_bar;
-
- vscrolled_bar = E_VSCROLLED_BAR (object);
-
- if (vscrolled_bar->timeout_id) {
- g_source_remove (vscrolled_bar->timeout_id);
- vscrolled_bar->timeout_id = 0;
- }
-
- gtk_widget_unparent (vscrolled_bar->up_button);
- gtk_widget_unparent (vscrolled_bar->down_button);
-
- GTK_OBJECT_CLASS (parent_class)->destroy (object);
-}
-
-
-static void
-e_vscrolled_bar_finalize (GtkObject *object)
-{
- EVScrolledBar *vscrolled_bar;
-
- vscrolled_bar = E_VSCROLLED_BAR (object);
-
- gtk_object_unref (GTK_OBJECT (vscrolled_bar->adjustment));
-
- GTK_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-
-static void
-e_vscrolled_bar_map (GtkWidget *widget)
-{
- EVScrolledBar *vscrolled_bar;
- GtkAdjustment *adjustment;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (E_IS_VSCROLLED_BAR (widget));
-
- vscrolled_bar = E_VSCROLLED_BAR (widget);
-
- /* chain parent class handler to map self and child */
- GTK_WIDGET_CLASS (parent_class)->map (widget);
-
- adjustment = vscrolled_bar->adjustment;
-
- if (GTK_WIDGET_VISIBLE (vscrolled_bar->up_button)
- && adjustment->value != adjustment->lower
- && !GTK_WIDGET_MAPPED (vscrolled_bar->up_button))
- gtk_widget_map (vscrolled_bar->up_button);
-
- if (GTK_WIDGET_VISIBLE (vscrolled_bar->down_button)
- && adjustment->value < adjustment->upper - adjustment->page_size
- && !GTK_WIDGET_MAPPED (vscrolled_bar->down_button))
- gtk_widget_map (vscrolled_bar->down_button);
-}
-
-
-static void
-e_vscrolled_bar_unmap (GtkWidget *widget)
-{
- EVScrolledBar *vscrolled_bar;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (E_IS_VSCROLLED_BAR (widget));
-
- vscrolled_bar = E_VSCROLLED_BAR (widget);
-
- /* chain parent class handler to unmap self and child */
- GTK_WIDGET_CLASS (parent_class)->unmap (widget);
-
- if (GTK_WIDGET_MAPPED (vscrolled_bar->up_button))
- gtk_widget_unmap (vscrolled_bar->up_button);
-
- if (GTK_WIDGET_MAPPED (vscrolled_bar->down_button))
- gtk_widget_unmap (vscrolled_bar->down_button);
-}
-
-
-static void
-e_vscrolled_bar_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
-{
- EVScrolledBar *vscrolled_bar;
- GtkBin *bin;
- GtkRequisition child_requisition;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (E_IS_VSCROLLED_BAR (widget));
- g_return_if_fail (requisition != NULL);
-
- vscrolled_bar = E_VSCROLLED_BAR (widget);
- bin = GTK_BIN (widget);
-
- requisition->width = 0;
- requisition->height = 0;
-
- /* We just return the requisition of the child widget, plus the
- border width. */
- if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) {
- gtk_widget_size_request (bin->child, &child_requisition);
- *requisition = child_requisition;
- }
-
- /* We remember the requested heights of the up & down buttons. */
- gtk_widget_size_request (vscrolled_bar->up_button,
- &child_requisition);
- vscrolled_bar->up_button_width = child_requisition.width;
- vscrolled_bar->up_button_height = child_requisition.height;
-
- gtk_widget_size_request (vscrolled_bar->down_button,
- &child_requisition);
- vscrolled_bar->down_button_width = child_requisition.width;
- vscrolled_bar->down_button_height = child_requisition.height;
-
- /* Add on the standard container border widths. */
- requisition->width += GTK_CONTAINER (widget)->border_width * 2;
- requisition->height += GTK_CONTAINER (widget)->border_width * 2;
-}
-
-
-static void
-e_vscrolled_bar_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation)
-{
- EVScrolledBar *vscrolled_bar;
- GtkBin *bin;
- GtkAllocation button_allocation, child_allocation;
- gint border_width;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (E_IS_VSCROLLED_BAR (widget));
- g_return_if_fail (allocation != NULL);
-
- vscrolled_bar = E_VSCROLLED_BAR (widget);
- bin = GTK_BIN (widget);
-
- widget->allocation = *allocation;
-
- border_width = GTK_CONTAINER (widget)->border_width;
-
- child_allocation.x = border_width;
- child_allocation.y = border_width;
- child_allocation.width = allocation->width - 2 * border_width;
- child_allocation.height = allocation->height - 2 * border_width;
- gtk_widget_size_allocate (bin->child, &child_allocation);
-
- button_allocation.x = allocation->width - border_width
- - vscrolled_bar->up_button_width
- - E_VSCROLLED_BAR_BUTTON_X_OFFSET;
- button_allocation.y = border_width + E_VSCROLLED_BAR_BUTTON_Y_OFFSET;
- button_allocation.width = vscrolled_bar->up_button_width;
- button_allocation.height = vscrolled_bar->up_button_height;
- gtk_widget_size_allocate (vscrolled_bar->up_button,
- &button_allocation);
-
- button_allocation.x = allocation->width - border_width
- - vscrolled_bar->down_button_width
- - E_VSCROLLED_BAR_BUTTON_X_OFFSET;
- button_allocation.y = allocation->height - border_width
- - vscrolled_bar->down_button_height
- - E_VSCROLLED_BAR_BUTTON_Y_OFFSET;
- button_allocation.width = vscrolled_bar->down_button_width;
- button_allocation.height = vscrolled_bar->down_button_height;
- gtk_widget_size_allocate (vscrolled_bar->down_button,
- &button_allocation);
-}
-
-
-static void
-e_vscrolled_bar_draw (GtkWidget *widget,
- GdkRectangle *area)
-{
- EVScrolledBar *vscrolled_bar;
- GtkBin *bin;
- GdkRectangle child_area;
-
- g_return_if_fail (widget != NULL);
- g_return_if_fail (E_IS_VSCROLLED_BAR (widget));
- g_return_if_fail (area != NULL);
-
- vscrolled_bar = E_VSCROLLED_BAR (widget);
- bin = GTK_BIN (widget);
-
- if (bin->child && GTK_WIDGET_VISIBLE (bin->child) &&
- gtk_widget_intersect (bin->child, area, &child_area))
- gtk_widget_draw (bin->child, &child_area);
-
- if (GTK_WIDGET_DRAWABLE (vscrolled_bar->up_button) &&
- gtk_widget_intersect (vscrolled_bar->up_button, area, &child_area))
- gtk_widget_draw (vscrolled_bar->up_button, &child_area);
-
- if (GTK_WIDGET_DRAWABLE (vscrolled_bar->down_button) &&
- gtk_widget_intersect (vscrolled_bar->down_button, area, &child_area))
- gtk_widget_draw (vscrolled_bar->down_button, &child_area);
-}
-
-
-static gint
-e_vscrolled_bar_button_press (GtkWidget *widget,
- GdkEventButton *event)
-{
- EVScrolledBar *vscrolled_bar;
- GtkAdjustment *adjustment;
- gfloat new_value, step;
-
- vscrolled_bar = E_VSCROLLED_BAR (widget);
- adjustment = vscrolled_bar->adjustment;
-
- step = adjustment->page_size;
-
- if (event->button == 4) {
- new_value = adjustment->value - step;
- if (new_value <= adjustment->lower) {
- new_value = adjustment->lower;
- }
- } else if (event->button == 5) {
- new_value = adjustment->value + step;
- if (new_value >= adjustment->upper - adjustment->page_size) {
- new_value = adjustment->upper - adjustment->page_size;
- }
- } else
- return FALSE;
-
- if (adjustment->value != new_value) {
- adjustment->value = new_value;
- gtk_signal_emit_by_name (GTK_OBJECT (adjustment),
- "value_changed");
- return TRUE;
- }
-
- return FALSE;
-}
-
-
-static void
-e_vscrolled_bar_add (GtkContainer *container,
- GtkWidget *child)
-{
- EVScrolledBar *vscrolled_bar;
- GtkBin *bin;
-
- g_return_if_fail (container != NULL);
- g_return_if_fail (E_IS_VSCROLLED_BAR (container));
-
- vscrolled_bar = E_VSCROLLED_BAR (container);
- bin = GTK_BIN (container);
-
- g_return_if_fail (bin->child == NULL);
-
- bin->child = child;
- gtk_widget_set_parent (child, GTK_WIDGET (bin));
-
- gtk_widget_set_scroll_adjustments (child, NULL,
- vscrolled_bar->adjustment);
-
- if (GTK_WIDGET_REALIZED (child->parent))
- gtk_widget_realize (child);
-
- if (GTK_WIDGET_VISIBLE (child->parent) && GTK_WIDGET_VISIBLE (child)) {
- if (GTK_WIDGET_MAPPED (child->parent))
- gtk_widget_map (child);
-
- gtk_widget_queue_resize (child);
- }
-}
-
-
-static void
-e_vscrolled_bar_remove (GtkContainer *container,
- GtkWidget *child)
-{
- g_return_if_fail (container != NULL);
- g_return_if_fail (E_IS_VSCROLLED_BAR (container));
- g_return_if_fail (child != NULL);
- g_return_if_fail (GTK_BIN (container)->child == child);
-
- gtk_widget_set_scroll_adjustments (child, NULL, NULL);
-
- /* chain parent class handler to remove child */
- GTK_CONTAINER_CLASS (parent_class)->remove (container, child);
-}
-
-
-static void
-e_vscrolled_bar_forall (GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data)
-{
- g_return_if_fail (container != NULL);
- g_return_if_fail (E_IS_VSCROLLED_BAR (container));
- g_return_if_fail (callback != NULL);
-
- GTK_CONTAINER_CLASS (parent_class)->forall (container,
- include_internals,
- callback,
- callback_data);
- if (include_internals) {
- EVScrolledBar *vscrolled_bar;
-
- vscrolled_bar = E_VSCROLLED_BAR (container);
-
- if (vscrolled_bar->up_button)
- callback (vscrolled_bar->up_button, callback_data);
- if (vscrolled_bar->down_button)
- callback (vscrolled_bar->down_button, callback_data);
- }
-}
-
-
-/**
- * e_vscrolled_bar_get_adjustment:
- *
- * @vscrolled_bar: An #EVScrolledBar.
- * @Return: The #GtkAdjustment used for scrolling @vscrolled_bar.
- *
- * Returns the #GtkAdjustment used for scrolling the #EVscrolledBar.
- **/
-GtkAdjustment*
-e_vscrolled_bar_get_adjustment (EVScrolledBar *vscrolled_bar)
-{
- g_return_val_if_fail (vscrolled_bar != NULL, NULL);
- g_return_val_if_fail (E_IS_VSCROLLED_BAR (vscrolled_bar), NULL);
-
- return vscrolled_bar->adjustment;
-}
-
-
-/**
- * e_vscrolled_bar_set_adjustment:
- *
- * @vscrolled_bar: An #EVScrolledBar.
- * @adjustment: The #GtkAdjustment to use for scrolling @vscrolled_bar.
- *
- * Sets the #GtkAdjustment to use for scrolling the #EVscrolledBar.
- **/
-void
-e_vscrolled_bar_set_adjustment (EVScrolledBar *vscrolled_bar,
- GtkAdjustment *adjustment)
-{
- g_return_if_fail (vscrolled_bar != NULL);
- g_return_if_fail (E_IS_VSCROLLED_BAR (vscrolled_bar));
-
- if (adjustment)
- g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));
- else
- adjustment = (GtkAdjustment*) gtk_object_new (GTK_TYPE_ADJUSTMENT, NULL);
-
- if (vscrolled_bar->adjustment == adjustment)
- return;
-
- if (vscrolled_bar->adjustment) {
- gtk_signal_disconnect_by_func (GTK_OBJECT (vscrolled_bar->adjustment),
- GTK_SIGNAL_FUNC (e_vscrolled_bar_adjustment_changed),
- vscrolled_bar);
- gtk_object_unref (GTK_OBJECT (vscrolled_bar->adjustment));
- }
-
- vscrolled_bar->adjustment = adjustment;
- gtk_object_ref (GTK_OBJECT (vscrolled_bar->adjustment));
- gtk_object_sink (GTK_OBJECT (vscrolled_bar->adjustment));
-
- /* I've used connect_after here to avoid a problem when using a
- GnomeCanvas as the child widget. When just using connect it would
- leave a blank space when one of the buttons is hidden. We want
- the GtkLayout to handle the scrolling before we hide any buttons. */
- gtk_signal_connect_after (GTK_OBJECT (adjustment), "changed",
- GTK_SIGNAL_FUNC (e_vscrolled_bar_adjustment_changed),
- vscrolled_bar);
- gtk_signal_connect_after (GTK_OBJECT (adjustment), "value_changed",
- GTK_SIGNAL_FUNC (e_vscrolled_bar_adjustment_changed),
- vscrolled_bar);
-
- e_vscrolled_bar_adjustment_changed (adjustment, vscrolled_bar);
-
- if (GTK_BIN (vscrolled_bar)->child)
- gtk_widget_set_scroll_adjustments (GTK_BIN (vscrolled_bar)->child, NULL, adjustment);
-}
-
-
-static void
-e_vscrolled_bar_adjustment_changed (GtkAdjustment *adjustment,
- gpointer data)
-{
- EVScrolledBar *vscrolled_bar;
-
- g_return_if_fail (adjustment != NULL);
- g_return_if_fail (data != NULL);
-#if 0
- g_print ("Adjustment changed to: %g\n", adjustment->value);
-#endif
- vscrolled_bar = E_VSCROLLED_BAR (data);
-
- if (!GTK_WIDGET_MAPPED (vscrolled_bar))
- return;
-
- /* If the adjustment value is not 0, show the up button. */
- if (adjustment->value != adjustment->lower) {
- gtk_widget_map (vscrolled_bar->up_button);
- gdk_window_raise (vscrolled_bar->up_button->window);
- } else {
- gtk_widget_unmap (vscrolled_bar->up_button);
- }
-
- /* If the adjustment value is less than the maximum value, show the
- down button. */
- if (adjustment->value < adjustment->upper - adjustment->page_size) {
- gtk_widget_map (vscrolled_bar->down_button);
- gdk_window_raise (vscrolled_bar->down_button->window);
- } else {
- gtk_widget_unmap (vscrolled_bar->down_button);
- }
-}
-
-
-static void
-e_vscrolled_bar_button_pressed (GtkWidget *button,
- EVScrolledBar *vscrolled_bar)
-{
- if (vscrolled_bar->timeout_id != 0)
- g_source_remove (vscrolled_bar->timeout_id);
-
- vscrolled_bar->timeout_id = g_timeout_add (E_VSCROLLED_BAR_SCROLL_TIMEOUT, e_vscrolled_bar_timeout_handler, vscrolled_bar);
- vscrolled_bar->scrolling_up = (button == vscrolled_bar->up_button) ? TRUE : FALSE;
- vscrolled_bar->min_distance = vscrolled_bar->adjustment->page_size / 4;
- vscrolled_bar->button_pressed = TRUE;
-
- e_vscrolled_bar_timeout_handler (vscrolled_bar);
-}
-
-
-static void
-e_vscrolled_bar_button_released (GtkWidget *button,
- EVScrolledBar *vscrolled_bar)
-{
- vscrolled_bar->button_pressed = FALSE;
-}
-
-
-/* This will be called when the user hits the space key to activate the button.
- It will also be called just before button_released() is called, but since
- we already handle that we simply return if the button is pressed. */
-static void
-e_vscrolled_bar_button_clicked (GtkWidget *button,
- EVScrolledBar *vscrolled_bar)
-{
- if (vscrolled_bar->button_pressed)
- return;
-
- /* We act as if the button is pressed and released immediately. */
- e_vscrolled_bar_button_pressed (button, vscrolled_bar);
- vscrolled_bar->button_pressed = FALSE;
-}
-
-
-static gboolean
-e_vscrolled_bar_timeout_handler (gpointer data)
-{
- EVScrolledBar *vscrolled_bar;
- GtkAdjustment *adjustment;
- gfloat new_value;
- gboolean retval = TRUE;
-
- vscrolled_bar = E_VSCROLLED_BAR (data);
- adjustment = vscrolled_bar->adjustment;
-
- GDK_THREADS_ENTER ();
-
- /* Check if the user has released the button and we have already
- scrolled the minimum distance. */
- if (vscrolled_bar->button_pressed == FALSE
- && vscrolled_bar->min_distance <= 0) {
- GDK_THREADS_LEAVE ();
- return FALSE;
- }
-
- vscrolled_bar->min_distance -= adjustment->step_increment;
-
- if (vscrolled_bar->scrolling_up) {
- new_value = adjustment->value - adjustment->step_increment;
- if (new_value <= adjustment->lower) {
- new_value = adjustment->lower;
- retval = FALSE;
- }
- } else {
- new_value = adjustment->value + adjustment->step_increment;
- if (new_value >= adjustment->upper - adjustment->page_size) {
- new_value = adjustment->upper - adjustment->page_size;
- retval = FALSE;
- }
- }
-
- if (adjustment->value != new_value) {
- adjustment->value = new_value;
- gtk_signal_emit_by_name (GTK_OBJECT (adjustment),
- "value_changed");
- }
-
- GDK_THREADS_LEAVE ();
- return retval;
-}
diff --git a/widgets/shortcut-bar/e-vscrolled-bar.h b/widgets/shortcut-bar/e-vscrolled-bar.h
deleted file mode 100644
index 0f4c8bfcec..0000000000
--- a/widgets/shortcut-bar/e-vscrolled-bar.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- * Author :
- * Damon Chaplin <damon@helixcode.com>
- *
- * Copyright 1999, Helix Code, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-#ifndef _E_VSCROLLED_BAR_H_
-#define _E_VSCROLLED_BAR_H_
-
-#include <gtk/gtkbin.h>
-#include <gtk/gtkadjustment.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-/*
- * EVScrolledBar is like GtkScrolledWindow but only scrolls the child widget
- * vertically. It is intended for scrolling narrow vertical bars.
- */
-
-
-#define E_VSCROLLED_BAR(obj) GTK_CHECK_CAST (obj, e_vscrolled_bar_get_type (), EVScrolledBar)
-#define E_VSCROLLED_BAR_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, e_vscrolled_bar_get_type (), EVScrolledBarClass)
-#define E_IS_VSCROLLED_BAR(obj) GTK_CHECK_TYPE (obj, e_vscrolled_bar_get_type ())
-
-
-typedef struct _EVScrolledBar EVScrolledBar;
-typedef struct _EVScrolledBarClass EVScrolledBarClass;
-
-struct _EVScrolledBar
-{
- GtkBin bin;
-
- GtkWidget *up_button;
- GtkWidget *down_button;
-
- GtkAdjustment *adjustment;
-
- gint up_button_width;
- gint up_button_height;
- gint down_button_width;
- gint down_button_height;
-
- /* The GTK+ event source ID of our timeout handler. */
- gint timeout_id;
-
- /* TRUE if we are scrolling up, FALSE if scrolling down. */
- gboolean scrolling_up;
-
- /* The minimum distance left to scroll. If the user just clicks a
- button we scroll a minimum amount. This is reduced after each
- scroll. */
- gfloat min_distance;
-
- /* TRUE if the button is still pressed. When the up/down button is
- released, this gets set to FALSE, and we scroll until the minimum
- distance falls below 0. */
- gboolean button_pressed;
-};
-
-struct _EVScrolledBarClass
-{
- GtkBinClass parent_class;
-};
-
-
-GtkType e_vscrolled_bar_get_type (void);
-GtkWidget* e_vscrolled_bar_new (GtkAdjustment *adjustment);
-
-GtkAdjustment* e_vscrolled_bar_get_adjustment (EVScrolledBar *vscrolled_bar);
-void e_vscrolled_bar_set_adjustment (EVScrolledBar *vscrolled_bar,
- GtkAdjustment *adjustment);
-
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* _E_VSCROLLED_BAR_H_ */
diff --git a/widgets/shortcut-bar/test-shortcut-bar.c b/widgets/shortcut-bar/test-shortcut-bar.c
deleted file mode 100644
index 4eb5e4c199..0000000000
--- a/widgets/shortcut-bar/test-shortcut-bar.c
+++ /dev/null
@@ -1,658 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-/*
- * Author :
- * Damon Chaplin <damon@helixcode.com>
- *
- * Copyright 1999, Helix Code, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
- */
-
-/*
- * This tests the ShortcutBar widget.
- */
-
-#include <gnome.h>
-
-#include "e-shortcut-bar.h"
-
-#include <gal/e-paned/e-hpaned.h>
-
-#define NUM_SHORTCUT_TYPES 5
-gchar *shortcut_types[NUM_SHORTCUT_TYPES] = {
- "folder:", "file:", "calendar:", "todo:", "contacts:"
-};
-gchar *icon_filenames[NUM_SHORTCUT_TYPES] = {
- "gnome-balsa2.png", "gnome-folder.png", "gnome-calendar.png",
- "gnome-cromagnon.png", "gnome-ccthemes.png"
-};
-GdkPixbuf *icon_pixbufs[NUM_SHORTCUT_TYPES];
-
-GtkWidget *main_label;
-
-static GdkPixbuf *icon_callback (EShortcutBar *shortcut_bar,
- const gchar *url,
- gpointer data);
-
-static void on_main_label_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation,
- gpointer data);
-static void quit (GtkWidget *window, GdkEvent *event, gpointer data);
-static void add_test_groups (EShortcutBar *shortcut_bar);
-static void add_test_group (EShortcutBar *shortcut_bar, gint i,
- gchar *group_name);
-static gint get_random_int (gint max);
-
-static void on_shortcut_bar_item_selected (EShortcutBar *shortcut_bar,
- GdkEvent *event,
- gint group_num,
- gint item_num);
-static void show_standard_popup (EShortcutBar *shortcut_bar,
- GdkEvent *event,
- gint group_num);
-static void show_context_popup (EShortcutBar *shortcut_bar,
- GdkEvent *event,
- gint group_num,
- gint item_num);
-
-static void set_large_icons (GtkWidget *menuitem,
- EShortcutBar *shortcut_bar);
-static void set_small_icons (GtkWidget *menuitem,
- EShortcutBar *shortcut_bar);
-static void add_group (GtkWidget *menuitem,
- EShortcutBar *shortcut_bar);
-static void remove_group (GtkWidget *menuitem,
- EShortcutBar *shortcut_bar);
-
-static void rename_item (GtkWidget *menuitem,
- EShortcutBar *shortcut_bar);
-static void remove_item (GtkWidget *menuitem,
- EShortcutBar *shortcut_bar);
-static void on_set_group_button_clicked (GtkWidget *button,
- EShortcutBar *shortcut_bar);
-static void on_set_group_button_no_animation_clicked (GtkWidget *button,
- EShortcutBar *shortcut_bar);
-static void on_item_added (EShortcutModel *shortcut_model,
- gint group_num,
- gint item_num);
-static void on_item_removed (EShortcutModel *shortcut_model,
- gint group_num,
- gint item_num);
-static void on_group_added (EShortcutModel *shortcut_model,
- gint group_num);
-static void on_group_removed (EShortcutModel *shortcut_model,
- gint group_num);
-static void on_shortcut_dragged (EShortcutBar *shortcut_bar,
- gint group_num,
- gint item_num);
-static void on_shortcut_dropped (EShortcutBar *shortcut_bar,
- gint group_num,
- gint item_num,
- gchar *url,
- gchar *name);
-
-int
-main (int argc, char *argv[])
-{
- GtkWidget *window, *hpaned, *shortcut_bar, *vbox, *button;
- EShortcutModel *shortcut_model;
- gchar *pathname;
- gint i;
-
- gnome_init ("test-shortcut-bar", "0.1", argc, argv);
-
- gtk_widget_push_visual (gdk_rgb_get_visual ());
- gtk_widget_push_colormap (gdk_rgb_get_cmap ());
-
- window = gnome_app_new ("TestShortcutBar", "TestShortCutBar");
- gtk_window_set_default_size (GTK_WINDOW (window), 600, 400);
- gtk_window_set_policy (GTK_WINDOW (window), FALSE, TRUE, FALSE);
-
- gtk_signal_connect (GTK_OBJECT (window), "delete-event",
- GTK_SIGNAL_FUNC (quit), NULL);
-
- hpaned = e_hpaned_new ();
- gnome_app_set_contents (GNOME_APP (window), hpaned);
- gtk_widget_show (hpaned);
-
- shortcut_model = e_shortcut_model_new ();
-
- shortcut_bar = e_shortcut_bar_new ();
- e_shortcut_bar_set_model (E_SHORTCUT_BAR (shortcut_bar),
- shortcut_model);
- e_paned_pack1 (E_PANED (hpaned), shortcut_bar, FALSE, TRUE);
- gtk_widget_show (shortcut_bar);
- e_shortcut_bar_set_icon_callback (E_SHORTCUT_BAR (shortcut_bar),
- icon_callback,
- NULL);
-
- gtk_signal_connect (GTK_OBJECT (shortcut_model), "item_added",
- GTK_SIGNAL_FUNC (on_item_added), NULL);
- gtk_signal_connect (GTK_OBJECT (shortcut_model), "item_removed",
- GTK_SIGNAL_FUNC (on_item_removed), NULL);
- gtk_signal_connect (GTK_OBJECT (shortcut_model), "group_added",
- GTK_SIGNAL_FUNC (on_group_added), NULL);
- gtk_signal_connect (GTK_OBJECT (shortcut_model), "group_removed",
- GTK_SIGNAL_FUNC (on_group_removed), NULL);
-
- gtk_signal_connect (GTK_OBJECT (shortcut_bar), "shortcut_dragged",
- GTK_SIGNAL_FUNC (on_shortcut_dragged), NULL);
- gtk_signal_connect (GTK_OBJECT (shortcut_bar), "shortcut_dropped",
- GTK_SIGNAL_FUNC (on_shortcut_dropped), NULL);
-
-#if 0
- gtk_container_set_border_width (GTK_CONTAINER (shortcut_bar), 4);
-#endif
-
- e_paned_set_position (E_PANED (hpaned), 100);
- /*e_paned_set_gutter_size (E_PANED (hpaned), 12);*/
-
- vbox = gtk_vbox_new (FALSE, 0);
- e_paned_pack2 (E_PANED (hpaned), vbox, TRUE, TRUE);
- gtk_widget_show (vbox);
-
-
- main_label = gtk_label_new ("Main Application Window Goes Here");
- gtk_box_pack_start (GTK_BOX (vbox), main_label, TRUE, TRUE, 0);
- gtk_widget_show (main_label);
- gtk_signal_connect (GTK_OBJECT (main_label), "size_allocate",
- GTK_SIGNAL_FUNC (on_main_label_size_allocate),
- NULL);
-
- button = gtk_button_new_with_label ("Set current group to 3rd");
- gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
- gtk_widget_show (button);
- gtk_signal_connect (GTK_OBJECT (button), "clicked",
- GTK_SIGNAL_FUNC (on_set_group_button_clicked),
- shortcut_bar);
-
- button = gtk_button_new_with_label ("Set current group to 5th (no animation)");
- gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
- gtk_widget_show (button);
- gtk_signal_connect (GTK_OBJECT (button), "clicked",
- GTK_SIGNAL_FUNC (on_set_group_button_no_animation_clicked),
- shortcut_bar);
-
-
- gtk_widget_pop_visual ();
- gtk_widget_pop_colormap ();
-
- /* Load our default icons. */
- for (i = 0; i < NUM_SHORTCUT_TYPES; i++) {
- pathname = gnome_pixmap_file (icon_filenames[i]);
- if (pathname)
- icon_pixbufs[i] = gdk_pixbuf_new_from_file (pathname);
- else
- icon_pixbufs[i] = NULL;
- }
-
- add_test_groups (E_SHORTCUT_BAR (shortcut_bar));
-
- gtk_signal_connect (GTK_OBJECT (shortcut_bar), "item_selected",
- GTK_SIGNAL_FUNC (on_shortcut_bar_item_selected),
- NULL);
-
- gtk_widget_show (window);
- gtk_main ();
- return 0;
-}
-
-
-static GdkPixbuf*
-icon_callback (EShortcutBar *shortcut_bar,
- const gchar *url,
- gpointer data)
-{
- gint i;
-
- for (i = 0; i < NUM_SHORTCUT_TYPES; i++) {
- if (!strncmp (url, shortcut_types[i],
- strlen (shortcut_types[i]))) {
- gdk_pixbuf_ref (icon_pixbufs[i]);
- return icon_pixbufs[i];
- }
- }
-
- return NULL;
-}
-
-static void
-on_main_label_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation,
- gpointer data)
-{
- g_print ("In on_main_label_size_allocate\n");
-}
-
-static void
-quit (GtkWidget *window, GdkEvent *event, gpointer data)
-{
- gtk_widget_destroy (window);
- gtk_exit (0);
-}
-
-
-static void
-add_test_groups (EShortcutBar *shortcut_bar)
-{
- add_test_group (shortcut_bar, 1, "Shortcuts");
- add_test_group (shortcut_bar, 2, "My Shortcuts");
- add_test_group (shortcut_bar, 3, "Longer Shortcuts");
- add_test_group (shortcut_bar, 4, "Very Long Shortcuts");
- add_test_group (shortcut_bar, 5, "Incredibly Long Shortcuts");
-}
-
-
-static void
-add_test_group (EShortcutBar *shortcut_bar, gint i, gchar *group_name)
-{
- gint group_num, item_num, num_items;
- gchar buffer[128];
- gint shortcut_type, j;
-
- group_num = e_shortcut_model_add_group (shortcut_bar->model, -1,
- group_name);
-
- if (group_num % 2)
- e_shortcut_bar_set_view_type (shortcut_bar, group_num,
- E_ICON_BAR_SMALL_ICONS);
-
- num_items = get_random_int (5) + 3;
- for (j = 1; j <= num_items; j++) {
- if (j == 1)
- sprintf (buffer, "A very long shortcut with proper words so I can test the wrapping and ellipsis behaviour");
- else if (j == 2)
- sprintf (buffer, "A very long shortcut with averylongworkinthemiddlesoIcantestthewrappingandellipsisbehaviour");
- else
- sprintf (buffer, "Item %i:%i\n", i, j);
-
- shortcut_type = get_random_int (NUM_SHORTCUT_TYPES);
- item_num = e_shortcut_model_add_item (shortcut_bar->model,
- group_num, -1,
- shortcut_types[shortcut_type],
- buffer);
- }
-}
-
-
-/* Returns a random integer between 0 and max - 1. */
-static gint
-get_random_int (gint max)
-{
- gint random_num;
-
- random_num = (int) (max * (rand () / (RAND_MAX + 1.0)));
-#if 0
- g_print ("Random num (%i): %i\n", max, random_num);
-#endif
- return random_num;
-}
-
-
-static void
-on_shortcut_bar_item_selected (EShortcutBar *shortcut_bar,
- GdkEvent *event, gint group_num, gint item_num)
-{
- gchar buffer[256];
-
- if (event->button.button == 1) {
- sprintf (buffer, "Item Selected - %i:%i",
- group_num + 1, item_num + 1);
- gtk_label_set_text (GTK_LABEL (main_label), buffer);
- } else if (event->button.button == 3) {
- if (item_num == -1)
- show_standard_popup (shortcut_bar, event, group_num);
- else
- show_context_popup (shortcut_bar, event, group_num,
- item_num);
- }
-}
-
-
-static void
-show_standard_popup (EShortcutBar *shortcut_bar,
- GdkEvent *event,
- gint group_num)
-{
- GtkWidget *menu, *menuitem;
-
- /* We don't have any commands if there aren't any groups yet. */
- if (group_num == -1)
- return;
-
- menu = gtk_menu_new ();
-
- menuitem = gtk_menu_item_new_with_label ("Large Icons");
- gtk_widget_show (menuitem);
- gtk_menu_append (GTK_MENU (menu), menuitem);
- gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
- GTK_SIGNAL_FUNC (set_large_icons), shortcut_bar);
-
- menuitem = gtk_menu_item_new_with_label ("Small Icons");
- gtk_widget_show (menuitem);
- gtk_menu_append (GTK_MENU (menu), menuitem);
- gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
- GTK_SIGNAL_FUNC (set_small_icons), shortcut_bar);
-
- menuitem = gtk_menu_item_new ();
- gtk_widget_set_sensitive (menuitem, FALSE);
- gtk_widget_show (menuitem);
- gtk_menu_append (GTK_MENU (menu), menuitem);
-
- menuitem = gtk_menu_item_new_with_label ("Add New Group");
- gtk_widget_show (menuitem);
- gtk_menu_append (GTK_MENU (menu), menuitem);
- gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
- GTK_SIGNAL_FUNC (add_group), shortcut_bar);
-
- menuitem = gtk_menu_item_new_with_label ("Remove Group");
- gtk_widget_show (menuitem);
- gtk_menu_append (GTK_MENU (menu), menuitem);
- gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
- GTK_SIGNAL_FUNC (remove_group), shortcut_bar);
-
- menuitem = gtk_menu_item_new_with_label ("Rename Group");
- gtk_widget_set_sensitive (menuitem, FALSE);
- gtk_widget_show (menuitem);
- gtk_menu_append (GTK_MENU (menu), menuitem);
-
- menuitem = gtk_menu_item_new ();
- gtk_widget_set_sensitive (menuitem, FALSE);
- gtk_widget_show (menuitem);
- gtk_menu_append (GTK_MENU (menu), menuitem);
-
- menuitem = gtk_menu_item_new_with_label ("Add Shortcut...");
- gtk_widget_set_sensitive (menuitem, FALSE);
- gtk_widget_show (menuitem);
- gtk_menu_append (GTK_MENU (menu), menuitem);
-
- menuitem = gtk_menu_item_new ();
- gtk_widget_set_sensitive (menuitem, FALSE);
- gtk_widget_show (menuitem);
- gtk_menu_append (GTK_MENU (menu), menuitem);
-
- menuitem = gtk_menu_item_new_with_label ("Hide Shortcut Bar");
- gtk_widget_set_sensitive (menuitem, FALSE);
- gtk_widget_show (menuitem);
- gtk_menu_append (GTK_MENU (menu), menuitem);
-
- /* Save the group num so we can get it in the callbacks. */
- gtk_object_set_data (GTK_OBJECT (menu), "group_num",
- GINT_TO_POINTER (group_num));
-
- /* FIXME: Destroy menu when finished with it somehow? */
- gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
- event->button.button, event->button.time);
-}
-
-
-static void
-set_large_icons (GtkWidget *menuitem,
- EShortcutBar *shortcut_bar)
-{
- GtkWidget *menu;
- gint group_num;
-
- menu = menuitem->parent;
- g_return_if_fail (GTK_IS_MENU (menu));
-
- group_num = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (menu),
- "group_num"));
-
- e_shortcut_bar_set_view_type (shortcut_bar, group_num,
- E_ICON_BAR_LARGE_ICONS);
-}
-
-
-static void
-set_small_icons (GtkWidget *menuitem,
- EShortcutBar *shortcut_bar)
-{
- GtkWidget *menu;
- gint group_num;
-
- menu = menuitem->parent;
- g_return_if_fail (GTK_IS_MENU (menu));
-
- group_num = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (menu),
- "group_num"));
-
- e_shortcut_bar_set_view_type (shortcut_bar, group_num,
- E_ICON_BAR_SMALL_ICONS);
-}
-
-
-static void
-add_group (GtkWidget *menuitem,
- EShortcutBar *shortcut_bar)
-{
- e_shortcut_model_add_group (shortcut_bar->model, 3, "New Group");
-}
-
-
-static void
-remove_group (GtkWidget *menuitem,
- EShortcutBar *shortcut_bar)
-{
- GtkWidget *menu;
- gint group_num;
-
- menu = menuitem->parent;
- g_return_if_fail (GTK_IS_MENU (menu));
-
- group_num = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (menu),
- "group_num"));
-
- e_shortcut_model_remove_group (shortcut_bar->model, group_num);
-}
-
-
-static void
-show_context_popup (EShortcutBar *shortcut_bar,
- GdkEvent *event,
- gint group_num,
- gint item_num)
-{
- GtkWidget *menu, *menuitem, *label, *pixmap;
-
- menu = gtk_menu_new ();
-
- menuitem = gtk_pixmap_menu_item_new ();
- label = gtk_label_new ("Open Folder");
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_widget_show (label);
- gtk_container_add (GTK_CONTAINER (menuitem), label);
- gtk_widget_set_sensitive (menuitem, FALSE);
- gtk_widget_show (menuitem);
- gtk_menu_append (GTK_MENU (menu), menuitem);
- pixmap = gnome_stock_pixmap_widget (menu, GNOME_STOCK_MENU_OPEN);
- if (pixmap) {
- gtk_widget_show(pixmap);
- gtk_pixmap_menu_item_set_pixmap (GTK_PIXMAP_MENU_ITEM (menuitem), pixmap);
- }
-
- menuitem = gtk_menu_item_new_with_label ("Open in New Window");
- gtk_widget_set_sensitive (menuitem, FALSE);
- gtk_widget_show (menuitem);
- gtk_menu_append (GTK_MENU (menu), menuitem);
-
- menuitem = gtk_menu_item_new_with_label ("Advanced Find");
- gtk_widget_set_sensitive (menuitem, FALSE);
- gtk_widget_show (menuitem);
- gtk_menu_append (GTK_MENU (menu), menuitem);
-
- menuitem = gtk_menu_item_new ();
- gtk_widget_set_sensitive (menuitem, FALSE);
- gtk_widget_show (menuitem);
- gtk_menu_append (GTK_MENU (menu), menuitem);
-
- menuitem = gtk_menu_item_new_with_label ("Remove from Shortcut Bar");
- gtk_widget_show (menuitem);
- gtk_menu_append (GTK_MENU (menu), menuitem);
- gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
- GTK_SIGNAL_FUNC (remove_item), shortcut_bar);
-
- menuitem = gtk_menu_item_new_with_label ("Rename Shortcut");
- gtk_widget_show (menuitem);
- gtk_menu_append (GTK_MENU (menu), menuitem);
- gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
- GTK_SIGNAL_FUNC (rename_item), shortcut_bar);
-
- menuitem = gtk_menu_item_new ();
- gtk_widget_set_sensitive (menuitem, FALSE);
- gtk_widget_show (menuitem);
- gtk_menu_append (GTK_MENU (menu), menuitem);
-
- menuitem = gtk_menu_item_new_with_label ("Properties");
- gtk_widget_set_sensitive (menuitem, FALSE);
- gtk_widget_show (menuitem);
- gtk_menu_append (GTK_MENU (menu), menuitem);
-
-
- /* Save the group & item nums so we can get them in the callbacks. */
- gtk_object_set_data (GTK_OBJECT (menu), "group_num",
- GINT_TO_POINTER (group_num));
- gtk_object_set_data (GTK_OBJECT (menu), "item_num",
- GINT_TO_POINTER (item_num));
-
- /* FIXME: Destroy menu when finished with it somehow? */
- gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
- event->button.button, event->button.time);
-}
-
-
-static void
-rename_item (GtkWidget *menuitem,
- EShortcutBar *shortcut_bar)
-{
- GtkWidget *menu;
- gint group_num, item_num;
-
- menu = menuitem->parent;
- g_return_if_fail (GTK_IS_MENU (menu));
-
- group_num = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (menu),
- "group_num"));
- item_num = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (menu),
- "item_num"));
-
- e_shortcut_bar_start_editing_item (shortcut_bar, group_num, item_num);
-}
-
-
-static void
-remove_item (GtkWidget *menuitem,
- EShortcutBar *shortcut_bar)
-{
- GtkWidget *menu;
- gint group_num, item_num;
-
- menu = menuitem->parent;
- g_return_if_fail (GTK_IS_MENU (menu));
-
- group_num = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (menu),
- "group_num"));
- item_num = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (menu),
- "item_num"));
-
- e_shortcut_model_remove_item (shortcut_bar->model, group_num,
- item_num);
-}
-
-
-static void
-on_set_group_button_clicked (GtkWidget *button,
- EShortcutBar *shortcut_bar)
-{
- g_print ("In on_set_group_button_clicked\n");
-
- e_group_bar_set_current_group_num (E_GROUP_BAR (shortcut_bar),
- 2, TRUE);
-}
-
-
-static void
-on_set_group_button_no_animation_clicked (GtkWidget *button,
- EShortcutBar *shortcut_bar)
-{
- g_print ("In on_set_group_button_no_animation_clicked\n");
-
- e_group_bar_set_current_group_num (E_GROUP_BAR (shortcut_bar),
- 4, FALSE);
-}
-
-
-static void
-on_item_added (EShortcutModel *shortcut_model,
- gint group_num,
- gint item_num)
-{
- g_print ("In on_item_added Group:%i Item:%i\n", group_num, item_num);
-}
-
-
-static void
-on_item_removed (EShortcutModel *shortcut_model,
- gint group_num,
- gint item_num)
-{
- g_print ("In on_item_removed Group:%i Item:%i\n", group_num, item_num);
-}
-
-
-static void
-on_group_added (EShortcutModel *shortcut_model,
- gint group_num)
-{
- g_print ("In on_group_added Group:%i\n", group_num);
-}
-
-
-static void
-on_group_removed (EShortcutModel *shortcut_model,
- gint group_num)
-{
- g_print ("In on_group_removed Group:%i\n", group_num);
-}
-
-
-static void
-on_shortcut_dragged (EShortcutBar *shortcut_bar,
- gint group_num,
- gint item_num)
-{
- g_print ("In on_shortcut_dragged Group:%i Item:%i\n", group_num,
- item_num);
-
- e_shortcut_model_remove_item (shortcut_bar->model, group_num,
- item_num);
-}
-
-
-static void
-on_shortcut_dropped (EShortcutBar *shortcut_bar,
- gint group_num,
- gint item_num,
- gchar *url,
- gchar *name)
-{
- g_print ("In on_shortcut_dropped Group:%i Item:%i\n", group_num,
- item_num);
-
- e_shortcut_model_add_item (shortcut_bar->model,
- group_num, item_num, url, name);
-}