Пример #1
0
static void
gimp_path_editor_new_clicked (GtkWidget      *widget,
                              GimpPathEditor *editor)
{
  if (editor->sel_path)
    {
      g_signal_handlers_block_by_func (editor->sel,
                                       gimp_path_editor_selection_changed,
                                       editor);

      gtk_tree_selection_unselect_path (editor->sel, editor->sel_path);

      g_signal_handlers_unblock_by_func (editor->sel,
                                         gimp_path_editor_selection_changed,
                                         editor);

      gtk_tree_path_free (editor->sel_path);
      editor->sel_path = NULL;
    }

  gtk_widget_set_sensitive (editor->delete_button, FALSE);
  gtk_widget_set_sensitive (editor->up_button, FALSE);
  gtk_widget_set_sensitive (editor->down_button, FALSE);
  gtk_widget_set_sensitive (editor->file_entry, TRUE);

  gtk_editable_set_position
    (GTK_EDITABLE (GIMP_FILE_ENTRY (editor->file_entry)->entry), -1);
  gtk_widget_grab_focus
    (GTK_WIDGET (GIMP_FILE_ENTRY (editor->file_entry)->entry));
}
Пример #2
0
static void raise_bus_cell_position (GtkWidget *widget, gpointer data)
  {
  bus_layout_D *dialog = (bus_layout_D *)data ;
  GtkTreeSelection *sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->tview)) ;
  GtkTreeModel *tm = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->tview)) ;
  GtkTreePath *tpBus = g_object_get_data (G_OBJECT (dialog->tview), "tpBus") ;
  GtkTreePath *tpSrc = NULL, *tpDst = NULL ;
  int icChildren = -1, Nix ;

  if (NULL == tpBus) return ;
  if (0 == (icChildren = gtk_tree_model_path_n_children (tm, tpBus))) return ;

  gtk_tree_path_down (tpDst = gtk_tree_path_copy (tpBus)) ;
  gtk_tree_path_next (tpSrc = gtk_tree_path_copy (tpDst)) ;

  for (Nix = 1 ; Nix < icChildren ; Nix++)
    {
    if (gtk_tree_selection_path_is_selected (sel, tpSrc))
      {
      // swap the 2 rows
      swap_model_paths_contents (tm, tpSrc, tpDst) ;
      gtk_tree_selection_unselect_path (sel, tpSrc) ;
      gtk_tree_selection_select_path (sel, tpDst) ;
      }
    gtk_tree_path_next (tpSrc) ;
    gtk_tree_path_next (tpDst) ;
    }
  }
Пример #3
0
static void
select_or_unselect_range(GtkTreeSelection *selection,
                         guint from, guint to,
                         gboolean select)
{
    if (from == to)
        return;

    GtkTreePath *pathfrom = gtk_tree_path_new();
    gtk_tree_path_append_index(pathfrom, from);
    if (from+1 == to) {
        if (select)
            gtk_tree_selection_select_path(selection, pathfrom);
        else
            gtk_tree_selection_unselect_path(selection, pathfrom);
    }
    else {
        GtkTreePath *pathto = gtk_tree_path_new();
        gtk_tree_path_append_index(pathto, to);
        if (select)
            gtk_tree_selection_select_range(selection, pathfrom, pathto);
        else
            gtk_tree_selection_unselect_range(selection, pathfrom, pathto);
        gtk_tree_path_free(pathto);
    }
    gtk_tree_path_free(pathfrom);
}
Пример #4
0
void GtkTreeSelection_::unselect_path(Php::Parameters &parameters)
{
	std::string param_path = parameters[0];
	GtkTreePath *path = gtk_tree_path_new_from_string(param_path.c_str());

	gtk_tree_selection_unselect_path (GTK_TREE_SELECTION(instance), path);

}
Пример #5
0
static void deselect_other_type_of_cells (GtkTreeModel *tm, GtkTreePath *tp, GtkTreeIter *itr, gpointer data)
  {
  DESELECT_DIFFERENT_CELLS_STRUCT *ddcs = (DESELECT_DIFFERENT_CELLS_STRUCT *)data ;
  int row_type = -1 ;

  gtk_tree_model_get (tm, itr, BUS_LAYOUT_MODEL_COLUMN_TYPE, &row_type, -1) ;

  if (ddcs->row_type != row_type)
    gtk_tree_selection_unselect_path (ddcs->sel, tp) ;
  }
