]> git.0d.be Git - empathy.git/blobdiff - src/empathy-chatrooms-window.c
Use double quotes for all internal headers
[empathy.git] / src / empathy-chatrooms-window.c
index aae8aac3234588659fcc7ae562daad1eddd6c8ca..83f6b99d7756bbb3113b12315a4cffb93dd8838b 100644 (file)
  *          Mikael Hallendal <micke@imendio.com>
  */
 
-#include <config.h>
+#include "config.h"
 
-#include <string.h>
-#include <stdio.h>
-
-#include <gtk/gtk.h>
-#include <glib.h>
 #include <glib/gi18n.h>
 
-#include <libempathy/empathy-chatroom-manager.h>
-#include <libempathy/empathy-utils.h>
+#include "libempathy/empathy-chatroom-manager.h"
+#include "libempathy/empathy-utils.h"
 
-#include <libempathy-gtk/empathy-account-chooser.h>
-#include <libempathy-gtk/empathy-ui-utils.h>
+#include "libempathy-gtk/empathy-account-chooser.h"
+#include "libempathy-gtk/empathy-ui-utils.h"
 
 #include "empathy-chatrooms-window.h"
-#include "empathy-new-chatroom-dialog.h"
 
 typedef struct {
        EmpathyChatroomManager *manager;
@@ -50,7 +44,6 @@ typedef struct {
        GtkWidget             *account_chooser;
        GtkWidget             *treeview;
        GtkWidget             *button_remove;
-       GtkWidget             *button_edit;
        GtkWidget             *button_close;
 } EmpathyChatroomsWindow;
 
@@ -66,16 +59,8 @@ static void             chatrooms_window_model_add                       (Empath
 static void             chatrooms_window_model_cell_auto_connect_toggled (GtkCellRendererToggle  *cell,
                                                                          gchar                  *path_string,
                                                                          EmpathyChatroomsWindow  *window);
-static EmpathyChatroom * chatrooms_window_model_get_selected              (EmpathyChatroomsWindow *window);
-static void             chatrooms_window_model_action_selected           (EmpathyChatroomsWindow *window);
-static void             chatrooms_window_row_activated_cb                (GtkTreeView           *tree_view,
-                                                                         GtkTreePath           *path,
-                                                                         GtkTreeViewColumn     *column,
-                                                                         EmpathyChatroomsWindow *window);
 static void             chatrooms_window_button_remove_clicked_cb        (GtkWidget             *widget,
                                                                          EmpathyChatroomsWindow *window);
-static void             chatrooms_window_button_edit_clicked_cb          (GtkWidget             *widget,
-                                                                         EmpathyChatroomsWindow *window);
 static void             chatrooms_window_button_close_clicked_cb         (GtkWidget             *widget,
                                                                          EmpathyChatroomsWindow *window);
 static void             chatrooms_window_chatroom_added_cb               (EmpathyChatroomManager *manager,
@@ -106,6 +91,8 @@ empathy_chatrooms_window_show (GtkWindow *parent)
        static EmpathyChatroomsWindow *window = NULL;
        GtkBuilder                    *gui;
        gchar                         *filename;
+       GtkWidget                     *sw, *toolbar;
+       GtkStyleContext               *context;
 
        if (window) {
                gtk_window_present (GTK_WINDOW (window->window));
@@ -119,17 +106,23 @@ empathy_chatrooms_window_show (GtkWindow *parent)
                                       "chatrooms_window", &window->window,
                                       "hbox_account", &window->hbox_account,
                                       "label_account", &window->label_account,
+                                      "sw_room_list", &sw,
                                       "treeview", &window->treeview,
-                                      "button_edit", &window->button_edit,
+                                      "toolbar_remove", &toolbar,
                                       "button_remove", &window->button_remove,
                                       "button_close", &window->button_close,
                                       NULL);
        g_free (filename);
 
+       /* join the remove toolbar to the treeview */
+       context = gtk_widget_get_style_context (sw);
+       gtk_style_context_set_junction_sides (context, GTK_JUNCTION_BOTTOM);
+       context = gtk_widget_get_style_context (toolbar);
+       gtk_style_context_set_junction_sides (context, GTK_JUNCTION_TOP);
+
        empathy_builder_connect (gui, window,
                              "chatrooms_window", "destroy", chatrooms_window_destroy_cb,
                              "button_remove", "clicked", chatrooms_window_button_remove_clicked_cb,
-                             "button_edit", "clicked", chatrooms_window_button_edit_clicked_cb,
                              "button_close", "clicked", chatrooms_window_button_close_clicked_cb,
                              NULL);
 
@@ -150,7 +143,7 @@ empathy_chatrooms_window_show (GtkWindow *parent)
        /* Account chooser for chat rooms */
        window->account_chooser = empathy_account_chooser_new ();
        empathy_account_chooser_set_filter (EMPATHY_ACCOUNT_CHOOSER (window->account_chooser),
-                                           empathy_account_chooser_filter_is_connected,
+                                           empathy_account_chooser_filter_supports_chatrooms,
                                            NULL);
        g_object_set (window->account_chooser,
                      "has-all-option", TRUE,
@@ -206,10 +199,6 @@ chatrooms_window_model_setup (EmpathyChatroomsWindow *window)
        /* View */
        view = GTK_TREE_VIEW (window->treeview);
 
-       g_signal_connect (view, "row-activated",
-                         G_CALLBACK (chatrooms_window_row_activated_cb),
-                         window);
-
        /* Store */
        store = gtk_list_store_new (COL_COUNT,
                                    G_TYPE_STRING,         /* Image */
@@ -353,8 +342,7 @@ chatrooms_window_model_add (EmpathyChatroomsWindow *window,
        model = gtk_tree_view_get_model (view);
        store = GTK_LIST_STORE (model);
 
-       gtk_list_store_append (store, &iter);
-       gtk_list_store_set (store, &iter,
+       gtk_list_store_insert_with_values (store, &iter, -1,
                            COL_NAME, empathy_chatroom_get_name (chatroom),
                            COL_ROOM, empathy_chatroom_get_room (chatroom),
                            COL_AUTO_CONNECT, empathy_chatroom_get_auto_connect (chatroom),
@@ -400,46 +388,6 @@ chatrooms_window_model_cell_auto_connect_toggled (GtkCellRendererToggle  *cell,
        g_object_unref (chatroom);
 }
 
-static EmpathyChatroom *
-chatrooms_window_model_get_selected (EmpathyChatroomsWindow *window)
-{
-       GtkTreeView      *view;
-       GtkTreeModel     *model;
-       GtkTreeSelection *selection;
-       GtkTreeIter       iter;
-       EmpathyChatroom   *chatroom = NULL;
-
-       view = GTK_TREE_VIEW (window->treeview);
-       selection = gtk_tree_view_get_selection (view);
-
-       if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
-               gtk_tree_model_get (model, &iter, COL_POINTER, &chatroom, -1);
-       }
-
-       return chatroom;
-}
-
-static void
-chatrooms_window_model_action_selected (EmpathyChatroomsWindow *window)
-{
-       EmpathyChatroom *chatroom;
-
-       /* FIXME: This is still not implemented since Gossip fork */
-       chatroom = chatrooms_window_model_get_selected (window);
-       g_object_unref (chatroom);
-}
-
-static void
-chatrooms_window_row_activated_cb (GtkTreeView           *tree_view,
-                                  GtkTreePath           *path,
-                                  GtkTreeViewColumn     *column,
-                                  EmpathyChatroomsWindow *window)
-{
-       if (gtk_widget_is_sensitive (window->button_edit)) {
-               chatrooms_window_model_action_selected (window);
-       }
-}
-
 static void
 chatrooms_window_button_remove_clicked_cb (GtkWidget             *widget,
                                           EmpathyChatroomsWindow *window)
@@ -467,17 +415,6 @@ chatrooms_window_button_remove_clicked_cb (GtkWidget             *widget,
        g_object_unref (chatroom);
 }
 
-static void
-chatrooms_window_button_edit_clicked_cb (GtkWidget             *widget,
-                                        EmpathyChatroomsWindow *window)
-{
-       EmpathyChatroom *chatroom;
-
-       /* FIXME: This is still not implemented since Gossip fork */
-       chatroom = chatrooms_window_model_get_selected (window);
-       g_object_unref (chatroom);
-}
-
 static void
 chatrooms_window_button_close_clicked_cb (GtkWidget             *widget,
                                          EmpathyChatroomsWindow *window)