r3380 - in trunk/src/target/OM-2007.2/applications/openmoko-appmanager2: . src
thomas at sita.openmoko.org
thomas at sita.openmoko.org
Thu Nov 8 18:43:01 CET 2007
Author: thomas
Date: 2007-11-08 18:42:57 +0100 (Thu, 08 Nov 2007)
New Revision: 3380
Removed:
trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/apply-dialog.c
trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/apply-dialog.h
trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/package-list.c
trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/package-list.h
Modified:
trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/ChangeLog
trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/Makefile.am
trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/appmanager-data.c
trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/appmanager-window.c
trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/detail-area.c
trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/detail-area.h
trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/navigation-area.c
trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/navigation-area.h
trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/search-bar.c
trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/search-bar.h
trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/tool-box.c
Log:
* src/Makefile.am:
* src/apply-dialog.c:
* src/apply-dialog.h:
* src/appmanager-data.c: (application_manager_data_init):
* src/appmanager-window.c: (main):
* src/detail-area.c: (detail_area_update_info):
* src/detail-area.h:
* src/navigation-area.c: (on_selection_changed),
(model_filter_func), (navigation_area_new),
(treeview_get_selected_name):
* src/navigation-area.h:
* src/package-list.c:
* src/package-list.h:
* src/search-bar.c: (search_bar_new):
* src/search-bar.h:
* src/tool-box.c: (on_remove_clicked):
Replace previous package list implementation with a package list store
and a filter.
Modified: trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/ChangeLog
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/ChangeLog 2007-11-08 15:52:03 UTC (rev 3379)
+++ trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/ChangeLog 2007-11-08 17:42:57 UTC (rev 3380)
@@ -1,7 +1,29 @@
2007-11-08 Thomas Wood <thomas at openedhand.com>
* src/Makefile.am:
+ * src/apply-dialog.c:
+ * src/apply-dialog.h:
* src/appmanager-data.c: (application_manager_data_init):
+ * src/appmanager-window.c: (main):
+ * src/detail-area.c: (detail_area_update_info):
+ * src/detail-area.h:
+ * src/navigation-area.c: (on_selection_changed),
+ (model_filter_func), (navigation_area_new),
+ (treeview_get_selected_name):
+ * src/navigation-area.h:
+ * src/package-list.c:
+ * src/package-list.h:
+ * src/search-bar.c: (search_bar_new):
+ * src/search-bar.h:
+ * src/tool-box.c: (on_remove_clicked):
+
+ Replace previous package list implementation with a package list store
+ and a filter.
+
+2007-11-08 Thomas Wood <thomas at openedhand.com>
+
+ * src/Makefile.am:
+ * src/appmanager-data.c: (application_manager_data_init):
* src/appmanager-data.h:
* src/appmanager-window.c: (main):
Modified: trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/Makefile.am
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/Makefile.am 2007-11-08 15:52:03 UTC (rev 3379)
+++ trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/Makefile.am 2007-11-08 17:42:57 UTC (rev 3380)
@@ -8,12 +8,11 @@
tool-box.c\
detail-area.c\
appmanager-data.c\
- package-list.c\
pixbuf-list.c\
- apply-dialog.c\
install-dialog.c \
search-bar.c \
ipkg-utils.c \
- am-progress-dialog.c
+ am-progress-dialog.c \
+ package-store.c
openmoko_appmanager_LDADD = @OPENMOKO_LIBS@
Deleted: trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/apply-dialog.c
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/apply-dialog.c 2007-11-08 15:52:03 UTC (rev 3379)
+++ trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/apply-dialog.c 2007-11-08 17:42:57 UTC (rev 3380)
@@ -1,114 +0,0 @@
-/*
- * @file apply-dialog.c
- * @brief It is an infomation dialog that will display the all package
- * that will be changed.
- *
- * Copyright (C) 2006-2007 OpenMoko Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Public License as published by
- * the Free Software Foundation; version 2 of the license.
- *
- * 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 Public License for more details.
- *
- * Current Version: $Rev$ ($Date$) [$Author$]
- *
- * @author Chaowei Song (songcw at fic-sh.com.cn)
- */
-#include "apply-dialog.h"
-#include "appmanager-window.h"
-#include "package-list.h"
-
-/*
- * @brief The id of package list that display in apply dialog.
- */
-enum {
- MARK_COL_NAME = 0, /* Package name */
- MARK_NUM_COL /* Column number */
-};
-
-/*
- * @brief Create a new apply dialog
- * @param The application manager data
- * @return The apply dialog
- */
-GtkWidget *
-apply_dialog_new (ApplicationManagerData *appdata)
-{
- GtkWidget *applydialog;
- GtkWidget *dialogvbox;
- GtkWidget *applymsg;
- GtkWidget *listwindow;
- GtkWidget *applylist;
- GtkWidget *actionarea;
- GtkWidget *calcelbutton;
- GtkWidget *okbutton;
-
- GtkTreeViewColumn *col;
- GtkCellRenderer *renderer;
- GtkTreeStore *store;
-
- /* Create a new dialog and add a GtkTreeview and two button to the dialog */
- applydialog = gtk_dialog_new ();
- gtk_window_set_title (GTK_WINDOW (applydialog), _("summary"));
- gtk_window_set_position (GTK_WINDOW (applydialog), GTK_WIN_POS_CENTER_ALWAYS);
- gtk_window_set_default_size (GTK_WINDOW (applydialog), 200, 300);
- gtk_window_set_type_hint (GTK_WINDOW (applydialog), GDK_WINDOW_TYPE_HINT_DIALOG);
-
- dialogvbox = GTK_DIALOG (applydialog)->vbox;
- gtk_widget_show (dialogvbox);
-
- applymsg = gtk_label_new (_("Apply the following changes"));
- gtk_widget_show (applymsg);
- gtk_box_pack_start (GTK_BOX (dialogvbox), applymsg, FALSE, FALSE, 0);
-
- applylist = gtk_tree_view_new ();
- gtk_widget_show (applylist);
- gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (applylist), FALSE);
- gtk_tree_view_set_enable_search (GTK_TREE_VIEW (applylist), FALSE);
-
- listwindow = gtk_scrolled_window_new (NULL, NULL);
- gtk_container_add (GTK_CONTAINER (listwindow),applylist);
- gtk_widget_show (listwindow);
- gtk_box_pack_start (GTK_BOX (dialogvbox), listwindow, TRUE, TRUE, 0);
-
- actionarea = GTK_DIALOG (applydialog)->action_area;
- gtk_widget_show (actionarea);
- gtk_button_box_set_layout (GTK_BUTTON_BOX (actionarea), GTK_BUTTONBOX_END);
-
- calcelbutton = gtk_button_new_from_stock ("gtk-cancel");
- gtk_widget_show (calcelbutton);
- gtk_dialog_add_action_widget (GTK_DIALOG (applydialog), calcelbutton, GTK_RESPONSE_CANCEL);
- GTK_WIDGET_SET_FLAGS (calcelbutton, GTK_CAN_DEFAULT);
-
- okbutton = gtk_button_new_from_stock ("gtk-ok");
- gtk_widget_show (okbutton);
- gtk_dialog_add_action_widget (GTK_DIALOG (applydialog), okbutton, GTK_RESPONSE_OK);
- GTK_WIDGET_SET_FLAGS (okbutton, GTK_CAN_DEFAULT);
-
- /* Add column to the treeview */
- col = gtk_tree_view_column_new ();
- gtk_tree_view_column_set_title (col, _("Package Name"));
-
- renderer = gtk_cell_renderer_text_new ();
- gtk_tree_view_column_pack_start (col, renderer, FALSE);
- gtk_tree_view_column_set_attributes (col, renderer,
- "text", MARK_COL_NAME,
- NULL);
- gtk_tree_view_append_column (GTK_TREE_VIEW (applylist), col);
-
- store = gtk_tree_store_new (MARK_NUM_COL, G_TYPE_STRING);
-
- package_list_fill_store_with_selected_list (store,
- application_manager_data_get_selectedlist (appdata),
- MARK_COL_NAME);
-
- gtk_tree_view_set_model (GTK_TREE_VIEW (applylist), GTK_TREE_MODEL (store));
- g_object_unref (GTK_TREE_MODEL (store));
-
- return applydialog;
-}
-
Deleted: trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/apply-dialog.h
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/apply-dialog.h 2007-11-08 15:52:03 UTC (rev 3379)
+++ trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/apply-dialog.h 2007-11-08 17:42:57 UTC (rev 3380)
@@ -1,31 +0,0 @@
-/*
- * @file apply-dialog.h
- * @brief It is an infomation dialog that will display the all package
- * that will be changed.
- *
- * Copyright (C) 2006-2007 OpenMoko Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Public License as published by
- * the Free Software Foundation; version 2.1 of the license.
- *
- * 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 Public License for more details.
- *
- * Current Version: $Rev$ ($Date$) [$Author$]
- *
- * @author Chaowei Song (songcw at fic-sh.com.cn)
- */
-#ifndef _FIC_APPLY_DIALOG_H
-#define _FIC_APPLY_DIALOG_H
-
-#include <gtk/gtk.h>
-
-#include "appmanager-data.h"
-
-GtkWidget *apply_dialog_new (ApplicationManagerData *appdata);
-
-#endif
-
Modified: trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/appmanager-data.c
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/appmanager-data.c 2007-11-08 15:52:03 UTC (rev 3379)
+++ trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/appmanager-data.c 2007-11-08 17:42:57 UTC (rev 3380)
@@ -48,6 +48,10 @@
data->currentlist = NULL;
data->selectedlist = NULL;
data->installdialog = NULL;
+ data->filter_store = NULL;
+ data->install_btn = NULL;
+ data->remove_btn = NULL;
+ data->searchbar = NULL;
for (i = 0; i < N_COUNT_PKG_STATUS; i++)
{
Modified: trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/appmanager-window.c
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/appmanager-window.c 2007-11-08 15:52:03 UTC (rev 3379)
+++ trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/appmanager-window.c 2007-11-08 17:42:57 UTC (rev 3380)
@@ -46,9 +46,9 @@
GtkWidget *notebook;
GtkWidget *searchbar;
GtkWidget *vbox, *nav_vbox;
+
+ GtkTreeModel *pkg_list;
- gint ret;
-
g_debug ("application manager start up");
g_thread_init (NULL);
@@ -70,6 +70,9 @@
init_pixbuf_list (appdata);
+ /* create the package list store */
+ pkg_list = package_store_new ();
+
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (G_OBJECT (window), "delete_event",
G_CALLBACK (gtk_main_quit), NULL);
@@ -91,11 +94,11 @@
toolbox = tool_box_new (appdata);
gtk_box_pack_start (GTK_BOX (nav_vbox), toolbox, FALSE, FALSE, 0);
-
- searchbar = search_bar_new (appdata);
+
+ searchbar = search_bar_new (appdata, pkg_list);
gtk_box_pack_start (GTK_BOX (nav_vbox), searchbar, FALSE, FALSE, 0);
- navigation = navigation_area_new (appdata);
+ navigation = navigation_area_new (appdata, pkg_list);
gtk_box_pack_start (GTK_BOX (nav_vbox), navigation, TRUE, TRUE, 0);
@@ -104,6 +107,7 @@
gtk_image_new_from_stock (GTK_STOCK_FILE, GTK_ICON_SIZE_LARGE_TOOLBAR));
gtk_container_child_set (GTK_CONTAINER (notebook), detail, "tab-expand", TRUE, NULL);
+#if 0
/* Load the list of all package in the memory */
ret = init_package_list (appdata);
if (ret != OP_SUCCESS)
@@ -147,9 +151,10 @@
return -1;
}
}
-
/* Add section list to the filter menu */
package_list_add_section_to_filter_menu (appdata);
+#endif
+
search_bar_set_active_filter (MOKO_SEARCH_BAR (searchbar), FILTER_INSTALLED);
gtk_widget_show_all (GTK_WIDGET (window));
Modified: trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/detail-area.c
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/detail-area.c 2007-11-08 15:52:03 UTC (rev 3379)
+++ trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/detail-area.c 2007-11-08 17:42:57 UTC (rev 3380)
@@ -25,6 +25,8 @@
#include "navigation-area.h"
#include "package-list.h"
+#include "ipkgapi.h"
+
/*
* @brief Create a detail area to the application manager data
* @param appdata The application manager data
@@ -90,7 +92,7 @@
*/
void
detail_area_update_info (ApplicationManagerData *appdata,
- gpointer pkg)
+ IPK_PACKAGE *pkg)
{
GtkWidget *textview;
GtkTextBuffer *buffer;
@@ -132,7 +134,7 @@
gtk_text_buffer_get_end_iter (buffer, &end);
pstart = gtk_text_iter_get_offset (&end);
gtk_text_buffer_insert (buffer, &end,
- package_list_get_package_name (pkg),
+ pkg->name,
-1);
/* Insert the "\n" */
@@ -143,7 +145,7 @@
gtk_text_buffer_get_end_iter (buffer, &end);
pend = gtk_text_iter_get_offset (&end);
gtk_text_buffer_insert (buffer, &end,
- package_list_get_package_maintainer (pkg),
+ pkg->name,
-1);
/* Set bold to the first line */
@@ -159,7 +161,7 @@
gtk_text_buffer_get_end_iter (buffer, &end);
pend = gtk_text_iter_get_offset (&end);
gtk_text_buffer_insert (buffer, &end,
- package_list_get_package_version (pkg),
+ pkg->version,
-1);
gtk_text_buffer_get_iter_at_offset (buffer, &start, pstart);
gtk_text_buffer_get_iter_at_offset (buffer, &end, pend);
@@ -173,14 +175,14 @@
gtk_text_buffer_get_end_iter (buffer, &end);
pend = gtk_text_iter_get_offset (&end);
gtk_text_buffer_insert (buffer, &end,
- package_list_get_package_description (pkg),
+ pkg->description,
-1);
gtk_text_buffer_get_iter_at_offset (buffer, &start, pstart);
gtk_text_buffer_get_iter_at_offset (buffer, &end, pend);
gtk_text_buffer_apply_tag_by_name (buffer, "bold", &start, &end);
/* Set the depends */
- depends = package_list_get_package_depends (pkg);
+ depends = pkg->depends;
if (depends != NULL)
{
char *dep;
Modified: trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/detail-area.h
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/detail-area.h 2007-11-08 15:52:03 UTC (rev 3379)
+++ trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/detail-area.h 2007-11-08 17:42:57 UTC (rev 3380)
@@ -23,11 +23,12 @@
#include <gtk/gtk.h>
#include "appmanager-data.h"
+#include "ipkgapi.h"
GtkWidget *detail_area_new (ApplicationManagerData *appdata);
void detail_area_update_info (ApplicationManagerData *appdata,
- gpointer pkg);
+ IPK_PACKAGE *pkg);
#endif
Modified: trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/navigation-area.c
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/navigation-area.c 2007-11-08 15:52:03 UTC (rev 3379)
+++ trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/navigation-area.c 2007-11-08 17:42:57 UTC (rev 3380)
@@ -25,7 +25,7 @@
#include "navigation-area.h"
#include "errorcode.h"
#include "detail-area.h"
-#include "package-list.h"
+#include "package-store.h"
#include "select-menu.h"
#include "ipkgapi.h"
@@ -66,19 +66,6 @@
}
}
-static GtkListStore *
-create_package_list_store (void)
-{
- GtkListStore *store;
-
- store = gtk_list_store_new (NUM_COL, GDK_TYPE_PIXBUF,
- G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_POINTER);
-
- return store;
-}
-
-
/*
* model_filter_func
*/
@@ -88,6 +75,10 @@
{
gboolean result = TRUE;
+ if (!appdata->searchbar)
+ return FALSE;
+
+
if (moko_search_bar_search_visible (MOKO_SEARCH_BAR (appdata->searchbar)))
{
gchar *haystack;
@@ -104,7 +95,31 @@
g_free (haystack);
return result;
}
- return result;
+ else
+ {
+ GtkComboBox *combo;
+ GtkTreeIter cb_iter;
+ GtkTreeModel *cb_model;
+ gchar *needle;
+ IPK_PACKAGE *pkg;
+
+ combo = moko_search_bar_get_combo_box (MOKO_SEARCH_BAR (appdata->searchbar));
+ if (!gtk_combo_box_get_active_iter (combo, &cb_iter))
+ return FALSE;
+ cb_model = gtk_combo_box_get_model (combo);
+ if (!cb_model) return FALSE;
+ gtk_tree_model_get (cb_model, &cb_iter, 0, &needle, -1);
+
+ gtk_tree_model_get (model, iter, COL_POINTER, &pkg, -1);
+
+ if (pkg && pkg->section && needle && !strcmp (pkg->section, needle))
+ result = TRUE;
+ else
+ result = FALSE;
+
+ g_free (needle);
+ return result;
+ }
}
/*
@@ -114,12 +129,12 @@
* @return The toplevel widget in the navigation area
*/
GtkWidget *
-navigation_area_new (ApplicationManagerData *appdata)
+navigation_area_new (ApplicationManagerData *appdata, GtkTreeModel *pkg_list)
{
GtkWidget *scrollwindow;
GtkWidget *treeview;
- GtkTreeModel *model, *filter;
+ GtkTreeModel *filter;
GtkTreeViewColumn *col;
GtkCellRenderer *renderer;
@@ -132,6 +147,7 @@
col = gtk_tree_view_column_new ();
gtk_tree_view_column_set_title (col, _("S"));
+ /*
renderer = gtk_cell_renderer_pixbuf_new ();
gtk_tree_view_column_pack_start (col, renderer, FALSE);
gtk_tree_view_column_set_attributes (col, renderer,
@@ -139,6 +155,7 @@
NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), col);
+ */
/* Add the name as the second column. */
col = gtk_tree_view_column_new ();
@@ -152,13 +169,10 @@
gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), col);
- model = GTK_TREE_MODEL (create_package_list_store ());
-
- filter = gtk_tree_model_filter_new (model, NULL);
+ filter = gtk_tree_model_filter_new (pkg_list, NULL);
gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (filter),
(GtkTreeModelFilterVisibleFunc) model_filter_func, appdata, NULL);
- g_object_unref (model);
-
+
gtk_tree_view_set_model (GTK_TREE_VIEW (treeview), filter);
g_object_unref (filter);
@@ -202,152 +216,3 @@
return NULL;
}
-
-/*
- * @brief Refresh the navigation area with the package list
- * @param appdata The application manager data
- * @param pkglist The pachage list
- */
-void
-navigation_area_refresh_with_package_list (ApplicationManagerData *appdata,
- gpointer pkglist)
-{
- GtkWidget *treeview;
- GtkTreeModel *model, *filter;
- GtkListStore *store;
- GtkTreeIter iter;
-
- g_return_if_fail (MOKO_IS_APPLICATION_MANAGER_DATA (appdata));
- g_return_if_fail (pkglist != NULL);
-
- treeview = application_manager_get_tvpkglist (appdata);
- g_return_if_fail (GTK_IS_TREE_VIEW (treeview));
-
- filter = gtk_tree_view_get_model (GTK_TREE_VIEW (treeview));
- model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (filter));
-
- g_return_if_fail (GTK_IS_TREE_MODEL (model));
- store = GTK_LIST_STORE (model);
-
- gtk_list_store_clear (store);
-
- translate_package_list_to_store (appdata, store, pkglist);
- /* Save current list to the application manager data */
- application_manager_data_set_current_list (appdata, pkglist);
-
- /* ensure one item is selected */
- if (gtk_tree_model_get_iter_first (filter, &iter))
- gtk_tree_selection_select_iter (gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview)),
- &iter);
-}
-
-/*
- * @brief Rebuild the navigation list from the latest package list
- * @param appdata The application manager data
- */
-void
-navigation_area_rebuild_from_latest (ApplicationManagerData *appdata)
-{
- gpointer pkglist;
-
- g_return_if_fail (MOKO_IS_APPLICATION_MANAGER_DATA (appdata));
-
- pkglist = application_manager_data_get_currentlist (appdata);
- g_return_if_fail (pkglist != NULL);
-
- navigation_area_refresh_with_package_list (appdata, pkglist);
-}
-
-/*
- * @brief Rebuild the navigagion list from the search result of the latest
- * package list
- * @param appdata The application manager data
- * @param str The search string
- */
-void
-navigation_area_rebuild_search_result (ApplicationManagerData *appdata,
- const gchar *str)
-{
- GtkWidget *treeview;
- GtkTreeModel *model;
- GtkListStore *store;
-
- gpointer pkglist;
-
- g_return_if_fail (MOKO_IS_APPLICATION_MANAGER_DATA (appdata));
-
- pkglist = application_manager_data_get_currentlist (appdata);
-
- treeview = application_manager_get_tvpkglist (appdata);
- g_return_if_fail (GTK_IS_TREE_VIEW (treeview));
-
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (treeview));
- g_return_if_fail (GTK_IS_TREE_MODEL (model));
- store = GTK_LIST_STORE (model);
-
- g_object_ref (model);
- gtk_tree_view_set_model (GTK_TREE_VIEW (treeview), NULL);
- gtk_list_store_clear (store);
-
- /* FIXME Add search and build the store */
- search_and_translate_package_list_to_store (appdata, store, pkglist, str);
-
- gtk_tree_view_set_model (GTK_TREE_VIEW(treeview), model);
- g_object_unref (model);
-}
-
-/*
- * @brief Increase search for the package list
- * @param appdata The application manager data
- * @param str The search string
- */
-void
-navigation_area_increase_search (ApplicationManagerData *appdata,
- const gchar *str)
-{
- GtkWidget *treeview;
- GtkTreeModel *model;
- GtkTreeIter iter, next;
- gint res;
- gchar *pkgname = NULL;
-
- g_return_if_fail (MOKO_IS_APPLICATION_MANAGER_DATA (appdata));
-
- treeview = application_manager_get_tvpkglist (appdata);
- g_return_if_fail (GTK_IS_TREE_VIEW (treeview));
-
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (treeview));
- g_return_if_fail (GTK_IS_TREE_MODEL (model));
-
- g_object_ref (model);
- gtk_tree_view_set_model (GTK_TREE_VIEW (treeview), NULL);
-
- res = gtk_tree_model_get_iter_first (model, &next);
- while (res)
- {
- iter = next;
- res = gtk_tree_model_iter_next (model, &next);
-
- gtk_tree_model_get (model, &iter, COL_NAME, &pkgname, -1);
- if (pkgname == NULL)
- {
- g_debug ("Can not the package name in a row");
- continue;
- }
-
- if (strstr ((char *)pkgname, (char *)str) != NULL)
- {
- g_free (pkgname);
- pkgname = NULL;
- continue;
- }
-
- gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
- g_free (pkgname);
- pkgname = NULL;
- }
-
- gtk_tree_view_set_model (GTK_TREE_VIEW(treeview), model);
- g_object_unref (model);
-}
-
Modified: trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/navigation-area.h
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/navigation-area.h 2007-11-08 15:52:03 UTC (rev 3379)
+++ trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/navigation-area.h 2007-11-08 17:42:57 UTC (rev 3380)
@@ -23,17 +23,10 @@
#include <gtk/gtk.h>
#include "appmanager-data.h"
+#include "package-store.h"
-enum {
- COL_STATUS = 0,
- COL_NAME,
- COL_SIZE,
- COL_POINTER,
- NUM_COL
-};
+GtkWidget *navigation_area_new (ApplicationManagerData *appdata, GtkTreeModel *pkg_list);
-GtkWidget *navigation_area_new (ApplicationManagerData *appdata);
-
gint navigation_area_insert_test_data (ApplicationManagerData *appdata);
gchar *treeview_get_selected_name (GtkWidget *treeview);
Deleted: trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/package-list.c
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/package-list.c 2007-11-08 15:52:03 UTC (rev 3379)
+++ trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/package-list.c 2007-11-08 17:42:57 UTC (rev 3380)
@@ -1,1485 +0,0 @@
-/*
- * @file package-list.c
- * @brief The package list that get from the lib ipkg
- *
- * Copyright (C) 2006-2007 OpenMoko Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Public License as published by
- * the Free Software Foundation; version 2 of the license.
- *
- * 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 Public License for more details.
- *
- * Current Version: $Rev$ ($Date$) [$Author$]
- *
- * @author Chaowei Song (songcw at fic-sh.com.cn)
- */
-#include <gtk/gtk.h>
-
-#include "appmanager-data.h"
-#include "package-list.h"
-#include "ipkgapi.h"
-#include "search-bar.h"
-#include "errorcode.h"
-#include "navigation-area.h"
-#include "install-dialog.h"
-
-/*
- * @brief The structor of Package list node
- */
-typedef struct package_list {
- IPK_PACKAGE *pkg; /* Package info */
- struct package_list *pre; /* The previous node of package list */
- struct package_list *next; /* The next node of package list */
-} PackageList;
-
-/*
- * @brief Section list structure.
- */
-typedef struct section_list {
- char *name; /* Section name */
- int sequence; /* The sequence in section list */
- PackageList head; /* The first node of package list at this section */
- struct section_list *next; /* The next section list node */
-} SectionList;
-
-static gint package_list_insert_node_without_check (PackageList *pkglist, IPK_PACKAGE *pkg);
-
-/*
- * @brief Version compare
- *
- * This function is copy from ipkg.(pkg.c)
- * The verrevcmp() function compares the two version string "val" and
- * "ref". It returns an integer less than, equal to, or greater than
- * zero if "val" is found, respectively, to be less than, to match, or
- * be greater than "ref".
- */
-static int
-verrevcmp(const char *val, const char *ref)
-{
- int vc, rc;
- long vl, rl;
- const char *vp, *rp;
- const char *vsep, *rsep;
-
- if (!val) val= "";
- if (!ref) ref= "";
- for (;;)
- {
- vp= val; while (*vp && !isdigit(*vp)) vp++;
- rp= ref; while (*rp && !isdigit(*rp)) rp++;
- for (;;)
- {
- vc= (val == vp) ? 0 : *val++;
- rc= (ref == rp) ? 0 : *ref++;
- if (!rc && !vc) break;
- if (vc && !isalpha(vc)) vc += 256;
- if (rc && !isalpha(rc)) rc += 256;
- if (vc != rc) return vc - rc;
- }
- val= vp;
- ref= rp;
- vl=0; if (isdigit(*vp)) vl= strtol(val,(char**)&val,10);
- rl=0; if (isdigit(*rp)) rl= strtol(ref,(char**)&ref,10);
- if (vl != rl) return vl - rl;
-
- vc = *val;
- rc = *ref;
- vsep = strchr(".-", vc);
- rsep = strchr(".-", rc);
- if (vsep && !rsep) return -1;
- if (!vsep && rsep) return +1;
-
- if (!*val && !*ref) return 0;
- if (!*val) return -1;
- if (!*ref) return +1;
- }
-}
-
-/*
- * @brief Get the list of all packages from lib ipkg
- * @param appdata The application manager data
- * @return If success, return OP_SUCCESS, else return error code
- */
-gint
-init_package_list (ApplicationManagerData *appdata)
-{
- PKG_LIST_HEAD *head;
- int ret;
-
- head = g_malloc (sizeof (PKG_LIST_HEAD));
- if (head == NULL)
- {
- g_debug ("Can not malloc memory for the package list header");
- return OP_MAMORY_MALLOC_ERROR;
- }
-
- head->length = 0;
- head->pkg_list = NULL;
-
- ret = ipkg_initialize (0);
- if (ret != 0)
- {
- /* Can't initialize the lib ipkg */
- g_debug ("Can not initialize the libipkg, the result is %d\nthe error message is:%s",
- ret, get_error_msg());
- return OP_ERROR;
- }
-
- ret = ipkg_list_available_cmd (head);
- if (ret != 0)
- {
- /* Can't get the package list correctly */
- g_debug ("Can not get the package list, the result is %d\nthe error message is:%s",
- ret, get_error_msg());
- g_free (head);
- return OP_ERROR;
- }
-
- application_manager_data_set_pkglist (appdata, head);
- return OP_SUCCESS;
-}
-
-/*
- * @brief Reinit the package list. Only get the packages from the lib ipkg.
- * @param appdata The application manager data
- * @return If success, return OP_SUCCESS, else return error code
- */
-gint
-reinit_package_list (ApplicationManagerData *appdata)
-{
- PKG_LIST_HEAD *head;
- int ret;
-
- head = g_malloc (sizeof (PKG_LIST_HEAD));
- if (head == NULL)
- {
- g_debug ("Can not malloc memory for the package list header");
- return OP_MAMORY_MALLOC_ERROR;
- }
-
- head->length = 0;
- head->pkg_list = NULL;
-
- ret = ipkg_list_available_cmd (head);
- if (ret != 0)
- {
- /* Can't get the package list correctly */
- g_debug ("Can not get the package list, the result is %d\nthe error message is:%s",
- ret, get_error_msg());
- g_free (head);
- return OP_ERROR;
- }
-
- application_manager_data_set_pkglist (appdata, head);
- return OP_SUCCESS;
-}
-
-/*
- * @brief Create a new node of section list.
- *
- * If the param name is NULL, return NULL;
- * If it can not malloc memory for the node of section list, it will return NULL.
- * @param name The section name.
- * @return The section pointer.
- */
-static SectionList *
-package_list_create_new_section_node (const char *name)
-{
- SectionList *sect;
-
- g_return_val_if_fail (name != NULL, NULL);
-
- sect = g_malloc (sizeof (SectionList));
- if (sect == NULL)
- {
- g_debug ("ERROR: Malloc memory for section list error.");
- return NULL;
- }
-
- sect->name = g_malloc (strlen (name) +1);
- if (sect->name == NULL)
- {
- g_debug ("ERROR: Malloc memory for section list error.");
- g_free (sect);
- return NULL;
- }
-
- strcpy (sect->name, name);
- sect->head.pkg = NULL;
- sect->head.pre = &(sect->head);
- sect->head.next = &(sect->head);
- sect->next = NULL;
-
- return sect;
-}
-
-/*
- * @brief Search section node.
- *
- * Search the section node for a package. If the section of package isn't
- * in the section list, add a new section node for it. Only when the
- * return value is OP_SUCCESS, the value of parameter "section" is valid.
- *
- * @param name The name of section
- * @param section The section pointer
- * @param sechead The header of section list
- * @return Error code
- * @retval OP_SUCCESS Operation success
- */
-static gint
-package_list_search_section_node (const char *name,
- SectionList **section,
- SectionList *sechead)
-{
- SectionList *tmp;
- SectionList *pre;
- gint ret;
-
- if (name == NULL)
- {
- g_debug ("The name of section is NULL");
- return OP_SECTION_NAME_NULL;
- }
- if (name[0] == 0)
- {
- g_debug ("The name of section is NULL");
- return OP_SECTION_NAME_NULL;
- }
-
- pre = sechead;
- tmp = sechead->next;
- while (tmp != NULL)
- {
- ret = strcmp (tmp->name, name);
-
- if (ret == 0)
- {
- /* Find it. */
- *section = tmp;
- return OP_SUCCESS;
- }
- if (ret > 0)
- {
- break;
- }
-
- pre = tmp;
- tmp = pre->next;
- }
-
- tmp = package_list_create_new_section_node (name);
- if (tmp == NULL)
- {
- g_debug ("Can not create section node");
- return OP_MAMORY_MALLOC_ERROR;
- }
- tmp->next = pre->next;
- pre->next = tmp;
-
- *section = tmp;
-
- return OP_SUCCESS;
-}
-
-/*
- * @brief Free the package list
- * @param pkglist The package list
- */
-static void
-package_list_free_package_list (PackageList *pkglist)
-{
- PackageList *tmp;
- PackageList *next;
-
- tmp = pkglist->next;
- while (tmp != pkglist)
- {
- next = tmp->next;
- g_free (tmp);
- tmp = next;
- }
- pkglist->next = pkglist;
- pkglist->pre = pkglist;
-}
-
-/*
- * @brief Free the section list
- * @param seclist The section list
- */
-static void
-packaeg_list_free_section_list (SectionList *seclist)
-{
- SectionList *tmp;
- SectionList *next;
-
- tmp = seclist->next;
- while (tmp != NULL)
- {
- next = tmp->next;
- package_list_free_package_list (&(tmp->head));
- g_free (tmp->name);
- g_free (tmp);
- tmp = next;
- }
- g_free (seclist);
-}
-
-/*
- * @brief Clear the old index
- */
-static void
-package_list_clear_old_index (ApplicationManagerData *appdata)
-{
- SectionList *sectionlist = NULL;
- PackageList *installed = NULL;
- PackageList *upgrade = NULL;
- PackageList *selected = NULL;
- PackageList *nosecpkg = NULL;
-
- /* Get the section list from the application manager data
- If the section list is not NULL, clear it. */
- sectionlist = (SectionList *) application_manager_data_get_sectionlist (appdata);
- if (sectionlist != NULL)
- {
- packaeg_list_free_section_list (sectionlist);
- sectionlist = NULL;
- application_manager_data_set_section_list (appdata, sectionlist);
- }
-
- /* Get the installed list from the application manager data
- If the installed list is not NULL, clear it. */
- installed = (PackageList *)application_manager_data_get_installedlist (appdata);
- if (installed != NULL)
- {
- package_list_free_package_list (installed);
- g_free (installed);
- installed = NULL;
- application_manager_data_set_installed_list (appdata, installed);
- }
-
- /* Get the upgrade list from the application manager data
- If the upgrade list is not NULL, clear it. */
- upgrade = (PackageList *)application_manager_data_get_upgradelist (appdata);
- if (upgrade != NULL)
- {
- package_list_free_package_list (upgrade);
- g_free (upgrade);
- upgrade = NULL;
- application_manager_data_set_upgrade_list (appdata, upgrade);
- }
-
- /* Get the selected list from the application manager data
- If the selected list is not NULL, clear it. */
- selected = (PackageList *)application_manager_data_get_upgradelist (appdata);
- if (selected != NULL)
- {
- package_list_free_package_list (selected);
- g_free (selected);
- selected = NULL;
- application_manager_data_set_upgrade_list (appdata, selected);
- }
-
- /* Get the nosecpkg list from the application manager data
- If the selected list is not NULL, clear it. */
- nosecpkg = (PackageList *)application_manager_data_get_upgradelist (appdata);
- if (nosecpkg != NULL)
- {
- package_list_free_package_list (nosecpkg);
- g_free (nosecpkg);
- nosecpkg = NULL;
- application_manager_data_set_upgrade_list (appdata, nosecpkg);
- }
-
- application_manager_data_set_current_list (appdata, NULL);
-}
-
-/*
- * @brief Inist the SectionList struct
- */
-static void
-section_list_init_node (SectionList *sec)
-{
- sec->name = NULL;
- sec->next = NULL;
- sec->head.pkg = NULL;
- sec->head.pre = &(sec->head);
- sec->head.next = &(sec->head);
-}
-
-/*
- * @brief Init the PackageList struct
- */
-static void
-package_list_init_node (PackageList *pkg)
-{
- pkg->pkg = NULL;
- pkg->pre = pkg;
- pkg->next = pkg;
-}
-
-/*
- * @brief Check the packages, if the installed package is upgradeable,
- * put them to the "upgrade" package list.
- *
- * @param pkglist The package list
- * @param pkg The package node
- */
-static gint
-check_package_upgradeable (PackageList *pkglist, IPK_PACKAGE *pkg,
- PackageList *upgrade)
-{
- IPK_PACKAGE *tmp;
- gint ret;
-
- tmp = pkglist->pkg;
- if (tmp->state_status != SS_INSTALLED)
- {
- /* If the package in the list is not installed,
- check the other one. */
- if (pkg->state_status == SS_INSTALLED)
- {
- /* If the other one is installed, exchange them */
- pkglist->pkg = pkg;
- pkg = tmp;
- tmp = pkglist->pkg;
- }
- else
- {
- /* If the other one is not installed either,
- set the package with high version to the list.*/
- ret = verrevcmp (tmp->version, pkg->version);
- if (ret < 0)
- {
- pkglist->pkg = pkg;
- }
- return OP_SUCCESS;
- }
- }
-
- ret = verrevcmp (tmp->version, pkg->version);
- if (ret >= 0)
- {
- return OP_SUCCESS;
- }
-
- tmp->mark = PKG_STATUS_UPGRADEABLE;
- ret = package_list_insert_node_without_check (upgrade, tmp);
- if (ret == OP_SUCCESS)
- {
- return OP_SUCCESS;
- }
-
- return ret;
-}
-
-/*
- * @brief Insert a package node to the package list without check whether
- * the package is upgradeable
- *
- * @param pkglist The package list
- * @param pkg The package node
- * @return The result code
- */
-static gint
-package_list_insert_node_without_check (PackageList *pkglist, IPK_PACKAGE *pkg)
-{
- PackageList *tmp;
- PackageList *ins;
- gint ret;
-
- tmp = pkglist->pre;
-
- while ((tmp != pkglist) && (tmp != NULL))
- {
- ret = strcmp (pkg->name, tmp->pkg->name);
-
- if (ret > 0)
- {
- /* The name of package is larger then the name of node */
- ins = (PackageList *) g_malloc (sizeof (PackageList));
- if (ins == NULL)
- {
- g_debug ("Can not malloc memory for package node, the package name is:%s", pkg->name);
- return OP_MAMORY_MALLOC_ERROR;
- }
- ins->pkg = pkg;
- ins->pre = tmp;
- ins->next = tmp->next;
-
- tmp->next->pre = ins;
- tmp->next = ins;
-
- return OP_SUCCESS;
- }
- /* FIXME Ignore the names of two packages are equal
- At this condition, if there are two packages with the same name,
- add every of them to the package list */
-
- /* The name of package is small then the name of node, search the pre node. */
- tmp = tmp->pre;
- }
-
- ins = (PackageList *) g_malloc (sizeof (PackageList));
- if (ins == NULL)
- {
- g_debug ("Can not malloc memory for package node, the package name is:%s", pkg->name);
- return OP_MAMORY_MALLOC_ERROR;
- }
- ins->pkg = pkg;
- ins->pre = tmp;
- ins->next = tmp->next;
-
- tmp->next->pre = ins;
- tmp->next = ins;
-
- return OP_SUCCESS;
-}
-
-/*
- * @brief Insert a package node to the package list.
- *
- * @param pkglist The package list
- * @param pkg The package node
- * @param upgrade The package list of upgradeable packages
- * @return The result code
- */
-static gint
-package_list_insert_node (PackageList *pkglist, IPK_PACKAGE *pkg, PackageList *upgrade)
-{
- PackageList *tmp;
- PackageList *ins;
- gint ret;
-
- tmp = pkglist->pre;
-
- while ((tmp != pkglist) && (tmp != NULL))
- {
- ret = strcmp (pkg->name, tmp->pkg->name);
-
- if (ret > 0)
- {
- /* The name of package is larger then the name of node */
- ins = (PackageList *) g_malloc (sizeof (PackageList));
- if (ins == NULL)
- {
- g_debug ("Can not malloc memory for package node, the package name is:%s", pkg->name);
- return OP_MAMORY_MALLOC_ERROR;
- }
- ins->pkg = pkg;
- ins->pre = tmp;
- ins->next = tmp->next;
-
- tmp->next->pre = ins;
- tmp->next = ins;
-
- return OP_SUCCESS;
- }
- else if (ret == 0)
- {
- /* The name of package is equal to the name of node.
- The package maybe an upgradeable package. */
- g_debug ("The package maybe upgradeable. Package name is:%s", pkg->name);
- g_debug ("The pkg version 1 is:%s, The version 2 is:%s", tmp->pkg->version, pkg->version);
- return check_package_upgradeable (tmp, pkg, upgrade);
- }
-
- /* The name of package is small then the name of node, search the pre node. */
- tmp = tmp->pre;
- }
-
- ins = (PackageList *) g_malloc (sizeof (PackageList));
- if (ins == NULL)
- {
- g_debug ("Can not malloc memory for package node, the package name is:%s", pkg->name);
- return OP_MAMORY_MALLOC_ERROR;
- }
- ins->pkg = pkg;
- ins->pre = tmp;
- ins->next = tmp->next;
-
- tmp->next->pre = ins;
- tmp->next = ins;
-
- return OP_SUCCESS;
-}
-
-/*
- * @brief Build a detailed index for the packages list in the application
- * manager data
- * @param appdata The application manager data
- * @return If success, return OP_SUCCESS, else return error code
- */
-gint
-package_list_build_index (ApplicationManagerData *appdata)
-{
- PKG_LIST_HEAD *pkglist;
- IPK_PACKAGE *pkg;
-
- SectionList *sectionlist = NULL;
- PackageList *installed = NULL;
- PackageList *upgrade = NULL;
- PackageList *selected = NULL;
- PackageList *nosecpkg = NULL;
-
- SectionList *tmpsec = NULL;
- gint ret;
-
- /* Get the package list from application manager data */
- pkglist = (PKG_LIST_HEAD *) application_manager_data_get_pkglist (appdata);
- if (pkglist == NULL)
- {
- g_debug ("The package list is not available");
- return OP_ERROR;
- }
-
- if (pkglist->pkg_list == NULL)
- {
- g_debug ("The package list is not available");
- return OP_ERROR;
- }
-
- /* Clear the old data */
- package_list_clear_old_index (appdata);
-
- /* Malloc memory for the head */
- sectionlist = g_malloc (sizeof (SectionList));
- if (sectionlist == NULL)
- {
- g_debug ("Can not malloc memory for the section list");
- return OP_MAMORY_MALLOC_ERROR;
- }
-
- installed = g_malloc (sizeof (PackageList));
- if (installed == NULL)
- {
- g_debug ("Can not malloc memory for the package list");
- g_free (sectionlist);
- return OP_MAMORY_MALLOC_ERROR;
- }
-
- upgrade = g_malloc (sizeof (PackageList));
- if (upgrade == NULL)
- {
- g_debug ("Can not malloc memory for the package list");
- g_free (sectionlist);
- g_free (installed);
- return OP_MAMORY_MALLOC_ERROR;
- }
-
- selected = g_malloc (sizeof (PackageList));
- if (selected == NULL)
- {
- g_debug ("Can not malloc memory for the package list");
- g_free (sectionlist);
- g_free (installed);
- g_free (upgrade);
- return OP_MAMORY_MALLOC_ERROR;
- }
-
- nosecpkg = g_malloc (sizeof (PackageList));
- if (nosecpkg == NULL)
- {
- g_debug ("Can not malloc memory for the package list");
- g_free (sectionlist);
- g_free (installed);
- g_free (upgrade);
- g_free (selected);
- return OP_MAMORY_MALLOC_ERROR;
- }
-
- /* Init each list */
- g_debug ("Begin init each list");
-
- section_list_init_node (sectionlist);
-
- package_list_init_node (installed);
- package_list_init_node (upgrade);
- package_list_init_node (selected);
- package_list_init_node (nosecpkg);
-
- /* Set the header of each list to the application manager data */
- application_manager_data_set_section_list (appdata, sectionlist);
- application_manager_data_set_installed_list (appdata, installed);
- application_manager_data_set_upgrade_list (appdata, upgrade);
- application_manager_data_set_selected_list (appdata, selected);
- application_manager_data_set_nosecpkg_list (appdata, nosecpkg);
-
- /* Start to build the index for all packages */
- pkg = pkglist->pkg_list;
-
- while (pkg != NULL)
- {
- /* Check wheather the package was installed */
- if (pkg->state_status == SS_INSTALLED)
- {
- pkg->mark = PKG_STATUS_INSTALLED;
- ret = package_list_insert_node_without_check (installed, pkg);
- if (ret != OP_SUCCESS)
- {
- return ret;
- }
- }
- else
- {
- pkg->mark = PKG_STATUS_AVAILABLE;
- }
-
- /* Search the section node of package. */
- ret = package_list_search_section_node (pkg->section, &tmpsec, sectionlist);
- if (ret == OP_SUCCESS)
- {
- ret = package_list_insert_node (&(tmpsec->head), pkg, upgrade);
- if (ret != OP_SUCCESS)
- {
- return ret;
- }
- }
- else if (ret == OP_SECTION_NAME_NULL)
- {
- ret = package_list_insert_node (nosecpkg, pkg, upgrade);
- if (ret != OP_SUCCESS)
- {
- return ret;
- }
- }
- else
- {
- return ret;
- }
-
- pkg = pkg->next;
- }
-
- return OP_SUCCESS;
-}
-
-/*
- * @brief Add the sections to the filter menu
- *
- * @param appdata The application manager data
- */
-void
-package_list_add_section_to_filter_menu (ApplicationManagerData *appdata)
-{
- SectionList *seclist;
- SectionList *tmpsec;
- PackageList *tmppkg;
-
- seclist = application_manager_data_get_sectionlist (appdata);
- if (seclist == NULL)
- {
- g_debug ("Section list is empty, not need add anything to filter menu");
- return;
- }
-
- tmpsec = seclist->next;
-
- while (tmpsec != NULL)
- {
- search_bar_add_filter_item (appdata, tmpsec->name);
- tmpsec = tmpsec->next;
- }
-
- tmppkg = application_manager_data_get_nosecpkglist (appdata);
- if (tmppkg == NULL)
- {
- return;
- }
-
- if (tmppkg->next != tmppkg)
- {
- search_bar_add_filter_item (appdata, PACKAGE_LIST_NO_SECTION_STRING);
- }
-}
-
-/*
- * @brief Insert node to store
- */
-static void
-insert_node_to_store (ApplicationManagerData *appdata,
- GtkListStore *store,
- IPK_PACKAGE *pkg)
-{
- GtkTreeIter iter;
- GdkPixbuf *pix = NULL;
-
- pix = application_manager_data_get_status_pixbuf (appdata, pkg->mark);
-
- gtk_list_store_append (store, &iter);
-
- gtk_list_store_set (store, &iter,
- COL_STATUS, pix,
- COL_NAME, pkg->name,
- COL_SIZE, pkg->size,
- COL_POINTER, pkg,
- -1);
-
-}
-
-/*
- * @brief Put the nodes in the package list to the GtkListStore
- *
- * @param appdata The application manager data
- * @param store The list store
- * @param pkglist The package list
- */
-void
-translate_package_list_to_store (ApplicationManagerData *appdata,
- GtkListStore *store,
- gpointer pkglist)
-{
- PackageList *pkglisthead = (PackageList *)pkglist;
- PackageList *tmplist;
-
- tmplist = pkglisthead->next;
- while (tmplist != pkglisthead)
- {
- insert_node_to_store (appdata, store, tmplist->pkg);
- tmplist = tmplist->next;
- }
-}
-
-/*
- * @brief Get the package list which section name equals the "name"
- * from the dynamic section list
- * @param appdata The application manager data
- * @param name The section name
- */
-gpointer
-package_list_get_with_name (ApplicationManagerData *appdata,
- const gchar *name)
-{
- SectionList *seclist;
-
- g_return_val_if_fail (MOKO_IS_APPLICATION_MANAGER_DATA (appdata), NULL);
-
- seclist = application_manager_data_get_sectionlist (appdata);
- if (seclist == NULL)
- {
- g_debug ("Section list is NULL");
- return NULL;
- }
-
- seclist = seclist->next;
- while (seclist != NULL)
- {
- if ( 0 == strcmp (name, seclist->name))
- {
- return &(seclist->head);
- }
- seclist = seclist->next;
- }
-
- return NULL;
-}
-
-/*
- * @brief Get the select status from package infomation.
- * @param data The package infomation
- * @return The select status
- */
-gint
-package_list_get_package_status (gpointer data)
-{
- IPK_PACKAGE *tmp;
-
- g_return_val_if_fail (data != NULL, -1);
-
- tmp = (IPK_PACKAGE *)data;
- return tmp->mark;
-}
-
-/*
- * @brief Set the select status to package infomation
- * @param data The package infomation
- * @param status The new select status
- */
-void
-package_list_set_package_status (gpointer data, gint status)
-{
- IPK_PACKAGE *tmp;
-
- g_return_if_fail (data != NULL);
- g_return_if_fail ((status >= PKG_STATUS_AVAILABLE) && (status < N_COUNT_PKG_STATUS));
-
- tmp = (IPK_PACKAGE *)data;
- tmp->mark = status;
-}
-
-/*
- * @brief Remove a package node from the selected package list
- * @brief appdata The application manager data
- * @param pkg The package infomation
- */
-void
-package_list_remove_package_from_selected_list (ApplicationManagerData *appdata,
- gpointer pkg)
-{
- PackageList *selectedlist;
- PackageList *tmplist;
-
- selectedlist = (PackageList *)application_manager_data_get_selectedlist (appdata);
- g_return_if_fail (selectedlist != NULL);
-
- tmplist = selectedlist;
-
- while (tmplist != selectedlist)
- {
- if(tmplist->pkg == pkg)
- {
- tmplist->next->pre = tmplist->pre;
- tmplist->pre->next = tmplist->next;
- g_free (tmplist);
- }
- tmplist = tmplist->next;
- }
-}
-
-/*
- * @brief Add a new package node to the selected package list
- * @param appdata The application manager data
- * @param pkg The package infomation
- */
-void
-package_list_add_node_to_selected_list (ApplicationManagerData *appdata,
- gpointer pkg)
-{
- PackageList *selectedlist;
-
- selectedlist = (PackageList *)application_manager_data_get_selectedlist (appdata);
- g_return_if_fail (selectedlist != NULL);
-
- package_list_insert_node_without_check (selectedlist, (IPK_PACKAGE *)pkg);
-}
-
-/*
- * @brief Get the package version from package node
- *
- * @param pkg The package infomation
- * @return A pointer to the version of the package. The string points to the
- * internally allocated storage and must not be free, modified or stored.
- */
-char *
-package_list_get_package_version (gpointer pkg)
-{
- IPK_PACKAGE *package;
-
- g_return_val_if_fail (pkg != NULL, NULL);
-
- package = (IPK_PACKAGE *)pkg;
-
- return package->version;
-}
-
-/*
- * @brief Get the package name from package node
- *
- * @param pkg The package infomation
- * @return A pointer to the name of the package. The string points to the
- * internally allocated storage and must not be free, modified or stored.
- */
-char *
-package_list_get_package_name (gpointer pkg)
-{
- IPK_PACKAGE *package;
-
- g_return_val_if_fail (pkg != NULL, NULL);
-
- package = (IPK_PACKAGE *)pkg;
-
- return package->name;
-}
-
-/*
- * @brief Get the package depends from package node
- *
- * @param pkg The package infomation
- * @return A pointer to the depends of the package. The string points to the
- * internally allocated storage and must not be free, modified or stored.
- */
-char *
-package_list_get_package_depends (gpointer pkg)
-{
- IPK_PACKAGE *package;
-
- g_return_val_if_fail (pkg != NULL, NULL);
-
- package = (IPK_PACKAGE *)pkg;
-
- return package->depends;
-}
-
-/*
- * @brief Get the package description from package node
- *
- * @param pkg The package infomation
- * @return A pointer to the description of the package. The string points to the
- * internally allocated storage and must not be free, modified or stored.
- */
-char *
-package_list_get_package_description (gpointer pkg)
-{
- IPK_PACKAGE *package;
-
- g_return_val_if_fail (pkg != NULL, NULL);
-
- package = (IPK_PACKAGE *)pkg;
-
- return package->description;
-}
-
-/*
- * @brief Get the package maintainer from package node
- *
- * @param pkg The package infomation
- * @return A pointer to the maintainer of the package. The string points to the
- * internally allocated storage and must not be free, modified or stored.
- */
-char *
-package_list_get_package_maintainer (gpointer pkg)
-{
- IPK_PACKAGE *package;
-
- g_return_val_if_fail (pkg != NULL, NULL);
-
- package = (IPK_PACKAGE *)pkg;
-
- return package->maintainer;
-}
-
-/*
- * @brief Put the nodes in the package list to the GtkListStore
- *
- * @param appdata The application manager data
- * @param store The list store
- * @param pkglist The package list
- * @param str The search string
- */
-void
-search_and_translate_package_list_to_store (ApplicationManagerData *appdata,
- GtkListStore *store,
- gpointer pkglist,
- const gchar *str)
-{
- PackageList *pkglisthead = (PackageList *)pkglist;
- PackageList *tmplist;
-
- tmplist = pkglisthead->next;
- while (tmplist != pkglisthead)
- {
- if (strstr (tmplist->pkg->name, str) != NULL)
- insert_node_to_store (appdata, store, tmplist->pkg);
- tmplist = tmplist->next;
- }
-}
-
-/*
- * @brief Check the status of the marked list
- *
- * Takecare, the return value of this function is reversed.
- * If it returns TRUE, means that the marked list is empty
- * If it returns FALSE, means that the marked list is not empty
- * @return FALSE The marked list is not empty.\n
- * TRUE The marked list is empty.
- */
-gboolean
-package_list_check_marked_list_empty (ApplicationManagerData *appdata)
-{
- PackageList *mark;
-
- g_return_val_if_fail (MOKO_IS_APPLICATION_MANAGER_DATA (appdata), TRUE);
-
- mark = application_manager_data_get_selectedlist (appdata);
- if (mark == NULL)
- {
- return TRUE;
- }
-
- if (mark->next == mark)
- {
- return TRUE;
- }
-
- return FALSE;
-}
-
-/*
- * @brief Fill the GtkTreeStore with the selected package
- * @param treestore The tree store
- * @param selectedlist The selected package list
- * @param column The column that package name will insert
- */
-void
-package_list_fill_store_with_selected_list (GtkTreeStore *treestore,
- gpointer *selectedlist,
- gint column)
-{
- PackageList *tmplist;
- PackageList *slist = (PackageList *)selectedlist;
- GtkTreeIter iter;
- gboolean needupgrade, needinstall, needremove;
- GtkTreeIter iterupgrade, iterinstall, iterremove;
-
- needupgrade = needinstall = needremove = FALSE;
- tmplist = slist->next;
- while (tmplist != slist)
- {
- switch (tmplist->pkg->mark)
- {
- case PKG_STATUS_AVAILABLE_MARK_FOR_INSTALL:
- needinstall = TRUE;
- break;
-
- case PKG_STATUS_UPGRADEABLE_MARK_FOR_UPGRADE:
- needupgrade = TRUE;
- break;
-
- case PKG_STATUS_INSTALLED_MARK_FOR_REMOVE:
- case PKG_STATUS_UPGRADEABLE_MARK_FOR_REMOVE:
- needremove = TRUE;
- break;
-
- default:
- g_debug ("The status of package in the marked list is error, the package name is:%s",
- tmplist->pkg->name);
- break;
- }
- tmplist = tmplist->next;
- }
-
- if (needinstall)
- {
- gtk_tree_store_append (treestore, &iterinstall, NULL);
- gtk_tree_store_set (treestore, &iterinstall, column, "To be installed", -1);
- }
-
- if (needupgrade)
- {
- gtk_tree_store_append (treestore, &iterupgrade, NULL);
- gtk_tree_store_set (treestore, &iterupgrade, column, "To be upgraded", -1);
- }
-
- if (needremove)
- {
- gtk_tree_store_append (treestore, &iterremove, NULL);
- gtk_tree_store_set (treestore, &iterremove, column, "To be removed", -1);
- }
-
- tmplist = slist->next;
- while (tmplist != slist)
- {
- switch (tmplist->pkg->mark)
- {
- case PKG_STATUS_AVAILABLE_MARK_FOR_INSTALL:
- gtk_tree_store_append (treestore, &iter, &iterinstall);
- break;
-
- case PKG_STATUS_UPGRADEABLE_MARK_FOR_UPGRADE:
- gtk_tree_store_append (treestore, &iter, &iterupgrade);
- break;
-
- case PKG_STATUS_INSTALLED_MARK_FOR_REMOVE:
- case PKG_STATUS_UPGRADEABLE_MARK_FOR_REMOVE:
- gtk_tree_store_append (treestore, &iter, &iterremove);
- break;
-
- default:
- tmplist = tmplist->next;
- continue;
- }
- gtk_tree_store_set (treestore, &iter, column, tmplist->pkg->name, -1);
- tmplist = tmplist->next;
- }
-}
-
-/*
- * @brief Mark all upgradeable package for upgrade
- * @param appdata The application manager data
- */
-void
-package_list_mark_all_upgradeable (ApplicationManagerData *appdata)
-{
- PackageList *selectedlist;
- PackageList *upgradelist;
- PackageList *tmplist;
-
- g_return_if_fail (MOKO_IS_APPLICATION_MANAGER_DATA (appdata));
-
- selectedlist = application_manager_data_get_selectedlist (appdata);
- g_return_if_fail (selectedlist);
-
- upgradelist = application_manager_data_get_upgradelist (appdata);
- g_return_if_fail (upgradelist);
-
- tmplist = upgradelist->next;
- while (tmplist != upgradelist)
- {
- switch (tmplist->pkg->mark)
- {
- case PKG_STATUS_UPGRADEABLE:
- tmplist->pkg->mark = PKG_STATUS_UPGRADEABLE_MARK_FOR_UPGRADE;
- package_list_insert_node_without_check (selectedlist, tmplist->pkg);
- break;
-
- case PKG_STATUS_UPGRADEABLE_MARK_FOR_REMOVE:
- tmplist->pkg->mark = PKG_STATUS_UPGRADEABLE_MARK_FOR_UPGRADE;
- break;
-
- default:
- break;
- } /* end switch */
- tmplist = tmplist->next;
- } /* end while */
-}
-
-/*
- * @brief Install/upgrade/remove pacakges that belong to the selected list
- * @param data The application manager data
- */
-gpointer
-package_list_execute_change (gpointer data)
-{
- ApplicationManagerData *appdata;
- GtkWidget *installdialog;
- PackageList *pkglist;
- PackageList *tmplist;
- char *newname = NULL;
- gchar tmpstr[256];
- gchar *errstr;
- int ret;
- int res;
- gboolean change;
-
- g_return_val_if_fail (MOKO_IS_APPLICATION_MANAGER_DATA (data), NULL);
- appdata = MOKO_APPLICATION_MANAGER_DATA (data);
-
- installdialog = application_manager_data_get_install_dialog(appdata);
- g_return_val_if_fail (MOKO_IS_INSTALL_DIALOG (installdialog), NULL);
-
- pkglist = application_manager_data_get_selectedlist (appdata);
- g_return_val_if_fail (pkglist != NULL, NULL);
-
- tmplist = pkglist->next;
- change = FALSE;
-
- g_debug ("Begin to execute the marked packages");
-
- while (tmplist != pkglist)
- {
- switch (tmplist->pkg->mark)
- {
- case PKG_STATUS_AVAILABLE_MARK_FOR_INSTALL:
- snprintf (tmpstr, 255,
- "Begin install package \"%s\"\n",
- tmplist->pkg->name);
- install_dialog_add_prepare_info (MOKO_INSTALL_DIALOG (installdialog),
- tmpstr);
- /* FIXME The newname of the packages are not used now. */
- g_debug ("Begin to install:%s", tmplist->pkg->name);
- ret = ipkg_install_cmd (tmplist->pkg->name, "root", &newname);
- g_debug ("Install:%s complete, ret=%d", tmplist->pkg->name, ret);
- if (ret == 0)
- {
- snprintf (tmpstr, 255,
- "Install package \"%s\" success.\n",
- tmplist->pkg->name);
- install_dialog_add_install_info (MOKO_INSTALL_DIALOG (installdialog),
- tmpstr);
- }
- else
- {
- res = strlen (get_error_msg ());
- errstr = g_malloc (res + 100);
- if (errstr == NULL)
- {
- /* FIXME Add error manager code here */
- g_debug ("errstr malloc menory NULL");
- install_dialog_add_install_info (MOKO_INSTALL_DIALOG (installdialog),
- get_error_msg ());
- break;
- }
- snprintf (errstr, res + 100,
- "Install package \"%s\" error, the error message is:\n%s\n",
- tmplist->pkg->name,
- get_error_msg ());
- install_dialog_add_install_info (MOKO_INSTALL_DIALOG (installdialog),
- errstr);
- g_free (errstr);
- errstr = NULL;
- }
- break;
-
- case PKG_STATUS_UPGRADEABLE_MARK_FOR_UPGRADE:
- snprintf (tmpstr, 255,
- "Begin upgrade package \"%s\"\n",
- tmplist->pkg->name);
- install_dialog_add_prepare_info (MOKO_INSTALL_DIALOG (installdialog),
- tmpstr);
- /* FIXME The newname of the packages are not used now. */
- ret = ipkg_install_cmd (tmplist->pkg->name, "root", &newname);
- if (ret == 0)
- {
- snprintf (tmpstr, 255,
- "Upgrade package \"%s\" success.\n",
- tmplist->pkg->name);
- install_dialog_add_install_info (MOKO_INSTALL_DIALOG (installdialog),
- tmpstr);
- }
- else
- {
- res = strlen (get_error_msg ());
- errstr = g_malloc (res + 100);
- if (errstr == NULL)
- {
- /* FIXME Add error manager code here */
- install_dialog_add_install_info (MOKO_INSTALL_DIALOG (installdialog),
- get_error_msg ());
- break;
- }
- snprintf (errstr, res + 100,
- "Upgrade package \"%s\" error, the error message is:\n%s\n",
- tmplist->pkg->name,
- get_error_msg ());
- install_dialog_add_install_info (MOKO_INSTALL_DIALOG (installdialog),
- errstr);
- g_free (errstr);
- errstr = NULL;
- }
- break;
-
- case PKG_STATUS_INSTALLED_MARK_FOR_REMOVE:
- case PKG_STATUS_UPGRADEABLE_MARK_FOR_REMOVE:
- snprintf (tmpstr, 255,
- "Begin remove package \"%s\"\n",
- tmplist->pkg->name);
- install_dialog_add_prepare_info (MOKO_INSTALL_DIALOG (installdialog),
- tmpstr);
- /* FIXME The newname of the packages are not used now. */
- ret = ipkg_remove_cmd (tmplist->pkg->name);
- if (ret == 0)
- {
- snprintf (tmpstr, 255,
- "Remove package \"%s\" success.\n",
- tmplist->pkg->name);
- install_dialog_add_install_info (MOKO_INSTALL_DIALOG (installdialog),
- tmpstr);
- }
- else
- {
- res = strlen (get_error_msg ());
- errstr = g_malloc (res + 100);
- if (errstr == NULL)
- {
- /* FIXME Add error manager code here */
- install_dialog_add_install_info (MOKO_INSTALL_DIALOG (installdialog),
- get_error_msg ());
- break;
- }
- snprintf (errstr, res + 100,
- "Remove package \"%s\" error, the error message is:\n%s\n",
- tmplist->pkg->name,
- get_error_msg ());
- install_dialog_add_install_info (MOKO_INSTALL_DIALOG (installdialog),
- errstr);
- g_free (errstr);
- errstr = NULL;
- }
- break;
-
- default :
- ret = -1;
- break;
-
- }
- if (ret == 0)
- {
- change = TRUE;
- if (newname != NULL)
- {
- free (newname);
- newname = NULL;
- }
- }
- tmplist = tmplist->next;
- }
-
- if (change)
- {
- install_dialog_set_install_status (MOKO_INSTALL_DIALOG (installdialog),
- STATUS_REINIT);
- package_list_free_all_dynamic (appdata);
-
- ret = reinit_package_list (appdata);
- if (ret != OP_SUCCESS)
- {
- g_debug ("Can not initial the libipkg, the result is%d", ret);
- return NULL;
- }
- ret = package_list_build_index (appdata);
- if (ret != OP_SUCCESS)
- {
- g_debug ("Can not build index for packages");
- return NULL;
- }
- /* FIXME Add reinit filter menu code late */
- }
-
- install_dialog_set_install_status (MOKO_INSTALL_DIALOG (installdialog),
- STATUS_COMPLETE);
-
- return NULL;
-}
-
-/*
- * @brief Free all dynamic data
- * @param appdata The application manager data
- */
-void
-package_list_free_all_dynamic (ApplicationManagerData *appdata)
-{
- PKG_LIST_HEAD *pkgheader;
-
- g_return_if_fail (MOKO_IS_APPLICATION_MANAGER_DATA (appdata));
-
- pkgheader = application_manager_data_get_pkglist (appdata);
- if (pkgheader != NULL)
- {
- free_pkg_list (pkgheader);
- g_free (pkgheader);
- application_manager_data_set_pkglist (appdata, NULL);
- }
-
- package_list_clear_old_index (appdata);
-}
-
-/*
- * @brief Get the number of packages in the selected list
- * @param appdata The application manager data
- */
-gint
-package_list_get_number_of_selected (ApplicationManagerData *appdata)
-{
- PackageList *pkglist;
- PackageList *tmplist;
- gint number;
-
- g_return_val_if_fail (MOKO_IS_APPLICATION_MANAGER_DATA (appdata), -1);
-
- pkglist = application_manager_data_get_selectedlist (appdata);
- g_return_val_if_fail (pkglist != NULL, 0);
-
- number = 0;
- tmplist = pkglist->next;
- while (tmplist != pkglist)
- {
- number ++;
- tmplist = tmplist->next;
- }
-
- return number;
-}
-
Deleted: trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/package-list.h
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/package-list.h 2007-11-08 15:52:03 UTC (rev 3379)
+++ trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/package-list.h 2007-11-08 17:42:57 UTC (rev 3380)
@@ -1,81 +0,0 @@
-/*
- * @file package-list.h
- * @brief The package list that get from the lib ipkg
- *
- * Copyright (C) 2006-2007 OpenMoko Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Public License as published by
- * the Free Software Foundation; version 2.1 of the license.
- *
- * 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 Public License for more details.
- *
- * Current Version: $Rev$ ($Date$) [$Author$]
- *
- * @author Chaowei Song (songcw at fic-sh.com.cn)
- */
-#ifndef _FIC_PACKAGE_LIST_H
-#define _FIC_PACKAGE_LIST_H
-
-#include <gtk/gtk.h>
-
-#define PACKAGE_LIST_NO_SECTION_STRING "no section"
-
-gint init_package_list (ApplicationManagerData *appdata);
-
-gint reinit_package_list (ApplicationManagerData *appdata);
-
-gint package_list_build_index (ApplicationManagerData *appdata);
-
-void package_list_add_section_to_filter_menu (ApplicationManagerData *appdata);
-
-void translate_package_list_to_store (ApplicationManagerData *appdata,
- GtkListStore *store,
- gpointer pkglist);
-
-gpointer package_list_get_with_name (ApplicationManagerData *appdata,
- const gchar *name);
-
-gint package_list_get_package_status (gpointer data);
-
-void package_list_set_package_status (gpointer data, gint status);
-
-void package_list_remove_package_from_selected_list (ApplicationManagerData *appdata,
- gpointer pkg);
-
-void package_list_add_node_to_selected_list (ApplicationManagerData *appdata,
- gpointer pkg);
-
-char *package_list_get_package_version (gpointer pkg);
-
-char *package_list_get_package_name (gpointer pkg);
-
-char *package_list_get_package_depends (gpointer pkg);
-
-char *package_list_get_package_description (gpointer pkg);
-
-char *package_list_get_package_maintainer (gpointer pkg);
-
-void search_and_translate_package_list_to_store (ApplicationManagerData *appdata,
- GtkListStore *store,
- gpointer pkglist,
- const gchar *str);
-gboolean
-package_list_check_marked_list_empty (ApplicationManagerData *appdata);
-
-void package_list_fill_store_with_selected_list (GtkTreeStore *treestore,
- gpointer *selectedlist,
- gint column);
-void package_list_mark_all_upgradeable (ApplicationManagerData *appdata);
-
-gpointer package_list_execute_change (gpointer data);
-
-void package_list_free_all_dynamic (ApplicationManagerData *appdata);
-
-gint package_list_get_number_of_selected (ApplicationManagerData *appdata);
-
-#endif
-
Modified: trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/search-bar.c
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/search-bar.c 2007-11-08 15:52:03 UTC (rev 3379)
+++ trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/search-bar.c 2007-11-08 17:42:57 UTC (rev 3380)
@@ -19,10 +19,10 @@
#include "appmanager-data.h"
#include "navigation-area.h"
-#include "package-list.h"
+#include "package-store.h"
+#include "ipkgapi.h"
-
static gboolean
combo_seperator_func (GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
{
@@ -43,75 +43,70 @@
static void
combo_changed_cb (MokoSearchBar *searchbar, GtkComboBox *combo, ApplicationManagerData *data)
{
- int ret;
- gchar *secname;
- GtkTreeIter iter;
- gpointer pkglist;
+ GtkTreeModel *filter;
- if ((ret = gtk_combo_box_get_active (combo)) < 5)
+ filter = gtk_tree_view_get_model (GTK_TREE_VIEW (data->tvpkglist));
+ gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (filter));
+}
+
+static void
+searchbar_toggled_cb (MokoSearchBar *searchbar, gboolean search, ApplicationManagerData *data)
+{
+}
+
+gboolean
+section_search_hash (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, GHashTable *hash)
+{
+ IPK_PACKAGE *pkg;
+
+ gtk_tree_model_get (model, iter, COL_POINTER, &pkg, -1);
+
+ if (!g_hash_table_lookup (hash, pkg->section))
{
- switch (ret)
- {
- case 0:
- /* installed */
- g_debug ("Clicked the installed menuitem");
- pkglist = application_manager_data_get_installedlist (data);
- navigation_area_refresh_with_package_list (data, pkglist);
- return;
- case 1:
- /* upgradeable */
- g_debug ("Clicked the upgradeable menuitem");
- pkglist = application_manager_data_get_upgradelist (data);
- navigation_area_refresh_with_package_list (data, pkglist);
- return;
- case 2:
- /* selected */
- g_debug ("Click the selected menuitem");
- pkglist = application_manager_data_get_selectedlist (data);
- navigation_area_refresh_with_package_list (data, pkglist);
- return;
- }
+ g_hash_table_insert (hash, pkg->section, pkg->section);
+ g_debug ("hash table insert %s", pkg->section);
}
- gtk_combo_box_get_active_iter (combo, &iter);
- gtk_tree_model_get (data->filter_store, &iter, 0, &secname, -1);
-
- ret = strcmp (secname, PACKAGE_LIST_NO_SECTION_STRING);
- if (ret == 0)
+ return FALSE;
+}
+
+void
+section_hash_insert (gchar *key, gchar *value, GtkListStore *list)
+{
+ gtk_list_store_insert_with_values (list, NULL, -1, 0, key, -1);
+}
+
+gboolean
+section_search_slist (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, GSList **head)
+{
+ IPK_PACKAGE *pkg;
+
+ gtk_tree_model_get (model, iter, COL_POINTER, &pkg, -1);
+
+ if (!g_slist_find_custom (*head, pkg->section, (GCompareFunc) strcmp))
{
- pkglist = application_manager_data_get_nosecpkglist (
- MOKO_APPLICATION_MANAGER_DATA (data));
- navigation_area_refresh_with_package_list (
- MOKO_APPLICATION_MANAGER_DATA (data),
- pkglist);
- return;
+ *head = g_slist_prepend(*head, pkg->section);
+ g_debug ("slist table insert %s", pkg->section);
}
- pkglist = package_list_get_with_name (
- MOKO_APPLICATION_MANAGER_DATA (data),
- secname);
- if (pkglist == NULL)
- {
- g_debug ("Can not find the section that named:%s", secname);
- return;
- }
- navigation_area_refresh_with_package_list (
- MOKO_APPLICATION_MANAGER_DATA (data),
- pkglist);
+ return FALSE;
}
-static void
-searchbar_toggled_cb (MokoSearchBar *searchbar, gboolean search, ApplicationManagerData *data)
+void
+slist_insert (gchar *value, GtkListStore *list)
{
+ gtk_list_store_insert_with_values (list, NULL, -1, 0, value, -1);
}
GtkWidget *
-search_bar_new (ApplicationManagerData *appdata)
+search_bar_new (ApplicationManagerData *appdata, GtkTreeModel *pkg_list)
{
GtkWidget *combo;
GtkWidget *searchbar;
GtkListStore *filter;
GtkCellRenderer *renderer;
+ GHashTable *hash;
+ /* GSList *slist = NULL; */
filter = gtk_list_store_new (1, G_TYPE_STRING);
appdata->filter_store = GTK_TREE_MODEL (filter);
@@ -120,7 +115,19 @@
gtk_list_store_insert_with_values (filter, NULL, FILTER_UPGRADEABLE, 0, "Upgradeable", -1);
gtk_list_store_insert_with_values (filter, NULL, FILTER_SELECTED, 0, "Selected", -1);
gtk_list_store_insert_with_values (filter, NULL, 3, 0, NULL, -1);
+
+ /* profile these two methods to see which is quicker */
+ hash = g_hash_table_new (g_str_hash, g_str_equal);
+ gtk_tree_model_foreach (pkg_list, (GtkTreeModelForeachFunc) section_search_hash, hash);
+ g_hash_table_foreach (hash, (GHFunc) section_hash_insert, filter);
+ g_hash_table_unref (hash);
+#if 0
+ gtk_tree_model_foreach (pkg_list, (GtkTreeModelForeachFunc) section_search_slist, &slist);
+ g_slist_foreach (slist, slist_insert, filter);
+ g_slist_free (slist);
+#endif
+
renderer = gtk_cell_renderer_text_new ();
combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (filter));
Modified: trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/search-bar.h
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/search-bar.h 2007-11-08 15:52:03 UTC (rev 3379)
+++ trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/search-bar.h 2007-11-08 17:42:57 UTC (rev 3380)
@@ -29,7 +29,7 @@
FILTER_SELECTED
} SearchBarFilter;
-GtkWidget* search_bar_new (ApplicationManagerData *appdata);
+GtkWidget* search_bar_new (ApplicationManagerData *appdatam, GtkTreeModel *pkg_list);
void search_bar_add_filter_item (ApplicationManagerData *appdata, gchar *item);
void search_bar_set_active_filter (MokoSearchBar *bar, SearchBarFilter filter);
Modified: trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/tool-box.c
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/tool-box.c 2007-11-08 15:52:03 UTC (rev 3379)
+++ trunk/src/target/OM-2007.2/applications/openmoko-appmanager2/src/tool-box.c 2007-11-08 17:42:57 UTC (rev 3380)
@@ -93,61 +93,7 @@
}
-
/*
- * @brief The callback function of the search entry
- */
-void
-on_search_entry_changed (GtkEditable *entryedit, gpointer data)
-{
- ApplicationManagerData *appdata;
- GtkEntry *entry;
- const gchar *searchstr;
- gchar *searchhistory;
-
- g_debug ("Change the contant of entry");
- g_return_if_fail (MOKO_IS_APPLICATION_MANAGER_DATA (data));
-
- appdata = data;
- entry = application_manager_get_search_entry (appdata);
- g_return_if_fail (GTK_IS_ENTRY (entry));
- searchstr = gtk_entry_get_text (entry);
-
- g_return_if_fail (searchstr != NULL);
-
- if (searchstr[0] == '\0')
- {
- /* FIXME Add code later */
- g_debug ("The length of search string is 0");
- navigation_area_rebuild_from_latest (appdata);
- return;
- }
-
- searchhistory = application_manager_data_get_search_history (appdata);
- if (searchhistory == NULL)
- {
- searchhistory = g_malloc (MAX_SEARCH_ENTRY_TEXT_LENGTH + 1);
- g_return_if_fail (searchhistory != NULL);
-
- searchhistory[0] = '\0';
- application_manager_data_set_search_history (appdata, searchhistory);
- }
-
- if (strstr ((char *)searchstr, (char *)searchhistory) != NULL)
- {
- g_debug ("Increase search");
- navigation_area_increase_search (appdata, searchstr);
- }
- else
- {
- g_debug ("Search from the beginning");
- navigation_area_rebuild_search_result (appdata, searchstr);
- }
-
- strncpy (searchhistory, searchstr, MAX_SEARCH_ENTRY_TEXT_LENGTH);
-}
-
-/*
* @brief Create a new tool box for the application manager data
* @param appdata The application manager data
* @return The toplevel widget of the tool box
More information about the commitlog
mailing list