~ubuntu-branches/ubuntu/precise/remmina/precise-updates

« back to all changes in this revision

Viewing changes to remmina/src/remmina_log.c

  • Committer: Package Import Robot
  • Author(s): Luca Falavigna
  • Date: 2012-02-11 17:28:48 UTC
  • mfrom: (1.2.8)
  • Revision ID: package-import@ubuntu.com-20120211172848-rh3ffi7075qyobuq
Tags: 1.0.0-1
* New upstream release.
  - Compatible with FreeRDP 1.0 (Closes: #658363).
  - Ported to GTK3, this also fixes an incompatibility with
    GTK2 and recent Avahi with GTK3 support, which lead to
    crashes when scanning network services (Closes: #626499).
* debian/patches/libvncserver.patch:
  - Do not use convenience copy of libvncserver.
* debian/patches/g_thread_init.patch:
  - Do not use deprecated g_thread_init function.
* debian/patches/REMMINA_COMMAND_NONE.patch:
  - Removed, obsoleted by GApplication port.
* debian/clean:
  - Remove spurious files created at build-time.
* debian/compat:
  - Bump compatibility level to 9.
* debian/control:
  - Refresh build-dependencies to match new structure.
  - Drop remmina-dev package, no longer used.
  - Build packages once provided by remmina-plugins.
  - Provide remmina-common package.
  - Provide remmina-plugin-gnome package.
* debian/copyright:
  - Refresh copyright information.
* debian/docs:
  - Documentation is no longer accurate, do not ship it anymore.
* debian/remmina-dev.install:
  - Drop remmina-dev package, no longer used.
* debian/remmina-plugin-telepathy.install:
  - Adjust location for Remmina.client.
  - Disable D-BUS support for now.
* debian/rules:
  - Compile with -DWITH_APPINDICATOR=OFF.
  - Do not treat plugins as shared libraries.
* debian/watch:
  - Adjust watch file to match new download location.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Remmina - The GTK+ Remote Desktop Client
 
3
 * Copyright (C) 2010 Vic Lee 
 
4
 *
 
5
 * This program is free software; you can redistribute it and/or modify
 
6
 * it under the terms of the GNU General Public License as published by
 
7
 * the Free Software Foundation; either version 2 of the License, or
 
8
 * (at your option) any later version.
 
9
 *
 
10
 * This program is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 * GNU General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU General Public License
 
16
 * along with this program; if not, write to the Free Software
 
17
 * Foundation, Inc., 59 Temple Place, Suite 330, 
 
18
 * Boston, MA 02111-1307, USA.
 
19
 */
 
20
 
 
21
#include <gtk/gtk.h>
 
22
#include <glib/gi18n.h>
 
23
#include "remmina_public.h"
 
24
#include "remmina_log.h"
 
25
 
 
26
/***** Define the log window GUI *****/
 
27
#define REMMINA_TYPE_LOG_WINDOW               (remmina_log_window_get_type ())
 
28
#define REMMINA_LOG_WINDOW(obj)               (G_TYPE_CHECK_INSTANCE_CAST ((obj), REMMINA_TYPE_LOG_WINDOW, RemminaLogWindow))
 
29
#define REMMINA_LOG_WINDOW_CLASS(klass)       (G_TYPE_CHECK_CLASS_CAST ((klass), REMMINA_TYPE_LOG_WINDOW, RemminaLogWindowClass))
 
30
#define REMMINA_IS_LOG_WINDOW(obj)            (G_TYPE_CHECK_INSTANCE_TYPE ((obj), REMMINA_TYPE_LOG_WINDOW))
 
31
#define REMMINA_IS_LOG_WINDOW_CLASS(klass)    (G_TYPE_CHECK_CLASS_TYPE ((klass), REMMINA_TYPE_LOG_WINDOW))
 
32
#define REMMINA_LOG_WINDOW_GET_CLASS(obj)     (G_TYPE_INSTANCE_GET_CLASS ((obj), REMMINA_TYPE_LOG_WINDOW, RemminaLogWindowClass))
 
33
 
 
34
typedef struct _RemminaLogWindow
 
35
{
 
36
        GtkWindow window;
 
37
 
 
38
        GtkWidget *log_view;
 
39
        GtkTextBuffer *log_buffer;
 
40
} RemminaLogWindow;
 
41
 
 
42
typedef struct _RemminaLogWindowClass
 
43
{
 
44
        GtkWindowClass parent_class;
 
45
} RemminaLogWindowClass;
 
46
 
 
47
GType remmina_log_window_get_type(void)
 
48
G_GNUC_CONST;
 
49
 
 
50
G_DEFINE_TYPE(RemminaLogWindow, remmina_log_window, GTK_TYPE_WINDOW)
 
51
 
 
52
static void remmina_log_window_class_init(RemminaLogWindowClass *klass)
 
53
{
 
54
}
 
55
 
 
56
static void remmina_log_window_init(RemminaLogWindow *logwin)
 
57
{
 
58
        GtkWidget *scrolledwindow;
 
59
        GtkWidget *widget;
 
60
 
 
61
        gtk_container_set_border_width(GTK_CONTAINER(logwin), 4);
 
62
 
 
63
        scrolledwindow = gtk_scrolled_window_new(NULL, NULL);
 
64
        gtk_widget_show(scrolledwindow);
 
65
        gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
 
66
        gtk_container_add(GTK_CONTAINER(logwin), scrolledwindow);
 
67
 
 
68
        widget = gtk_text_view_new();
 
69
        gtk_widget_show(widget);
 
70
        gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(widget), GTK_WRAP_WORD_CHAR);
 
71
        gtk_text_view_set_editable(GTK_TEXT_VIEW(widget), FALSE);
 
72
        gtk_container_add(GTK_CONTAINER(scrolledwindow), widget);
 
73
        logwin->log_view = widget;
 
74
        logwin->log_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(widget));
 
75
}
 
