Back to index

system-config-printer  1.3.9+20120706
Public Member Functions | Public Attributes | Static Public Attributes
system-config-printer.GUI Class Reference
Inheritance diagram for system-config-printer.GUI:
Inheritance graph
[legend]
Collaboration diagram for system-config-printer.GUI:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def display_properties_dialog_for
def setup_toolbar_for_search_entry
def on_search_entry_search
def on_filter_criterion_changed
def dests_iconview_item_activated
def dests_iconview_selection_changed
def dests_iconview_popup_menu
def dests_iconview_button_press_event
def dests_iconview_key_press_event
def dests_iconview_drag_data_get
def on_server_settings_activate
def setConnected
def getServers
def populateList
def on_connect_servername_changed
def on_connect_activate
def update_connecting_pbar
def on_connectingdialog_delete
def on_cancel_connect_clicked
def connect
def reconnect
def on_btnCancelConnect_clicked
def on_btnRefresh_clicked
def set_system_or_user_default_printer
def set_default_printer
def on_quit_activate
def is_rename_possible
def rename_confirmed_by_user
def on_rename_activate
def printer_name_edit_start
def printer_name_editing
def printer_name_edited
def printer_name_edit_cancel
def rename_printer
def duplicate_printer
def on_duplicate_activate
def on_entDuplicateName_changed
def on_delete_activate
def delete_selected_printer_queues
def on_enabled_activate
def on_shared_activate
def advise_publish
def on_set_as_default_activate
def on_edit_activate
def on_create_class_activate
def on_view_print_queue_activate
def on_jobviewer_exit
def on_view_discovered_printers_activate
def on_troubleshoot_activate
def on_troubleshoot_quit
def on_about_activate
def on_problems_button_clicked
 Server settings.
def on_new_printer_activate
def on_new_class_activate
def on_new_printer_added
def on_start_service_clicked
 Service start-up.
def on_start_service_reply
def service_started_try
def service_started_retry
def checkDriverExists
def on_printer_modified
def printer_added_or_removed
 Monitor signal helpers.
def printer_added
 Monitor signal handlers.
def printer_event
def printer_removed
def cups_connection_error
def cups_connection_recovered
def getWidgets

Public Attributes

 language
 encoding
 printers
 connect_server
 connect_encrypt
 connect_user
 monitor
 populateList_timer
 servers
 server_is_publishing
 changed
 updating_widgets
 ui_manager
 btnNew
 menuItemNew
 printer_context_menu
 jobviewers
 newPrinterGUI
 cups
 status_context_id
 current_filter_text
 current_filter_mode
 servicestart
 mainlist
 propertiesDlg
 search_entry
 default_printer
 serverSettings
 connect_thread
 rename_sigids
 rename_entry_sigid
 troubleshooter

Static Public Attributes

dictionary printer_states
int DESTS_PAGE_DESTS = 0
int DESTS_PAGE_NO_PRINTERS = 1
int DESTS_PAGE_NO_SERVICE = 2

Detailed Description

Definition at line 129 of file system-config-printer.py.


Constructor & Destructor Documentation

def system-config-printer.GUI.__init__ (   self)

Definition at line 140 of file system-config-printer.py.

00140 
00141     def __init__(self):
00142 
00143         try:
00144             self.language = locale.getlocale(locale.LC_MESSAGES)
00145             self.encoding = locale.getlocale(locale.LC_CTYPE)
00146         except:
00147             nonfatalException()
00148             os.environ['LC_ALL'] = 'C'
00149             locale.setlocale (locale.LC_ALL, "")
00150             self.language = locale.getlocale(locale.LC_MESSAGES)
00151             self.encoding = locale.getlocale(locale.LC_CTYPE)
00152 
00153         self.printers = {}
00154         self.connect_server = cups.getServer()
00155         self.connect_encrypt = cups.getEncryption ()
00156         self.connect_user = cups.getUser()
00157         self.monitor = None
00158         self.populateList_timer = None
00159 
00160         self.servers = set((self.connect_server,))
00161         self.server_is_publishing = None # not known
00162         self.changed = set() # of options
00163 
00164         # WIDGETS
00165         # =======
00166         self.updating_widgets = False
00167         self.getWidgets({"PrintersWindow":
00168                              ["PrintersWindow",
00169                               "view_area_vbox",
00170                               "view_area_scrolledwindow",
00171                               "dests_notebook",
00172                               "dests_iconview",
00173                               "btnAddFirstPrinter",
00174                               "btnStartService",
00175                               "btnConnectNoService",
00176                               "statusbarMain",
00177                               "toolbar",
00178                               "server_menubar_item",
00179                               "printer_menubar_item",
00180                               "view_discovered_printers"],
00181                          "AboutDialog":
00182                              ["AboutDialog"],
00183                          "ConnectDialog":
00184                              ["ConnectDialog",
00185                               "chkEncrypted",
00186                               "cmbServername",
00187                               "btnConnect"],
00188                          "ConnectingDialog":
00189                              ["ConnectingDialog",
00190                               "lblConnecting",
00191                               "pbarConnecting"],
00192                          "NewPrinterName":
00193                              ["NewPrinterName",
00194                               "entDuplicateName",
00195                               "btnDuplicateOk"],
00196                          "InstallDialog":
00197                              ["InstallDialog",
00198                               "lblInstall"]},
00199 
00200                         domain=config.PACKAGE)
00201 
00202 
00203         # Since some dialogs are reused we can't let the delete-event's
00204         # default handler destroy them
00205         self.ConnectingDialog.connect ("delete-event",
00206                                        self.on_connectingdialog_delete)
00207 
00208         gtk.window_set_default_icon_name ('printer')
00209 
00210         # Printer Actions
00211         printer_manager_action_group = \
00212             gtk.ActionGroup ("PrinterManagerActionGroup")
00213         printer_manager_action_group.add_actions ([
00214                 ("connect-to-server", gtk.STOCK_CONNECT, _("_Connect..."),
00215                  None, _("Choose a different CUPS server"),
00216                  self.on_connect_activate),
00217                 ("server-settings", gtk.STOCK_PREFERENCES, _("_Settings..."),
00218                  None, _("Adjust server settings"),
00219                  self.on_server_settings_activate),
00220                 ("new-printer", gtk.STOCK_PRINT, _("_Printer"),
00221                  None, None, self.on_new_printer_activate),
00222                 ("new-class", gtk.STOCK_DND_MULTIPLE, _("_Class"),
00223                  None, None, self.on_new_class_activate),
00224                 ("quit", gtk.STOCK_QUIT, None, None, None,
00225                  self.on_quit_activate)])
00226         printer_manager_action_group.add_actions ([
00227                 ("rename-printer", None, _("_Rename"),
00228                  None, None, self.on_rename_activate),
00229                 ("duplicate-printer", gtk.STOCK_COPY, _("_Duplicate"),
00230                  "<Ctrl>d", None, self.on_duplicate_activate),
00231                 ("delete-printer", gtk.STOCK_DELETE, None,
00232                  None, None, self.on_delete_activate),
00233                 ("set-default-printer", gtk.STOCK_HOME, _("Set As De_fault"),
00234                  None, None, self.on_set_as_default_activate),
00235                 ("edit-printer", gtk.STOCK_PROPERTIES, None,
00236                  None, None, self.on_edit_activate),
00237                 ("create-class", gtk.STOCK_DND_MULTIPLE, _("_Create class"),
00238                  None, None, self.on_create_class_activate),
00239                 ("view-print-queue", gtk.STOCK_FIND, _("View Print _Queue"),
00240                  None, None, self.on_view_print_queue_activate),
00241                 ])
00242         printer_manager_action_group.add_toggle_actions ([
00243                 ("enable-printer", None, _("E_nabled"),
00244                  None, None, self.on_enabled_activate),
00245                 ("share-printer", None, _("_Shared"),
00246                  None, None, self.on_shared_activate),
00247                 ])
00248         printer_manager_action_group.add_radio_actions ([
00249                 ("filter-name", None, _("Name")),
00250                 ("filter-description", None, _("Description")),
00251                 ("filter-location", None, _("Location")),
00252                 ("filter-manufacturer", None, _("Manufacturer / Model")),
00253                 ], 1, self.on_filter_criterion_changed)
00254         for action in printer_manager_action_group.list_actions ():
00255             action.set_sensitive (False)
00256         for action in ["connect-to-server",
00257                        "quit",
00258                        "view-print-queue",
00259                        "filter-name",
00260                        "filter-description",
00261                        "filter-location",
00262                        "filter-manufacturer"]:
00263             act = printer_manager_action_group.get_action (action)
00264             act.set_sensitive (True)
00265 
00266         self.ui_manager = gtk.UIManager ()
00267         self.ui_manager.insert_action_group (printer_manager_action_group, -1)
00268         self.ui_manager.add_ui_from_string (
00269 """
00270 <ui>
00271  <accelerator action="connect-to-server"/>
00272  <accelerator action="server-settings"/>
00273  <accelerator action="new-printer"/>
00274  <accelerator action="new-class"/>
00275  <accelerator action="quit"/>
00276 
00277  <accelerator action="rename-printer"/>
00278  <accelerator action="duplicate-printer"/>
00279  <accelerator action="delete-printer"/>
00280  <accelerator action="set-default-printer"/>
00281  <accelerator action="edit-printer"/>
00282  <accelerator action="create-class"/>
00283  <accelerator action="view-print-queue"/>
00284  <accelerator action="enable-printer"/>
00285  <accelerator action="share-printer"/>
00286  <accelerator action="filter-name"/>
00287  <accelerator action="filter-description"/>
00288  <accelerator action="filter-location"/>
00289  <accelerator action="filter-manufacturer"/>
00290 </ui>
00291 """
00292 )
00293         self.ui_manager.ensure_update ()
00294         self.PrintersWindow.add_accel_group (self.ui_manager.get_accel_group ())
00295 
00296         # Toolbar
00297         # Glade-2 doesn't have support for MenuToolButton, so we do that here.
00298         self.btnNew = gtk.MenuToolButton (gtk.STOCK_ADD)
00299         self.btnNew.set_is_important (True)
00300         newmenu = gtk.Menu ()
00301         action = self.ui_manager.get_action ("/new-printer")
00302         newprinteritem = action.create_menu_item ()
00303         action = self.ui_manager.get_action ("/new-class")
00304         newclassitem = action.create_menu_item ()
00305         newprinteritem.show ()
00306         newclassitem.show ()
00307         newmenu.attach (newprinteritem, 0, 1, 0, 1)
00308         newmenu.attach (newclassitem, 0, 1, 1, 2)
00309         self.btnNew.set_menu (newmenu)
00310         self.btnNew.connect ('clicked', self.on_new_printer_activate)
00311         self.toolbar.add (self.btnNew)
00312         self.toolbar.add (gtk.SeparatorToolItem ())
00313         refreshbutton = gtk.ToolButton (gtk.STOCK_REFRESH)
00314         refreshbutton.connect ('clicked', self.on_btnRefresh_clicked)
00315         self.toolbar.add (refreshbutton)
00316         self.toolbar.show_all ()
00317 
00318         server_context_menu = gtk.Menu ()
00319         for action_name in ["connect-to-server",
00320                             "server-settings",
00321                             None,
00322                             "new",
00323                             None,
00324                             "quit"]:
00325             if action_name == "new":
00326                 item = gtk.MenuItem (_("_New"))
00327                 item.set_sensitive (True)
00328                 self.menuItemNew = item
00329             elif not action_name:
00330                 item = gtk.SeparatorMenuItem ()
00331             else:
00332                 action = printer_manager_action_group.get_action (action_name)
00333                 item = action.create_menu_item ()
00334             item.show ()
00335             server_context_menu.append (item)
00336         self.server_menubar_item.set_submenu (server_context_menu)
00337 
00338         new_menu = gtk.Menu ()
00339         for action_name in ["new-printer",
00340                             "new-class"]:
00341             action = printer_manager_action_group.get_action (action_name)
00342             item = action.create_menu_item ()
00343             item.show ()
00344             new_menu.append (item)
00345         self.menuItemNew.set_submenu (new_menu)
00346 
00347         self.printer_context_menu = gtk.Menu ()
00348         for action_name in ["edit-printer",
00349                             "duplicate-printer",
00350                             "rename-printer",
00351                             "delete-printer",
00352                             None,
00353                             "enable-printer",
00354                             "share-printer",
00355                             "create-class",
00356                             "set-default-printer",
00357                             None,
00358                             "view-print-queue"]:
00359             if not action_name:
00360                 item = gtk.SeparatorMenuItem ()
00361             else:
00362                 action = printer_manager_action_group.get_action (action_name)
00363                 item = action.create_menu_item ()
00364             item.show ()
00365             self.printer_context_menu.append (item)
00366         self.printer_menubar_item.set_submenu (self.printer_context_menu)
00367 
00368         self.jobviewers = [] # to keep track of jobviewer windows
00369 
00370         # New Printer Dialog
00371         self.newPrinterGUI = np = newprinter.NewPrinterGUI()
00372         np.connect ("printer-added", self.on_new_printer_added)
00373         np.connect ("printer-modified", self.on_printer_modified)
00374 
00375         # Set up "About" dialog
00376         self.AboutDialog.set_program_name(config.PACKAGE)
00377         self.AboutDialog.set_version(config.VERSION)
00378         self.AboutDialog.set_icon_name('printer')
00379 
00380         try:
00381             slip.gtk.label_set_autowrap(self.PrintersWindow)
00382         except: # no slip.gtk module
00383             gtk_label_autowrap.set_autowrap(self.PrintersWindow)
00384 
00385         try:
00386             self.cups = authconn.Connection(self.PrintersWindow)
00387         except RuntimeError:
00388             self.cups = None
00389 
00390         self.status_context_id = self.statusbarMain.get_context_id(
00391             "Connection")
00392 
00393         # Setup search
00394         self.setup_toolbar_for_search_entry ()
00395         self.current_filter_text = ""
00396         self.current_filter_mode = "filter-name"
00397 
00398         # Search entry drop down menu
00399         menu = gtk.Menu ()
00400         for action_name in ["filter-name",
00401                             "filter-description",
00402                             "filter-location",
00403                             "filter-manufacturer"]:
00404             action = printer_manager_action_group.get_action (action_name)
00405             item = action.create_menu_item ()
00406             menu.append (item)
00407         menu.show_all ()
00408         self.search_entry.set_drop_down_menu (menu)
00409 
00410         self.servicestart = ServiceStart ()
00411 
00412         # Setup icon view
00413         self.mainlist = gtk.ListStore(gobject.TYPE_PYOBJECT, # Object
00414                                       gtk.gdk.Pixbuf,        # Pixbuf
00415                                       gobject.TYPE_STRING,   # Name
00416                                       gobject.TYPE_STRING)   # Tooltip
00417 
00418         self.dests_iconview.set_model(self.mainlist)
00419         self.dests_iconview.set_column_spacing (30)
00420         self.dests_iconview.set_row_spacing (20)
00421         self.dests_iconview.set_pixbuf_column (1)
00422         self.dests_iconview.set_text_column (2)
00423         self.dests_iconview.set_tooltip_column (3)
00424         self.dests_iconview.set_has_tooltip(True)
00425         self.dests_iconview.connect ('key-press-event',
00426                                      self.dests_iconview_key_press_event)
00427         self.dests_iconview.connect ('item-activated',
00428                                      self.dests_iconview_item_activated)
00429         self.dests_iconview.connect ('selection-changed',
00430                                      self.dests_iconview_selection_changed)
00431         self.dests_iconview.connect ('button-press-event',
00432                                      self.dests_iconview_button_press_event)
00433         self.dests_iconview.connect ('popup-menu',
00434                                      self.dests_iconview_popup_menu)
00435         self.dests_iconview_selection_changed (self.dests_iconview)
00436         self.dests_iconview.enable_model_drag_source (gtk.gdk.BUTTON1_MASK,
00437                                                       # should use a variable
00438                                                       # instead of 0
00439                                                       [("queue", 0, 0)],
00440                                                       gtk.gdk.ACTION_COPY)
00441         self.dests_iconview.connect ("drag-data-get",
00442                                      self.dests_iconview_drag_data_get)
00443         self.btnStartService.connect ('clicked', self.on_start_service_clicked)
00444         self.btnConnectNoService.connect ('clicked', self.on_connect_activate)
00445         self.btnAddFirstPrinter.connect ('clicked',
00446                                          self.on_new_printer_activate)
00447 
00448         # Printer Properties dialog
00449         self.propertiesDlg = printerproperties.PrinterPropertiesDialog ()
00450 
00451         try:
00452             self.populateList()
00453         except cups.HTTPError, (s,):
00454             self.cups = None
00455             self.populateList()
00456             show_HTTP_Error(s, self.PrintersWindow)
00457 
00458         self.setConnected()
00459 
00460         if len (self.printers) > 3:
00461             self.PrintersWindow.set_default_size (550, 400)
00462 
00463         self.PrintersWindow.show()


