Replace netbook mode with sizing proportional to screen size

svn: r18374
This commit is contained in:
Nick Hall 2011-10-26 18:28:32 +00:00
parent 594bc9257f
commit e1ae74e952
8 changed files with 18 additions and 17 deletions

View File

@ -402,15 +402,17 @@ class DisplayState(gen.utils.Callback):
# but this connection is still made!
# self.dbstate.connect('database-changed', self.db_changed)
self.__netbook_mode = False
if self.window.get_screen().get_width() <= 1024:
self.__netbook_mode = True
def screen_width(self):
"""
Return the width of the current screen.
"""
return self.window.get_screen().get_width()
def netbook_mode(self):
def screen_height(self):
"""
Return True if running on a small screen, else return False.
Return the height of the current screen.
"""
return self.__netbook_mode
return self.window.get_screen().get_height()
def clear_history(self):
"""

View File

@ -314,10 +314,9 @@ class GrampsBar(gtk.Notebook):
"""
Add a tab to the notebook for the given gramplet.
"""
if self.uistate.netbook_mode():
gramplet.set_size_request(225, 120)
else:
gramplet.set_size_request(285, 200)
width = int(self.uistate.screen_width() * 0.25)
height = int(self.uistate.screen_height() * 0.20)
gramplet.set_size_request(width, height)
page_num = self.append_page(gramplet)
return page_num

View File

@ -44,7 +44,7 @@ class Photo(gtk.EventBox):
"""
Displays an image and allows it to be viewed in an external image viewer.
"""
def __init__(self, netbook_mode=False):
def __init__(self, use_small_size=False):
gtk.EventBox.__init__(self)
self.full_path = None
self.photo = gtk.Image()
@ -54,7 +54,7 @@ class Photo(gtk.EventBox):
'viewer application.')
self.set_tooltip_text(tip)
self.__size = ThumbNails.SIZE_LARGE
if netbook_mode:
if use_small_size:
self.__size = ThumbNails.SIZE_NORMAL
def set_image(self, full_path, mime_type=None, rectangle=None):

View File

@ -39,7 +39,7 @@ class CalendarGramplet(Gramplet):
self.set_tooltip(_("Double-click a day for details"))
self.gui.calendar = gtk.Calendar()
self.gui.calendar.connect('day-selected-double-click', self.double_click)
if self.uistate.netbook_mode():
if self.uistate.screen_width() <= 1024:
self.gui.calendar.set_display_options(gtk.CALENDAR_SHOW_HEADING)
self.gui.get_container_widget().remove(self.gui.textview)
self.gui.get_container_widget().add_with_viewport(self.gui.calendar)

View File

@ -61,7 +61,7 @@ class Gallery(Gramplet):
full_path = Utils.media_path_full(self.dbstate.db, media.get_path())
mime_type = media.get_mime_type()
if mime_type and mime_type.startswith("image"):
photo = Photo(self.uistate.netbook_mode())
photo = Photo(self.uistate.screen_height() < 1000)
photo.set_image(full_path, mime_type, media_ref.get_rectangle())
self.image_list.append(photo)
self.top.pack_start(photo, expand=False, fill=False)

View File

@ -38,7 +38,7 @@ class MediaPreview(Gramplet):
Build the GUI interface.
"""
self.top = gtk.HBox()
self.photo = Photo(self.uistate.netbook_mode())
self.photo = Photo(self.uistate.screen_height() < 1000)
self.top.pack_start(self.photo, fill=True, expand=False, padding=5)
self.top.show_all()
return self.top

View File

@ -45,7 +45,7 @@ class PersonDetails(Gramplet):
"""
self.top = gtk.HBox()
vbox = gtk.VBox()
self.photo = Photo(self.uistate.netbook_mode())
self.photo = Photo(self.uistate.screen_height() < 1000)
self.photo.show()
self.name = gtk.Label()
self.name.set_alignment(0, 0)

View File

@ -42,7 +42,7 @@ class PlaceDetails(Gramplet):
"""
self.top = gtk.HBox()
vbox = gtk.VBox()
self.photo = Photo(self.uistate.netbook_mode())
self.photo = Photo(self.uistate.screen_height() < 1000)
self.title = gtk.Label()
self.title.set_alignment(0, 0)
self.title.modify_font(pango.FontDescription('sans bold 12'))