anjuta r3914 - in trunk: . plugins/terminal
- From: sgranjoux svn gnome org
- To: svn-commits-list gnome org
- Subject: anjuta r3914 - in trunk: . plugins/terminal
- Date: Fri, 2 May 2008 19:58:46 +0100 (BST)
Author: sgranjoux
Date: Fri May 2 18:58:46 2008
New Revision: 3914
URL: http://svn.gnome.org/viewvc/anjuta?rev=3914&view=rev
Log:
* (added) plugins/terminal/anjuta-terminal-plugin.ui,
plugins/terminal/Makefile.am,
plugins/terminal/terminal.c:
Add a context menu with copy/paste in terminal plugin
Added:
trunk/plugins/terminal/anjuta-terminal-plugin.ui
Modified:
trunk/ChangeLog
trunk/plugins/terminal/Makefile.am
trunk/plugins/terminal/terminal.c
Modified: trunk/plugins/terminal/Makefile.am
==============================================================================
--- trunk/plugins/terminal/Makefile.am (original)
+++ trunk/plugins/terminal/Makefile.am Fri May 2 18:58:46 2008
@@ -2,6 +2,10 @@
terminal_gladedir = $(anjuta_glade_dir)
terminal_glade_DATA = anjuta-terminal-plugin.glade
+# Plugin ui file
+terminal_uidir = $(anjuta_ui_dir)
+terminal_ui_DATA = anjuta-terminal-plugin.ui
+
# Plugin Icon file
terminal_pixmapsdir = $(anjuta_image_dir)
terminal_pixmaps_DATA = \
@@ -47,4 +51,5 @@
$(plugin_in_files) \
$(terminal_plugin_DATA) \
$(terminal_pixmaps_DATA) \
+ $(terminal_ui_DATA) \
$(terminal_glade_DATA)
Added: trunk/plugins/terminal/anjuta-terminal-plugin.ui
==============================================================================
--- (empty file)
+++ trunk/plugins/terminal/anjuta-terminal-plugin.ui Fri May 2 18:58:46 2008
@@ -0,0 +1,7 @@
+<!--*- xml -*-->
+<ui>
+ <popup name="PopupTerminal">
+ <menuitem name="Copy" action="ActionCopyFromTerminal" />
+ <menuitem name="Paste" action="ActionPasteInTerminal" />
+ </popup>
+</ui>
Modified: trunk/plugins/terminal/terminal.c
==============================================================================
--- trunk/plugins/terminal/terminal.c (original)
+++ trunk/plugins/terminal/terminal.c Fri May 2 18:58:46 2008
@@ -30,7 +30,7 @@
#include <signal.h>
-#define UI_FILE PACKAGE_DATA_DIR"/ui/anjuta-terminal.ui"
+#define UI_FILE PACKAGE_DATA_DIR"/ui/anjuta-terminal-plugin.ui"
#define PREFS_GLADE PACKAGE_DATA_DIR"/glade/anjuta-terminal-plugin.glade"
#define ICON_FILE "anjuta-terminal-plugin-48.png"
@@ -78,7 +78,9 @@
struct _TerminalPlugin{
AnjutaPlugin parent;
- AnjutaUI *ui;
+ gint uiid;
+ GtkActionGroup *action_group;
+
AnjutaPreferences *prefs;
pid_t child_pid;
GtkWidget *term;
@@ -432,6 +434,28 @@
return FALSE;
}
+static gboolean
+terminal_click_cb (GtkWidget *widget, GdkEventButton *event,
+ TerminalPlugin *term)
+{
+ if (event->button == 3)
+ {
+ AnjutaUI *ui;
+ GtkMenu *popup;
+ GtkAction *action;
+
+ ui = anjuta_shell_get_ui (ANJUTA_PLUGIN(term)->shell, NULL);
+ popup = GTK_MENU (gtk_ui_manager_get_widget (GTK_UI_MANAGER (ui), "/PopupTerminal"));
+ action = gtk_action_group_get_action (term->action_group, "ActionCopyFromTerminal");
+ gtk_action_set_sensitive (action,vte_terminal_get_has_selection(VTE_TERMINAL(term->term)));
+
+ gtk_menu_popup (popup, NULL, NULL, NULL, NULL,
+ event->button, event->time);
+ }
+
+ return FALSE;
+}
+
#if OLD_VTE == 1
/* VTE has a terrible bug where it could crash when container is changed.
* The problem has been traced in vte where its style-set handler does not
@@ -485,6 +509,38 @@
}
static void
+on_terminal_copy_cb (GtkAction * action, TerminalPlugin *term)
+{
+ if (vte_terminal_get_has_selection(VTE_TERMINAL(term->term)))
+ vte_terminal_copy_clipboard(VTE_TERMINAL(term->term));
+}
+
+static void
+on_terminal_paste_cb (GtkAction * action, TerminalPlugin *term)
+{
+ vte_terminal_paste_clipboard(VTE_TERMINAL(term->term));
+}
+
+static GtkActionEntry actions_terminal[] = {
+ {
+ "ActionCopyFromTerminal", /* Action name */
+ GTK_STOCK_COPY, /* Stock icon, if any */
+ N_("_Copy"), /* Display label */
+ NULL, /* short-cut */
+ NULL, /* Tooltip */
+ G_CALLBACK (on_terminal_copy_cb) /* action callback */
+ },
+ {
+ "ActionPasteInTerminal",
+ GTK_STOCK_PASTE,
+ N_("_Paste"),
+ NULL,
+ NULL,
+ G_CALLBACK (on_terminal_paste_cb)
+ }
+};
+
+static void
terminal_create (TerminalPlugin *term_plugin)
{
GtkWidget *sb, *frame, *hbox;
@@ -504,8 +560,10 @@
G_CALLBACK (terminal_init_cb), term_plugin);
g_signal_connect (G_OBJECT (term_plugin->term), "destroy",
G_CALLBACK (terminal_destroy_cb), term_plugin);
- g_signal_connect (G_OBJECT (term_plugin->term), "event",
+ g_signal_connect (G_OBJECT (term_plugin->term), "key-press-event",
G_CALLBACK (terminal_keypress_cb), term_plugin);
+ g_signal_connect (G_OBJECT (term_plugin->term), "button-press-event",
+ G_CALLBACK (terminal_click_cb), term_plugin);
#if OLD_VTE == 1
g_signal_connect (G_OBJECT (term_plugin->term), "realize",
G_CALLBACK (terminal_realize_cb), term_plugin);
@@ -554,13 +612,22 @@
{
TerminalPlugin *term_plugin;
static gboolean initialized = FALSE;
+ AnjutaUI *ui;
DEBUG_PRINT ("TerminalPlugin: Activating Terminal plugin ...");
term_plugin = ANJUTA_PLUGIN_TERMINAL (plugin);
- term_plugin->ui = anjuta_shell_get_ui (plugin->shell, NULL);
term_plugin->prefs = anjuta_shell_get_preferences (plugin->shell, NULL);
term_plugin->widget_added_to_shell = FALSE;
+ ui = anjuta_shell_get_ui (plugin->shell, NULL);
+ term_plugin->action_group = anjuta_ui_add_action_group_entries (ui,
+ "ActionGroupTerminal",
+ _("terminal operations"),
+ actions_terminal,
+ G_N_ELEMENTS (actions_terminal),
+ GETTEXT_PACKAGE, TRUE, term_plugin);
+ term_plugin->uiid = anjuta_ui_merge (ui, UI_FILE);
+
terminal_create (term_plugin);
if (!initialized)
@@ -586,7 +653,17 @@
deactivate_plugin (AnjutaPlugin *plugin)
{
TerminalPlugin *term_plugin;
+ AnjutaUI *ui;
+
term_plugin = ANJUTA_PLUGIN_TERMINAL (plugin);
+
+ ui = anjuta_shell_get_ui (plugin->shell, NULL);
+ anjuta_ui_unmerge (ui, term_plugin->uiid);
+ if (term_plugin->action_group)
+ {
+ anjuta_ui_remove_action_group (ui, term_plugin->action_group);
+ term_plugin->action_group = NULL;
+ }
prefs_finalize (term_plugin);
@@ -635,6 +712,8 @@
plugin->gconf_notify_ids = NULL;
plugin->child_pid = 0;
plugin->pref_profile_combo = NULL;
+ plugin->uiid = 0;
+ plugin->action_group = NULL;
#if OLD_VTE == 1
plugin->first_time_realization = TRUE;
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]