Merge pull request #162 from leigh123linux/master

Port to gtk3
This commit is contained in:
Clement Lefebvre 2017-04-28 12:04:14 +01:00 committed by GitHub
commit 931ccd73c6
17 changed files with 1381 additions and 1675 deletions

View File

@ -1,36 +0,0 @@
#!/usr/bin/python2
import gi
import ctypes
from ctypes import *
libgobject = CDLL('libgobject-2.0.so.0')
class _PyGObject_Functions(ctypes.Structure):
_fields_ = [
('register_class',
ctypes.PYFUNCTYPE(ctypes.c_void_p, ctypes.c_char_p,
ctypes.c_int, ctypes.py_object,
ctypes.py_object)),
('register_wrapper',
ctypes.PYFUNCTYPE(ctypes.c_void_p, ctypes.py_object)),
('lookup_class',
ctypes.PYFUNCTYPE(ctypes.py_object, ctypes.c_int)),
('newgobj',
ctypes.PYFUNCTYPE(ctypes.py_object, ctypes.c_void_p)),
]
class PyGObjectCPAI(object):
def __init__(self):
PyCObject_AsVoidPtr = ctypes.pythonapi.PyCObject_AsVoidPtr
PyCObject_AsVoidPtr.restype = ctypes.c_void_p
PyCObject_AsVoidPtr.argtypes = [ctypes.py_object]
addr = PyCObject_AsVoidPtr(ctypes.py_object(
gi._gobject._PyGObject_API))
self._api = _PyGObject_Functions.from_address(addr)
def pygobject_new(self, addr):
return self._api.newgobj(addr)
def get_widget(ptr):
return PyGObjectCPAI().pygobject_new(ptr)

View File

@ -25,18 +25,14 @@
# DEALINGS IN THE SOFTWARE. # DEALINGS IN THE SOFTWARE.
import gi import gi
gi.require_version("Gtk", "2.0") gi.require_version("Gtk", "3.0")
from Xlib.display import Display from Xlib.display import Display
from Xlib import X, error from Xlib import X, error
from gi.repository import Gtk, Gdk, GObject, GLib from gi.repository import Gtk, Gdk, GdkX11, GObject, GLib
import threading import threading
import ctypes import ctypes
from ctypes import * from ctypes import *
import capi
gdk = CDLL("libgdk-x11-2.0.so.0")
gtk = CDLL("libgtk-x11-2.0.so.0")
SPECIAL_MODS = (["Super_L", "<Super>"], SPECIAL_MODS = (["Super_L", "<Super>"],
["Super_R", "<Super>"], ["Super_R", "<Super>"],
@ -57,8 +53,7 @@ class GlobalKeyBinding(GObject.GObject, threading.Thread):
threading.Thread.__init__ (self) threading.Thread.__init__ (self)
self.setDaemon (True) self.setDaemon (True)
gdk.gdk_keymap_get_default.restype = c_void_p self.keymap = Gdk.Keymap().get_default()
self.keymap = capi.get_widget (gdk.gdk_keymap_get_default())
self.display = Display() self.display = Display()
self.screen = self.display.screen() self.screen = self.display.screen()
self.window = self.screen.root self.window = self.screen.root
@ -90,12 +85,7 @@ class GlobalKeyBinding(GObject.GObject, threading.Thread):
self.known_modifiers_mask |= modifier self.known_modifiers_mask |= modifier
def get_keycode(self, keyval): def get_keycode(self, keyval):
count = c_int() return self.keymap.get_entries_for_keyval(keyval).keys[0].keycode
array = (KeymapKey * 10)()
keys = cast(array, POINTER(KeymapKey))
gdk.gdk_keymap_get_entries_for_keyval.argtypes = [c_void_p, c_uint, c_void_p, c_void_p]
gdk.gdk_keymap_get_entries_for_keyval(hash(self.keymap), keyval, byref(keys), byref(count))
return keys[0].keycode
def grab(self, key): def grab(self, key):
accelerator = key accelerator = key
@ -137,8 +127,7 @@ class GlobalKeyBinding(GObject.GObject, threading.Thread):
if window is None: if window is None:
self.window = self.screen.root self.window = self.screen.root
else: else:
gdk.gdk_x11_drawable_get_xid.argtypes = [c_void_p] self.window = self.display.create_resource_object("window", window.get_xid())
self.window = self.display.create_resource_object("window", gdk.gdk_x11_drawable_get_xid(hash(window)))
self.grab(self.keytext) self.grab(self.keytext)
def get_mask_combinations(self, mask): def get_mask_combinations(self, mask):
@ -185,7 +174,7 @@ class KeymapKey(Structure):
("group", c_int), ("group", c_int),
("level", c_int)] ("level", c_int)]
class KeybindingWidget(Gtk.HBox): class KeybindingWidget(Gtk.Box):
__gsignals__ = { __gsignals__ = {
'accel-edited': (GObject.SignalFlags.RUN_LAST, None, ()), 'accel-edited': (GObject.SignalFlags.RUN_LAST, None, ()),
} }
@ -235,8 +224,7 @@ class KeybindingWidget(Gtk.HBox):
self.set_button_text() self.set_button_text()
self.emit("accel-edited") self.emit("accel-edited")
return True return True
gtk.gtk_accelerator_name.restype = c_char_p accel_string = Gtk.accelerator_name( event.keyval, event.state )
accel_string = gtk.gtk_accelerator_name(event.keyval, event.state)
accel_string = self.sanitize(accel_string) accel_string = self.sanitize(accel_string)
self.value = accel_string self.value = accel_string
self.set_button_text() self.set_button_text()

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<interface> <interface>
<!-- interface-requires gtk+ 2.10 --> <requires lib="gtk+" version="3.0"/>
<!-- interface-naming-policy toplevel-contextual -->
<object class="GtkWindow" id="mainWindow"> <object class="GtkWindow" id="mainWindow">
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK</property>
@ -16,9 +15,10 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<child> <child>
<object class="GtkHBox" id="paneholder"> <object class="GtkBox" id="paneholder">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="orientation">horizontal</property>
<child> <child>
<placeholder/> <placeholder/>
</child> </child>

View File