static gboolean
scan_for_source_name (GtkTreeModel *model,
                      GtkTreePath  *path,
                      GtkTreeIter  *iter,
                      gpointer      user_data)
{
  SelectData *select_data = user_data;
  gchar *source_name = NULL;

  if (!select_data)
    return TRUE;

  gtk_tree_model_get (model, iter, SOURCE_NAME, &source_name, -1);
  if (!source_name)
    return FALSE;

  if (strcmp (source_name, select_data->source_name) == 0)
    {
      GtkTreeView *tree_view;
      GtkTreeSelection *selection;

      select_data->found = TRUE;

      tree_view = GTK_TREE_VIEW (select_data->chooser->priv->treeview);

      if (select_data->do_activate)
        {
          GtkTreeViewColumn *column;

          column = gtk_tree_view_get_column (tree_view, 2);

          gtk_list_store_set (GTK_LIST_STORE (model), iter,
                              SOURCE_CURRENT, PANGO_WEIGHT_BOLD,
                              -1);

          gtk_tree_view_row_activated (tree_view, path, column);
        }

      selection = gtk_tree_view_get_selection (tree_view);
      if (select_data->do_select)
        gtk_tree_selection_select_path (selection, path);
      else
        gtk_tree_selection_unselect_path (selection, path);
    }
  else
    {
      gtk_list_store_set (GTK_LIST_STORE (model), iter,
                          SOURCE_CURRENT, PANGO_WEIGHT_NORMAL,
                          -1);
    }

  g_free (source_name);

  return FALSE;
}
Пример #7
0
static gboolean
select_inverse_foreach_func (GtkTreeModel *model, GtkTreePath *path,
                             GtkTreeIter *iter, gpointer data)
{
    GtkamMain *m = GTKAM_MAIN (data);
    GtkTreeSelection *s;

    s = gtk_tree_view_get_selection (GTK_TREE_VIEW (m->priv->list));
    if (gtk_tree_selection_path_is_selected (s, path))
        gtk_tree_selection_unselect_path (s, path);
    else
        gtk_tree_selection_select_path (s, path);

    return (FALSE);
}
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GtkListPeer_deselect
  (JNIEnv *env, jobject obj, jint index)
{
  void *ptr;
  GtkWidget *list;
  GtkTreeSelection *selection;
  GtkTreePath *path;

  gdk_threads_enter ();

  ptr = gtkpeer_get_widget (env, obj);

  list = list_get_widget (GTK_WIDGET (ptr));
  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (list));
  path = gtk_tree_path_new_from_indices (index, -1);
  gtk_tree_selection_unselect_path (selection, path);

  gdk_threads_leave ();
}
Пример #9
0
static void
fm_list_view_set_cursor (FMDirectoryView *view, GtkTreePath *path, 
                         gboolean start_editing, gboolean select)
{
    FMListView *list_view = FM_LIST_VIEW (view);
    GtkTreeSelection *selection = gtk_tree_view_get_selection (list_view->tree);

    /* the treeview select the path by default */
    if (!select)
        g_signal_handlers_block_by_func (selection, list_selection_changed_callback, list_view);
    gtk_tree_view_set_cursor_on_cell (list_view->tree, path, 
                                      list_view->details->file_name_column,
                                      (GtkCellRenderer *) list_view->details->file_name_cell,
                                      start_editing);

    if (!select) {
        gtk_tree_selection_unselect_path (selection, path);
        g_signal_handlers_unblock_by_func (selection, list_selection_changed_callback, list_view);
    }
}
Пример #10
0
static void lower_bus_cell_position (GtkWidget *widget, gpointer data)
  {
  bus_layout_D *dialog = (bus_layout_D *)data ;
  GtkTreeSelection *sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->tview)) ;
  GtkTreeModel *tm = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->tview)) ;
  GtkTreePath *tpBus = g_object_get_data (G_OBJECT (dialog->tview), "tpBus") ;
  GtkTreePath *tpSrc = NULL, *tpDst = NULL ;
  int icChildren = -1, Nix ;

  if (NULL == tpBus)
		{
		fprintf (stderr, "lower_bus_cell_position: tpBus == NULL !\n") ;
		return ;
		}
  if (0 == (icChildren = gtk_tree_model_path_n_children (tm, tpBus)))
		{
		fprintf (stderr, "lower_bus_cell_position: tpBus has no children O_o\n") ;
		return ;
		}

  gtk_tree_path_down (tpDst = gtk_tree_path_copy (tpBus)) ;
  for (Nix = 1 ; Nix < icChildren ; Nix++) gtk_tree_path_next (tpDst) ;
    // St00pid short-circuit if statement to suppress a warning.
    if (gtk_tree_path_prev (tpSrc = gtk_tree_path_copy (tpDst))) ;

  for (Nix = 1 ; Nix < icChildren ; Nix++)
    {
    if (gtk_tree_selection_path_is_selected (sel, tpSrc))
      {
      // swap the 2 rows
      swap_model_paths_contents (tm, tpSrc, tpDst) ;
      gtk_tree_selection_unselect_path (sel, tpSrc) ;
      gtk_tree_selection_select_path (sel, tpDst) ;
      }
    if (!gtk_tree_path_prev (tpSrc)) break ;
    if (!gtk_tree_path_prev (tpDst)) break ;
    }
  }