Member Function Documentation

def system-config-printer.GUI.advise_publish (   self)

Definition at line 1624 of file system-config-printer.py.

01624 
01625     def advise_publish(self):
01626         if not self.server_is_publishing:
01627             show_info_dialog (_("Publish Shared Printers"),
01628                               _("Shared printers are not available "
01629                                 "to other people unless the "
01630                                 "'Publish shared printers' option is "
01631                                 "enabled in the server settings."),
01632                               parent=self.PrintersWindow)

Here is the caller graph for this function:

def system-config-printer.GUI.checkDriverExists (   self,
  parent,
  name,
  ppd = None 
)
Check that the driver for an existing queue actually
exists, and prompt to install the appropriate package
if not.

ppd: cups.PPD object, if already created

Definition at line 1833 of file system-config-printer.py.

01833 
01834     def checkDriverExists(self, parent, name, ppd=None):
01835         """Check that the driver for an existing queue actually
01836         exists, and prompt to install the appropriate package
01837         if not.
01838 
01839         ppd: cups.PPD object, if already created"""
01840 
01841         # Is this queue on the local machine?  If not, we can't check
01842         # anything at all.
01843         server = cups.getServer ()
01844         if not (self.connect_server == 'localhost' or
01845                 self.connect_server[0] == '/'):
01846             return
01847 
01848         # Fetch the PPD if we haven't already.
01849         if not ppd:
01850             try:
01851                 filename = self.cups.getPPD(name)
01852             except cups.IPPError, (e, msg):
01853                 if e == cups.IPP_NOT_FOUND:
01854                     # This is a raw queue.  Nothing to check.
01855                     return
01856                 else:
01857                     self.show_IPP_Error(e, msg)
01858                     return
01859 
01860             ppd = cups.PPD(filename)
01861             os.unlink(filename)
01862 
01863         (pkgs, exes) = cupshelpers.missingPackagesAndExecutables (ppd)
01864         if len (pkgs) > 0 or len (exes) > 0:
01865             # We didn't find a necessary executable.  Complain.
01866             can_install = False
01867             if len (pkgs) > 0:
01868                 try:
01869                     pk = installpackage.PackageKit ()
01870                     can_install = True
01871                 except:
01872                     pass
01873 
01874             if can_install and len (pkgs) > 0:
01875                 pkg = pkgs[0]
01876                 install_text = ('<span weight="bold" size="larger">' +
01877                                 _('Install driver') + '</span>\n\n' +
01878                                 _("Printer '%s' requires the %s package but "
01879                                   "it is not currently installed.") %
01880                                 (name, pkg))
01881                 dialog = self.InstallDialog
01882                 self.lblInstall.set_markup(install_text)
01883                 dialog.set_transient_for (parent)
01884                 response = dialog.run ()
01885                 dialog.hide ()
01886                 if response == gtk.RESPONSE_OK:
01887                     # Install the package.
01888                     try:
01889                         xid = parent.window.xid
01890                         pk.InstallPackageName (xid, 0, pkg)
01891                     except:
01892                         pass # should handle error
01893             else:
01894                 show_error_dialog (_('Missing driver'),
01895                                    _("Printer '%s' requires the '%s' program "
01896                                      "but it is not currently installed.  "
01897                                      "Please install it before using this "
01898                                      "printer.") % (name, (exes + pkgs)[0]),
01899                                    parent)

Here is the call graph for this function:

Here is the caller graph for this function:

def system-config-printer.GUI.connect (   self,
  parent = None 
)
Open a connection to a new server. Is executed in a separate thread!

Definition at line 1065 of file system-config-printer.py.

01065 
01066     def connect(self, parent=None):
01067         """
01068         Open a connection to a new server. Is executed in a separate thread!
01069         """
01070         cups.setUser(self.connect_user)
01071         if self.connect_server[0] == '/':
01072             # UNIX domain socket.  This may potentially fail if the server
01073             # settings have been changed and cupsd has written out a
01074             # configuration that does not include a Listen line for the
01075             # UNIX domain socket.  To handle this special case, try to
01076             # connect once and fall back to "localhost" on failure.
01077             try:
01078                 connection = cups.Connection (host=self.connect_server,
01079                                               encryption=self.connect_encrypt)
01080 
01081                 # Worked fine.  Disconnect, and we'll connect for real
01082                 # shortly.
01083                 del connection
01084             except RuntimeError:
01085                 # When we connect, avoid the domain socket.
01086                 cups.setServer ("localhost")
01087             except:
01088                 nonfatalException ()
01089 
01090         try:
01091             connection = authconn.Connection(parent,
01092                                              host=self.connect_server,
01093                                              encryption=self.connect_encrypt)
01094         except RuntimeError, s:
01095             if self.connect_thread != thread.get_ident(): return
01096             gtk.gdk.threads_enter()
01097             self.ConnectingDialog.hide()
01098             self.cups = None
01099             self.setConnected()
01100             self.populateList()
01101             show_IPP_Error(None, s, parent)
01102             gtk.gdk.threads_leave()
01103             return
01104         except cups.IPPError, (e, s):
01105             if self.connect_thread != thread.get_ident(): return
01106             gtk.gdk.threads_enter()
01107             self.ConnectingDialog.hide()
01108             self.cups = None
01109             self.setConnected()
01110             self.populateList()
01111             show_IPP_Error(e, s, parent)
01112             gtk.gdk.threads_leave()
01113             return
01114         except:
01115             nonfatalException ()
01116 
01117         if self.connect_thread != thread.get_ident(): return
01118         gtk.gdk.threads_enter()
01119 
01120         try:
01121             self.ConnectingDialog.hide()
01122             self.cups = connection
01123             self.setConnected()
01124             self.populateList()
01125        except cups.HTTPError, (s,):
01126             self.cups = None
01127             self.setConnected()
01128             self.populateList()
01129             show_HTTP_Error(s, parent)
01130         except:
01131             nonfatalException ()
01132 
01133         gtk.gdk.threads_leave()

