~ubuntu-branches/ubuntu/maverick/awn-extras-applets/maverick

« back to all changes in this revision

Viewing changes to applets/maintained/file-browser-launcher/file-browser-launcher.py

  • Committer: Bazaar Package Importer
  • Author(s): Julien Lavergne
  • Date: 2010-08-29 14:29:52 UTC
  • mto: This revision was merged to the branch mainline in revision 21.
  • Revision ID: james.westby@ubuntu.com-20100829142952-rhvuetyms9bv5uu7
Tags: upstream-0.4.0+bzr1372
ImportĀ upstreamĀ versionĀ 0.4.0+bzr1372

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
import urllib
33
33
import gettext
34
34
 
 
35
from desktopagnostic.config import GROUP_DEFAULT as group
 
36
from desktopagnostic import vfs
 
37
import awn
 
38
from awn.extras import _
 
39
gettext.bindtextdomain('xdg-user-dirs', '/usr/share/locale')
 
40
 
35
41
try:
36
42
  import gio
37
 
 
38
43
except:
39
44
  gio = False
40
45
 
41
 
from desktopagnostic.config import GROUP_DEFAULT as group
42
 
import awn
43
 
from awn.extras import _
44
 
gettext.bindtextdomain('xdg-user-dirs', '/usr/share/locale')
45
 
 
46
46
 
47
47
class App(awn.Applet):
48
48
  icons = {}
62
62
    self.icon = awn.ThemedIcon()
63
63
    self.icon.set_tooltip_text(_("File Browser Launcher"))
64
64
    self.icon.set_size(self.get_size())
65
 
    self.dialog = awn.Dialog(self)
 
65
    self.dialog = awn.Dialog(self.icon, self)
66
66
 
67
67
    #AwnConfigClient instance
68
68
    self.client = awn.config_get_default_for_applet(self)
70
70
    #Get the default icon theme
71
71
    self.theme = gtk.icon_theme_get_default()
72
72
    self.icons[24] = {}
73
 
    self.icons[24]['stock_folder'] = self.theme.load_icon('stock_folder', 24, 0)
 
73
    self.icons[24]['folder'] = self.theme.load_icon('folder', 24, 0)
74
74
 
75
75
    #Docklet...
76
76
    self.mode = self.client.get_int(group, 'mode')
84
84
      self.icon_box.add(self.icon)
85
85
 
86
86
    #Set the icon
87
 
    self.icon.set_info_simple('file-browser-launcher', uid, 'stock_folder')
 
87
    self.icon.set_info_simple('file-browser-launcher', uid, 'folder')
88
88
 
89
 
    #This part (and other progress overlay code) adapted from
90
 
    #mhr3's 'Dropper' applet
91
89
    if gio:
 
90
      #This part (and other progress overlay code) adapted from
 
91
      #mhr3's 'Dropper' applet
92
92
      #Set the progress overlay
93
93
      self.timer_overlay = awn.OverlayProgressCircle()
94
94
      self.timer_overlay.props.active = False
95
95
      self.timer_overlay.props.apply_effects = False
96
96
      self.icon.add_overlay(self.timer_overlay)
97
 
 
98
97
    else:
99
98
      #Read fstab for mounting info
100
99
      #(It it assumed that fstab won't change after the applet is started)
103
102
      self.fstab2.close()
104
103
 
105
104
    #Check if nautilus-connect-server is installed
106
 
    if os.path.exists('/usr/bin/nautilus-connect-server') or os.path.exists\
 
105
    if os.path.exists('/usr/bin/nautilus-connect-server') or os.path.exists \
107
106
      ('/usr/local/bin/nautilus-connect-server'):
108
107
      self.nautilus_connect_server = True
109
108
    else:
110
109
      self.nautilus_connect_server = False
111
110
 
 
111
    if os.path.exists('/usr/share/applications/nautilus-computer.desktop') or \
 
112
      os.path.exists('/usr/local/share/applications/nautilus-computer.desktop'):
 
113
      self.nautilus_computer = True
 
