#define DINGUS1 "(((news|telnet|nttp|file|http|ftp|https)://)|(www|ftp)[-A-Za-z0-9]*\\.)[-A-Za-z0-9\\.]+(:[0-9]*)?"
#define DINGUS2 "(((news|telnet|nttp|file|http|ftp|https)://)|(www|ftp)[-A-Za-z0-9]*\\.)[-A-Za-z0-9\\.]+(:[0-9]*)?/[-A-Za-z0-9_\\$\\.\\+\\!\\*\\(\\),;:@&=\\?/~\\#\\%]*[^]'\\.}>\\) ,\\\"]"
+/*******************************************************************************
+ * All popup-menu code is below
+ ******************************************************************************/
+
+static void
+menu_add_term_cb (GtkWidget *widget, gpointer data)
+{
+ debug_enter ();
+ debug_assert (TILDA_IS_TERMINAL(data));
+
+ TildaTerminal *self = TILDA_TERMINAL(data);
+ TildaWindow *parent_window = TILDA_WINDOW(self->parent_window);
+
+ tilda_window_add_terminal (parent_window);
+}
+
+static void
+menu_remove_term_cb (GtkWidget *widget, gpointer data)
+{
+ debug_enter ();
+ debug_assert (TILDA_IS_TERMINAL(data));
+
+ TildaTerminal *self = TILDA_TERMINAL(data);
+ TildaWindow *parent_window = TILDA_WINDOW(self->parent_window);
+
+ tilda_window_remove_terminal (parent_window, self->number);
+}
+
+static void
+menu_copy_cb (GtkWidget *widget, gpointer data)
+{
+ debug_enter ();
+ debug_assert (TILDA_IS_TERMINAL(data));
+
+ TildaTerminal *self = TILDA_TERMINAL(data);
+
+ vte_terminal_copy_clipboard (VTE_TERMINAL(self->vte_term));
+}
+
+static void
+menu_paste_cb (GtkWidget *widget, gpointer data)
+{
+ debug_enter ();
+ debug_assert (TILDA_IS_TERMINAL(data));
+
+ TildaTerminal *self = TILDA_TERMINAL(data);
+
+ vte_terminal_paste_clipboard (VTE_TERMINAL(self->vte_term));
+}
+
+static void
+menu_preferences_cb (GtkWidget *widget, gpointer data)
+{
+ debug_enter ();
+ debug_assert (TILDA_IS_TERMINAL(data));
+
+ TildaTerminal *self = TILDA_TERMINAL(data);
+ TildaWindow *parent_window = TILDA_WINDOW(self->parent_window);
+
+ /* TODO:
+ *
+ * Note that this lends interesting possibilities for the tilda-wizard
+ * command line interface. Maybe a --window --terminal option, which will
+ * auto-set the preferences to a current window and term :) Neat.
+ */
+
+ g_print ("FIXME: show wizard here\n");
+}
+
+static void
+menu_quit_cb (GtkWidget *widget, gpointer data)
+{
+ debug_enter ();
+ debug_assert (TILDA_IS_TERMINAL(data));
+
+ TildaTerminal *self = TILDA_TERMINAL(data);
+ TildaWindow *parent_window = TILDA_WINDOW(self->parent_window);
+ TildaController *controller = TILDA_CONTROLLER(parent_window->controller);
+
+ tilda_controller_remove_window (controller, parent_window->number);
+}
+
+static void
+tilda_terminal_popup_menu (TildaTerminal *self)
+{
+ debug_enter ();
+ debug_assert (TILDA_IS_TERMINAL(self));
+
+ GtkAction *action;
+ GtkActionGroup *action_group;
+ GtkUIManager *ui_manager;
+ GError *error = NULL;
+ GtkWidget *menu;
+
+ /* Just use a static string here to initialize the GtkUIManager,
+ * rather than installing and reading from a file all the time. */
+ static const gchar menu_str[] =
+ "<ui>"
+ "<popup name=\"popup-menu\">"
+ "<menuitem action=\"add-term\" />"
+ "<menuitem action=\"remove-term\" />"
+ "<separator />"
+ "<menuitem action=\"copy\" />"
+ "<menuitem action=\"paste\" />"
+ "<separator />"
+ "<menuitem action=\"preferences\" />"
+ "<separator />"
+ "<menuitem action=\"quit\" />"
+ "</popup>"
+ "</ui>";
+
+ TildaWindow *parent_window = TILDA_WINDOW(self->parent_window);
+
+ /* Create the action group */
+ action_group = gtk_action_group_new ("popup-menu-action-group");
+
+ /* Add Actions and connect callbacks */
+ action = gtk_action_new ("add-term", _("_Add Terminal"), NULL, GTK_STOCK_ADD);
+ gtk_action_group_add_action_with_accel (action_group, action, parent_window->accel_add_term);
+ g_signal_connect (G_OBJECT(action), "activate", G_CALLBACK(menu_add_term_cb), self);
+
+ action = gtk_action_new ("remove-term", _("_Remove Terminal"), NULL, GTK_STOCK_CLOSE);
+ gtk_action_group_add_action_with_accel (action_group, action, parent_window->accel_remove_term);
+ g_signal_connect (G_OBJECT(action), "activate", G_CALLBACK(menu_remove_term_cb), self);
+
+ action = gtk_action_new ("copy", NULL, NULL, GTK_STOCK_COPY);
+ gtk_action_group_add_action_with_accel (action_group, action, parent_window->accel_copy);
+ g_signal_connect (G_OBJECT(action), "activate", G_CALLBACK(menu_copy_cb), self);
+
+ action = gtk_action_new ("paste", NULL, NULL, GTK_STOCK_PASTE);
+ gtk_action_group_add_action_with_accel (action_group, action, parent_window->accel_paste);
+ g_signal_connect (G_OBJECT(action), "activate", G_CALLBACK(menu_paste_cb), self);
+
+ action = gtk_action_new ("preferences", NULL, NULL, GTK_STOCK_PREFERENCES);
+ gtk_action_group_add_action (action_group, action);
+ g_signal_connect (G_OBJECT(action), "activate", G_CALLBACK(menu_preferences_cb), self);
+
+ action = gtk_action_new ("quit", NULL, NULL, GTK_STOCK_QUIT);
+ gtk_action_group_add_action_with_accel (action_group, action, parent_window->accel_quit);
+ g_signal_connect (G_OBJECT(action), "activate", G_CALLBACK(menu_quit_cb), self);
+
+ /* Create and add actions to the GtkUIManager */
+ ui_manager = gtk_ui_manager_new ();
+ gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
+ gtk_ui_manager_add_ui_from_string (ui_manager, menu_str, -1, &error);
+
+ /* Check for an error (REALLY REALLY unlikely, unless the developers screwed up */
+ if (error)
+ {
+ g_critical ("GtkUIManager problem: %s\n", error->message);
+ g_error_free (error);
+ }
+
+ /* Get the popup menu out of the GtkUIManager */
+ menu = gtk_ui_manager_get_widget (ui_manager, "/ui/popup-menu");
+
+ /* Display the menu */
+ gtk_menu_popup (GTK_MENU(menu), NULL, NULL, NULL, NULL, 3, gtk_get_current_event_time());
+ gtk_widget_show_all(menu);
+}
+
+/*******************************************************************************
+ * All TildaTerminal functions below
+ ******************************************************************************/
+
static void
tilda_terminal_dbus_register_object (TildaTerminal *tt)
{
switch (event->button)
{
case 3: /* Right Click */
- // FIXME: need to add this
- //popup_menu (tt->tw, tt);
- g_print ("FIXME: popup_menu() here\n");
+ tilda_terminal_popup_menu (self);
break;
case 2: /* Middle Click */