Here is the call graph for this function:

Here is the caller graph for this function:

def system-config-printer.GUI.cups_connection_error (   self,
  mon 
)

Definition at line 1958 of file system-config-printer.py.

01958 
01959     def cups_connection_error (self, mon):
01960         self.cups = None
01961         self.setConnected ()
01962         self.populateList (prompt_allowed=False)

Here is the call graph for this function:

Here is the caller graph for this function:

def system-config-printer.GUI.cups_connection_recovered (   self,
  mon 
)

Definition at line 1963 of file system-config-printer.py.

01963 
01964     def cups_connection_recovered (self, mon):
01965         debugprint ("Trying to recover connection")
01966         gobject.idle_add (self.service_started_try)

Here is the call graph for this function:

Here is the caller graph for this function:

def system-config-printer.GUI.delete_selected_printer_queues (   self)

Definition at line 1505 of file system-config-printer.py.

01505 
01506     def delete_selected_printer_queues (self):
01507         paths = self.dests_iconview.get_selected_items ()
01508         model = self.dests_iconview.get_model ()
01509         n = len (paths)
01510         if n == 1:
01511             iter = model.get_iter (paths[0])
01512             object = model.get_value (iter, 0)
01513             name = model.get_value (iter, 2)
01514             if object.is_class:
01515                 message_format = _("Really delete class '%s'?") % name
01516             else:
01517                 message_format = _("Really delete printer '%s'?") % name
01518         else:
01519             message_format = _("Really delete selected destinations?")
01520 
01521         dialog = gtk.MessageDialog(self.PrintersWindow,
01522                                    gtk.DIALOG_DESTROY_WITH_PARENT |
01523                                    gtk.DIALOG_MODAL,
01524                                    gtk.MESSAGE_WARNING,
01525                                    gtk.BUTTONS_NONE,
01526                                    message_format)
01527         dialog.add_buttons (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
01528                             gtk.STOCK_DELETE, gtk.RESPONSE_ACCEPT)
01529         dialog.set_default_response (gtk.RESPONSE_REJECT)
01530         result = dialog.run()
01531         dialog.destroy()
01532 
01533         if result != gtk.RESPONSE_ACCEPT:
01534             return
01535 
01536         try:
01537             for path in paths:
01538                 iter = model.get_iter (path)
01539                 name = model.get_value (iter, 2)
01540                 self.cups._begin_operation (_("deleting printer %s") % name)
01541                 name = unicode (name)
01542                 self.cups.deletePrinter (name)
01543                 self.cups._end_operation ()
01544         except cups.IPPError, (e, msg):
01545             self.cups._end_operation ()
01546             show_IPP_Error(e, msg, self.PrintersWindow)
01547 
01548         self.monitor.update ()

Here is the call graph for this function:

Here is the caller graph for this function:

def system-config-printer.GUI.dests_iconview_button_press_event (   self,
  iconview,
  event 
)

Definition at line 593 of file system-config-printer.py.

00593 
00594     def dests_iconview_button_press_event (self, iconview, event):
00595         if event.button > 1:
00596             click_path = iconview.get_path_at_pos (int (event.x),
00597                                                    int (event.y))
00598             paths = iconview.get_selected_items ()
00599             if click_path == None:
00600                 iconview.unselect_all ()
00601             elif click_path not in paths:
00602                 iconview.unselect_all ()
00603                 iconview.select_path (click_path)
00604                 cells = iconview.get_cells ()
00605                 for cell in cells:
00606                     if type (cell) == gtk.CellRendererText:
00607                         break
00608                 iconview.set_cursor (click_path, cell)
00609             self.printer_context_menu.popup (None, None, None,
00610                                              event.button, event.time)
00611         return False

def system-config-printer.GUI.dests_iconview_drag_data_get (   self,
  iconview,
  context,
  selection_data,
  info,
  timestamp 
)

Definition at line 632 of file system-config-printer.py.

00632 
00633                                       selection_data, info, timestamp):
00634         if info == 0: # FIXME: should use an "enum" here
00635             model = iconview.get_model ()
00636             paths = iconview.get_selected_items ()
00637             selected_printer_names = ""
00638             for path in paths:
00639                 selected_printer_names += \
00640                     model.get_value (model.get_iter (path), 2) + "\n"
00641 
00642             if len (selected_printer_names) > 0:
00643                 selection_data.set ("queue", 8, selected_printer_names)
00644         else:
00645             nonfatalException ()

Here is the caller graph for this function:

def system-config-printer.GUI.dests_iconview_item_activated (   self,
  iconview,
  path 
)

Definition at line 503 of file system-config-printer.py.

00503 
00504     def dests_iconview_item_activated (self, iconview, path):
00505         model = iconview.get_model ()
00506         iter = model.get_iter (path)
00507         name = unicode (model.get_value (iter, 2))
00508         object = model.get_value (iter, 0)
00509 
00510         try:
00511             self.propertiesDlg.show (name, host=self.connect_server,
00512                                      encryption=self.connect_encrypt,
00513                                      parent=self.PrintersWindow)
00514         except cups.IPPError, (e, m):
00515             show_IPP_Error (e, m, self.PrintersWindow)
00516             if e == cups.IPP_SERVICE_UNAVAILABLE:
00517                 self.cups = None
00518                 self.setConnected ()
00519                 self.populateList ()
00520             return
00521         except RuntimeError:
00522             # Perhaps cupsGetPPD2 failed for a browsed printer.
00523 
00524             # Check that we're still connected.
00525             self.monitor.update ()
00526             return

Here is the call graph for this function:

Here is the caller graph for this function:

def system-config-printer.GUI.dests_iconview_key_press_event (   self,
  iconview,
  event 
)

Definition at line 612 of file system-config-printer.py.

00612 
00613     def dests_iconview_key_press_event (self, iconview, event):
00614         modifiers = gtk.accelerator_get_default_mod_mask ()
00615 
00616         if ((event.keyval == gtk.keysyms.BackSpace or
00617              event.keyval == gtk.keysyms.Delete or
00618              event.keyval == gtk.keysyms.KP_Delete) and
00619             ((event.state & modifiers) == 0)):
00620 
00621             self.ui_manager.get_action ("/delete-printer").activate ()
00622             return True
00623 
00624         if ((event.keyval == gtk.keysyms.F2) and
00625             ((event.state & modifiers) == 0)):
00626 
00627             self.ui_manager.get_action ("/rename-printer").activate ()
00628             return True
00629 
00630         return False

Here is the call graph for this function:

def system-config-printer.GUI.dests_iconview_popup_menu (   self,
  iconview 
)

Definition at line 590 of file system-config-printer.py.

00590 
00591     def dests_iconview_popup_menu (self, iconview):
00592         self.printer_context_menu.popup (None, None, None, 0, 0L)

def system-config-printer.GUI.dests_iconview_selection_changed (   self,
  iconview 
)

Definition at line 527 of file system-config-printer.py.

00527 
00528     def dests_iconview_selection_changed (self, iconview):
00529         self.updating_widgets = True
00530         paths = iconview.get_selected_items ()
00531         any_disabled = False
00532         any_enabled = False
00533         any_discovered = False
00534         any_shared = False
00535         any_unshared = False
00536         model = iconview.get_model ()
00537         for path in paths:
00538             iter = model.get_iter (path)
00539             object = model.get_value (iter, 0)
00540             name = unicode (model.get_value (iter, 2))
00541             if object.discovered:
00542                 any_discovered = True
00543             if object.enabled:
00544                 any_enabled = True
00545             else:
00546                 any_disabled = True
00547             if object.is_shared:
00548                 any_shared = True
00549             else:
00550                 any_unshared = True
00551 
00552         n = len (paths)
00553         self.ui_manager.get_action ("/edit-printer").set_sensitive (n == 1)
00554 
00555         self.ui_manager.get_action ("/duplicate-printer").set_sensitive (n == 1)
00556 
00557         self.ui_manager.get_action ("/rename-printer").set_sensitive (
00558             n == 1 and not any_discovered)
00559 
00560         userdef = userdefault.UserDefaultPrinter ().get ()
00561         if (n != 1 or
00562             (userdef == None and self.default_printer == name)):
00563             set_default_sensitivity = False
00564         else:
00565             set_default_sensitivity = True
00566 
00567         self.ui_manager.get_action ("/set-default-printer").set_sensitive (
00568             set_default_sensitivity)
00569 
00570         action = self.ui_manager.get_action ("/enable-printer")
00571         action.set_sensitive (n > 0 and not any_discovered)
00572         for widget in action.get_proxies ():
00573             if isinstance (widget, gtk.CheckMenuItem):
00574                 widget.set_inconsistent (n > 1 and any_enabled and any_disabled)
00575         action.set_active (any_discovered or not any_disabled)
00576 
00577         action = self.ui_manager.get_action ("/share-printer")
00578         action.set_sensitive (n > 0 and not any_discovered)
00579         for widget in action.get_proxies ():
00580             if isinstance (widget, gtk.CheckMenuItem):
00581                 widget.set_inconsistent (n > 1 and any_shared and any_unshared)
00582         action.set_active (any_discovered or not any_unshared)
00583 
00584         self.ui_manager.get_action ("/delete-printer").set_sensitive (
00585             n > 0 and not any_discovered)
00586 
00587         self.ui_manager.get_action ("/create-class").set_sensitive (n > 1)
00588 
00589         self.updating_widgets = False

Here is the caller graph for this function:

def system-config-printer.GUI.display_properties_dialog_for (   self,
  queue 
)

Definition at line 464 of file system-config-printer.py.

00464 
00465     def display_properties_dialog_for (self, queue):
00466         model = self.dests_iconview.get_model ()
00467         iter = model.get_iter_first ()
00468         while iter != None:
00469             name = unicode (model.get_value (iter, 2))
00470             if name == queue:
00471                 path = model.get_path (iter)
00472                 self.dests_iconview.scroll_to_path (path, True, 0.5, 0.5)
00473                 self.dests_iconview.set_cursor (path)
00474                 self.dests_iconview.item_activated (path)
00475                 break
00476             iter = model.iter_next (iter)
00477 
00478         if iter == None:
00479             raise RuntimeError

Here is the caller graph for this function:

def system-config-printer.GUI.duplicate_printer (   self,
  new_name 
)

Definition at line 1448 of file system-config-printer.py.

01448 
01449     def duplicate_printer (self, new_name):
01450         self.propertiesDlg.printer.name = new_name
01451         self.propertiesDlg.printer.class_members = [] # for classes make sure all members
01452                                         # will get added
01453 
01454         ret = self.propertiesDlg.save_printer(self.propertiesDlg.printer,
01455                                               saveall=True,
01456                                               parent=self.PrintersWindow)
01457         return ret

Here is the caller graph for this function:

def system-config-printer.GUI.getServers (   self)

Definition at line 698 of file system-config-printer.py.

00698 
00699     def getServers(self):
00700         self.servers.discard(None)
00701         known_servers = list(self.servers)
00702         known_servers.sort()
00703         return known_servers

