Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

ImageChooserButton, EditButton

  • Loading branch information...
commit 4876eec671aeca8c071b439693bc59d911ec7443 1 parent 8d0ac00
Nelson Da Silva authored
22 gdm3setup.desktop
... ... @@ -1,15 +1,21 @@
1   -#!/usr/bin/env xdg-open
2 1
3 2 [Desktop Entry]
4   -Version=1.0
5   -Type=Application
6   -Terminal=false
7   -Exec=/usr/bin/gdm3setup.py
8 3 Name=GDM3 Settings
9   -Name[fr_FR]=Paramètres de GDM3
10 4 Name[de_DE]=Einstellungen der GDM3
11   -Name[it_IT]=impostazioni di GDM3
12 5 Name[es_ES]=Configuratión de GDM3
  6 +Name[fr]=Paramètres de GDM3
  7 +Name[it]=Impostazioni di GNOME Display Manager 3
  8 +Comment=Change GDM3 settings
  9 +Comment[de_DE]=Einstellungen ändern für GDM3
  10 +Comment[es_ES]=Cambiar la configuración de GDM3
  11 +Comment[fr]=Modifier les paramètres de GDM3
  12 +Comment[it]=Modifica il impostazioni di GNOME Display Manager 3
  13 +Exec=gdm3setup.py
13 14 Icon=preferences-desktop-theme
14   -Categories=Settings;
  15 +Terminal=false
  16 +Type=Application
  17 +StartupNotify=true
  18 +Categories=GNOME;GTK;Settings;X-GNOME-SystemSettings;
  19 +OnlyShowIn=GNOME;Unity;
  20 +
15 21
83 gdm3setup.py
@@ -7,6 +7,7 @@
7 7 import mimetypes
8 8
9 9 from gi.repository import Gtk
  10 +from gi.repository import Gdk
10 11 from gi.repository import GdkPixbuf
11 12 from gi.repository import GnomeDesktop
12 13 from gi.repository import GObject
@@ -32,6 +33,12 @@ def __init__(self):
32 33 self.Box.pack_end(self.Separator,False,False,2)
33 34 self.PreviewImage = Gtk.Image()
34 35 self.PreviewBox = Gtk.VBox.new(False, 16)
  36 + self.Label_Size = Gtk.Label("0 x 0")
  37 + self.PreviewBox.set_size_request(200,-1);
  38 + self.PreviewBox.pack_start(self.PreviewImage, False, False, 0)
  39 + self.PreviewImage.show()
  40 + self.PreviewBox.pack_start(self.Label_Size, False, False, 0)
  41 + self.Label_Size.show()
35 42 self.Filename = ""
36 43 self.connect("clicked",self._Clicked)
37 44 self.FileChooserDialog = None
@@ -43,9 +50,6 @@ def _Clicked(self,e) :
43 50 filter = Gtk.FileFilter()
44 51 filter.add_pixbuf_formats()
45 52 filter.set_name('Image')
46   - self.PreviewBox.set_size_request(200,-1);
47   - self.PreviewBox.pack_start(self.PreviewImage, False, False, 0)
48   - self.PreviewImage.show()
49 53 self.FileChooserDialog.add_filter(filter)
50 54 self.FileChooserDialog.set_filename(self.Filename)
51 55 self.FileChooserDialog.add_shortcut_folder('/usr/share/backgrounds')
@@ -97,8 +101,13 @@ def _UpdatePreview(self,e) :
97 101 else :
98 102 mimetype, enc = mimetypes.guess_type(PreviewURI,True)
99 103 pixbuf = ThumbnailFactory.generate_thumbnail(PreviewURI,mimetype)
  104 + ThumbnailFactory.save_thumbnail(pixbuf,PreviewURI,mtime)
100 105 self.PreviewImage.set_from_pixbuf(pixbuf)
101 106 self.FileChooserDialog.set_preview_widget_active(True)
  107 +
  108 + PreviewWidth = pixbuf.get_option("tEXt::Thumb::Image::Width")
  109 + PreviewHeight = pixbuf.get_option("tEXt::Thumb::Image::Height")
  110 + self.Label_Size.set_label( PreviewWidth + " x " + PreviewHeight)
