#include "empathy-theme-manager.h"
#include "empathy-ui-utils.h"
#include "empathy-webkit-utils.h"
+#include "empathy-geometry.h"
#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
#include <libempathy/empathy-debug.h>
g_slice_free (Ctx, ctx);
}
-static void
-account_chooser_ready_cb (EmpathyAccountChooser *chooser,
- EmpathyLogWindow *self)
-{
- /* We'll display the account once the model has been populate with the chats
- * of this account. */
- empathy_account_chooser_set_account (EMPATHY_ACCOUNT_CHOOSER (
- self->priv->account_chooser), self->priv->selected_account);
-}
-
static void
select_account_once_ready (EmpathyLogWindow *self,
TpAccount *account,
self->priv->selected_is_chatroom = is_chatroom;
- if (empathy_account_chooser_is_ready (account_chooser))
- account_chooser_ready_cb (account_chooser, self);
- else
- /* Chat will be selected once the account chooser is ready */
- g_signal_connect (account_chooser, "ready",
- G_CALLBACK (account_chooser_ready_cb), self);
+ empathy_account_chooser_set_account (account_chooser,
+ self->priv->selected_account);
}
static void
GFile *gfile;
GtkWidget *vbox, *accounts, *search, *label, *closeitem;
GtkWidget *scrolledwindow_events;
+ gchar *uri;
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
EMPATHY_TYPE_LOG_WINDOW, EmpathyLogWindowPriv);
G_CALLBACK (gtk_widget_destroy), self);
/* Account chooser for chats */
- vbox = gtk_vbox_new (FALSE, 3);
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 3);
self->priv->account_chooser = empathy_account_chooser_new ();
account_chooser = EMPATHY_ACCOUNT_CHOOSER (self->priv->account_chooser);
gtk_container_add (GTK_CONTAINER (accounts), vbox);
/* Search entry */
- vbox = gtk_vbox_new (FALSE, 3);
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 3);
self->priv->search_entry = gtk_entry_new ();
- gtk_entry_set_icon_from_stock (GTK_ENTRY (self->priv->search_entry),
- GTK_ENTRY_ICON_PRIMARY, GTK_STOCK_FIND);
- gtk_entry_set_icon_from_stock (GTK_ENTRY (self->priv->search_entry),
- GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_CLEAR);
+ gtk_entry_set_icon_from_icon_name (GTK_ENTRY (self->priv->search_entry),
+ GTK_ENTRY_ICON_SECONDARY, "edit-find-symbolic");
+ gtk_entry_set_icon_sensitive (GTK_ENTRY (self->priv->search_entry),
+ GTK_ENTRY_ICON_SECONDARY, FALSE);
label = gtk_label_new (_("Search"));
gfile = g_file_new_for_path (filename);
g_free (filename);
- webkit_web_view_load_uri (WEBKIT_WEB_VIEW (self->priv->webview),
- g_file_get_uri (gfile));
+ uri = g_file_get_uri (gfile);
+ webkit_web_view_load_uri (WEBKIT_WEB_VIEW (self->priv->webview), uri);
g_object_unref (gfile);
+ g_free (uri);
/* handle all navigation externally */
g_signal_connect (self->priv->webview, "navigation-policy-decision-requested",
log_window_update_buttons_sensitivity (self);
gtk_widget_show (GTK_WIDGET (self));
+
+ empathy_geometry_bind (GTK_WINDOW (self), "log-window");
}
GtkWidget *
if (tpl_call_event_get_end_reason (call) != TPL_CALL_END_REASON_NO_ANSWER)
{
gchar *body;
+ gchar *tmp;
span = tpl_call_event_get_duration (TPL_CALL_EVENT (event));
+
if (span < 60)
- duration = g_strdup_printf (_("%" G_GINT64_FORMAT " seconds"), span);
+ {
+ tmp = g_strdup_printf ("%" G_GINT64_FORMAT, span);
+ duration = g_strdup_printf (
+ ngettext ("%s second", "%s seconds", span), tmp);
+ g_free (tmp);
+ }
else
- duration = g_strdup_printf (_("%" G_GINT64_FORMAT " minutes"),
- span / 60);
+ {
+ tmp = g_strdup_printf ("%" G_GINT64_FORMAT, span / 60);
+ duration = g_strdup_printf (
+ ngettext ("%s minute", "%s minutes", span / 60), tmp);
+ g_free (tmp);
+ }
finished_date = g_date_time_add (started_date, -span);
finished = g_date_time_format (finished_date, "%X");
if (!g_date_compare (date, d))
{
has_element = TRUE;
+ g_date_free (d);
return TRUE;
}
+ g_date_free (d);
return FALSE;
}
text = g_date_time_format (dt, "%A");
else
text = g_date_time_format (dt,
- C_("A date such as '23 May 2010', "
- "%e is the day, %B the month and %Y the year",
- "%e %B %Y"));
+ /* Translators: A date such as '23 May 2010' (strftime format) */
+ _("%e %B %Y"));
g_date_time_unref (dt);
}
if (gtk_tree_model_get_iter_first (model, &iter))
{
+ GDate *date;
+
+ date = g_date_new_dmy (1, 1, -1),
+
gtk_list_store_prepend (store, &iter);
gtk_list_store_set (store, &iter,
- COL_WHEN_DATE, g_date_new_dmy (1, 1, -1),
+ COL_WHEN_DATE, date,
COL_WHEN_TEXT, "separator",
-1);
+ g_date_free (date);
+
+ date = g_date_new_dmy (2, 1, -1),
gtk_list_store_prepend (store, &iter);
gtk_list_store_set (store, &iter,
- COL_WHEN_DATE, g_date_new_dmy (2, 1, -1),
+ COL_WHEN_DATE, date,
COL_WHEN_TEXT, _("Anytime"),
-1);
+ g_date_free (date);
+
if (gtk_tree_model_iter_nth_child (model, &iter, NULL, 2))
gtk_tree_selection_select_iter (selection, &iter);
}
log_window_search_entry_changed_cb (GtkWidget *entry,
EmpathyLogWindow *self)
{
+ const gchar *str;
+
+ str = gtk_entry_get_text (GTK_ENTRY (self->priv->search_entry));
+
+ if (!tp_str_empty (str))
+ {
+ gtk_entry_set_icon_from_icon_name (GTK_ENTRY (self->priv->search_entry),
+ GTK_ENTRY_ICON_SECONDARY, "edit-clear-symbolic");
+ gtk_entry_set_icon_sensitive (GTK_ENTRY (self->priv->search_entry),
+ GTK_ENTRY_ICON_SECONDARY, TRUE);
+ }
+ else
+ {
+ gtk_entry_set_icon_from_icon_name (GTK_ENTRY (self->priv->search_entry),
+ GTK_ENTRY_ICON_SECONDARY, "edit-find-symbolic");
+ gtk_entry_set_icon_sensitive (GTK_ENTRY (self->priv->search_entry),
+ GTK_ENTRY_ICON_SECONDARY, FALSE);
+ }
+
if (self->priv->source != 0)
g_source_remove (self->priv->source);
self->priv->source = g_timeout_add (500, (GSourceFunc) start_find_search,
"", -1);
}
+static void
+do_update_buttons_sensitivity (EmpathyLogWindow *self)
+{
+ EmpathyCapabilities capabilities;
+ gboolean profile, chat, call, video;
+
+ tp_clear_object (&self->priv->button_video_binding);
+
+ if (self->priv->selected_contact != NULL)
+ {
+ capabilities = empathy_contact_get_capabilities (
+ self->priv->selected_contact);
+
+ profile = chat = TRUE;
+ call = capabilities & EMPATHY_CAPABILITIES_AUDIO;
+ video = capabilities & EMPATHY_CAPABILITIES_VIDEO;
+ }
+ else
+ {
+ profile = chat = call = video = FALSE;
+ }
+
+ gtk_widget_set_sensitive (self->priv->button_profile, profile);
+ gtk_widget_set_sensitive (self->priv->button_chat, chat);
+ gtk_widget_set_sensitive (self->priv->button_call, call);
+
+ if (video)
+ {
+ self->priv->button_video_binding = g_object_bind_property (
+ self->priv->camera_monitor, "available",
+ self->priv->button_video, "sensitive",
+ G_BINDING_SYNC_CREATE);
+ }
+ else
+ {
+ /* Don't override the binding */
+ gtk_widget_set_sensitive (self->priv->button_video, video);
+ }
+}
+
+static void
+contact_capabilities_changed_cb (EmpathyContact *contact,
+ GParamSpec *spec,
+ EmpathyLogWindow *self)
+{
+ do_update_buttons_sensitivity (self);
+}
+
static void
log_window_update_buttons_sensitivity (EmpathyLogWindow *self)
{
GtkTreeView *view;
GtkTreeModel *model;
GtkTreeSelection *selection;
- EmpathyCapabilities capabilities;
TpAccount *account;
TplEntity *target;
GtkTreeIter iter;
GList *paths;
GtkTreePath *path;
- gboolean profile, chat, call, video;
- profile = chat = call = video = FALSE;
+ if (self->priv->selected_contact != NULL)
+ {
+ g_signal_handlers_disconnect_by_func (self->priv->selected_contact,
+ contact_capabilities_changed_cb, self);
- tp_clear_object (&self->priv->button_video_binding);
- tp_clear_object (&self->priv->selected_contact);
+ tp_clear_object (&self->priv->selected_contact);
+ }
view = GTK_TREE_VIEW (self->priv->treeview_who);
model = gtk_tree_view_get_model (view);
selection = gtk_tree_view_get_selection (view);
- profile = chat = call = video = FALSE;
-
if (!gtk_tree_model_get_iter_first (model, &iter))
goto events;
g_object_unref (account);
g_object_unref (target);
- capabilities = empathy_contact_get_capabilities (self->priv->selected_contact);
-
- profile = chat = TRUE;
- call = capabilities & EMPATHY_CAPABILITIES_AUDIO;
- video = capabilities & EMPATHY_CAPABILITIES_VIDEO;
-
goto out;
events:
if (self->priv->events_contact != NULL)
self->priv->selected_contact = g_object_ref (self->priv->events_contact);
- else
- goto out;
-
- capabilities = empathy_contact_get_capabilities (self->priv->selected_contact);
-
- profile = chat = TRUE;
- call = capabilities & EMPATHY_CAPABILITIES_AUDIO;
- video = capabilities & EMPATHY_CAPABILITIES_VIDEO;
-
- if (video)
- self->priv->button_video_binding = g_object_bind_property (
- self->priv->camera_monitor, "available",
- self->priv->button_video, "sensitive",
- G_BINDING_SYNC_CREATE);
out:
- gtk_widget_set_sensitive (self->priv->button_profile, profile);
- gtk_widget_set_sensitive (self->priv->button_chat, chat);
- gtk_widget_set_sensitive (self->priv->button_call, call);
+ if (self->priv->selected_contact != NULL)
+ {
+ tp_g_signal_connect_object (self->priv->selected_contact,
+ "notify::capabilities", G_CALLBACK (contact_capabilities_changed_cb),
+ self, 0);
+ }
- /* Don't override the binding */
- if (!video)
- gtk_widget_set_sensitive (self->priv->button_video, video);
+ do_update_buttons_sensitivity (self);
}
static void
gpointer user_data)
{
GDate *date1, *date2;
+ gint result;
gtk_tree_model_get (model, a,
COL_WHEN_DATE, &date1,
COL_WHEN_DATE, &date2,
-1);
- return g_date_compare (date1, date2);
+ result = g_date_compare (date1, date2);
+
+ g_date_free (date1);
+ g_date_free (date2);
+ return result;
}
static gboolean
event_mask, subtype, self->priv->count);
_tpl_action_chain_append (self->priv->chain, get_events_for_date, ctx);
}
+
+ g_date_free (d);
}
}
}
if (g_strcmp0 (separator, "separator") != 0)
{
+ GDate *date;
+
+ date = g_date_new_dmy (1, 1, -1);
+
gtk_list_store_prepend (store, &iter);
gtk_list_store_set (store, &iter,
- COL_WHEN_DATE, g_date_new_dmy (1, 1, -1),
+ COL_WHEN_DATE, date,
COL_WHEN_TEXT, "separator",
-1);
+ g_date_free (date);
+
+ date = g_date_new_dmy (2, 1, -1);
+
gtk_list_store_prepend (store, &iter);
gtk_list_store_set (store, &iter,
- COL_WHEN_DATE, g_date_new_dmy (2, 1, -1),
+ COL_WHEN_DATE, date,
COL_WHEN_TEXT, _("Anytime"),
-1);
+
+ g_date_free (date);
}
+
+ g_free (separator);
}
g_list_free_full (dates, g_free);
gtk_tree_store_clear (self->priv->store_events);
log_window_who_populate (self);
- /* Re-filter the account chooser so the accounts without logs get greyed out */
- empathy_account_chooser_set_filter (
- EMPATHY_ACCOUNT_CHOOSER (self->priv->account_chooser),
- empathy_account_chooser_filter_has_logs, NULL);
-}
-
-static void
-log_window_clear_logs_chooser_select_account (EmpathyAccountChooser *chooser,
- EmpathyLogWindow *self)
-{
- EmpathyAccountChooser *account_chooser;
-
- account_chooser = EMPATHY_ACCOUNT_CHOOSER (self->priv->account_chooser);
-
- empathy_account_chooser_set_account (chooser,
- empathy_account_chooser_get_account (account_chooser));
+ /* Re-filter the account chooser so the accounts without logs get
+ * greyed out */
+ empathy_account_chooser_refilter (
+ EMPATHY_ACCOUNT_CHOOSER (self->priv->account_chooser));
}
static void
account_chooser = (EmpathyAccountChooser *) empathy_account_chooser_new ();
empathy_account_chooser_set_has_all_option (account_chooser, TRUE);
- empathy_account_chooser_set_filter (account_chooser,
- empathy_account_chooser_filter_has_logs, NULL);
+
+ empathy_account_chooser_refilter (account_chooser);
/* Select the same account as in the history window */
- if (empathy_account_chooser_is_ready (account_chooser))
- log_window_clear_logs_chooser_select_account (account_chooser, self);
- else
- g_signal_connect (account_chooser, "ready",
- G_CALLBACK (log_window_clear_logs_chooser_select_account), self);
+ empathy_account_chooser_set_account (account_chooser,
+ empathy_account_chooser_get_account (
+ EMPATHY_ACCOUNT_CHOOSER (self->priv->account_chooser)));
dialog = gtk_message_dialog_new_with_markup (GTK_WINDOW (self),
GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING,
content_area = gtk_message_dialog_get_message_area (
GTK_MESSAGE_DIALOG (dialog));
- hbox = gtk_hbox_new (FALSE, 6);
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
label = gtk_label_new (_("Delete from:"));
gtk_box_pack_start (GTK_BOX (hbox), label,
FALSE, FALSE, 0);