r472 - in trunk/src/target/OM-2007/applications/openmoko-appmanager: . src
caowai_song at gta01.hmw-consulting.de
caowai_song at gta01.hmw-consulting.de
Tue Dec 26 10:16:58 CET 2006
Author: caowai_song
Date: 2006-12-26 10:16:41 +0100 (Tue, 26 Dec 2006)
New Revision: 472
Added:
trunk/src/target/OM-2007/applications/openmoko-appmanager/src/install-dialog.c
trunk/src/target/OM-2007/applications/openmoko-appmanager/src/install-dialog.h
Modified:
trunk/src/target/OM-2007/applications/openmoko-appmanager/openmoko-appmanager.pro
trunk/src/target/OM-2007/applications/openmoko-appmanager/src/Makefile.am
Log:
Add an install dialog. It displays the install/remove/upgrade infomation
to the user.
Modified: trunk/src/target/OM-2007/applications/openmoko-appmanager/openmoko-appmanager.pro
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-appmanager/openmoko-appmanager.pro 2006-12-26 07:47:24 UTC (rev 471)
+++ trunk/src/target/OM-2007/applications/openmoko-appmanager/openmoko-appmanager.pro 2006-12-26 09:16:41 UTC (rev 472)
@@ -13,7 +13,8 @@
src/pixbuf-list.h \
src/select-menu.h \
src/tool-box.h \
- src/apply-dialog.h
+ src/apply-dialog.h \
+ src/install-dialog.h
SOURCES += src/application-menu.c \
src/appmanager-data.c \
src/appmanager-window.c \
@@ -25,7 +26,8 @@
src/pixbuf-list.c \
src/select-menu.c \
src/tool-box.c \
- src/apply-dialog.c
+ src/apply-dialog.c \
+ src/install-dialog.c
include ( $(OPENMOKODIR)/devel/qmake/openmoko-include.pro )
Modified: trunk/src/target/OM-2007/applications/openmoko-appmanager/src/Makefile.am
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-appmanager/src/Makefile.am 2006-12-26 07:47:24 UTC (rev 471)
+++ trunk/src/target/OM-2007/applications/openmoko-appmanager/src/Makefile.am 2006-12-26 09:16:41 UTC (rev 472)
@@ -13,6 +13,7 @@
package-list.c\
pixbuf-list.c\
select-menu.c\
- apply-dialog.c
+ apply-dialog.c\
+ install-dialog.c
openmoko_appmanager_LDADD = @OPENMOKO_LIBS@
Added: trunk/src/target/OM-2007/applications/openmoko-appmanager/src/install-dialog.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-appmanager/src/install-dialog.c 2006-12-26 07:47:24 UTC (rev 471)
+++ trunk/src/target/OM-2007/applications/openmoko-appmanager/src/install-dialog.c 2006-12-26 09:16:41 UTC (rev 472)
@@ -0,0 +1,243 @@
+/**
+ * @file install-dialog.c
+ * @brief It is the dialog that displays the process of install/remove/upgrade
+ * packages.
+ *
+ * Copyright (C) 2006 First International Computer 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)
+ */
+#include <libmokoui/moko-tree-view.h>
+
+#include "install-dialog.h"
+#include "appmanager-window.h"
+#include "package-list.h"
+
+static void install_dialog_class_init (InstallDialogClass *klass);
+static void install_dialog_init (InstallDialog *self);
+static gboolean install_dialog_time_out (gpointer dialog);
+
+G_DEFINE_TYPE (InstallDialog, install_dialog, GTK_TYPE_DIALOG)
+
+#define MOKO_INSTALL_DIALOG_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), MOKO_TYPE_INSTALL_DIALOG, InstallDialogPriv));
+
+/**
+ * @brief The private data of the Install dialog
+ */
+typedef struct _InstallDialogPriv {
+ ApplicationManagerData *maindata; ///<! The main data of the application manager
+ gchar **installinfolist; ///<! The list of install/remove/upgrade infomation
+ gchar **prepareinfolist; ///<! The list of prepareinfomation
+ gint preparenum; ///<! Prepare to install/remove/upgrade the _number_ package
+ gint installnum; ///<! Installing/removing/upgrading the _number_ package
+ gint displaypreparenum; ///<! Prepare info of the _number_ package has been displayed
+ gint displayinstallnum; ///<! Installed info of the _number_ package has been displayed
+ gint installstatus; ///<! The status of the install process
+ gint displaystatus; ///<! The status of the display process
+ gboolean requestcancel; ///<! Cancel the install status by user choice
+ GtkWidget *textview; ///<! The textview in the dialog
+} InstallDialogPriv;
+
+static void
+install_dialog_class_init (InstallDialogClass *klass)
+{
+}
+
+static void
+install_dialog_init (InstallDialog *self)
+{
+ InstallDialogPriv *priv = MOKO_INSTALL_DIALOG_GET_PRIVATE (self);
+ GtkWidget *vbox;
+ GtkWidget *scrollwindow;
+ GtkWidget *closebutton;
+
+ // Init the data
+ priv->maindata = NULL;
+ priv->installinfolist = NULL;
+ priv->prepareinfolist = NULL;
+ priv->preparenum = 0;
+ priv->installnum = 0;
+ priv->displaypreparenum = 0;
+ priv->displayinstallnum = 0;
+ priv->installstatus = STATUS_INSTALL;
+ priv->displaystatus = STATUS_INSTALL;
+ priv->requestcancel = FALSE;
+
+ // Init the dialog
+ gtk_widget_set_size_request (GTK_WIDGET (self), 300, 480);
+ gtk_window_set_title (GTK_WINDOW (self), _("dialog1"));
+ gtk_window_set_type_hint (GTK_WINDOW (self), GDK_WINDOW_TYPE_HINT_DIALOG);
+
+ vbox = GTK_DIALOG (self)->vbox;
+ gtk_widget_show (vbox);
+
+ scrollwindow = gtk_scrolled_window_new (NULL, NULL);
+ gtk_widget_show (scrollwindow);
+ gtk_box_pack_start (GTK_BOX (vbox), scrollwindow, TRUE, TRUE, 0);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrollwindow), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrollwindow), GTK_SHADOW_IN);
+
+ priv->textview = gtk_text_view_new ();
+ gtk_widget_show (priv->textview);
+ gtk_container_add (GTK_CONTAINER (scrollwindow), priv->textview);
+ gtk_text_view_set_editable (GTK_TEXT_VIEW (priv->textview), FALSE);
+ gtk_text_view_set_accepts_tab (GTK_TEXT_VIEW (priv->textview), FALSE);
+ gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (priv->textview), GTK_WRAP_WORD);
+ gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (priv->textview), FALSE);
+
+ closebutton = gtk_button_new_from_stock ("gtk-close");
+ gtk_widget_show (closebutton);
+ gtk_dialog_add_action_widget (GTK_DIALOG (self), closebutton, GTK_RESPONSE_CLOSE);
+ GTK_WIDGET_SET_FLAGS (closebutton, GTK_CAN_DEFAULT);
+}
+
+/**
+ * @brief Create a new install dialog
+ * @param appdata The application manager data
+ * @param pkgnum The number of package that will be disposed
+ * @return The install dialog
+ */
+InstallDialog *
+install_dialog_new (ApplicationManagerData *appdata, gint pkgnum)
+{
+ InstallDialog *dialog = MOKO_INSTALL_DIALOG (g_object_new (MOKO_TYPE_INSTALL_DIALOG, NULL));
+ InstallDialogPriv *priv = MOKO_INSTALL_DIALOG_GET_PRIVATE (dialog);
+
+ priv->installinfolist = (gchar **)g_malloc (sizeof(gchar *) * pkgnum);
+ if (priv->installinfolist == NULL)
+ {
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+ g_debug ("Can not malloc memory for the install dialog");
+ return NULL;
+ }
+ priv->prepareinfolist = (gchar **)g_malloc (sizeof(gchar *) * pkgnum);
+ if (priv->prepareinfolist == NULL)
+ {
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+ g_free (priv->installinfolist);
+ g_debug ("Can not malloc memory for the install dialog");
+ return NULL;
+ }
+ g_timeout_add (100, (GSourceFunc)install_dialog_time_out, dialog);
+
+ return dialog;
+}
+
+/**
+ * @brief The timeout event, update the display infomation of
+ * install/remove/upgrade packages
+ * @param dialog The install dialog
+ */
+static gboolean
+install_dialog_time_out (gpointer dialog)
+{
+ InstallDialog *installdialog;
+ InstallDialogPriv *priv;
+ GtkTextBuffer *buffer;
+ gboolean change = FALSE;
+ GtkTextIter iter;
+
+ g_return_val_if_fail (MOKO_IS_INSTALL_DIALOG (dialog), FALSE);
+ installdialog = MOKO_INSTALL_DIALOG (dialog);
+
+ priv = MOKO_INSTALL_DIALOG_GET_PRIVATE (installdialog);
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->textview));
+
+ while ((priv->displaypreparenum < priv->preparenum)
+ || (priv->displayinstallnum < priv->installnum))
+ {
+ change = TRUE;
+ if (priv->displaypreparenum == priv->displayinstallnum)
+ {
+ gtk_text_buffer_get_end_iter (buffer, &iter);
+ gtk_text_buffer_insert (buffer, &iter,
+ priv->prepareinfolist[priv->displaypreparenum],
+ -1);
+ g_free (priv->prepareinfolist[priv->displaypreparenum]);
+ priv->prepareinfolist[priv->displaypreparenum] = NULL;
+ priv->displaypreparenum ++;
+ }
+ else
+ {
+ gtk_text_buffer_get_end_iter (buffer, &iter);
+ gtk_text_buffer_insert (buffer, &iter,
+ priv->installinfolist[priv->displayinstallnum],
+ -1);
+ g_free (priv->installinfolist[priv->displayinstallnum]);
+ priv->installinfolist[priv->displayinstallnum] = NULL;
+ priv->displayinstallnum ++;
+ }
+ }
+
+ if (change)
+ return TRUE;
+
+ if (priv->installstatus == STATUS_REINIT)
+ {
+ if (priv->displaystatus != STATUS_REINIT)
+ {
+ gtk_text_buffer_get_end_iter (buffer, &iter);
+ gtk_text_buffer_insert (buffer, &iter,
+ "Reload the package list, please wait\n",
+ -1);
+ priv->displaystatus = STATUS_REINIT;
+ }
+ return TRUE;
+ }
+
+ if (priv->installstatus == STATUS_ERROR)
+ {
+ // FIXME An error appeared in the install process. Add code later.
+ return FALSE;
+ }
+
+ if (priv->installstatus == STATUS_COMPLETE)
+ {
+ gtk_text_buffer_get_end_iter (buffer, &iter);
+ gtk_text_buffer_insert (buffer, &iter,
+ "Completely, press the close button to finish.\n",
+ -1);
+
+ if (priv->installinfolist != NULL)
+ {
+ g_free (priv->installinfolist);
+ priv->installinfolist = NULL;
+ }
+
+ if (priv->prepareinfolist != NULL)
+ {
+ g_free (priv->prepareinfolist);
+ priv->prepareinfolist = NULL;
+ }
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/**
+ * @brief Set the install status of the install dialog
+ */
+void
+install_dialog_set_install_status (InstallDialog *dialog,
+ gint status)
+{
+ InstallDialogPriv *priv;
+
+ g_return_if_fail (MOKO_IS_INSTALL_DIALOG (dialog));
+ priv = MOKO_INSTALL_DIALOG_GET_PRIVATE (dialog);
+
+ g_return_if_fail ((status >= STATUS_INSTALL) && (status <= STATUS_COMPLETE));
+ priv->installstatus = status;
+}
Added: trunk/src/target/OM-2007/applications/openmoko-appmanager/src/install-dialog.h
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-appmanager/src/install-dialog.h 2006-12-26 07:47:24 UTC (rev 471)
+++ trunk/src/target/OM-2007/applications/openmoko-appmanager/src/install-dialog.h 2006-12-26 09:16:41 UTC (rev 472)
@@ -0,0 +1,77 @@
+/**
+ * @file install-dialog.h
+ * @brief It is the dialog that displays the process of install/remove/upgrade
+ * packages.
+ *
+ * Copyright (C) 2006 First International Computer 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_INSTALL_DIALOG_H
+#define _FIC_INSTALL_DIALOG_H
+
+#include <gtk/gtk.h>
+
+#include "appmanager-data.h"
+
+G_BEGIN_DECLS
+
+#define MOKO_TYPE_INSTALL_DIALOG (install_dialog_get_type ())
+#define MOKO_INSTALL_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ MOKO_TYPE_INSTALL_DIALOG, \
+ InstallDialog))
+#define MOKO_INSTALL_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), \
+ MOKO_TYPE_INSTALL_DIALOG, \
+ InstallDialogClass))
+#define MOKO_IS_INSTALL_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ MOKO_TYPE_INSTALL_DIALOG))
+#define MOKO_IS_INSTALL_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+ MOKO_TYPE_INSTALL_DIALOG))
+#define MOKO_INSTALL_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+ MOKO_TYPE_INSTALL_DIALOG, \
+ InstallDialogClass))
+
+/**
+ * @brief Process status of the install dialog
+ */
+enum {
+ STATUS_INSTALL, ///<! Install/remove/upgrade packages
+ STATUS_REINIT, ///<! Reinit the package list and navigation view
+ STATUS_ERROR, ///<! There is error when install/remove/upgrade packages
+ STATUS_COMPLETE ///<! The process of install/remove/upgrade packages completed
+};
+
+/**
+ * @brief The install dialog struct
+ */
+typedef struct _InstallDialog {
+ GtkDialog parent; ///<! The parent of the struct
+} InstallDialog;
+
+/**
+ * @brief The install dialog class struct
+ */
+typedef struct _InstallDialogClass {
+ GtkDialogClass parent_class; ///<! The parent of the struct
+} InstallDialogClass;
+
+GType install_dialog_get_type (void);
+
+InstallDialog *install_dialog_new (ApplicationManagerData *appdata, gint pkgnum);
+void install_dialog_set_install_status (InstallDialog *dialog,
+ gint status);
+
+G_END_DECLS
+
+#endif
More information about the commitlog
mailing list