102 111 else :
103 112 self.FileChooserDialog.set_preview_widget_active(False)
104 113 else :
@@ -275,6 +284,74 @@ def Delay_toggled(self,e):
275 284 else:
276 285 self.SpinButton_Delay.set_sensitive(False)
277 286
  287 +class EditButton(Gtk.HBox) :
  288 + __gtype_name__ = 'EditButton'
  289 +
  290 + def __init__(self):
  291 + Gtk.HBox.__init__(self)
  292 + self.Button = Gtk.Button('text')
  293 + self.Button.connect("clicked",self.set_state_active)
  294 + self.add(self.Button)
  295 + self.Entry = Gtk.Entry()
  296 + self.Entry.connect("key-press-event",self.key_press)
  297 + self.Entry.connect("button-press-event",self.button_press)
  298 + self.Entry.connect("focus-in-event",self.focus_in)
  299 + self.focus_out_event = None
  300 + self.update_size()
  301 +
  302 + def update_size(self):
  303 + entry_preferred_width = self.Entry.get_preferred_width()[0]
  304 + entry_preferred_height = self.Entry.get_preferred_height()[0]
  305 + button_preferred_width = self.Button.get_preferred_width()[0]
  306 + if entry_preferred_width >= button_preferred_width :
  307 + preferred_width = entry_preferred_width
  308 + else :
  309 + preferred_width = button_preferred_width
  310 + self.set_size_request(preferred_width,entry_preferred_height)
  311 +
  312 + def set_state_active(self,w):
  313 + self.Entry.set_text(self.Button.get_label())
  314 + self.remove(self.Button)
  315 + self.add(self.Entry)
  316 + self.Entry.show()
  317 + self.Entry.grab_focus()
  318 +
  319 + def set_state_inactive(self):
  320 + self.Entry.disconnect(self.focus_out_event)
  321 + self.remove(self.Entry)
  322 + self.add(self.Button)
  323 +
  324 + def key_press(self,w,e):
  325 + k = Gdk.keyval_name(e.keyval)
  326 + if k == "Return" :
  327 + self.Button.set_label(self.Entry.get_text())
  328 + self.set_state_inactive()
  329 + self.Button.grab_focus()
  330 + self.update_size()
  331 + self.emit("changed")
  332 + if k == "Escape" :
  333 + self.set_state_inactive()
  334 + self.Button.grab_focus()
  335 +
  336 + def button_press(self,w,e):
  337 + b = e.button
  338 + if b == 3:
  339 + self.Entry.disconnect(self.focus_out_event)
  340 +
  341 + def focus_out(self,w,e):
  342 + self.set_state_inactive()
  343 +
  344 + def focus_in(self,w,e):
  345 + self.focus_out_event = self.Entry.connect("focus-out-event",self.focus_out)
  346 +
  347 + def get_text(self):
  348 + return self.Button.get_label()
  349 +
  350 + def set_text(self,text):
  351 + self.Button.set_label(text)
  352 + self.update_size()
  353 +
  354 +GObject.signal_new("changed", EditButton, GObject.SIGNAL_RUN_FIRST,GObject.TYPE_NONE, ())
278 355
279 356 class MainWindow(Gtk.Window) :
280 357 def __init__(self) :
6 gdm3setup.ui
@@ -467,10 +467,9 @@
467 467 </packing>
468 468 </child>
469 469 <child>
470   - <object class="GtkEntry" id="Entry_logo_icon">
  470 + <object class="EditButton" id="Entry_logo_icon">
471 471 <property name="visible">True</property>
472 472 <property name="can_focus">True</property>
473   - <property name="invisible_char">●</property>
474 473 </object>
475 474 <packing>
476 475 <property name="expand">False</property>
@@ -479,10 +478,9 @@
479 478 </packing>
480 479 </child>
481 480 <child>
482   - <object class="GtkEntry" id="Entry_banner_text">
  481 + <object class="EditButton" id="Entry_banner_text">
483 482 <property name="visible">True</property>
484 483 <property name="can_focus">True</property>
485   - <property name="invisible_char">●</property>
486 484 </object>
487 485 <packing>
488 486 <property name="expand">False</property>
2  install.sh
@@ -26,6 +26,6 @@ install -D apps.nano77.gdm3setup.service /usr/share/dbus-1/system-services/
26 26 install -D apps.nano77.gdm3setup.service /usr/share/dbus-1/services/
27 27 install -D apps.nano77.gdm3setup.conf /etc/dbus-1/system.d/
28 28 install -D apps.nano77.gdm3setup.policy /usr/share/polkit-1/actions/
29   -install -D gdm3setup.ui /usr/share/gdm3setup/ui/gdm3setup.ui
  29 +install -D gdm3setup.ui /usr/share/gdm3setup/ui/
30 30 cp -r locale /usr/share/
31 31
BIN  locale/it/LC_MESSAGES/gdm3setup.mo
Binary file not shown

0 comments on commit 4876eec

Please sign in to comment.
Something went wrong with that request. Please try again.