Пример #1
0
static gboolean
thunar_location_entry_accept_focus (ThunarLocationBar *location_bar,
                                    const gchar       *initial_text)
{
  ThunarLocationEntry *location_entry = THUNAR_LOCATION_ENTRY (location_bar);

  /* give the keyboard focus to the path entry */
  gtk_widget_grab_focus (location_entry->path_entry);

  /* check if we have an initial text for the location bar */
  if (G_LIKELY (initial_text != NULL))
    {
      /* setup the new text */
      gtk_entry_set_text (GTK_ENTRY (location_entry->path_entry), initial_text);

      /* move the cursor to the end of the text */
      gtk_editable_set_position (GTK_EDITABLE (location_entry->path_entry), -1);
    }
  else
    {
      /* select the whole path in the path entry */
      gtk_editable_select_region (GTK_EDITABLE (location_entry->path_entry), 0, -1);
    }

  return TRUE;
}
Пример #2
0
/**
 * thunar_location_bar_request_entry
 * @bar          : The #ThunarLocationBar
 * @initial_text : The initial text to be placed inside the entry, or NULL to
 *                 use the path of the current directory.
 *
 * Makes the location bar display an entry with the given text and places the cursor
 * accordingly. If the currently displayed location widget is a path bar, it will be
 * temporarily swapped for an entry widget and swapped back once the user completed
 * (or aborted) the input.
 */
void
thunar_location_bar_request_entry (ThunarLocationBar *bar,
                                   const gchar       *initial_text)
{
  GtkWidget *child;

  child = gtk_bin_get_child (GTK_BIN (bar));

  _thunar_return_if_fail (child != NULL && GTK_IS_WIDGET (child));

  if (THUNAR_IS_LOCATION_ENTRY (child))
    {
      /* already have an entry */
      thunar_location_entry_accept_focus (THUNAR_LOCATION_ENTRY (child), initial_text);
    }
  else
    {
      /* not an entry => temporarily replace it */
      child = thunar_location_bar_install_widget (bar, THUNAR_TYPE_LOCATION_ENTRY);
      thunar_location_entry_accept_focus (THUNAR_LOCATION_ENTRY (child), initial_text);
    }

  g_signal_connect (child, "edit-done", G_CALLBACK (thunar_location_bar_on_enry_edit_done), bar);
}
Пример #3
0
static void
thunar_location_entry_set_current_directory (ThunarNavigator *navigator,
                                             ThunarFile      *current_directory)
{
  ThunarLocationEntry *location_entry = THUNAR_LOCATION_ENTRY (navigator);

  /* disconnect from the previous directory */
  if (G_LIKELY (location_entry->current_directory != NULL))
    g_object_unref (G_OBJECT (location_entry->current_directory));

  /* activate the new directory */
  location_entry->current_directory = current_directory;

  /* connect to the new directory */
  if (G_LIKELY (current_directory != NULL))
    g_object_ref (G_OBJECT (current_directory));

  /* notify listeners */
  g_object_notify (G_OBJECT (location_entry), "current-directory");
}
Пример #4
0
static ThunarFile*
thunar_location_entry_get_current_directory (ThunarNavigator *navigator)
{
  return THUNAR_LOCATION_ENTRY (navigator)->current_directory;
}