gnome-packagekit r157 - in trunk: data po src



Author: rhughes
Date: Thu Apr 10 19:30:55 2008
New Revision: 157
URL: http://svn.gnome.org/viewvc/gnome-packagekit?rev=157&view=rev

Log:
from git

Modified:
   trunk/data/gpk-install-file.glade
   trunk/po/POTFILES.in
   trunk/src/Makefile.am
   trunk/src/gpk-install-file.c
   trunk/src/gpk-install-package.c

Modified: trunk/data/gpk-install-file.glade
==============================================================================
--- trunk/data/gpk-install-file.glade	(original)
+++ trunk/data/gpk-install-file.glade	Thu Apr 10 19:30:55 2008
@@ -45,12 +45,22 @@
                   </packing>
                 </child>
                 <child>
+                  <widget class="GtkLabel" id="label_package">
+                    <property name="visible">True</property>
+                    <property name="use_markup">True</property>
+                  </widget>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="position">3</property>
+                  </packing>
+                </child>
+                <child>
                   <widget class="GtkLabel" id="label1">
                     <property name="visible">True</property>
                     <property name="label">    </property>
                   </widget>
                   <packing>
-                    <property name="position">2</property>
+                    <property name="position">4</property>
                   </packing>
                 </child>
                 <child>
@@ -88,7 +98,7 @@
                     <property name="expand">False</property>
                     <property name="fill">False</property>
                     <property name="pack_type">GTK_PACK_END</property>
-                    <property name="position">3</property>
+                    <property name="position">2</property>
                   </packing>
                 </child>
               </widget>

Modified: trunk/po/POTFILES.in
==============================================================================
--- trunk/po/POTFILES.in	(original)
+++ trunk/po/POTFILES.in	Thu Apr 10 19:30:55 2008
@@ -22,6 +22,7 @@
 src/gpk-application-main.c
 src/gpk-backend-status.c
 src/gpk-common.c
+src/gpk-client.c
 src/gpk-inhibit.c
 src/gpk-install-file.c
 src/gpk-install-package.c

Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am	(original)
+++ trunk/src/Makefile.am	Thu Apr 10 19:30:55 2008
@@ -47,8 +47,8 @@
 
 gpk_install_file_SOURCES =				\
 	gpk-install-file.c				\
-	gpk-progress.c					\
-	gpk-progress.h					\
+	gpk-client.c					\
+	gpk-client.h					\
 	gpk-common.c					\
 	gpk-common.h					\
 	$(NULL)
@@ -68,6 +68,8 @@
 	gpk-install-package.c				\
 	gpk-progress.c					\
 	gpk-progress.h					\
+	gpk-client.c					\
+	gpk-client.h					\
 	gpk-common.c					\
 	gpk-common.h					\
 	$(NULL)
@@ -286,6 +288,8 @@
 	rm -f gprof.txt
 	rm -f gpk-marshal.c gpk-marshal.h
 
+CLEANFILES = *~ $(BUILT_SOURCES)
+
 MAINTAINERCLEANFILES =					\
 	*~			      			\
 	Makefile.in					\

Modified: trunk/src/gpk-install-file.c
==============================================================================
--- trunk/src/gpk-install-file.c	(original)
+++ trunk/src/gpk-install-file.c	Thu Apr 10 19:30:55 2008
@@ -1,6 +1,6 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
  *
- * Copyright (C) 2007 Richard Hughes <richard hughsie com>
+ * Copyright (C) 2007-2008 Richard Hughes <richard hughsie com>
  *
  * Licensed under the GNU General Public License Version 2
  *
@@ -21,174 +21,15 @@
 
 #include "config.h"
 
-#include <errno.h>
-#include <string.h>
-#include <unistd.h>
-#include <stdlib.h>
 #include <glib.h>
 #include <glib/gi18n.h>
-#include <glade/glade.h>
-#include <dbus/dbus-glib.h>
 #include <gtk/gtk.h>
 #include <locale.h>
 
 #include <pk-debug.h>
-#include <pk-client.h>
 