Пример #11
0
gboolean treemodel_update_selection(GtkTreeModel* model, GtkTreePath* path, GtkTreeIter* iter, gpointer data)
{
  GtkTreeView* view = reinterpret_cast<GtkTreeView*>(data);

  scene::Instance* instance;
  gtk_tree_model_get_pointer(model, iter, 1, &instance);
  Selectable* selectable = Instance_getSelectable(*instance);

  if(selectable != 0)
  {
    GtkTreeSelection* selection = gtk_tree_view_get_selection(view);
    if(selectable->isSelected())
    {
      gtk_tree_selection_select_path(selection, path);
    }
    else
    {
      gtk_tree_selection_unselect_path(selection, path);
    }
  }

  return FALSE;
}
Пример #12
0
// Implements the selection constraints for the available cells tree view
static gboolean select_cell_row_p (GtkTreeSelection *sel, GtkTreeModel *tm, GtkTreePath *tp, gboolean bSelStatus, gpointer data)
  {
  int Nix ;
  static gboolean bIgnore = FALSE ;
  int this_row_type = -1 ;
  GtkTreeIter itr ;

  if (bIgnore) return TRUE ;

  if (!gtk_tree_model_get_iter (tm, &itr, tp)) return FALSE ;

  gtk_tree_model_get (tm, &itr, BUS_LAYOUT_MODEL_COLUMN_TYPE, &this_row_type, -1) ;

  if (this_row_type & ROW_TYPE_BUS)
    {
    GtkTreePath *tpNew = NULL ;
    int icChildren = gtk_tree_model_iter_n_children (tm, &itr) ;
    int x, y ;
    GdkModifierType mask ;

    if (bSelStatus)
      {
      bIgnore = TRUE ;
      gtk_tree_selection_unselect_path (sel, tp) ;
      bIgnore = FALSE ;
      }

    gtk_tree_view_expand_row (gtk_tree_selection_get_tree_view (sel), tp, TRUE) ;

    if (icChildren > 0)
      {
      // I should be able to programmatically simulate a "click" event, because its meaning depends
      // on whether Ctrl or Shift are held down.  I should not have to reproduce that behaviour here,
      // because it may change in the future. I need to simulate a "click" event because I would like to
      // implement the following: Clicking on a bus is equivalent to clicking on all its inputs
      gdk_window_get_pointer (GTK_WIDGET (gtk_tree_selection_get_tree_view (sel))->window, &x, &y, &mask) ;

      gtk_tree_path_down (tpNew = gtk_tree_path_copy (tp)) ;

      bSelStatus = gtk_tree_selection_path_is_selected (sel, tpNew) ;

      for (Nix = 0 ; Nix < icChildren ; Nix++, gtk_tree_path_next (tpNew))
        if ((mask & GDK_CONTROL_MASK))
          {
          if (bSelStatus)
            gtk_tree_selection_unselect_path (sel, tpNew) ;
          else
            gtk_tree_selection_select_path (sel, tpNew) ;
          }
        else
          gtk_tree_selection_select_path (sel, tpNew) ;

      gtk_tree_path_free (tpNew) ;
      }
    return FALSE ;
    }
  else
  if (this_row_type & ROW_TYPE_CELL)
    {
    if (!bSelStatus)
      {
      DESELECT_DIFFERENT_CELLS_STRUCT ddcs = {NULL, 0} ;

      ddcs.sel = sel ;
      ddcs.row_type = this_row_type ;

      gtk_tree_selection_selected_foreach (sel, deselect_other_type_of_cells, &ddcs) ;
      }
    }

  return TRUE ;
  }
