From f04a0e55193e33fb9a0f5f2885ce26f43d971837 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 7 Jun 2008 23:31:04 +0000 Subject: done --- TODO | 10 +-- gnunet-gtk.glade | 73 +++++++++++++++++--- pixmaps/self.png | Bin 0 -> 2010 bytes pixmaps/self.svg | 172 ++++++++++++++++++++++++++++++++++++++++++++++++ src/plugins/chat/chat.c | 100 +++++++++++++++++++++++++--- 5 files changed, 331 insertions(+), 24 deletions(-) create mode 100644 pixmaps/self.png create mode 100644 pixmaps/self.svg diff --git a/TODO b/TODO index e4ab33f5..fd0c55dc 100644 --- a/TODO +++ b/TODO @@ -3,14 +3,6 @@ This is just the current plan, plans change. Annotations: RC == Release Critical -0.8.0 (new core features): -- chat improvements: - * allow leaving chat rooms - * allow sending / joining by pressing ENTER - * indicate who we are in the member list - * add various options for sending messages - * indicate how a message was received (private, signed, etc.) - 0.8.1 (expand basics): - improved search: * implement search bookmarking (e.g. user could add/edit/delete @@ -20,6 +12,8 @@ Annotations: pattern that must be matched for the lines to be displayed (to further prune search results, for example) - improved chat: + * add various options for sending messages + * indicate how a message was received (private, signed, etc.) * allow specifying metadata with nickname * show chatroom member metadata (right-click pop-up) - unindexing: diff --git a/gnunet-gtk.glade b/gnunet-gtk.glade index d004360c..4802bbee 100644 --- a/gnunet-gtk.glade +++ b/gnunet-gtk.glade @@ -3144,7 +3144,7 @@ Press ENTER to add the data. - + True True Close search tab (also aborts search) @@ -3311,6 +3311,8 @@ Press ENTER to add the data. True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + 5 @@ -3324,8 +3326,8 @@ Press ENTER to add the data. True Broadcast the message to all participants in the current chat room 0 - - + + True @@ -3348,8 +3350,7 @@ Press ENTER to add the data. True - Sen_d - True + Send False @@ -3379,6 +3380,16 @@ Press ENTER to add the data. + + + True + + + False + 2 + 1 + + True @@ -3389,16 +3400,18 @@ Press ENTER to add the data. GTK_SHADOW_IN + 200 True True True + True False False - 1 + 2 @@ -4363,7 +4376,7 @@ Alex Jones <alexrjones@ntlworld.com> gtk-cancel True -6 - + @@ -4855,7 +4868,7 @@ Alex Jones <alexrjones@ntlworld.com> - + True Stop the search and close the tab GTK_RELIEF_NONE @@ -4928,4 +4941,48 @@ Alex Jones <alexrjones@ntlworld.com> + + True + Chat Tab Label with Close Button + + + True + + + True + 5 + FIXME + True + chatCloseButton + True + + + False + False + + + + + True + Leave the chat room and close the tab + GTK_RELIEF_NONE + 0 + + + + True + gtk-cancel + 1 + + + + + False + False + 1 + + + + + diff --git a/pixmaps/self.png b/pixmaps/self.png new file mode 100644 index 00000000..bed8ea26 Binary files /dev/null and b/pixmaps/self.png differ diff --git a/pixmaps/self.svg b/pixmaps/self.svg new file mode 100644 index 00000000..4a97911f --- /dev/null +++ b/pixmaps/self.svg @@ -0,0 +1,172 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/plugins/chat/chat.c b/src/plugins/chat/chat.c index e4cbfa2f..99305457 100644 --- a/src/plugins/chat/chat.c +++ b/src/plugins/chat/chat.c @@ -54,7 +54,9 @@ struct GNUNET_CHAT_gui_chat_client GtkListStore *nick_model; GtkWidget *chatFrame; GtkWidget *chat_entry; + GtkWidget *tab_label; GladeXML *chatXML; + GladeXML *labelXML; struct GNUNET_CHAT_Room *room; GNUNET_HashCode mypid; }; @@ -160,6 +162,55 @@ remove_nick_save_call (void *arg) return NULL; } + +/** + * This method is called when the user clicks on + * the "CANCEL (X)" button in the TAB of the + * chat notebook. + */ +void +on_closeChatButton_clicked_chat (GtkWidget * chatPage, + GtkWidget * closeButton) +{ + struct GNUNET_CHAT_gui_chat_client *pos; + struct GNUNET_CHAT_gui_chat_client *prev; + GtkNotebook *chatnotebook; + int index; + int i; + + prev = NULL; + pos = list; + while (pos != NULL) + { + if (pos->tab_label == chatPage) + break; + prev = pos; + pos = pos->next; + } + if (prev == NULL) + list = pos->next; + else + prev->next = pos; + GNUNET_GE_ASSERT (NULL, pos != NULL); + GNUNET_GTK_run_with_save_calls + ((GNUNET_ThreadMainFunction)&GNUNET_CHAT_leave_room, pos->room); + + chatnotebook = + GTK_NOTEBOOK(glade_xml_get_widget (GNUNET_GTK_get_main_glade_XML (), "chatnotebook")); + /* remove page from notebook */ + index = -1; + for (i = gtk_notebook_get_n_pages (chatnotebook) - 1; i >= 0; i--) + if (pos->chatFrame == gtk_notebook_get_nth_page (chatnotebook, i)) + index = i; + GNUNET_GE_BREAK (NULL, index != -1); + gtk_notebook_remove_page (chatnotebook, index); + UNREF (pos->chatXML); + UNREF (pos->labelXML); + GNUNET_free(pos); +} + + + /** * A message was sent in the chat to us. * @@ -206,12 +257,29 @@ member_list_callback (void *cls, struct GNUNET_CHAT_gui_chat_client *client = cls; struct GNUNET_CHAT_safe_nick_write_struct writearg; char *nick; + char *path; + char *filename; GNUNET_hash (pkey, sizeof (GNUNET_RSA_PublicKey), &writearg.pid); nick = GNUNET_pseudonym_id_to_name (chat_ectx, chat_cfg, &writearg.pid); writearg.model = client->nick_model; - /* FIXME: set icon if pid == ours */ writearg.icon = NULL; + if (0 == memcmp(&writearg.pid, + &client->mypid, + sizeof(GNUNET_HashCode))) + { + path = GNUNET_get_installation_path (GNUNET_IPK_DATADIR); + filename = + GNUNET_malloc (strlen (path) + + strlen ("/../gnunet-gtk/self.png") + 2); + strcpy (filename, path); + GNUNET_free (path); + strcat (filename, "/../gnunet-gtk/self.png"); + writearg.icon + = gdk_pixbuf_new_from_file(filename, + NULL); + GNUNET_free(filename); + } writearg.meta = member_info; writearg.nick = nick; if (member_info != NULL) @@ -219,6 +287,8 @@ member_list_callback (void *cls, else GNUNET_GTK_save_call (&remove_nick_save_call, &writearg); GNUNET_free (nick); + if (writearg.icon != NULL) + g_object_unref(writearg.icon); return GNUNET_OK; } @@ -231,22 +301,26 @@ on_chat_frame_send_button_click_event_chat (GtkWidget * widget, gpointer data) GNUNET_mutex_lock (lock); pos = list; - while ((pos != NULL) && (pos->send_button != widget)) + while ((pos != NULL) && (pos->send_button != widget) && + (pos->chat_entry != widget) ) pos = pos->next; GNUNET_GE_ASSERT (NULL, pos != NULL); message = (const char *) gtk_entry_get_text (GTK_ENTRY (pos->chat_entry)); - GNUNET_CHAT_send_message (pos->room, - message, GNUNET_CHAT_MSG_OPTION_NONE, NULL, &seq); - gtk_entry_set_text (GTK_ENTRY (pos->chat_entry), ""); + if (strlen(message) > 0) + { + GNUNET_CHAT_send_message (pos->room, + message, GNUNET_CHAT_MSG_OPTION_NONE, NULL, &seq); + gtk_entry_set_text (GTK_ENTRY (pos->chat_entry), ""); + } GNUNET_mutex_unlock (lock); } static void create_chat_room_tab (const char *room_name, const char *nick) { - GtkWidget *chatLabel; GtkWidget *chatnotebook; + GtkLabel *label; GtkTreeView *treeview; struct GNUNET_CHAT_gui_chat_client *client; struct GNUNET_MetaData *meta; @@ -264,9 +338,19 @@ create_chat_room_tab (const char *room_name, const char *nick) GNUNET_GTK_connect_glade_with_plugins (client->chatXML); client->chatFrame = GNUNET_GTK_extract_main_widget_from_window (client->chatXML, "chatFrame"); - chatLabel = gtk_label_new (room_name); + client->labelXML = + glade_xml_new (GNUNET_GTK_get_glade_filename (), + "chatTabLabelWindow", PACKAGE_NAME); + GNUNET_GTK_connect_glade_with_plugins (client->labelXML); + client->tab_label + = GNUNET_GTK_extract_main_widget_from_window (client->labelXML, + "chatTabLabelWindow"); + label = GTK_LABEL (glade_xml_get_widget (client->labelXML, + "chatTabLabel")); + gtk_label_set (label, room_name); gtk_notebook_append_page (GTK_NOTEBOOK (chatnotebook), - client->chatFrame, chatLabel); + client->chatFrame, + client->tab_label); gtk_widget_show (chatnotebook); client->nick_model = gtk_list_store_new (CHAT_NUM, G_TYPE_STRING, /* nickname */ -- cgit v1.2.3