ereader gtk library - GtkIconView object adapted for ereader system More...
Go to the source code of this file.
Data Structures | |
struct | _erGtkIconView |
: Derive from GtkIconView. Properties: navigate-mode gchar * READ/WRITE "normal-navigate-mode" default navigate mode. "simple-navigate-mode" translate up/down to left/right. More... | |
struct | _erGtkIconViewClass |
Defines | |
#define | ERGTK_TYPE_ICON_VIEW (ergtk_icon_view_get_type()) |
#define | ERGTK_ICON_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), ERGTK_TYPE_ICON_VIEW, erGtkIconView)) |
#define | ERGTK_IS_ICON_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), ERGTK_TYPE_ICON_VIEW)) |
#define | ERGTK_ICON_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), ERGTK_TYPE_ICON_VIEW, erGtkIconViewClass)) |
#define | ERGTK_ICON_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), ERGTK_TYPE_ICON_VIEW, erGtkIconViewClass)) |
#define | ERGTK_IS_ICON_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), ERGTK_TYPE_ICON_VIEW)) |
#define | ERGTK_ICON_VIEW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), ERGTK_TYPE_ICON_VIEW, erGtkIconViewPrivate)) |
Typedefs | |
typedef struct _erGtkIconView | erGtkIconView |
typedef struct _erGtkIconViewClass | erGtkIconViewClass |
Enumerations | |
enum | erGtkIconViewKeyPress { ERGTK_ICON_VIEW_PRESS_SHORT_UP, ERGTK_ICON_VIEW_PRESS_SHORT_DOWN, ERGTK_ICON_VIEW_PRESS_SHORT_LEFT, ERGTK_ICON_VIEW_PRESS_SHORT_RIGHT, ERGTK_ICON_VIEW_PRESS_LONG_UP, ERGTK_ICON_VIEW_PRESS_LONG_DOWN, ERGTK_ICON_VIEW_PRESS_LONG_LEFT, ERGTK_ICON_VIEW_PRESS_LONG_RIGHT, ERGTK_ICON_VIEW_PRESS_ACTIVATE } |
Functions | |
GtkWidget * | ergtk_icon_view_new (void) |
GtkWidget * | ergtk_icon_view_new_with_model (GtkTreeModel *model) |
void | ergtk_icon_view_set_model (erGtkIconView *er_iconview, GtkTreeModel *model) |
void | ergtk_icon_view_set_next (erGtkIconView *er_iconview, erGtkIconView *next) |
void | ergtk_icon_view_set_previous (erGtkIconView *er_iconview, erGtkIconView *previous) |
void | ergtk_icon_view_get_view_size (erGtkIconView *er_iconview, gint *num_rows, gint *num_cols, gint *num_items) |
void | ergtk_icon_view_get_icon_size (erGtkIconView *er_iconview, gint *icon_width, gint *icon_height) |
void | ergtk_icon_view_get_cursor (erGtkIconView *er_iconview, gint *row, gint *col) |
void | ergtk_icon_view_set_cursor (erGtkIconView *er_iconview, gint row, gint col) |
void | ergtk_icon_view_set_focus_mode (erGtkIconView *er_listview, gboolean focus_in, gboolean focus_out) |
GType | ergtk_icon_view_get_type (void) |
ereader gtk library - GtkIconView object adapted for ereader system
Definition in file erGtkIconView.h.
#define ERGTK_ICON_VIEW | ( | obj | ) | (G_TYPE_CHECK_INSTANCE_CAST((obj), ERGTK_TYPE_ICON_VIEW, erGtkIconView)) |
Definition at line 34 of file erGtkIconView.h.
Referenced by create_iconview(), ergtk_icon_view_new_with_model(), get_cursor(), on_idle_set_cursor(), on_pre_move_cursor(), set_cursor_at_index(), and update_view_size().
#define ERGTK_ICON_VIEW_CLASS | ( | klass | ) | (G_TYPE_CHECK_CLASS_CAST((klass), ERGTK_TYPE_ICON_VIEW, erGtkIconViewClass)) |
Definition at line 37 of file erGtkIconView.h.
#define ERGTK_ICON_VIEW_GET_CLASS | ( | obj | ) | (G_TYPE_INSTANCE_GET_CLASS((obj), ERGTK_TYPE_ICON_VIEW, erGtkIconViewClass)) |
Definition at line 38 of file erGtkIconView.h.
#define ERGTK_ICON_VIEW_GET_PRIVATE | ( | obj | ) | (G_TYPE_INSTANCE_GET_PRIVATE ((obj), ERGTK_TYPE_ICON_VIEW, erGtkIconViewPrivate)) |
Definition at line 41 of file erGtkIconView.h.
Referenced by finalize_impl(), get_property_impl(), and set_property_impl().
#define ERGTK_IS_ICON_VIEW | ( | obj | ) | (G_TYPE_CHECK_INSTANCE_TYPE((obj), ERGTK_TYPE_ICON_VIEW)) |
Definition at line 35 of file erGtkIconView.h.
Referenced by destroy_impl(), ergtk_icon_view_get_cursor(), ergtk_icon_view_get_icon_size(), ergtk_icon_view_get_view_size(), ergtk_icon_view_init(), ergtk_icon_view_set_cursor(), ergtk_icon_view_set_model(), ergtk_icon_view_set_next(), ergtk_icon_view_set_previous(), finalize_impl(), get_property_impl(), on_button_press_event(), on_button_release_event(), on_model_row_changed(), on_model_row_inserted(), on_size_allocate(), on_style_set(), and set_property_impl().
#define ERGTK_IS_ICON_VIEW_CLASS | ( | klass | ) | (G_TYPE_CHECK_CLASS_TYPE((klass), ERGTK_TYPE_ICON_VIEW)) |
Definition at line 39 of file erGtkIconView.h.
#define ERGTK_TYPE_ICON_VIEW (ergtk_icon_view_get_type()) |
Copyright (C) 2008 iRex Technologies B.V. All rights reserved.
Definition at line 33 of file erGtkIconView.h.
Referenced by ergtk_icon_view_new(), and ergtk_icon_view_new_with_model().
typedef struct _erGtkIconView erGtkIconView |
Definition at line 56 of file erGtkIconView.h.
typedef struct _erGtkIconViewClass erGtkIconViewClass |
Definition at line 57 of file erGtkIconView.h.
Definition at line 43 of file erGtkIconView.h.
00044 { 00045 ERGTK_ICON_VIEW_PRESS_SHORT_UP, 00046 ERGTK_ICON_VIEW_PRESS_SHORT_DOWN, 00047 ERGTK_ICON_VIEW_PRESS_SHORT_LEFT, 00048 ERGTK_ICON_VIEW_PRESS_SHORT_RIGHT, 00049 ERGTK_ICON_VIEW_PRESS_LONG_UP, 00050 ERGTK_ICON_VIEW_PRESS_LONG_DOWN, 00051 ERGTK_ICON_VIEW_PRESS_LONG_LEFT, 00052 ERGTK_ICON_VIEW_PRESS_LONG_RIGHT, 00053 ERGTK_ICON_VIEW_PRESS_ACTIVATE 00054 } erGtkIconViewKeyPress;
void ergtk_icon_view_get_cursor | ( | erGtkIconView * | er_iconview, | |
gint * | row, | |||
gint * | col | |||
) |
Definition at line 734 of file erGtkIconView.c.
References ERGTK_IS_ICON_VIEW, force_cursor_present(), and LOGPRINTF.
Referenced by get_cursor(), on_iconview_navigate_cursor(), and on_pre_move_cursor().
00735 { 00736 GtkIconView *iconview = (GtkIconView*) er_iconview; 00737 00738 gint r = 0; 00739 gint c = 0; 00740 00741 LOGPRINTF("entry"); 00742 g_return_if_fail(ERGTK_IS_ICON_VIEW(er_iconview)); 00743 00744 force_cursor_present(er_iconview); 00745 00746 if (iconview->priv->cursor_item) 00747 { 00748 r = iconview->priv->cursor_item->row; 00749 c = iconview->priv->cursor_item->col; 00750 } 00751 00752 if (row != NULL) 00753 { 00754 *row = r; 00755 } 00756 00757 if (col != NULL) 00758 { 00759 *col = c; 00760 } 00761 }
void ergtk_icon_view_get_icon_size | ( | erGtkIconView * | er_iconview, | |
gint * | icon_width, | |||
gint * | icon_height | |||
) |
Definition at line 790 of file erGtkIconView.c.
References _GtkIconViewCellInfo::cell, ERGTK_IS_ICON_VIEW, and LOGPRINTF.
Referenced by scale_pixbuf().
00791 { 00792 LOGPRINTF("entry"); 00793 g_return_if_fail(ERGTK_IS_ICON_VIEW(er_iconview)); 00794 00795 GtkIconView *iconview = (GtkIconView*) er_iconview; 00796 GtkIconViewCellInfo *info; 00797 00798 // get pixbuf cell properties 00799 info = g_list_nth_data (iconview->priv->cell_list, iconview->priv->pixbuf_cell); 00800 if (info && info->cell) 00801 { 00802 gtk_cell_renderer_get_fixed_size(GTK_CELL_RENDERER(info->cell), icon_width, icon_height); 00803 } 00804 else 00805 { 00806 if (icon_width) 00807 { 00808 *icon_width = 0; 00809 } 00810 if (icon_height) 00811 { 00812 *icon_height = 0; 00813 } 00814 } 00815 }
GType ergtk_icon_view_get_type | ( | void | ) |
get type of erGtkIconView widget
Definition at line 257 of file erGtkIconView.c.
References ergtk_icon_view_class_init(), ergtk_icon_view_init(), and type_name.
00258 { 00259 static GType class_type = 0; 00260 00261 if (class_type == 0) 00262 { 00263 static const GTypeInfo class_info = 00264 { 00265 sizeof(erGtkIconViewClass), 00266 NULL, /* base_init */ 00267 NULL, /* base_finalize */ 00268 (GClassInitFunc) ergtk_icon_view_class_init, 00269 NULL, /* class_finalize */ 00270 NULL, /* class_data */ 00271 sizeof(erGtkIconView), 00272 0, /* n_preallocs */ 00273 (GInstanceInitFunc) ergtk_icon_view_init, 00274 NULL /* *value_table */ 00275 }; 00276 class_type = g_type_register_static(GTK_TYPE_ICON_VIEW, type_name, &class_info, 0); 00277 } 00278 00279 return class_type; 00280 }
void ergtk_icon_view_get_view_size | ( | erGtkIconView * | er_iconview, | |
gint * | num_rows, | |||
gint * | num_cols, | |||
gint * | num_items | |||
) |
Definition at line 764 of file erGtkIconView.c.
References ERGTK_IS_ICON_VIEW, LOGPRINTF, _erGtkIconView::num_cols, and _erGtkIconView::num_rows.
Referenced by ergtk_icon_view_set_cursor(), on_iconview_navigate_cursor(), on_pre_move_cursor(), set_cursor_at_index(), and update_view_size().
00765 { 00766 LOGPRINTF("entry"); 00767 g_return_if_fail(ERGTK_IS_ICON_VIEW(er_iconview)); 00768 00769 GtkIconView *iconview = (GtkIconView*) er_iconview; 00770 00771 if (num_rows != NULL) 00772 { 00773 *num_rows = er_iconview->num_rows; 00774 } 00775 00776 if (num_cols != NULL) 00777 { 00778 *num_cols = er_iconview->num_cols; 00779 } 00780 00781 if (num_items != NULL) 00782 { 00783 *num_items = g_list_length(iconview->priv->items); 00784 } 00785 00786 LOGPRINTF("leave"); 00787 }
GtkWidget* ergtk_icon_view_new | ( | void | ) |
Definition at line 283 of file erGtkIconView.c.
References ERGTK_TYPE_ICON_VIEW, and LOGPRINTF.
00284 { 00285 LOGPRINTF("entry"); 00286 00287 return g_object_new (ERGTK_TYPE_ICON_VIEW, NULL); 00288 }
GtkWidget* ergtk_icon_view_new_with_model | ( | GtkTreeModel * | model | ) |
Definition at line 291 of file erGtkIconView.c.
References ERGTK_ICON_VIEW, ergtk_icon_view_set_model(), ERGTK_TYPE_ICON_VIEW, LOGPRINTF, and widget.
Referenced by create_iconview().
00292 { 00293 GtkWidget* widget; 00294 00295 LOGPRINTF("entry"); 00296 g_return_val_if_fail(model, NULL); 00297 00298 widget = g_object_new (ERGTK_TYPE_ICON_VIEW, NULL); 00299 ergtk_icon_view_set_model( ERGTK_ICON_VIEW(widget), model); 00300 00301 return widget; 00302 }
void ergtk_icon_view_set_cursor | ( | erGtkIconView * | er_iconview, | |
gint | row, | |||
gint | col | |||
) |
Definition at line 824 of file erGtkIconView.c.
References ergtk_icon_view_get_view_size(), ERGTK_IS_ICON_VIEW, LOGPRINTF, path, WARNPRINTF, and widget.
Referenced by force_cursor_present(), on_idle_set_cursor(), and on_pre_move_cursor().
00825 { 00826 LOGPRINTF("entry"); 00827 g_return_if_fail(ERGTK_IS_ICON_VIEW(er_iconview)); 00828 00829 GtkIconView *iconview = (GtkIconView*) er_iconview; 00830 GtkWidget *widget = (GtkWidget *) er_iconview; 00831 00832 GtkTreePath *path = NULL; 00833 gint index = 0; 00834 gint num_rows = 0; 00835 gint num_cols = 0; 00836 gint num_items = 0; 00837 gint last_row; 00838 gint last_col; 00839 gint last_row_last_col; 00840 00841 LOGPRINTF("entry: row [%d] col [%d]", row, col); 00842 00843 ergtk_icon_view_get_view_size(er_iconview, &num_rows, &num_cols, &num_items); 00844 LOGPRINTF("num_rows [%d] num_cols [%d] num_items [%d]", num_rows, num_cols, num_items); 00845 00846 if (num_items <= 0) 00847 { 00848 WARNPRINTF("no items, quit"); 00849 return; 00850 } 00851 00852 if (num_rows <= 0 || num_cols <= 0) 00853 { 00854 WARNPRINTF("no space allocated, num_rows [%d] num_cols [%d]", 00855 num_rows, num_cols ); 00856 return; 00857 } 00858 00859 last_row = (num_items - 1) / num_cols; 00860 last_row_last_col = (num_items - 1) % num_cols; 00861 00862 // correct row, if needed 00863 if (last_row == 0) 00864 { 00865 // only one row present: use this one 00866 row = 0; 00867 } 00868 else 00869 { 00870 // multiple rows present: decide which one to use 00871 if (row < 0) 00872 { 00873 // no row requested: use last row 00874 row = last_row; 00875 } 00876 else if (row > last_row) 00877 { 00878 // requested row not present: use last row or before-last row 00879 if (col <= last_row_last_col) 00880 { 00881 // no col requested : use last row 00882 // requested col present on last row : use last row 00883 row = last_row; 00884 } 00885 else 00886 { 00887 // col requested not present on last row: use before-last row 00888 row = last_row - 1; 00889 } 00890 } 00891 } 00892 00893 // correct column, if needed 00894 if (row == last_row) 00895 { 00896 last_col = last_row_last_col; 00897 } 00898 else 00899 { 00900 last_col = num_cols - 1; 00901 } 00902 if (col < 0 || col > last_col) 00903 { 00904 // col not requested: use last column on row 00905 // col not present : use last column on row 00906 col = last_col; 00907 } 00908 LOGPRINTF("calculated: col [%d] row [%d]", col, row); 00909 00910 // create path from index and set cursor 00911 index = (row * num_cols) + col; 00912 path = gtk_tree_path_new_from_indices(index, -1); 00913 gtk_widget_grab_focus (widget); 00914 gtk_icon_view_select_path(iconview, path); 00915 gtk_icon_view_set_cursor(iconview, path, NULL, FALSE); 00916 00917 // clean up 00918 if (path) { gtk_tree_path_free(path); } 00919 00920 return; 00921 }
void ergtk_icon_view_set_focus_mode | ( | erGtkIconView * | er_listview, | |
gboolean | focus_in, | |||
gboolean | focus_out | |||
) |
Definition at line 924 of file erGtkIconView.c.
References on_focus_in(), and on_focus_out().
Referenced by create_iconview().
00927 { 00928 if (!focus_in) 00929 { 00930 // block focus-in events 00931 g_signal_connect(G_OBJECT(er_iconview), "focus-in-event", G_CALLBACK (on_focus_in), NULL); 00932 } 00933 if (!focus_out) 00934 { 00935 // block focus-out events 00936 g_signal_connect(G_OBJECT(er_iconview), "focus-out-event", G_CALLBACK (on_focus_out), NULL); 00937 } 00938 }
void ergtk_icon_view_set_model | ( | erGtkIconView * | er_iconview, | |
GtkTreeModel * | model | |||
) |
Definition at line 308 of file erGtkIconView.c.
References ERGTK_IS_ICON_VIEW, LOGPRINTF, on_model_row_changed(), and on_model_row_inserted().
Referenced by destroy_impl(), and ergtk_icon_view_new_with_model().
00309 { 00310 LOGPRINTF("entry"); 00311 g_return_if_fail(ERGTK_IS_ICON_VIEW(er_iconview)); 00312 00313 GtkIconView *iconview = (GtkIconView*) er_iconview; 00314 GtkTreeModel *iconview_model = gtk_icon_view_get_model(iconview); 00315 00316 // disconnect signal handlers to old model 00317 if (iconview_model) 00318 { 00319 g_signal_handlers_disconnect_by_func(iconview_model, on_model_row_changed, er_iconview); 00320 g_signal_handlers_disconnect_by_func(iconview_model, on_model_row_inserted, er_iconview); 00321 } 00322 00323 // chain to parent class 00324 gtk_icon_view_set_model(iconview, model); 00325 iconview_model = model; 00326 00327 // connect signal handlers to new model 00328 if (iconview_model) 00329 { 00330 g_signal_connect_after(model, "row-changed", G_CALLBACK(on_model_row_changed), er_iconview); 00331 g_signal_connect_after(model, "row-inserted", G_CALLBACK(on_model_row_inserted), er_iconview); 00332 } 00333 }
void ergtk_icon_view_set_next | ( | erGtkIconView * | er_iconview, | |
erGtkIconView * | next | |||
) |
Definition at line 714 of file erGtkIconView.c.
References ERGTK_IS_ICON_VIEW, LOGPRINTF, and _erGtkIconView::next.
00715 { 00716 LOGPRINTF("entry"); 00717 g_return_if_fail( ERGTK_IS_ICON_VIEW(er_iconview)); 00718 g_return_if_fail(next == NULL || ERGTK_IS_ICON_VIEW(next )); 00719 00720 er_iconview->next = next; 00721 }
void ergtk_icon_view_set_previous | ( | erGtkIconView * | er_iconview, | |
erGtkIconView * | previous | |||
) |
Definition at line 724 of file erGtkIconView.c.
References ERGTK_IS_ICON_VIEW, LOGPRINTF, and _erGtkIconView::previous.
00725 { 00726 LOGPRINTF("entry"); 00727 g_return_if_fail( ERGTK_IS_ICON_VIEW(er_iconview)); 00728 g_return_if_fail(previous == NULL || ERGTK_IS_ICON_VIEW(previous )); 00729 00730 er_iconview->previous = previous; 00731 }