Changeset 281:c9e392a0a8b1


Ignore:
Timestamp:
07/07/12 12:23:21 (10 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

Using icons instead of a drawing for the connection state

Files:
4 added
4 edited

Legend:

Unmodified
Added
Removed
  • makesdist.sh

    r20 r281  
    11#!/bin/sh
    22
     3make
    34python setup.py sdist
  • setup.py

    r230 r281  
    1717data_files.append((os.path.join("doc", "manual", "hu"),
    1818                   glob(os.path.join("doc", "manual", "en", "*.*"))))
    19 data_files.append(("", ["logo.png"]))
     19data_files.append(("", ["logo.png",
     20                        "conn_grey.png", "conn_red.png", "conn_green.png"]))
    2021if os.name=="nt":
    2122    import py2exe
  • src/mlx/gui/gui.py

    r276 r281  
    141141        mainVBox.pack_start(gtk.HSeparator(), False, False, 0)
    142142
    143         self._statusbar = Statusbar()
     143        self._statusbar = Statusbar(iconDirectory)
    144144        mainVBox.pack_start(self._statusbar, False, False, 0)
    145145
  • src/mlx/gui/statusbar.py

    r116 r281  
    1515class Statusbar(gtk.Frame, FlightStatusHandler):
    1616    """A status bar for the logger."""
    17     def __init__(self):
     17    def __init__(self, iconDirectory):
    1818        """Construct the status bar."""
    1919        gtk.Frame.__init__(self)
     
    3535        frameAlignment.add(statusBox)
    3636
     37        iconPath = os.path.join(iconDirectory, "conn_grey.png")
     38        self._connGreyIcon = pixbuf_new_from_file(iconPath)
     39
     40        iconPath = os.path.join(iconDirectory, "conn_red.png")
     41        self._connRedIcon = pixbuf_new_from_file(iconPath)
     42
     43        iconPath = os.path.join(iconDirectory, "conn_green.png")
     44        self._connGreenIcon = pixbuf_new_from_file(iconPath)
     45
    3746        self._connStateArea = gtk.DrawingArea()
    38         self._connStateArea.set_size_request(16, 16)
     47        self._connStateArea.set_size_request(18, 18)
    3948        self._connStateArea.set_tooltip_markup(xstr("statusbar_conn_tooltip"))
    4049
     
    105114
    106115    def _drawConnState(self, connStateArea, eventOrContext):
    107         """Draw the connection state."""       
    108         context = eventOrContext if pygobject else connStateArea.window.cairo_create()
    109 
     116        """Draw the connection state."""
    110117        if self._connecting:
    111118            if self._connected:
    112                 context.set_source_rgb(0.0, 1.0, 0.0)
     119                icon = self._connGreenIcon
    113120            else:
    114                 context.set_source_rgb(1.0, 0.0, 0.0)
     121                icon = self._connRedIcon
    115122        else:
    116             context.set_source_rgb(0.75, 0.75, 0.75)
     123            icon = self._connGreyIcon
    117124
    118         width = connStateArea.get_allocated_width() if pygobject \
    119                 else connStateArea.allocation.width
    120         height = connStateArea.get_allocated_height() if pygobject \
    121                  else connStateArea.allocation.height
    122         context.arc(width/2, height/2, width/2, 0, 2*math.pi)
    123 
    124         context.fill()
     125        if pygobject:
     126            gdk.cairo_set_source_pixbuf(eventOrContext, icon, 0, 0)
     127            eventOrContext.paint()
     128        else:
     129            gc = connStateArea.get_style().fg_gc[gtk.STATE_NORMAL]
     130            drawable = connStateArea.get_window()
     131            drawable.draw_pixbuf(gc, icon, 0, 0, 0, 0)
    125132
    126133    def _updateFlightStatus(self):
Note: See TracChangeset for help on using the changeset viewer.