Here is the caller graph for this function:

def gui.GtkGUI.getWidgets (   self,
  widgets,
  domain = None 
) [inherited]

Definition at line 32 of file gui.py.

00032 
00033     def getWidgets(self, widgets, domain=None):
00034         ui_dir = os.environ.get ("SYSTEM_CONFIG_PRINTER_UI",
00035                                  os.path.join (pkgdata, "ui"))
00036         for xmlfile, names in widgets.iteritems ():
00037             bld = gtk.Builder ()
00038 
00039             if domain:
00040                 bld.set_translation_domain (domain)
00041 
00042             bld.add_from_file (os.path.join (ui_dir, xmlfile + ".ui"))
00043             for name in names:
00044                 widget = bld.get_object(name)
00045                 if widget is None:
00046                     raise ValueError, "Widget '%s' not found" % name
00047                 setattr(self, name, widget)
00048 
00049             try:
00050                 win = widget.get_top_level()
00051             except AttributeError:
00052                 win = None
00053             
00054             if win != None:
00055                 gtk.Window.set_focus_on_map(widget.get_top_level (),
00056                                             self.focus_on_map)
00057                 widget.show()
00058 
00059             bld.connect_signals (self)
def system-config-printer.GUI.is_rename_possible (   self,
  name 
)

Definition at line 1237 of file system-config-printer.py.

01237 
01238     def is_rename_possible (self, name):
01239         jobs = self.printers[name].jobsQueued (limit=1)
01240         if len (jobs) > 0:
01241             show_error_dialog (_("Cannot Rename"),
01242                                _("There are queued jobs."),
01243                                parent=self.PrintersWindow)
01244             return False
01245 
01246         return True

Here is the caller graph for this function:

def system-config-printer.GUI.on_about_activate (   self,
  widget 
)

Definition at line 1712 of file system-config-printer.py.

01712 
01713     def on_about_activate(self, widget):
01714         self.AboutDialog.set_transient_for (self.PrintersWindow)
01715         self.AboutDialog.run()
01716         self.AboutDialog.hide()

def system-config-printer.GUI.on_btnCancelConnect_clicked (   self,
  widget 
)
Close Connect dialog

Definition at line 1152 of file system-config-printer.py.

01152 
01153     def on_btnCancelConnect_clicked(self, widget):
01154         """Close Connect dialog"""
01155         self.ConnectWindow.hide()

def system-config-printer.GUI.on_btnRefresh_clicked (   self,
  button 
)

Definition at line 1158 of file system-config-printer.py.

01158 
01159     def on_btnRefresh_clicked(self, button):
01160         if self.cups == None:
01161             try:
01162                 self.cups = authconn.Connection(self.PrintersWindow)
01163             except RuntimeError:
01164                 pass
01165 
01166             self.setConnected()
01167 
01168         self.populateList()

Here is the call graph for this function:

Here is the caller graph for this function:

def system-config-printer.GUI.on_cancel_connect_clicked (   self,
  widget 
)
Stop connection to new server
(Doesn't really stop but sets flag for the connecting thread to
ignore the connection)

Definition at line 1056 of file system-config-printer.py.

01056 
01057     def on_cancel_connect_clicked(self, widget):
01058         """
01059         Stop connection to new server
01060         (Doesn't really stop but sets flag for the connecting thread to
01061         ignore the connection)
01062         """
01063         self.connect_thread = None
01064         self.ConnectingDialog.hide()

Here is the caller graph for this function:

def system-config-printer.GUI.on_connect_activate (   self,
  widget 
)

Definition at line 991 of file system-config-printer.py.

00991 
00992     def on_connect_activate(self, widget):
00993         # Use browsed queues to build up a list of known IPP servers
00994         servers = self.getServers()
00995         current_server = (self.propertiesDlg.printer and
00996                           self.propertiesDlg.printer.getServer()) \
00997                           or cups.getServer()
00998 
00999         store = gtk.ListStore (gobject.TYPE_STRING)
01000         self.cmbServername.set_model(store)
01001         self.cmbServername.set_text_column (0)
01002         for server in servers:
01003             self.cmbServername.append_text(server)
01004         self.cmbServername.show()
01005 
01006         self.cmbServername.child.set_text (current_server)
01007         self.chkEncrypted.set_active (cups.getEncryption() ==
01008                                       cups.HTTP_ENCRYPT_ALWAYS)
01009 
01010         self.cmbServername.child.set_activates_default (True)
01011         self.cmbServername.grab_focus ()
01012         self.ConnectDialog.set_transient_for (self.PrintersWindow)
01013         response = self.ConnectDialog.run()
01014 
01015         self.ConnectDialog.hide()
01016 
01017         if response != gtk.RESPONSE_OK:
01018             return
01019 
01020         if self.chkEncrypted.get_active():
01021             cups.setEncryption(cups.HTTP_ENCRYPT_ALWAYS)
01022         else:
01023             cups.setEncryption(cups.HTTP_ENCRYPT_IF_REQUESTED)
01024         self.connect_encrypt = cups.getEncryption ()
01025 
01026         servername = self.cmbServername.child.get_text()
01027 
01028         self.lblConnecting.set_markup(_("<i>Opening connection to %s</i>") %
01029                                       servername)
01030         self.ConnectingDialog.set_transient_for(self.PrintersWindow)
01031         self.ConnectingDialog.show()
01032         gobject.timeout_add (40, self.update_connecting_pbar)
01033         self.connect_server = servername
01034         # We need to set the connecting user in this thread as well.
01035         cups.setServer(self.connect_server)
01036         cups.setUser('')
01037         self.connect_user = cups.getUser()
01038         # Now start a new thread for connection.
01039         self.connect_thread = thread.start_new_thread(self.connect,
01040                                                       (self.PrintersWindow,))

Here is the call graph for this function:

def system-config-printer.GUI.on_connect_servername_changed (   self,
  widget 
)

Definition at line 988 of file system-config-printer.py.

00988 
00989     def on_connect_servername_changed(self, widget):
00990         self.btnConnect.set_sensitive (len (widget.get_active_text ()) > 0)

def system-config-printer.GUI.on_connectingdialog_delete (   self,
  widget,
  event 
)

Definition at line 1052 of file system-config-printer.py.

01052 
01053     def on_connectingdialog_delete (self, widget, event):
01054         self.on_cancel_connect_clicked (widget)
01055         return True

Here is the call graph for this function:

def system-config-printer.GUI.on_create_class_activate (   self,
  UNUSED 
)

Definition at line 1646 of file system-config-printer.py.

01646 
01647     def on_create_class_activate (self, UNUSED):
01648         paths = self.dests_iconview.get_selected_items ()
01649         class_members = []
01650         model = self.dests_iconview.get_model ()
01651         for path in paths:
01652             iter = model.get_iter (path)
01653             name = unicode (model.get_value (iter, 2), 'utf-8')
01654             class_members.append (name)
01655         if not self.newPrinterGUI.init ("class",
01656                                         host=self.connect_server,
01657                                         encryption=self.connect_encrypt,
01658                                         parent=self.PrintersWindow):
01659             self.monitor.update ()
01660             return
01661 
01662         out_model = self.newPrinterGUI.tvNCNotMembers.get_model ()
01663         in_model = self.newPrinterGUI.tvNCMembers.get_model ()
01664         iter = out_model.get_iter_first ()
01665         while iter != None:
01666             next = out_model.iter_next (iter)
01667             data = out_model.get (iter, 0)
01668             if data[0] in class_members:
01669                 in_model.append (data)
01670                 out_model.remove (iter)
01671             iter = next

def system-config-printer.GUI.on_delete_activate (   self,
  UNUSED 
)

Definition at line 1502 of file system-config-printer.py.

01502 
01503     def on_delete_activate(self, UNUSED):
01504         self.delete_selected_printer_queues ()

Here is the call graph for this function:

def system-config-printer.GUI.on_duplicate_activate (   self,
  UNUSED 
)

Definition at line 1458 of file system-config-printer.py.

01458 
01459     def on_duplicate_activate(self, UNUSED):
01460         iconview = self.dests_iconview
01461         paths = iconview.get_selected_items ()
01462         model = self.dests_iconview.get_model ()
01463         iter = model.get_iter (paths[0])
01464         name = unicode (model.get_value (iter, 2))
01465         self.entDuplicateName.set_text(name)
01466         self.NewPrinterName.set_transient_for (self.PrintersWindow)
01467         result = self.NewPrinterName.run()
01468         self.NewPrinterName.hide()
01469 
01470         if result == gtk.RESPONSE_CANCEL:
01471             return
01472 
01473         try:
01474             self.propertiesDlg.load (name,
01475                                      host=self.connect_server,
01476                                      encryption=self.connect_encrypt,
01477                                      parent=self.PrintersWindow)
01478         except RuntimeError:
01479             # Perhaps cupsGetPPD2 failed for a browsed printer
01480             pass
01481         except cups.IPPError, (e, m):
01482             show_IPP_Error (e, m, self.PrintersWindow)
01483             self.populateList ()
01484             return
01485 
01486         self.duplicate_printer (self.entDuplicateName.get_text ())
01487         self.monitor.update ()

Here is the call graph for this function:

def system-config-printer.GUI.on_edit_activate (   self,
  UNUSED 
)

Definition at line 1642 of file system-config-printer.py.

01642 
01643     def on_edit_activate (self, UNUSED):
01644         paths = self.dests_iconview.get_selected_items ()
01645         self.dests_iconview_item_activated (self.dests_iconview, paths[0])

Here is the call graph for this function:

def system-config-printer.GUI.on_enabled_activate (   self,
  toggle_action 
)

Definition at line 1550 of file system-config-printer.py.

01550 
01551     def on_enabled_activate(self, toggle_action):
01552         if self.updating_widgets:
01553             return
01554         enable = toggle_action.get_active ()
01555         iconview = self.dests_iconview
01556         paths = iconview.get_selected_items ()
01557         model = iconview.get_model ()
01558         for path in paths:
01559             iter = model.get_iter (path)
01560             printer = model.get_value (iter, 0)
01561             name = unicode (model.get_value (iter, 2), 'utf-8')
01562             self.cups._begin_operation (_("modifying printer %s") % name)
01563             try:
01564                 printer.setEnabled (enable)
01565             except cups.IPPError, (e, m):
01566                 errordialogs.show_IPP_Error (e, m, self.PrintersWindow)
01567                 # Give up on this operation.
01568                 self.cups._end_operation ()
01569                 break
01570 
01571             self.cups._end_operation ()
01572 
01573         self.monitor.update ()

def system-config-printer.GUI.on_entDuplicateName_changed (   self,
  widget 
)

Definition at line 1488 of file system-config-printer.py.

01488 
01489     def on_entDuplicateName_changed(self, widget):
01490         # restrict
01491         text = unicode (widget.get_text())
01492         new_text = text
01493         new_text = new_text.replace("/", "")
01494         new_text = new_text.replace("#", "")
01495         new_text = new_text.replace(" ", "")
01496         if text!=new_text:
01497             widget.set_text(new_text)
01498         self.btnDuplicateOk.set_sensitive(
01499             newprinter.checkNPName(self.printers, new_text))

Here is the call graph for this function:

def system-config-printer.GUI.on_filter_criterion_changed (   self,
  UNUSED,
  selected_action 
)

