Example #1
0
void remove_current_playlist_entry(gmpv_handle *ctx)
{
	const gchar *cmd[] = {"playlist_remove", NULL, NULL};
	PlaylistWidget *playlist;
	GtkTreePath *path;

	playlist = PLAYLIST_WIDGET(ctx->gui->playlist);

	gtk_tree_view_get_cursor
		(	GTK_TREE_VIEW(playlist->tree_view),
			&path,
			NULL );

	if(path)
	{
		gint index;
		gchar *index_str;

		index = gtk_tree_path_get_indices(path)[0];
		index_str = g_strdup_printf("%d", index);
		cmd[1] = index_str;

		g_signal_handlers_block_matched
			(	playlist->list_store,
				G_SIGNAL_MATCH_DATA,
				0,
				0,
				NULL,
				NULL,
				ctx );

		playlist_widget_remove(playlist, index);

		if(ctx->loaded)
		{
			mpv_check_error(mpv_command(ctx->mpv_ctx, cmd));
		}

		if(playlist_widget_empty(playlist))
		{
			control_box_set_enabled
				(CONTROL_BOX(ctx->gui->control_box), FALSE);
		}

		g_signal_handlers_unblock_matched
			(	playlist->list_store,
				G_SIGNAL_MATCH_DATA,
				0,
				0,
				NULL,
				NULL,
				ctx );

		g_free(index_str);
	}
}
Example #2
0
G_MODULE_EXPORT void
audio_list_selection_changed_cb(GtkTreeSelection *selection, signal_user_data_t *ud)
{
    GtkTreeModel *store;
    GtkTreeIter iter;
    GtkWidget *widget;
    
    GtkTreePath *treepath;
    gint *indices;
    gint row;
    GValue *asettings = NULL;

    const GValue *audio_list;
    g_debug("audio_list_selection_changed_cb ()");
    if (gtk_tree_selection_get_selected(selection, &store, &iter))
    {
        //const gchar *actual_codec, *track, *codec, *bitrate, *sample_rate, *mix;
        //gdouble drc;

        // Get the row number
        treepath = gtk_tree_model_get_path (store, &iter);
        indices = gtk_tree_path_get_indices (treepath);
        row = indices[0];
        gtk_tree_path_free(treepath);
        // find audio settings
        if (row < 0) return;
        audio_list = ghb_settings_get_value(ud->settings, "audio_list");
        if (row >= ghb_array_len(audio_list))
            return;
        asettings = ghb_array_get_nth(audio_list, row);

        block_updates = TRUE;
        ghb_ui_update(ud, "AudioTrack", ghb_settings_get_value(asettings, "AudioTrack"));
        ghb_ui_update(ud, "AudioEncoder", ghb_settings_get_value(asettings, "AudioEncoder"));
        ghb_settings_set_value(ud->settings, "AudioEncoderActual", ghb_settings_get_value(asettings, "AudioEncoderActual"));
        ghb_check_dependency(ud, NULL, "AudioEncoderActual");
        ghb_ui_update(ud, "AudioBitrate", ghb_settings_get_value(asettings, "AudioBitrate"));
        ghb_ui_update(ud, "AudioTrackName", ghb_settings_get_value(asettings, "AudioTrackName"));
        ghb_ui_update(ud, "AudioSamplerate", ghb_settings_get_value(asettings, "AudioSamplerate"));
        ghb_ui_update(ud, "AudioMixdown", ghb_settings_get_value(asettings, "AudioMixdown"));
        ghb_ui_update(ud, "AudioTrackDRCSlider", ghb_settings_get_value(asettings, "AudioTrackDRCSlider"));
        ghb_ui_update(ud, "AudioTrackGain", ghb_settings_get_value(asettings, "AudioTrackGain"));
        ghb_ui_update(ud, "AudioTrackQuality", ghb_settings_get_value(asettings, "AudioTrackQuality"));
        ghb_ui_update(ud, "AudioTrackQualityEnable", ghb_settings_get_value(asettings, "AudioTrackQualityEnable"));
        block_updates = FALSE;
        widget = GHB_WIDGET (ud->builder, "audio_remove");
        gtk_widget_set_sensitive(widget, TRUE);

        ghb_adjust_audio_rate_combos(ud);
    }
    else
    {
        widget = GHB_WIDGET (ud->builder, "audio_remove");
        gtk_widget_set_sensitive(widget, FALSE);
    }
}
gboolean
gnc_sx_slr_model_get_instance_and_variable(GncSxSlrTreeModelAdapter *model, GtkTreeIter *iter, GncSxInstance **instance_loc, GncSxVariable **var_loc)
{
    GtkTreePath *path;
    gint *indices, variable_index;
    GncSxInstance *instance;
    GList *variables;

    instance = _gnc_sx_slr_model_get_instance(model, iter, FALSE);
    if (instance == NULL)
    {
        return FALSE;
    }
    variables = gnc_sx_instance_get_variables(instance);

    path = gtk_tree_model_get_path(GTK_TREE_MODEL(model), iter);
    if (gtk_tree_path_get_depth(path) != 3)
    {
        gtk_tree_path_free(path);
        return FALSE;
    }
    indices = gtk_tree_path_get_indices(path);
    variable_index = indices[2];
    gtk_tree_path_free(path);

    if (variable_index < 0 || variable_index >= g_list_length(variables))
    {
        g_list_free(variables);
        return FALSE;
    }

    if (instance_loc != NULL)
    {
        *instance_loc = instance;
    }

    if (var_loc != NULL)
    {
        // *var_loc = (GncSxVariable*)g_list_nth_data(variables, variable_index);
        GList *list_iter = variables;
        for (; list_iter != NULL; list_iter = list_iter->next)
        {
            GncSxVariable *var = (GncSxVariable*)list_iter->data;
            if (!var->editable)
                continue;
            if (variable_index-- == 0)
            {
                *var_loc = var;
                break;
            }
        }
    }

    g_list_free(variables);
    return TRUE;
}
static void
status_edited_cb (GtkCellRenderer *renderer, const gchar *path, const gchar *text, GtkTreeView *view)
{
	SunOneInvitationListModel *model = SUNONE_INVITATION_LIST_MODEL (gtk_tree_view_get_model (view));
	GtkTreePath *treepath = gtk_tree_path_new_from_string (path);
	int row = gtk_tree_path_get_indices (treepath)[0];
       
	sunone_invitation_list_model_set_value (model, STATUS_COL, row, text);
	gtk_tree_path_free (treepath);
}
Example #5
0
gint selected_row(void)
{
	GtkTreeIter i;
	if (!gtk_tree_selection_get_selected(tree_selection, NULL, &i))
		return -1;
	GtkTreePath *p = gtk_tree_model_get_path(GTK_TREE_MODEL(list_store), &i);
	gint row = gtk_tree_path_get_indices(p)[0];
	gtk_tree_path_free(p);
	return row;
}
Example #6
0
G_MODULE_EXPORT void
queue_remove_clicked_cb(GtkWidget *widget, gchar *path, signal_user_data_t *ud)
{
    GtkTreeView *treeview;
    GtkTreePath *treepath;
    GtkTreeModel *store;
    GtkTreeIter iter;
    gint row;
    gint *indices;
    gint unique_id;
    GValue *settings;
    gint status;

    g_debug("queue_remove_clicked_cb ()");
    treeview = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "queue_list"));
    store = gtk_tree_view_get_model(treeview);
    treepath = gtk_tree_path_new_from_string (path);
    if (gtk_tree_path_get_depth(treepath) > 1) return;
    if (gtk_tree_model_get_iter(store, &iter, treepath))
    {
        // Find the entry in the queue
        indices = gtk_tree_path_get_indices (treepath);
        row = indices[0];
        // Can only free the treepath After getting what I need from
        // indices since this points into treepath somewhere.
        gtk_tree_path_free (treepath);
        if (row < 0) return;
        if (row >= ghb_array_len(ud->queue))
            return;
        settings = ghb_array_get_nth(ud->queue, row);
        status = ghb_settings_get_int(settings, "job_status");
        if (status == GHB_QUEUE_RUNNING)
        {
            // Ask if wants to stop encode.
            if (!ghb_cancel_encode2(ud, NULL))
            {
                return;
            }
            unique_id = ghb_settings_get_int(settings, "job_unique_id");
            ghb_remove_job(unique_id);
        }
        // Remove the selected item
        gtk_tree_store_remove(GTK_TREE_STORE(store), &iter);
        // Remove the corresponding item from the queue list
        GValue *old = ghb_array_get_nth(ud->queue, row);
        ghb_value_free(old);
        ghb_array_remove(ud->queue, row);
        ghb_save_queue(ud->queue);
    }
    else
    {   
        gtk_tree_path_free (treepath);
    }
    ghb_update_pending(ud);
}
Example #7
0
void
dsn_config_delete (GtkWidget *dsn)
{
	DsnConfigPrivate *priv;
	GtkTreeSelection *sel;
	GList *list, *sel_rows;
	GList *sel_dsn = NULL;
	GdaDataModel *model;

	priv = g_object_get_data (G_OBJECT (dsn), DSN_CONFIG_DATA);

	sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->dsn_list));
	sel_rows = gtk_tree_selection_get_selected_rows (sel, NULL);
	model = gdaui_data_selector_get_model (GDAUI_DATA_SELECTOR (priv->dsn_list));
	g_assert (GDA_IS_DATA_MODEL (model));

	/* make a list of DSN to remove */
	for (list = sel_rows; list; list = list->next) {
		gchar *dsn;
		gint *row;
		const GValue *cvalue;
		
		row = gtk_tree_path_get_indices ((GtkTreePath *) list->data);
		cvalue = gda_data_model_get_value_at (model, 0, *row, NULL);
		if (cvalue) {
			dsn = gda_value_stringify ((GValue *) cvalue);
			sel_dsn = g_list_prepend (sel_dsn, dsn);
		}
		gtk_tree_path_free ((GtkTreePath *) list->data);
	}
	g_list_free (sel_rows);

	/* actually remove the DSN listed */
	for (list = sel_dsn; list; list = list->next) {
		gchar *str, *dsn;
		GtkWidget *dialog;
		dsn = (gchar *) list->data;

		str = g_strdup_printf (_("Are you sure you want to remove the data source '%s'?"), dsn);
		dialog = gtk_message_dialog_new_with_markup (GTK_WINDOW (gtk_widget_get_toplevel (priv->dsn_list)),
							     GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION,
							     GTK_BUTTONS_YES_NO, 
							     "<b>%s:</b>\n\n%s",
							     _("Data source removal confirmation"), str);
		g_free (str);
		gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_NO);
		gtk_widget_show (dialog);
		
		if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_YES) 
			gda_config_remove_dsn (dsn, NULL);
		gtk_widget_destroy (dialog);
		
		g_free (dsn);
	}
}
void 
gw_settingswindow_remove_dictionary_cb (GSimpleAction *action, 
                                        GVariant      *parameter,
                                        gpointer       data)
{
    //Declarations
    GwSettingsWindow *window;
    GwSettingsWindowPrivate *priv;
    GwApplication *application;
    GwDictionaryList *dictionarylist;

    GtkTreePath *path;
    GtkTreeIter iter;
    LwDictionary *dictionary;
    GError *error;
    GtkTreeSelection *selection;
    GtkTreeModel *model;
    gboolean has_selection;
    gint* indices;
    GtkTreeView *view;

    //Initializations
    window = GW_SETTINGSWINDOW (data);
    priv = window->priv;
    application = gw_window_get_application (GW_WINDOW (window));
    dictionarylist = gw_application_get_installed_dictionarylist (application);
    view = priv->manage_dictionaries_treeview;
    selection = gtk_tree_view_get_selection (view);
    model = GTK_TREE_MODEL (gw_dictionarylist_get_liststore (dictionarylist));
    has_selection = gtk_tree_selection_get_selected (selection, &model, &iter);
    error = NULL;

    //Sanity check
    if (!has_selection) return;

    path = gtk_tree_model_get_path (model, &iter);
    indices = gtk_tree_path_get_indices (path);
    dictionary = lw_dictionarylist_remove_by_position (LW_DICTIONARYLIST (dictionarylist), *indices);

    if (dictionary != NULL)
    {
      lw_dictionary_uninstall (dictionary, NULL, &error);
    }

    //Cleanup
    gtk_tree_path_free (path); path = NULL;

    if (error != NULL)
    {
      gw_application_handle_error (application, GTK_WINDOW (window), TRUE, &error);
      exit(EXIT_SUCCESS);
    }

    gw_settingswindow_check_for_dictionaries (window);
}
static gboolean is_separator (GtkTreeModel *model, GtkTreeIter *iter, gpointer sep_index)
{
    GtkTreePath *path;
    gboolean result;

    path = gtk_tree_model_get_path (model, iter);
    result = gtk_tree_path_get_indices (path)[0] == GPOINTER_TO_INT (sep_index);
    gtk_tree_path_free (path);

    return result;
}
Example #10
0
/* 
 * shows arrow icon for the current frame, hides renderer for a thread row
 */