Пример #13
0
static gboolean
exo_tree_view_single_click_timeout (gpointer user_data)
{
  GtkTreeViewColumn *cursor_column;
  GtkTreeSelection  *selection;
  GtkTreeModel      *model;
  GtkTreePath       *cursor_path;
  GtkTreeIter        iter;
  ExoTreeView       *tree_view = EXO_TREE_VIEW (user_data);
  gboolean           hover_path_selected;
  GList             *rows;
  GList             *lp;

  //GDK_THREADS_ENTER ();  //sfm not needed because called from g_idle?

  /* verify that we are in single-click mode, have focus and a hover path */
  if (gtk_widget_has_focus (GTK_WIDGET (tree_view)) && tree_view->priv->single_click && tree_view->priv->hover_path != NULL)
    {
      /* transform the hover_path to a tree iterator */
      model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view));
      if (model != NULL && gtk_tree_model_get_iter (model, &iter, tree_view->priv->hover_path))
        {
          /* determine the current cursor path/column */
          gtk_tree_view_get_cursor (GTK_TREE_VIEW (tree_view), &cursor_path, &cursor_column);

          /* be sure the row is fully visible */
          gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (tree_view),
                            tree_view->priv->hover_path, 
                            0, //sfm was cursor_column - caused horizontal scroll
                            FALSE, 0.0f, 0.0f);

          /* determine the selection and change it appropriately */
          selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));
          if (gtk_tree_selection_get_mode (selection) == GTK_SELECTION_NONE)
            {
              /* just place the cursor on the row */
              gtk_tree_view_set_cursor (GTK_TREE_VIEW (tree_view), tree_view->priv->hover_path, cursor_column, FALSE);
            }
          else if ((tree_view->priv->single_click_timeout_state & GDK_SHIFT_MASK) != 0
                && gtk_tree_selection_get_mode (selection) == GTK_SELECTION_MULTIPLE)
            {
              /* check if the item is not already selected (otherwise do nothing) */
              if (!gtk_tree_selection_path_is_selected (selection, tree_view->priv->hover_path))
                {
                  /* unselect all previously selected items */
                  gtk_tree_selection_unselect_all (selection);

                  /* since we cannot access the anchor of a GtkTreeView, we
                   * use the cursor instead which is usually the same row.
                   */
                  if (G_UNLIKELY (cursor_path == NULL))
                    {
                      /* place the cursor on the new row */
                      gtk_tree_view_set_cursor (GTK_TREE_VIEW (tree_view), tree_view->priv->hover_path, cursor_column, FALSE);
                    }
                  else
                    {
                      /* select all between the cursor and the current row */
                      gtk_tree_selection_select_range (selection, tree_view->priv->hover_path, cursor_path);
                    }
                }
            }
          else
            {
              /* remember the previously selected rows as set_cursor() clears the selection */
              rows = gtk_tree_selection_get_selected_rows (selection, NULL);

              /* check if the hover path is selected (as it will be selected after the set_cursor() call) */
              hover_path_selected = gtk_tree_selection_path_is_selected (selection, tree_view->priv->hover_path);

              /* place the cursor on the hover row */
              gtk_tree_view_set_cursor (GTK_TREE_VIEW (tree_view), tree_view->priv->hover_path, cursor_column, FALSE);

              /* restore the previous selection */
              for (lp = rows; lp != NULL; lp = lp->next)
                {
                  gtk_tree_selection_select_path (selection, lp->data);
                  gtk_tree_path_free (lp->data);
                }
              g_list_free (rows);

              /* check what to do */
              if ((gtk_tree_selection_get_mode (selection) == GTK_SELECTION_MULTIPLE ||
                  (gtk_tree_selection_get_mode (selection) == GTK_SELECTION_SINGLE && hover_path_selected))
                  && (tree_view->priv->single_click_timeout_state & GDK_CONTROL_MASK) != 0)
                {
                  /* toggle the selection state of the row */
                  if (G_UNLIKELY (hover_path_selected))
                    gtk_tree_selection_unselect_path (selection, tree_view->priv->hover_path);
                  else
                    gtk_tree_selection_select_path (selection, tree_view->priv->hover_path);
                }
              else if (G_UNLIKELY (!hover_path_selected))
                {
                  /* unselect all other rows */
                  gtk_tree_selection_unselect_all (selection);

                  /* select only the hover row */
                  gtk_tree_selection_select_path (selection, tree_view->priv->hover_path);
                }
            }

          /* cleanup */
          if (G_LIKELY (cursor_path != NULL))
            gtk_tree_path_free (cursor_path);
        }
    }

  //GDK_THREADS_LEAVE ();

  return FALSE;
}