[gitg] Implemented tag create, remove and checkout
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: svn-commits-list gnome org
- Subject: [gitg] Implemented tag create, remove and checkout
- Date: Sun, 5 Jul 2009 17:40:37 +0000 (UTC)
commit 10062d12d673a384bafb9ddd7a9305edef5dbef6
Author: Jesse van den Kieboom <jessevdk gnome org>
Date: Sun Jul 5 19:12:31 2009 +0200
Implemented tag create, remove and checkout
gitg/Makefile.am | 1 +
gitg/gitg-branch-actions.c | 122 ++++++++++++++++++++++++
gitg/gitg-branch-actions.h | 3 +
gitg/gitg-menus.xml | 24 +++++-
gitg/gitg-preferences.c | 27 +++++-
gitg/gitg-tag.ui | 158 +++++++++++++++++++++++++++++++
gitg/gitg-window.c | 224 +++++++++++++++++++++++++++++++++++++++++--
7 files changed, 545 insertions(+), 14 deletions(-)
---
diff --git a/gitg/Makefile.am b/gitg/Makefile.am
index 7b387a3..93074c0 100644
--- a/gitg/Makefile.am
+++ b/gitg/Makefile.am
@@ -95,6 +95,7 @@ ui_DATA = \
gitg-ui.xml \
gitg-menus.xml \
gitg-preferences.ui \
+ gitg-tag.ui \
gitg-repository.ui
gitg-enum-types.h: gitg-enum-types.h.template $(ENUM_H_FILES) $(GLIB_MKENUMS)
diff --git a/gitg/gitg-branch-actions.c b/gitg/gitg-branch-actions.c
index fc887f9..28636c1 100644
--- a/gitg/gitg-branch-actions.c
+++ b/gitg/gitg-branch-actions.c
@@ -445,6 +445,50 @@ remove_stash (GitgWindow *window, GitgRef *ref)
return NULL;
}
+static GitgRunner *
+remove_tag (GitgWindow *window, GitgRef *ref)
+{
+ gchar const *name = gitg_ref_get_shortname (ref);
+ gchar *message = g_strdup_printf (_("Are you sure you want to remove the tag <%s>?"),
+ name);
+ gint r = message_dialog (window,
+ GTK_MESSAGE_QUESTION,
+ _("Remove tag"),
+ message,
+ _("Remove tag"));
+ g_free (message);
+
+ if (r != GTK_RESPONSE_ACCEPT)
+ {
+ return NULL;
+ }
+
+ GitgRepository *repository = gitg_window_get_repository (window);
+
+ if (!gitg_repository_commandv (repository,
+ NULL,
+ "tag",
+ "-d",
+ name,
+ NULL))
+ {
+ message = g_strdup_printf (_("The tag <%s> could not be successfully removed"),
+ name);
+ message_dialog (window,
+ GTK_MESSAGE_ERROR,
+ _("Failed to remove tag"),
+ message,
+ NULL);
+ g_free (message);
+ return NULL;
+ }
+ else
+ {
+ gitg_repository_reload (repository);
+ return NULL;
+ }
+}
+
GitgRunner *
gitg_branch_actions_remove (GitgWindow *window,
GitgRef *ref)
@@ -466,6 +510,8 @@ gitg_branch_actions_remove (GitgWindow *window,
case GITG_REF_TYPE_STASH:
ret = remove_stash (window, cp);
default:
+ case GITG_REF_TYPE_TAG:
+ ret = remove_tag (window, cp);
break;
}
@@ -822,6 +868,45 @@ checkout_remote_branch (GitgWindow *window,
return ret;
}
+static gboolean
+checkout_tag (GitgWindow *window,
+ GitgRef *ref)
+{
+ if (!stash_changes (window, NULL, TRUE))
+ {
+ return FALSE;
+ }
+
+ GitgRepository *repository = gitg_window_get_repository (window);
+ gchar const *name = gitg_ref_get_shortname (ref);
+ gboolean ret;
+
+ if (!gitg_repository_commandv (repository,
+ NULL,
+ "checkout",
+ "-b",
+ name,
+ name,
+ NULL))
+ {
+ message_dialog (window,
+ GTK_MESSAGE_ERROR,
+ _("Failed to checkout tag <%s> to local branch <%s>"),
+ NULL,
+ NULL,
+ name,
+ name);
+ ret = FALSE;
+ }
+ else
+ {
+ gitg_repository_load (repository, 1, (gchar const **)&name, NULL);
+ ret = TRUE;
+ }
+
+ return ret;
+}
+
gboolean
gitg_branch_actions_checkout (GitgWindow *window,
GitgRef *ref)
@@ -839,6 +924,8 @@ gitg_branch_actions_checkout (GitgWindow *window,
case GITG_REF_TYPE_REMOTE:
ret = checkout_remote_branch (window, cp);
break;
+ case GITG_REF_TYPE_TAG:
+ ret = checkout_tag (window, cp);
default:
break;
}
@@ -1345,3 +1432,38 @@ gitg_branch_actions_apply_stash (GitgWindow *window,
return ret;
}
+gboolean
+gitg_branch_actions_tag (GitgWindow *window, gchar const *sha1, gchar const *name, gchar const *message, gboolean sign)
+{
+ g_return_val_if_fail (GITG_IS_WINDOW (window), FALSE);
+ g_return_val_if_fail (sha1 != NULL, FALSE);
+ g_return_val_if_fail (name != NULL, FALSE);
+ g_return_val_if_fail (message != NULL, FALSE);
+
+ GitgRepository *repository;
+
+ repository = gitg_window_get_repository (window);
+
+ if (!gitg_repository_commandv (repository,
+ NULL,
+ "tag",
+ "-m",
+ message,
+ sign ? "-s" : "-a",
+ name,
+ sha1,
+ NULL))
+ {
+ message_dialog (window,
+ GTK_MESSAGE_ERROR,
+ _("Failed to create tag"),
+ _("The tag object could not be successfully created"),
+ NULL);
+ return FALSE;
+ }
+ else
+ {
+ gitg_repository_reload (repository);
+ return TRUE;
+ }
+}
diff --git a/gitg/gitg-branch-actions.h b/gitg/gitg-branch-actions.h
index 1cb9d64..224f007 100644
--- a/gitg/gitg-branch-actions.h
+++ b/gitg/gitg-branch-actions.h
@@ -38,6 +38,9 @@ GitgRunner *gitg_branch_actions_push (GitgWindow *window, GitgRef *source, GitgR
GitgRunner *gitg_branch_actions_push_remote (GitgWindow *window, GitgRef *source, gchar const *remote);
gboolean gitg_branch_actions_apply_stash (GitgWindow *window, GitgRef *stash, GitgRef *branch);
+
+gboolean gitg_branch_actions_tag (GitgWindow *window, gchar const *sha1, gchar const *name, gchar const *message, gboolean sign);
+
G_END_DECLS
#endif /* __GITG_BRANCH_ACTIONS_H__ */
diff --git a/gitg/gitg-menus.xml b/gitg/gitg-menus.xml
index 2a15470..c9617aa 100644
--- a/gitg/gitg-menus.xml
+++ b/gitg/gitg-menus.xml
@@ -35,7 +35,7 @@
</object>
</child>
<child>
- <object class="GtkActionGroup" id="action_group_revision">
+ <object class="GtkActionGroup" id="action_group_ref">
<child>
<object class="GtkAction" id="CheckoutAction">
<property name="label">Checkout branch</property>
@@ -86,6 +86,22 @@
</child>
</object>
</child>
+ <child>
+ <object class="GtkActionGroup" id="action_group_revision">
+ <child>
+ <object class="GtkAction" id="TagAction">
+ <property name="label">Create tag</property>
+ <signal name="activate" handler="on_revision_tag_activate"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkAction" id="SquashAction">
+ <property name="label">Squash revisions</property>
+ <signal name="activate" handler="on_revision_squash_activate"/>
+ </object>
+ </child>
+ </object>
+ </child>
<ui>
<popup name="search_popup">
<menuitem action="subject"/>
@@ -93,7 +109,7 @@
<menuitem action="date"/>
<menuitem action="hash"/>
</popup>
- <popup name="revision_popup">
+ <popup name="ref_popup">
<menuitem action="CheckoutAction"/>
<menuitem action="RemoveAction"/>
<separator/>
@@ -114,6 +130,10 @@
<menuitem action="RebaseDndAction"/>
<menuitem action="MergeDndAction"/>
</popup>
+ <popup name="revision_popup">
+ <menuitem action="TagAction"/>
+ <menuitem action="SquashAction"/>
+ </popup>
</ui>
</object>
</interface>
diff --git a/gitg/gitg-preferences.c b/gitg/gitg-preferences.c
index c101dd0..8995d65 100644
--- a/gitg/gitg-preferences.c
+++ b/gitg/gitg-preferences.c
@@ -45,6 +45,8 @@ enum
PROP_MESSAGE_SHOW_RIGHT_MARGIN,
PROP_MESSAGE_RIGHT_MARGIN_AT,
+
+ PROP_HIDDEN_SIGN_TAG,
PROP_STYLE_TEXT_FOREGROUND,
PROP_STYLE_TEXT_BACKGROUND,
@@ -205,7 +207,17 @@ install_property_binding(guint prop_id, gchar const *group, gchar const *name, W
g_snprintf(b->key, PATH_MAX, "%s/%s/%s", KEY_ROOT, group, name);
- gchar const *prefix = g_utf8_strrchr(group, -1, '/') + 1;
+ gchar const *prefix = g_utf8_strrchr(group, -1, '/');
+
+ if (prefix)
+ {
+ prefix += 1;
+ }
+ else
+ {
+ prefix = group;
+ }
+
g_snprintf(b->property, PATH_MAX, "%s-%s", prefix, name);
b->wrap_get = wrap_get;
@@ -416,6 +428,19 @@ gitg_preferences_class_init(GitgPreferencesClass *klass)
72,
G_PARAM_READWRITE));
+ install_property_binding(PROP_HIDDEN_SIGN_TAG,
+ "hidden",
+ "sign-tag",
+ wrap_get_boolean,
+ wrap_set_boolean);
+
+ g_object_class_install_property(object_class, PROP_HIDDEN_SIGN_TAG,
+ g_param_spec_boolean("hidden-sign-tag",
+ "HIDDEN_SIGN_TAG",
+ "Whether to sign tag objects",
+ TRUE,
+ G_PARAM_READWRITE));
+
install_style_properties(object_class, PROP_STYLE_TEXT_FOREGROUND, "text");
install_style_properties(object_class, PROP_STYLE_ADDED_LINE_FOREGROUND, "added-line");
install_style_properties(object_class, PROP_STYLE_REMOVED_LINE_FOREGROUND, "removed-line");
diff --git a/gitg/gitg-tag.ui b/gitg/gitg-tag.ui
new file mode 100644
index 0000000..cb4b62b
--- /dev/null
+++ b/gitg/gitg-tag.ui
@@ -0,0 +1,158 @@
+<?xml version="1.0"?>
+<interface>
+ <!-- interface-requires gtk+ 2.12 -->
+ <!-- interface-naming-policy toplevel-contextual -->
+ <object class="GtkDialog" id="dialog_tag">
+ <property name="border_width">5</property>
+ <property name="title" translatable="yes">Properties</property>
+ <property name="window_position">center-always</property>
+ <property name="default_width">400</property>
+ <property name="default_height">200</property>
+ <property name="destroy_with_parent">True</property>
+ <property name="type_hint">normal</property>
+ <property name="has_separator">False</property>
+ <child internal-child="vbox">
+ <object class="GtkVBox" id="dialog_vbox_main">
+ <property name="visible">True</property>
+ <property name="spacing">2</property>
+ <child>
+ <object class="GtkTable" id="table_main">
+ <property name="visible">True</property>
+ <property name="n_rows">3</property>
+ <property name="n_columns">2</property>
+ <property name="column_spacing">6</property>
+ <property name="row_spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="label_name">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Name:</property>
+ </object>
+ <packing>
+ <property name="x_options">GTK_SHRINK | GTK_FILL</property>
+ <property name="y_options">GTK_SHRINK</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label_message">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0</property>
+ <property name="label" translatable="yes">Message:</property>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_SHRINK | GTK_FILL</property>
+ <property name="y_options">GTK_SHRINK | GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="entry_name">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">●</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolled_window_message">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">automatic</property>
+ <property name="vscrollbar_policy">automatic</property>
+ <property name="shadow_type">etched-in</property>
+ <child>
+ <object class="GtkTextView" id="text_view_message">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="check_button_sign">
+ <property name="label" translatable="yes">Create signed tag object</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child internal-child="action_area">
+ <object class="GtkHButtonBox" id="dialog_action_area">
+ <property name="visible">True</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="button_cancel">
+ <property name="label">gtk-cancel</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="button_tag">
+ <property name="label" translatable="yes">Create tag</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="has_focus">True</property>
+ <property name="is_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="has_default">True</property>
+ <property name="receives_default">True</property>
+ <property name="image">image_tag</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="-6">button_cancel</action-widget>
+ <action-widget response="-3">button_tag</action-widget>
+ </action-widgets>
+ </object>
+ <object class="GtkImage" id="image_tag">
+ <property name="visible">True</property>
+ <property name="stock">gtk-apply</property>
+ </object>
+</interface>
diff --git a/gitg/gitg-window.c b/gitg/gitg-window.c
index 8f4d4e5..b11c687 100644
--- a/gitg/gitg-window.c
+++ b/gitg/gitg-window.c
@@ -42,6 +42,7 @@
#include "gitg-repository-dialog.h"
#include "gitg-dnd.h"
#include "gitg-branch-actions.h"
+#include "gitg-preferences.h"
#define DYNAMIC_ACTION_DATA_KEY "GitgDynamicActionDataKey"
@@ -1588,7 +1589,7 @@ update_merge_rebase (GitgWindow *window, GitgRef *ref)
gtk_ui_manager_add_ui (window->priv->menus_ui_manager,
window->priv->merge_rebase_uid,
- "/ui/revision_popup/Rebase/Placeholder",
+ "/ui/ref_popup/Rebase/Placeholder",
name,
rebase,
GTK_UI_MANAGER_MENUITEM,
@@ -1599,7 +1600,7 @@ update_merge_rebase (GitgWindow *window, GitgRef *ref)
gtk_ui_manager_add_ui (window->priv->menus_ui_manager,
window->priv->merge_rebase_uid,
- "/ui/revision_popup/Merge/Placeholder",
+ "/ui/ref_popup/Merge/Placeholder",
name,
merge,
GTK_UI_MANAGER_MENUITEM,
@@ -1631,7 +1632,7 @@ update_merge_rebase (GitgWindow *window, GitgRef *ref)
gtk_ui_manager_add_ui (window->priv->menus_ui_manager,
window->priv->merge_rebase_uid,
- "/ui/revision_popup/Stash/Placeholder",
+ "/ui/ref_popup/Stash/Placeholder",
name,
stash,
GTK_UI_MANAGER_MENUITEM,
@@ -1661,7 +1662,7 @@ update_merge_rebase (GitgWindow *window, GitgRef *ref)
gchar *name = g_strconcat ("Push", *ptr, NULL);
gtk_ui_manager_add_ui (window->priv->menus_ui_manager,
window->priv->merge_rebase_uid,
- "/ui/revision_popup/Push/Placeholder",
+ "/ui/ref_popup/Push/Placeholder",
name,
push,
GTK_UI_MANAGER_MENUITEM,
@@ -1718,7 +1719,7 @@ has_local_ref (GitgWindow *window,
}
static gboolean
-popup_revision (GitgWindow *window, GdkEventButton *event)
+popup_ref (GitgWindow *window, GdkEventButton *event)
{
gint cell_x;
gint cell_y;
@@ -1753,16 +1754,17 @@ popup_revision (GitgWindow *window, GdkEventButton *event)
if (!ref || (gitg_ref_get_ref_type (ref) != GITG_REF_TYPE_BRANCH &&
gitg_ref_get_ref_type (ref) != GITG_REF_TYPE_REMOTE &&
- gitg_ref_get_ref_type (ref) != GITG_REF_TYPE_STASH))
+ gitg_ref_get_ref_type (ref) != GITG_REF_TYPE_STASH &&
+ gitg_ref_get_ref_type (ref) != GITG_REF_TYPE_TAG))
{
return FALSE;
}
GtkWidget *popup = gtk_ui_manager_get_widget (window->priv->menus_ui_manager,
- "/ui/revision_popup");
+ "/ui/ref_popup");
- GtkAction *checkout = gtk_ui_manager_get_action (window->priv->menus_ui_manager, "/ui/revision_popup/CheckoutAction");
- GtkAction *remove = gtk_ui_manager_get_action (window->priv->menus_ui_manager, "/ui/revision_popup/RemoveAction");
+ GtkAction *checkout = gtk_ui_manager_get_action (window->priv->menus_ui_manager, "/ui/ref_popup/CheckoutAction");
+ GtkAction *remove = gtk_ui_manager_get_action (window->priv->menus_ui_manager, "/ui/ref_popup/RemoveAction");
if (gitg_ref_get_ref_type (ref) == GITG_REF_TYPE_REMOTE)
{
@@ -1798,6 +1800,23 @@ popup_revision (GitgWindow *window, GdkEventButton *event)
gtk_action_set_label (remove, _("Remove stash"));
gtk_action_set_visible (checkout, FALSE);
}
+ else if (gitg_ref_get_ref_type (ref) == GITG_REF_TYPE_TAG)
+ {
+ gtk_action_set_label (remove, _("Remove tag"));
+
+ if (!has_local_ref (window, gitg_ref_get_shortname (ref)))
+ {
+ gchar *label = g_strdup_printf (_("New local branch <%s>"), gitg_ref_get_shortname (ref));
+
+ gtk_action_set_label (checkout, label);
+ gtk_action_set_visible (checkout, TRUE);
+ g_free (label);
+ }
+ else
+ {
+ gtk_action_set_visible (checkout, FALSE);
+ }
+ }
update_merge_rebase (window, ref);
window->priv->popup_refs[0] = ref;
@@ -1806,13 +1825,66 @@ popup_revision (GitgWindow *window, GdkEventButton *event)
return TRUE;
}
+static gboolean
+consecutive_revisions (GitgWindow *window, GList *rows)
+{
+ return FALSE;
+}
+
+static gboolean
+popup_revision (GitgWindow *window, GdkEventButton *event)
+{
+ GtkTreeSelection *selection;
+
+ selection = gtk_tree_view_get_selection (window->priv->tree_view);
+ GList *rows = gtk_tree_selection_get_selected_rows (selection, NULL);
+
+ gboolean show = FALSE;
+
+ if (rows)
+ {
+ GtkAction *tag = gtk_ui_manager_get_action (window->priv->menus_ui_manager, "/ui/revision_popup/TagAction");
+ GtkAction *squash = gtk_ui_manager_get_action (window->priv->menus_ui_manager, "/ui/revision_popup/SquashAction");
+
+ if (!rows->next)
+ {
+ show = TRUE;
+ gtk_action_set_visible (squash, FALSE);
+ gtk_action_set_visible (tag, TRUE);
+ }
+ else if (consecutive_revisions (window, rows))
+ {
+ show = TRUE;
+ gtk_action_set_visible (squash, TRUE);
+ gtk_action_set_visible (tag, FALSE);
+ }
+ }
+
+ g_list_foreach (rows, (GFunc)gtk_tree_path_free, NULL);
+ g_list_free (rows);
+
+ if (!show)
+ {
+ return FALSE;
+ }
+
+ gtk_menu_popup (GTK_MENU (gtk_ui_manager_get_widget (window->priv->menus_ui_manager, "/ui/revision_popup")),
+ NULL,
+ NULL,
+ NULL,
+ window,
+ event->button,
+ event->time);
+
+ return TRUE;
+}
+
gboolean
on_tree_view_rv_button_press_event (GtkWidget *widget, GdkEventButton *event, GitgWindow *window)
{
if (event->button == 3)
{
- // Check to find a ref
- return popup_revision (window, event);
+ return popup_ref (window, event) || popup_revision (window, event);
}
return FALSE;
@@ -1871,3 +1943,133 @@ on_merge_branch_action_activate (GtkAction *action, GitgWindow *window)
window->priv->popup_refs[source]));
}
+typedef struct
+{
+ GtkBuilder *builder;
+ GitgWindow *window;
+ GitgRevision *revision;
+} TagInfo;
+
+static void
+free_tag_info (TagInfo *info)
+{
+ g_object_unref (info->builder);
+ gitg_revision_unref (info->revision);
+
+ g_slice_free (TagInfo, info);
+}
+
+static void
+on_tag_dialog_response (GtkWidget *dialog, gint response, TagInfo *info)
+{
+ gboolean destroy = TRUE;
+
+ if (response == GTK_RESPONSE_ACCEPT)
+ {
+ gchar const *name = gtk_entry_get_text (GTK_ENTRY (gtk_builder_get_object (info->builder, "entry_name")));
+
+ GtkTextView *view = GTK_TEXT_VIEW (gtk_builder_get_object (info->builder, "text_view_message"));
+ GtkTextIter start;
+ GtkTextIter end;
+
+ gtk_text_buffer_get_bounds (gtk_text_view_get_buffer (view), &start, &end);
+ gchar *message = gtk_text_iter_get_text (&start, &end);
+
+ if (!*name || !*message)
+ {
+ GtkWidget *dlg = gtk_message_dialog_new (GTK_WINDOW (dialog),
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK,
+ _("Not all fields are correctly filled in"));
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dlg),
+ _("Please make sure to fill in both the tag name and the commit message"));
+
+ g_signal_connect (dlg, "response", G_CALLBACK (gtk_widget_destroy), NULL);
+ gtk_widget_show (dlg);
+
+ destroy = FALSE;
+ }
+ else
+ {
+ gboolean sign = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (info->builder, "check_button_sign")));
+
+ gchar *sha1 = gitg_revision_get_sha1 (info->revision);
+ gitg_branch_actions_tag (info->window,
+ sha1,
+ name,
+ message,
+ sign);
+ g_free (sha1);
+
+ GitgPreferences *preferences = gitg_preferences_get_default ();
+ g_object_set (preferences, "hidden-sign-tag", sign, NULL);
+ }
+
+ g_free (message);
+ }
+
+ if (destroy)
+ {
+ g_slice_free (TagInfo, info);
+ gtk_widget_destroy (dialog);
+ }
+}
+
+
+
+void
+on_revision_tag_activate (GtkAction *action, GitgWindow *window)
+{
+ GtkTreeSelection *selection;
+ GtkTreeModel *model;
+
+ selection = gtk_tree_view_get_selection (window->priv->tree_view);
+ GList *rows = gtk_tree_selection_get_selected_rows (selection, &model);
+
+ GitgPreferences *preferences = gitg_preferences_get_default ();
+
+ if (rows && !rows->next)
+ {
+ GtkBuilder *builder = gitg_utils_new_builder ("gitg-tag.ui");
+ GtkWidget *widget = GTK_WIDGET (gtk_builder_get_object (builder, "dialog_tag"));
+
+ GtkToggleButton *toggle = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "check_button_sign"));
+
+ gboolean active = TRUE;
+
+ g_object_get (preferences, "hidden-sign-tag", &active, NULL);
+ gtk_toggle_button_set_active (toggle, active);
+
+ gtk_window_set_transient_for (GTK_WINDOW (widget), GTK_WINDOW (window));
+
+ GtkTreeIter iter;
+ GitgRevision *rev;
+
+ gtk_tree_model_get_iter (model, &iter, (GtkTreePath *)rows->data);
+ gtk_tree_model_get (model, &iter, 0, &rev, -1);
+
+ TagInfo *info = g_slice_new (TagInfo);
+ info->revision = gitg_revision_ref (rev);
+ info->window = window;
+ info->builder = builder;
+
+ g_signal_connect (widget,
+ "response",
+ G_CALLBACK (on_tag_dialog_response),
+ info);
+
+ gtk_widget_show (widget);
+
+ gtk_widget_grab_focus (GTK_WIDGET (gtk_builder_get_object (builder, "entry_name")));
+ }
+
+ g_list_foreach (rows, (GFunc)gtk_tree_path_free, NULL);
+ g_list_free (rows);
+}
+
+void
+on_revision_squash_activate (GtkAction *action, GitgWindow *window)
+{
+
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]