Esempio n. 1
0
    def open_about_window(self, menuitem):
        gtk.about_dialog_set_url_hook(self._open_url, None)
        gtk.about_dialog_set_email_hook(self._open_email, None)
        about = gtk.AboutDialog()

        about.set_name("Rounder")
        about.set_version("0.0.1")
        about.set_copyright("Copyright © 2008 Devan Goodwin & James Bowes")
        about.set_comments("Poker for the GNOME Desktop")
        # XXX Put the full license in here
        about.set_license("GPLv2")
        about.set_website("http://dangerouslyinc.com")
        about.set_website_label("http://dangerouslyinc.com")
        about.set_authors(('Devan Goodwin <*****@*****.**>',
            'James Bowes <*****@*****.**>',
            'Kenny MacDermid <*****@*****.**>'))
        about.set_artists(('Anette Goodwin <*****@*****.**>',
            'James Bowes <*****@*****.**>'))
        about.set_logo(gtk.gdk.pixbuf_new_from_file(
            find_file_on_path(ROUNDER_LOGO_FILE)))

        about.set_icon_from_file(find_file_on_path(ROUNDER_ICON_FILE))

        about.connect('response', lambda x, y: about.destroy())
        about.show_all()
Esempio n. 2
0
    def __init__(self, host=None, port=None, username=None, password=None):

        logger.info("Starting rounder.")
        logger.debug("Initial connection Info:\n"
                     "   host = %s\n"
                     "   port = %s\n"
                     "   username = %s\n"
                     "   password = %s", host, port, username, password)
        register_message_classes()

        glade_file = 'rounder/ui/gtk/data/rounder.glade'
        self.glade_xml = gtk.glade.XML(find_file_on_path(glade_file))

        main_window = self.glade_xml.get_widget('main-window')
        main_window.set_icon_from_file(find_file_on_path(ROUNDER_ICON_FILE))
        self.table_list = self.glade_xml.get_widget('table-list')
        self.statusbar = self.glade_xml.get_widget('statusbar')
        self.connect_button = self.glade_xml.get_widget('connect-button')
        logo = self.glade_xml.get_widget("rounder-logo-image")
        logo.set_from_file(find_file_on_path(ROUNDER_LOGO_FILE))

        signals = {
            'on_connect_activate': self.show_connect_dialog,
            'on_close_activate': self.shutdown,
            'on_main_window_destroy': self.shutdown,
            'on_connect_button_clicked': self.show_connect_dialog,
            'on_quit_button_clicked': self.shutdown,
            'on_table_list_row_activated': self.open_table,
            'on_about1_activate': self.open_about_window,
        }
        self.glade_xml.signal_autoconnect(signals)

        treeselection = self.table_list.get_selection()
        treeselection.set_mode(gtk.SELECTION_SINGLE)

        # Reference to a network client.
        self.client = None

        self.connect_dialog = None # Set once connect dialog is open

        self.set_status("Connect to a server to begin playing.")

        main_window.show_all()

        # Autoconnect if given details, otherwise show connect dialog:
        if host != None and port != None and username != None and \
                password != None:
            connect(host, port, username, password, self)
        else:
            self.show_connect_dialog(None)
Esempio n. 3
0
    def __init__(self, app):

        logger.debug("Opening connect dialog.")

        self.app = app

        glade_file = 'rounder/ui/gtk/data/connect.glade'
        self.glade_xml = gtk.glade.XML(find_file_on_path(glade_file))
        self.connect_dialog = self.glade_xml.get_widget('connect-dialog')
        self.connect_dialog.set_icon_from_file(
                find_file_on_path(ROUNDER_ICON_FILE))

        signals = {
            'on_connect_button_clicked': self.connect,
        }
        self.glade_xml.signal_autoconnect(signals)
        self.connect_dialog.connect("delete_event", self.destroy)

        self.connect_dialog.show_all()
Esempio n. 4
0
 def render_dealer_button(self, dealer_seat_num):
     """ Draw the dealer button for the given seat. """
     logger.debug("Rendering dealer button for seat %s" % dealer_seat_num)
     coords = GUI_FIXED_COORDS["dealer-button-%s" % dealer_seat_num]
     if self.dealer_button == None:
         self.dealer_button = gtk.Image()
         self.dealer_button.set_from_file(find_file_on_path(DEALER_BUTTON_FILE))
         self.fixed_table.put(self.dealer_button, coords[0], coords[1])
         self.dealer_button.show()
     else:
         self.fixed_table.move(self.dealer_button, coords[0], coords[1])