Definition at line 499 of file system-config-printer.py.

00499 
00500     def on_filter_criterion_changed (self, UNUSED, selected_action):
00501         self.current_filter_mode = selected_action.get_name ()
00502         self.populateList ()

Here is the call graph for this function:

def system-config-printer.GUI.on_jobviewer_exit (   self,
  viewer 
)

Definition at line 1692 of file system-config-printer.py.

01692 
01693     def on_jobviewer_exit (self, viewer):
01694         try:
01695             i = self.jobviewers.index (viewer)
01696             del self.jobviewers[i]
01697         except ValueError:
01698             # This shouldn't happen, but does (bug #757520).
01699             debugprint ("Jobviewer exited but not in list:\n"
01700                         "%s\n%s" % (repr (viewer), repr (self.jobviewers)))

Here is the caller graph for this function:

def system-config-printer.GUI.on_new_class_activate (   self,
  widget 
)

Definition at line 1742 of file system-config-printer.py.

01742 
01743     def on_new_class_activate(self, widget):
01744         if not self.newPrinterGUI.init("class",
01745                                        host=self.connect_server,
01746                                        encryption=self.connect_encrypt,
01747                                        parent=self.PrintersWindow):
01748             self.monitor.update ()

def system-config-printer.GUI.on_new_printer_activate (   self,
  widget 
)

Definition at line 1732 of file system-config-printer.py.

01732 
01733     def on_new_printer_activate(self, widget):
01734         busy (self.PrintersWindow)
01735         if not self.newPrinterGUI.init("printer",
01736                                        host=self.connect_server,
01737                                        encryption=self.connect_encrypt,
01738                                        parent=self.PrintersWindow):
01739             self.monitor.update ()
01740         ready (self.PrintersWindow)

def system-config-printer.GUI.on_new_printer_added (   self,
  obj,
  name 
)

Definition at line 1749 of file system-config-printer.py.

01749 
01750     def on_new_printer_added (self, obj, name):
01751         debugprint ("New printer added: %s" % name)
01752         self.populateList ()
01753 
01754         if not self.printers.has_key (name):
01755             # At this stage the printer has disappeared even though we
01756             # only added it moments ago.
01757             debugprint ("New printer disappeared")
01758             return
01759 
01760         # Now select it.
01761         model = self.dests_iconview.get_model ()
01762         iter = model.get_iter_first ()
01763         while iter != None:
01764             queue = unicode (model.get_value (iter, 2))
01765             if queue == name:
01766                 path = model.get_path (iter)
01767                 self.dests_iconview.scroll_to_path (path, True, 0.5, 0.5)
01768                 self.dests_iconview.unselect_all ()
01769                 self.dests_iconview.set_cursor (path)
01770                 self.dests_iconview.select_path (path)
01771                 break
01772 
01773             iter = model.iter_next (iter)
01774 
01775         # Finally, suggest printing a test page.
01776         self.propertiesDlg.load (name)
01777         if self.propertiesDlg.ppd:
01778             try:
01779                 self.checkDriverExists (self.PrintersWindow, name,
01780                                         ppd=self.propertiesDlg.ppd)
01781             except:
01782                 nonfatalException()
01783 
01784             q = gtk.MessageDialog (self.PrintersWindow,
01785                                    gtk.DIALOG_DESTROY_WITH_PARENT |
01786                                    gtk.DIALOG_MODAL,
01787                                    gtk.MESSAGE_QUESTION,
01788                                    gtk.BUTTONS_NONE,
01789                                    _("Would you like to print a test page?"))
01790             q.add_buttons (gtk.STOCK_CANCEL, gtk.RESPONSE_NO,
01791                            _("Print Test Page"), gtk.RESPONSE_YES)
01792             response = q.run ()
01793             q.destroy ()
01794             if response == gtk.RESPONSE_YES:
01795                 self.propertiesDlg.dialog.hide ()
01796 
01797                 properties_shown = False
01798                 try:
01799                     # Load the printer details but hide the properties dialog.
01800                     self.display_properties_dialog_for (name)
01801                     properties_shown = True
01802                 except RuntimeError:
01803                     pass
01804 
01805                 if properties_shown:
01806                     # Click the test button.
01807                     self.propertiesDlg.btnPrintTestPage.clicked ()

Here is the call graph for this function:

def system-config-printer.GUI.on_printer_modified (   self,
  obj,
  name,
  ppd_has_changed 
)

Definition at line 1900 of file system-config-printer.py.

01900 
01901     def on_printer_modified (self, obj, name, ppd_has_changed):
01902         debugprint ("Printer modified by user: %s" % name)
01903         # Load information about the printer,
01904         # e.g. self.propertiesDlg.server_side_options and self.propertiesDlg.ppd
01905         # (both used below).
01906         self.propertiesDlg.load (name)
01907 
01908         if self.propertiesDlg.ppd:
01909             try:
01910                 self.checkDriverExists (self.propertiesDlg.dialog,
01911                                         name, ppd=self.propertiesDlg.ppd)
01912             except:
01913                 nonfatalException()
01914 
01915             # Also check to see whether the media option has become
01916             # invalid.  This can happen if it had previously been
01917             # explicitly set to a page size that is not offered with
01918             # the new PPD (see bug #441836).
01919             try:
01920                 option = self.propertiesDlg.server_side_options['media']
01921                 if option.get_current_value () == None:
01922                     debugprint ("Invalid media option: resetting")
01923                     option.reset ()
01924                     self.propertiesDlg.changed.add (option)
01925                     self.propertiesDlg.save_printer (self.printer)
01926             except KeyError:
01927                 pass
01928             except:
01929                 nonfatalException()

Here is the call graph for this function:

def system-config-printer.GUI.on_problems_button_clicked (   self,
  serversettings 
)

Server settings.

The "Problems?" clickable label

Definition at line 1722 of file system-config-printer.py.

01722 
01723     def on_problems_button_clicked (self, serversettings):
01724         if not self.__dict__.has_key ('troubleshooter'):
01725             self.troubleshooter = troubleshoot.run (self.on_troubleshoot_quit,
01726                                                     parent=serversettings.get_dialog ())

Here is the call graph for this function:

def system-config-printer.GUI.on_quit_activate (   self,
  widget,
  event = None 
)

Definition at line 1223 of file system-config-printer.py.

01223 
01224     def on_quit_activate(self, widget, event=None):
01225         if self.monitor:
01226             self.monitor.cleanup ()
01227 
01228         while len (self.jobviewers) > 0:
01229             # this will call on_jobviewer_exit
01230             self.jobviewers[0].on_delete_event ()
01231         del self.mainlist
01232         del self.printers
01233         self.propertiesDlg.destroy ()
01234         self.newPrinterGUI.destroy ()
01235         gtk.main_quit()

def system-config-printer.GUI.on_rename_activate (   self,
  UNUSED 
)

Definition at line 1270 of file system-config-printer.py.

01270 
01271     def on_rename_activate(self, UNUSED):
01272         tuple = self.dests_iconview.get_cursor ()
01273         if tuple == None:
01274             return
01275 
01276         (path, cell) = tuple
01277         if type (cell) != gtk.CellRendererText:
01278             cells = self.dests_iconview.get_cells ()
01279             for cell in cells:
01280                 if type (cell) == gtk.CellRendererText:
01281                     break
01282             if type (cell) != gtk.CellRendererText:
01283                 return
01284 
01285         model = self.dests_iconview.get_model ()
01286         iter = model.get_iter (path)
01287         name = unicode (model.get_value (iter, 2))
01288         if not self.is_rename_possible (name):
01289             return
01290         if not self.rename_confirmed_by_user (name):
01291             return
01292         cell.set_property ('editable', True)
01293         ids = []
01294         ids.append (cell.connect ('editing-started',
01295                                  self.printer_name_edit_start))
01296         ids.append (cell.connect ('edited', self.printer_name_edited))
01297         ids.append (cell.connect ('editing-canceled',
01298                                  self.printer_name_edit_cancel))
01299         self.rename_sigids = ids
01300         self.rename_entry_sigid = None
01301         self.dests_iconview.set_cursor (path, cell, start_editing=True)

Here is the call graph for this function:

def system-config-printer.GUI.on_search_entry_search (   self,
  UNUSED,
  text 
)

Definition at line 495 of file system-config-printer.py.

00495 
00496     def on_search_entry_search (self, UNUSED, text):
00497         self.current_filter_text = text
00498         self.populateList ()

Here is the call graph for this function:

def system-config-printer.GUI.on_server_settings_activate (   self,
  menuitem 
)

Definition at line 646 of file system-config-printer.py.

00646 
00647     def on_server_settings_activate (self, menuitem):
00648         try:
00649             self.serverSettings = ServerSettings (host=self.connect_server,
00650                                                   encryption=self.connect_encrypt,
00651                                                   parent=self.PrintersWindow)
00652             self.serverSettings.connect ('problems-clicked',
00653                                          self.on_problems_button_clicked)
00654         except (cups.IPPError, cups.HTTPError):
00655             # Not authorized.
00656             return
00657         except RuntimeError:
00658             self.monitor.update ()

def system-config-printer.GUI.on_set_as_default_activate (   self,
  UNUSED 
)

Definition at line 1634 of file system-config-printer.py.

01634 
01635     def on_set_as_default_activate(self, UNUSED):
01636         iconview = self.dests_iconview
01637         paths = iconview.get_selected_items ()
01638         model = iconview.get_model ()
01639         iter = model.get_iter (paths[0])
01640         name = unicode (model.get_value (iter, 2))
01641         self.set_system_or_user_default_printer (name)

Here is the call graph for this function:

def system-config-printer.GUI.on_shared_activate (   self,
  menuitem 
)

Definition at line 1575 of file system-config-printer.py.

01575 
01576     def on_shared_activate(self, menuitem):
01577         if self.updating_widgets:
01578             return
01579         share = menuitem.get_active ()
01580         iconview = self.dests_iconview
01581         paths = iconview.get_selected_items ()
01582         model = iconview.get_model ()
01583         success = False
01584         for path in paths:
01585             iter = model.get_iter (path)
01586             printer = model.get_value (iter, 0)
01587             self.cups._begin_operation (_("modifying printer %s") %
01588                                         printer.name)
01589             try:
01590                 printer.setShared (share)
01591                 success = True
01592             except cups.IPPError, (e, m):
01593                 show_IPP_Error(e, m, self.PrintersWindow)
01594                 self.cups._end_operation ()
01595                 # Give up on this operation.
01596                 break
01597 
01598             self.cups._end_operation ()
01599 
01600         if success and share:
01601             if self.server_is_publishing == None:
01602                 # We haven't yet seen a server-is-sharing-printers attribute.
01603                 # Assuming CUPS 1.4, this means we haven't opened a
01604                 # properties dialog yet.  Fetch the attributes now and
01605                 # look for it.
01606                 try:
01607                     printer.getAttributes ()
01608                     p = printer.other_attributes['server-is-sharing-printers']
01609                     self.server_is_publishing = p
01610                 except (cups.IPPError, KeyError):
01611                     pass
01612 
01613             self.advise_publish ()
01614 
01615         # For some reason CUPS doesn't give us a notification about
01616         # printers changing 'shared' state, so refresh instead of
01617         # update.  We have to defer this to prevent signal problems.
01618         def deferred_refresh ():
01619             gtk.gdk.threads_enter ()
01620             self.populateList ()
01621             gtk.gdk.threads_leave ()
01622             return False
01623         gobject.idle_add (deferred_refresh)

