/soc/2015/igor.gajowiak/chatlog: dd33748bb679: Implemented start...
Igor Gajowiak
igor.gajowiak at gmail.com
Fri Jul 31 19:08:40 EDT 2015
Changeset: dd33748bb679ea86d9c74a08dc4e16a73a732f8e
Author: Igor Gajowiak <igor.gajowiak at gmail.com>
Date: 2015-08-01 01:08 +0200
Branch: default
URL: https://hg.pidgin.im/soc/2015/igor.gajowiak/chatlog/rev/dd33748bb679
Description:
Implemented start conversation button.
diffstat:
pidgin/gtkgenericlog.c | 71 +++++++++++++++++++++++++++++++++++++++++++------
pidgin/gtkgenericlog.h | 3 ++
2 files changed, 65 insertions(+), 9 deletions(-)
diffs (154 lines):
diff --git a/pidgin/gtkgenericlog.c b/pidgin/gtkgenericlog.c
--- a/pidgin/gtkgenericlog.c
+++ b/pidgin/gtkgenericlog.c
@@ -146,7 +146,17 @@ create_options_menu_item(PidginGenericLo
static void
on_start_conversation_item_clicked(GtkAction *action, gpointer data)
{
- printf("on_start_conversation_item_clicked\n");
+ g_assert(data);
+
+ PidginGenericLogViewer *viewer = (PidginGenericLogViewer*) data;
+
+ PurpleBuddy *buddy = viewer->current_buddy;
+ g_return_if_fail(buddy != NULL);
+
+ PurpleAccount *account = purple_buddy_get_account(buddy);
+ g_return_if_fail(account != NULL);
+
+ purple_im_conversation_new(account, purple_buddy_get_name(buddy));
}
static void
@@ -156,7 +166,9 @@ on_wipe_log_for_buddy_item_clicked(GtkAc
}
static GtkWidget *
-create_buddy_menu_item(PidginGenericLogViewer *viewer)
+create_buddy_menu_item(PidginGenericLogViewer *viewer,
+ GtkWidget **start_conversation_item_res,
+ GtkWidget **wipe_log_for_buddy_item_res)
{
g_assert(viewer);
@@ -180,11 +192,16 @@ create_buddy_menu_item(PidginGenericLogV
g_signal_connect(G_OBJECT(wipe_log_for_buddy_item), "activate",
G_CALLBACK(on_wipe_log_for_buddy_item_clicked), viewer);
+ *start_conversation_item_res = start_conversation_item;
+ *wipe_log_for_buddy_item_res = wipe_log_for_buddy_item;
+
return buddy_item;
}
static GtkWidget *
-create_menu_bar(PidginGenericLogViewer *viewer)
+create_menu_bar(PidginGenericLogViewer *viewer,
+ GtkWidget **start_conversation_item_res,
+ GtkWidget **wipe_log_for_buddy_item_res)
{
g_assert(viewer);
@@ -196,12 +213,40 @@ create_menu_bar(PidginGenericLogViewer *
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);
+ GtkWidget *buddy_item = create_buddy_menu_item(viewer,
+ start_conversation_item_res, wipe_log_for_buddy_item_res);
gtk_menu_shell_append(GTK_MENU_SHELL(menu_bar), buddy_item);
return menu_bar;
}
+static void
+update_menu_buttons(PidginGenericLogViewer *viewer)
+{
+ g_assert(viewer);
+
+ gboolean start_conv_enabled = TRUE;
+ gboolean wipe_log_enabled = TRUE;
+
+ if (!viewer->current_buddy) {
+ start_conv_enabled = FALSE;
+ wipe_log_enabled = FALSE;
+ }
+ else {
+ PurpleAccount *account = purple_buddy_get_account(
+ viewer->current_buddy);
+
+ /* Disable start conversation button if account is disabled */
+ if (!account || !purple_account_get_connection(account))
+ start_conv_enabled = FALSE;
+ }
+
+ gtk_widget_set_sensitive(viewer->start_conversation_item,
+ start_conv_enabled);
+ gtk_widget_set_sensitive(viewer->wipe_log_for_buddy_item,
+ wipe_log_enabled);
+}
+
/******************************************************************************/
/* Buddy list view */
/******************************************************************************/
@@ -256,6 +301,8 @@ on_buddylist_row_changed(GtkTreeSelectio
}
}
+ update_menu_buttons(viewer);
+
/* Unhook calendar model during updating to get better performance */
gtk_tree_view_set_model(GTK_TREE_VIEW(viewer->calendar_tree_view), NULL);
@@ -774,12 +821,16 @@ on_close_response(GtkWidget *widget, gin
}
static GtkWidget *
-create_window(PidginGenericLogViewer *viewer, GtkWidget **buddylist_view_res,
- GtkTreeStore **buddylist_store_res, GtkWidget **calendar_view_res,
- GtkTreeStore **calendar_store_res, GtkWidget **webview_res,
- PidginConvTheme **theme_res)
+create_window(PidginGenericLogViewer *viewer,
+ GtkWidget **start_conversation_item_res,
+ GtkWidget **wipe_log_for_buddy_item_res,
+ GtkWidget **buddylist_view_res, GtkTreeStore **buddylist_store_res,
+ GtkWidget **calendar_view_res, GtkTreeStore **calendar_store_res,
+ GtkWidget **webview_res, PidginConvTheme **theme_res)
{
g_assert(viewer);
+ g_assert(start_conversation_item_res);
+ g_assert(wipe_log_for_buddy_item_res);
g_assert(buddylist_view_res);
g_assert(buddylist_store_res);
g_assert(calendar_view_res);
@@ -800,7 +851,8 @@ create_window(PidginGenericLogViewer *vi
g_signal_connect(G_OBJECT(window), "delete_event",
G_CALLBACK(gtk_widget_hide_on_delete), NULL);
- GtkWidget *menu_bar = create_menu_bar(viewer);
+ GtkWidget *menu_bar = create_menu_bar(viewer, start_conversation_item_res,
+ wipe_log_for_buddy_item_res);
gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(window))),
menu_bar, FALSE, TRUE, 0);
@@ -847,6 +899,7 @@ create_genericlog_viewer()
PidginGenericLogViewer *viewer = g_new0(PidginGenericLogViewer, 1);
viewer->window = create_window(viewer,
+ &viewer->start_conversation_item, &viewer->wipe_log_for_buddy_item,
&viewer->blist_tree_view, &viewer->blist_tree_store,
&viewer->calendar_tree_view, &viewer->calendar_tree_store,
&viewer->webview, &viewer->theme);
diff --git a/pidgin/gtkgenericlog.h b/pidgin/gtkgenericlog.h
--- a/pidgin/gtkgenericlog.h
+++ b/pidgin/gtkgenericlog.h
@@ -32,6 +32,9 @@ typedef struct PidginGenericLogViewer
{
GtkWidget *window;
+ GtkWidget *start_conversation_item;
+ GtkWidget *wipe_log_for_buddy_item;
+
GtkWidget *blist_tree_view;
GtkTreeStore *blist_tree_store;
More information about the Commits
mailing list