From 15b9b66af1b92f19cac95ae8c56c78a2800b329d Mon Sep 17 00:00:00 2001 From: Aleksey Lim Date: Tue, 20 Jan 2009 19:11:48 +0000 Subject: ... --- diff --git a/Main.py b/Main.py index 9f9fb8d..dec42e5 100644 --- a/Main.py +++ b/Main.py @@ -162,7 +162,7 @@ class CartoonBuilder: def imgdown(self, widget, data=None): #pics = self.getpics(self.imgdir) - if len(pics[self.imgstartindex:]) > FRAME_COUNT: + if len(pics[self.imgstartindex:]) > FRAME_ROWS: self.imgstartindex += 2 self.loadimages() self.drawmain() @@ -206,7 +206,7 @@ class CartoonBuilder: pics = self.getpics(self.imgdir) count = 0 - for imgpath in pics[self.imgstartindex:self.imgstartindex+FRAME_COUNT]: + for imgpath in pics[self.imgstartindex:self.imgstartindex+FRAME_ROWS]: pixbuf = gtk.gdk.pixbuf_new_from_file(imgpath) scaled_buf = pixbuf.scale_simple(IMGWIDTH,IMGHEIGHT,gtk.gdk.INTERP_BILINEAR) self.posepixbufs.append(pixbuf) @@ -214,7 +214,7 @@ class CartoonBuilder: self.images[count].set_from_pixbuf(scaled_buf) count += 1 - for i in range(count,FRAME_COUNT): + for i in range(count,FRAME_ROWS): transpixbuf = self.gettranspixbuf(IMGWIDTH,IMGHEIGHT) imgpath = os.path.join(self.iconsdir,TRANSIMG) img = gtk.Image() @@ -313,20 +313,6 @@ class CartoonBuilder: - self.tableframeborder = gtk.EventBox() - self.tableframeborder.modify_bg(gtk.STATE_NORMAL,gtk.gdk.color_parse(YELLOW)) - self.tableframeborder.show() - self.tableframe = gtk.EventBox() - self.tableframe.modify_bg(gtk.STATE_NORMAL,gtk.gdk.color_parse(BACKGROUND)) - self.tableframe.show() - self.tableframe.set_border_width(5) - self.tableframeborder.add(self.tableframe) - - self.tfhbox = gtk.HBox() - self.tfhbox.show() - self.tfhbox.pack_start(self.tableframeborder,True,False,20) - self.tvbox.pack_start(self.tfhbox,False,False,0) - @@ -349,14 +335,17 @@ class CartoonBuilder: + from math import ceil - self.table = gtk.Table(10, columns=2, homogeneous=False) + rows = int(ceil(float(Theme.FRAME_COUNT)/Theme.FRAME_COLS)) + self.table = gtk.Table(rows, columns=Theme.FRAME_COLS, homogeneous=False) - - for i in range(100): - b = gtk.Button('foo') - b.show() - self.table.attach(b, 0, 1, i, i+1) + for y in range(rows): + for x in range(Theme.FRAME_COLS): + b = gtk.Button('foo') + b.set_size_request(Theme.THUMB_SIZE, Theme.THUMB_SIZE) + b.show() + self.table.attach(b, x, x+1, y, y+1) self.table.show() @@ -365,10 +354,32 @@ class CartoonBuilder: s.show() s.set_viewport(self.table) + s.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(BUTTON_FOREGROUND)) + s.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(BACKGROUND)) + + + yellow_frames = gtk.EventBox() + yellow_frames.modify_bg(gtk.STATE_NORMAL,gtk.gdk.color_parse(YELLOW)) + yellow_frames.show() + table_frames = gtk.EventBox() + table_frames.modify_bg(gtk.STATE_NORMAL,gtk.gdk.color_parse(BACKGROUND)) + table_frames.show() + table_frames.set_border_width(5) + table_frames.add(s) + yellow_frames.add(table_frames) + yellow_frames.props.border_width = 20 + self.tfhbox = gtk.HBox() + self.tfhbox.show() + #self.tfhbox.pack_start(yellow_frames,True,False,20) + #self.tvbox.pack_start(self.tfhbox,False,False,0) + + + + # screen @@ -474,7 +485,7 @@ class CartoonBuilder: cetralbox = gtk.HBox() cetralbox.show() cetralbox.pack_start(screen_alignment, True, True) - cetralbox.pack_start(s, False, False) + cetralbox.pack_start(yellow_frames, False, False) hdesktop = gtk.HBox() hdesktop.show() diff --git a/Theme.py b/Theme.py index 1b34f06..110ee63 100644 --- a/Theme.py +++ b/Theme.py @@ -20,13 +20,17 @@ from sugar.graphics import style TRANSIMG = '50x50blank-trans.png' +LOGO_WIDTH = 275 +FRAME_COUNT = 14 + DESKTOP_WIDTH = gtk.gdk.screen_width() DESKTOP_HEIGHT = gtk.gdk.screen_height() - style.LARGE_ICON_SIZE THUMB_SIZE = min(100, min(DESKTOP_WIDTH, DESKTOP_HEIGHT) / 8) -SCREEN_SIZE = min(DESKTOP_WIDTH - 275, DESKTOP_HEIGHT) - THUMB_SIZE*2 -FRAME_COUNT = DESKTOP_HEIGHT / THUMB_SIZE*2 +FRAME_COLS = max(1, ((DESKTOP_WIDTH-LOGO_WIDTH) - + min(DESKTOP_HEIGHT-THUMB_SIZE, DESKTOP_WIDTH-LOGO_WIDTH)) / THUMB_SIZE) + TAPE_COUNT = (DESKTOP_WIDTH - THUMB_SIZE) / THUMB_SIZE BORDER_LEFT = 1 diff --git a/Utils.py b/Utils.py index 958c2f5..a816bb9 100644 --- a/Utils.py +++ b/Utils.py @@ -206,6 +206,10 @@ class ScrolledBox(gtk.EventBox): self._right.connect('clicked', self._scroll_cb, 'right') box.pack_start(self._right, False, False, 0) + def modify_fg(self, state, bg): + gtk.EventBox.modify_fg(self, state, bg) + self._viewport.get_parent().modify_fg(state, bg) + def modify_bg(self, state, bg): gtk.EventBox.modify_bg(self, state, bg) self._viewport.get_parent().modify_bg(state, bg) -- cgit v0.9.1