summaryrefslogtreecommitdiff
path: root/src/trg-cell-renderer-wanted.c
diff options
context:
space:
mode:
authorGravatar Alan Fitton <ajf@eth0.org.uk>2012-01-04 10:40:44 +0000
committerGravatar Alan Fitton <ajf@eth0.org.uk>2012-01-04 10:40:44 +0000
commita007678f344943d6ea86392723004a3a72320d9e (patch)
tree5d92b359914fc32906cd81c49dd86eacb0bd818d /src/trg-cell-renderer-wanted.c
parent950b833d5c7c63fddd32da986a83a9eb7215c9f4 (diff)
make the torrent add tree view and the files tree view fairly consistent, sharing code where possible. this allows changing priority and enabled using a directory. expand/collapse all buttons. the one taken from Transmission for torrent add dialog now has menus and the mime icons. may be bugs here, I know there's one with directories appearing as mixed and not updating upwards properly, but it's a start.
Diffstat (limited to 'src/trg-cell-renderer-wanted.c')
-rw-r--r--src/trg-cell-renderer-wanted.c117
1 files changed, 117 insertions, 0 deletions
diff --git a/src/trg-cell-renderer-wanted.c b/src/trg-cell-renderer-wanted.c
new file mode 100644
index 0000000..aeb4ab9
--- /dev/null
+++ b/src/trg-cell-renderer-wanted.c
@@ -0,0 +1,117 @@
+/*
+ * transmission-remote-gtk - A GTK RPC client to Transmission
+ * Copyright (C) 2011 Alan Fitton
+
+ * 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <stdint.h>
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+
+#include "trg-cell-renderer-wanted.h"
+#include "protocol-constants.h"
+#include "trg-files-model.h"
+#include "util.h"
+
+enum {
+ PROP_0,
+ PROP_WANTED_VALUE
+};
+
+G_DEFINE_TYPE(TrgCellRendererWanted, trg_cell_renderer_wanted,
+ GTK_TYPE_CELL_RENDERER_TOGGLE)
+#define TRG_CELL_RENDERER_WANTED_GET_PRIVATE(o) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((o), TRG_TYPE_CELL_RENDERER_WANTED, TrgCellRendererWantedPrivate))
+typedef struct _TrgCellRendererWantedPrivate
+ TrgCellRendererWantedPrivate;
+
+struct _TrgCellRendererWantedPrivate {
+ gint64 wanted_value;
+};
+
+static void
+trg_cell_renderer_wanted_get_property(GObject * object,
+ guint property_id, GValue * value,
+ GParamSpec * pspec)
+{
+ TrgCellRendererWantedPrivate *priv =
+ TRG_CELL_RENDERER_WANTED_GET_PRIVATE(object);
+ switch (property_id) {
+ case PROP_WANTED_VALUE:
+ g_value_set_int64(value, priv->wanted_value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+trg_cell_renderer_wanted_set_property(GObject * object,
+ guint property_id,
+ const GValue * value,
+ GParamSpec * pspec)
+{
+ TrgCellRendererWantedPrivate *priv =
+ TRG_CELL_RENDERER_WANTED_GET_PRIVATE(object);
+
+ if (property_id == PROP_WANTED_VALUE) {
+ priv->wanted_value = g_value_get_int(value);
+ g_object_set(G_OBJECT(object), "inconsistent", (priv->wanted_value == TR_PRI_MIXED),
+ "active", (priv->wanted_value == TRUE), NULL);
+ } else {
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
+ }
+}
+
+static void
+trg_cell_renderer_wanted_class_init(TrgCellRendererWantedClass * klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+ object_class->get_property = trg_cell_renderer_wanted_get_property;
+ object_class->set_property = trg_cell_renderer_wanted_set_property;
+
+ g_object_class_install_property(object_class,
+ PROP_WANTED_VALUE,
+ g_param_spec_int
+ ("wanted-value",
+ "Wanted Value",
+ "Wanted Value", TR_PRI_UNSET,
+ TR_PRI_HIGH, TR_PRI_NORMAL,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB));
+
+ g_type_class_add_private(klass,
+ sizeof(TrgCellRendererWantedPrivate));
+}
+
+static void
+trg_cell_renderer_wanted_init(TrgCellRendererWanted *
+ self)
+{
+ /*g_object_set(G_OBJECT(self), "xalign", (gfloat) 0.5, "yalign", (gfloat) 0.5,
+ NULL);*/
+}
+
+GtkCellRenderer *trg_cell_renderer_wanted_new(void)
+{
+ return
+ GTK_CELL_RENDERER(g_object_new
+ (TRG_TYPE_CELL_RENDERER_WANTED, NULL));
+}