#include <config.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <gtk/gtk.h>
#include <libermanifest/ermanifest.h>
#include <liberdm/display.h>
#include "contentListerLog.h"
#include "gtkContentListItem.h"
#include "erConnect.h"
#include "system.h"
#include "gtkPincodeScreen.h"
#include "control.h"
#include "displayUpdate.h"
#include "icons.h"
#include "programManager.h"
#include "languages.h"
Go to the source code of this file.
Defines | |
#define | MAX_INT_LEN 50 |
Functions | |
static void | ls_listItem_press_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data) |
static gboolean | ls_lister_expose_event (GtkWidget *widget, GdkEventExpose *event, ContentLister *theContentLister) |
static void | formatSize (const int bytes, char *str, const int length) |
static void | formatFree (const int kbytes, char *str, const int length) |
lsLister_t * | lsInit (GtkWidget *topLevelWidget, gpointer data) |
GtkWidget * | lsGetListerItem (lsLister_t *lister, int index) |
void | lsUpdatePage (lsLister_t *lister, clDisplayItem_t *items, int count, int focus, gchar *title, const gchar *path) |
Variables | |
static lsLister_t | g_lister |
<File description>=""> The eReader content Lister page contains a predefined number of gtkContentListItems. Which are created and updated with the following API
Definition in file lister.c.
void formatFree | ( | const int | kbytes, | |
char * | str, | |||
const int | length | |||
) | [static] |
void formatSize | ( | const int | bytes, | |
char * | str, | |||
const int | length | |||
) | [static] |
Definition at line 281 of file lister.c.
00282 { 00283 const int MB = 1024 * 1024; 00284 const int KB = 1024; 00285 const char *title = _("Size"); 00286 00287 int ret = 0; 00288 if (bytes >= MB) 00289 { 00290 ret = bytes / MB; 00291 snprintf(str, length, "%s:\n%d.%d %s", title, ret, (bytes - ret * MB) * 10 / MB, _("MB")); 00292 } 00293 else if (bytes >= KB) 00294 { 00295 ret = bytes / KB; 00296 snprintf(str, length, "%s:\n%d.%d %s", title, ret, (bytes - ret * KB) * 10 / KB, _("KB")); 00297 } 00298 else 00299 { 00300 snprintf(str, length, "%s:\n%d %s", title, bytes, _("Bytes")); 00301 } 00302 }
gboolean ls_lister_expose_event | ( | GtkWidget * | widget, | |
GdkEventExpose * | event, | |||
ContentLister * | theContentLister | |||
) | [static] |
Definition at line 273 of file lister.c.
00274 { 00275 CL_SCREENPRINTF("entry"); 00276 display_update_request_screen_refresh(LISTER_EXPOSE_LEVEL); 00277 return FALSE; 00278 }
void ls_listItem_press_event | ( | GtkWidget * | widget, | |
GdkEventButton * | event, | |||
gpointer | user_data | |||
) | [static] |
Definition at line 263 of file lister.c.
00264 { 00265 GtkContentListItem *listItem = (GtkContentListItem *) widget; 00266 00267 CL_LISTERPRINTF("index %d", listItem->index); 00268 00269 ctrl_listItem_clicked(listItem->index, data); 00270 }
GtkWidget* lsGetListerItem | ( | lsLister_t * | lister, | |
int | index | |||
) |
Return the specified lister item
lister | reference to the lister page | |
index | sequence number of lister item on this page (0 ..) |
Definition at line 143 of file lister.c.
00144 { 00145 g_assert(lister != NULL); 00146 g_assert(index >= 0 && index < MAX_ITEMS_ON_ONE_PAGE); 00147 00148 return lister->listItems[index]; 00149 }
lsLister_t* lsInit | ( | GtkWidget * | topLevelWindow, | |
gpointer | data | |||
) |
Init Lister page, by creating a predefined number of gtkContentListItems and assigning "control" callback routines
topLevelWindow | reference to the top level window | |
data | value that needs to be passed in lister item callback routines |
Definition at line 71 of file lister.c.
00072 { 00073 GtkWidget *alignment; 00074 GtkWidget *listVBox; 00075 GtkWidget *listItem; 00076 GtkWidget *titleBackground; 00077 GtkWidget *titleContainer; 00078 00079 int index; 00080 00081 // object hierarchy: 00082 // topLevelWidget 00083 // |-- listVBox 00084 // | 00085 listVBox = gtk_vbox_new(FALSE, LIST_ITEM_SPACING); 00086 gtk_container_add(GTK_CONTAINER(topLevelWidget), listVBox); 00087 gtk_widget_show(listVBox); 00088 // | 00089 // |-- alignment 00090 // | |-- titleBackground 00091 // | | 00092 alignment = gtk_alignment_new(0, 0, 0, 0); 00093 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment), 0, 0, LISTER_BOX_BORDER, 0); 00094 gtk_box_pack_start(GTK_BOX(listVBox), alignment, FALSE, FALSE, 0); 00095 gtk_widget_show(alignment); 00096 // 00097 titleBackground = gtk_event_box_new(); 00098 gtk_widget_set_size_request(GTK_WIDGET(titleBackground), TITLE_MIN_WIDTH, TITLE_MIN_HEIGHT); 00099 gtk_widget_set_name(GTK_WIDGET(titleBackground), "title_background"); 00100 gtk_container_add(GTK_CONTAINER(alignment), titleBackground); 00101 g_signal_connect(G_OBJECT(titleBackground), "expose-event", G_CALLBACK(ls_lister_expose_event), NULL); 00102 gtk_widget_show(titleBackground); 00103 // | | 00104 // | |-- titleContainer (GtkHBox) 00105 // | |-- g_lister.titleItem (GtkLabel) 00106 // | |-- g_lister.titleLocation (GtkLabel) 00107 // | 00108 titleContainer = gtk_hbox_new(FALSE, 10); 00109 gtk_widget_set_size_request(GTK_WIDGET(titleContainer), TITLE_MIN_WIDTH, TITLE_MIN_HEIGHT); 00110 gtk_container_add(GTK_CONTAINER(titleBackground), titleContainer); 00111 gtk_widget_show(titleContainer); 00112 // 00113 g_lister.titleItem = gtk_label_new(""); 00114 gtk_misc_set_alignment(GTK_MISC(g_lister.titleItem), 0, 0.5); 00115 gtk_widget_set_name(GTK_WIDGET(g_lister.titleItem), "title_item"); 00116 gtk_box_pack_start (GTK_BOX (titleContainer), g_lister.titleItem, FALSE, FALSE, 10); 00117 gtk_widget_show(g_lister.titleItem); 00118 // 00119 g_lister.titleLocation = gtk_label_new(""); 00120 gtk_misc_set_alignment(GTK_MISC(g_lister.titleLocation), 1.0, 0.5); 00121 gtk_label_set_ellipsize(GTK_LABEL(g_lister.titleLocation), PANGO_ELLIPSIZE_START); 00122 gtk_widget_set_name(GTK_WIDGET(g_lister.titleLocation), "title_location"); 00123 gtk_box_pack_start (GTK_BOX (titleContainer), g_lister.titleLocation, TRUE, TRUE, 10); 00124 gtk_widget_show(g_lister.titleLocation); 00125 // | 00126 // |-- g_lister.listItems[0] (GtkContentListItem) 00127 // |-- ... 00128 // |-- g_lister.listItems[..] (GtkContentListItem) 00129 // 00130 for (index = 0; index < MAX_ITEMS_ON_ONE_PAGE; index++) 00131 { 00132 listItem = gtk_content_list_item_new(index); 00133 gtk_content_list_item_show_cursor(GTK_CONTENT_LIST_ITEM(listItem), FALSE); 00134 gtk_box_pack_start(GTK_BOX(listVBox), listItem, FALSE, FALSE, 0); 00135 g_signal_connect(G_OBJECT(listItem), "button_press_event", G_CALLBACK(ls_listItem_press_event), data); 00136 00137 g_lister.listItems[index] = listItem; 00138 } 00139 00140 return &g_lister; 00141 }
void lsUpdatePage | ( | lsLister_t * | lister, | |
clDisplayItem_t * | items, | |||
int | count, | |||
int | focus, | |||
gchar * | category, | |||
const gchar * | location | |||
) |
Update the items of the lister widget
<note> the max itemcount/page is the fixed value "MAX_ITEMS_ON_ONE_PAGE" so when more items are available, only the first MAX_ITEMS_ON_ONE_PAGE will be shown
lister | reference to the lister page | |
items | array page items, containing the data that needs to be displayed | |
count | number of items in the array | |
focus | item that should get the focus | |
category | category name - used as the header fro the lster page | |
location | current location information - where are we |
Definition at line 152 of file lister.c.
00154 { 00155 int index = 0; 00156 GtkWidget *listerItem; 00157 char *location; 00158 char str[MAX_INT_LEN]; 00159 00160 //update the title 00161 if (title) 00162 { 00163 CL_LISTERPRINTF("set title %s", title); 00164 gtk_label_set_text(GTK_LABEL(lister->titleItem), title); 00165 } 00166 else 00167 { 00168 gtk_label_set_text(GTK_LABEL(lister->titleItem), ""); 00169 } 00170 00171 if (path) 00172 { 00173 // update the location information 00174 gtk_label_set_text(GTK_LABEL(lister->titleLocation), path); 00175 } 00176 else 00177 { 00178 gtk_label_set_text(GTK_LABEL(lister->titleLocation), ""); 00179 } 00180 00181 00182 // update and display used lister items, hide the others 00183 for (index = 0 ; index < MAX_ITEMS_ON_ONE_PAGE ; index++) 00184 { 00185 listerItem = lister->listItems[index]; 00186 00187 if (index < count) 00188 { 00189 // update and display used lister items 00190 CL_LISTERPRINTF("update and display listerItem %p - index %d", listerItem, index); 00191 gtk_content_list_item_set_title(GTK_CONTENT_LIST_ITEM(listerItem), items[index].szTitle); 00192 gtk_content_list_item_set_subtitle(GTK_CONTENT_LIST_ITEM(listerItem), items[index].szSubTitle); 00193 gtk_content_list_item_set_description(GTK_CONTENT_LIST_ITEM(listerItem), items[index].szDescription); 00194 00195 str[0] = '\0'; 00196 if (ERCL_INVALID_SIZE != items[index].size) 00197 { 00198 if (items[index].fit == mdsFitStorage) 00199 { 00200 formatFree(items[index].size, str, MAX_INT_LEN); 00201 } 00202 else 00203 { 00204 formatSize(items[index].size, str, MAX_INT_LEN); 00205 } 00206 } 00207 gtk_content_list_item_set_information(GTK_CONTENT_LIST_ITEM(listerItem), str); 00208 00209 // set icon 00210 if (ctrl_location_is_outbox(path)) 00211 { 00212 CL_LISTERPRINTF("clIconOutboxItem"); 00213 gtk_content_list_item_set_icon_thumb(GTK_CONTENT_LIST_ITEM(listerItem), clOutboxIcon); 00214 } 00215 else if (items[index].iconID == clIconUrlDefined) 00216 { 00217 CL_LISTERPRINTF("clIconUrlDefined"); 00218 gtk_content_list_item_set_thumb(GTK_CONTENT_LIST_ITEM(listerItem), items[index].clIconURL); 00219 } 00220 else if ( (items[index].iconID == clUnknownIcon) 00221 && ((location = pm_getIcon(items[index].szFileExt)) != NULL) ) 00222 { 00223 CL_LISTERPRINTF("known extension => location"); 00224 gtk_content_list_item_set_thumb(GTK_CONTENT_LIST_ITEM(listerItem), location); 00225 } 00226 else 00227 { 00228 gtk_content_list_item_set_icon_thumb(GTK_CONTENT_LIST_ITEM(listerItem), items[index].iconID); 00229 } 00230 00231 // set cursor 00232 if (index == focus) 00233 { 00234 CL_LISTERPRINTF("focus widget %d", focus); 00235 //temp do update here until history story becomes clear in future releases 00236 gtk_content_list_item_show_cursor(GTK_CONTENT_LIST_ITEM(listerItem), TRUE); 00237 } 00238 else 00239 { 00240 gtk_content_list_item_show_cursor(GTK_CONTENT_LIST_ITEM(listerItem), FALSE); 00241 } 00242 00243 gtk_widget_show(listerItem); 00244 } 00245 else 00246 { 00247 CL_LISTERPRINTF("hide and clear listerItem %p - index %d", listerItem, index); 00248 gtk_content_list_item_set_title(GTK_CONTENT_LIST_ITEM(listerItem), ""); 00249 gtk_content_list_item_set_subtitle(GTK_CONTENT_LIST_ITEM(listerItem), ""); 00250 gtk_content_list_item_set_description(GTK_CONTENT_LIST_ITEM(listerItem), ""); 00251 gtk_content_list_item_set_information(GTK_CONTENT_LIST_ITEM(listerItem), ""); 00252 gtk_content_list_item_hide_thumb(GTK_CONTENT_LIST_ITEM(listerItem)); 00253 00254 gtk_widget_hide(listerItem); 00255 } 00256 } 00257 00258 CL_SCREENPRINTF(""); 00259 display_update_increase_level(LISTER_EXPOSE_LEVEL); 00260 }
lsLister_t g_lister [static] |