114
    else:
 
115
      self.nautilus_computer = False
 
116
 
 
117
    def trash_count_cb(*args):
 
118
      if self.show_trash:
 
119
        if gio:
 
120
          self.do_gio_places()
 
121
        else:
 
122
          self.add_places()
 
123
 
 
124
    self.trash = vfs.Trash.get_default()
 
125
    self.trash.connect('file-count-changed', trash_count_cb)
 
126
 
112
127
    #Make the dialog, will only be shown when approiate
113
128
    #Make all the things needed for a treeview for the homefolder, root dir, bookmarks, and mounted drives
114
129
    self.liststore = gtk.ListStore(gtk.gdk.Pixbuf, str, gtk.gdk.Pixbuf, str, int)
133
148
    self.treeview.set_hover_selection(True)
134
149
    self.treeview.set_headers_visible(False)
135
150
    self.treeview.append_column(column)
 
151
    self.treeview.set_no_show_all(True)
136
152
    self.treeview.connect('button-press-event', self.treeview_clicked)
137
153
 
138
154
    self.vbox = gtk.VBox()
144
160
        'mount-changed', 'mount-removed'):
145
161
        self.monitor.connect(signal, self.do_gio_places)
146
162
 
147
 
      for key in ('show_home', 'show_local', 'show_network', 'show_connect', 'show_bookmarks',
148
 
        'show_filesystem'):
 
163
      for key in ('show_computer', 'show_home', 'show_filesystem', 'show_local', 'show_network',
 
164
        'show_connect', 'show_trash', 'show_bookmarks'):
149
165
        self.client.notify_add(group, key, self.do_gio_places)
150
166
 
151
167
      self.do_gio_places()
169
185
    self.entry = gtk.Entry()
170
186
    self.entry.set_text(os.environ['HOME'])
171
187
    self.entry.connect('key-release-event', self.detect_enter)
 
188
    self.entry.show()
 
189
 
172
190
    #Open button to run the file browser
173
191
    self.enter = gtk.Button(stock=gtk.STOCK_OPEN)
174
192
    self.enter.connect('clicked', self.launch_fb)
 
193
    self.enter.show()
 
194
 
175
195
    #HBox to put the two together
176
 
    self.hbox = gtk.HBox()
177
 
    self.hbox.pack_start(self.entry)
178
 
    self.hbox.pack_start(self.enter, False)
 
196
    entry_hbox = gtk.HBox()
 
197
    entry_hbox.pack_start(self.entry)
 
198
    entry_hbox.pack_start(self.enter, False)
 
199
 
179
200
    #And add the HBox to the vbox and add the vbox to the dialog
180
 
    self.vbox.pack_end(self.hbox)
 
201
    self.vbox.pack_end(entry_hbox)
181
202
    self.dialog.add(self.vbox)
182
203
 
183
204
    #Connect to signals
210
231
      self.treeview.connect('drag-motion', self.treeview_drag_motion)
211
232
      self.treeview.connect('drag-leave', self.treeview_drag_leave)
212
233
 
 
234
    elif self.mode == 2:
 
235
      self.add_places()
 
236
 
213
237
  def size_changed(self, *args):
214
238
    if self.docklet_visible:
215
239
      self.update_docklet()
284
308
      dropped_paths = data.data.split('\n')
285
309
      num_success = 0
286
310
 
287
 
      for dropped_path in dropped_paths:
288
 
        if len(dropped_path) >= 8:
289
 
          if dropped_path[:8] == 'file:///':
290
 
            dropped_path = dropped_path.strip()
291
 
 
292
 
            dropped_path = urllib.unquote(dropped_path)
293
 
 
294
 
            from_file = gio.File(dropped_path)
295
 
 
296
 
            to_file = gio.File(path + '/' + from_file.get_basename())
297
 
 
298
 
            #Make sure we're not just moving the file to the same directory
299
 
            if not from_file.equal(to_file):
300
 
              if from_file.move(to_file):
301
 
                num_success += 1
