GtkIconList



Hello,

for some time I've been working on a new icon list widget, targeting
gtk+ 2.4 or possibly gtk+ 2.6. Screenshots are available at
http://hadjaha.gimp.org/~andersca/pics/iconlist/ 

I have attached the header file and would appreciate any
comments/questions. A Simple code snippet that creates an icon and adds
it to the icon list could look like this:

GtkWidget *icon_list;
GtkIconListItem *item;

icon_list = gtk_icon_list_new ();
item = gtk_icon_list_item_new (icon_list, icon, label);
gtk_icon_list_set_row_data (icon_list, row_data);
gtk_icon_list_append_item (icon_list, item);

(I realize now that I don't think we should have a GtkIconList *
argument to gtk_icon_list_item_now; you first create the item and then
insert it into the icon list.

Currently there are some other issues that I haven't yet tackled, those
are:

* Drag and drop, the implementation has some simple drag-checking code
but does nothing.

* Icon layout. How flexible should the icon layout be? Currently it
handles different icon sizes. Is that necessary? What should we do if an
icon label is too wide, how should it be wrapped then? I would also like
to have a top-to-bottom icon layout mode (I know QT and Windows does
this) and also a text-beside-icons layout mode (Again, both QT and
Windows does it).

* Memory management of items. I think we want to make them ref-counted,
so gtk_icon_list_item_{ref|unref} should be added.

References:

QIconView - http://doc.trolltech.com/3.0/qiconview.html
System.Windows.Forms.ListView -
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWindowsFormsListViewClassTopic.asp

(I've also put up what I've done so far on
http://hadjaha.gimp.org/~andersca/iconlist.tar.gz)

Anders
#ifndef __GTK_ICON_LIST_H__
#define __GTK_ICON_LIST_H__

#include <gtk/gtkcontainer.h>

G_BEGIN_DECLS

#define GTK_TYPE_ICON_LIST		(gtk_icon_list_get_type ())
#define GTK_ICON_LIST(obj)		(GTK_CHECK_CAST ((obj), GTK_TYPE_ICON_LIST, GtkIconList))
#define GTK_ICON_LIST_CLASS(klass)	(GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_ICON_LIST, GtkIconListClass))
#define GTK_IS_ICON_LIST(obj)		(GTK_CHECK_TYPE ((obj), GTK_TYPE_ICON_LIST))
#define GTK_IS_ICON_LIST_CLASS(klass)	(GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_ICON_LIST))
#define GTK_ICON_LIST_GET_CLASS(obj)    (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_ICON_LIST, GtkIconListClass))
#define GTK_TYPE_ICON_LIST_ITEM         (gtk_icon_list_item_get_type ())

typedef enum
{
  GTK_ICON_LIST_MOVEMENT_BEGINNING,
  GTK_ICON_LIST_MOVEMENT_END,
  GTK_ICON_LIST_MOVEMENT_UP,
  GTK_ICON_LIST_MOVEMENT_DOWN,
  GTK_ICON_LIST_MOVEMENT_LEFT,
  GTK_ICON_LIST_MOVEMENT_RIGHT
} GtkIconListMovementStep;

typedef struct _GtkIconList           GtkIconList;
typedef struct _GtkIconListClass      GtkIconListClass;
typedef struct _GtkIconListPrivate    GtkIconListPrivate;
typedef struct _GtkIconListItem       GtkIconListItem;

typedef void (* GtkIconListForeachFunc)     (GtkIconList      *icon_list,
					     GtkIconListItem  *item,
					     gpointer          data);
typedef gint (* GtkIconListItemCompareFunc) (GtkIconList      *icon_list,
					     GtkIconListItem  *a,
					     GtkIconListItem  *b,
					     gpointer          user_data);

struct _GtkIconList
{
  GtkContainer parent;

  GtkIconListPrivate *priv;
};

struct _GtkIconListClass
{
  GtkContainerClass parent_class;

  void    (* set_scroll_adjustments) (GtkIconList      *icon_list,
				      GtkAdjustment    *hadjustment,
				      GtkAdjustment    *vadjustment);
  
  void    (* item_activated)         (GtkIconList      *icon_list,
				      GtkIconListItem  *item);
  void    (* selection_changed)      (GtkIconList      *icon_list);
  void    (* item_added)             (GtkIconList      *icon_list,
				      GtkIconListItem  *item);
  void    (* item_removed)           (GtkIconList      *icon_list,
				      GtkIconListItem  *item);
  void    (* item_changed)           (GtkIconList      *icon_list,
				      GtkIconListItem  *item);
  /* Key binding signals */
  void    (* select_all)             (GtkIconList      *icon_list);
  void    (* unselect_all)           (GtkIconList      *icon_list);
  void    (* select_cursor_item)     (GtkIconList      *icon_list);
  void    (* toggle_cursor_item)     (GtkIconList      *icon_list);
  void    (* move_cursor)            (GtkIconList      *icon_list,
				      GtkIconListMovementStep step);
};

GType      gtk_icon_list_get_type      (void);
GType      gtk_icon_list_item_get_type (void);
GtkWidget *gtk_icon_list_new           (void);

GtkIconListItem *     gtk_icon_list_item_new           (GtkIconList                *icon_list,
							GdkPixbuf                  *icon,
							const gchar                *label);
void                  gtk_icon_list_item_set_data      (GtkIconListItem            *item,
							gpointer                    data);
void                  gtk_icon_list_item_set_data_full (GtkIconListItem            *item,
							gpointer                    data,
							GDestroyNotify              destroy_notify);
gpointer              gtk_icon_list_item_get_data      (GtkIconListItem            *item);
void                  gtk_icon_list_item_set_label     (GtkIconListItem            *item,
							const char                 *label);
G_CONST_RETURN gchar *gtk_icon_list_item_get_label     (GtkIconListItem            *item);
void                  gtk_icon_list_item_set_icon      (GtkIconListItem            *item,
							GdkPixbuf                  *icon);
GdkPixbuf *           gtk_icon_list_item_get_icon      (GtkIconListItem            *item);
void                  gtk_icon_list_append_item        (GtkIconList                *icon_list,
							GtkIconListItem            *item);
void                  gtk_icon_list_prepend_item       (GtkIconList                *icon_list,
							GtkIconListItem            *item);
void                  gtk_icon_list_insert_item_before (GtkIconList                *icon_list,
							GtkIconListItem            *sibling,
							GtkIconListItem            *item);
void                  gtk_icon_list_insert_item_after  (GtkIconList                *icon_list,
							GtkIconListItem            *sibling,
							GtkIconListItem            *item);
void                  gtk_icon_list_remove_item        (GtkIconList                *icon_list,
							GtkIconListItem            *item);
GtkIconListItem *     gtk_icon_list_get_item_at_pos    (GtkIconList                *icon_list,
							gint                        x,
							gint                        y);
gint                  gtk_icon_list_get_item_count     (GtkIconList                *icon_list);
void                  gtk_icon_list_foreach            (GtkIconList                *icon_list,
							GtkIconListForeachFunc      func,
							gpointer                    data);
GList *               gtk_icon_list_get_selected       (GtkIconList                *icon_list);
void                  gtk_icon_list_selected_foreach   (GtkIconList                *icon_list,
							GtkIconListForeachFunc      func,
							gpointer                    data);
void                  gtk_icon_list_set_selection_mode (GtkIconList                *icon_list,
							GtkSelectionMode            mode);
GtkSelectionMode      gtk_icon_list_get_selection_mode (GtkIconList                *icon_list);
void                  gtk_icon_list_select_item        (GtkIconList                *icon_list,
							GtkIconListItem            *item);
void                  gtk_icon_list_unselect_item      (GtkIconList                *icon_list,
							GtkIconListItem            *item);

gboolean              gtk_icon_list_item_is_selected   (GtkIconListItem            *item);
void                  gtk_icon_list_select_all         (GtkIconList                *icon_list);
void                  gtk_icon_list_unselect_all       (GtkIconList                *icon_list);
void                  gtk_icon_list_set_sorted         (GtkIconList                *icon_list,
							gboolean                    sorted);
gboolean              gtk_icon_list_get_sorted         (GtkIconList                *icon_list);
void                  gtk_icon_list_set_sort_func      (GtkIconList                *icon_list,
							GtkIconListItemCompareFunc  func,
							gpointer                    data,
							GDestroyNotify              destroy_notify);
void                  gtk_icon_list_set_sort_order     (GtkIconList                *icon_list,
							GtkSortType                 order);
GtkSortType           gtk_icon_list_get_sort_order     (GtkIconList                *icon_list);


G_END_DECLS

#endif /* __GTK_ICON_LIST_H__ */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]