SHARE
TWEET
Untitled
a guest
Jun 27th, 2012
4
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
- ### BEGIN LICENSE
- # This file is in the public domain
- ### END LICENSE
- import gettext
- from gettext import gettext as _
- gettext.textdomain('rymate-notes')
- import os
- from gi.repository import GLib # pylint: disable=E0611
- from gi.repository import Gtk # pylint: disable=E0611
- from gi.repository import Gio # pylint: disable=E0611
- import logging
- logger = logging.getLogger('rymate_notes')
- import pango
- from rymate_notes_lib import Window
- from rymate_notes.AboutRymateNotesDialog import AboutRymateNotesDialog
- from rymate_notes.PreferencesRymateNotesDialog import PreferencesRymateNotesDialog
- # See rymate_notes_lib.Window.py for more details about how this class works
- class RymateNotesWindow(Window):
- __gtype_name__ = "RymateNotesWindow"
- def finish_initializing(self, builder): # pylint: disable=E1002
- """Set up the main window"""
- super(RymateNotesWindow, self).finish_initializing(builder)
- self.AboutDialog = AboutRymateNotesDialog
- self.PreferencesDialog = PreferencesRymateNotesDialog
- settings = Gio.Settings("net.launchpad.rymate-notes")
- pangoFont = pango.FontDescription(settings.get_string("font"))
- self.ui.textview1.modify_font(pangoFont)
- # Code for other initialization actions should be added here.
- def on_mnu_save_activate(self, widget, data=None):
- #get the title for the note
- title = self.ui.comboBoxEntry.get_text()
- #get the string
- buff = self.ui.textview1.get_buffer()
- start_iter = buff.get_start_iter()
- end_iter = buff.get_end_iter()
- text = buff.get_text(start_iter, end_iter, True)
- #create the filename
- data_dir = GLib.get_user_data_dir()
- jotty_dir = os.path.join(data_dir, "rymate_notes")
- filename = os.path.join(jotty_dir, title)
- #write the data
- GLib.mkdir_with_parents(jotty_dir, 0o700)
- GLib.file_set_contents(filename, text)
- #Annnnnd we're done! :)
- print "Saved!"
RAW Paste Data