302
 
 
303
 
      if num_success > 0:
304
 
        config_fb = self.client.get_string(group, 'fb')
305
 
        open_dir = path.replace(' ', '\ ')
306
 
        os.system('%s %s &' % (config_fb, open_dir))
307
 
        self.dialog.hide()
 
311
      if path == 'trash:///':
 
312
        for dropped_path in dropped_paths:
 
313
          from_file = vfs.File.for_uri(urllib.unquote(dropped_path).strip())
 
314
          try:
 
315
            self.trash.send_to_trash(from_file)
 
316
          except:
 
317
            pass
 
318
 
 
319
      else:
 
320
        for dropped_path in dropped_paths:
 
321
          if len(dropped_path) >= 8:
 
322
            if dropped_path[:8] == 'file:///':
 
323
              dropped_path = dropped_path.strip()
 
324
 
 
325
              dropped_path = urllib.unquote(dropped_path)
 
326
 
 
327
              from_file = gio.File(dropped_path)
 
328
 
 
329
              to_file = gio.File(path + '/' + from_file.get_basename())
 
330
 
 
331
              #Make sure we're not just moving the file to the same directory
 
332
              if not from_file.equal(to_file):
 
333
                if from_file.move(to_file):
 
334
                  num_success += 1
 
335
 
 
336
        if num_success > 0:
 
337
          config_fb = self.client.get_string(group, 'fb')
 
338
          open_dir = path.replace(' ', '\ ')
 
339
          os.system('%s %s &' % (config_fb, open_dir))
 
340
          self.dialog.hide()
308
341
 
309
342
    return True
310
343
 
329
362
      self.dialog.hide()
330
363
 
331
364
  #Certain places, regardless of GIO/not GIO
332
 
  def do_places(self):
 
365
  def do_places(self, *args):
333
366
    self.liststore.clear()
334
367
    self.places_paths = []
335
368
    self.places_data = []
336
369
 
337
370
    #Get the needed config values
 
371
    self.show_computer = self.client.get_bool(group, 'show_computer')
338
372
    self.show_home = self.client.get_int(group, 'show_home')
 
373
    self.show_filesystem = self.client.get_int(group, 'show_filesystem')
339
374
    self.show_local = self.client.get_int(group, 'show_local')
340
375
    self.show_network = self.client.get_int(group, 'show_network')
341
376
    self.show_connect = self.client.get_int(group, 'show_connect')
342
377
    self.show_bookmarks = self.client.get_int(group, 'show_bookmarks')
343
 
    self.show_filesystem = self.client.get_int(group, 'show_filesystem')
 
378
    self.show_trash = self.client.get_bool(group, 'show_trash')
 
379
 
 
380
    if self.show_computer and self.nautilus_computer:
 
381
      self.place('computer', _("Computer"), 'exec://nautilus computer:')
344
382
 
345
383
    #Home folder
346
384
    if self.show_home == 2:
460
498
 
461
499
    self.do_ncs()
462
500
    self.do_bookmarks()
 
501
    self.do_trash()
463
502
 
464
503
    if self.docklet_visible:
465
504
      self.update_docklet()
466
505
 
467
506
  #A volume was mounted through file-browser-launcher; open the file manager to the path
468
507
  def gio_mounted(self, vol, blah):
469
 
    self.launch_fb(None, vol.get_mount().get_root().get_uri())
 
508
    try:
 
509
      uri = vol.get_mount().get_root().get_uri()
 
510
    except:
 
511
      return
 
512
 
 
513
    self.launch_fb(None, uri)
470
514
 
471
515
  #If nautilus-connect-server is installed, offer to start it "Connect to server..."
472
516
  def do_ncs(self):
526
570
 
527
571
                  #Documents
528
572
                  elif dir == gettext.dgettext('xdg-user-dirs', 'Documents'):
529
 
                    self.place(('folder-documents', 'stock_folder'), name, path)
 
573
                    self.place(('folder-documents', 'folder'), name, path)
530
574
 