-#include "gpk-progress.h"
 #include "gpk-common.h"
-
-static GladeXML *glade_xml = NULL;
-static PkClient *client = NULL;
-
-typedef enum {
-        PAGE_PROGRESS,
-        PAGE_CONFIRM,
-        PAGE_ERROR,
-        PAGE_LAST
-} PkPageEnum;
-
-static void
-gpk_install_file_set_page (PkPageEnum page)
-{
-        GList *list, *l;
-        GtkWidget *widget;
-        guint i;
-
-        widget = glade_xml_get_widget (glade_xml, "hbox_hidden");
-        list = gtk_container_get_children (GTK_CONTAINER (widget));
-        for (l=list, i=0; l; l=l->next, i++) {
-                if (i == page) {
-                        gtk_widget_show (l->data);
-                } else {
-                        gtk_widget_hide (l->data);
-                }
-        }
-}
-
-static gboolean
-gpk_install_finished_timeout (gpointer data)
-{
-	gtk_main_quit ();
-
-	return FALSE;
-}
-
-static void
-gpk_install_file_finished_cb (PkClient *client, PkExitEnum exit,
-			      guint runtime, gpointer data)
-{
-	if (exit == PK_EXIT_ENUM_SUCCESS) {
-                gpk_install_file_set_page (PAGE_CONFIRM);
-
-		g_timeout_add_seconds (30, gpk_install_finished_timeout, NULL);
-	}
-
-}
-
-static gint pulse_timeout = 0;
-
-static void
-gpk_install_file_progress_changed_cb (PkClient *client,
-				      guint     percentage,
-				      guint     subpercentage,
-				      guint     elapsed,
-				      guint     remaining,
-				      gpointer  data)
-{
-        GtkWidget *widget;
-
-        widget = glade_xml_get_widget (glade_xml, "progressbar_percent");
-
-	if (pulse_timeout != 0) {
-		g_source_remove (pulse_timeout);
-		pulse_timeout = 0;
-	}
-
-        if (percentage != PK_CLIENT_PERCENTAGE_INVALID) {
-                gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (widget), (gfloat) percentage / 100.0);
-        }
-}
-
-static gboolean
-pulse_progress (gpointer data)
-{
-        GtkWidget *widget;
-
-        widget = glade_xml_get_widget (glade_xml, "progressbar_percent");
-
-	gtk_progress_bar_pulse (GTK_PROGRESS_BAR (widget));
-
-	return TRUE;
-}
-
-static void
-gpk_install_file_status_changed_cb (PkClient     *client,
-				    PkStatusEnum  status,
-				    gpointer      data)
-{
-        GtkWidget *widget;
-        gchar *text;
-
-        widget = glade_xml_get_widget (glade_xml, "progress_part_label");
-        text = g_strdup_printf ("<b>%s</b>", gpk_status_enum_to_localised_text (status));
-        gtk_label_set_markup (GTK_LABEL (widget), text);
-        g_free (text);
-
-	if (status == PK_STATUS_ENUM_WAIT) {
-		if (pulse_timeout == 0) {
-			widget = glade_xml_get_widget (glade_xml, "progressbar_percent");
-
-			gtk_progress_bar_set_pulse_step (GTK_PROGRESS_BAR (widget ), 0.04);
-			pulse_timeout = g_timeout_add (75, pulse_progress, NULL);
-		}
-	}
-}
-
-static void
-gpk_install_file_error_code_cb (PkClient        *client,
-			        PkErrorCodeEnum  code,
-			        const gchar     *details,
-			        gpointer         data)
-{
-        GtkWidget *widget;
-        const gchar *title;
-        gchar *title_bold;
-        gchar *details_safe;
-
-        gpk_install_file_set_page (PAGE_ERROR);
-
-        /* set bold title */
-        widget = glade_xml_get_widget (glade_xml, "label_error_title");
-        title = gpk_error_enum_to_localised_text (code);
-        title_bold = g_strdup_printf ("<b>%s</b>", title);
-        gtk_label_set_label (GTK_LABEL (widget), title_bold);
-        g_free (title_bold);
-
-        widget = glade_xml_get_widget (glade_xml, "label_error_message");
-        gtk_label_set_label (GTK_LABEL (widget), gpk_error_enum_to_localised_message (code));
-
-        widget = glade_xml_get_widget (glade_xml, "label_error_details");
-        details_safe = g_markup_escape_text (details, -1);
-        gtk_label_set_label (GTK_LABEL (widget), details_safe);
-	g_free (details_safe);
-}
-
-static gboolean
-pk_window_delete_event_cb (GtkWidget    *widget,
-                           GdkEvent    *event,
-                           gpointer    data)
-{
-        gtk_main_quit ();
-
-        return FALSE;
-}
-
-static void
-pk_button_close_cb (GtkWidget *widget, gpointer data)
-{
-        gtk_main_quit ();
-}
+#include "gpk-client.h"
 
 /**
  * main:
@@ -199,17 +40,12 @@
 	GOptionContext *context;
 	gboolean ret;
 	gboolean verbose = FALSE;
-	gboolean program_version = FALSE;
 	GError *error;
-	GtkWidget *main_window;
-	GtkWidget *widget;
-	char *text;
+	GpkClient *gclient;
 
 	const GOptionEntry options[] = {
 		{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose,
 		  N_("Show extra debugging information"), NULL },
-		{ "version", '\0', 0, G_OPTION_ARG_NONE, &program_version,
-		  N_("Show the program version and exit"), NULL },
 		{ NULL}
 	};
 
@@ -222,96 +58,31 @@
 	if (! g_thread_supported ()) {
 		g_thread_init (NULL);
 	}
-	dbus_g_thread_init ();
 	g_type_init ();
 
 	g_set_application_name (_("PackageKit File Installer"));
-	context = g_option_context_new (NULL);
+	context = g_option_context_new ("gpk-install-file");
 	g_option_context_set_summary (context, _("PackageKit File Installer"));
 	g_option_context_add_main_entries (context, options, NULL);
 	g_option_context_parse (context, &argc, &argv, NULL);
 	g_option_context_free (context);
 
-	if (program_version) {
-		g_print (VERSION "\n");
-		return 0;
-	}
-
 	pk_debug_init (verbose);
 	gtk_init (&argc, &argv);
 
-        /* add application specific icons to search path */
-        gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
-                                           PK_DATA G_DIR_SEPARATOR_S "icons");
-
 	if (argc < 2) {
-		g_print ("%s\n", _("You need to specify a file to install"));
+		gpk_error_modal_dialog (_("Failed to install"), _("You need to specify a file to install"));
 		return 1;
 	}
 	if (argc > 2) {
-		g_print ("%s\n%s\n", _("You can only specify one file to install"),
-			 _("This will change in future versions of PackageKit"));
+		gpk_error_modal_dialog (_("Failed to install files"), _("You can only specify one file to install"));
 		return 1;
 	}
 
