/soc/2015/igor.gajowiak/chatlog: 33fd88ed5f84: Implement a gener...

Igor Gajowiak igor.gajowiak at gmail.com
Tue Jul 21 20:24:21 EDT 2015


Changeset: 33fd88ed5f84dfc2f7e9c82ddf2223cae3537c48
Author:	 Igor Gajowiak <igor.gajowiak at gmail.com>
Date:	 2015-07-22 02:24 +0200
Branch:	 default
URL: https://hg.pidgin.im/soc/2015/igor.gajowiak/chatlog/rev/33fd88ed5f84

Description:

Implement a generic log UI stub.

diffstat:

 pidgin/Makefile.am     |    2 +
 pidgin/gtkgenericlog.c |  465 +++++++++++++++++++++++++++++++++++++++++++++++++
 pidgin/gtkgenericlog.h |   79 ++++++++
 pidgin/gtklog.c        |    4 +
 4 files changed, 550 insertions(+), 0 deletions(-)

diffs (truncated from 594 to 300 lines):

diff --git a/pidgin/Makefile.am b/pidgin/Makefile.am
--- a/pidgin/Makefile.am
+++ b/pidgin/Makefile.am
@@ -60,6 +60,7 @@ libpidgin_la_SOURCES = \
 	gtkicon-theme-loader.c \
 	gtkidle.c \
 	gtklog.c \
+	gtkgenericlog.c \
 	gtkmedia.c \
 	gtkmenutray.c \
 	gtknotify.c \
@@ -108,6 +109,7 @@ libpidgin_la_headers = \
 	gtkicon-theme-loader.h \
 	gtkidle.h \
 	gtklog.h \
+	gtkgenericlog.h \
 	gtkmedia.h \
 	gtkmenutray.h \
 	gtknickcolors.h \
