2005-09-12 [paul] 1.9.14cvs21
authorPaul Mangan <paul@claws-mail.org>
Mon, 12 Sep 2005 09:44:30 +0000 (09:44 +0000)
committerPaul Mangan <paul@claws-mail.org>
Mon, 12 Sep 2005 09:44:30 +0000 (09:44 +0000)
* AUTHORS
* src/gtk/logwindow.c
add 'Clear Log' to popup menu
Patch by Anders Hammar <anders.hammar@telia.com>

AUTHORS
ChangeLog-gtk2.claws
PATCHSETS
configure.ac
src/gtk/logwindow.c

diff --git a/AUTHORS b/AUTHORS
index bb449ff..5859788 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -230,3 +230,4 @@ contributors (beside the above; based on Changelog)
        M. Benkmann
        Yang Guilong
        Daniel Gustafson
+       Anders Hammar
index 61ef7ca..65313ad 100644 (file)
@@ -1,3 +1,10 @@
+2005-09-12 [paul]      1.9.14cvs21
+
+       * AUTHORS
+       * src/gtk/logwindow.c
+               add 'Clear Log' to popup menu
+               Patch by Anders Hammar <anders.hammar@telia.com>
+
 2005-09-12 [paul]      1.9.14cvs20
 
        * src/compose.c
index a4377d9..3c602ff 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.1.2.4 -r 1.1.2.5 src/plugins/pgpcore/select-keys.c;  ) > 1.9.14cvs18.patchset
 ( cvs diff -u -r 1.3.2.24 -r 1.3.2.25 src/prefs_themes.c;  cvs diff -u -r 1.5.2.10 -r 1.5.2.11 src/gtk/description_window.c;  cvs diff -u -r 1.30.2.4 -r 1.30.2.5 tools/README;  cvs diff -u -r 1.1.2.2 -r 1.1.2.3 tools/claws.i18n.status.pl;  ) > 1.9.14cvs19.patchset
 ( cvs diff -u -r 1.382.2.165 -r 1.382.2.166 src/compose.c;  cvs diff -u -r 1.213.2.55 -r 1.213.2.56 src/folder.c;  cvs diff -u -r 1.5.2.10 -r 1.5.2.11 src/prefs_spelling.c;  cvs diff -u -r 1.1.4.11 -r 1.1.4.12 src/common/xml.c;  ) > 1.9.14cvs20.patchset
+( cvs diff -u -r 1.100.2.25 -r 1.100.2.26 AUTHORS;  cvs diff -u -r 1.1.4.9 -r 1.1.4.10 src/gtk/logwindow.c;  ) > 1.9.14cvs21.patchset
index 09fe171..790f57f 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=14
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=20
+EXTRA_VERSION=21
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 45f6281..c3474bb 100644 (file)
@@ -30,6 +30,8 @@
 #include <gtk/gtkscrolledwindow.h>
 #include <gtk/gtktextview.h>
 #include <gtk/gtkstyle.h>
+#include <gtk/gtkmenuitem.h>
+#include <gtk/gtkseparatormenuitem.h>
 
 #include "logwindow.h"
 #include "utils.h"
 #include "log.h"
 #include "hooks.h"
 
-static void hide_cb                    (GtkWidget      *widget,
-                                        LogWindow      *logwin);
-static gboolean key_pressed            (GtkWidget      *widget,
-                                        GdkEventKey    *event,
-                                        LogWindow      *logwin);
-static gboolean log_window_append      (gpointer        source,
-                                        gpointer        data);
-static void log_window_clip            (GtkWidget      *text,
-                                        guint           glip_length);
-
+static void hide_cb                            (GtkWidget      *widget,
+                                                LogWindow      *logwin);
+static gboolean key_pressed                    (GtkWidget      *widget,
+                                                GdkEventKey    *event,
+                                                LogWindow      *logwin);
+static gboolean log_window_append              (gpointer        source,
+                                                gpointer        data);
+static void log_window_clip                    (GtkWidget      *text,
+                                                guint           glip_length);
+static void log_window_clear                   (GtkWidget      *widget,
+                                                LogWindow      *logwin);
+static void log_window_popup_menu_extend       (GtkTextView    *textview,
+                                                GtkMenu        *menu,
+                                                LogWindow      *logwin);
+                                        
 LogWindow *log_window_create(void)
 {
        LogWindow *logwin;
@@ -85,6 +92,8 @@ LogWindow *log_window_create(void)
        buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text));
        gtk_text_buffer_get_start_iter(buffer, &iter);
        gtk_text_buffer_create_mark(buffer, "end", &iter, FALSE);
+       g_signal_connect(G_OBJECT(text), "populate-popup",
+                        G_CALLBACK(log_window_popup_menu_extend), logwin);
        gtk_container_add(GTK_CONTAINER(scrolledwin), text);
        gtk_widget_show(text);
 
@@ -226,6 +235,9 @@ static gboolean key_pressed(GtkWidget *widget, GdkEventKey *event,
 {
        if (event && event->keyval == GDK_Escape)
                gtk_widget_hide(logwin->window);
+       else if (event && event->keyval == GDK_Delete) 
+               log_window_clear(NULL, logwin);
+
        return FALSE;
 }
 
@@ -251,3 +263,34 @@ static void log_window_clip(GtkWidget *textw, guint clip_length)
                gtk_text_buffer_delete(textbuf, &start_iter, &end_iter);
        }
 }
+
+static void log_window_clear(GtkWidget *widget, LogWindow *logwin)
+{
+       GtkTextView *textview = GTK_TEXT_VIEW(logwin->text);
+       GtkTextBuffer *textbuf = gtk_text_view_get_buffer(textview);
+       GtkTextIter start_iter, end_iter;
+       
+       gtk_text_buffer_get_start_iter(textbuf, &start_iter);
+       gtk_text_buffer_get_end_iter(textbuf, &end_iter);
+       gtk_text_buffer_delete(textbuf, &start_iter, &end_iter);
+}
+
+static void log_window_popup_menu_extend(GtkTextView *textview,
+                       GtkMenu *menu, LogWindow *logwin)
+{
+       GtkWidget *menuitem;
+       
+       g_return_if_fail(menu != NULL);
+       g_return_if_fail(GTK_IS_MENU_SHELL(menu));
+
+       menuitem = gtk_separator_menu_item_new();
+       gtk_menu_shell_prepend(GTK_MENU_SHELL(menu), menuitem);
+       gtk_widget_show(menuitem);
+       
+       menuitem = gtk_menu_item_new_with_mnemonic("Clear _Log");
+       g_signal_connect(G_OBJECT(menuitem), "activate",
+                        G_CALLBACK(log_window_clear), logwin);
+       gtk_menu_shell_prepend(GTK_MENU_SHELL(menu), menuitem);
+       gtk_widget_show(menuitem);
+}
+