76
 
 
77
static GtkWidget*
 
78
remmina_log_window_new(void)
 
79
{
 
80
        return GTK_WIDGET(g_object_new(REMMINA_TYPE_LOG_WINDOW, NULL));
 
81
}
 
82
 
 
83
/* We will always only have one log window per instance */
 
84
static GtkWidget *log_window = NULL;
 
85
 
 
86
static void remmina_log_end(GtkWidget *widget, gpointer data)
 
87
{
 
88
        log_window = NULL;
 
89
}
 
90
 
 
91
void remmina_log_start(void)
 
92
{
 
93
        if (log_window)
 
94
        {
 
95
                gtk_window_present(GTK_WINDOW(log_window));
 
96
        }
 
97
        else
 
98
        {
 
99
                log_window = remmina_log_window_new();
 
100
                gtk_window_set_default_size(GTK_WINDOW(log_window), 640, 480);
 
101
                g_signal_connect(G_OBJECT(log_window), "destroy", G_CALLBACK(remmina_log_end), NULL);
 
102
                gtk_widget_show(log_window);
 
103
        }
 
104
}
 
105
 
 
106
gboolean remmina_log_running(void)
 
107
{
 
108
        return (log_window != NULL);
 
109
}
 
110
 
 
111
static gboolean remmina_log_scroll_to_end(gpointer data)
 
112
{
 
113
        GtkTextIter iter;
 
114
 
 
115
        if (log_window)
 
116
        {
 
117
                gtk_text_buffer_get_end_iter(REMMINA_LOG_WINDOW (log_window)->log_buffer, &iter);
 
118
                gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(REMMINA_LOG_WINDOW (log_window)->log_view), &iter, 0.0, FALSE, 0.0,
 
119
                                0.0);
 
120
        }
 
121
        return FALSE;
 
122
}
 
123
 
 
124
static gboolean remmina_log_print_real(gpointer data)
 
125
{
 
126
        GtkTextIter iter;
 
127
 
 
128
        if (log_window)
 
129
        {
 
130
                gtk_text_buffer_get_end_iter(REMMINA_LOG_WINDOW (log_window)->log_buffer, &iter);
 
131
                gtk_text_buffer_insert(REMMINA_LOG_WINDOW (log_window)->log_buffer, &iter, (const gchar*) data, -1);
 
132
                IDLE_ADD(remmina_log_scroll_to_end, NULL);
 
133
        }
 
134
        g_free(data);
 
135
        return FALSE;
 
136
}
 
137
 
 
138
void remmina_log_print(const gchar *text)
 
139
{
 
140
        if (!log_window)
 
141
                return;
 
142
 
 
143
        IDLE_ADD(remmina_log_print_real, g_strdup(text));
 
144
}
 
145
 
 
146
void remmina_log_printf(const gchar *fmt, ...)
 
147
{
 
148
        va_list args;
 
149
        gchar *text;
 
150
 
 
151
        if (!log_window) return;
 
152
 
 
153
        va_start (args, fmt);
 
154
        text = g_strdup_vprintf (fmt, args);
 
155
        va_end (args);
 
156
 
 
157
        IDLE_ADD (remmina_log_print_real, text);
 
158
}
 
159