-	client = pk_client_new ();
-
-	g_signal_connect (client, "finished",
-			  G_CALLBACK (gpk_install_file_finished_cb), NULL);
-	g_signal_connect (client, "progress-changed",
-			  G_CALLBACK (gpk_install_file_progress_changed_cb), NULL);
-	g_signal_connect (client, "status-changed",
-			  G_CALLBACK (gpk_install_file_status_changed_cb), NULL);
-	g_signal_connect (client, "error-code",
-			  G_CALLBACK (gpk_install_file_error_code_cb), NULL);
-
-	glade_xml = glade_xml_new (PK_DATA "/gpk-install-file.glade", NULL, NULL);
-	main_window = glade_xml_get_widget (glade_xml, "window_updates");
-
-        /* Get the main window quit */
-	g_signal_connect (main_window, "delete_event",
-			  G_CALLBACK (pk_window_delete_event_cb), NULL);
-
-	widget = glade_xml_get_widget (glade_xml, "button_close");
-	g_signal_connect (widget, "clicked",
-			  G_CALLBACK (pk_button_close_cb), NULL);
-
-	widget = glade_xml_get_widget (glade_xml, "button_close2");
-	g_signal_connect (widget, "clicked",
-			  G_CALLBACK (pk_button_close_cb), NULL);
-
-	widget = glade_xml_get_widget (glade_xml, "button_close3");
-	g_signal_connect (widget, "clicked",
-			  G_CALLBACK (pk_button_close_cb), NULL);
-
-        /* set the label blank initially */
-        widget = glade_xml_get_widget (glade_xml, "progress_part_label");
-        gtk_label_set_label (GTK_LABEL (widget), "");
-
-	gpk_install_file_set_page (PAGE_PROGRESS);
-
 	error = NULL;