diff --git a/pidgin/gtkgenericlog.c b/pidgin/gtkgenericlog.c
new file mode 100644
--- /dev/null
+++ b/pidgin/gtkgenericlog.c
@@ -0,0 +1,465 @@
+/* pidgin
+ *
+ * Pidgin is the legal property of its developers, whose names are too numerous
+ * to list here.  Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
+ */
+
+#include "blistnodetypes.h"
+#include "buddylist.h"
+#include "gtkgenericlog.h"
+#include "gtkutils.h"
+#include "gtkwebview.h"
+
+static PidginGenericLogViewer *generic_log_viewer = NULL;
+
+/******************************************************************************/
+/* Menu                                                                       */
+/******************************************************************************/
+
+static void
+on_search_item_clicked(GtkAction *action, gpointer data)
+{
+	printf("on_search_item_clicked\n");
+}
+
+static void
+on_export_item_clicked(GtkAction *action, gpointer data)
+{
+	printf("on_export_item_clicked\n");
+}
+
+static void
+on_import_item_clicked(GtkAction *action, gpointer data)
+{
+	printf("on_import_item_clicked\n");
+}
+
+static void
+on_close_item_clicked(GtkAction *action, gpointer data)
+{
+	printf("on_close_item_clicked\n");
+}
+
+static void
+on_print_item_clicked(GtkAction *action, gpointer data)
+{
+	printf("on_print_item_clicked\n");
+}
+
+static GtkWidget *
+create_archive_menu_item(PidginGenericLogViewer *viewer)
+{
+	g_assert(viewer);
+
+	GtkWidget *archive_item = gtk_menu_item_new_with_label("Archive");
+
+	GtkWidget *archive_menu = gtk_menu_new();
+	gtk_menu_item_set_submenu(GTK_MENU_ITEM(archive_item), archive_menu);
+
+	GtkWidget *search_item = gtk_menu_item_new_with_label("Search");
+	GtkWidget *export_item = gtk_menu_item_new_with_label("Export");
+	GtkWidget *import_item = gtk_menu_item_new_with_label("Import");
+	GtkWidget *print_item = gtk_menu_item_new_with_label("Print");
+	GtkWidget *close_item = gtk_menu_item_new_with_label("Close");
+
+	gtk_menu_shell_append(GTK_MENU_SHELL(archive_menu), search_item);
+	gtk_menu_shell_append(GTK_MENU_SHELL(archive_menu), export_item);
+	gtk_menu_shell_append(GTK_MENU_SHELL(archive_menu), import_item);
+	gtk_menu_shell_append(GTK_MENU_SHELL(archive_menu), print_item);
+	gtk_menu_shell_append(GTK_MENU_SHELL(archive_menu), close_item);
+
+	g_signal_connect(G_OBJECT(search_item), "activate",
+		G_CALLBACK(on_search_item_clicked), viewer);
+	g_signal_connect(G_OBJECT(export_item), "activate",
+		G_CALLBACK(on_export_item_clicked), viewer);
+	g_signal_connect(G_OBJECT(import_item), "activate",
+		G_CALLBACK(on_import_item_clicked), viewer);
+	g_signal_connect(G_OBJECT(print_item), "activate",
+		G_CALLBACK(on_print_item_clicked), viewer);
+	g_signal_connect(G_OBJECT(close_item), "activate",
+		G_CALLBACK(on_close_item_clicked), viewer);
+
+	return archive_item;
+}
+
+static void
+on_display_status_changes_item_clicked(GtkAction *action, gpointer data)
+{
+	printf("on_display_status_changes_item_clicked\n");
+}
+
+static void
+on_display_inline_msgs_item_clicked(GtkAction *action, gpointer data)
+{
+	printf("on_display_inline_msgs_item_clicked\n");
+}
+
+static GtkWidget *
+create_options_menu_item(PidginGenericLogViewer *viewer)
+{
+	g_assert(viewer);
+
+	GtkWidget *options_item = gtk_menu_item_new_with_label("Options");
+
+	GtkWidget *options_menu = gtk_menu_new();
+	gtk_menu_item_set_submenu(GTK_MENU_ITEM(options_item), options_menu);
+
+	GtkWidget *display_status_changes_item = gtk_menu_item_new_with_label(
+		"Display status changes");
+	GtkWidget *display_inline_msgs_item = gtk_menu_item_new_with_label(
+		"Display inline messages");
+
+	gtk_menu_shell_append(GTK_MENU_SHELL(options_menu),
+		display_status_changes_item);
+	gtk_menu_shell_append(GTK_MENU_SHELL(options_menu),
+		display_inline_msgs_item);
+
+	g_signal_connect(G_OBJECT(display_status_changes_item), "activate",
+		G_CALLBACK(on_display_status_changes_item_clicked), viewer);
+	g_signal_connect(G_OBJECT(display_inline_msgs_item), "activate",
+		G_CALLBACK(on_display_inline_msgs_item_clicked), viewer);
+
+	return options_item;
+}
+
+static void
+on_start_conversation_item_clicked(GtkAction *action, gpointer data)
+{
+	printf("on_start_conversation_item_clicked\n");
+}
+
+static void
+on_wipe_log_for_buddy_item_clicked(GtkAction *action, gpointer data)
+{
+	printf("on_wipe_log_for_buddy_item_clicked\n");
+}
+
+static GtkWidget *
+create_buddy_menu_item(PidginGenericLogViewer *viewer)
+{
+	g_assert(viewer);
+
+	GtkWidget *buddy_item = gtk_menu_item_new_with_label("Buddy");
+
+	GtkWidget *buddy_menu = gtk_menu_new();
+	gtk_menu_item_set_submenu(GTK_MENU_ITEM(buddy_item), buddy_menu);
+
+	GtkWidget *start_conversation_item = gtk_menu_item_new_with_label(
+		"Start conversation");
+	GtkWidget *wipe_log_for_buddy_item = gtk_menu_item_new_with_label(
+		"Wipe log for buddy");
+
+	gtk_menu_shell_append(GTK_MENU_SHELL(buddy_menu),
+		start_conversation_item);
+	gtk_menu_shell_append(GTK_MENU_SHELL(buddy_menu),
+		wipe_log_for_buddy_item);
+
+	g_signal_connect(G_OBJECT(start_conversation_item), "activate",
+		G_CALLBACK(on_start_conversation_item_clicked), viewer);
+	g_signal_connect(G_OBJECT(wipe_log_for_buddy_item), "activate",
+		G_CALLBACK(on_wipe_log_for_buddy_item_clicked), viewer);
+
+	return buddy_item;
+}
+
+static GtkWidget *
+create_menu_bar(PidginGenericLogViewer *viewer)
+{
+	g_assert(viewer);
+
+	GtkWidget *menu_bar = gtk_menu_bar_new();
+
+	GtkWidget *archive_item = create_archive_menu_item(viewer);
+	gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), archive_item);
+
+	GtkWidget *options_item = create_options_menu_item(viewer);
+	gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), options_item);
+
+	GtkWidget *buddy_item = create_buddy_menu_item(viewer);
+	gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), buddy_item);
+
+	return menu_bar;
+}
+
+/******************************************************************************/
+/* Buddy list view                                                            */
+/******************************************************************************/
+
+static void
+on_buddylist_row_activated(GtkTreeView *tv, GtkTreePath *path,
+	GtkTreeViewColumn *col, gpointer data)
+{
+	printf("on_buddylist_row_activated\n");
+}
+
+static void
+on_buddylist_row_changed(GtkTreeSelection *sel, gpointer data)
+{
+	printf("on_buddylist_row_changed\n");
+}
+
+static GtkTreeModel *
+create_buddylist_model(void)
+{
+	// TODO: Fill the store with real values
+
+	GtkTreeStore *store = gtk_tree_store_new(1, G_TYPE_STRING);
+	GtkTreeIter iter;
+
+	gtk_tree_store_append(store, &iter, NULL);
+	gtk_tree_store_set(store, &iter, 0, "Entry 1", -1);
+
+	gtk_tree_store_append(store, &iter, &iter);
+	gtk_tree_store_set(store, &iter, 0, "Entry 2", -1);
+
+	gtk_tree_store_append(store, &iter, NULL);
+	gtk_tree_store_set(store, &iter, 0, "Entry 3", -1);
+
+	GtkTreeModel *model = GTK_TREE_MODEL(store);
+	return model;
+}
+
+static GtkWidget *
+create_buddylist_view(GtkTreeModel *model, PidginGenericLogViewer *viewer)
+{
+	g_assert(model);
+	g_assert(viewer);
+
+	GtkWidget *view = gtk_tree_view_new_with_model(model);
+	GtkCellRenderer *renderer = gtk_cell_renderer_text_new();
+
+	gtk_tree_view_insert_column_with_attributes(
+		GTK_TREE_VIEW (view), -1, "BList", renderer,
+		"text", 0, NULL);
+	gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view), FALSE);
+
+	GtkTreeSelection *selection = gtk_tree_view_get_selection(
+		GTK_TREE_VIEW(view));
+
+	g_signal_connect (G_OBJECT(view), "row-activated",
+		G_CALLBACK(on_buddylist_row_activated), viewer);
+
+	g_signal_connect(G_OBJECT(selection), "changed",
+		G_CALLBACK(on_buddylist_row_changed), viewer);
+
+	return view;
+}
+
+/******************************************************************************/
+/* Calendar view                                                              */
+/******************************************************************************/
+
+static void
+on_calendar_row_activated(GtkTreeView *tv, GtkTreePath *path,
+	GtkTreeViewColumn *col, gpointer data)
+{
+	printf("on_calendar_row_activated\n");
+}
+
+static void
+on_calendar_row_changed(GtkTreeSelection *sel, gpointer data)
+{



More information about the Commits mailing list