@ -1,7 +1,7 @@
#!/usr/bin/python2 #!/usr/bin/python2
import gi import gi
gi.require_version("Gtk", "2.0") gi.require_version("Gtk", "3.0")
gi.require_version('MatePanelApplet', '4.0') gi.require_version('MatePanelApplet', '4.0')
from gi.repository import Gtk, GdkPixbuf, Gdk, GObject from gi.repository import Gtk, GdkPixbuf, Gdk, GObject
from gi.repository import MatePanelApplet from gi.repository import MatePanelApplet
@ -23,8 +23,6 @@ import setproctitle
GObject.threads_init() GObject.threads_init()
gdk = CDLL("libgdk-x11-2.0.so.0")
# Rename the process # Rename the process
setproctitle.setproctitle('mintmenu') setproctitle.setproctitle('mintmenu')
@ -63,7 +61,7 @@ class MainWindow( object ):
builder.add_from_file(os.path.join( self.path, "mintMenu.glade" )) builder.add_from_file(os.path.join( self.path, "mintMenu.glade" ))
self.window = builder.get_object( "mainWindow" ) self.window = builder.get_object( "mainWindow" )
self.window.realize() self.window.realize()
self.window.window.set_decorations(Gdk.WMDecoration.BORDER) self.window.get_window().set_decorations(Gdk.WMDecoration.BORDER)
self.window.set_title("") self.window.set_title("")
self.paneholder = builder.get_object( "paneholder" ) self.paneholder = builder.get_object( "paneholder" )
self.border = builder.get_object( "border" ) self.border = builder.get_object( "border" )
@ -97,11 +95,11 @@ class MainWindow( object ):
self.getSetGSettingEntries() self.getSetGSettingEntries()
self.tooltips = Gtk.Tooltips() self.tooltipsWidgets = []
if self.globalEnableTooltips and self.enableTooltips: if self.globalEnableTooltips and self.enableTooltips:
self.tooltips.enable() self.tooltipsEnable()
else: else:
self.tooltips.disable() self.tooltipsEnable( False )
self.PopulatePlugins(); self.PopulatePlugins();
self.firstTime = True; self.firstTime = True;
@ -123,9 +121,9 @@ class MainWindow( object ):
self.enableTooltips = settings.get_boolean(key) self.enableTooltips = settings.get_boolean(key)
if self.globalEnableTooltips and self.enableTooltips: if self.globalEnableTooltips and self.enableTooltips:
self.tooltips.enable() self.tooltipsEnable()
else: else:
self.tooltips.disable() self.tooltipsEnable( False )
def toggleStartWithFavorites( self, settings, key, args = None ): def toggleStartWithFavorites( self, settings, key, args = None ):
self.startWithFavorites = settings.get_boolean(key) self.startWithFavorites = settings.get_boolean(key)
@ -165,11 +163,14 @@ class MainWindow( object ):
self.globalEnableTooltips = self.panelSettings.get_boolean( "tooltips-enabled" ) self.globalEnableTooltips = self.panelSettings.get_boolean( "tooltips-enabled" )
def SetupMintMenuBorder( self, defaultStyle = None ): def SetupMintMenuBorder( self, color = None ):
context = self.window.get_style_context()
if self.usecustomcolor: if self.usecustomcolor:
self.window.modify_bg( Gtk.StateType.NORMAL, Gdk.color_parse( self.custombordercolor ) ) borderColor = Gdk.RGBA()
elif defaultStyle is not None: borderColor.parse( self.custombordercolor )
self.window.modify_bg( Gtk.StateType.NORMAL, defaultStyle.lookup_color('bg_color')[1] ) self.window.override_background_color( context.get_state(), borderColor )
elif color is not None:
self.window.override_background_color( context.get_state(), color )
self.border.set_padding( self.borderwidth, self.borderwidth, self.borderwidth, self.borderwidth ) self.border.set_padding( self.borderwidth, self.borderwidth, self.borderwidth, self.borderwidth )
def PopulatePlugins( self ): def PopulatePlugins( self ):
@ -178,7 +179,7 @@ class MainWindow( object ):
start = time.time() start = time.time()
PluginPane = Gtk.EventBox() PluginPane = Gtk.EventBox()
PluginPane.show() PluginPane.show()
PaneLadder = Gtk.VBox( False, 0 ) PaneLadder = Gtk.Box( orientation=Gtk.Orientation.VERTICAL )
PluginPane.add( PaneLadder ) PluginPane.add( PaneLadder )
ImageBox = Gtk.EventBox() ImageBox = Gtk.EventBox()
ImageBox.show() ImageBox.show()
@ -239,7 +240,7 @@ class MainWindow( object ):
self.panesToColor.append( MyPlugin.content_holder ) self.panesToColor.append( MyPlugin.content_holder )
MyPlugin.content_holder.show() MyPlugin.content_holder.show()
VBox1 = Gtk.VBox( False, 0 ) VBox1 = Gtk.Box( orientation=Gtk.Orientation.VERTICAL )
if MyPlugin.heading != "": if MyPlugin.heading != "":
Label1 = Gtk.Label(label= MyPlugin.heading ) Label1 = Gtk.Label(label= MyPlugin.heading )
Align1 = Gtk.Alignment.new( 0, 0, 0, 0 ) Align1 = Gtk.Alignment.new( 0, 0, 0, 0 )
@ -255,7 +256,7 @@ class MainWindow( object ):
heading.set_visible_window( False ) heading.set_visible_window( False )
heading.set_size_request( MyPlugin.width, 30 ) heading.set_size_request( MyPlugin.width, 30 )
else: else:
heading = Gtk.HBox() heading = Gtk.Box( orientation=Gtk.Orientation.HORIZONTAL )
#heading.set_relief( Gtk.ReliefStyle.NONE ) #heading.set_relief( Gtk.ReliefStyle.NONE )
heading.set_size_request( MyPlugin.width, -1 ) heading.set_size_request( MyPlugin.width, -1 )
#heading.set_sensitive(False) #heading.set_sensitive(False)
@ -266,14 +267,17 @@ class MainWindow( object ):
VBox1.pack_start( heading, False, False, 0 ) VBox1.pack_start( heading, False, False, 0 )
VBox1.show() VBox1.show()
#Add plugin to Plugin Box under heading button #Add plugin to Plugin Box under heading button
MyPlugin.content_holder.reparent( VBox1 ) MyPlugin.content_holder.get_parent().remove(MyPlugin.content_holder)
VBox1.add( MyPlugin.content_holder )
#Add plugin to main window #Add plugin to main window
PaneLadder.pack_start( VBox1 , True, True, 0) PaneLadder.pack_start( VBox1 , True, True, 0)
PaneLadder.show() PaneLadder.show()
if MyPlugin.window: try:
MyPlugin.window.destroy() MyPlugin.get_window().destroy()
except AttributeError:
pass
try: try:
if hasattr( MyPlugin, 'do_plugin' ): if hasattr( MyPlugin, 'do_plugin' ):
@ -299,7 +303,7 @@ class MainWindow( object ):
self.paneholder.pack_start( ImageBox, False, False, 0 ) self.paneholder.pack_start( ImageBox, False, False, 0 )
self.paneholder.pack_start( PluginPane, False, False, 0 ) self.paneholder.pack_start( PluginPane, False, False, 0 )
PluginPane = Gtk.EventBox() PluginPane = Gtk.EventBox()
PaneLadder = Gtk.VBox( False, 0 ) PaneLadder = Gtk.Box( orientation=Gtk.Orientation.VERTICAL )
PluginPane.add( PaneLadder ) PluginPane.add( PaneLadder )
ImageBox = Gtk.EventBox() ImageBox = Gtk.EventBox()
self.panesToColor.extend( [ PluginPane, ImageBox ] ) self.panesToColor.extend( [ PluginPane, ImageBox ] )
@ -321,31 +325,39 @@ class MainWindow( object ):
self.paneholder.pack_start( ImageBox, False, False, 0 ) self.paneholder.pack_start( ImageBox, False, False, 0 )
self.paneholder.pack_start( PluginPane, False, False, 0 ) self.paneholder.pack_start( PluginPane, False, False, 0 )
self.tooltips.disable() self.tooltipsEnable( False )
#print u"Loading", (time.time() - start), "s"
# A little hacky but works # A little bit hacky but works.
def getDefaultStyle( self ): def getDefaultColors( self ):
widget = Gtk.EventBox() widget = Gtk.EventBox()
widget.show() widget.show()
return Gtk.rc_get_style(widget)
context = widget.get_style_context()
context.set_state( Gtk.StateFlags.NORMAL )
context.add_class( Gtk.STYLE_CLASS_DEFAULT )
context.add_class( Gtk.STYLE_CLASS_BACKGROUND )
fgColor = context.get_color( context.get_state() )
bgColor = context.get_background_color( context.get_state() )
borderColor = context.get_border_color( context.get_state() )
return { "fg": fgColor, "bg": bgColor, "border": borderColor }
def loadTheme( self ): def loadTheme( self ):
defaultStyle = self.getDefaultStyle() colors = self.getDefaultColors()
self.SetPaneColors( self.panesToColor, defaultStyle ) self.SetPaneColors( self.panesToColor, colors["bg"] )
self.SetupMintMenuBorder( defaultStyle ) self.SetupMintMenuBorder( colors["border"] )
self.SetHeadingStyle( self.headingsToColor ) self.SetHeadingStyle( self.headingsToColor )
def SetPaneColors( self, items, defaultStyle = None ): def SetPaneColors( self, items, color = None ):
for item in items:
context = item.get_style_context()
if self.usecustomcolor: if self.usecustomcolor:
for item in items: bgColor = Gdk.RGBA()
item.modify_bg( Gtk.StateType.NORMAL, Gdk.color_parse( self.customcolor ) ) bgColor.parse( self.customcolor )
# TODO: Changing background color isn't working for pixmaps! The following does not work: item.override_background_color( context.get_state(), bgColor )
item.get_style().bg_pixmap[Gtk.StateType.NORMAL] = None elif color is not None:
elif defaultStyle is not None: item.override_background_color( context.get_state(), color )
for item in items:
item.modify_bg( Gtk.StateType.NORMAL, defaultStyle.lookup_color('bg_color')[1] )
item.get_style().bg_pixmap[Gtk.StateType.NORMAL] = defaultStyle.bg_pixmap[Gtk.StateType.NORMAL]
def SetHeadingStyle( self, items ): def SetHeadingStyle( self, items ):
if self.usecustomcolor: if self.usecustomcolor:
@ -362,8 +374,13 @@ class MainWindow( object ):
markup = '<span size="12000" weight="bold" color="%s">%s</span>' % (color, text) markup = '<span size="12000" weight="bold" color="%s">%s</span>' % (color, text)
item.set_markup( markup ) item.set_markup( markup )
def setTooltip( self, widget, tip, tipPrivate = None ): def tooltipsEnable( self, enable = True ):
self.tooltips.set_tip( widget, tip, tipPrivate ) for widget in self.tooltipsWidgets:
widget.set_has_tooltip( enable )
def setTooltip( self, widget, tip ):
self.tooltipsWidgets.append( widget )
widget.set_tooltip_text( tip )
def RegenPlugins( self, *args, **kargs ): def RegenPlugins( self, *args, **kargs ):
#print #print
@ -407,7 +424,7 @@ class MainWindow( object ):
self.firstTime = False self.firstTime = False
self.window.set_opacity(1.0) self.window.set_opacity(1.0)
self.window.window.focus( Gdk.CURRENT_TIME ) self.window.get_window().focus( Gdk.CURRENT_TIME )
for plugin in self.plugins.values(): for plugin in self.plugins.values():
if hasattr( plugin, "onShowMenu" ): if hasattr( plugin, "onShowMenu" ):
@ -488,20 +505,18 @@ class MenuWin( object ):
self.pointerMonitor.connect("activate", self.onPointerOutside) self.pointerMonitor.connect("activate", self.onPointerOutside)
def onWindowMap( self, *args ): def onWindowMap( self, *args ):
self.applet.set_state( Gtk.StateType.SELECTED ) self.applet.get_style_context().set_state( Gtk.StateFlags.SELECTED )
self.keybinder.set_focus_window( self.mainwin.window.window ) self.keybinder.set_focus_window( self.mainwin.window.get_window() )
#self.pointerMonitor.grabPointer()
return False return False
def onWindowUnmap( self, *args ): def onWindowUnmap( self, *args ):
self.applet.set_state( Gtk.StateType.NORMAL ) self.applet.get_style_context().set_state( Gtk.StateFlags.NORMAL )
self.keybinder.set_focus_window() self.keybinder.set_focus_window()
#self.pointerMonitor.ungrabPointer()
return False return False
def onRealize( self, *args): def onRealize( self, *args):
self.pointerMonitor.addWindowToMonitor( self.mainwin.window.window ) self.pointerMonitor.addWindowToMonitor( self.mainwin.window.get_window() )
self.pointerMonitor.addWindowToMonitor( self.applet.window ) self.pointerMonitor.addWindowToMonitor( self.applet.get_window() )
self.pointerMonitor.start() self.pointerMonitor.start()
return False return False
@ -518,8 +533,8 @@ class MenuWin( object ):
def leave_notify(self, applet, event): def leave_notify(self, applet, event):
# Hack for mate-panel-test-applets focus issue (this can be commented) # Hack for mate-panel-test-applets focus issue (this can be commented)
if event.state & Gdk.ModifierType.BUTTON1_MASK and applet.state & Gtk.StateType.SELECTED: if event.state & Gdk.ModifierType.BUTTON1_MASK and applet.get_style_context().get_state() & Gtk.StateFlags.SELECTED:
if event.x >= 0 and event.y >= 0 and event.x < applet.window.get_width() and event.y < applet.window.get_height(): if event.x >= 0 and event.y >= 0 and event.x < applet.get_window().get_width() and event.y < applet.get_window().get_height():
self.mainwin.stopHiding() self.mainwin.stopHiding()
self.do_image(self.buttonIcon, False) self.do_image(self.buttonIcon, False)
@ -546,19 +561,19 @@ class MenuWin( object ):
self.systemlabel.set_tooltip_text(tooltip) self.systemlabel.set_tooltip_text(tooltip)
self.button_icon.set_tooltip_text(tooltip) self.button_icon.set_tooltip_text(tooltip)
if self.applet.get_orient() == MatePanelApplet.AppletOrient.UP or self.applet.get_orient() == MatePanelApplet.AppletOrient.DOWN: if self.applet.get_orient() == MatePanelApplet.AppletOrient.UP or self.applet.get_orient() == MatePanelApplet.AppletOrient.DOWN:
self.button_box = Gtk.HBox() self.button_box = Gtk.Box( orientation=Gtk.Orientation.HORIZONTAL )
self.button_box.pack_start( self.button_icon, False, False, 0 ) self.button_box.pack_start( self.button_icon, False, False, 0 )
self.button_box.pack_start( self.systemlabel, False, False, 0 ) self.button_box.pack_start( self.systemlabel, False, False, 0 )
self.button_icon.set_padding( 5, 0 ) self.button_icon.set_padding( 5, 0 )
# if we have a vertical panel # if we have a vertical panel
elif self.applet.get_orient() == MatePanelApplet.AppletOrient.LEFT: elif self.applet.get_orient() == MatePanelApplet.AppletOrient.LEFT:
self.button_box = Gtk.VBox() self.button_box = Gtk.Box( orientation=Gtk.Orientation.VERTICAL )
self.systemlabel.set_angle( 270 ) self.systemlabel.set_angle( 270 )
self.button_box.pack_start( self.button_icon , False, False, 0) self.button_box.pack_start( self.button_icon , False, False, 0)
self.button_box.pack_start( self.systemlabel , False, False, 0) self.button_box.pack_start( self.systemlabel , False, False, 0)
self.button_icon.set_padding( 0, 5 ) self.button_icon.set_padding( 0, 5 )
elif self.applet.get_orient() == MatePanelApplet.AppletOrient.RIGHT: elif self.applet.get_orient( orientation=Gtk.Orientation.VERTICAL ) == MatePanelApplet.AppletOrient.RIGHT:
self.button_box = Gtk.VBox() self.button_box = Gtk.Box()
self.systemlabel.set_angle( 90 ) self.systemlabel.set_angle( 90 )
self.button_box.pack_start( self.systemlabel , False, False, 0) self.button_box.pack_start( self.systemlabel , False, False, 0)
self.button_box.pack_start( self.button_icon , False, False, 0) self.button_box.pack_start( self.button_icon , False, False, 0)
@ -600,17 +615,17 @@ class MenuWin( object ):
def changeOrientation( self, *args, **kargs ): def changeOrientation( self, *args, **kargs ):
if self.applet.get_orient() == MatePanelApplet.AppletOrient.UP or self.applet.get_orient() == MatePanelApplet.AppletOrient.DOWN: if self.applet.get_orient() == MatePanelApplet.AppletOrient.UP or self.applet.get_orient() == MatePanelApplet.AppletOrient.DOWN:
tmpbox = Gtk.HBox() tmpbox = Gtk.Box( orientation=Gtk.Orientation.HORIZONTAL )
self.systemlabel.set_angle( 0 ) self.systemlabel.set_angle( 0 )
self.button_box.reorder_child( self.button_icon, 0 ) self.button_box.reorder_child( self.button_icon, 0 )
self.button_icon.set_padding( 5, 0 ) self.button_icon.set_padding( 5, 0 )
elif self.applet.get_orient() == MatePanelApplet.AppletOrient.LEFT: elif self.applet.get_orient() == MatePanelApplet.AppletOrient.LEFT:
tmpbox = Gtk.VBox() tmpbox = Gtk.Box( orientation=Gtk.Orientation.VERTICAL )
self.systemlabel.set_angle( 270 ) self.systemlabel.set_angle( 270 )
self.button_box.reorder_child( self.button_icon, 0 ) self.button_box.reorder_child( self.button_icon, 0 )
self.button_icon.set_padding( 0, 5 ) self.button_icon.set_padding( 0, 5 )
elif self.applet.get_orient() == MatePanelApplet.AppletOrient.RIGHT: elif self.applet.get_orient() == MatePanelApplet.AppletOrient.RIGHT:
tmpbox = Gtk.VBox() tmpbox = Gtk.Box( orientation=Gtk.Orientation.VERTICAL )
self.systemlabel.set_angle( 90 ) self.systemlabel.set_angle( 90 )
self.button_box.reorder_child( self.button_icon, 1 ) self.button_box.reorder_child( self.button_icon, 1 )
self.button_icon.set_padding( 0, 5 ) self.button_icon.set_padding( 0, 5 )
@ -662,10 +677,8 @@ class MenuWin( object ):
self.button_icon.show() self.button_icon.show()
# This code calculates width and height for the button_box # This code calculates width and height for the button_box
# and takes the orientation in account # and takes the orientation in account
sl_req = Gtk.Requisition() bi_req = self.button_icon.size_request()
bi_req = Gtk.Requisition() sl_req = self.systemlabel.size_request()
self.button_icon.size_request(bi_req)
self.systemlabel.size_request(sl_req)
if self.applet.get_orient() == MatePanelApplet.AppletOrient.UP or self.applet.get_orient() == MatePanelApplet.AppletOrient.DOWN: if self.applet.get_orient() == MatePanelApplet.AppletOrient.UP or self.applet.get_orient() == MatePanelApplet.AppletOrient.DOWN:
if self.hideIcon: if self.hideIcon:
self.applet.set_size_request( sl_req.width + 2, bi_req.height ) self.applet.set_size_request( sl_req.width + 2, bi_req.height )
@ -725,7 +738,7 @@ class MenuWin( object ):
self.mainwin.hide() self.mainwin.hide()
def toggleMenu( self ): def toggleMenu( self ):
if self.applet.state & Gtk.StateType.SELECTED: if self.applet.get_style_context().get_state() & Gtk.StateFlags.SELECTED:
self.mainwin.hide() self.mainwin.hide()
else: else:
self.positionMenu() self.positionMenu()
@ -743,10 +756,8 @@ class MenuWin( object ):
x = c_int() x = c_int()
y = c_int() y = c_int()
# Get the dimensions/position of the widgetToAlignWith # Get the dimensions/position of the widgetToAlignWith
gdk.gdk_window_get_origin.argtypes = [c_void_p, c_void_p, c_void_p] entryX = self.applet.get_window().get_origin().x
gdk.gdk_window_get_origin(hash(self.applet.window), byref(x), byref(y)) entryY = self.applet.get_window().get_origin().y
entryX = x.value
entryY = y.value
entryWidth, entryHeight = self.applet.get_allocation().width, self.applet.get_allocation().height entryWidth, entryHeight = self.applet.get_allocation().width, self.applet.get_allocation().height
entryHeight = entryHeight + self.mainwin.offset entryHeight = entryHeight + self.mainwin.offset
@ -785,17 +796,17 @@ class MenuWin( object ):
# this callback is to create a context menu # this callback is to create a context menu
def create_menu(self): def create_menu(self):
action_group = Gtk.ActionGroup("context-menu") action_group = Gtk.ActionGroup(name="context-menu")
action = Gtk.Action("MintMenuPrefs", _("Preferences"), None, "gtk-preferences") action = Gtk.Action(name="MintMenuPrefs", label=_("Preferences"), tooltip=None, stock_id="gtk-preferences")
action.connect("activate", self.showPreferences) action.connect("activate", self.showPreferences)
action_group.add_action(action) action_group.add_action(action)
action = Gtk.Action("MintMenuEdit", _("Edit menu"), None, "gtk-edit") action = Gtk.Action(name="MintMenuEdit", label=_("Edit menu"), tooltip=None, stock_id="gtk-edit")
action.connect("activate", self.showMenuEditor) action.connect("activate", self.showMenuEditor)
action_group.add_action(action) action_group.add_action(action)
action = Gtk.Action("MintMenuReload", _("Reload plugins"), None, "gtk-refresh") action = Gtk.Action(name="MintMenuReload", label=_("Reload plugins"), tooltip=None, stock_id="gtk-refresh")
action.connect("activate", self.mainwin.RegenPlugins) action.connect("activate", self.mainwin.RegenPlugins)
action_group.add_action(action) action_group.add_action(action)
action = Gtk.Action("MintMenuAbout", _("About"), None, "gtk-about") action = Gtk.Action(name="MintMenuAbout", label=_("About"), tooltip=None, stock_id="gtk-about")
action.connect("activate", self.showAboutDialog) action.connect("activate", self.showAboutDialog)
action_group.add_action(action) action_group.add_action(action)
action_group.set_translation_domain ("mintmenu") action_group.set_translation_domain ("mintmenu")

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,7 @@
import sys import sys
import gi import gi
gi.require_version("Gtk", "2.0") gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, Gdk, GdkPixbuf from gi.repository import Gtk, Gdk, GdkPixbuf
import keybinding import keybinding
@ -63,7 +63,7 @@ class mintMenuConfig( object ):
self.builder.get_object("buttonTextLabel").set_text(_("Button text:")) self.builder.get_object("buttonTextLabel").set_text(_("Button text:"))
self.builder.get_object("label1").set_text(_("Options")) self.builder.get_object("label1").set_text(_("Options"))
self.builder.get_object("label23").set_text(_("Applications")) self.builder.get_object("applicationsLabel").set_text(_("Applications"))
self.builder.get_object("colorsLabel").set_text(_("Theme")) self.builder.get_object("colorsLabel").set_text(_("Theme"))
self.builder.get_object("favLabel").set_text(_("Favorites")) self.builder.get_object("favLabel").set_text(_("Favorites"))
@ -143,8 +143,8 @@ class mintMenuConfig( object ):
self.enableInternetSearch = self.builder.get_object( "enableInternetSearch" ) self.enableInternetSearch = self.builder.get_object( "enableInternetSearch" )
self.buttonText = self.builder.get_object( "buttonText" ) self.buttonText = self.builder.get_object( "buttonText" )
self.hotkeyWidget = keybinding.KeybindingWidget(_("Keyboard shortcut:") ) self.hotkeyWidget = keybinding.KeybindingWidget(_("Keyboard shortcut:") )
table = self.builder.get_object( "main_table" ) grid = self.builder.get_object( "main_grid" )
table.attach(self.hotkeyWidget, 0, 2, 2, 3, Gtk.AttachOptions.FILL, Gtk.AttachOptions.FILL, 0, 0) grid.attach(self.hotkeyWidget, 0, 2, 2, 1)
self.buttonIcon = self.builder.get_object( "buttonIcon" ) self.buttonIcon = self.builder.get_object( "buttonIcon" )
self.buttonIconChooser = self.builder.get_object( "button_icon_chooser" ) self.buttonIconChooser = self.builder.get_object( "button_icon_chooser" )
self.image_filter = Gtk.FileFilter() self.image_filter = Gtk.FileFilter()
@ -217,9 +217,9 @@ class mintMenuConfig( object ):
self.bindGSettingsValueToWidget( self.settings, "int", "border-width", self.borderWidth, "value-changed", self.borderWidth.set_value, self.borderWidth.get_value_as_int ) self.bindGSettingsValueToWidget( self.settings, "int", "border-width", self.borderWidth, "value-changed", self.borderWidth.set_value, self.borderWidth.get_value_as_int )
self.bindGSettingsValueToWidget( self.settings, "bool", "use-custom-color", self.useCustomColors, "toggled", self.useCustomColors.set_active, self.useCustomColors.get_active ) self.bindGSettingsValueToWidget( self.settings, "bool", "use-custom-color", self.useCustomColors, "toggled", self.useCustomColors.set_active, self.useCustomColors.get_active )
self.bindGSettingsValueToWidget( self.settings, "color", "custom-color", self.backgroundColor, "color-set", self.backgroundColor.set_color, self.getBackgroundColor ) self.bindGSettingsValueToWidget( self.settings, "color", "custom-color", self.backgroundColor, "color-set", self.backgroundColor.set_rgba, self.getBackgroundColor )
self.bindGSettingsValueToWidget( self.settings, "color", "custom-heading-color", self.headingColor, "color-set", self.headingColor.set_color, self.getHeadingColor ) self.bindGSettingsValueToWidget( self.settings, "color", "custom-heading-color", self.headingColor, "color-set", self.headingColor.set_rgba, self.getHeadingColor )
self.bindGSettingsValueToWidget( self.settings, "color", "custom-border-color", self.borderColor, "color-set", self.borderColor.set_color, self.getBorderColor ) self.bindGSettingsValueToWidget( self.settings, "color", "custom-border-color", self.borderColor, "color-set", self.borderColor.set_rgba, self.getBorderColor )
self.bindGSettingsValueToWidget( self.settings, "bool", "hide-applet-icon", self.showButtonIcon, "toggled", self.setShowButtonIcon, self.getShowButtonIcon ) self.bindGSettingsValueToWidget( self.settings, "bool", "hide-applet-icon", self.showButtonIcon, "toggled", self.setShowButtonIcon, self.getShowButtonIcon )
self.bindGSettingsValueToWidget( self.settings, "string", "applet-text", self.buttonText, "changed", self.buttonText.set_text, self.buttonText.get_text ) self.bindGSettingsValueToWidget( self.settings, "string", "applet-text", self.buttonText, "changed", self.buttonText.set_text, self.buttonText.get_text )
self.bindGSettingsValueToWidget( self.settings, "string", "hot-key", self.hotkeyWidget, "accel-edited", self.hotkeyWidget.set_val, self.hotkeyWidget.get_val ) self.bindGSettingsValueToWidget( self.settings, "string", "hot-key", self.hotkeyWidget, "accel-edited", self.hotkeyWidget.set_val, self.hotkeyWidget.get_val )
@ -355,7 +355,9 @@ class mintMenuConfig( object ):
def bindGSettingsValueToWidget( self, settings, setting_type, key, widget, changeEvent, setter, getter ): def bindGSettingsValueToWidget( self, settings, setting_type, key, widget, changeEvent, setter, getter ):
settings.notifyAdd( key, self.callSetter, args = [ setting_type, setter ] ) settings.notifyAdd( key, self.callSetter, args = [ setting_type, setter ] )
if setting_type == "color": if setting_type == "color":
setter( Gdk.color_parse( settings.get( setting_type, key ) ) ) color = Gdk.RGBA()
color.parse( settings.get( setting_type, key ) )
setter( color )
else: else:
setter( settings.get( setting_type, key ) ) setter( settings.get( setting_type, key ) )
widget.connect( changeEvent, lambda *args: self.callGetter( settings, setting_type, key, getter ) ) widget.connect( changeEvent, lambda *args: self.callGetter( settings, setting_type, key, getter ) )
@ -368,7 +370,9 @@ class mintMenuConfig( object ):
elif args[0] == "int": elif args[0] == "int":
args[1]( settings.get_int(key) ) args[1]( settings.get_int(key) )
elif args[0] == "color": elif args[0] == "color":
args[1]( Gdk.color_parse( settings.get_string(key) ) ) color = Gdk.RGBA()
color.parse( settings.get_string(key) )
args[1]( color )
def callGetter( self, settings, setting_type, key, getter ): def callGetter( self, settings, setting_type, key, getter ):
if (setting_type == "int"): if (setting_type == "int"):
@ -385,31 +389,19 @@ class mintMenuConfig( object ):
self.headingColorLabel.set_sensitive( widget.get_active() ) self.headingColorLabel.set_sensitive( widget.get_active() )
def getBackgroundColor( self ): def getBackgroundColor( self ):
try: color = self.backgroundColor.get_rgba()
color = self.backgroundColor.get_color() return self.gdkRGBAToString( color )
except:
color = Gdk.Color(0, 0, 0)
self.backgroundColor.get_color(color)
return self.gdkColorToString( color )
def getBorderColor( self ): def getBorderColor( self ):
try: color = self.borderColor.get_rgba()
color = self.borderColor.get_color() return self.gdkRGBAToString( color )
except:
color = Gdk.Color(0, 0, 0)
self.borderColor.get_color(color)
return self.gdkColorToString( color )
def getHeadingColor( self ): def getHeadingColor( self ):
try: color = self.headingColor.get_rgba()
color = self.headingColor.get_color() return self.gdkRGBAToString( color )
except:
color = Gdk.Color(0, 0, 0)
self.headingColor.get_color(color)
return self.gdkColorToString( color )
def gdkColorToString( self, gdkColor ): def gdkRGBAToString( self, gdkRGBA ):
return "#%.2X%.2X%.2X" % ( gdkColor.red / 256, gdkColor.green / 256, gdkColor.blue / 256 ) return "#%.2X%.2X%.2X" % ( gdkRGBA.red * 256, gdkRGBA.green * 256, gdkRGBA.blue * 256 )
def moveUp( self, upButton ): def moveUp( self, upButton ):

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<interface> <interface>
<!-- interface-requires gtk+ 2.6 --> <requires lib="gtk+" version="3.0"/>
<!-- interface-naming-policy toplevel-contextual -->
<object class="GtkWindow" id="mainWindow"> <object class="GtkWindow" id="mainWindow">
<property name="width_request">169</property> <property name="width_request">169</property>
<property name="height_request">227</property> <property name="height_request">227</property>
@ -14,25 +13,26 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<child> <child>
<object class="GtkVBox" id="vbox4"> <object class="GtkBox" id="vbox4">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child> <child>
<object class="GtkNotebook" id="notebook2"> <object class="GtkNotebook" id="notebook2">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="show_tabs">False</property> <property name="show_tabs">False</property>
<property name="show_border">False</property> <property name="show_border">False</property>
<property name="tab_border">14</property>
<child> <child>
<object class="GtkVBox" id="vbox5"> <object class="GtkBox" id="vbox5">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="border_width">3</property> <property name="border_width">3</property>
<property name="orientation">vertical</property>
<property name="spacing">3</property> <property name="spacing">3</property>
<child> <child>
<object class="GtkHBox" id="hbox8"> <object class="GtkBox" id="hbox8">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="homogeneous">True</property> <property name="homogeneous">True</property>
@ -40,11 +40,11 @@
<object class="GtkLabel" id="label6"> <object class="GtkLabel" id="label6">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="xpad">15</property> <property name="xpad">15</property>
<property name="ypad">10</property> <property name="ypad">10</property>
<property name="label" translatable="yes">&lt;span weight="bold"&gt;Favorites&lt;/span&gt;</property> <property name="label" translatable="yes">&lt;span weight="bold"&gt;Favorites&lt;/span&gt;</property>
<property name="use_markup">True</property> <property name="use_markup">True</property>
<property name="xalign">0</property>
</object> </object>
<packing> <packing>
<property name="expand">True</property> <property name="expand">True</property>
@ -58,20 +58,13 @@
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="can_default">True</property> <property name="can_default">True</property>
<property name="receives_default">False</property> <property name="receives_default">False</property>
<property name="use_action_appearance">False</property>
<property name="relief">none</property> <property name="relief">none</property>
<child> <child>
<object class="GtkAlignment" id="alignment3"> <object class="GtkBox" id="hbox10">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="xscale">0</property>
<property name="yscale">0</property>
<property name="right_padding">10</property>
<child>
<object class="GtkHBox" id="hbox10">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="halign">end</property>
<property name="margin_right">10</property>
<property name="spacing">2</property> <property name="spacing">2</property>
<child> <child>
<object class="GtkLabel" id="label7"> <object class="GtkLabel" id="label7">
@ -90,7 +83,8 @@
<object class="GtkImage" id="image4"> <object class="GtkImage" id="image4">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="xpad">5</property> <property name="margin_left">5</property>
<property name="margin_right">5</property>
<property name="stock">gtk-go-forward</property> <property name="stock">gtk-go-forward</property>
</object> </object>
<packing> <packing>
@ -102,8 +96,6 @@
</object> </object>
</child> </child>
</object> </object>
</child>
</object>
<packing> <packing>
<property name="expand">True</property> <property name="expand">True</property>
<property name="fill">True</property> <property name="fill">True</property>
@ -127,10 +119,12 @@
<property name="resize_mode">queue</property> <property name="resize_mode">queue</property>
<property name="shadow_type">none</property> <property name="shadow_type">none</property>
<child> <child>
<object class="GtkTable" id="favoritesBox"> <object class="GtkGrid" id="favoritesBox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="column_homogeneous">True</property>
<child> <child>
<placeholder/> <placeholder/>
</child> </child>
@ -149,13 +143,14 @@
<placeholder/> <placeholder/>
</child> </child>
<child> <child>
<object class="GtkVBox" id="vbox1"> <object class="GtkBox" id="vbox1">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="border_width">3</property> <property name="border_width">3</property>
<property name="orientation">vertical</property>
<property name="spacing">3</property> <property name="spacing">3</property>
<child> <child>
<object class="GtkHBox" id="hbox3"> <object class="GtkBox" id="hbox3">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="homogeneous">True</property> <property name="homogeneous">True</property>
@ -163,11 +158,11 @@
<object class="GtkLabel" id="label2"> <object class="GtkLabel" id="label2">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="xpad">15</property> <property name="xpad">15</property>
<property name="ypad">10</property> <property name="ypad">10</property>
<property name="label" translatable="yes">&lt;span weight="bold"&gt;All Applications&lt;/span&gt;</property> <property name="label" translatable="yes">&lt;span weight="bold"&gt;All Applications&lt;/span&gt;</property>
<property name="use_markup">True</property> <property name="use_markup">True</property>
<property name="xalign">0</property>
</object> </object>
<packing> <packing>
<property name="expand">True</property> <property name="expand">True</property>
@ -181,20 +176,13 @@
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="can_default">True</property> <property name="can_default">True</property>
<property name="receives_default">False</property> <property name="receives_default">False</property>
<property name="use_action_appearance">False</property>
<property name="relief">none</property> <property name="relief">none</property>
<child> <child>
<object class="GtkAlignment" id="alignment2"> <object class="GtkBox" id="hbox4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="xscale">0</property>
<property name="yscale">0</property>
<property name="right_padding">10</property>
<child>
<object class="GtkHBox" id="hbox4">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="halign">end</property>
<property name="margin_right">10</property>
<property name="spacing">2</property> <property name="spacing">2</property>
<child> <child>
<object class="GtkLabel" id="label3"> <object class="GtkLabel" id="label3">
@ -213,7 +201,8 @@
<object class="GtkImage" id="image3"> <object class="GtkImage" id="image3">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="xpad">5</property> <property name="margin_left">5</property>
<property name="margin_right">5</property>
<property name="stock">gtk-go-forward</property> <property name="stock">gtk-go-forward</property>
</object> </object>
<packing> <packing>
@ -225,8 +214,6 @@
</object> </object>
</child> </child>
</object> </object>
</child>
</object>
<packing> <packing>
<property name="expand">True</property> <property name="expand">True</property>
<property name="fill">True</property> <property name="fill">True</property>
@ -243,7 +230,7 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkHBox" id="hbox5"> <object class="GtkBox" id="hbox5">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<child> <child>
@ -251,16 +238,18 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="hscrollbar_policy">never</property> <property name="hscrollbar_policy">never</property>
<property name="vscrollbar_policy">automatic</property>
<child> <child>
<object class="GtkViewport" id="viewport1"> <object class="GtkViewport" id="viewport1">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="shadow_type">none</property> <property name="shadow_type">none</property>
<child> <child>
<object class="GtkVBox" id="categoriesBox"> <object class="GtkBox" id="categoriesBox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="orientation">vertical</property>
</object> </object>
</child> </child>
</object> </object>
@ -273,10 +262,11 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkVSeparator" id="vseparator1"> <object class="GtkSeparator" id="vseparator1">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="orientation">vertical</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@ -291,17 +281,18 @@
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="can_default">True</property> <property name="can_default">True</property>
<property name="hscrollbar_policy">never</property> <property name="hscrollbar_policy">never</property>
<property name="vscrollbar_policy">automatic</property>
<child> <child>
<object class="GtkViewport" id="viewport3"> <object class="GtkViewport" id="viewport3">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="shadow_type">none</property> <property name="shadow_type">none</property>
<child> <child>
<object class="GtkVBox" id="applicationsBox"> <object class="GtkBox" id="applicationsBox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="vexpand">True</property>
<property name="border_width">6</property> <property name="border_width">6</property>
<property name="orientation">vertical</property>
</object> </object>
</child> </child>
</object> </object>
@ -336,7 +327,7 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkHBox" id="hbox9"> <object class="GtkBox" id="hbox9">
<property name="width_request">227</property> <property name="width_request">227</property>
<property name="height_request">30</property> <property name="height_request">30</property>
<property name="visible">True</property> <property name="visible">True</property>
@ -366,8 +357,6 @@
<property name="activates_default">True</property> <property name="activates_default">True</property>
<property name="primary_icon_activatable">False</property> <property name="primary_icon_activatable">False</property>
<property name="secondary_icon_activatable">False</property> <property name="secondary_icon_activatable">False</property>
<property name="primary_icon_sensitive">True</property>
<property name="secondary_icon_sensitive">True</property>
<signal name="changed" handler="on_entry1_changed" swapped="no"/> <signal name="changed" handler="on_entry1_changed" swapped="no"/>
</object> </object>
<packing> <packing>
@ -381,12 +370,11 @@
<property name="width_request">28</property> <property name="width_request">28</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="focus_on_click">False</property>
<property name="can_default">True</property> <property name="can_default">True</property>
<property name="has_default">True</property> <property name="has_default">True</property>
<property name="receives_default">False</property> <property name="receives_default">False</property>
<property name="use_action_appearance">False</property>
<property name="relief">none</property> <property name="relief">none</property>
<property name="focus_on_click">False</property>
<signal name="clicked" handler="on_button17_clicked" swapped="no"/> <signal name="clicked" handler="on_button17_clicked" swapped="no"/>
<child> <child>
<object class="GtkImage" id="image1"> <object class="GtkImage" id="image1">
@ -395,7 +383,7 @@
<property name="can_default">True</property> <property name="can_default">True</property>
<property name="has_default">True</property> <property name="has_default">True</property>
<property name="stock">gtk-find</property> <property name="stock">gtk-find</property>
<property name="icon-size">1</property> <property name="icon_size">1</property>
</object> </object>
</child> </child>
</object> </object>