-	ret = pk_client_install_file (client, argv[1], &error);
-	if (ret == FALSE) {
-		gtk_widget_hide (main_window);
-
-		/* check if we got a permission denied */
-		if (g_str_has_prefix (error->message, "org.freedesktop.packagekit.localinstall")) {
-			gpk_error_modal_dialog (_("Failed to install"),
-					       _("You don't have the necessary privileges to install local packages"));
-		}
-		else {
-			text = g_markup_escape_text (error->message, -1);
-			gpk_error_modal_dialog (_("Failed to install"),
-					        text);
-			g_free (text);
-		}
-		g_error_free (error);
-	} else {
-		gtk_main ();
-	}
-
-	g_object_unref (client);
+	gclient = gpk_client_new ();
+	ret = gpk_client_install_file (gclient, argv[1]);
+	g_object_unref (gclient);
 
-	return 0;
+	return !ret;
 }

Modified: trunk/src/gpk-install-package.c
==============================================================================
--- trunk/src/gpk-install-package.c	(original)
+++ trunk/src/gpk-install-package.c	Thu Apr 10 19:30:55 2008
@@ -1,6 +1,6 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
  *
- * Copyright (C) 2007 Richard Hughes <richard hughsie com>
+ * Copyright (C) 2007-2008 Richard Hughes <richard hughsie com>
  *
  * Licensed under the GNU General Public License Version 2
  *
@@ -21,102 +21,15 @@
 
 #include "config.h"
 
-#include <errno.h>
-#include <string.h>
-#include <unistd.h>
-#include <stdlib.h>
 #include <glib.h>
 #include <glib/gi18n.h>
-#include <dbus/dbus-glib.h>
 #include <gtk/gtk.h>
 #include <locale.h>
 
 #include <pk-debug.h>
-#include <pk-client.h>
-#include <pk-common.h>
 
-#include "gpk-progress.h"
 #include "gpk-common.h"