Here is the call graph for this function:

def system-config-printer.GUI.on_start_service_clicked (   self,
  button 
)

Service start-up.

Definition at line 1809 of file system-config-printer.py.

01809 
01810     def on_start_service_clicked (self, button):
01811         button.set_sensitive (False)
01812         self.servicestart.start (reply_handler=self.on_start_service_reply,
01813                                  error_handler=self.on_start_service_reply)

Here is the call graph for this function:

def system-config-printer.GUI.on_start_service_reply (   self,
  args 
)

Definition at line 1814 of file system-config-printer.py.

01814 
01815     def on_start_service_reply (self, *args):
01816         gobject.timeout_add_seconds (1, self.service_started_try)

Here is the call graph for this function:

Here is the caller graph for this function:

def system-config-printer.GUI.on_troubleshoot_activate (   self,
  widget 
)

Definition at line 1704 of file system-config-printer.py.

01704 
01705     def on_troubleshoot_activate(self, widget):
01706         if not self.__dict__.has_key ('troubleshooter'):
01707             self.troubleshooter = troubleshoot.run (self.on_troubleshoot_quit)

def system-config-printer.GUI.on_troubleshoot_quit (   self,
  troubleshooter 
)

Definition at line 1708 of file system-config-printer.py.

01708 
01709     def on_troubleshoot_quit(self, troubleshooter):
01710         del self.troubleshooter

Here is the caller graph for this function:

def system-config-printer.GUI.on_view_discovered_printers_activate (   self,
  UNUSED 
)

Definition at line 1701 of file system-config-printer.py.

01701 
01702     def on_view_discovered_printers_activate (self, UNUSED):
01703         self.populateList ()

Here is the call graph for this function:

def system-config-printer.GUI.on_view_print_queue_activate (   self,
  UNUSED 
)

Definition at line 1672 of file system-config-printer.py.

01672 
01673     def on_view_print_queue_activate (self, UNUSED):
01674         paths = self.dests_iconview.get_selected_items ()
01675         if len (paths):
01676             specific_dests = []
01677             model = self.dests_iconview.get_model ()
01678             for path in paths:
01679                 iter = model.get_iter (path)
01680                 name = unicode (model.get_value (iter, 2), 'utf-8')
01681                 specific_dests.append (name)
01682             viewer = jobviewer.JobViewer (None, None, my_jobs=False,
01683                                           specific_dests=specific_dests,
01684                                           parent=self.PrintersWindow)
01685             viewer.connect ('finished', self.on_jobviewer_exit)
01686         else:
01687             viewer = jobviewer.JobViewer (None, None, my_jobs=False,
01688                                           parent=self.PrintersWindow)
01689             viewer.connect ('finished', self.on_jobviewer_exit)
01690 
01691         self.jobviewers.append (viewer)

Here is the call graph for this function:

def system-config-printer.GUI.populateList (   self,
  prompt_allowed = True 
)

Definition at line 704 of file system-config-printer.py.

00704 
00705     def populateList(self, prompt_allowed=True):
00706         # Save selection of printers.
00707         selected_printers = set()
00708         paths = self.dests_iconview.get_selected_items ()
00709         model = self.dests_iconview.get_model ()
00710         for path in paths:
00711             iter = model.get_iter (path)
00712             name = unicode (model.get_value (iter, 2))
00713             selected_printers.add (name)
00714 
00715         if self.cups:
00716             kill_connection = False
00717             self.cups._set_prompt_allowed (prompt_allowed)
00718             self.cups._begin_operation (_("obtaining queue details"))
00719             try:
00720                 # get Printers
00721                 self.printers = cupshelpers.getPrinters(self.cups)
00722 
00723                 # Get default printer.
00724                 self.default_printer = self.cups.getDefault ()
00725             except cups.IPPError, (e, m):
00726                 show_IPP_Error(e, m, self.PrintersWindow)
00727                 self.printers = {}
00728                 self.default_printer = None
00729                 if e == cups.IPP_SERVICE_UNAVAILABLE:
00730                     kill_connection = True
00731 
00732             self.cups._end_operation ()
00733             self.cups._set_prompt_allowed (True)
00734             if kill_connection:
00735                 self.cups = None
00736         else:
00737             self.printers = {}
00738             self.default_printer = None
00739 
00740         for name, printer in self.printers.iteritems():
00741             self.servers.add(printer.getServer())
00742 
00743         userdef = userdefault.UserDefaultPrinter ().get ()
00744 
00745         local_printers = []
00746         local_classes = []
00747         remote_printers = []
00748         remote_classes = []
00749 
00750         delete_action = self.ui_manager.get_action ("/delete-printer")
00751         delete_action.set_properties (label = None)
00752         printers_set = self.printers
00753 
00754         # Filter printers
00755         if len (self.current_filter_text) > 0:
00756             printers_subset = {}
00757             pattern = re.compile (self.current_filter_text, re.I) # ignore case
00758 
00759             if self.current_filter_mode == "filter-name":
00760                 for name in printers_set.keys ():
00761                     if pattern.search (name) != None:
00762                         printers_subset[name] = printers_set[name]
00763             elif self.current_filter_mode == "filter-description":
00764                 for name, printer in printers_set.iteritems ():
00765                     if pattern.search (printer.info) != None:
00766                         printers_subset[name] = printers_set[name]
00767             elif self.current_filter_mode == "filter-location":
00768                 for name, printer in printers_set.iteritems ():
00769                     if pattern.search (printer.location) != None:
00770                         printers_subset[name] = printers_set[name]
00771             elif self.current_filter_mode == "filter-manufacturer":
00772                 for name, printer in printers_set.iteritems ():
00773                     if pattern.search (printer.make_and_model) != None:
00774                         printers_subset[name] = printers_set[name]
00775             else:
00776                 nonfatalException ()
00777 
00778             printers_set = printers_subset
00779 
00780         if not self.view_discovered_printers.get_active ():
00781             printers_subset = {}
00782             for name, printer in printers_set.iteritems ():
00783                 if not printer.discovered:
00784                     printers_subset[name] = printer
00785 
00786             printers_set = printers_subset
00787 
00788         for name, printer in printers_set.iteritems():
00789             if printer.remote:
00790                 if printer.is_class: remote_classes.append(name)
00791                 else: remote_printers.append(name)
00792             else:
00793                 if printer.is_class: local_classes.append(name)
00794                 else: local_printers.append(name)
00795 
00796         local_printers.sort()
00797         local_classes.sort()
00798         remote_printers.sort()
00799         remote_classes.sort()
00800 
00801         # remove old printers/classes
00802         self.mainlist.clear ()
00803 
00804         # add new
00805         PRINTER_TYPE = { 'discovered-printer':
00806                              (_("Network printer (discovered)"),
00807                               'i-network-printer'),
00808                          'discovered-class':
00809                              (_("Network class (discovered)"),
00810                               'i-network-printer'),
00811                          'local-printer':
00812                              (_("Printer"),
00813                               'printer'),
00814                          'local-fax':
00815                              (_("Fax"),
00816                               'printer'),
00817                          'local-class':
00818                              (_("Class"),
00819                               'printer'),
00820                          'ipp-printer':
00821                              (_("Network printer"),
00822                               'i-network-printer'),
00823                          'smb-printer':
00824                              (_("Network print share"),
00825                               'printer'),
00826                          'network-printer':
00827                              (_("Network printer"),
00828                               'i-network-printer'),
00829                          }
00830         theme = gtk.icon_theme_get_default ()
00831         for printers in (local_printers,
00832                          local_classes,
00833                          remote_printers,
00834                          remote_classes):
00835             if not printers: continue
00836             for name in printers:
00837                 type = 'local-printer'
00838                 object = printers_set[name]
00839                 if object.discovered:
00840                     if object.is_class:
00841                         type = 'discovered-class'
00842                     else:
00843                         type = 'discovered-printer'
00844                 elif object.is_class:
00845                     type = 'local-class'
00846                 else:
00847                     (scheme, rest) = urllib.splittype (object.device_uri)
00848                     if scheme == 'ipp':
00849                         type = 'ipp-printer'
00850                     elif scheme == 'smb':
00851                         type = 'smb-printer'
00852                     elif scheme == 'hpfax':
00853                         type = 'local-fax'
00854                     elif scheme in ['socket', 'lpd']:
00855                         type = 'network-printer'
00856 
00857                 (tip, icon) = PRINTER_TYPE[type]
00858                 (w, h) = gtk.icon_size_lookup (gtk.ICON_SIZE_DIALOG)
00859                 try:
00860                     pixbuf = theme.load_icon (icon, w, 0)
00861                 except gobject.GError:
00862                     # Not in theme.
00863                     pixbuf = None
00864                     for p in [iconpath, 'icons/']:
00865                         try:
00866                             pixbuf = gtk.gdk.pixbuf_new_from_file ("%s%s.png" %
00867                                                                    (p, icon))
00868                             break
00869                         except gobject.GError:
00870                             pass
00871 
00872                     if pixbuf == None:
00873                         try:
00874                             pixbuf = theme.load_icon ('printer', w, 0)
00875                         except:
00876                             # Just create an empty pixbuf.
00877                             pixbuf = gtk.gdk.Pixbuf (gtk.gdk.COLORSPACE_RGB,
00878                                                      True, 8, w, h)
00879                             pixbuf.fill (0)
00880 
00881                 def_emblem = None
00882                 emblem = None
00883                 if name == self.default_printer:
00884                     def_emblem = 'emblem-default'
00885                 elif name == userdef:
00886                     def_emblem = 'emblem-favorite'
00887 
00888                 if not emblem:
00889                     attrs = object.other_attributes
00890                     reasons = attrs.get ('printer-state-reasons', [])
00891                     worst_reason = None
00892                     for reason in reasons:
00893                         if reason == "none":
00894                             break
00895 
00896                         if reason == "paused":
00897                             emblem = gtk.STOCK_MEDIA_PAUSE
00898                             continue
00899 
00900                         r = statereason.StateReason (object.name, reason)
00901                         if worst_reason == None:
00902                             worst_reason = r
00903                         elif r > worst_reason:
00904                             worst_reason = r
00905 
00906                     if worst_reason:
00907                         level = worst_reason.get_level ()
00908                         emblem = worst_reason.LEVEL_ICON[level]
00909 
00910                 if not emblem and not object.enabled:
00911                     emblem = gtk.STOCK_MEDIA_PAUSE
00912 
00913                 if object.rejecting:
00914                     # Show the icon as insensitive
00915                     copy = pixbuf.copy ()
00916                     copy.fill (0)
00917                     pixbuf.composite (copy, 0, 0,
00918                                       copy.get_width(), copy.get_height(),
00919                                       0, 0, 1.0, 1.0,
00920                                       gtk.gdk.INTERP_BILINEAR, 127)
00921                     pixbuf = copy
00922 
00923                 if def_emblem:
00924                     (w, h) = gtk.icon_size_lookup (gtk.ICON_SIZE_DIALOG)
00925                     try:
00926                         default_emblem = theme.load_icon (def_emblem, w/2, 0)
00927                         copy = pixbuf.copy ()
00928                         default_emblem.composite (copy, 0, 0,
00929                                                   copy.get_width (),
00930                                                   copy.get_height (),
00931                                                   0, 0,
00932                                                   1.0, 1.0,
00933                                                   gtk.gdk.INTERP_NEAREST, 255)
00934                         pixbuf = copy
00935                     except gobject.GError:
00936                         debugprint ("No %s icon available" % def_emblem)
00937 
00938                 if emblem:
00939                     (w, h) = gtk.icon_size_lookup (gtk.ICON_SIZE_DIALOG)
00940                     try:
00941                         other_emblem = theme.load_icon (emblem, w/2, 0)
00942                         copy = pixbuf.copy ()
00943                         other_emblem.composite (copy, 0, 0,
00944                                                 copy.get_width (),
00945                                                 copy.get_height (),
00946                                                 copy.get_width () / 2,
00947                                                 copy.get_height () / 2,
00948                                                 1.0, 1.0,
00949                                                 gtk.gdk.INTERP_NEAREST, 255)
00950                         pixbuf = copy
00951                     except gobject.GError:
00952                         debugprint ("No %s icon available" % emblem)
00953 
00954                 self.mainlist.append (row=[object, pixbuf, name, tip])
00955 
00956         # Restore selection of printers.
00957         model = self.dests_iconview.get_model ()
00958         def maybe_select (model, path, iter):
00959             name = unicode (model.get_value (iter, 2))
00960             if name in selected_printers:
00961                 self.dests_iconview.select_path (path)
00962         model.foreach (maybe_select)
00963 
00964         # Set up the dests_notebook page.
00965         page = self.DESTS_PAGE_DESTS
00966         if self.cups:
00967             if (not self.current_filter_text and
00968                 not self.mainlist.get_iter_first ()):
00969                 page = self.DESTS_PAGE_NO_PRINTERS
00970         else:
00971             page = self.DESTS_PAGE_NO_SERVICE
00972             can_start = (self.connect_server == 'localhost' or
00973                          self.connect_server[0] != '/')
00974             tooltip_text = None
00975             if can_start:
00976                 can_start = self.servicestart.can_start ()
00977                 if not can_start:
00978                     tooltip_text = _("Service framework not available")
00979             else:
00980                 tooltip_text = _("Cannot start service on remote server")
00981 
00982             self.btnStartService.set_sensitive (can_start)
00983             self.btnStartService.set_tooltip_text (tooltip_text)
00984 
00985         self.dests_notebook.set_current_page (page)