static void on_render_icon(GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *tree_model,
	GtkTreeIter *iter, gpointer data)
{
	GtkTreePath *tpath = gtk_tree_model_get_path(model, iter);
	gboolean frame_row = 1 != gtk_tree_path_get_depth(tpath);

	g_object_set(cell, "visible", frame_row, NULL);
	g_object_set(cell, "pixbuf", (frame_row && 0 == gtk_tree_path_get_indices(tpath)[1]) ? (gpointer)frame_current_pixbuf : NULL, NULL);

	gtk_tree_path_free(tpath);
}
Example #11
0
int wxListBox::GTKGetIndexFor(GtkTreeIter& iter) const
{
    wxGtkTreePath path(
        gtk_tree_model_get_path(GTK_TREE_MODEL(m_liststore), &iter));

    gint* pIntPath = gtk_tree_path_get_indices(path);

    wxCHECK_MSG( pIntPath, wxNOT_FOUND, wxT("failed to get iterator path") );

    return pIntPath[0];
}
Example #12
0
static void gtkListRowActivated(GtkTreeView *tree_view, GtkTreePath *path, GtkTreeViewColumn *column, Ihandle* ih)
{
  IFnis cb = (IFnis) IupGetCallback(ih, "DBLCLICK_CB");
  if (cb)
  {
    int* indices = gtk_tree_path_get_indices(path);
    iupListSingleCallDblClickCallback(ih, cb, indices[0]+1);  /* IUP starts at 1 */
  }
  (void)column;
  (void)tree_view;
}
static void
set_context_data (GdkDragContext *context,
		  GList          *path_list)
{
	g_object_set_data_full (G_OBJECT (context),
				"rb-tree-view-multi-source-row",
				path_list,
				(GDestroyNotify) path_list_free);

	rb_debug ("Setting path_list: index=%i", gtk_tree_path_get_indices(path_list->data)[0]);
}
Example #14
0
// triggered when the user selects an entry in the feedback box
static void feedback_selection_changed( GtkTreeSelection* selection, gpointer data ){
	g_DbgDlg.DropHighlight();

	GtkTreeModel* model;
	GtkTreeIter selected;
	if ( gtk_tree_selection_get_selected( selection, &model, &selected ) ) {
		GtkTreePath* path = gtk_tree_model_get_path( model, &selected );
		g_DbgDlg.SetHighlight( gtk_tree_path_get_indices( path )[0] );
		gtk_tree_path_free( path );
	}
}
Example #15
0
static void
gimp_path_editor_selection_changed (GtkTreeSelection *sel,
                                    GimpPathEditor   *editor)
{
  GtkTreeIter  iter;
  gchar       *directory;
  gint        *indices;

  if (gtk_tree_selection_get_selected (sel, NULL, &iter))
    {
      gtk_tree_model_get (GTK_TREE_MODEL (editor->dir_list), &iter,
                          0, &directory,
                          -1);

      g_signal_handlers_block_by_func (editor->file_entry,
                                       gimp_path_editor_file_entry_changed,
                                       editor);

      gimp_file_entry_set_filename (GIMP_FILE_ENTRY (editor->file_entry),
                                    directory);

      g_signal_handlers_unblock_by_func (editor->file_entry,
                                         gimp_path_editor_file_entry_changed,
                                         editor);

      g_free (directory);

      if (editor->sel_path)
        gtk_tree_path_free (editor->sel_path);

      editor->sel_path =
        gtk_tree_model_get_path (GTK_TREE_MODEL (editor->dir_list), &iter);

      indices = gtk_tree_path_get_indices (editor->sel_path);

      gtk_widget_set_sensitive (editor->delete_button, TRUE);
      gtk_widget_set_sensitive (editor->up_button, (indices[0] > 0));
      gtk_widget_set_sensitive (editor->down_button,
                                (indices[0] < (editor->num_items - 1)));
      gtk_widget_set_sensitive (editor->file_entry, TRUE);
    }
  else
    {
      g_signal_handlers_block_by_func (sel,
                                       gimp_path_editor_selection_changed,
                                       editor);

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

      g_signal_handlers_unblock_by_func (sel,
                                         gimp_path_editor_selection_changed,
                                         editor);
    }
}
Example #16
0
static void
gtk_icon_view_accessible_model_row_deleted (GtkTreeModel *tree_model,
                                            GtkTreePath  *path,
                                            gpointer     user_data)
{
  GtkIconViewItemAccessibleInfo *info;
  GtkIconViewAccessible *view;
  GtkIconViewItemAccessible *item;
  GList *items;
  GList *tmp_list;
  GList *deleted_item;
  AtkObject *atk_obj;
  gint index;

  index = gtk_tree_path_get_indices(path)[0];
  atk_obj = gtk_widget_get_accessible (GTK_WIDGET (user_data));
  view = GTK_ICON_VIEW_ACCESSIBLE (atk_obj);

  items = view->items;
  tmp_list = NULL;
  deleted_item = NULL;
  info = NULL;
  while (items)
    {
      info = items->data;
      item = GTK_ICON_VIEW_ITEM_ACCESSIBLE (info->item);
      if (info->index == index)
        {
          deleted_item = items;
        }
      if (info->index != item->item->index)
        {
          if (tmp_list == NULL)
            tmp_list = items;

          info->index = item->item->index;
        }

      items = items->next;
    }
  gtk_icon_view_accessible_traverse_items (view, tmp_list);
  if (deleted_item)
    {
      info = deleted_item->data;
      gtk_icon_view_item_accessible_add_state (GTK_ICON_VIEW_ITEM_ACCESSIBLE (info->item), ATK_STATE_DEFUNCT, TRUE);
      g_signal_emit_by_name (atk_obj, "children-changed::remove",
                             index, NULL, NULL);
      view->items = g_list_remove_link (view->items, deleted_item);
      g_free (info);
    }

  return;
}
Example #17
0
static GtkTreePath *fm_dir_tree_model_get_path (GtkTreeModel *tree_model, GtkTreeIter *iter)
{
    GList *item_list;
    GList *children;
    FmDirTreeItem *dir_tree_item;
    GtkTreePath *path;
    int i;
    FmDirTreeModel *dir_tree_model = FM_DIR_TREE_MODEL (tree_model);

    g_return_val_if_fail (dir_tree_model, NULL);
    g_return_val_if_fail (iter->stamp == dir_tree_model->stamp, NULL);
    g_return_val_if_fail (iter != NULL, NULL);
    g_return_val_if_fail (iter->user_data != NULL, NULL);

    item_list = (GList*)iter->user_data;
    dir_tree_item = (FmDirTreeItem*)item_list->data;

    // Root Item... 
    if (dir_tree_item->parent == NULL)
    {
        i = g_list_position (dir_tree_model->root_list, item_list);
        path = gtk_tree_path_new_first ();
        gtk_tree_path_get_indices (path)[0] = i;
    }
    else
    {
        path = gtk_tree_path_new ();
        do
        {
            FmDirTreeItem *parent_item = (FmDirTreeItem*)dir_tree_item->parent->data;
            children = parent_item->children;
            i = g_list_position (children, item_list);
            if (G_UNLIKELY (i == -1))
            {
                gtk_tree_path_free (path);
                return NULL;
            }
            
            gtk_tree_path_prepend_index (path, i);
            
            // Go One Level Up...
            item_list = dir_tree_item->parent;
            dir_tree_item = (FmDirTreeItem*)item_list->data;
        
        } while (G_UNLIKELY (dir_tree_item->parent));

        // We Have Reached Toplevel...
        children = dir_tree_model->root_list;
        i = g_list_position (children, item_list);
        gtk_tree_path_prepend_index (path, i);
    }
    return path;
}
Example #18
0
File: dismodel.c Project: bpeel/eek
static void
dis_model_refresh_rows (DisModel *model)
{
  int row_num, got_bytes = 0;
  DisModelRowData row;
  guint16 address = model->address;
  GtkTreePath *path;
  GtkTreeIter iter;

  path = gtk_tree_path_new_first ();

  for (row_num = 0; row_num < DIS_MODEL_ROW_COUNT; row_num++)
  {
    if (model->electron == NULL)
    {
      row.address = 0;
      row.num_bytes = 0;
      row.mnemonic[0] = '\0';
      row.operands[0] = '\0';
      row.current = FALSE;
    }
    else
    {
      while (got_bytes < DISASSEMBLE_MAX_BYTES)
      {
        row.bytes[got_bytes] = electron_read_from_location (model->electron->data,
                                                            address + got_bytes);
        got_bytes++;
      }
      row.address = address;
      row.num_bytes = disassemble_instruction (address, row.bytes, row.mnemonic, row.operands);
      row.current = model->electron->data->cpu.pc == address ? TRUE : FALSE;
    }

    /* Only fire the changed signal if the row is actually different */
    if (row.address != model->rows[row_num].address
        || row.num_bytes != model->rows[row_num].num_bytes
        || memcmp (row.bytes, model->rows[row_num].bytes, row.num_bytes)
        || row.current != model->rows[row_num].current)
    {
      model->rows[row_num] = row;
      gtk_tree_path_get_indices (path)[0] = row_num;
      iter.user_data = GINT_TO_POINTER (row_num);
      iter.stamp = model->iter_stamp;
      gtk_tree_model_row_changed (GTK_TREE_MODEL (model), path, &iter);
    }

    memmove (row.bytes, row.bytes + row.num_bytes, got_bytes = DISASSEMBLE_MAX_BYTES - row.num_bytes);
    address += row.num_bytes;
  }

  gtk_tree_path_free (path);
}
Example #19
0
static void on_cursor_changed (GtkTreeView* view, UgtkSettingDialog* sdialog)
{
	GtkTreePath*   path;
	int            nth;

	gtk_tree_view_get_cursor (view, &path, NULL);
	if (path == NULL)
		return;
	nth = *gtk_tree_path_get_indices (path);
	gtk_tree_path_free (path);
	gtk_notebook_set_current_page (sdialog->notebook, nth);
}
static gboolean search_cb (GtkTreeModel * model, gint column, const gchar * key,
 GtkTreeIter * iter, void * user)
{
    GtkTreePath * path = gtk_tree_model_get_path (model, iter);
    g_return_val_if_fail (path, TRUE);
    gint row = gtk_tree_path_get_indices (path)[0];
    g_return_val_if_fail (row >= 0, TRUE);
    gchar * s[3] = {NULL, NULL, NULL};
    aud_playlist_entry_describe (((PlaylistWidgetData *) user)->list, row,
     & s[0], & s[1], & s[2], FALSE);
    gtk_tree_path_free (path);

    gchar * temp = g_utf8_strdown (key, -1);
    gchar * * keys = g_strsplit (temp, " ", 0);
    g_free (temp);

    gint remain = 0; /* number of keys remaining to be matched */
    for (gint j = 0; keys[j]; j ++)
    {
        if (keys[j][0])
            remain ++;
    }
    if (! remain)
        remain ++; /* force non-match if there are no non-blank keys */

    for (gint i = 0; i < G_N_ELEMENTS (s); i ++)
    {
        if (! s[i])
            continue;

        if (remain)
        {
            temp = g_utf8_strdown (s[i], -1);

            for (gint j = 0; keys[j] && remain; j ++)
            {
                if (keys[j][0] && strstr (temp, keys[j]))
                {
                    keys[j][0] = 0; /* don't look for this one again */
                    remain --;
                }
            }

            g_free (temp);
        }

        str_unref (s[i]);
    }

    g_strfreev (keys);
    return remain ? TRUE : FALSE; /* TRUE == not matched, FALSE == matched */
}
JNIEXPORT jintArray JNICALL
Java_gnu_java_awt_peer_gtk_GtkListPeer_getSelectedIndexes
  (JNIEnv *env, jobject obj)
{
  void *ptr;
  GtkWidget *list;
  GtkTreeSelection *selection;
  jintArray result_array;
  jint *result_array_iter;
  GList *current_row;
  GList *rows;
  gint *indices;
  jint count;
  jint i;

  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));
  count = gtk_tree_selection_count_selected_rows (selection);
  if (count > 0)
    {
      current_row = rows = gtk_tree_selection_get_selected_rows (selection, NULL);

      result_array = (*env)->NewIntArray (env, count);

      result_array_iter = (*env)->GetIntArrayElements (env, result_array, NULL);

      for (i = 0; i < count; i++)
        {
          indices = gtk_tree_path_get_indices (current_row->data);
          result_array_iter[i] = indices ? indices[0] : -1;
          current_row = g_list_next (current_row);
        }

      if (rows)
        {
          g_list_foreach (rows, (GFunc) gtk_tree_path_free, NULL);
          g_list_free (rows);
        }

      (*env)->ReleaseIntArrayElements (env, result_array, result_array_iter, 0);
    }
  else
    result_array = NULL;

  gdk_threads_leave ();

  return result_array;
}
Example #22
0
File: gchan.cpp Project: dyne/MuSE
void gcb_play_channel(GtkWidget *w, struct gchan *o)
{
	guint res;
	
	GtkTreeSelection *select;
	GtkTreeModel *model;
	gint index=0;
	GList *pathlist=NULL;
	
	if( mixer->chan[o->idx-1]->on) {
	  gtk_toggle_button_set_active
	    (GTK_TOGGLE_BUTTON(o->play), FALSE);
	  return;
	}
	select = gtk_tree_view_get_selection(GTK_TREE_VIEW(o->tree));
	if( !(pathlist = gtk_tree_selection_get_selected_rows(select, &model)) )
		return;
	index = gtk_tree_path_get_indices((GtkTreePath *)pathlist->data)[0];
	
	func(_("selected index = %d"), index);
	gtk_tree_path_free((GtkTreePath *)pathlist->data);
	mixer->set_channel(o->idx-1, index+1);
	res = mixer->play_channel(o->idx-1);

	switch(res) {
	case 0:
	  o->channel=0;
	  break;
	case 1:  /* channel is seekable */
	  gtk_entry_set_text(GTK_ENTRY(o->ptime), "00:00:00");
	  gtk_adjustment_set_value(GTK_ADJUSTMENT(o->adjprog), 0.0);
	  o->channel=1;
	  break;
	case 2: /* unseekable */
	  gtk_entry_set_text(GTK_ENTRY(o->ptime), "-stream-");
	  gtk_adjustment_set_value(GTK_ADJUSTMENT(o->adjprog), 0.0);
	  o->channel=2;
	  break;
	}
	
	if(res==0) {
	  func(_("KO for playing :("));
	  gtk_toggle_button_set_mode
	    (GTK_TOGGLE_BUTTON(o->play), FALSE);
	} else {
	  func(_("ok for playing"));
	  gtk_toggle_button_set_mode
	    (GTK_TOGGLE_BUTTON(o->play), TRUE);
	}
		

}
Example #23
0
static void
test_position (GtkTreeView *tree_view,
	       GtkTreePath *path,
	       gboolean     use_align,
	       gdouble      row_align)
{
	gint pos;
	gchar *path_str;
	GdkRectangle rect;
	GtkTreeModel *model;
	gint row_start;

	/* Get the location of the path we scrolled to */
	gtk_tree_view_get_background_area (GTK_TREE_VIEW (tree_view),
					   path, NULL, &rect);

	row_start = get_row_start_for_index (GTK_TREE_VIEW (tree_view),
					     gtk_tree_path_get_indices (path)[0]);

	/* Ugh */
	pos = get_pos_from_path (GTK_TREE_VIEW (tree_view),
				 path, rect.height,
			         gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (tree_view)));

	/* This is only tested for during test_single() */
	model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view));
	if (gtk_tree_model_iter_n_children (model, NULL) == 1) {
                GtkAllocation allocation;
		GtkTreePath *tmppath;

		/* Test nothing is dangling at the bottom; read
		 * description for test_single() for more information.
		 */

		/* FIXME: hardcoded width */
                gtk_widget_get_allocation (GTK_WIDGET (tree_view), &allocation);
		if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (tree_view), 0, allocation.height - 30, &tmppath, NULL, NULL, NULL)) {
			g_assert_not_reached ();
			gtk_tree_path_free (tmppath);
		}
	}

	path_str = gtk_tree_path_to_string (path);
	if (use_align) {
		assert_position_with_align (tree_view, pos, rect.y,
                                            row_start, rect.height, row_align);
	} else {
		assert_position_without_align (tree_view, row_start, rect.height);
	}

	g_free (path_str);
}
Example #24
0
PyObject *
pygtk_tree_path_to_pyobject(GtkTreePath *path)
{
    gint len, i, *indices;
    PyObject *ret;

    len = gtk_tree_path_get_depth(path);
    indices = gtk_tree_path_get_indices(path);
    ret = PyTuple_New(len);
    for (i = 0; i < len; i++)
	PyTuple_SetItem(ret, i, PyInt_FromLong(indices[i]));
    return ret;
}
Example #25
0
void iupdrvListConvertXYToItem(Ihandle* ih, int x, int y, int *pos)
{
  if (!ih->data->is_dropdown)
  {
    GtkTreePath* path;
    if (gtk_tree_view_get_dest_row_at_pos((GtkTreeView*)ih->handle, x, y, &path, NULL))
    {
      int* indices = gtk_tree_path_get_indices(path);
      *pos = indices[0]+1;  /* IUP starts at 1 */
      gtk_tree_path_free (path);
    }
  }
}
Example #26
0
static void remove_row(GtkTreeRowReference *ref, GtkTreeModel *model) {
  GtkTreeIter iter;
  GtkTreePath *path;
  int *i;

  path = gtk_tree_row_reference_get_path(ref);
  gtk_tree_model_get_iter(model, &iter, path);

  i = gtk_tree_path_get_indices(path);
  list_delete_entry(i[0]);

  gtk_list_store_remove(GTK_LIST_STORE(model), &iter);
}
Example #27
0
static void rc_gui_list2_row_activated(GtkTreeView *list, GtkTreePath *path, 
    GtkTreeViewColumn *column, gpointer data)
{
    gint *indices = NULL;
    gint list1_index, list2_index;
    if(path==NULL) return;
    list1_index = rc_gui_list1_get_selected_index();
    if(list1_index==-1) return;
    indices = gtk_tree_path_get_indices(path);
    list2_index = indices[0];
    rc_plist_play_by_index(list1_index, list2_index);
    rc_core_play();
}
Example #28
0
gboolean on_dnd_dest_files_dropped(FmDndDest* dd, GdkDragAction action,
                               int info_type, FmFileInfoList* files, FmPlacesView* view)
{
    FmPath* dest;
    GList* l;
    gboolean ret = FALSE;

    dest = fm_dnd_dest_get_dest_path(dd);
    /* g_debug("action= %d, %d files-dropped!, info_type: %d", action, fm_list_get_length(files), info_type); */

    if(!dest && action == GDK_ACTION_LINK) /* add bookmarks */
    {
        GtkTreePath* tp = view->dest_row;
        if(tp)
        {
            const GtkTreePath* sep = fm_places_model_get_separator_path(FM_PLACES_MODEL(model));
            int idx = gtk_tree_path_get_indices(tp)[0] - gtk_tree_path_get_indices(sep)[0];

            if(view->dest_pos == GTK_TREE_VIEW_DROP_BEFORE)
                --idx;
            for( l=fm_list_peek_head_link(files); l; l=l->next, ++idx )
            {
                FmBookmarkItem* item;
                FmFileInfo* fi = FM_FILE_INFO(l->data);
                if(fm_file_info_is_dir(fi))
                    item = fm_bookmarks_insert( FM_PLACES_MODEL(model)->bookmarks, fi->path, fi->disp_name, idx);
                /* we don't need to add item to places view. Later the bookmarks will be reloaded. */
            }
        }
        ret = TRUE;
    }

    if(view->dest_row)
    {
        gtk_tree_path_free(view->dest_row);
        view->dest_row = NULL;
    }
    return ret;
}
static void
on_row_deleted (GtkListStore *store,
		GtkTreePath *path,
		gpointer user_data)
{
	gint *indices, row;

	indices = gtk_tree_path_get_indices (path);
	row = indices[0];

	g_signal_handler_block (bookmarks, bookmark_list_changed_signal_id);
	nautilus_bookmark_list_delete_item_at (bookmarks, row);
	g_signal_handler_unblock (bookmarks, bookmark_list_changed_signal_id);
}
Example #30
0
/* A GtkTreeViewRowSeparatorFunc that demonstrates how rows can be
 * rendered as separators. This particular function does nothing 
 * useful and just turns the fourth row into a separator.
 */
static gboolean
is_separator (GtkTreeModel *model,
	      GtkTreeIter  *iter,
	      gpointer      data)
{
  GtkTreePath *path;
  gboolean result;

  path = gtk_tree_model_get_path (model, iter);
  result = gtk_tree_path_get_indices (path)[0] == 4;
  gtk_tree_path_free (path);

  return result;
}