コード例 #1
0
static void
got_messages_for_date_cb (GObject *manager,
                       GAsyncResult *result,
                       gpointer user_data)
{
	EmpathyLogWindow *window = user_data;
	GList         *messages;
	GList         *l;
	gboolean       can_do_previous;
	gboolean       can_do_next;
	GError        *error = NULL;

	if (log_window == NULL)
		return;

	if (!tpl_log_manager_get_messages_for_date_finish (TPL_LOG_MANAGER (manager),
		result, &messages, &error)) {
			DEBUG ("Unable to retrieve messages for the selected date: %s. Aborting",
					error->message);
			empathy_chat_view_append_event (window->chatview_find,
					"Unable to retrieve messages for the selected date");
			g_error_free (error);
			return;
	}

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

			g_assert (TPL_IS_ENTRY (l->data));

			message = empathy_message_from_tpl_log_entry (l->data);
			g_object_unref (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,
			FALSE);
	empathy_chat_view_find_next (window->chatview_find,
			window->last_find,
			TRUE,
			FALSE);
	empathy_chat_view_find_abilities (window->chatview_find,
			window->last_find,
			FALSE,
			&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);
}
コード例 #2
0
static void
log_window_updating_calendar_month_cb (GObject *manager,
		GAsyncResult *result, gpointer user_data)
{
	EmpathyLogWindow *window = user_data;
	GList					*dates;
	GList					*l;
	guint					 year_selected;
	guint					 month_selected;
	GError				*error = NULL;

	dates = tpl_log_manager_get_dates_async_finish (result, &error);

	if (error != NULL) {
			DEBUG ("Unable to retrieve messages' dates: %s. Aborting",
					error->message);
			empathy_chat_view_append_event (window->chatview_find,
					"Unable to retrieve messages' dates");
			g_error_free (error);
			return;
	}

	gtk_calendar_clear_marks (GTK_CALENDAR (window->calendar_chats));
	g_object_get (window->calendar_chats,
			"month", &month_selected,
			"year", &year_selected,
			NULL);

	/* We need this here because it appears that the months start from 0 */
	month_selected++;

	for (l = dates; l; l = l->next) {
			const gchar *str;
			guint        year;
			guint        month;
			guint        day;

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

			sscanf (str, "%4d%2d%2d", &year, &month, &day);

			if (year == year_selected && month == month_selected) {
					DEBUG ("Marking date:'%s'", str);
					gtk_calendar_mark_day (GTK_CALENDAR (window->calendar_chats), day);
			}
	}

	g_list_foreach (dates, (GFunc) g_free, NULL);
	g_list_free (dates);

	DEBUG ("Currently showing month %d and year %d", month_selected,
			year_selected);
}
コード例 #3
0
static void
log_window_updating_calendar_month_cb (GObject *manager,
		GAsyncResult *result, gpointer user_data)
{
	EmpathyLogWindow *window = user_data;
	GList					*dates;
	GList					*l;
	guint					 year_selected;
	guint					 month_selected;
	GError				*error = NULL;

	if (log_window == NULL)
		return;

	if (!tpl_log_manager_get_dates_finish (TPL_LOG_MANAGER (manager),
		result, &dates, &error)) {
			DEBUG ("Unable to retrieve messages' dates: %s. Aborting",
					error->message);
			empathy_chat_view_append_event (window->chatview_find,
					"Unable to retrieve messages' dates");
			g_error_free (error);
			return;
	}

	gtk_calendar_clear_marks (GTK_CALENDAR (window->calendar_chats));
	g_object_get (window->calendar_chats,
			"month", &month_selected,
			"year", &year_selected,
			NULL);

	/* We need this here because it appears that the months start from 0 */
	month_selected++;

	for (l = dates; l; l = l->next) {
			GDate *date = l->data;

			if (g_date_get_year (date) == year_selected &&
			    g_date_get_month (date) == month_selected) {
					DEBUG ("Marking date: %04u-%02u-%02u", g_date_get_year (date),
						g_date_get_month (date), g_date_get_day (date));
					gtk_calendar_mark_day (GTK_CALENDAR (window->calendar_chats), g_date_get_day (date));
			}
	}

	g_list_foreach (dates, (GFunc) g_free, NULL);
	g_list_free (dates);

	DEBUG ("Currently showing month %d and year %d", month_selected,
			year_selected);
}
コード例 #4
0
static void
log_window_got_messages_for_date_cb (GObject *manager,
    GAsyncResult *result,
    gpointer user_data)
{
  EmpathyLogWindow *window = user_data;
  GList *messages;
  GList *l;
  GError *error = NULL;

  if (log_window == NULL)
    return;

  if (!tpl_log_manager_get_messages_for_date_finish (TPL_LOG_MANAGER (manager),
        result, &messages, &error)) {
      DEBUG ("Unable to retrieve messages for the selected date: %s. Aborting",
          error->message);
      empathy_chat_view_append_event (window->chatview_find,
          "Unable to retrieve messages for the selected date");
      g_error_free (error);
      return;
  }

  for (l = messages; l; l = l->next) {
      EmpathyMessage *message = empathy_message_from_tpl_log_entry (l->data);
      g_object_unref (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);
}
コード例 #5
0
static void
preferences_preview_theme_changed_cb (EmpathyThemeManager *manager,
				      EmpathyPreferences  *preferences)
{
	EmpathyPreferencesPriv *priv = GET_PRIV (preferences);
	TpDBusDaemon *dbus;
	TpAccount *account;
	EmpathyContact *juliet;
	EmpathyContact *romeo;

	DEBUG ("Theme changed, update preview widget");

	if (priv->chat_theme_preview != NULL) {
		gtk_widget_destroy (GTK_WIDGET (priv->chat_theme_preview));
	}
	priv->chat_theme_preview = empathy_theme_manager_create_view (manager);
	gtk_container_add (GTK_CONTAINER (priv->sw_chat_theme_preview),
			   GTK_WIDGET (priv->chat_theme_preview));
	gtk_widget_show (GTK_WIDGET (priv->chat_theme_preview));

	/* FIXME: It is ugly to add a fake conversation like that.
	 * Would be cool if we could request a TplLogManager for a fake
	 * conversation */
	dbus = tp_dbus_daemon_dup (NULL);
	account = tp_account_new (dbus,
		TP_ACCOUNT_OBJECT_PATH_BASE "cm/jabber/account", NULL);
	juliet = g_object_new (EMPATHY_TYPE_CONTACT,
		"account", account,
		"id", "juliet",
		/* translators: Contact name for the chat theme preview */
		"alias", _("Juliet"),
		"is-user", FALSE,
		NULL);
	romeo = g_object_new (EMPATHY_TYPE_CONTACT,
		"account", account,
		"id", "romeo",
		/* translators: Contact name for the chat theme preview */
		"alias", _("Romeo"),
		"is-user", TRUE,
		NULL);

	preferences_preview_theme_append_message (priv->chat_theme_preview,
		/* translators: Quote from Romeo & Julier, for chat theme preview */
		juliet, romeo, _("O Romeo, Romeo, wherefore art thou Romeo?"),
		TRUE /* this message mentions Romeo */);
	preferences_preview_theme_append_message (priv->chat_theme_preview,
		/* translators: Quote from Romeo & Julier, for chat theme preview */
		juliet, romeo, _("Deny thy father and refuse thy name;"), FALSE);
	preferences_preview_theme_append_message (priv->chat_theme_preview,
		/* translators: Quote from Romeo & Julier, for chat theme preview */
		juliet, romeo, _("Or if thou wilt not, be but sworn my love"), FALSE);
	preferences_preview_theme_append_message (priv->chat_theme_preview,
		/* translators: Quote from Romeo & Julier, for chat theme preview */
		juliet, romeo, _("And I'll no longer be a Capulet."), FALSE);
	preferences_preview_theme_append_message (priv->chat_theme_preview,
		/* translators: Quote from Romeo & Julier, for chat theme preview */
		romeo, juliet, _("Shall I hear more, or shall I speak at this?"), FALSE);

	/* translators: Quote from Romeo & Julier, for chat theme preview */
	empathy_chat_view_append_event (priv->chat_theme_preview, _("Juliet has disconnected"));

	g_object_unref (juliet);
	g_object_unref (romeo);
	g_object_unref (account);
	g_object_unref (dbus);
}
コード例 #6
0
static void
log_manager_got_dates_cb (GObject *manager,
                          GAsyncResult *result,
                          gpointer user_data)
{
  EmpathyLogWindow *window = user_data;
  GList         *dates;
  GList         *l;
  guint          year_selected;
  guint          month_selected;
  gboolean       day_selected = FALSE;
  GDate         *date = NULL;
  GError        *error = NULL;

  if (log_window == NULL)
    return;

  if (!tpl_log_manager_get_dates_finish (TPL_LOG_MANAGER (manager),
        result, &dates, &error)) {
    DEBUG ("Unable to retrieve messages' dates: %s. Aborting",
        error->message);
    empathy_chat_view_append_event (window->chatview_find,
        "Unable to retrieve messages' dates");
      return;
  }

  for (l = dates; l; l = l->next) {
      GDate *d = l->data;

      gtk_calendar_get_date (GTK_CALENDAR (window->calendar_chats),
          &year_selected,
          &month_selected,
          NULL);

      month_selected++;

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

      if (g_date_get_year (d) != year_selected ||
          g_date_get_month (d) != month_selected) {
          continue;
      }

      DEBUG ("Marking date: %04u-%02u-%02u", g_date_get_year (d),
          g_date_get_month (d), g_date_get_day (d));

      gtk_calendar_mark_day (GTK_CALENDAR (window->calendar_chats),
          g_date_get_day (d));

      if (l->next) {
          continue;
      }

      day_selected = TRUE;

      gtk_calendar_select_day (GTK_CALENDAR (window->calendar_chats),
          g_date_get_day (d));
  }

  if (!day_selected) {
      /* Unselect the day in the calendar */
      gtk_calendar_select_day (GTK_CALENDAR (window->calendar_chats), 0);
  }

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

  if (date != NULL) {
      /* Show messages of the most recent date */
      log_window_get_messages_for_date (window, date);
  }

  g_list_foreach (dates, (GFunc) g_free, NULL);
  g_list_free (dates);
}
コード例 #7
0
static void
log_manager_got_dates_cb (GObject *manager,
                          GAsyncResult *result,
                          gpointer user_data)
{
  EmpathyLogWindow *window = user_data;
  GList         *dates;
  GList         *l;
  guint          year_selected;
  guint          year;
  guint          month;
  guint          month_selected;
  guint          day;
  gboolean       day_selected = FALSE;
  const gchar   *date = NULL;
  GError        *error = NULL;

  dates = tpl_log_manager_get_dates_async_finish (result, &error);

  if (error != NULL) {
    DEBUG ("Unable to retrieve messages' dates: %s. Aborting",
        error->message);
    empathy_chat_view_append_event (window->chatview_find,
        "Unable to retrieve messages' dates");
      return;
  }

  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);
  }

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

  if (date) {
      log_window_get_messages_for_date (window, date);
  }

  g_list_foreach (dates, (GFunc) g_free, NULL);
  g_list_free (dates);
}