Here is the call graph for this function:

Here is the caller graph for this function:

def system-config-printer.GUI.printer_added (   self,
  mon,
  printer 
)

Monitor signal handlers.

Definition at line 1946 of file system-config-printer.py.

01946 
01947     def printer_added (self, mon, printer):
01948         self.printer_added_or_removed ()

Here is the call graph for this function:

Here is the caller graph for this function:

def system-config-printer.GUI.printer_added_or_removed (   self)

Monitor signal helpers.

Definition at line 1931 of file system-config-printer.py.

01931 
01932     def printer_added_or_removed (self):
01933         # Just fetch the list of printers again.  This is too simplistic.
01934         def deferred_refresh ():
01935             gtk.gdk.threads_enter ()
01936             self.populateList (prompt_allowed=False)
01937             gtk.gdk.threads_leave ()
01938             return False
01939 
01940         if self.populateList_timer:
01941             gobject.source_remove (self.populateList_timer)
01942 
01943         self.populateList_timer = gobject.timeout_add (200, deferred_refresh)
01944         debugprint ("Deferred populateList by 200ms")

Here is the call graph for this function:

Here is the caller graph for this function:

def system-config-printer.GUI.printer_event (   self,
  mon,
  printer,
  eventname,
  event 
)

Definition at line 1949 of file system-config-printer.py.

01949 
01950     def printer_event (self, mon, printer, eventname, event):
01951         if self.printers.has_key (printer):
01952             self.printers[printer].update (**event)
01953             self.dests_iconview_selection_changed (self.dests_iconview)
01954             self.printer_added_or_removed ()

Here is the call graph for this function:

Here is the caller graph for this function:

def system-config-printer.GUI.printer_name_edit_cancel (   self,
  cell 
)

Definition at line 1332 of file system-config-printer.py.

01332 
01333     def printer_name_edit_cancel (self, cell):
01334         debugprint ("editing-canceled")
01335         cell.stop_editing (canceled=True)
01336         cell.set_property ('editable', False)
01337         for id in self.rename_sigids:
01338             cell.disconnect (id)
01339         if self.rename_entry_sigid != None:
01340             self.rename_entry_sigid[0].disconnect(self.rename_entry_sigid[1])
01341 

Here is the caller graph for this function:

def system-config-printer.GUI.printer_name_edit_start (   self,
  cell,
  editable,
  path 
)

Definition at line 1302 of file system-config-printer.py.

01302 
01303     def printer_name_edit_start (self, cell, editable, path):
01304         debugprint ("editing-started")
01305         if isinstance(editable, gtk.Entry):
01306             id = editable.connect('changed', self.printer_name_editing)
01307             self.rename_entry_sigid = editable, id

Here is the call graph for this function:

Here is the caller graph for this function:

def system-config-printer.GUI.printer_name_edited (   self,
  cell,
  path,
  newname 
)

Definition at line 1317 of file system-config-printer.py.

01317 
01318     def printer_name_edited (self, cell, path, newname):
01319         model = self.dests_iconview.get_model ()
01320         iter = model.get_iter (path)
01321         name = unicode (model.get_value (iter, 2))
01322         debugprint ("edited: %s -> %s" % (name, newname))
01323         try:
01324             self.rename_printer (name, newname)
01325         finally:
01326             cell.stop_editing (canceled=False)
01327             cell.set_property ('editable', False)
01328             for id in self.rename_sigids:
01329                 cell.disconnect (id)
01330             if self.rename_entry_sigid != None:
01331                 self.rename_entry_sigid[0].disconnect(self.rename_entry_sigid[1])

Here is the call graph for this function:

Here is the caller graph for this function:

def system-config-printer.GUI.printer_name_editing (   self,
  entry 
)

Definition at line 1308 of file system-config-printer.py.

01308 
01309     def printer_name_editing (self, entry):
01310         newname = origname = unicode (entry.get_text())
01311         newname = newname.replace("/", "")
01312         newname = newname.replace("#", "")
01313         newname = newname.replace(" ", "")
01314         if origname != newname:
01315             debugprint ("removed disallowed character %s" % origname[-1])
01316             entry.set_text(newname)

Here is the caller graph for this function:

def system-config-printer.GUI.printer_removed (   self,
  mon,
  printer 
)

Definition at line 1955 of file system-config-printer.py.

01955 
01956     def printer_removed (self, mon, printer):
01957         self.printer_added_or_removed ()

Here is the call graph for this function:

Here is the caller graph for this function:

def system-config-printer.GUI.reconnect (   self)
Reconnect to CUPS after the server has reloaded.

Definition at line 1134 of file system-config-printer.py.

01134 
01135     def reconnect (self):
01136         """Reconnect to CUPS after the server has reloaded."""
01137         # libcups would handle the reconnection if we just told it to
01138         # do something, for example fetching a list of classes.
01139         # However, our local authentication certificate would be
01140         # invalidated by a server restart, so it is better for us to
01141         # handle the reconnection ourselves.
01142 
01143         attempt = 1
01144         while attempt <= 5:
01145             try:
01146                 time.sleep(1)
01147                 self.cups._connect ()
01148                 break
01149             except RuntimeError:
01150                 # Connection failed.
01151                 attempt += 1

Here is the caller graph for this function:

def system-config-printer.GUI.rename_confirmed_by_user (   self,
  name 
)
Renaming deletes job history. So if we have some completed jobs,
inform the user and let him confirm the renaming.

Definition at line 1247 of file system-config-printer.py.

01247 
01248     def rename_confirmed_by_user (self, name):
01249         """
01250         Renaming deletes job history. So if we have some completed jobs,
01251         inform the user and let him confirm the renaming.
01252         """
01253         preserved_jobs = self.printers[name].jobsPreserved(limit=1)
01254         if len (preserved_jobs) > 0:
01255             dialog = gtk.MessageDialog (self.PrintersWindow,
01256                                         gtk.DIALOG_MODAL |
01257                                         gtk.DIALOG_DESTROY_WITH_PARENT,
01258                                         gtk.MESSAGE_WARNING,
01259                                         gtk.BUTTONS_OK_CANCEL,
01260                                         _("Renaming will lose history"))
01261 
01262             dialog.format_secondary_text (_("Completed jobs will no longer "
01263                                             "be available for re-printing."))
01264             result = dialog.run()
01265             dialog.destroy ()
01266             if result == gtk.RESPONSE_CANCEL:
01267                 return False
01268 
01269         return True

Here is the caller graph for this function:

def system-config-printer.GUI.rename_printer (   self,
  old_name,
  new_name 
)

Definition at line 1342 of file system-config-printer.py.

01342 
01343     def rename_printer (self, old_name, new_name):
01344         if old_name.lower() == new_name.lower():
01345             return
01346 
01347         try:
01348             self.propertiesDlg.load (old_name,
01349                                      host=self.connect_server,
01350                                      encryption=self.connect_encrypt,
01351                                      parent=self.PrintersWindow)
01352         except RuntimeError:
01353             # Perhaps cupsGetPPD2 failed for a browsed printer
01354             pass
01355         except cups.IPPError, (e, m):
01356             show_IPP_Error (e, m, self.PrintersWindow)
01357             self.populateList ()
01358             return
01359 
01360         if not self.is_rename_possible (old_name):
01361             return
01362 
01363         self.cups._begin_operation (_("renaming printer"))
01364         rejecting = self.propertiesDlg.printer.rejecting
01365         if not rejecting:
01366             try:
01367                 self.propertiesDlg.printer.setAccepting (False)
01368                 if not self.is_rename_possible (old_name):
01369                     self.propertiesDlg.printer.setAccepting (True)
01370                     self.cups._end_operation ()
01371                     return
01372             except cups.IPPError, (e, msg):
01373                 show_IPP_Error (e, msg, self.PrintersWindow)
01374                 self.cups._end_operation ()
01375                 return
01376 
01377         if self.duplicate_printer (new_name):
01378             # Failure.
01379             self.monitor.update ()
01380 
01381             # Restore original accepting/rejecting state.
01382             if not rejecting and self.propertiesDlg.printer:
01383                 try:
01384                     self.propertiesDlg.printer.name = old_name
01385                     self.propertiesDlg.printer.setAccepting (True)
01386                 except cups.HTTPError, (s,):
01387                     show_HTTP_Error (s, self.PrintersWindow)
01388                 except cups.IPPError, (e, msg):
01389                     show_IPP_Error (e, msg, self.PrintersWindow)
01390 
01391             self.cups._end_operation ()
01392             self.populateList ()
01393             return
01394 
01395         if not self.propertiesDlg.printer:
01396             self.cups._end_operation ()
01397             self.populateList ()
01398             return
01399 
01400         # Restore rejecting state.
01401         if not rejecting:
01402             try:
01403                 self.propertiesDlg.printer.setAccepting (True)
01404             except cups.HTTPError, (s,):
01405                 show_HTTP_Error (s, self.PrintersWindow)
01406                 # Not fatal.
01407             except cups.IPPError, (e, msg):
01408                 show_IPP_Error (e, msg, self.PrintersWindow)
01409                 # Not fatal.
01410 
01411         # Fix up default printer.
01412         if self.default_printer == old_name:
01413             reload = False
01414             try:
01415                 reload = self.propertiesDlg.printer.setAsDefault ()
01416             except cups.HTTPError, (s,):
01417                 show_HTTP_Error (s, self.PrintersWindow)
01418                 # Not fatal.
01419             except cups.IPPError, (e, msg):
01420                 show_IPP_Error (e, msg, self.PrintersWindow)
01421                 # Not fatal.
01422 
01423             if reload:
01424                 self.reconnect ()
01425 
01426         # Finally, delete the old printer.
01427         try:
01428             self.cups.deletePrinter (old_name)
01429         except cups.HTTPError, (s,):
01430             show_HTTP_Error (s, self.PrintersWindow)
01431             # Not fatal
01432         except cups.IPPError, (e, msg):
01433             show_IPP_Error (e, msg, self.PrintersWindow)
01434             # Not fatal.
01435 
01436         self.cups._end_operation ()
01437 
01438         # ..and select the new printer.
01439         def select_new_printer (model, path, iter):
01440             name = unicode (model.get_value (iter, 2))
01441             if name == new_name:
01442                 self.dests_iconview.select_path (path)
01443         self.populateList ()
01444         model = self.dests_iconview.get_model ()
01445         model.foreach (select_new_printer)