531
575
                  #Downloads
532
576
                  elif dir == gettext.dgettext('xdg-user-dirs', 'Downloads'):
533
 
                    self.place(('folder-downloads', 'stock_folder'), name, path)
 
577
                    self.place(('folder-downloads', 'folder'), name, path)
534
578
 
535
579
                  #Music
536
580
                  elif dir == gettext.dgettext('xdg-user-dirs', 'Music'):
537
 
                    self.place(('folder-music', 'stock_folder'), name, path)
 
581
                    self.place(('folder-music', 'folder'), name, path)
538
582
 
539
583
                  #Pictures
540
584
                  elif dir == gettext.dgettext('xdg-user-dirs', 'Pictures'):
541
 
                    self.place(('folder-pictures', 'stock_folder'), name, path)
 
585
                    self.place(('folder-pictures', 'folder'), name, path)
542
586
 
543
587
                  #Public
544
588
                  elif dir == gettext.dgettext('xdg-user-dirs', 'Public'):
545
 
                    self.place(('folder-publicshare', 'stock_folder'), name, path)
 
589
                    self.place(('folder-publicshare', 'folder'), name, path)
546
590
 
547
591
                  #Templates
548
592
                  elif dir == gettext.dgettext('xdg-user-dirs', 'Templates'):
549
 
                    self.place(('folder-templates', 'stock_folder'), name, path)
 
593
                    self.place(('folder-templates', 'folder'), name, path)
550
594
 
551
595
                  #Videos
552
596
                  elif dir == gettext.dgettext('xdg-user-dirs', 'Videos'):
553
 
                    self.place(('folder-videos', 'stock_folder'), name, path)
 
597
                    self.place(('folder-videos', 'folder'), name, path)
554
598
 
555
599
                  #Other
556
600
                  else:
557
 
                    self.place('stock_folder', name, path)
 
601
                    self.place('folder', name, path)
558
602
 
559
603
                #It's not
560
604
                else:
561
 
                  self.place('stock_folder', name, path)
 
605
                  self.place('folder', name, path)
562
606
 
563
607
          #computer://, trash://, network fs, etc.
564
608
          else:
568
612
            elif type in ['network', 'smb', 'nfs', 'ftp', 'sftp', 'ssh']:
569
613
              self.place('network-folder', name, path, _("Network"))
570
614
 
571
 
            elif type == 'trash':
572
 
              #Get whether the trash is empty or not - but first find out if the Trash is in
573
 
              #~/.Trash or ~/.local/share/Trash
574
 
              try:
575
 
                #Get trash dir
576
 
                if os.path.isdir(os.path.expanduser('~/.local/share/Trash/files')):
577
 
                  self.trash_path = os.path.expanduser('~/.local/share/Trash/files')
578
 
                else:
579
 
                  self.trash_path = os.path.expanduser('~/.Trash')
580
 
 
581
 
                #Get number of items in trash
582
 
                if len(os.listdir(self.trash_path)) > 0:
583
 
                  self.trash_full = True
584
 
                else:
585
 
                  self.trash_full = False
586
 
 
587
 
              except:
588
 
                #Maybe the trash is in a different location? Just put false
589
 
                self.trash_full = False
590
 
 
591
 
              if self.trash_full:
592
 
                self.place('user-trash-full', name, path, _("Trash"))
593
 
 
594
 
              else:
595
 
                self.place('user-trash', name, path, _("Trash"))
596
 
 
597
615
            elif type == 'x-nautilus-search':
598
616
              self.place('search', name, path, _("Search"))
599
617
 
605
623
 
606
624
            #Default to folder
607
625
            else:
608
 
              self.place('stock_folder', name, path, _("Folder"))
 
626
              self.place('folder', name, path, _("Folder"))
 
627
 
 
628
  def do_trash(self):
 
629
    if self.show_trash:
 
630
      count = self.trash.props.file_count
 
631
      if count > 0:
 
632
        self.place('user-trash-full', _("Trash (%d)" % count), 'trash:///')
 
