From 3f7afad1f69c4021fb2b29135fc5005f8a41f61f Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Wed, 25 Mar 2009 00:11:23 +0100 Subject: Add a commit dialog box. This is a first dialog box. This is not operational. Signed-off-by: Matthieu Gautier --- commit.glade | 148 +++++++++++++++++++++++++++++++++++++++++++++++ g-ed-it.py | 185 ++++++++++++++++++++++++++++++++++------------------------- 2 files changed, 255 insertions(+), 78 deletions(-) create mode 100644 commit.glade diff --git a/commit.glade b/commit.glade new file mode 100644 index 0000000..8342062 --- /dev/null +++ b/commit.glade @@ -0,0 +1,148 @@ + + + + + + + + 667 + False + Commit Message + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_CENTER_ON_PARENT + False + True + True + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + True + False + False + + + + True + False + 4 + + + True + GTK_BUTTONBOX_END + + + + True + True + True + gtk-close + True + GTK_RELIEF_NORMAL + True + -7 + + + + + + + True + False + True + True + gtk-ok + True + GTK_RELIEF_NORMAL + True + -10 + + + + + + + 4 + False + True + GTK_PACK_END + + + + + + 10 + True + False + 18 + + + + True + False + 12 + + + 80 + True + Commit message + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + True + True + True + True + 0 + + True + * + False + + + 0 + True + True + + + + + 0 + True + True + + + + + + 0 + True + True + + + + + + + diff --git a/g-ed-it.py b/g-ed-it.py index 1ae351b..b0943aa 100644 --- a/g-ed-it.py +++ b/g-ed-it.py @@ -1,5 +1,7 @@ import gedit + import gtk +import gtk.glade import gobject @@ -18,84 +20,111 @@ ui_string = """ """ +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) - - # We're going to keep track of each tab's split view - # and, if used, ALT view -- the view of a separate - # document -- with a couple of dictionaries. We'll - # index each dictionary via the tab objects. - self.split_views = {} - self.alt_views = {} - - # This keeps track of whether the user is viewing an ALT document. - self.same_document = {} - - # 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): - 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") - - # Create an action for the "Run in python" menu option - # and set it to call the "run_document_in_python" function. - 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) - - # Add the action with Ctrl + F5 as its keyboard shortcut. - 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) - - # Add the item to the "Views" menu. - self.ui_id = manager.add_ui_from_string(ui_string) - - def remove_menu_item(self): - panel = self.window.get_side_panel() - - panel.remove_item(self.results_view) + 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) class G_ed_it(gedit.Plugin): - def __init__(self): - gedit.Plugin.__init__(self) - self.instances = {} - - def activate(self, window): - self.instances[window] = PluginHelper(self, window) - - def deactivate(self, window): - self.instances[window].deactivate() - - def update_ui(self, window): - self.instances[window].update_ui() + def __init__(self): + gedit.Plugin.__init__(self) + self.instances = {} + + def activate(self, window): + self.instances[window] = PluginHelper(self, window) + + def deactivate(self, window): + self.instances[window].deactivate() + + def update_ui(self, window): + self.instances[window].update_ui() -- cgit