Here is the call graph for this function:

Here is the caller graph for this function:

def system-config-printer.GUI.service_started_retry (   self)

Definition at line 1824 of file system-config-printer.py.

01824 
01825     def service_started_retry (self):
01826         if not self.cups:
01827             gtk.gdk.threads_enter ()
01828             self.on_btnRefresh_clicked (None)
01829             self.btnStartService.set_sensitive (True)
01830             gtk.gdk.threads_leave ()
01831 
01832         return False

Here is the call graph for this function:

Here is the caller graph for this function:

def system-config-printer.GUI.service_started_try (   self)

Definition at line 1817 of file system-config-printer.py.

01817 
01818     def service_started_try (self):
01819         gtk.gdk.threads_enter ()
01820         self.on_btnRefresh_clicked (None)
01821         gtk.gdk.threads_leave ()
01822         gobject.timeout_add_seconds (1, self.service_started_retry)
01823         return False

Here is the call graph for this function:

Here is the caller graph for this function:

def system-config-printer.GUI.set_default_printer (   self,
  name 
)

Definition at line 1191 of file system-config-printer.py.

01191 
01192     def set_default_printer (self, name):
01193         printer = self.printers[name]
01194         reload = False
01195         self.cups._begin_operation (_("setting default printer"))
01196         try:
01197             reload = printer.setAsDefault ()
01198         except cups.HTTPError, (s,):
01199             show_HTTP_Error (s, self.PrintersWindow)
01200             self.cups._end_operation ()
01201             return
01202         except cups.IPPError, (e, msg):
01203             show_IPP_Error(e, msg, self.PrintersWindow)
01204             self.cups._end_operation ()
01205             return
01206 
01207         self.cups._end_operation ()
01208 
01209         # Now reconnect in case the server needed to reload.  This may
01210         # happen if we replaced the lpoptions file.
01211         if reload:
01212             self.reconnect ()
01213 
01214         try:
01215             self.populateList()
01216         except cups.HTTPError, (s,):
01217             self.cups = None
01218             self.setConnected()
01219             self.populateList()
01220             show_HTTP_Error(s, self.PrintersWindow)

Here is the call graph for this function:

Here is the caller graph for this function:

def system-config-printer.GUI.set_system_or_user_default_printer (   self,
  name 
)

Definition at line 1170 of file system-config-printer.py.

01170 
01171     def set_system_or_user_default_printer (self, name):
01172         # First, decide if this is already the system default, in which
01173         # case we only need to clear the user default.
01174         userdef = userdefault.UserDefaultPrinter ()
01175         if name == self.default_printer:
01176             userdef.clear ()
01177             self.populateList ()
01178             return
01179 
01180         userdefault.UserDefaultPrompt (self.set_default_printer,
01181                                        self.populateList,
01182                                        name,
01183                                        _("Set Default Printer"),
01184                                        self.PrintersWindow,
01185                                        _("Do you want to set this as "
01186                                          "the system-wide default printer?"),
01187                                        _("Set as the _system-wide "
01188                                          "default printer"),
01189                                        _("_Clear my personal default setting"),
01190                                        _("Set as my _personal default printer"))

Here is the call graph for this function:

Here is the caller graph for this function:

def system-config-printer.GUI.setConnected (   self)

Definition at line 659 of file system-config-printer.py.

00659 
00660     def setConnected(self):
00661         connected = bool(self.cups)
00662 
00663         host = CUPS_server_hostname ()
00664         self.PrintersWindow.set_title(_("Printing - %s") % host)
00665 
00666         if connected:
00667             status_msg = _("Connected to %s") % host
00668         else:
00669             status_msg = _("Not connected")
00670         self.statusbarMain.push(self.status_context_id, status_msg)
00671 
00672         for widget in (self.btnNew,
00673                        self.menuItemNew):
00674             widget.set_sensitive(connected)
00675 
00676         for action_name in ["/server-settings",
00677                             "/new-printer",
00678                             "/new-class"]:
00679             action = self.ui_manager.get_action (action_name)
00680             action.set_sensitive (connected)
00681 
00682         if connected:
00683             if self.monitor:
00684                 self.monitor.cleanup ()
00685 
00686             self.monitor = monitor.Monitor (monitor_jobs=False,
00687                                             host=self.connect_server,
00688                                             encryption=self.connect_encrypt)
00689             self.monitor.connect ('printer-added', self.printer_added)
00690             self.monitor.connect ('printer-event', self.printer_event)
00691             self.monitor.connect ('printer-removed', self.printer_removed)
00692             self.monitor.connect ('cups-connection-error',
00693                                   self.cups_connection_error)
00694             self.monitor.connect ('cups-connection-recovered',
00695                                   self.cups_connection_recovered)
00696             self.monitor.refresh ()
00697             self.propertiesDlg.set_monitor (self.monitor)

Here is the call graph for this function:

Here is the caller graph for this function:

def system-config-printer.GUI.setup_toolbar_for_search_entry (   self)

Definition at line 480 of file system-config-printer.py.

00480 
00481     def setup_toolbar_for_search_entry (self):
00482         separator = gtk.SeparatorToolItem ()
00483         separator.set_draw (False)
00484 
00485         self.toolbar.insert (separator, -1)
00486         self.toolbar.child_set_property (separator, "expand", True)
00487 
00488         self.search_entry = ToolbarSearchEntry ()
00489         self.search_entry.connect ('search', self.on_search_entry_search)
00490 
00491         tool_item = gtk.ToolItem ()
00492         tool_item.add (self.search_entry)
00493         self.toolbar.insert (tool_item, -1)
00494         self.toolbar.show_all ()

def system-config-printer.GUI.update_connecting_pbar (   self)

Definition at line 1041 of file system-config-printer.py.

01041 
01042     def update_connecting_pbar (self):
01043         ret = True
01044         gtk.gdk.threads_enter ()
01045         if not self.ConnectingDialog.get_property ("visible"):
01046             ret = False # stop animation
01047         else:
01048             self.pbarConnecting.pulse ()
01049 
01050         gtk.gdk.threads_leave ()
01051         return ret

Here is the caller graph for this function:


Member Data Documentation

system-config-printer.GUI.btnNew

Definition at line 297 of file system-config-printer.py.

system-config-printer.GUI.changed

Definition at line 161 of file system-config-printer.py.

system-config-printer.GUI.connect_encrypt

Definition at line 154 of file system-config-printer.py.

system-config-printer.GUI.connect_server

Definition at line 153 of file system-config-printer.py.

system-config-printer.GUI.connect_thread

Definition at line 1038 of file system-config-printer.py.

system-config-printer.GUI.connect_user

Definition at line 155 of file system-config-printer.py.

system-config-printer.GUI.cups

Definition at line 385 of file system-config-printer.py.

system-config-printer.GUI.current_filter_mode

Definition at line 395 of file system-config-printer.py.

system-config-printer.GUI.current_filter_text

Definition at line 394 of file system-config-printer.py.

system-config-printer.GUI.default_printer

Definition at line 561 of file system-config-printer.py.

int system-config-printer.GUI.DESTS_PAGE_DESTS = 0 [static]

Definition at line 136 of file system-config-printer.py.

int system-config-printer.GUI.DESTS_PAGE_NO_PRINTERS = 1 [static]

Definition at line 137 of file system-config-printer.py.

int system-config-printer.GUI.DESTS_PAGE_NO_SERVICE = 2 [static]

Definition at line 138 of file system-config-printer.py.

system-config-printer.GUI.encoding

Definition at line 144 of file system-config-printer.py.

system-config-printer.GUI.jobviewers

Definition at line 367 of file system-config-printer.py.

system-config-printer.GUI.language

Definition at line 143 of file system-config-printer.py.

system-config-printer.GUI.mainlist

Definition at line 412 of file system-config-printer.py.

system-config-printer.GUI.menuItemNew

Definition at line 327 of file system-config-printer.py.

system-config-printer.GUI.monitor

Definition at line 156 of file system-config-printer.py.

system-config-printer.GUI.newPrinterGUI

Definition at line 370 of file system-config-printer.py.

system-config-printer.GUI.populateList_timer

Definition at line 157 of file system-config-printer.py.

system-config-printer.GUI.printer_context_menu

Definition at line 346 of file system-config-printer.py.

dictionary system-config-printer.GUI.printer_states [static]
Initial value:
{ cups.IPP_PRINTER_IDLE: _("Idle"),
                       cups.IPP_PRINTER_PROCESSING: _("Processing"),
                       cups.IPP_PRINTER_BUSY: _("Busy"),
                       cups.IPP_PRINTER_STOPPED: _("Stopped") }

Definition at line 131 of file system-config-printer.py.

system-config-printer.GUI.printers

Definition at line 152 of file system-config-printer.py.

system-config-printer.GUI.propertiesDlg

Definition at line 448 of file system-config-printer.py.

system-config-printer.GUI.rename_entry_sigid

Definition at line 1299 of file system-config-printer.py.

system-config-printer.GUI.rename_sigids

Definition at line 1298 of file system-config-printer.py.

system-config-printer.GUI.search_entry

Definition at line 487 of file system-config-printer.py.

system-config-printer.GUI.server_is_publishing

Definition at line 160 of file system-config-printer.py.

system-config-printer.GUI.servers

Definition at line 159 of file system-config-printer.py.

system-config-printer.GUI.serverSettings

Definition at line 648 of file system-config-printer.py.

system-config-printer.GUI.servicestart

Definition at line 409 of file system-config-printer.py.

system-config-printer.GUI.status_context_id

Definition at line 389 of file system-config-printer.py.

system-config-printer.GUI.troubleshooter

Definition at line 1706 of file system-config-printer.py.

system-config-printer.GUI.ui_manager

Definition at line 265 of file system-config-printer.py.

system-config-printer.GUI.updating_widgets

Definition at line 165 of file system-config-printer.py.


The documentation for this class was generated from the following file: