mirror of
https://gitlab.gnome.org/GNOME/gitg
synced 2024-10-03 22:54:15 +00:00
Added Edit menu
This commit is contained in:
parent
6bf650f9cd
commit
0896bcacc6
|
@ -14,6 +14,11 @@
|
|||
<property name="label">_File</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkAction" id="EditAction">
|
||||
<property name="label">_Edit</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
|
@ -32,6 +37,28 @@
|
|||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkActionGroup" id="action_group_menu_edit">
|
||||
<child>
|
||||
<object class="GtkAction" id="EditCutAction">
|
||||
<property name="stock-id">gtk-cut</property>
|
||||
<signal name="activate" handler="on_edit_cut"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkAction" id="EditCopyAction">
|
||||
<property name="stock-id">gtk-copy</property>
|
||||
<signal name="activate" handler="on_edit_copy"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkAction" id="EditPasteAction">
|
||||
<property name="stock-id">gtk-paste</property>
|
||||
<signal name="activate" handler="on_edit_paste"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<ui>
|
||||
<menubar name="menubar_main">
|
||||
<menu action="FileAction">
|
||||
|
@ -39,6 +66,11 @@
|
|||
<separator/>
|
||||
<menuitem action="FileQuitAction"/>
|
||||
</menu>
|
||||
<menu action="EditAction">
|
||||
<menuitem action="EditCutAction"/>
|
||||
<menuitem action="EditCopyAction"/>
|
||||
<menuitem action="EditPasteAction"/>
|
||||
</menu>
|
||||
</menubar>
|
||||
</ui>
|
||||
</object>
|
||||
|
@ -46,6 +78,7 @@
|
|||
<property name="title" translatable="yes">GitG</property>
|
||||
<property name="default_width">800</property>
|
||||
<property name="default_height">600</property>
|
||||
<signal name="set_focus" handler="on_window_set_focus"/>
|
||||
<child>
|
||||
<object class="GtkVBox" id="vbox1">
|
||||
<property name="visible">True</property>
|
||||
|
@ -659,6 +692,7 @@
|
|||
<object class="GtkTextView" id="text_view_comment">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="wrap_mode">word-char</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
|
|
@ -33,6 +33,7 @@ struct _GitgWindowPrivate
|
|||
GtkWidget *search_popup;
|
||||
GtkComboBox *combo_branches;
|
||||
|
||||
GtkActionGroup *edit_group;
|
||||
GtkWidget *open_dialog;
|
||||
};
|
||||
|
||||
|
@ -298,6 +299,8 @@ gitg_window_parser_finished(GtkBuildable *buildable, GtkBuilder *builder)
|
|||
window->priv->revision_tree_view = GITG_REVISION_TREE_VIEW(gtk_builder_get_object(builder, "revision_tree_view"));
|
||||
window->priv->commit_view = GITG_COMMIT_VIEW(gtk_builder_get_object(builder, "hpaned_commit"));
|
||||
|
||||
window->priv->edit_group = GTK_ACTION_GROUP(gtk_builder_get_object(builder, "action_group_menu_edit"));
|
||||
|
||||
GtkTreeViewColumn *col = GTK_TREE_VIEW_COLUMN(gtk_builder_get_object(builder, "rv_column_subject"));
|
||||
gtk_tree_view_column_set_cell_data_func(col, GTK_CELL_RENDERER(gtk_builder_get_object(builder, "rv_renderer_subject")), (GtkTreeCellDataFunc)on_renderer_path, window, NULL);
|
||||
|
||||
|
@ -623,3 +626,46 @@ on_file_open(GtkAction *action, GitgWindow *window)
|
|||
|
||||
g_signal_connect(window->priv->open_dialog, "response", G_CALLBACK(on_open_dialog_response), window);
|
||||
}
|
||||
|
||||
void
|
||||
on_edit_copy(GtkAction *action, GitgWindow *window)
|
||||
{
|
||||
GtkWidget *focus = gtk_window_get_focus(GTK_WINDOW(window));
|
||||
|
||||
g_message("ciopy");
|
||||
g_signal_emit_by_name(focus, "copy-clipboard", 0);
|
||||
}
|
||||
|
||||
void
|
||||
on_edit_cut(GtkAction *action, GitgWindow *window)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
on_edit_paste(GtkAction *action, GitgWindow *window)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
on_window_set_focus(GitgWindow *window, GtkWidget *widget)
|
||||
{
|
||||
if (widget == NULL)
|
||||
return;
|
||||
|
||||
gboolean cancopy = g_signal_lookup("copy-clipboard", G_OBJECT_TYPE(widget)) != 0;
|
||||
gboolean selection = FALSE;
|
||||
gboolean editable = FALSE;
|
||||
|
||||
if (GTK_IS_EDITABLE(widget))
|
||||
{
|
||||
selection = gtk_editable_get_selection_bounds(GTK_EDITABLE(widget), NULL, NULL);
|
||||
editable = gtk_editable_get_editable(GTK_EDITABLE(widget));
|
||||
cancopy = cancopy && selection;
|
||||
}
|
||||
|
||||
gtk_action_set_sensitive(gtk_action_group_get_action(window->priv->edit_group, "EditPasteAction"), editable);
|
||||
gtk_action_set_sensitive(gtk_action_group_get_action(window->priv->edit_group, "EditCutAction"), editable && selection);
|
||||
gtk_action_set_sensitive(gtk_action_group_get_action(window->priv->edit_group, "EditCopyAction"), cancopy);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue