]> git.0d.be Git - empathy.git/blobdiff - src/empathy-import-widget.c
Reorder header inclusions accordingly to the Telepathy coding style
[empathy.git] / src / empathy-import-widget.c
index 40956f9eee91616c8e189ace588a2362e1469a69..a572ad0c6c872c2baeae90990233cdfcbaa2a891 100644 (file)
 
 /* empathy-import-widget.c */
 
-#include <config.h>
-
-#include "empathy-import-dialog.h"
+#include "config.h"
 #include "empathy-import-widget.h"
-#include "empathy-import-pidgin.h"
-
-#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
-#include <libempathy/empathy-debug.h>
-#include <libempathy/empathy-connection-managers.h>
-#include <libempathy/empathy-utils.h>
 
-#include <libempathy-gtk/empathy-ui-utils.h>
+#include <glib/gi18n-lib.h>
 
-#include <telepathy-glib/account-manager.h>
-#include <telepathy-glib/util.h>
+#include "empathy-import-dialog.h"
+#include "empathy-ui-utils.h"
+#include "empathy-utils.h"
 
-#include <glib/gi18n-lib.h>
+#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
+#include "empathy-debug.h"
 
 G_DEFINE_TYPE (EmpathyImportWidget, empathy_import_widget, G_TYPE_OBJECT)
 
@@ -62,6 +56,7 @@ enum {
 typedef struct {
   GtkWidget *vbox;
   GtkWidget *treeview;
+  GtkWidget *scrolledwindow;
 
   GList *accounts;
   EmpathyImportApplication app_id;
@@ -91,14 +86,16 @@ import_widget_account_id_in_list (GList *accounts,
   return FALSE;
 }
 
+#define MAX_TREEVIEW_HEIGHT 300
+
 static void
 import_widget_add_accounts_to_model (EmpathyImportWidget *self)
 {
   TpAccountManager *manager;
   GtkTreeModel *model;
-  GtkTreeIter iter;
   GList *l;
   EmpathyImportWidgetPriv *priv = GET_PRIV (self);
+  gint min, natural;
 
   manager = tp_account_manager_dup ();
 
@@ -120,18 +117,16 @@ import_widget_add_accounts_to_model (EmpathyImportWidget *self)
 
       value = g_hash_table_lookup (data->settings, "account");
 
-      accounts = tp_account_manager_get_valid_accounts (manager);
+      accounts = tp_account_manager_dup_valid_accounts (manager);
 
       /* Only set the "Import" cell to be active if there isn't already an
        * account set up with the same account id. */
       import = !import_widget_account_id_in_list (accounts,
           g_value_get_string (value));
 
-      g_list_free (accounts);
-
-      gtk_list_store_append (GTK_LIST_STORE (model), &iter);
+      g_list_free_full (accounts, g_object_unref);
 
-      gtk_list_store_set (GTK_LIST_STORE (model), &iter,
+      gtk_list_store_insert_with_values (GTK_LIST_STORE (model), NULL, -1,
           COL_IMPORT, import,
           COL_PROTOCOL, data->protocol,
           COL_NAME, g_value_get_string (value),
@@ -141,6 +136,11 @@ import_widget_add_accounts_to_model (EmpathyImportWidget *self)
 
     }
 
+  /* Display as much rows as possible */
+  gtk_widget_get_preferred_height (priv->treeview, &min, &natural);
+  gtk_widget_set_size_request (priv->scrolledwindow, -1,
+      MIN (natural, MAX_TREEVIEW_HEIGHT));
+
   g_object_unref (manager);
 }
 
@@ -434,6 +434,7 @@ do_constructed (GObject *obj)
   gui = empathy_builder_get_file (filename,
       "widget_vbox", &priv->vbox,
       "treeview", &priv->treeview,
+      "scrolledwindow", &priv->scrolledwindow,
       NULL);
 
   g_free (filename);