summaryrefslogtreecommitdiffstats
path: root/g-ed-it
diff options
context:
space:
mode:
Diffstat (limited to 'g-ed-it')
-rw-r--r--g-ed-it/__init__.py21
-rw-r--r--g-ed-it/commit.glade148
-rw-r--r--g-ed-it/g_ed_it.py118
3 files changed, 287 insertions, 0 deletions
diff --git a/g-ed-it/__init__.py b/g-ed-it/__init__.py
new file mode 100644
index 0000000..d57f401
--- /dev/null
+++ b/g-ed-it/__init__.py
@@ -0,0 +1,21 @@
+import gedit
+
+import os
+import os.path
+
+import g_ed_it
+
+
+class G_ed_it(gedit.Plugin):
+ def __init__(self):
+ gedit.Plugin.__init__(self)
+ self.instances = {}
+
+ def activate(self, window):
+ self.instances[window] = g_ed_it.PluginHelper(self, window)
+
+ def deactivate(self, window):
+ self.instances[window].deactivate()
+
+ def update_ui(self, window):
+ self.instances[window].update_ui()
diff --git a/g-ed-it/commit.glade b/g-ed-it/commit.glade
new file mode 100644
index 0000000..8342062
--- /dev/null
+++ b/g-ed-it/commit.glade
@@ -0,0 +1,148 @@
+<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
+<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
+
+<glade-interface>
+<requires lib="gnome"/>
+
+<widget class="GtkDialog" id="commit_dialog">
+ <property name="width_request">667</property>
+ <property name="visible">False</property>
+ <property name="title" translatable="yes">Commit Message</property>
+ <property name="type">GTK_WINDOW_TOPLEVEL</property>
+ <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
+ <property name="modal">False</property>
+ <property name="resizable">True</property>
+ <property name="destroy_with_parent">True</property>
+ <property name="decorated">True</property>
+ <property name="skip_taskbar_hint">False</property>
+ <property name="skip_pager_hint">False</property>
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+ <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+ <property name="focus_on_map">True</property>
+ <property name="urgency_hint">False</property>
+ <property name="has_separator">False</property>
+
+ <child internal-child="vbox">
+ <widget class="GtkVBox" id="dialog-vbox1">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">4</property>
+ <child internal-child="action_area">
+ <widget class="GtkHButtonBox" id="dialog-action_area1">
+ <property name="visible">True</property>
+ <property name="layout_style">GTK_BUTTONBOX_END</property>
+
+ <child>
+ <widget class="GtkButton" id="cancel_button">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label">gtk-close</property>
+ <property name="use_stock">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="response_id">-7</property>
+ <accelerator key="Escape" modifiers="0" signal="clicked"/>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkButton" id="commit_button">
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label">gtk-ok</property>
+ <property name="use_stock">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="response_id">-10</property>
+ <accelerator key="Return" modifiers="0" signal="clicked"/>
+ </widget>
+ </child>
+
+ </widget>
+ <packing>
+ <property name="padding">4</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">GTK_PACK_END</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkVBox" id="vbox1">
+ <property name="border_width">10</property>
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">18</property>
+
+ <child>
+ <widget class="GtkHBox" id="hbox1">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">12</property>
+ <child>
+ <widget class="GtkLabel" id="labelsearchfor">
+ <property name="width_request">80</property>
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Commit message</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkEntry" id="commit_text">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">True</property>
+ <property name="visibility">True</property>
+ <property name="max_length">0</property>
+ <property name="text" translatable="yes"></property>
+ <property name="has_frame">True</property>
+ <property name="invisible_char">*</property>
+ <property name="activates_default">False</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ <!-- perhaps use GTK Label for explaining this uses Python re-->
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+</widget>
+
+</glade-interface>
diff --git a/g-ed-it/g_ed_it.py b/g-ed-it/g_ed_it.py
new file mode 100644
index 0000000..553dff4
--- /dev/null
+++ b/g-ed-it/g_ed_it.py
@@ -0,0 +1,118 @@
+import gedit
+
+import gtk
+import gtk.glade
+
+import gobject
+
+import os
+import time
+
+ui_string = """<ui>
+ <menubar name="MenuBar">
+ <placeholder name="ExtraMenu_1">
+ <menu action="GitMenu">
+ <menuitem action="Commit"/>
+ <menuitem action="Add"/>
+ </menu>
+ </placeholder>
+ </menubar>
+</ui>
+"""
+
+GLADE_FILE = os.path.join(os.path.dirname(__file__), "commit.glade")
+
+class PluginHelper:
+ def __init__(self, plugin, window):
+ self.window = window
+ self.plugin = plugin
+
+ self.ui_id = None
+
+ # Add a "toggle split view" item to the View menu
+ self.insert_menu_item(window)
+ self.load_dialogs()
+
+
+ # I hardly even know how this works, but it gets our encoding.
+ try: self.encoding = gedit.encoding_get_current()
+ except: self.encoding = gedit.gedit_encoding_get_current()
+
+ def deactivate(self):
+ self.remove_menu_item()
+
+ self.window = None
+ self.plugin = None
+
+ def update_ui(self):
+ return
+
+ def commit_action(self, window):
+ self._search_dialog.show()
+ pass
+
+ ###
+ # Called when the "Close" button is clicked.
+ def on_cancel_button_clicked(self, close_button):
+ self._search_dialog.hide()
+
+ def on_commit_button_clicked(self, close_button):
+ pass
+
+ ###
+ # Called when the text to be replaced is changed.
+ def on_commit_text_changed(self, commit_text_entry):
+ pass
+
+
+ def add_action(self, window):
+ pass
+
+ def insert_menu_item(self, window):
+ manager = self.window.get_ui_manager()
+
+ self.action_group = gtk.ActionGroup("GitPluginActions")
+
+ self.git_menu_action_ = gtk.Action(name="GitMenu", label="Git", tooltip="Manage git", stock_id=None)
+ self.commit_action_ = gtk.Action(name="Commit", label="Commit", tooltip="Commit current state", stock_id=gtk.STOCK_GO_UP)
+ self.add_action_ = gtk.Action(name="Add", label="Add to index", tooltip="", stock_id=gtk.STOCK_ADD)
+ self.commit_action_.connect("activate", self.commit_action)
+ self.add_action_.connect("activate", self.add_action)
+
+ self.action_group.add_action(self.git_menu_action_)
+ self.action_group.add_action(self.commit_action_)
+ self.action_group.add_action(self.add_action_)
+
+ # Add the action group.
+ manager.insert_action_group(self.action_group, -1)
+
+ self.ui_id = manager.add_ui_from_string(ui_string)
+
+ def remove_menu_item(self):
+ manager.remove_ui(self.ui_id)
+ manager.remove_action_group(self.action_group)
+ manager.ensure_update()
+
+ ###
+ # Load commit dialog.
+ # - Load dialog from its Glade file
+ # - Connect widget signals
+ # - Put needed widgets in object variables.
+ def load_dialogs(self):
+ self.glade_xml = gtk.glade.XML(GLADE_FILE)
+
+ self._search_dialog = self.glade_xml.get_widget("commit_dialog")
+ self._search_dialog.hide()
+ self._search_dialog.set_transient_for(self.window)
+ self._search_dialog.connect("delete_event", self._search_dialog.hide_on_delete)
+
+ self._find_button = self.glade_xml.get_widget("commit_button")
+ self._find_button.connect("clicked", self.on_commit_button_clicked)
+
+ close_button = self.glade_xml.get_widget("cancel_button")
+ close_button.connect("clicked", self.on_cancel_button_clicked)
+
+ self._search_text_box = self.glade_xml.get_widget("commit_text")
+ self._search_text_box.connect("changed", self.on_commit_text_changed)
+
+