Esempio n. 5
0
    def __init__(self, app, table_uplink):
        """
        Create a new table window with a reference to the parent application
        window, as well as the client table we can use to perform actions.
        """

        logger.debug("Opening table window.")

        self.app = app
        self.table_uplink = table_uplink
        # TODO: Chicken and egg problem here, probably easy to solve:
        self.table_uplink.ui = self

        glade_file = "rounder/ui/gtk/data/table.glade"
        self.glade_xml = gtk.glade.XML(find_file_on_path(glade_file))
        self.table_window = self.glade_xml.get_widget("table-window")
        table_title = "%s: %s %s" % (table_uplink.state.name, table_uplink.state.limit, "Texas Hold'em")
        self.table_window.set_title(table_title)
        self.table_window.set_icon_from_file(find_file_on_path(ROUNDER_ICON_FILE))

        # GtkFixed where we render almost everything:
        self.fixed_table = self.glade_xml.get_widget("fixed-table")
        # Display the table background image:
        img = gtk.Image()
        img.set_from_file(find_file_on_path(ROUNDER_TABLE_FILE))
        self.fixed_table.put(img, 0, 0)

        # Create the "Fold" button:
        self.fold_button = gtk.Button(label="Fold")
        self.fold_button.set_name("fold-button")

        # Create the "Call" button:
        self.call_button = gtk.Button(label="Call")
        self.call_button.set_name("call-button")

        # Create the "Raise" button:
        self.raise_button = gtk.Button(label="Raise")
        self.raise_button.set_name("raise-button")

        # Create the "Deal" button:
        self.deal_button = gtk.Button(label="Deal")
        self.deal_button.set_sensitive(False)
        self.deal_button.connect("clicked", self.handle_deal_button)

        # Place the action buttons on the background image:
        actions_vbox = gtk.VBox()
        actions_hbox = gtk.HBox(homogeneous=True)
        actions_hbox.add(self.fold_button)
        actions_hbox.add(self.call_button)
        actions_hbox.add(self.raise_button)
        actions_vbox.add(actions_hbox)
        actions_vbox.add(self.deal_button)
        coords = GUI_FIXED_COORDS["action-buttons"]
        actions_vbox.set_size_request(400, 150)
        self.fixed_table.put(actions_vbox, coords[0], coords[1])

        # Create the chat textview:
        sw = gtk.ScrolledWindow()
        sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS)
        sw.set_size_request(400, 125)
        sw.set_shadow_type(gtk.SHADOW_ETCHED_IN)
        self.chat_textview = gtk.TextView()
        self.chat_textview.set_name("chat-textview")
        self.chat_textview.set_wrap_mode(gtk.WRAP_WORD)
        self.chat_textview.set_editable(False)
        sw.add(self.chat_textview)

        # Create the chat entry:
        self.chat_entry = gtk.Entry()
        self.chat_entry.set_name("chat-entry")
        self.chat_entry.connect("activate", self.handle_chat_entry)

        chat_vbox = gtk.VBox()
        chat_vbox.add(sw)
        chat_vbox.add(self.chat_entry)
        coords = GUI_FIXED_COORDS["chat"]
        self.fixed_table.put(chat_vbox, coords[0], coords[1])

        # Signal handlers we reuse:
        self.__call_handler_id = None
        self.__raise_handler_id = None
        self.__fold_handler_id = None
        self.__disable_action_buttons()

        self.board_label = gtk.Label()
        self.board_label.set_use_markup(True)
        coords = GUI_FIXED_COORDS["board-label"]
        self.fixed_table.put(self.board_label, coords[0], coords[1])
        self.pot_label = gtk.Label("Pot:")
        coords = GUI_FIXED_COORDS["pot-label"]
        self.fixed_table.put(self.pot_label, coords[0], coords[1])

        # Setup and display the player seats:
        self.gui_seats = []
        for i in range(0, 10):
            seat = GuiSeat(self, i)
            self.gui_seats.append(seat)
        # Will be a pointer to our GuiSeat:
        self.my_seat = None
        self.my_seat_num = None

        # Map usernames to seats for dealing with incoming actions:
        self.__username_to_seat = {}
        for player_state in self.table_uplink.state.seats:
            if player_state == None:
                continue
            self.__username_to_seat[player_state.username] = self.gui_seats[player_state.seat]

        self.clean_actions = False

        self.dealer_button = None

        self.table_window.connect("delete_event", self.confirm_window_close)

        # Render the initial table state:
        self.__render_table_state(self.table_uplink.state)

        # Clear these when a hand ends:
        self.my_hole_cards = None

        # Enable to view where some gui elements will be drawn for all seats:
        # self.__draw_stuff()

        self.fixed_table.show_all()
        self.table_window.show_all()