633
 
 
634
      else:
 
635
        self.place('user-trash', _("Trash"), 'trash:///')
 
636
 
 
637
      if gio:
 
638
        self.droppable_places.append('trash:///')
609
639
 
610
640
  #Function to show the home folder, mounted drives/partitions, and bookmarks according to config
611
641
  #This also refreshes in case a CD was inserted, MP3 player unplugged, bookmark added, etc.
641
671
      for line in self.fstab:
642
672
        try:
643
673
          if line.replace(' ','').replace('\t','') != '' and line[0] != "#":
644
 
 
645
674
            words = line.split(' ')
646
675
            for word in words[1:]:
647
676
              if word != '':
749
778
    self.paths.extend(self.dvd_paths)
750
779
 
751
780
    self.do_ncs()
752
 
 
753
781
    self.do_bookmarks()
 
782
    self.do_trash()
754
783
 
755
784
    if self.docklet_visible:
756
785
      self.update_docklet()
791
820
 
792
821
    #If no icon does exists - load default folder icon
793
822
    if not worked:
794
 
      if 'stock_folder' not in self.icons[size]:
795
 
        self.icons[size]['stock_folder'] = self.theme.load_icon('stock_folder', size, 0)
 
823
      if 'folder' not in self.icons[size]:
 
824
        self.icons[size]['folder'] = self.theme.load_icon('folder', size, 0)
796
825
 
797
 
      icon = self.icons[size]['stock_folder']
 
826
      icon = self.icons[size]['folder']
798
827
      self.icons[size][name] = icon
799
828
 
800
829
    else:
944
973
      icon.set_from_pixbuf(self.load_pixbuf(place[0], self.get_size()))
945
974
      icon.set_tooltip_text(place[1])
946
975
      icon.connect('clicked', self.docklet_icon_clicked, place[3])
 
976
      icon.connect('middle-clicked', self.docklet_icon_middle_clicked, place[3])
947
977
      icon.connect('context-menu-popup', self.docklet_icon_menu, place)
948
978
      box.add(icon)
949
979
      box.set_child_packing(icon, False, True, 0, gtk.PACK_START)
969
999
        dropped_paths = data.data.split('\n')
970
1000
        num_success = 0
971
1001
 
972
 
        for dropped_path in dropped_paths:
973
 
          if len(dropped_path) >= 8:
974
 
            if dropped_path[:8] == 'file:///':
975
 
              dropped_path = dropped_path.strip()
976
 
 
977
 
              dropped_path = urllib.unquote(dropped_path)
978
 
 
979
 
              from_file = gio.File(dropped_path)
980
 
 
981
 
              to_file = gio.File(path + '/' + from_file.get_basename())
982
 
 
983
 
              #Make sure we're not just moving the file to the same directory
984
 
              if not from_file.equal(to_file):
985
 
                if from_file.move(to_file):
986
 
                  num_success += 1
987
 
 
988
 
        if num_success > 0:
989
 
          config_fb = self.client.get_string(group, 'fb')
990
 
          open_dir = path.replace(' ', '\ ')
991
 
          os.system('%s %s &' % (config_fb, open_dir))
992
 
          self.dialog.hide()
 
1002
        if path == 'trash:///':
 
1003
          for dropped_path in dropped_paths:
 
1004
            from_file = vfs.File.for_uri(urllib.unquote(dropped_path).strip())
 
1005
            try:
 
1006
              self.trash.send_to_trash(from_file)
 
1007
            except:
 
1008
              pass
 
1009
 
 
1010
        else:
 
1011
          for dropped_path in dropped_paths:
 
1012
            if len(dropped_path) >= 8:
 
1013
              if dropped_path[:8] == 'file:///':
 
1014
                dropped_path = dropped_path.strip()
 
1015
 
 
1016
                dropped_path = urllib.unquote(dropped_path)
 
1017
 
 
1018
                from_file = gio.File(dropped_path)
 
1019
 
 
1020
                to_file = gio.File(path + '/' + from_file.get_basename())
 
