[gnome-mud] Context Menus within VTE
- From: "Paul Esson" <paul esson gmail com>
- To: gnome-mud-list gnome org
- Subject: [gnome-mud] Context Menus within VTE
- Date: Wed, 3 May 2006 09:59:56 +1000
Hey Guys,
Added callbacks for context menus within the mud-connection-view
Changelog Entry.
2006-05-3 Paul Esson <
paul esson gmail com>
* src/mud-
window.c, src/mud-window.h, src/mud-connection-view.c:
implemented callbacks in context menu within mud-connection-view.
Implemented the following callbacks for the context menu
within mud-connection-view
Close Tab - Close current tab.
Copy/Paste - Copy from VTE
- Paste to Text Input
Edit Current Profile - Bring up the profile preferences.
- Paul
? .cvsignore
? connection-view-context.patch
? patches
? po/stamp-it
? src/changes
? src/mud-window-mconnect_c_tabs.patch
? src/mud-window.diff
? src/mud-window.nopane.patch
? src/mud-window_c_callback.patch
? src/mud-window_c_tabs.patch
? src/mud-window_h_tabs.patch
? src/stuff.txt
? ui/main.glade.patch
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-mud/ChangeLog,v
retrieving revision 1.378
diff -u -r1.378 ChangeLog
--- ChangeLog 26 Apr 2006 20:33:52 -0000 1.378
+++ ChangeLog 2 May 2006 23:55:27 -0000
@@ -1,3 +1,16 @@
+2006-05-3 Paul Esson <paul esson gmail com>
+
+ * src/mud-window.c, src/mud-window.h, src/mud-connection-view.c:
+ implemented callbacks in context menu within mud-connection-view.
+
+ Implemented the following callbacks for the context menu
+ within mud-connection-view
+
+ Close Tab - Close current tab.
+ Copy/Paste - Copy from VTE
+ - Paste to Text Input
+ Edit Current Profile - Bring up the profile preferences.
+
2006-04-25 Mart Raudsepp <leio dustbite net>
* src/mud-window.c, ui/main.glade: Re-implement the input box as
Index: src/mud-connection-view.c
===================================================================
RCS file: /cvs/gnome/gnome-mud/src/mud-connection-view.c,v
retrieving revision 1.11
diff -u -r1.11 mud-connection-view.c
--- src/mud-connection-view.c 23 Apr 2006 17:31:13 -0000 1.11
+++ src/mud-connection-view.c 2 May 2006 23:55:28 -0000
@@ -6,14 +6,21 @@
#include <glib-object.h>
#include <glib/gi18n.h>
#include <gtk/gtkmenu.h>
+#include <gtk/gtkclipboard.h>
+#include <gtk/gtktextview.h>
+#include <gtk/gtktextbuffer.h>
+
#include <vte/vte.h>
+
+
#include "gnome-mud.h"
#include "mud-connection-view.h"
#include "mud-profile.h"
#include "mud-window.h"
#include "mud-tray.h"
#include "mud-log.h"
+#include "mud-preferences-window.h"
struct _MudConnectionViewPrivate
{
@@ -51,6 +58,11 @@
static void mud_connection_view_popup (MudConnectionView *view, GdkEventButton *event);
static void mud_connection_view_reread_profile (MudConnectionView *view);
+static void mud_connection_view_close_page(GtkWidget *widget, MudConnectionView *view);
+static void mud_connection_view_copy(GtkWidget *widget, MudConnectionView *view);
+static void mud_connection_view_paste(GtkWidget *widget, MudConnectionView *view);
+static void mud_connection_edit_profile(GtkWidget *widget, MudConnectionView *view);
+
GType
mud_connection_view_get_type (void)
{
@@ -79,6 +91,7 @@
return object_type;
}
+
static GtkWidget*
append_stock_menuitem(GtkWidget *menu, const gchar *text, GCallback callback, gpointer data)
{
@@ -576,8 +589,8 @@
popup_menu_detach);
append_menuitem(view->priv->popup_menu,
- _("Close tab or window, whatever :)"),
- NULL,
+ _("Close Tab"),
+ G_CALLBACK(mud_connection_view_close_page),
view);
menu_item = gtk_separator_menu_item_new();
@@ -585,11 +598,11 @@
append_stock_menuitem(view->priv->popup_menu,
GTK_STOCK_COPY,
- NULL,
+ G_CALLBACK(mud_connection_view_copy),
view);
append_stock_menuitem(view->priv->popup_menu,
GTK_STOCK_PASTE,
- NULL,
+ G_CALLBACK(mud_connection_view_paste) ,
view);
menu_item = gtk_separator_menu_item_new();
@@ -633,7 +646,7 @@
append_menuitem(view->priv->popup_menu,
_("Edit Current Profile..."),
- NULL,
+ G_CALLBACK(mud_connection_edit_profile),
view);
menu_item = gtk_separator_menu_item_new();
@@ -759,4 +772,35 @@
mud_connection_view_get_terminal(MudConnectionView *view)
{
return view->priv->terminal;
+}
+
+/* Callbacks */
+
+/* Close Current Page */
+static void mud_connection_view_close_page(GtkWidget *widget, MudConnectionView *view){
+ mud_window_close_current_page(view->priv->window);
+}
+
+/* Copy Selected Text To Clipboard */
+static void mud_connection_view_copy(GtkWidget *widget, MudConnectionView *view){
+ vte_terminal_copy_clipboard (VTE_TERMINAL(view->priv->terminal));
+}
+
+/* Paste whatever is in the default clipbord into the textview */
+static void mud_connection_view_paste(GtkWidget *widget, MudConnectionView *view){
+ GtkTextView* input_textview;
+ GtkClipboard* clipboard;
+ GtkTextBuffer* text_buffer;
+
+ input_textview = mud_window_get_input_textview(view->priv->window);
+ text_buffer = gtk_text_view_get_buffer(input_textview);
+ clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
+
+ gtk_text_buffer_paste_clipboard(text_buffer, clipboard, NULL, TRUE);
+ gtk_text_view_set_buffer(input_textview, text_buffer);
+}
+
+/* Edit the Current Profile */
+static void mud_connection_edit_profile(GtkWidget *widget, MudConnectionView *view){
+ mud_preferences_window_new(mud_profile_get_name(view->priv->profile));
}
Index: src/mud-window.c
===================================================================
RCS file: /cvs/gnome/gnome-mud/src/mud-window.c,v
retrieving revision 1.20
diff -u -r1.20 mud-window.c
--- src/mud-window.c 26 Apr 2006 20:33:53 -0000 1.20
+++ src/mud-window.c 2 May 2006 23:55:29 -0000
@@ -160,6 +160,29 @@
gtk_notebook_append_page(GTK_NOTEBOOK(window->priv->notebook), window->priv->image, NULL);
}
}
+
+/* Close the Current Page within the notebook */
+
+void
+mud_window_close_current_page(MudWindow *window)
+{
+ if (window->priv->nr_of_tabs > 0)
+ {
+ gint nr = gtk_notebook_get_current_page(GTK_NOTEBOOK(window->priv->notebook));
+
+ mud_window_remove_connection_view(window, nr);
+
+ if(window->priv->nr_of_tabs == 0)
+ mud_tray_update_icon(window->priv->tray, offline_connecting);
+ }
+}
+
+/* Get the TextView used for input ( Used for Paste within mud-connection view ) */
+
+GtkTextView* mud_window_get_input_textview(MudWindow *window){
+ return window->priv->textview;
+}
+
static void
mud_window_disconnect_cb(GtkWidget *widget, MudWindow *window)
{
@@ -177,16 +200,10 @@
static void
mud_window_closewindow_cb(GtkWidget *widget, MudWindow *window)
{
- if (window->priv->nr_of_tabs > 0)
- {
- gint nr = gtk_notebook_get_current_page(GTK_NOTEBOOK(window->priv->notebook));
- mud_window_remove_connection_view(window, nr);
-
- if(window->priv->nr_of_tabs == 0)
- mud_tray_update_icon(window->priv->tray, offline_connecting);
- }
+
+ mud_window_close_current_page(window);
}
static gint
Index: src/mud-window.h
===================================================================
RCS file: /cvs/gnome/gnome-mud/src/mud-window.h,v
retrieving revision 1.8
diff -u -r1.8 mud-window.h
--- src/mud-window.h 25 Apr 2006 09:12:44 -0000 1.8
+++ src/mud-window.h 2 May 2006 23:55:29 -0000
@@ -36,7 +36,9 @@
void mud_window_handle_plugins(MudWindow *window, gint id, gchar *data, gint dir);
void mud_window_populate_profiles_menu(MudWindow *window);
void mud_window_profile_menu_set_active(gchar *name, MudWindow *window);
+void mud_window_close_current_page(MudWindow *window);
+GtkTextView* mud_window_get_input_textview(MudWindow *window);
GtkWidget* mud_window_get_window(MudWindow *window);
extern GtkWidget *pluginMenu;
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]