[postr] Add combo box for choosing content type (#507243)
- From: Germán Poó Caamaño <gpoo src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [postr] Add combo box for choosing content type (#507243)
- Date: Tue, 10 Nov 2009 04:02:44 +0000 (UTC)
commit af066e250e68a6af043486637b9d375f709d5d50
Author: Karl Svensson <kalle maxflow org>
Date: Tue Nov 10 01:01:43 2009 -0300
Add combo box for choosing content type (#507243)
The flickr API includes a method for setting the content type
of an upload, with options including photo, screenshot and other.
This is exposed as an additional combo box in the privacy/safety
pane.
Signed-off-by: Germán Póo-Caamaño <gpoo gnome org>
src/ImageStore.py | 8 ++++--
src/flickrest.py | 4 ++-
src/postr.glade | 68 +++++++++++++++++++++++++++++++++++++---------------
src/postr.py | 28 ++++++++++++++++-----
4 files changed, 77 insertions(+), 31 deletions(-)
---
diff --git a/src/ImageStore.py b/src/ImageStore.py
index c74b9fe..2187d97 100644
--- a/src/ImageStore.py
+++ b/src/ImageStore.py
@@ -30,8 +30,9 @@ import gobject, gtk
COL_GROUPS, # Pyton list of group IDs
COL_PRIVACY, # Iterator containing privacy rules
COL_SAFETY, # Iterator containing safety
- COL_VISIBLE # If the image is searchable
- ) = range (0, 13)
+ COL_VISIBLE, # If the image is searchable
+ COL_CONTENT_TYPE, # Iterator containing content type
+ ) = range (0, 14)
class ImageStore (gtk.ListStore):
def __init__(self):
@@ -47,7 +48,8 @@ class ImageStore (gtk.ListStore):
object, # COL_GROUPS
gtk.TreeIter, # COL_PRIVACY
gtk.TreeIter, # COL_SAFETY
- gobject.TYPE_BOOLEAN) # COL_VISIBLE
+ gobject.TYPE_BOOLEAN, # COL_VISIBLE
+ gtk.TreeIter) # COL_CONTENT_TYPE
self._dirty = False
self.connect("row-changed", self._on_row_changed)
diff --git a/src/flickrest.py b/src/flickrest.py
index 8799aec..0448a9b 100644
--- a/src/flickrest.py
+++ b/src/flickrest.py
@@ -160,7 +160,7 @@ class Flickr:
def upload(self, filename=None, imageData=None,
title=None, desc=None, tags=None,
is_public=None, is_family=None, is_friend=None,
- safety=None, search_hidden=None):
+ safety=None, search_hidden=None, content_type=None):
# Sanity check the arguments
if filename is None and imageData is None:
raise ValueError("Need to pass either filename or imageData")
@@ -184,6 +184,8 @@ class Flickr:
kwargs['safety_level'] = safety
if search_hidden is not None:
kwargs['hidden'] = search_hidden and 2 or 1 # Why Flickr, why?
+ if content_type:
+ kwargs['content_type'] = content_type
self.__sign(kwargs)
self.logger.info("Upload args %s" % kwargs)
diff --git a/src/postr.glade b/src/postr.glade
index 98e240f..23b576e 100644
--- a/src/postr.glade
+++ b/src/postr.glade
@@ -472,7 +472,7 @@
<widget class="GtkTable" id="table2">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="n_rows">3</property>
+ <property name="n_rows">4</property>
<property name="n_columns">2</property>
<property name="column_spacing">4</property>
<property name="row_spacing">6</property>
@@ -480,6 +480,21 @@
<placeholder/>
</child>
<child>
+ <widget class="GtkLabel" id="content_type_label">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">_Content type:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">tags_entry</property>
+ </widget>
+ <packing>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
<widget class="Custom" id="privacy_combo">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
@@ -504,24 +519,6 @@
</packing>
</child>
<child>
- <widget class="GtkCheckButton" id="visible_check">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="label" translatable="yes">_Visible in search results</property>
- <property name="use_underline">True</property>
- <property name="response_id">0</property>
- <property name="active">True</property>
- <property name="draw_indicator">True</property>
- </widget>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
- </packing>
- </child>
- <child>
<widget class="GtkLabel" id="safety_label">
<property name="visible">True</property>
<property name="xalign">0</property>
@@ -549,13 +546,44 @@
<property name="bottom_attach">2</property>
</packing>
</child>
+ <child>
+ <widget class="GtkCheckButton" id="visible_check">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes">_Visible in search results</property>
+ <property name="use_underline">True</property>
+ <property name="response_id">0</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="Custom" id="content_type_combo">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="creation_function">ContentTypeCombo.ContentTypeCombo()</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ </packing>
+ </child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label5">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="label" translatable="yes">Privacy and Safety</property>
+ <property name="label" translatable="yes">Privacy, Safety and Type</property>
</widget>
<packing>
<property name="type">label_item</property>
diff --git a/src/postr.py b/src/postr.py
index e926cef..fbc4634 100644
--- a/src/postr.py
+++ b/src/postr.py
@@ -32,7 +32,7 @@ from AboutDialog import AboutDialog
from AuthenticationDialog import AuthenticationDialog
from ProgressDialog import ProgressDialog
from ErrorDialog import ErrorDialog
-import ImageStore, ImageList, StatusBar, PrivacyCombo, SafetyCombo, GroupSelector
+import ImageStore, ImageList, StatusBar, PrivacyCombo, SafetyCombo, GroupSelector, ContentTypeCombo
from flickrest import Flickr
import EXIF
@@ -95,6 +95,7 @@ class Postr(UniqueApp):
"privacy_combo",
"safety_combo",
"visible_check",
+ "content_type_combo",
"thumbview")
)
align_labels(glade, ("title_label", "desc_label",
@@ -146,6 +147,7 @@ class Postr(UniqueApp):
self.change_signals.append((self.privacy_combo, self.privacy_combo.connect('changed', self.on_field_changed, ImageStore.COL_PRIVACY)))
self.change_signals.append((self.safety_combo, self.safety_combo.connect('changed', self.on_field_changed, ImageStore.COL_SAFETY)))
self.change_signals.append((self.visible_check, self.visible_check.connect('toggled', self.on_field_changed, ImageStore.COL_VISIBLE)))
+ self.change_signals.append((self.content_type_combo, self.content_type_combo.connect('changed', self.on_field_changed, ImageStore.COL_CONTENT_TYPE)))
self.thumbnail_image.connect('size-allocate', self.update_thumbnail)
self.old_thumb_allocation = None
@@ -585,7 +587,8 @@ class Postr(UniqueApp):
# TODO: do something clever with multiple selections
self.current_it = self.model.get_iter(items[0])
(title, desc, tags, set_it, groups,
- privacy_it, safety_it, visible) = self.model.get(self.current_it,
+ privacy_it, safety_it, visible,
+ content_type_it) = self.model.get(self.current_it,
ImageStore.COL_TITLE,
ImageStore.COL_DESCRIPTION,
ImageStore.COL_TAGS,
@@ -593,7 +596,8 @@ class Postr(UniqueApp):
ImageStore.COL_GROUPS,
ImageStore.COL_PRIVACY,
ImageStore.COL_SAFETY,
- ImageStore.COL_VISIBLE)
+ ImageStore.COL_VISIBLE,
+ ImageStore.COL_CONTENT_TYPE)
enable_field(self.title_entry, title)
enable_field(self.desc_view, desc)
@@ -603,6 +607,7 @@ class Postr(UniqueApp):
enable_field(self.privacy_combo, privacy_it)
enable_field(self.safety_combo, safety_it)
enable_field(self.visible_check, visible)
+ enable_field(self.content_type_combo, content_type_it)
self.update_thumbnail(self.thumbnail_image)
else:
@@ -615,6 +620,7 @@ class Postr(UniqueApp):
disable_field(self.privacy_combo)
disable_field(self.safety_combo)
disable_field(self.visible_check)
+ disable_field(self.content_type_combo)
self.thumbnail_image.set_from_icon_name("postr", self.logo_icon_size)
[obj.handler_unblock(i) for obj,i in self.change_signals]
@@ -845,7 +851,7 @@ class Postr(UniqueApp):
(filename, thumb, pixbuf, title, desc,
tags, set_it, groups, privacy_it, safety_it,
- visible) = self.model.get(it,
+ visible, content_type_it) = self.model.get(it,
ImageStore.COL_FILENAME,
ImageStore.COL_THUMBNAIL,
ImageStore.COL_IMAGE,
@@ -856,7 +862,8 @@ class Postr(UniqueApp):
ImageStore.COL_GROUPS,
ImageStore.COL_PRIVACY,
ImageStore.COL_SAFETY,
- ImageStore.COL_VISIBLE)
+ ImageStore.COL_VISIBLE,
+ ImageStore.COL_CONTENT_TYPE)
# Lookup the set ID from the iterator
if set_it:
(set_id,) = self.set_combo.get_id_for_iter(set_it)
@@ -873,6 +880,11 @@ class Postr(UniqueApp):
else:
safety = None
+ if content_type_it:
+ content_type = self.content_type_combo.get_content_type_for_iter(content_type_it)
+ else:
+ content_type = None
+
self.update_progress(filename, title, thumb)
self.upload_index += 1
self.current_upload_it = it
@@ -881,7 +893,8 @@ class Postr(UniqueApp):
d = self.flickr.upload(filename=filename,
title=title, desc=desc,
tags=tags, search_hidden=not visible, safety=safety,
- is_public=is_public, is_family=is_family, is_friend=is_friend)
+ is_public=is_public, is_family=is_family, is_friend=is_friend,
+ content_type=content_type)
elif pixbuf:
# This isn't very nice, but might be the best way
data = []
@@ -889,7 +902,8 @@ class Postr(UniqueApp):
d = self.flickr.upload(imageData=''.join(data),
title=title, desc=desc, tags=tags,
search_hidden=not visible, safety=safety,
- is_public=is_public, is_family=is_family, is_friend=is_friend)
+ is_public=is_public, is_family=is_family, is_friend=is_friend,
+ content_type=content_type)
else:
print "No filename or pixbuf stored"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]