1021
 
 
1022
                #Make sure we're not just moving the file to the same directory
 
1023
                if not from_file.equal(to_file):
 
1024
                  if from_file.move(to_file):
 
1025
                    num_success += 1
 
1026
 
 
1027
          if num_success > 0:
 
1028
            config_fb = self.client.get_string(group, 'fb')
 
1029
            open_dir = path.replace(' ', '\ ')
 
1030
            os.system('%s %s &' % (config_fb, open_dir))
 
1031
            self.dialog.hide()
993
1032
 
994
1033
      return True
995
1034
 
1012
1051
    if self.mode == 1:
1013
1052
      self.docklet.destroy()
1014
1053
 
 
1054
  def docklet_icon_middle_clicked(self, icon, uri):
 
1055
    if not os.path.isdir(uri.replace('file:///', '/')):
 
1056
      return False
 
1057
 
 
1058
    self.icon_dialog = awn.Dialog(icon, self)
 
1059
    self.icon_dialog.connect('focus-out-event', self.icon_dialog_focusout)
 
1060
 
 
1061
    self.icon_entry = gtk.Entry()
 
1062
    self.icon_entry.connect('key-release-event', self.detect_enter)
 
1063
    self.icon_entry.set_text(uri.replace('file:///', '/') + ['/', ''][uri[-1] == '/'])
 
1064
 
 
1065
    self.icon_enter = gtk.Button(stock=gtk.STOCK_OPEN)
 
1066
    self.icon_enter.connect('clicked', self.launch_fb, self.icon_entry)
 
1067
 
 
1068
    hbox = gtk.HBox()
 
1069
    hbox.pack_start(self.icon_entry)
 
1070
    hbox.pack_start(self.icon_enter, False)
 
1071
 
 
1072
    self.icon_dialog.add(hbox)
 
1073
    self.icon_dialog.show_all()
 
1074
 
 
1075
    self.icon_entry.grab_focus()
 
1076
    self.icon_entry.set_position(-1)
 
1077
 
 
1078
  def icon_dialog_focusout(self, widget, event):
 
1079
    widget.hide()
 
1080
 
 
1081
    gobject.timeout_add_seconds(1, widget.destroy)
 
1082
 
1015
1083
  def docklet_icon_menu(self, icon, event, place):
1016
1084
    menu = self.create_default_menu()
1017
1085
 
1018
 
    #If the place is ejectable
1019
 
    if place[2]:
1020
 
      eject = awn.image_menu_item_new_with_label(_("Eject"))
1021
 
      image = gtk.image_new_from_icon_name('media-eject', gtk.ICON_SIZE_MENU)
1022
 
      eject.set_image(image)
1023
 
      menu.append(eject)
1024
 
 
1025
 
      eject.connect('activate', self.docklet_menu_eject, place[4])
 
1086
    if place is not None:
 
1087
      #If the place is ejectable
 
1088
      if place[2]:
 
1089
        eject = awn.image_menu_item_new_with_label(_("Eject"))
 
1090
        image = gtk.image_new_from_icon_name('media-eject', gtk.ICON_SIZE_MENU)
 
1091
        eject.set_image(image)
 
1092
        menu.append(eject)
 
1093
 
 
1094
        eject.connect('activate', self.docklet_menu_eject, place[4])
 
1095
 
 
1096
      elif place[3] == 'trash:///':
 
1097
        empty = gtk.MenuItem(_("Empty Trash"))
 
1098
        menu.append(empty)
 
1099
 
 
1100
        if self.trash.props.file_count == 0:
 
1101
          empty.set_sensitive(False)
 
1102
 
 
1103
        empty.connect('activate', self.docklet_empty_trash)
1026
1104
 
1027
1105
    prefs = gtk.ImageMenuItem(gtk.STOCK_PREFERENCES)
1028
1106
    prefs.connect('activate', self.open_prefs)
1038
1116
  def docklet_menu_eject(self, menu, num):
1039
1117
    self.unmount(num)
