Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

ImageChooserButton, EditButton

  • Loading branch information...
commit 4876eec671aeca8c071b439693bc59d911ec7443 1 parent 8d0ac00
@Nano77 authored
View
22 gdm3setup.desktop
@@ -1,15 +1,21 @@
-#!/usr/bin/env xdg-open
[Desktop Entry]
-Version=1.0
-Type=Application
-Terminal=false
-Exec=/usr/bin/gdm3setup.py
Name=GDM3 Settings
-Name[fr_FR]=Paramètres de GDM3
Name[de_DE]=Einstellungen der GDM3
-Name[it_IT]=impostazioni di GDM3
Name[es_ES]=Configuratión de GDM3
+Name[fr]=Paramètres de GDM3
+Name[it]=Impostazioni di GNOME Display Manager 3
+Comment=Change GDM3 settings
+Comment[de_DE]=Einstellungen ändern für GDM3
+Comment[es_ES]=Cambiar la configuración de GDM3
+Comment[fr]=Modifier les paramètres de GDM3
+Comment[it]=Modifica il impostazioni di GNOME Display Manager 3
+Exec=gdm3setup.py
Icon=preferences-desktop-theme
-Categories=Settings;
+Terminal=false
+Type=Application
+StartupNotify=true
+Categories=GNOME;GTK;Settings;X-GNOME-SystemSettings;
+OnlyShowIn=GNOME;Unity;
+
View
83 gdm3setup.py
@@ -7,6 +7,7 @@
import mimetypes
from gi.repository import Gtk
+from gi.repository import Gdk
from gi.repository import GdkPixbuf
from gi.repository import GnomeDesktop
from gi.repository import GObject
@@ -32,6 +33,12 @@ def __init__(self):
self.Box.pack_end(self.Separator,False,False,2)
self.PreviewImage = Gtk.Image()
self.PreviewBox = Gtk.VBox.new(False, 16)
+ self.Label_Size = Gtk.Label("0 x 0")
+ self.PreviewBox.set_size_request(200,-1);
+ self.PreviewBox.pack_start(self.PreviewImage, False, False, 0)
+ self.PreviewImage.show()
+ self.PreviewBox.pack_start(self.Label_Size, False, False, 0)
+ self.Label_Size.show()
self.Filename = ""
self.connect("clicked",self._Clicked)
self.FileChooserDialog = None
@@ -43,9 +50,6 @@ def _Clicked(self,e) :
filter = Gtk.FileFilter()
filter.add_pixbuf_formats()
filter.set_name('Image')
- self.PreviewBox.set_size_request(200,-1);
- self.PreviewBox.pack_start(self.PreviewImage, False, False, 0)
- self.PreviewImage.show()
self.FileChooserDialog.add_filter(filter)
self.FileChooserDialog.set_filename(self.Filename)
self.FileChooserDialog.add_shortcut_folder('/usr/share/backgrounds')
@@ -97,8 +101,13 @@ def _UpdatePreview(self,e) :
else :
mimetype, enc = mimetypes.guess_type(PreviewURI,True)
pixbuf = ThumbnailFactory.generate_thumbnail(PreviewURI,mimetype)
+ ThumbnailFactory.save_thumbnail(pixbuf,PreviewURI,mtime)
self.PreviewImage.set_from_pixbuf(pixbuf)
self.FileChooserDialog.set_preview_widget_active(True)
+
+ PreviewWidth = pixbuf.get_option("tEXt::Thumb::Image::Width")
+ PreviewHeight = pixbuf.get_option("tEXt::Thumb::Image::Height")
+ self.Label_Size.set_label( PreviewWidth + " x " + PreviewHeight)
else :
self.FileChooserDialog.set_preview_widget_active(False)
else :
@@ -275,6 +284,74 @@ def Delay_toggled(self,e):
else:
self.SpinButton_Delay.set_sensitive(False)
+class EditButton(Gtk.HBox) :
+ __gtype_name__ = 'EditButton'
+
+ def __init__(self):
+ Gtk.HBox.__init__(self)
+ self.Button = Gtk.Button('text')
+ self.Button.connect("clicked",self.set_state_active)
+ self.add(self.Button)
+ self.Entry = Gtk.Entry()
+ self.Entry.connect("key-press-event",self.key_press)
+ self.Entry.connect("button-press-event",self.button_press)
+ self.Entry.connect("focus-in-event",self.focus_in)
+ self.focus_out_event = None
+ self.update_size()
+
+ def update_size(self):
+ entry_preferred_width = self.Entry.get_preferred_width()[0]
+ entry_preferred_height = self.Entry.get_preferred_height()[0]
+ button_preferred_width = self.Button.get_preferred_width()[0]
+ if entry_preferred_width >= button_preferred_width :
+ preferred_width = entry_preferred_width
+ else :
+ preferred_width = button_preferred_width
+ self.set_size_request(preferred_width,entry_preferred_height)
+
+ def set_state_active(self,w):
+ self.Entry.set_text(self.Button.get_label())
+ self.remove(self.Button)
+ self.add(self.Entry)
+ self.Entry.show()
+ self.Entry.grab_focus()
+
+ def set_state_inactive(self):
+ self.Entry.disconnect(self.focus_out_event)
+ self.remove(self.Entry)
+ self.add(self.Button)
+
+ def key_press(self,w,e):
+ k = Gdk.keyval_name(e.keyval)
+ if k == "Return" :
+ self.Button.set_label(self.Entry.get_text())
+ self.set_state_inactive()
+ self.Button.grab_focus()
+ self.update_size()
+ self.emit("changed")
+ if k == "Escape" :
+ self.set_state_inactive()
+ self.Button.grab_focus()
+
+ def button_press(self,w,e):
+ b = e.button
+ if b == 3:
+ self.Entry.disconnect(self.focus_out_event)
+
+ def focus_out(self,w,e):
+ self.set_state_inactive()
+
+ def focus_in(self,w,e):
+ self.focus_out_event = self.Entry.connect("focus-out-event",self.focus_out)
+
+ def get_text(self):
+ return self.Button.get_label()
+
+ def set_text(self,text):
+ self.Button.set_label(text)
+ self.update_size()
+
+GObject.signal_new("changed", EditButton, GObject.SIGNAL_RUN_FIRST,GObject.TYPE_NONE, ())
class MainWindow(Gtk.Window) :
def __init__(self) :
View
6 gdm3setup.ui
@@ -467,10 +467,9 @@
</packing>
</child>
<child>
- <object class="GtkEntry" id="Entry_logo_icon">
+ <object class="EditButton" id="Entry_logo_icon">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="invisible_char">●</property>
</object>
<packing>
<property name="expand">False</property>
@@ -479,10 +478,9 @@
</packing>
</child>
<child>
- <object class="GtkEntry" id="Entry_banner_text">
+ <object class="EditButton" id="Entry_banner_text">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="invisible_char">●</property>
</object>
<packing>
<property name="expand">False</property>
View
2  install.sh
@@ -26,6 +26,6 @@ install -D apps.nano77.gdm3setup.service /usr/share/dbus-1/system-services/
install -D apps.nano77.gdm3setup.service /usr/share/dbus-1/services/
install -D apps.nano77.gdm3setup.conf /etc/dbus-1/system.d/
install -D apps.nano77.gdm3setup.policy /usr/share/polkit-1/actions/
-install -D gdm3setup.ui /usr/share/gdm3setup/ui/gdm3setup.ui
+install -D gdm3setup.ui /usr/share/gdm3setup/ui/
cp -r locale /usr/share/
View
BIN  locale/it/LC_MESSAGES/gdm3setup.mo
Binary file not shown
Please sign in to comment.
Something went wrong with that request. Please try again.