mediaviews.py 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. '''
  2. Goblinoid: Experience all of MediaGoblin on an Android Device
  3. Copyright (C) 2015 Dylan Jeffers
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. '''
  15. from __future__ import print_function
  16. from kivy.app import App
  17. from kivy.lang import Builder
  18. from kivy.properties import ObjectProperty, StringProperty
  19. from kivy.uix.screenmanager import Screen
  20. from kivy.uix.togglebutton import ToggleButton
  21. from libs.toast.kivytoast import toast
  22. Builder.load_file('mediaviews.kv')
  23. class UploadView(Screen):
  24. upload_image = StringProperty('')
  25. def init_screen(self):
  26. print(self.manager.media_model.upload_image)
  27. self.upload_image = self.manager.media_model.upload_image
  28. def upload_media(self):
  29. pump = App.get_running_app().pump_model.pump
  30. title = self.ids.title.text
  31. description = self.ids.desc.text
  32. to = self.ids.to.text
  33. cc = self.ids.cc.text
  34. material = [title, description, to, cc]
  35. print(material)
  36. image = pump.Image(display_name=title)
  37. image.content = description
  38. image.to = pump.Person(to)
  39. # for now will only do public
  40. image.cc = pump.Public
  41. image.from_file(self.upload_image)
  42. toast('media uploaded', True)
  43. self.manager.parent.parent.open_media_view('gallery', True)
  44. class GalleryView(Screen):
  45. media_model = ObjectProperty(None)
  46. gallery = ObjectProperty(None)
  47. image_grid = ObjectProperty(None)
  48. highlighted_image = StringProperty('')
  49. def __init__(self, **kwargs):
  50. super(GalleryView, self).__init__(**kwargs)
  51. self.image_grid.bind(minimum_height=self.image_grid.setter('height'))
  52. def init_screen(self):
  53. pass
  54. def on_enter(self):
  55. for image in self.manager.media_model.gallery_content:
  56. toggle = ToggleButton(
  57. group='gallery',
  58. background_normal=image,
  59. # still need to figure out on_pressed background
  60. )
  61. toggle.bind(on_release=self.highlighted_image)
  62. self.image_grid.add_widget(toggle)
  63. def highlighted_image(self, image):
  64. print (image.background_normal)
  65. self.highlighted_image = image.background_normal
  66. class CameraView(Screen):
  67. def init_screen(self):
  68. pass
  69. class CamcorderView(Screen):
  70. def init_screen(self):
  71. pass