-
-static GpkProgress *progress = NULL;
-static gchar *package = NULL;
-static GMainLoop *loop = NULL;
-
-/**
- * gpk_install_package_action_unref_cb:
- **/
-static void
-gpk_install_package_action_unref_cb (GpkProgress *progress, gpointer data)
-{
-	GMainLoop *loop = (GMainLoop *) data;
-	g_object_unref (progress);
-	g_main_loop_quit (loop);
-}
-
-/**
- * gpk_install_package_install_finished_cb:
- **/
-static void
-gpk_install_package_install_finished_cb (PkClient *client, PkExitEnum exit_code, guint runtime, gpointer data)
-{
-	g_object_unref (client);
-}
-
-/**
- * gpk_install_package_resolve_finished_cb:
- **/
-static void
-gpk_install_package_resolve_finished_cb (PkClient *client, PkExitEnum exit_code, guint runtime, gpointer data)
-{
-	gchar *tid;
-	gboolean ret;
-
-	pk_debug ("unref'ing %p", client);
-	g_object_unref (client);
-
-	/* did we resolve? */
-	if (pk_strzero (package)) {
-		gpk_error_modal_dialog (_("Failed to find package"),
-				       _("The package could not be found on the system"));
-		g_main_loop_quit (loop);
-		return;
-	}
-
-	/* create a new instance */
-	client = pk_client_new ();
-	g_signal_connect (client, "finished",
-			  G_CALLBACK (gpk_install_package_install_finished_cb), NULL);
-
-	pk_warning ("Installing '%s'", package);
-	ret = pk_client_install_package (client, package, NULL);
-	if (ret == FALSE) {
-		gpk_error_modal_dialog (_("Method not supported"),
-				       _("Installing packages is not supported"));
-		g_object_unref (client);
-		g_main_loop_quit (loop);
-		return;
-	}
-
-	tid = pk_client_get_tid (client);
-	/* create a new progress object */
-	progress = gpk_progress_new ();
-	g_signal_connect (progress, "action-unref",
-			  G_CALLBACK (gpk_install_package_action_unref_cb), loop);
-	gpk_progress_monitor_tid (progress, tid);
-	g_free (tid);
-}
-
-/**
- * gpk_install_package_resolve_package_cb:
- **/
-static void
-gpk_install_package_resolve_package_cb (PkClient *client, PkInfoEnum info, const gchar *package_id,
-					const gchar *summary, gboolean data)
-{
-	/* save */
-	pk_debug ("package '%s' resolved!", package_id);
-	package = g_strdup (package_id);
-}
+#include "gpk-client.h"
 
 /**
  * main:
@@ -124,18 +37,15 @@
 int
 main (int argc, char *argv[])
 {
-	PkClient *client;
 	GOptionContext *context;
-	const gchar *filter;
 	gboolean ret;
 	gboolean verbose = FALSE;
-	gboolean program_version = FALSE;
+	GError *error;
+	GpkClient *gclient;
 
 	const GOptionEntry options[] = {
 		{ "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose,
 		  N_("Show extra debugging information"), NULL },
-		{ "version", '\0', 0, G_OPTION_ARG_NONE, &program_version,
-		  N_("Show the program version and exit"), NULL },
 		{ NULL}
 	};
 
@@ -148,7 +58,6 @@
 	if (! g_thread_supported ()) {
 		g_thread_init (NULL);
 	}
-	dbus_g_thread_init ();
 	g_type_init ();
 
 	g_set_application_name (_("PackageKit Package Installer"));
@@ -158,47 +67,22 @@
 	g_option_context_parse (context, &argc, &argv, NULL);
 	g_option_context_free (context);
 
-	if (program_version) {
-		g_print (VERSION "\n");
-		return 0;
-	}
-
 	pk_debug_init (verbose);
 	gtk_init (&argc, &argv);
 
-        /* add application specific icons to search path */
-        gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
-                                           PK_DATA G_DIR_SEPARATOR_S "icons");
-
 	if (argc < 2) {
-		g_print ("%s\n", _("You need to specify a package to install"));
+		gpk_error_modal_dialog (_("Failed to install"), _("You need to specify a package to install"));
 		return 1;
 	}
 	if (argc > 2) {
-		g_print ("%s\n%s\n", _("You can only specify one package to install"),
-			 _("This will change in future versions of PackageKit"));
+		gpk_error_modal_dialog (_("Failed to install packages"), _("You can only specify one package name to install"));
 		return 1;
 	}
-	loop = g_main_loop_new (NULL, FALSE);
-
-	client = pk_client_new ();
-	g_signal_connect (client, "finished",
-			  G_CALLBACK (gpk_install_package_resolve_finished_cb), NULL);
-	g_signal_connect (client, "package",
-			  G_CALLBACK (gpk_install_package_resolve_package_cb), NULL);
-	filter = pk_filter_enum_to_text (PK_FILTER_ENUM_NOT_INSTALLED);
-	ret = pk_client_resolve (client, filter, argv[1], NULL);
-	if (ret == FALSE) {
-		gpk_error_modal_dialog (_("Method not supported"),
-				       _("Resolving names to packages is not supported"));
-	} else {
-		g_main_loop_run (loop);
-	}
 
-	g_free (package);
-	if (progress != NULL) {
-		g_object_unref (progress);
-	}
+	error = NULL;
+	gclient = gpk_client_new ();
+	ret = gpk_client_install_package (gclient, argv[1]);
+	g_object_unref (gclient);
 
-	return 0;
+	return !ret;
 }



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