gnome-packagekit r497 - trunk/src



Author: rhughes
Date: Tue Feb 24 22:21:04 2009
New Revision: 497
URL: http://svn.gnome.org/viewvc/gnome-packagekit?rev=497&view=rev

Log:
from git

Added:
   trunk/src/gpk-cell-renderer-restart.c
   trunk/src/gpk-cell-renderer-restart.h
   trunk/src/gpk-cell-renderer-size.c
   trunk/src/gpk-cell-renderer-size.h

Added: trunk/src/gpk-cell-renderer-restart.c
==============================================================================
--- (empty file)
+++ trunk/src/gpk-cell-renderer-restart.c	Tue Feb 24 22:21:04 2009
@@ -0,0 +1,126 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008-2009 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+#include <packagekit-glib/packagekit.h>
+
+#include "egg-debug.h"
+
+#include "gpk-enum.h"
+#include "gpk-cell-renderer-restart.h"
+
+enum {
+	PROP_0,
+	PROP_VALUE
+};
+
+G_DEFINE_TYPE (GpkCellRendererRestart, gpk_cell_renderer_restart, GTK_TYPE_CELL_RENDERER_PIXBUF)
+
+static gpointer parent_class = NULL;
+
+static void
+gpk_cell_renderer_restart_get_property (GObject *object, guint param_id,
+				        GValue *value, GParamSpec *pspec)
+{
+	GpkCellRendererRestart *cru = GPK_CELL_RENDERER_RESTART (object);
+
+	switch (param_id) {
+	case PROP_VALUE:
+		g_value_set_uint (value, cru->value);
+		break;
+	default:
+		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+		break;
+	}
+}
+
+static void
+gpk_cell_renderer_restart_set_property (GObject *object, guint param_id,
+				    const GValue *value, GParamSpec *pspec)
+{
+	GpkCellRendererRestart *cru = GPK_CELL_RENDERER_RESTART (object);
+
+	switch (param_id) {
+	case PROP_VALUE:
+		cru->value = g_value_get_uint (value);
+		cru->icon_name = gpk_restart_enum_to_icon_name (cru->value);
+		g_object_set (cru, "icon-name", cru->icon_name, NULL);
+		break;
+	default:
+		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+		break;
+	}
+}
+
+/**
+ * gpk_cell_renderer_finalize:
+ * @object: The object to finalize
+ **/
+static void
+gpk_cell_renderer_finalize (GObject *object)
+{
+	GpkCellRendererRestart *cru;
+	cru = GPK_CELL_RENDERER_RESTART (object);
+	G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static void
+gpk_cell_renderer_restart_class_init (GpkCellRendererRestartClass *class)
+{
+	GtkCellRendererClass *cell_renderer_class;
+	GObjectClass *object_class = G_OBJECT_CLASS (class);
+	object_class->finalize = gpk_cell_renderer_finalize;
+
+	parent_class = g_type_class_peek_parent (class);
+
+	cell_renderer_class = GTK_CELL_RENDERER_CLASS (class);
+
+	object_class->get_property = gpk_cell_renderer_restart_get_property;
+	object_class->set_property = gpk_cell_renderer_restart_set_property;
+
+	g_object_class_install_property (object_class, PROP_VALUE,
+					 g_param_spec_uint ("value", "VALUE",
+					 "VALUE", 0, G_MAXUINT, PK_RESTART_ENUM_NONE, G_PARAM_READWRITE));
+}
+
+/**
+ * gpk_cell_renderer_restart_init:
+ **/
+static void
+gpk_cell_renderer_restart_init (GpkCellRendererRestart *cru)
+{
+	cru->value = PK_RESTART_ENUM_NONE;
+	cru->icon_name = NULL;
+}
+
+/**
+ * gpk_cell_renderer_restart_new:
+ **/
+GtkCellRenderer *
+gpk_cell_renderer_restart_new (void)
+{
+	return g_object_new (GPK_TYPE_CELL_RENDERER_RESTART, NULL);
+}
+

Added: trunk/src/gpk-cell-renderer-restart.h
==============================================================================
--- (empty file)
+++ trunk/src/gpk-cell-renderer-restart.h	Tue Feb 24 22:21:04 2009
@@ -0,0 +1,59 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008-2009 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef GPK_CELL_RENDERER_RESTART_H
+#define GPK_CELL_RENDERER_RESTART_H
+
+#include <glib-object.h>
+#include <gtk/gtk.h>
+#include <packagekit-glib/packagekit.h>
+
+#define GPK_TYPE_CELL_RENDERER_RESTART			(gpk_cell_renderer_restart_get_type())
+#define GPK_CELL_RENDERER_RESTART(obj)			(G_TYPE_CHECK_INSTANCE_CAST((obj), GPK_TYPE_CELL_RENDERER_RESTART, GpkCellRendererRestart))
+#define GPK_CELL_RENDERER_RESTART_CLASS(cls)		(G_TYPE_CHECK_CLASS_CAST((cls), GPK_TYPE_CELL_RENDERER_RESTART, GpkCellRendererRestartClass))
+#define GPK_IS_CELL_RENDERER_RESTART(obj)		(G_TYPE_CHECK_INSTANCE_TYPE((obj), GPK_TYPE_CELL_RENDERER_RESTART))
+#define GPK_IS_CELL_RENDERER_RESTART_CLASS(cls)		(G_TYPE_CHECK_CLASS_TYPE((cls), GPK_TYPE_CELL_RENDERER_RESTART))
+#define GPK_CELL_RENDERER_RESTART_GET_CLASS(obj)	(G_TYPE_INSTANCE_GET_CLASS((obj), GPK_TYPE_CELL_RENDERER_RESTART, GpkCellRendererRestartClass))
+
+G_BEGIN_DECLS
+
+typedef struct _GpkCellRendererRestart		GpkCellRendererRestart;
+typedef struct _GpkCellRendererRestartClass	GpkCellRendererRestartClass;
+
+struct _GpkCellRendererRestart
+{
+	GtkCellRendererPixbuf	 parent;
+	PkRestartEnum		 value;
+	const gchar		*icon_name;
+};
+
+struct _GpkCellRendererRestartClass
+{
+	GtkCellRendererPixbufClass parent_class;
+};
+
+GType		 gpk_cell_renderer_restart_get_type	(void);
+GtkCellRenderer	*gpk_cell_renderer_restart_new		(void);
+
+G_END_DECLS
+
+#endif /* GPK_CELL_RENDERER_RESTART_H */
+

Added: trunk/src/gpk-cell-renderer-size.c
==============================================================================
--- (empty file)
+++ trunk/src/gpk-cell-renderer-size.c	Tue Feb 24 22:21:04 2009
@@ -0,0 +1,125 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008-2009 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+#include "egg-debug.h"
+
+#include "gpk-cell-renderer-size.h"
+
+enum {
+	PROP_0,
+	PROP_VALUE
+};
+
+G_DEFINE_TYPE (GpkCellRendererSize, gpk_cell_renderer_size, GTK_TYPE_CELL_RENDERER_TEXT)
+
+static gpointer parent_class = NULL;
+
+static void
+gpk_cell_renderer_size_get_property (GObject *object, guint param_id,
+				    GValue *value, GParamSpec *pspec)
+{
+	GpkCellRendererSize *cru = GPK_CELL_RENDERER_SIZE (object);
+
+	switch (param_id) {
+	case PROP_VALUE:
+		g_value_set_uint (value, cru->value);
+		break;
+	default:
+		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+		break;
+	}
+}
+
+static void
+gpk_cell_renderer_size_set_property (GObject *object, guint param_id,
+				    const GValue *value, GParamSpec *pspec)
+{
+	GpkCellRendererSize *cru = GPK_CELL_RENDERER_SIZE (object);
+
+	switch (param_id) {
+	case PROP_VALUE:
+		cru->value = g_value_get_uint (value);
+		g_free (cru->markup);
+		cru->markup = g_format_size_for_display (cru->value);
+		g_object_set (cru, "markup", cru->markup, NULL);
+		break;
+	default:
+		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+		break;
+	}
+}
+
+/**
+ * gpk_cell_renderer_finalize:
+ * @object: The object to finalize
+ **/
+static void
+gpk_cell_renderer_finalize (GObject *object)
+{
+	GpkCellRendererSize *cru;
+	cru = GPK_CELL_RENDERER_SIZE (object);
+	g_free (cru->markup);
+	G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static void
+gpk_cell_renderer_size_class_init (GpkCellRendererSizeClass *class)
+{
+	GtkCellRendererClass *cell_renderer_class;
+	GObjectClass *object_class = G_OBJECT_CLASS (class);
+	object_class->finalize = gpk_cell_renderer_finalize;
+
+	parent_class = g_type_class_peek_parent (class);
+
+	cell_renderer_class = GTK_CELL_RENDERER_CLASS (class);
+
+	object_class->get_property = gpk_cell_renderer_size_get_property;
+	object_class->set_property = gpk_cell_renderer_size_set_property;
+
+	g_object_class_install_property (object_class, PROP_VALUE,
+					 g_param_spec_uint ("value", "VALUE",
+					 "VALUE", 0, G_MAXUINT, 0, G_PARAM_READWRITE));
+}
+
+/**
+ * gpk_cell_renderer_size_init:
+ **/
+static void
+gpk_cell_renderer_size_init (GpkCellRendererSize *cru)
+{
+	cru->value = 0;
+	cru->markup = NULL;
+}
+
+/**
+ * gpk_cell_renderer_size_new:
+ **/
+GtkCellRenderer *
+gpk_cell_renderer_size_new (void)
+{
+	return g_object_new (GPK_TYPE_CELL_RENDERER_SIZE, NULL);
+}
+

Added: trunk/src/gpk-cell-renderer-size.h
==============================================================================
--- (empty file)
+++ trunk/src/gpk-cell-renderer-size.h	Tue Feb 24 22:21:04 2009
@@ -0,0 +1,58 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008-2009 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef GPK_CELL_RENDERER_SIZE_H
+#define GPK_CELL_RENDERER_SIZE_H
+
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+#define GPK_TYPE_CELL_RENDERER_SIZE		(gpk_cell_renderer_size_get_type())
+#define GPK_CELL_RENDERER_SIZE(obj)		(G_TYPE_CHECK_INSTANCE_CAST((obj), GPK_TYPE_CELL_RENDERER_SIZE, GpkCellRendererSize))
+#define GPK_CELL_RENDERER_SIZE_CLASS(cls)	(G_TYPE_CHECK_CLASS_CAST((cls), GPK_TYPE_CELL_RENDERER_SIZE, GpkCellRendererSizeClass))
+#define GPK_IS_CELL_RENDERER_SIZE(obj)		(G_TYPE_CHECK_INSTANCE_TYPE((obj), GPK_TYPE_CELL_RENDERER_SIZE))
+#define GPK_IS_CELL_RENDERER_SIZE_CLASS(cls)	(G_TYPE_CHECK_CLASS_TYPE((cls), GPK_TYPE_CELL_RENDERER_SIZE))
+#define GPK_CELL_RENDERER_SIZE_GET_CLASS(obj)	(G_TYPE_INSTANCE_GET_CLASS((obj), GPK_TYPE_CELL_RENDERER_SIZE, GpkCellRendererSizeClass))
+
+G_BEGIN_DECLS
+
+typedef struct _GpkCellRendererSize		GpkCellRendererSize;
+typedef struct _GpkCellRendererSizeClass	GpkCellRendererSizeClass;
+
+struct _GpkCellRendererSize
+{
+	GtkCellRendererText	 parent;
+	guint			 value;
+	gchar			*markup;
+};
+
+struct _GpkCellRendererSizeClass
+{
+	GtkCellRendererTextClass parent_class;
+};
+
+GType		 gpk_cell_renderer_size_get_type	(void);
+GtkCellRenderer	*gpk_cell_renderer_size_new		(void);
+
+G_END_DECLS
+
+#endif /* GPK_CELL_RENDERER_SIZE_H */
+



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