コード例 #1
0
ファイル: gtr-message-table.c プロジェクト: GNOME/gtranslator
static void
gtr_message_table_selection_changed (GtkTreeSelection *selection,
                                     GtrMessageTable *table)
{
    GtkTreeIter iter;
    GtkTreeModel *model;
    GtrMsg *msg;
    GList *current_msg = NULL;
    GtrMessageTablePrivate *priv;
    GtrPo *po;

    g_return_if_fail (selection != NULL);

    priv = gtr_message_table_get_instance_private (table);

    po = gtr_tab_get_po (priv->tab);
    current_msg = gtr_po_get_current_message (po);

    if (gtk_tree_selection_get_selected (selection, &model, &iter) == TRUE)
    {
        gtk_tree_model_get (model, &iter,
                            GTR_MESSAGE_TABLE_MODEL_POINTER_COLUMN, &msg, -1);

        if (msg != NULL
                && g_utf8_collate (gtr_msg_get_msgid (msg),
                                   gtr_msg_get_msgid (current_msg->data)))
        {
            g_signal_handlers_block_by_func (priv->tab, showed_message_cb, table);
            gtr_tab_message_go_to (priv->tab, msg,
                                   FALSE, GTR_TAB_MOVE_NONE);
            g_signal_handlers_unblock_by_func (priv->tab, showed_message_cb, table);
        }
    }
}
コード例 #2
0
ファイル: gtr-message-table.c プロジェクト: GNOME/gtranslator
static void
gtr_message_table_selection_changed (GtkTreeSelection *selection,
                                     GtrMessageTable *table)
{
  GtkTreeIter iter;
  GtkTreeModel *model;
  GtrMsg *msg;
  GtrMessageTablePrivate *priv;

  g_return_if_fail (selection != NULL);

  priv = gtr_message_table_get_instance_private (table);

  if (gtk_tree_selection_get_selected (selection, &model, &iter) == TRUE)
    {
      gtk_tree_model_get (model, &iter,
                          GTR_MESSAGE_TABLE_MODEL_POINTER_COLUMN, &msg, -1);

      if (msg != NULL)
        {
          g_signal_handlers_block_by_func (priv->tab, showed_message_cb, table);
          gtr_tab_message_go_to (priv->tab, msg,
                                 FALSE, GTR_TAB_MOVE_NONE);
          g_signal_handlers_unblock_by_func (priv->tab, showed_message_cb, table);
        }
    }
}
コード例 #3
0
/*
 * The main file opening function. Checks that the file isn't already open,
 * and if not, opens it in a new tab.
 */
gboolean
gtr_open (GFile * location, GtrWindow * window, GError ** error)
{
  GtrHeader *header;
  GtrPo *po;
  GtrTab *tab;
  GList *current;
  GtrView *active_view;
  const gchar *project_id;

  /*
   * If the filename can't be opened, pass the error back to the caller
   * to handle.
   */
  po = gtr_po_new ();
  gtr_po_parse (po, location, error);

  if ((*error != NULL)
      && (((GError *) * error)->code != GTR_PO_ERROR_RECOVERY))
    return FALSE;

  header = gtr_po_get_header (po);
  project_id = gtr_header_get_prj_id_version (header);

  /*
   * If not a crash/temporary file, add to the history.
   */
  _gtr_recent_add (window, location, (gchar *)project_id);

  /*
   * Create a page to add to our list of open files
   */
  tab = gtr_window_create_tab (window, po);
  gtr_window_set_active_tab (window, GTK_WIDGET (tab));

  /*
   * Show the current message.
   */
  current = gtr_po_get_current_message (po);
  gtr_tab_message_go_to (tab, current->data, FALSE, GTR_TAB_MOVE_NONE);

  /*
   * Grab the focus
   */
  active_view = gtr_tab_get_active_view (tab);
  gtk_widget_grab_focus (GTK_WIDGET (active_view));

  gtr_statusbar_update_progress_bar (GTR_STATUSBAR
                                     (gtr_window_get_statusbar
                                      (window)),
                                     (gdouble)
                                     gtr_po_get_translated_count
                                     (po),
                                     (gdouble)
                                     gtr_po_get_messages_count (po));

  return TRUE;
}