View File

@ -1,7 +1,7 @@
#!/usr/bin/python2 #!/usr/bin/python2
import gi import gi
gi.require_version("Gtk", "2.0") gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, Pango, Gdk, Gio, GLib from gi.repository import Gtk, Pango, Gdk, Gio, GLib
@ -20,8 +20,6 @@ from execute import Execute
from easygsettings import EasyGSettings from easygsettings import EasyGSettings
from easyfiles import * from easyfiles import *
gtk = CDLL("libgtk-x11-2.0.so.0")
import matemenu import matemenu
from user import home from user import home
@ -122,10 +120,11 @@ class SuggestionButton ( Gtk.Button ):
self.set_size_request( -1, -1 ) self.set_size_request( -1, -1 )
Align1 = Gtk.Alignment() Align1 = Gtk.Alignment()
Align1.set( 0, 0.5, 1.0, 0 ) Align1.set( 0, 0.5, 1.0, 0 )
HBox1 = Gtk.HBox() HBox1 = Gtk.Box( orientation=Gtk.Orientation.HORIZONTAL )
labelBox = Gtk.VBox( False, 2 ) labelBox = Gtk.Box( orientation=Gtk.Orientation.VERTICAL, spacing=2 )
self.image = Gtk.Image() self.image = Gtk.Image()
self.image.set_from_stock( self.iconName, iconSize ) self.image.set_from_icon_name( self.iconName, Gtk.IconSize.INVALID )
self.image.set_pixel_size( iconSize )
self.image.show() self.image.show()
HBox1.pack_start( self.image, False, False, 5 ) HBox1.pack_start( self.image, False, False, 5 )
self.label = Gtk.Label() self.label = Gtk.Label()
@ -148,7 +147,7 @@ class SuggestionButton ( Gtk.Button ):
self.label.set_markup(text) self.label.set_markup(text)
def set_icon_size (self, size): def set_icon_size (self, size):
self.image.set_from_stock( self.iconName, size ) self.image.set_pixel_size( size )
class TargetEntry(Structure): class TargetEntry(Structure):
_fields_ = [("target", c_char_p), _fields_ = [("target", c_char_p),
@ -157,13 +156,10 @@ class TargetEntry(Structure):
class pluginclass( object ): class pluginclass( object ):
TARGET_TYPE_TEXT = 80 TARGET_TYPE_TEXT = 80
array2 = TargetEntry * 2 toButton = ( Gtk.TargetEntry.new( "text/uri-list", 0, TARGET_TYPE_TEXT ), Gtk.TargetEntry.new( "text/uri-list", 0, TARGET_TYPE_TEXT ) )
toButton = array2( ("text/uri-list", 0, TARGET_TYPE_TEXT), ("text/uri-list", 0, TARGET_TYPE_TEXT) )
TARGET_TYPE_FAV = 81 TARGET_TYPE_FAV = 81
array = TargetEntry * 3 toFav = ( Gtk.TargetEntry.new( "FAVORITES", Gtk.TargetFlags.SAME_APP, 81 ), Gtk.TargetEntry.new( "text/plain", 0, 100 ), Gtk.TargetEntry.new( "text/uri-list", 0, 101 ) )
toFav = array( ( "FAVORITES", Gtk.TargetFlags.SAME_APP, 81 ), ( "text/plain", 0, 100 ), ( "text/uri-list", 0, 101 ) ) fromFav = ( Gtk.TargetEntry.new( "FAVORITES", Gtk.TargetFlags.SAME_APP, 81 ), Gtk.TargetEntry.new( "FAVORITES", Gtk.TargetFlags.SAME_APP, 81 ) )
array1 = TargetEntry * 2
fromFav = array1( ("FAVORITES", Gtk.TargetFlags.SAME_APP, 81), ("FAVORITES", Gtk.TargetFlags.SAME_APP, 81) )
@print_timing @print_timing
def __init__( self, mintMenuWin, toggleButton, de ): def __init__( self, mintMenuWin, toggleButton, de ):
@ -227,10 +223,9 @@ class pluginclass( object ):
self.favoritesBox.connect( "drag-data-received", self.ReceiveCallback ) self.favoritesBox.connect( "drag-data-received", self.ReceiveCallback )
gtk.gtk_drag_dest_set.argtypes = [c_void_p, c_ushort, c_void_p, c_int, c_ushort] self.favoritesBox.drag_dest_set ( Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT | Gtk.DestDefaults.DROP, self.toButton, Gdk.DragAction.COPY )
gtk.gtk_drag_dest_set ( hash(self.favoritesBox), Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT | Gtk.DestDefaults.DROP, self.toButton, 2, Gdk.DragAction.COPY )
self.showFavoritesButton.connect( "drag-data-received", self.ReceiveCallback ) self.showFavoritesButton.connect( "drag-data-received", self.ReceiveCallback )
gtk.gtk_drag_dest_set ( hash(self.showFavoritesButton), Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT | Gtk.DestDefaults.DROP, self.toButton, 2, Gdk.DragAction.COPY ) self.showFavoritesButton.drag_dest_set ( Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT | Gtk.DestDefaults.DROP, self.toButton, Gdk.DragAction.COPY )
# self.searchButton.connect( "button_release_event", self.SearchWithButton ) # self.searchButton.connect( "button_release_event", self.SearchWithButton )
try: try:
@ -555,8 +550,7 @@ class pluginclass( object ):
# of the existing text, that's the most likely candidate anyhow # of the existing text, that's the most likely candidate anyhow
self.searchEntry.grab_focus() self.searchEntry.grab_focus()
if self.rememberFilter or not clear: if self.rememberFilter or not clear:
gtk.gtk_editable_set_position.argtypes = [c_void_p, c_int] self.searchEntry.set_position(-1)
gtk.gtk_editable_set_position(hash(self.searchEntry), -1)
else: else:
self.searchEntry.set_text("") self.searchEntry.set_text("")
@ -590,14 +584,14 @@ class pluginclass( object ):
text = "<b>%s</b>" % text text = "<b>%s</b>" % text
if self.enableInternetSearch: if self.enableInternetSearch:
suggestionButton = SuggestionButton(Gtk.STOCK_ADD, self.iconSize, "") suggestionButton = SuggestionButton("list-add", self.iconSize, "")
suggestionButton.connect("clicked", self.search_ddg) suggestionButton.connect("clicked", self.search_ddg)
suggestionButton.set_text(_("Search DuckDuckGo for %s") % text) suggestionButton.set_text(_("Search DuckDuckGo for %s") % text)
suggestionButton.set_image("/usr/lib/linuxmint/mintMenu/search_engines/ddg.png") suggestionButton.set_image("/usr/lib/linuxmint/mintMenu/search_engines/ddg.png")
self.applicationsBox.add(suggestionButton) self.applicationsBox.add(suggestionButton)
self.suggestions.append(suggestionButton) self.suggestions.append(suggestionButton)
suggestionButton = SuggestionButton(Gtk.STOCK_ADD, self.iconSize, "") suggestionButton = SuggestionButton("list-add", self.iconSize, "")
suggestionButton.connect("clicked", self.search_wikipedia) suggestionButton.connect("clicked", self.search_wikipedia)
suggestionButton.set_text(_("Search Wikipedia for %s") % text) suggestionButton.set_text(_("Search Wikipedia for %s") % text)
suggestionButton.set_image("/usr/lib/linuxmint/mintMenu/search_engines/wikipedia.ico") suggestionButton.set_image("/usr/lib/linuxmint/mintMenu/search_engines/wikipedia.ico")
@ -605,7 +599,7 @@ class pluginclass( object ):
self.suggestions.append(suggestionButton) self.suggestions.append(suggestionButton)
separator = Gtk.EventBox() separator = Gtk.EventBox()
separator.add(Gtk.HSeparator()) separator.add(Gtk.Separator( orientation=Gtk.Orientation.HORIZONTAL ))
separator.set_visible_window(False) separator.set_visible_window(False)
separator.set_size_request(-1, 20) separator.set_size_request(-1, 20)
separator.type = "separator" separator.type = "separator"
@ -613,21 +607,21 @@ class pluginclass( object ):
self.applicationsBox.add(separator) self.applicationsBox.add(separator)
self.suggestions.append(separator) self.suggestions.append(separator)
suggestionButton = SuggestionButton(Gtk.STOCK_ADD, self.iconSize, "") suggestionButton = SuggestionButton("list-add", self.iconSize, "")
suggestionButton.connect("clicked", self.search_dictionary) suggestionButton.connect("clicked", self.search_dictionary)
suggestionButton.set_text(_("Lookup %s in Dictionary") % text) suggestionButton.set_text(_("Lookup %s in Dictionary") % text)
suggestionButton.set_image("/usr/lib/linuxmint/mintMenu/search_engines/dictionary.png") suggestionButton.set_image("/usr/lib/linuxmint/mintMenu/search_engines/dictionary.png")
self.applicationsBox.add(suggestionButton) self.applicationsBox.add(suggestionButton)
self.suggestions.append(suggestionButton) self.suggestions.append(suggestionButton)
suggestionButton = SuggestionButton(Gtk.STOCK_FIND, self.iconSize, "") suggestionButton = SuggestionButton("edit-find", self.iconSize, "")
suggestionButton.connect("clicked", self.Search) suggestionButton.connect("clicked", self.Search)
suggestionButton.set_text(_("Search Computer for %s") % text) suggestionButton.set_text(_("Search Computer for %s") % text)
self.applicationsBox.add(suggestionButton) self.applicationsBox.add(suggestionButton)
self.suggestions.append(suggestionButton) self.suggestions.append(suggestionButton)
#self.last_separator = gtk.EventBox() #self.last_separator = Gtk.EventBox()
#self.last_separator.add(gtk.HSeparator()) #self.last_separator.add(Gtk.Separator( orientation=Gtk.Orientation.HORIZONTAL ))
#self.last_separator.set_size_request(-1, 20) #self.last_separator.set_size_request(-1, 20)
#self.last_separator.type = "separator" #self.last_separator.type = "separator"
#self.mintMenuWin.SetPaneColors( [ self.last_separator ] ) #self.mintMenuWin.SetPaneColors( [ self.last_separator ] )
@ -859,8 +853,7 @@ class pluginclass( object ):
if event.string.strip() != "" or event.keyval == Gdk.KEY_BackSpace: if event.string.strip() != "" or event.keyval == Gdk.KEY_BackSpace:
self.searchEntry.grab_focus() self.searchEntry.grab_focus()
gtk.gtk_editable_set_position.argtypes = [c_void_p, c_int] self.searchEntry.set_position( -1 )
gtk.gtk_editable_set_position(hash(self.searchEntry), -1)
self.searchEntry.event( event ) self.searchEntry.event( event )
return True return True
@ -930,8 +923,7 @@ class pluginclass( object ):
mTree.show_all() mTree.show_all()
self.mintMenuWin.stopHiding() self.mintMenuWin.stopHiding()
gtk.gtk_menu_popup.argtypes = [c_void_p, c_void_p, c_void_p, c_void_p, c_void_p, c_uint, c_uint] mTree.popup(None, None, None, None, ev.button, ev.time)
gtk.gtk_menu_popup(hash(mTree), None, None, None, None, ev.button, ev.time)
else: else:
mTree = Gtk.Menu() mTree = Gtk.Menu()
mTree.set_events(Gdk.EventMask.POINTER_MOTION_MASK | Gdk.EventMask.POINTER_MOTION_HINT_MASK | mTree.set_events(Gdk.EventMask.POINTER_MOTION_MASK | Gdk.EventMask.POINTER_MOTION_HINT_MASK |
@ -950,8 +942,7 @@ class pluginclass( object ):
insertSpaceMenuItem.connect( "activate", self.onFavoritesInsertSpace, widget, insertBefore ) insertSpaceMenuItem.connect( "activate", self.onFavoritesInsertSpace, widget, insertBefore )
insertSeparatorMenuItem.connect( "activate", self.onFavoritesInsertSeparator, widget, insertBefore ) insertSeparatorMenuItem.connect( "activate", self.onFavoritesInsertSeparator, widget, insertBefore )
self.mintMenuWin.stopHiding() self.mintMenuWin.stopHiding()
gtk.gtk_menu_popup.argtypes = [c_void_p, c_void_p, c_void_p, c_void_p, c_void_p, c_uint, c_uint] mTree.popup(None, None, None, None, ev.button, ev.time)
gtk.gtk_menu_popup(hash(mTree), None, None, None, None, ev.button, ev.time)
def menuPopup( self, widget, event ): def menuPopup( self, widget, event ):
if event.button == 3: if event.button == 3:
@ -1013,8 +1004,7 @@ class pluginclass( object ):
startupMenuItem.connect( "toggled", self.onAddToStartup, widget ) startupMenuItem.connect( "toggled", self.onAddToStartup, widget )
self.mintMenuWin.stopHiding() self.mintMenuWin.stopHiding()
gtk.gtk_menu_popup.argtypes = [c_void_p, c_void_p, c_void_p, c_void_p, c_void_p, c_uint, c_uint] mTree.popup(None, None, None, None, ev.button, ev.time)
gtk.gtk_menu_popup(hash(mTree), None, None, None, None, event.button, event.time)
def searchPopup( self, widget=None, event=None ): def searchPopup( self, widget=None, event=None ):
@ -1048,7 +1038,8 @@ class pluginclass( object ):
menuItem = Gtk.ImageMenuItem(_("Search Computer")) menuItem = Gtk.ImageMenuItem(_("Search Computer"))
img = Gtk.Image() img = Gtk.Image()
img.set_from_stock(Gtk.STOCK_FIND, self.iconSize) img.set_from_icon_name("edit-find", Gtk.IconSize.INVALID)
img.set_pixel_size( self.iconSize )
menuItem.set_image(img) menuItem.set_image(img)
menuItem.connect("activate", self.Search) menuItem.connect("activate", self.Search)
menu.append(menuItem) menu.append(menuItem)
@ -1094,8 +1085,7 @@ class pluginclass( object ):
menu.show_all() menu.show_all()
self.mintMenuWin.stopHiding() self.mintMenuWin.stopHiding()
gtk.gtk_menu_popup.argtypes = [c_void_p, c_void_p, c_void_p, c_void_p, c_void_p, c_uint, c_uint] menu.popup(None, None, None, None, event.button, event.time)
gtk.gtk_menu_popup(hash(menu), None, None, None, None, event.button, event.time)
#menu.attach_to_widget(self.searchButton, None) #menu.attach_to_widget(self.searchButton, None)
#menu.reposition() #menu.reposition()
@ -1305,11 +1295,11 @@ class pluginclass( object ):
# Scroll button into view # Scroll button into view
def scrollItemIntoView( self, widget, event = None ): def scrollItemIntoView( self, widget, event = None ):
viewport = widget.parent viewport = widget.get_parent()
while not isinstance( viewport, Gtk.Viewport ): while not isinstance( viewport, Gtk.Viewport ):
if not viewport.parent: if not viewport.get_parent():
return return
viewport = viewport.parent viewport = viewport.get_parent()
aloc = widget.get_allocation() aloc = widget.get_allocation()
viewport.get_vadjustment().clamp_page(aloc.y, aloc.y + aloc.height) viewport.get_vadjustment().clamp_page(aloc.y, aloc.y + aloc.height)
@ -1325,8 +1315,9 @@ class pluginclass( object ):
return space return space
def favoritesBuildSeparator( self ): def favoritesBuildSeparator( self ):
separator = Gtk.HSeparator() separator = Gtk.Separator( orientation=Gtk.Orientation.HORIZONTAL )
separator.set_size_request( -1, 20 ) separator.set_margin_top( 5 )
separator.set_margin_bottom( 5 )
separator.type = "separator" separator.type = "separator"
separator.show_all() separator.show_all()
@ -1421,34 +1412,15 @@ class pluginclass( object ):
self.favorites.append( favButton ) self.favorites.append( favButton )
self.favoritesPositionOnGrid( favButton ) self.favoritesPositionOnGrid( favButton )
favButton.connect( "drag-data-received", self.onFavButtonDragReorder ) favButton.connect( "drag-data-received", self.onFavButtonDragReorder )
gtk.gtk_drag_dest_set.argtypes = [c_void_p, c_ushort, c_void_p, c_int, c_ushort] favButton.drag_dest_set( Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT | Gtk.DestDefaults.DROP, self.toFav, Gdk.DragAction.COPY )
gtk.gtk_drag_dest_set( hash(favButton), Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT | Gtk.DestDefaults.DROP, self.fromFav, 2, Gdk.DragAction.COPY )
favButton.connect( "drag-data-get", self.onFavButtonDragReorderGet ) favButton.connect( "drag-data-get", self.onFavButtonDragReorderGet )
gtk.gtk_drag_source_set.argtypes = [c_void_p, c_ushort, c_void_p, c_int, c_ushort] favButton.drag_source_set ( Gdk.ModifierType.BUTTON1_MASK, self.toFav, Gdk.DragAction.COPY )
gtk.gtk_drag_source_set( hash(favButton), Gdk.ModifierType.BUTTON1_MASK, self.toFav, 3, Gdk.DragAction.COPY )
position += 1 position += 1
self.favoritesSave() self.favoritesSave()
except Exception, e: except Exception, e:
print e print e
def favoritesGetNumRows( self ):
rows = 0
col = 0
for fav in self.favorites:
if ( fav.type == "separator" or fav.type == "space" ) and col != 0:
rows += 1
col = 0
col += 1
if fav.type == "separator" or fav.type == "space":
rows += 1
col = 0
if col >= self.favCols:
rows += 1
col = 0
return rows
def favoritesPositionOnGrid( self, favorite ): def favoritesPositionOnGrid( self, favorite ):
row = 0 row = 0
col = 0 col = 0
@ -1468,9 +1440,9 @@ class pluginclass( object ):
col = 0 col = 0
if favorite.type == "separator" or favorite.type == "space": if favorite.type == "separator" or favorite.type == "space":
self.favoritesBox.attach( favorite, col, col + self.favCols, row, row + 1, yoptions = 0 ) self.favoritesBox.attach( favorite, col, row, self.favCols, 1 )
else: else:
self.favoritesBox.attach( favorite, col, col + 1, row, row + 1, yoptions = 0 ) self.favoritesBox.attach( favorite, col, row, 1, 1 )
def favoritesReorder( self, oldposition, newposition ): def favoritesReorder( self, oldposition, newposition ):
if oldposition == newposition: if oldposition == newposition:
@ -1494,7 +1466,6 @@ class pluginclass( object ):
self.favoritesPositionOnGrid( fav ) self.favoritesPositionOnGrid( fav )
self.favoritesSave() self.favoritesSave()
self.favoritesBox.resize( self.favoritesGetNumRows(), self.favCols )
def favoritesAdd( self, favButton, position = -1 ): def favoritesAdd( self, favButton, position = -1 ):
if favButton: if favButton:
@ -1503,11 +1474,9 @@ class pluginclass( object ):
self.favoritesPositionOnGrid( favButton ) self.favoritesPositionOnGrid( favButton )
favButton.connect( "drag-data-received", self.onFavButtonDragReorder ) favButton.connect( "drag-data-received", self.onFavButtonDragReorder )
gtk.gtk_drag_dest_set.argtypes = [c_void_p, c_ushort, c_void_p, c_int, c_ushort] favButton.drag_dest_set( Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT | Gtk.DestDefaults.DROP, self.toFav, Gdk.DragAction.COPY )
gtk.gtk_drag_dest_set( hash(favButton), Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT | Gtk.DestDefaults.DROP, self.toFav, 3, Gdk.DragAction.COPY )
favButton.connect( "drag-data-get", self.onFavButtonDragReorderGet ) favButton.connect( "drag-data-get", self.onFavButtonDragReorderGet )
gtk.gtk_drag_source_set.argtypes = [c_void_p, c_ushort, c_void_p, c_int, c_ushort] favButton.drag_source_set ( Gdk.ModifierType.BUTTON1_MASK, self.toFav, Gdk.DragAction.COPY )
gtk.gtk_drag_source_set ( hash(favButton), Gdk.ModifierType.BUTTON1_MASK, self.toFav, 3, Gdk.DragAction.COPY )
if position >= 0: if position >= 0:
self.favoritesReorder( favButton.position, position ) self.favoritesReorder( favButton.position, position )
@ -1524,7 +1493,6 @@ class pluginclass( object ):
self.favoritesBox.remove( self.favorites[ i ] ) self.favoritesBox.remove( self.favorites[ i ] )
self.favoritesPositionOnGrid( self.favorites[ i ] ) self.favoritesPositionOnGrid( self.favorites[ i ] )
self.favoritesSave() self.favoritesSave()
self.favoritesBox.resize( self.favoritesGetNumRows(), self.favCols )
def favoritesRemoveLocation( self, location ): def favoritesRemoveLocation( self, location ):
for fav in self.favorites: for fav in self.favorites:
@ -1544,7 +1512,7 @@ class pluginclass( object ):
appListFile.close( ) appListFile.close( )
except Exception, e: except Exception, e:
msgDlg = Gtk.MessageDialog( None, gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR, Gtk.ButtonsType.OK, _("Couldn't save favorites. Check if you have write access to ~/.linuxmint/mintMenu")+"\n(" + e.__str__() + ")" ) msgDlg = Gtk.MessageDialog( None, Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR, Gtk.ButtonsType.OK, _("Couldn't save favorites. Check if you have write access to ~/.linuxmint/mintMenu")+"\n(" + e.__str__() + ")" )
msgDlg.run(); msgDlg.run();
msgDlg.destroy(); msgDlg.destroy();
@ -1737,7 +1705,7 @@ class pluginclass( object ):
for item in sortedApplicationList: for item in sortedApplicationList:
launcherName = item[0] launcherName = item[0]
button = item[1] button = item[1]
self.applicationsBox.pack_start( button, False, False, 0 ) self.applicationsBox.add( button )
if launcherName in launcherNames: if launcherName in launcherNames:
button.hide() button.hide()
else: else:
@ -1755,7 +1723,7 @@ class pluginclass( object ):
# Build a list of all categories in the menu ( [ { "name", "icon", tooltip" } ] # Build a list of all categories in the menu ( [ { "name", "icon", tooltip" } ]
def buildCategoryList( self ): def buildCategoryList( self ):
newCategoryList = [ { "name": _("All"), "icon": "stock_select-all", "tooltip": _("Show all applications"), "filter":"", "index": 0 } ] newCategoryList = [ { "name": _("All"), "icon": "edit-select-all", "tooltip": _("Show all applications"), "filter":"", "index": 0 } ]
num = 1 num = 1

View File

@ -13,8 +13,6 @@ from filemonitor import monitor as filemonitor
import ctypes import ctypes
from ctypes import * from ctypes import *
gtk = CDLL("libgtk-x11-2.0.so.0")
class IconManager(GObject.GObject): class IconManager(GObject.GObject):
__gsignals__ = { __gsignals__ = {
@ -124,8 +122,8 @@ class easyButton( Gtk.Button ):
self.set_size_request( buttonWidth, buttonHeight ) self.set_size_request( buttonWidth, buttonHeight )
Align1 = Gtk.Alignment.new( 0, 0.5, 1.0, 0 ) Align1 = Gtk.Alignment.new( 0, 0.5, 1.0, 0 )
HBox1 = Gtk.HBox() HBox1 = Gtk.Box( orientation=Gtk.Orientation.HORIZONTAL )
self.labelBox = Gtk.VBox( False, 2 ) self.labelBox = Gtk.Box( orientation=Gtk.Orientation.VERTICAL, spacing=2 )
self.buttonImage = Gtk.Image() self.buttonImage = Gtk.Image()
@ -135,7 +133,7 @@ class easyButton( Gtk.Button ):
else: else:
#[ iW, iH ] = iconManager.getIconSize( self.iconSize ) #[ iW, iH ] = iconManager.getIconSize( self.iconSize )
self.buttonImage.set_size_request( self.iconSize, self.iconSize ) self.buttonImage.set_size_request( self.iconSize, self.iconSize )
self.image_box = Gtk.HBox() self.image_box = Gtk.Box( orientation=Gtk.Orientation.HORIZONTAL )
self.image_box.pack_start(self.buttonImage, False, False, 5) self.image_box.pack_start(self.buttonImage, False, False, 5)
self.image_box.show_all() self.image_box.show_all()
HBox1.pack_start( self.image_box, False, False, 0 ) HBox1.pack_start( self.image_box, False, False, 0 )
@ -163,7 +161,7 @@ class easyButton( Gtk.Button ):
self.connections.append( self.connect( event, callback ) ) self.connections.append( self.connect( event, callback ) )
def onRelease( self, widget ): def onRelease( self, widget ):
widget.set_state(Gtk.StateType.NORMAL) widget.get_style_context().set_state( Gtk.StateFlags.NORMAL )
def onDestroy( self, widget ): def onDestroy( self, widget ):
self.buttonImage.clear() self.buttonImage.clear()
@ -188,6 +186,7 @@ class easyButton( Gtk.Button ):
label.set_ellipsize( Pango.EllipsizeMode.END ) label.set_ellipsize( Pango.EllipsizeMode.END )
label.set_alignment( 0.0, 1.0 ) label.set_alignment( 0.0, 1.0 )
label.set_max_width_chars(0)
label.show() label.show()
self.labelBox.pack_start( label , True, True, 0) self.labelBox.pack_start( label , True, True, 0)
@ -271,17 +270,13 @@ class ApplicationLauncher( easyButton ):
# Drag and Drop # Drag and Drop
self.connectSelf( "drag-data-get", self.dragDataGet ) self.connectSelf( "drag-data-get", self.dragDataGet )
array = TargetEntry * 2 targets = ( Gtk.TargetEntry.new( "text/plain", 0, 100 ), Gtk.TargetEntry.new( "text/uri-list", 0, 101 ) )
targets = array(( "text/plain", 0, 100 ), ( "text/uri-list", 0, 101 )) self.drag_source_set( Gdk.ModifierType.BUTTON1_MASK, targets, Gdk.DragAction.COPY )
gtk.gtk_drag_source_set.argtypes = [c_void_p, c_ushort, c_void_p, c_int, c_ushort]
gtk.gtk_drag_source_set(hash(self), Gdk.ModifierType.BUTTON1_MASK, targets, 2, Gdk.DragAction.COPY)
icon = self.getIcon( Gtk.IconSize.DND ) icon = self.getIcon( Gtk.IconSize.DND )
if icon: if icon:
iconName, s = icon.get_icon_name() iconName, s = icon.get_icon_name()
c = c_char_p(iconName.decode('utf-8', 'ignore').encode('ascii', 'ignore')) self.drag_source_set_icon_name( iconName )
gtk.gtk_drag_source_set_icon_name.argtypes = [c_void_p, c_char_p]
gtk.gtk_drag_source_set_icon_name( hash(self), c)
self.connectSelf( "focus-in-event", self.onFocusIn ) self.connectSelf( "focus-in-event", self.onFocusIn )
self.connectSelf( "focus-out-event", self.onFocusOut ) self.connectSelf( "focus-out-event", self.onFocusOut )
@ -398,9 +393,7 @@ class ApplicationLauncher( easyButton ):
icon = self.getIcon( Gtk.IconSize.DND ) icon = self.getIcon( Gtk.IconSize.DND )
if icon: if icon:
iconName, size = icon.get_icon_name() iconName, size = icon.get_icon_name()
c = c_char_p(iconName.encode('ascii', 'ignore')) self.drag_source_set_icon_name( iconName )
gtk.gtk_drag_source_set_icon_name.argtypes = [c_void_p, c_char_p]
gtk.gtk_drag_source_set_icon_name( hash(self), c)
def startupFileChanged( self, *args ): def startupFileChanged( self, *args ):
self.inStartup = os.path.exists( self.startupFilePath ) self.inStartup = os.path.exists( self.startupFilePath )
@ -493,7 +486,7 @@ class MenuApplicationLauncher( ApplicationLauncher ):
appComment = self.appComment appComment = self.appComment
if self.highlight: if self.highlight:
try: try:
#color = self.labelBox.rc_get_style().fg[ Gtk.StateType.SELECTED ].to_string() #color = self.labelBox.get_style_context().get_color( Gtk.StateFlags.SELECTED ).to_string()
#if len(color) > 0 and color[0] == "#": #if len(color) > 0 and color[0] == "#":
#appName = "<span foreground=\"%s\"><b>%s</b></span>" % (color, appName); #appName = "<span foreground=\"%s\"><b>%s</b></span>" % (color, appName);
#appComment = "<span foreground=\"%s\"><b>%s</b></span>" % (color, appComment); #appComment = "<span foreground=\"%s\"><b>%s</b></span>" % (color, appComment);

View File

@ -23,7 +23,7 @@ def Execute( cmd , commandCwd=None):
cwd = tmpCwd cwd = tmpCwd
if isinstance( cmd, str ) or isinstance( cmd, unicode): if isinstance( cmd, str ) or isinstance( cmd, unicode):
if (cmd.find("ubiquity") >= 0) or (cmd.find("/home/") >= 0) or (cmd.find("su-to-root") >= 0) or (cmd.find("\"") >= 0): if (cmd.find("ubiquity") >= 0) or (cmd.find("/home/") >= 0) or (cmd.find("xdg-su") >= 0) or (cmd.find("\"") >= 0):
print "running manually..." print "running manually..."
try: try:
os.chdir(cwd) os.chdir(cwd)

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<interface> <interface>
<requires lib="gtk+" version="2.16"/> <requires lib="gtk+" version="3.0"/>
<!-- interface-naming-policy toplevel-contextual -->
<object class="GtkWindow" id="mainWindow"> <object class="GtkWindow" id="mainWindow">
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="border_width">3</property> <property name="border_width">3</property>
@ -15,10 +14,8 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="border_width">3</property> <property name="border_width">3</property>
<property name="hscrollbar_policy">automatic</property>
<property name="vscrollbar_policy">automatic</property>
<signal name="drag-drop" handler="on_scrolledwindow_drag_drop" swapped="no"/>
<signal name="drag-data-received" handler="on_scrolledwindow_drag_data_received" swapped="no"/> <signal name="drag-data-received" handler="on_scrolledwindow_drag_data_received" swapped="no"/>
<signal name="drag-drop" handler="on_scrolledwindow_drag_drop" swapped="no"/>
<signal name="drag-motion" handler="on_scrolledwindow_drag_motion" swapped="no"/> <signal name="drag-motion" handler="on_scrolledwindow_drag_motion" swapped="no"/>
<child> <child>
<object class="GtkViewport" id="viewport2"> <object class="GtkViewport" id="viewport2">
@ -26,14 +23,16 @@
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="shadow_type">none</property> <property name="shadow_type">none</property>
<child> <child>
<object class="GtkVBox" id="vbox1"> <object class="GtkBox" id="vbox1">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child> <child>
<object class="GtkVBox" id="places_button_holder"> <object class="GtkBox" id="places_button_holder">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property> <property name="spacing">2</property>
</object> </object>
<packing> <packing>
@ -43,9 +42,10 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkVButtonBox" id="editable_button_holder"> <object class="GtkButtonBox" id="editable_button_holder">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="layout_style">start</property> <property name="layout_style">start</property>
</object> </object>
<packing> <packing>

View File

@ -15,8 +15,6 @@ from execute import Execute
from user import home from user import home
from urllib import unquote from urllib import unquote
gtk = CDLL("libgtk-x11-2.0.so.0")
# i18n # i18n
gettext.install("mintmenu", "/usr/share/linuxmint/locale") gettext.install("mintmenu", "/usr/share/linuxmint/locale")
@ -263,8 +261,7 @@ class pluginclass( object ):
trashMenu.show_all() trashMenu.show_all()
emptyTrashMenuItem.connect ( "activate", self.emptyTrash, widget ) emptyTrashMenuItem.connect ( "activate", self.emptyTrash, widget )
self.mintMenuWin.stopHiding() self.mintMenuWin.stopHiding()
gtk.gtk_menu_popup.argtypes = [c_void_p, c_void_p, c_void_p, c_void_p, c_void_p, c_uint, c_uint] trashMenu.popup(None, None, None, None, 3, 0)
gtk.gtk_menu_popup(hash(trashMenu), None, None, None, None, 3, 0)
def emptyTrash( self, menu, widget): def emptyTrash( self, menu, widget):
os.system("rm -rf " + home + "/.local/share/Trash/info/*") os.system("rm -rf " + home + "/.local/share/Trash/info/*")

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<interface> <interface>
<!-- interface-requires gtk+ 2.12 --> <requires lib="gtk+" version="3.0"/>
<!-- interface-naming-policy toplevel-contextual -->
<object class="GtkWindow" id="window1"> <object class="GtkWindow" id="window1">
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="border_width">3</property> <property name="border_width">3</property>
@ -12,9 +11,10 @@
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="border_width">5</property> <property name="border_width">5</property>
<child> <child>
<object class="GtkVBox" id="vbox1"> <object class="GtkBox" id="vbox1">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">3</property> <property name="spacing">3</property>
<child> <child>
<object class="GtkNotebook" id="RecentTabs"> <object class="GtkNotebook" id="RecentTabs">
@ -25,16 +25,15 @@
<object class="GtkScrolledWindow" id="scrolledwindow1"> <object class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="hscrollbar_policy">automatic</property>
<property name="vscrollbar_policy">automatic</property>
<child> <child>
<object class="GtkViewport" id="viewport2"> <object class="GtkViewport" id="viewport2">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<child> <child>
<object class="GtkVButtonBox" id="RecentApps"> <object class="GtkButtonBox" id="RecentApps">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="layout_style">start</property> <property name="layout_style">start</property>
<child> <child>
<placeholder/> <placeholder/>
@ -59,17 +58,16 @@
<object class="GtkScrolledWindow" id="scrolledwindow2"> <object class="GtkScrolledWindow" id="scrolledwindow2">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="hscrollbar_policy">automatic</property>
<property name="vscrollbar_policy">automatic</property>
<child> <child>
<object class="GtkViewport" id="viewport1"> <object class="GtkViewport" id="viewport1">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="shadow_type">none</property> <property name="shadow_type">none</property>
<child> <child>
<object class="GtkVButtonBox" id="RecentBox"> <object class="GtkButtonBox" id="RecentBox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="layout_style">start</property> <property name="layout_style">start</property>
</object> </object>
</child> </child>
@ -105,7 +103,6 @@
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="receives_default">True</property> <property name="receives_default">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="use_action_appearance">False</property>
<property name="use_stock">True</property> <property name="use_stock">True</property>
<signal name="clicked" handler="on_ClrBtn_clicked" swapped="no"/> <signal name="clicked" handler="on_ClrBtn_clicked" swapped="no"/>
</object> </object>

View File

@ -1,7 +1,7 @@
#!/usr/bin/python2 #!/usr/bin/python2
import gi import gi
gi.require_version("Gtk", "2.0") gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, Pango from gi.repository import Gtk, Pango
import os import os
@ -140,13 +140,12 @@ class pluginclass:
Align1 = Gtk.Alignment() Align1 = Gtk.Alignment()
Align1.set( 0, 0.5, 0, 0) Align1.set( 0, 0.5, 0, 0)
Align1.set_padding( 0, 0, 0, 0 ) Align1.set_padding( 0, 0, 0, 0 )
HBox1 = Gtk.HBox( False, 5 ) HBox1 = Gtk.Box( orientation=Gtk.Orientation.HORIZONTAL, spacing=5 )
VBox1 = Gtk.VBox( False, 2 ) VBox1 = Gtk.Box( orientation=Gtk.Orientation.VERTICAL, spacing=2 )
VBox1.show() VBox1.show()
req = Gtk.Requisition() req = AButton.size_request()
AButton.size_request(req)
Label1 = Gtk.Label( DispName ) Label1 = Gtk.Label( DispName )
Label1.set_size_request( req.width-20, -1 ) Label1.set_size_request( req.width-20, -1 )
@ -190,7 +189,7 @@ class pluginclass:
FileString=[] FileString=[]
IconString=[] IconString=[]
RecentInfo=self.RecManagerInstance.get_items() RecentInfo=self.RecManagerInstance.get_items()
# print RecentInfo[0].get_icon(gtk.ICON_SIZE_MENU) # print RecentInfo[0].get_icon(Gtk.IconSize.MENU)
count=0 count=0
MaxEntries=self.numentries MaxEntries=self.numentries
if self.numentries == -1: if self.numentries == -1:

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<interface> <interface>
<!-- interface-requires gtk+ 2.6 --> <requires lib="gtk+" version="3.0"/>
<!-- interface-naming-policy toplevel-contextual -->
<object class="GtkWindow" id="mainWindow"> <object class="GtkWindow" id="mainWindow">
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="border_width">3</property> <property name="border_width">3</property>
@ -15,10 +14,8 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="border_width">3</property> <property name="border_width">3</property>
<property name="hscrollbar_policy">automatic</property>
<property name="vscrollbar_policy">automatic</property>
<signal name="drag-drop" handler="on_scrolledwindow_drag_drop" swapped="no"/>
<signal name="drag-data-received" handler="on_scrolledwindow_drag_data_received" swapped="no"/> <signal name="drag-data-received" handler="on_scrolledwindow_drag_data_received" swapped="no"/>
<signal name="drag-drop" handler="on_scrolledwindow_drag_drop" swapped="no"/>
<signal name="drag-motion" handler="on_scrolledwindow_drag_motion" swapped="no"/> <signal name="drag-motion" handler="on_scrolledwindow_drag_motion" swapped="no"/>
<child> <child>
<object class="GtkViewport" id="viewport2"> <object class="GtkViewport" id="viewport2">
@ -26,14 +23,16 @@
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="shadow_type">none</property> <property name="shadow_type">none</property>
<child> <child>
<object class="GtkVBox" id="vbox1"> <object class="GtkBox" id="vbox1">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child> <child>
<object class="GtkVBox" id="system_button_holder"> <object class="GtkBox" id="system_button_holder">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property> <property name="spacing">2</property>
</object> </object>
<packing> <packing>
@ -43,9 +42,10 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkVButtonBox" id="editable_button_holder"> <object class="GtkButtonBox" id="editable_button_holder">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="layout_style">start</property> <property name="layout_style">start</property>
</object> </object>
<packing> <packing>

View File

@ -1,7 +1,7 @@
#!/usr/bin/python2 #!/usr/bin/python2
import gi import gi
gi.require_version("Gtk", "2.0") gi.require_version("Gtk", "3.0")
from gi.repository import Gtk from gi.repository import Gtk
import os import os

View File

@ -1,7 +1,7 @@
#!/usr/bin/python2 #!/usr/bin/python2
import gi import gi
gi.require_version("Gtk", "2.0") gi.require_version("Gtk", "3.0")
from Xlib.display import Display from Xlib.display import Display
from Xlib import X, error from Xlib import X, error
@ -10,8 +10,7 @@ import threading
import ctypes import ctypes
from ctypes import * from ctypes import *
gdk = CDLL("libgdk-x11-2.0.so.0") gdk = CDLL("libgdk-3.so.0")
gtk = CDLL("libgtk-x11-2.0.so.0")
class PointerMonitor(GObject.GObject, threading.Thread): class PointerMonitor(GObject.GObject, threading.Thread):
__gsignals__ = { __gsignals__ = {