load new uri




Hi,

Here is a nautilus extension, this opens the location bar with
the new uri when the scale is moved. However the Return event
propagation is not working so that it can load the new uri, any idea
whats wrong ?  Or what could be done to make this work ?

OR if you want to write a nautilus extension to replace the Home
button how would you write it ? Thanks.

----------------------------------------------------------------------------------------
#!/usr/bin/python

import gtk
import math
import nautilus

class EG(nautilus.LocationWidgetProvider):
    def __init__(self):
        print "Initializing EG"
        self.gui = gtk.Builder()
        self.gui.add_from_file("/root/.nautilus/python-extensions/eg.glade")
        self.hscale1 = self.gui.get_object("hscale1")
        self.adj1 = self.gui.get_object("adjustment1")
        self.adj1.set_upper(3)
        self.dirlist = ["DoNothing", "/tmp", "/etc"]
        for i in range(len(self.dirlist)):
            self.hscale1.add_mark(i,gtk.POS_BOTTOM,"")    
        self.gui.connect_signals(self)
        self.hscale1.unparent()
        return
   
    def get_widget(self, uri, window):
        self.window = window
        return self.hscale1
   
    def load_new_uri(self):
        self.window.emit("prompt-for-location",self.dirlist[self.pos])
        self.window.set_events(gtk.keysyms.Return)  <----
        return
   
    def on_adjustment1_value_changed(self, val=-1):
        self.pos = int(math.ceil(self.adj1.get_value()))
        self.adj1.set_value(self.pos)
        self.hscale1.clear_marks()
        for i in range(len(self.dirlist)):
            self.hscale1.add_mark(i,gtk.POS_BOTTOM,"")
        self.hscale1.add_mark(self.pos,gtk.POS_BOTTOM, self.dirlist[self.pos])
        self.load_new_uri()
        return
----------------------------------------------------------------------------------------

eg.glade:
--------------------------------------------------------------------------------------------
<?xml version="1.0"?>
<interface>
  <requires lib="gtk+" version="2.16"/>
  <!-- interface-naming-policy project-wide -->
  <object class="GtkWindow" id="window1">
    <child>
      <object class="GtkVBox" id="vbox1">
        <property name="visible">True</property>
        <property name="orientation">vertical</property>
        <child>
          <object class="GtkHScale" id="hscale1">
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <property name="update_policy">discontinuous</property>
            <property name="adjustment">adjustment1</property>
            <property name="inverted">True</property>
            <property name="restrict_to_fill_level">False</property>
            <property name="fill_level">0</property>
            <property name="digits">0</property>
            <property name="draw_value">False</property>
          </object>
          <packing>
            <property name="position">0</property>
          </packing>
        </child>
      </object>
    </child>
  </object>
  <object class="GtkAdjustment" id="adjustment1">
    <property name="value">1</property>
    <property name="upper">2.0299999997764826</property>
    <property name="step_increment">1</property>
    <property name="page_increment">1</property>
    <property name="page_size">1</property>
    <signal name="value_changed" handler="on_adjustment1_value_changed"/>
  </object>
</interface>
---------------------------------------------------------------------------------------------------------


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]