Ejemplo n.º 1
0
static void
log_window_find_populate (EmpathyLogWindow *window,
			  const gchar     *search_criteria)
{
	GtkTreeView        *view;
	GtkTreeModel       *model;
	GtkTreeSelection   *selection;
	GtkListStore       *store;

	view = GTK_TREE_VIEW (window->treeview_find);
	model = gtk_tree_view_get_model (view);
	selection = gtk_tree_view_get_selection (view);
	store = GTK_LIST_STORE (model);

	empathy_chat_view_clear (window->chatview_find);

	gtk_list_store_clear (store);

	if (EMP_STR_EMPTY (search_criteria)) {
		/* Just clear the search. */
		return;
	}

	tpl_log_manager_search_async (window->log_manager, search_criteria,
			log_manager_searched_new_cb, (gpointer) store);
}
Ejemplo n.º 2
0
static void
log_window_get_messages_for_date (EmpathyLogWindow *window,
				  GDate *date)
{
  TpAccount *account;
  gchar *chat_id;
  gboolean is_chatroom;

  if (!log_window_chats_get_selected (window, &account,
        &chat_id, &is_chatroom)) {
      return;
  }

  /* Clear all current messages shown in the textview */
  empathy_chat_view_clear (window->chatview_chats);

  /* Turn off scrolling temporarily */
  empathy_chat_view_scroll (window->chatview_find, FALSE);

  /* Get messages */
  tpl_log_manager_get_messages_for_date_async (window->log_manager,
      account, chat_id,
      is_chatroom,
      date,
      log_window_got_messages_for_date_cb,
      (gpointer) window);
}
Ejemplo n.º 3
0
static void
log_window_chats_accounts_changed_cb (GtkWidget       *combobox,
				      EmpathyLogWindow *window)
{
	/* Clear all current messages shown in the textview */
	empathy_chat_view_clear (window->chatview_chats);

	log_window_chats_populate (window);
}
Ejemplo n.º 4
0
static void
log_window_chats_get_messages (EmpathyLogWindow *window,
			       const gchar     *date_to_show)
{
	EmpathyAccount     *account;
	gchar         *chat_id;
	gboolean       is_chatroom;
	EmpathyMessage *message;
	GList         *messages;
	GList         *dates = NULL;
	GList         *l;
	const gchar   *date;
	guint          year_selected;
	guint          year;
	guint          month;
	guint          month_selected;
	guint          day;

	if (!log_window_chats_get_selected (window, &account,
					    &chat_id, &is_chatroom)) {
		return;
	}

	g_signal_handlers_block_by_func (window->calendar_chats,
					 log_window_calendar_chats_day_selected_cb,
					 window);

	/* Either use the supplied date or get the last */
	date = date_to_show;
	if (!date) {
		gboolean day_selected = FALSE;

		/* Get a list of dates and show them on the calendar */
		dates = empathy_log_manager_get_dates (window->log_manager,
						       account, chat_id,
						       is_chatroom);

		for (l = dates; l; l = l->next) {
			const gchar *str;

			str = l->data;
			if (!str) {
				continue;
			}

			sscanf (str, "%4d%2d%2d", &year, &month, &day);
			gtk_calendar_get_date (GTK_CALENDAR (window->calendar_chats),
					       &year_selected,
					       &month_selected,
					       NULL);

			month_selected++;

			if (!l->next) {
				date = str;
			}

			if (year != year_selected || month != month_selected) {
				continue;
			}


			DEBUG ("Marking date:'%s'", str);
			gtk_calendar_mark_day (GTK_CALENDAR (window->calendar_chats), day);

			if (l->next) {
				continue;
			}

			day_selected = TRUE;

			gtk_calendar_select_day (GTK_CALENDAR (window->calendar_chats), day);
		}

		if (!day_selected) {
			/* Unselect the day in the calendar */
			gtk_calendar_select_day (GTK_CALENDAR (window->calendar_chats), 0);
		}
	} else {
		sscanf (date, "%4d%2d%2d", &year, &month, &day);
		gtk_calendar_get_date (GTK_CALENDAR (window->calendar_chats),
				       &year_selected,
				       &month_selected,
				       NULL);

		month_selected++;

		if (year != year_selected && month != month_selected) {
			day = 0;
		}

		gtk_calendar_select_day (GTK_CALENDAR (window->calendar_chats), day);
	}

	g_signal_handlers_unblock_by_func (window->calendar_chats,
					   log_window_calendar_chats_day_selected_cb,
					   window);

	if (!date) {
		goto OUT;
	}

	/* Clear all current messages shown in the textview */
	empathy_chat_view_clear (window->chatview_chats);

	/* Turn off scrolling temporarily */
	empathy_chat_view_scroll (window->chatview_find, FALSE);

	/* Get messages */
	messages = empathy_log_manager_get_messages_for_date (window->log_manager,
							      account, chat_id,
							      is_chatroom,
							      date);

	for (l = messages; l; l = l->next) {
		message = l->data;

		empathy_chat_view_append_message (window->chatview_chats,
						 message);
		g_object_unref (message);
	}
	g_list_free (messages);

	/* Turn back on scrolling */
	empathy_chat_view_scroll (window->chatview_find, TRUE);

	/* Give the search entry main focus */
	gtk_widget_grab_focus (window->entry_chats);

OUT:
	g_list_foreach (dates, (GFunc) g_free, NULL);
	g_list_free (dates);
	g_object_unref (account);
	g_free (chat_id);
}
Ejemplo n.º 5
0
static void
log_window_find_populate (EmpathyLogWindow *window,
			  const gchar     *search_criteria)
{
	GList              *hits, *l;

	GtkTreeView        *view;
	GtkTreeModel       *model;
	GtkTreeSelection   *selection;
	GtkListStore       *store;
	GtkTreeIter         iter;

	view = GTK_TREE_VIEW (window->treeview_find);
	model = gtk_tree_view_get_model (view);
	selection = gtk_tree_view_get_selection (view);
	store = GTK_LIST_STORE (model);

	empathy_chat_view_clear (window->chatview_find);

	gtk_list_store_clear (store);

	if (EMP_STR_EMPTY (search_criteria)) {
		/* Just clear the search. */
		return;
	}

	hits = empathy_log_manager_search_new (window->log_manager, search_criteria);

	for (l = hits; l; l = l->next) {
		EmpathyLogSearchHit *hit;
		const gchar         *account_name;
		const gchar         *account_icon;
		gchar               *date_readable;

		hit = l->data;

		/* Protect against invalid data (corrupt or old log files. */
		if (!hit->account || !hit->chat_id) {
			continue;
		}

		date_readable = empathy_log_manager_get_date_readable (hit->date);
		account_name = empathy_account_get_display_name (hit->account);
		account_icon = empathy_icon_name_from_account (hit->account);

		gtk_list_store_append (store, &iter);
		gtk_list_store_set (store, &iter,
				    COL_FIND_ACCOUNT_ICON, account_icon,
				    COL_FIND_ACCOUNT_NAME, account_name,
				    COL_FIND_ACCOUNT, hit->account,
				    COL_FIND_CHAT_NAME, hit->chat_id, /* FIXME */
				    COL_FIND_CHAT_ID, hit->chat_id,
				    COL_FIND_IS_CHATROOM, hit->is_chatroom,
				    COL_FIND_DATE, hit->date,
				    COL_FIND_DATE_READABLE, date_readable,
				    -1);

		g_free (date_readable);

		/* FIXME: Update COL_FIND_CHAT_NAME */
		if (hit->is_chatroom) {
		} else {
		}
	}

	if (hits) {
		empathy_log_manager_search_free (hits);
	}
}
Ejemplo n.º 6
0
static void
log_window_find_changed_cb (GtkTreeSelection *selection,
			    EmpathyLogWindow  *window)
{
	GtkTreeView   *view;
	GtkTreeModel  *model;
	GtkTreeIter    iter;
	EmpathyAccount     *account;
	gchar         *chat_id;
	gboolean       is_chatroom;
	gchar         *date;
	EmpathyMessage *message;
	GList         *messages;
	GList         *l;
	gboolean       can_do_previous;
	gboolean       can_do_next;

	/* Get selected information */
	view = GTK_TREE_VIEW (window->treeview_find);
	model = gtk_tree_view_get_model (view);

	if (!gtk_tree_selection_get_selected (selection, NULL, &iter)) {
		gtk_widget_set_sensitive (window->button_previous, FALSE);
		gtk_widget_set_sensitive (window->button_next, FALSE);

		empathy_chat_view_clear (window->chatview_find);

		return;
	}

	gtk_widget_set_sensitive (window->button_previous, TRUE);
	gtk_widget_set_sensitive (window->button_next, TRUE);

	gtk_tree_model_get (model, &iter,
			    COL_FIND_ACCOUNT, &account,
			    COL_FIND_CHAT_ID, &chat_id,
			    COL_FIND_IS_CHATROOM, &is_chatroom,
			    COL_FIND_DATE, &date,
			    -1);

	/* Clear all current messages shown in the textview */
	empathy_chat_view_clear (window->chatview_find);

	/* Turn off scrolling temporarily */
	empathy_chat_view_scroll (window->chatview_find, FALSE);

	/* Get messages */
	messages = empathy_log_manager_get_messages_for_date (window->log_manager,
							      account,
							      chat_id,
							      is_chatroom,
							      date);
	g_object_unref (account);
	g_free (date);
	g_free (chat_id);

	for (l = messages; l; l = l->next) {
		message = l->data;
		empathy_chat_view_append_message (window->chatview_find, message);
		g_object_unref (message);
	}
	g_list_free (messages);

	/* Scroll to the most recent messages */
	empathy_chat_view_scroll (window->chatview_find, TRUE);

	/* Highlight and find messages */
	empathy_chat_view_highlight (window->chatview_find,
				    window->last_find);
	empathy_chat_view_find_next (window->chatview_find,
				    window->last_find,
				    TRUE);
	empathy_chat_view_find_abilities (window->chatview_find,
					 window->last_find,
					 &can_do_previous,
					 &can_do_next);
	gtk_widget_set_sensitive (window->button_previous, can_do_previous);
	gtk_widget_set_sensitive (window->button_next, can_do_next);
	gtk_widget_set_sensitive (window->button_find, FALSE);
}
Ejemplo n.º 7
0
static void
chat_text_view_clear_view_cb (GtkMenuItem *menuitem, EmpathyChatTextView *view)
{
	empathy_chat_view_clear (EMPATHY_CHAT_VIEW (view));
}
Ejemplo n.º 8
0
static void
log_window_find_changed_cb (GtkTreeSelection *selection,
			    EmpathyLogWindow  *window)
{
	GtkTreeView   *view;
	GtkTreeModel  *model;
	GtkTreeIter    iter;
	TpAccount     *account;
	gchar         *chat_id;
	gboolean       is_chatroom;
	gchar         *date;
	GDate         *gdate;

	/* Get selected information */
	view = GTK_TREE_VIEW (window->treeview_find);
	model = gtk_tree_view_get_model (view);

	if (!gtk_tree_selection_get_selected (selection, NULL, &iter)) {
		gtk_widget_set_sensitive (window->button_previous, FALSE);
		gtk_widget_set_sensitive (window->button_next, FALSE);

		empathy_chat_view_clear (window->chatview_find);

		return;
	}

	gtk_widget_set_sensitive (window->button_previous, TRUE);
	gtk_widget_set_sensitive (window->button_next, TRUE);

	gtk_tree_model_get (model, &iter,
			    COL_FIND_ACCOUNT, &account,
			    COL_FIND_CHAT_ID, &chat_id,
			    COL_FIND_IS_CHATROOM, &is_chatroom,
			    COL_FIND_DATE, &date,
			    -1);

	/* Clear all current messages shown in the textview */
	empathy_chat_view_clear (window->chatview_find);

	/* Turn off scrolling temporarily */
	empathy_chat_view_scroll (window->chatview_find, FALSE);

	/* Get messages */
	gdate = gdate_from_str (date);

	if (gdate != NULL) {
		tpl_log_manager_get_messages_for_date_async (window->log_manager,
								      account,
								      chat_id,
								      is_chatroom,
								      gdate,
								      got_messages_for_date_cb,
								      window);

		g_date_free (gdate);
	}

	g_object_unref (account);
	g_free (date);
	g_free (chat_id);
}