1040
1118
 
 
1119
  def docklet_empty_trash(self, menu):
 
1120
    dialog = gtk.Dialog(_("Confirm deletion"), self, gtk.DIALOG_MODAL,
 
1121
      (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
 
1122
    dialog.set_icon_name('user-trash-full')
 
1123
 
 
1124
    vbox = gtk.VBox(False, 6)
 
1125
    vbox.set_border_width(12)
 
1126
 
 
1127
    label1 = gtk.Label()
 
1128
    label1.set_markup(_("<big><b>Are you sure you want to delete\nevery item from the trash?</b></big>"))
 
1129
 
 
1130
    label2 = gtk.Label(_("This action cannot be undone."))
 
1131
    label2.set_alignment(0.0, 0.0)
 
1132
 
 
1133
    vbox.pack_start(label1, False)
 
1134
    vbox.pack_start(label2, False)
 
1135
 
 
1136
    dialog.vbox.pack_start(vbox)
 
1137
    dialog.show_all()
 
1138
    response = dialog.run()
 
1139
    dialog.destroy()
 
1140
 
 
1141
    if response == gtk.RESPONSE_ACCEPT:
 
1142
      try:
 
1143
        self.trash.empty()
 
1144
      except:
 
1145
        pass
 
1146
 
1041
1147
  #The user changed the icon theme
1042
1148
  def icon_theme_changed(self, icon_theme):
1043
1149
    for d in self.icons.values():
1048
1154
      self.do_gio_places()
1049
1155
 
1050
1156
    #Reload the stock folder icon
1051
 
    self.icons[24]['stock_folder'] = self.theme.load_icon('stock_folder', 24, 0)
 
1157
    self.icons[24]['folder'] = self.theme.load_icon('folder', 24, 0)
1052
1158
 
1053
1159
  def dialog_config(self, button):
1054
1160
    #Left click data
1064
1170
    if action == 3:
1065
1171
      return
1066
1172
 
 
1173
    if path.strip() == '':
 
1174
        path = os.environ['HOME']
 
1175
 
 
1176
    if path[-1] != '/':
 
1177
        path += '/'
 
1178
 
1067
1179
    if not gio:
1068
1180
      self.add_places()
1069
1181
 
1086
1198
      else:
1087
1199
        self.entry.set_text(path)
1088
1200
 
1089
 
        if config_focus == 2:
1090
 
          self.entry.grab_focus()
1091
 
          self.entry.set_position(-1)
1092
 
 
 
1201
        self.treeview.show()
 
1202
        self.dialog.set_property('anchor', self.icon)
1093
1203
        self.dialog.show_all()
1094
1204
 
 
1205
        self.entry.grab_focus()
 
1206
        self.entry.set_position(-1)
 
1207
 
1095
1208
    #Launch path
1096
1209
    elif action == 2:
1097
1210
      self.launch_fb(None, path)
1121
1234
      self.update_docklet()
1122
1235
 
1123
1236
  #If the user hits the enter key on the main part OR the number pad
1124
 
  def detect_enter(self, a, event):
 
1237
  def detect_enter(self, widget, event):
1125
1238
    if event.keyval == 65293 or event.keyval == 65421:
1126
 
      self.enter.clicked()
 
1239
      if widget == self.entry:
 
1240
        self.enter.clicked()
 
1241
      else:
 
1242
        self.icon_enter.clicked()
1127
1243
 
1128
1244
  #Launces file browser to open "path". If "path" is None: use value from the entry widget
1129
1245
  def launch_fb(self, widget, path=None):
1130
1246
    self.dialog.hide()
1131
 
    if path == None:
 
1247
    if isinstance(path, gtk.Widget):
 
1248
      path = path.get_text()
 
1249
      self.icon_dialog.hide()
 
1250
      if self.mode == 1:
 
1251
        self.docklet.destroy()
 
1252
    elif path is None:
1132
1253
      path = self.entry.get_text()
1133
1254
 
1134
1255
    #Get the file browser app