2003-01-03 13:26:04 +00:00
|
|
|
/*
|
|
|
|
* tree.c
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 Sun Microsystems, Inc.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
COPYING, src/about.c, src/calendar.c, src/eggtrayicon.c, src/entry.c,
2005-04-25 Glynn Foster <glynn.foster@sun.com>
* COPYING, src/about.c, src/calendar.c, src/eggtrayicon.c,
* src/entry.c, src/fileselection.c, src/main.c, src/msg.c,
* src/notification.c, src/option.c, src/progress.c,
* src/text.c, src/tree.c, src/util.c: Update the FSF address
to point to 51 Franklin Street, Fifth Floor as per forwarded
mail from Alvaro Lopez Ortega.
2005-04-25 03:20:45 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2003-01-03 13:26:04 +00:00
|
|
|
*
|
|
|
|
* Authors: Glynn Foster <glynn.foster@sun.com>
|
|
|
|
* Jonathan Blanford <jrb@redhat.com>
|
|
|
|
* Kristian Rietveld <kris@gtk.org>
|
|
|
|
*/
|
|
|
|
|
2005-07-06 20:13:11 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
2003-01-28 14:58:30 +00:00
|
|
|
#include <string.h>
|
2004-09-17 08:57:21 +00:00
|
|
|
#include <stdlib.h>
|
2003-01-03 13:26:04 +00:00
|
|
|
#include "zenity.h"
|
|
|
|
#include "util.h"
|
|
|
|
|
2003-05-06 20:22:16 +00:00
|
|
|
#define MAX_ELEMENTS_BEFORE_SCROLLING 5
|
2005-06-28 11:11:50 +00:00
|
|
|
#define PRINT_HIDE_COLUMN_SEPARATOR ","
|
2003-01-03 13:26:04 +00:00
|
|
|
|
2009-07-20 08:23:32 +00:00
|
|
|
static GtkBuilder *builder;
|
2003-01-14 01:52:23 +00:00
|
|
|
static GSList *selected;
|
|
|
|
static gchar *separator;
|
2004-07-19 01:01:28 +00:00
|
|
|
static gboolean print_all_columns = FALSE;
|
2005-06-30 23:43:23 +00:00
|
|
|
static gint *print_columns = NULL;
|
2005-07-01 21:28:36 +00:00
|
|
|
static gint *hide_columns = NULL;
|
2011-07-26 13:08:31 +00:00
|
|
|
static GIOChannel *channel;
|
2003-01-03 13:26:04 +00:00
|
|
|
|
2005-06-30 23:43:23 +00:00
|
|
|
static int *zenity_tree_extract_column_indexes (char *indexes, gint n_columns);
|
2005-07-01 21:28:36 +00:00
|
|
|
static gboolean zenity_tree_column_is_hidden (gint column_index);
|
Fix up the response signal handlers. Use returns of 0 for 'Ok' and
2003-01-07 Glynn Foster <glynn.foster@sun.com>
* src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c,
src/tree.c, src/zenity.glade, src/zenity.h: Fix up
the response signal handlers. Use returns of 0 for
'Ok' and 'Close', 1 for 'Cancel' and 'Escape' and
-1 for 'Uh Oh'. Get stuff printing to stderr. Fix up
the error handling that I thought was improved,
although still have issues with popt callback getting
called numerous times because of more than one instance
of the same kind is being used in poptOption.
* TODO: Update accordingly.
2003-01-07 13:22:57 +00:00
|
|
|
static void zenity_tree_dialog_response (GtkWidget *widget, int response, gpointer data);
|
2005-06-27 04:27:15 +00:00
|
|
|
static void zenity_tree_row_activated (GtkTreeView *tree_view, GtkTreePath *tree_path,
|
|
|
|
GtkTreeViewColumn *tree_col, gpointer data);
|
2003-01-03 13:26:04 +00:00
|
|
|
|
2003-04-13 15:42:41 +00:00
|
|
|
static gboolean
|
|
|
|
zenity_tree_dialog_untoggle (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
|
|
|
|
{
|
|
|
|
GValue toggle_value = {0, };
|
|
|
|
|
|
|
|
gtk_tree_model_get_value (model, iter, 0, &toggle_value);
|
|
|
|
|
|
|
|
if (g_value_get_boolean (&toggle_value))
|
|
|
|
gtk_list_store_set (GTK_LIST_STORE (model), iter, 0, FALSE, -1);
|
2003-06-04 12:53:46 +00:00
|
|
|
return FALSE;
|
2003-04-13 15:42:41 +00:00
|
|
|
}
|
|
|
|
|
2003-01-03 13:26:04 +00:00
|
|
|
static void
|
|
|
|
zenity_tree_toggled_callback (GtkCellRendererToggle *cell, gchar *path_string, gpointer data)
|
|
|
|
{
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
GtkTreeModel *model;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreePath *path;
|
|
|
|
gboolean value;
|
2003-01-03 13:26:04 +00:00
|
|
|
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
model = GTK_TREE_MODEL (data);
|
2003-01-03 13:26:04 +00:00
|
|
|
|
2003-04-13 15:42:41 +00:00
|
|
|
/* Because this is a radio list, we should untoggle the previous toggle so that
|
|
|
|
* we only have one selection at any given time
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (GPOINTER_TO_INT (g_object_get_data (G_OBJECT (model), "radio")) == 1) {
|
|
|
|
gtk_tree_model_foreach (model, zenity_tree_dialog_untoggle, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
path = gtk_tree_path_new_from_string (path_string);
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
gtk_tree_model_get_iter (model, &iter, path);
|
|
|
|
gtk_tree_model_get (model, &iter, 0, &value, -1);
|
2003-01-03 13:26:04 +00:00
|
|
|
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
value = !value;
|
|
|
|
gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, value, -1);
|
2003-01-03 13:26:04 +00:00
|
|
|
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
gtk_tree_path_free (path);
|
2003-01-03 13:26:04 +00:00
|
|
|
}
|
|
|
|
|
2012-07-19 17:22:25 +00:00
|
|
|
static void
|
|
|
|
zenity_load_pixbuf (GtkTreeViewColumn *tree_column,
|
|
|
|
GtkCellRenderer *cell,
|
|
|
|
GtkTreeModel *tree_model,
|
|
|
|
GtkTreeIter *iter,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
static GHashTable *pixbuf_cache = NULL;
|
|
|
|
GError *error = NULL;
|
|
|
|
GdkPixbuf *pixbuf;
|
|
|
|
gchar *str;
|
|
|
|
|
|
|
|
gtk_tree_model_get (tree_model, iter, 0, &str, -1);
|
|
|
|
|
|
|
|
if (!str)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!pixbuf_cache) {
|
|
|
|
pixbuf_cache = g_hash_table_new (g_str_hash, g_str_equal);
|
|
|
|
g_assert(pixbuf_cache);
|
|
|
|
}
|
|
|
|
|
|
|
|
pixbuf = g_hash_table_lookup (pixbuf_cache, str);
|
|
|
|
|
|
|
|
if (!pixbuf) {
|
|
|
|
pixbuf = gdk_pixbuf_new_from_file (str, &error);
|
|
|
|
if (!pixbuf)
|
|
|
|
g_warning ("Failed to load '%s'", str);
|
|
|
|
|
|
|
|
g_hash_table_insert (pixbuf_cache, g_strdup (str), pixbuf);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pixbuf)
|
|
|
|
g_object_set (cell, "pixbuf", pixbuf, NULL);
|
|
|
|
|
|
|
|
g_free (str);
|
|
|
|
}
|
|
|
|
|
2003-05-05 17:17:02 +00:00
|
|
|
static gboolean
|
|
|
|
zenity_tree_handle_stdin (GIOChannel *channel,
|
|
|
|
GIOCondition condition,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
static GtkTreeView *tree_view;
|
|
|
|
GtkTreeModel *model;
|
2007-05-27 21:20:39 +00:00
|
|
|
static GtkTreeIter iter;
|
2003-05-05 17:17:02 +00:00
|
|
|
static gint column_count = 0;
|
|
|
|
static gint row_count = 0;
|
|
|
|
static gint n_columns;
|
|
|
|
static gboolean editable;
|
|
|
|
static gboolean toggles;
|
2007-05-27 21:20:39 +00:00
|
|
|
static gboolean first_time = TRUE;
|
2003-05-05 17:17:02 +00:00
|
|
|
|
|
|
|
tree_view = GTK_TREE_VIEW (data);
|
|
|
|
n_columns = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tree_view), "n_columns"));
|
|
|
|
editable = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tree_view), "editable"));
|
|
|
|
toggles = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tree_view), "toggles"));
|
|
|
|
|
|
|
|
model = gtk_tree_view_get_model (tree_view);
|
|
|
|
|
2007-05-27 21:20:39 +00:00
|
|
|
if (first_time) {
|
|
|
|
first_time = FALSE;
|
2003-05-06 20:22:16 +00:00
|
|
|
gtk_list_store_append (GTK_LIST_STORE (model), &iter);
|
|
|
|
}
|
|
|
|
|
2003-05-05 17:17:02 +00:00
|
|
|
if ((condition == G_IO_IN) || (condition == G_IO_IN + G_IO_HUP)) {
|
|
|
|
GString *string;
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
string = g_string_new (NULL);
|
|
|
|
|
2012-05-08 20:14:58 +00:00
|
|
|
while ((g_io_channel_get_flags(channel) & G_IO_FLAG_IS_READABLE) != G_IO_FLAG_IS_READABLE)
|
2003-05-05 17:17:02 +00:00
|
|
|
;
|
|
|
|
do {
|
|
|
|
gint status;
|
|
|
|
|
|
|
|
do {
|
2012-05-08 20:14:58 +00:00
|
|
|
if (g_io_channel_get_flags(channel) & G_IO_FLAG_IS_READABLE)
|
2011-07-26 13:08:31 +00:00
|
|
|
status = g_io_channel_read_line_string (channel, string, NULL, &error);
|
|
|
|
else
|
|
|
|
return FALSE;
|
2003-05-05 17:17:02 +00:00
|
|
|
|
|
|
|
while (gtk_events_pending ())
|
|
|
|
gtk_main_iteration ();
|
|
|
|
|
2011-07-08 14:57:18 +00:00
|
|
|
// TODO: Find a better way to avoid 100% cpu utilization
|
|
|
|
g_usleep(10000);
|
|
|
|
|
2003-05-05 17:17:02 +00:00
|
|
|
} while (status == G_IO_STATUS_AGAIN);
|
|
|
|
|
|
|
|
if (status != G_IO_STATUS_NORMAL) {
|
|
|
|
if (error) {
|
|
|
|
g_warning ("zenity_tree_handle_stdin () : %s", error->message);
|
|
|
|
g_error_free (error);
|
|
|
|
error = NULL;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (column_count == n_columns) {
|
|
|
|
/* We're starting a new row */
|
|
|
|
column_count = 0;
|
|
|
|
row_count++;
|
|
|
|
gtk_list_store_append (GTK_LIST_STORE (model), &iter);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (toggles && column_count == 0) {
|
2009-01-09 00:14:01 +00:00
|
|
|
if (strcmp (g_ascii_strdown (zenity_util_strip_newline (string->str), -1), "true") == 0)
|
2003-05-05 17:17:02 +00:00
|
|
|
gtk_list_store_set (GTK_LIST_STORE (model), &iter, column_count, TRUE, -1);
|
2005-06-28 11:11:50 +00:00
|
|
|
else
|
2003-05-05 17:17:02 +00:00
|
|
|
gtk_list_store_set (GTK_LIST_STORE (model), &iter, column_count, FALSE, -1);
|
|
|
|
}
|
|
|
|
else {
|
2005-06-28 11:11:50 +00:00
|
|
|
gtk_list_store_set (GTK_LIST_STORE (model), &iter, column_count, zenity_util_strip_newline (string->str), -1);
|
2003-05-05 17:17:02 +00:00
|
|
|
}
|
|
|
|
|
2007-05-27 21:20:39 +00:00
|
|
|
if (editable) {
|
|
|
|
gtk_list_store_set (GTK_LIST_STORE (model), &iter, n_columns, TRUE, -1);
|
|
|
|
}
|
2003-05-05 17:17:02 +00:00
|
|
|
|
2007-05-27 21:20:39 +00:00
|
|
|
if (row_count == MAX_ELEMENTS_BEFORE_SCROLLING) {
|
|
|
|
GtkWidget *scrolled_window;
|
|
|
|
GtkRequisition rectangle;
|
2003-05-05 17:17:02 +00:00
|
|
|
|
2007-05-27 21:20:39 +00:00
|
|
|
gtk_widget_size_request (GTK_WIDGET (tree_view), &rectangle);
|
2009-07-20 08:23:32 +00:00
|
|
|
scrolled_window = GTK_WIDGET (gtk_builder_get_object (builder,
|
|
|
|
"zenity_tree_window"));
|
2007-05-27 21:20:39 +00:00
|
|
|
gtk_widget_set_size_request (scrolled_window, -1, rectangle.height);
|
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
|
|
|
|
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
|
|
|
}
|
2003-05-05 17:17:02 +00:00
|
|
|
|
2007-05-27 21:20:39 +00:00
|
|
|
column_count++;
|
2003-05-05 17:17:02 +00:00
|
|
|
|
|
|
|
} while (g_io_channel_get_buffer_condition (channel) == G_IO_IN);
|
|
|
|
g_string_free (string, TRUE);
|
|
|
|
}
|
|
|
|
|
2011-01-03 00:57:42 +00:00
|
|
|
if ((condition != G_IO_IN) && (condition != G_IO_IN + G_IO_HUP)) {
|
2003-05-05 17:17:02 +00:00
|
|
|
g_io_channel_shutdown (channel, TRUE, NULL);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
zenity_tree_fill_entries_from_stdin (GtkTreeView *tree_view,
|
|
|
|
gint n_columns,
|
|
|
|
gboolean toggles,
|
|
|
|
gboolean editable)
|
|
|
|
{
|
2006-07-26 23:17:04 +00:00
|
|
|
g_object_set_data (G_OBJECT (tree_view), "n_columns", GINT_TO_POINTER (n_columns));
|
|
|
|
g_object_set_data (G_OBJECT (tree_view), "toggles", GINT_TO_POINTER (toggles));
|
|
|
|
g_object_set_data (G_OBJECT (tree_view), "editable", GINT_TO_POINTER (editable));
|
2003-05-05 17:17:02 +00:00
|
|
|
|
|
|
|
channel = g_io_channel_unix_new (0);
|
|
|
|
g_io_channel_set_encoding (channel, NULL, NULL);
|
|
|
|
g_io_channel_set_flags (channel, G_IO_FLAG_NONBLOCK, NULL);
|
|
|
|
g_io_add_watch (channel, G_IO_IN | G_IO_HUP, zenity_tree_handle_stdin, tree_view);
|
|
|
|
}
|
|
|
|
|
2003-01-03 13:26:04 +00:00
|
|
|
static void
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
zenity_tree_fill_entries (GtkTreeView *tree_view,
|
|
|
|
const gchar **args,
|
|
|
|
gint n_columns,
|
|
|
|
gboolean toggles,
|
|
|
|
gboolean editable)
|
2003-01-03 13:26:04 +00:00
|
|
|
{
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
GtkTreeModel *model;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
gint i = 0;
|
2003-01-03 13:26:04 +00:00
|
|
|
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
model = gtk_tree_view_get_model (tree_view);
|
2003-01-06 21:58:21 +00:00
|
|
|
|
2006-07-26 23:17:04 +00:00
|
|
|
g_object_set_data (G_OBJECT (tree_view), "n_columns", GINT_TO_POINTER (n_columns));
|
2004-07-19 01:01:28 +00:00
|
|
|
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
while (args[i] != NULL) {
|
|
|
|
gint j;
|
2003-01-03 13:26:04 +00:00
|
|
|
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
gtk_list_store_append (GTK_LIST_STORE (model), &iter);
|
2003-01-06 15:06:17 +00:00
|
|
|
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
for (j = 0; j < n_columns; j++) {
|
2005-06-28 11:11:50 +00:00
|
|
|
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
if (toggles && j == 0) {
|
2009-01-09 00:14:01 +00:00
|
|
|
if (strcmp (g_ascii_strdown ((gchar *) args[i+j], -1), "true") == 0)
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
gtk_list_store_set (GTK_LIST_STORE (model), &iter, j, TRUE, -1);
|
2005-06-28 11:11:50 +00:00
|
|
|
else
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
gtk_list_store_set (GTK_LIST_STORE (model), &iter, j, FALSE, -1);
|
|
|
|
}
|
|
|
|
else
|
2005-06-28 11:11:50 +00:00
|
|
|
gtk_list_store_set (GTK_LIST_STORE (model), &iter, j, args[i+j], -1);
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (editable)
|
|
|
|
gtk_list_store_set (GTK_LIST_STORE (model), &iter, n_columns, TRUE, -1);
|
|
|
|
|
|
|
|
if (i == MAX_ELEMENTS_BEFORE_SCROLLING) {
|
|
|
|
GtkWidget *scrolled_window;
|
|
|
|
GtkRequisition rectangle;
|
|
|
|
|
2012-07-19 17:22:25 +00:00
|
|
|
gtk_widget_get_preferred_size (GTK_WIDGET (tree_view), &rectangle, NULL);
|
2009-07-20 08:23:32 +00:00
|
|
|
scrolled_window = GTK_WIDGET (gtk_builder_get_object (builder,
|
|
|
|
"zenity_tree_window"));
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
gtk_widget_set_size_request (scrolled_window, -1, rectangle.height);
|
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
|
2003-08-27 12:10:04 +00:00
|
|
|
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
}
|
|
|
|
|
2003-05-05 17:17:02 +00:00
|
|
|
i += n_columns;
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
}
|
2003-01-03 13:26:04 +00:00
|
|
|
}
|
|
|
|
|
2003-01-28 14:58:30 +00:00
|
|
|
static void
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
zenity_cell_edited_callback (GtkCellRendererText *cell,
|
|
|
|
const gchar *path_string,
|
|
|
|
const gchar *new_text,
|
|
|
|
gpointer data)
|
2003-01-28 14:58:30 +00:00
|
|
|
{
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
GtkTreeModel *model;
|
|
|
|
GtkTreePath *path;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
gint column;
|
2003-01-28 14:58:30 +00:00
|
|
|
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
model = GTK_TREE_MODEL (data);
|
|
|
|
path = gtk_tree_path_new_from_string (path_string);
|
2003-01-28 14:58:30 +00:00
|
|
|
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
column = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cell), "column"));
|
|
|
|
gtk_tree_model_get_iter (model, &iter, path);
|
|
|
|
|
|
|
|
gtk_list_store_set (GTK_LIST_STORE (model), &iter, column, new_text, -1);
|
2003-01-28 14:58:30 +00:00
|
|
|
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
gtk_tree_path_free (path);
|
2003-01-28 14:58:30 +00:00
|
|
|
}
|
|
|
|
|
Fix up the response signal handlers. Use returns of 0 for 'Ok' and
2003-01-07 Glynn Foster <glynn.foster@sun.com>
* src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c,
src/tree.c, src/zenity.glade, src/zenity.h: Fix up
the response signal handlers. Use returns of 0 for
'Ok' and 'Close', 1 for 'Cancel' and 'Escape' and
-1 for 'Uh Oh'. Get stuff printing to stderr. Fix up
the error handling that I thought was improved,
although still have issues with popt callback getting
called numerous times because of more than one instance
of the same kind is being used in poptOption.
* TODO: Update accordingly.
2003-01-07 13:22:57 +00:00
|
|
|
void
|
2003-01-03 13:26:04 +00:00
|
|
|
zenity_tree (ZenityData *data, ZenityTreeData *tree_data)
|
|
|
|
{
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
GtkWidget *dialog;
|
2011-07-26 17:00:28 +00:00
|
|
|
GtkWidget *button;
|
2009-07-20 08:23:32 +00:00
|
|
|
GObject *tree_view;
|
|
|
|
GObject *text;
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
GtkTreeViewColumn *column;
|
|
|
|
GtkListStore *model;
|
|
|
|
GType *column_types;
|
|
|
|
GSList *tmp;
|
|
|
|
gboolean first_column = FALSE;
|
|
|
|
gint i, column_index, n_columns;
|
|
|
|
|
2009-07-20 08:23:32 +00:00
|
|
|
builder = zenity_util_load_ui_file ("zenity_tree_dialog", NULL);
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
|
2009-07-20 08:23:32 +00:00
|
|
|
if (builder == NULL) {
|
2003-06-07 14:41:56 +00:00
|
|
|
data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR);
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
return;
|
|
|
|
}
|
2003-01-14 01:52:23 +00:00
|
|
|
|
2009-09-16 20:30:46 +00:00
|
|
|
separator = g_strcompress (tree_data->separator);
|
2003-01-14 01:52:23 +00:00
|
|
|
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
n_columns = g_slist_length (tree_data->columns);
|
2003-01-13 16:48:45 +00:00
|
|
|
|
2004-07-19 01:01:28 +00:00
|
|
|
if (tree_data->print_column) {
|
2009-01-09 00:14:01 +00:00
|
|
|
if (strcmp (g_ascii_strdown (tree_data->print_column, -1), "all") == 0)
|
2004-07-19 01:01:28 +00:00
|
|
|
print_all_columns = TRUE;
|
2005-06-30 23:43:23 +00:00
|
|
|
else
|
|
|
|
print_columns = zenity_tree_extract_column_indexes (tree_data->print_column, n_columns);
|
2005-06-28 11:11:50 +00:00
|
|
|
}
|
|
|
|
else {
|
2005-06-30 23:43:23 +00:00
|
|
|
print_columns = g_new (gint, 2);
|
2007-08-13 20:16:37 +00:00
|
|
|
print_columns[0] = (tree_data->radiobox || tree_data->checkbox ? 2 : 1);
|
2005-06-30 23:43:23 +00:00
|
|
|
print_columns[1] = 0;
|
2004-07-19 01:01:28 +00:00
|
|
|
}
|
|
|
|
|
2005-07-01 21:28:36 +00:00
|
|
|
if (tree_data->hide_column)
|
|
|
|
hide_columns = zenity_tree_extract_column_indexes (tree_data->hide_column, n_columns);
|
|
|
|
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
if (n_columns == 0) {
|
2003-05-07 01:08:08 +00:00
|
|
|
g_printerr (_("No column titles specified for List dialog.\n"));
|
2003-06-07 14:41:56 +00:00
|
|
|
data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR);
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
return;
|
|
|
|
}
|
2003-01-17 07:46:11 +00:00
|
|
|
|
2012-07-19 17:22:25 +00:00
|
|
|
if (tree_data->checkbox + tree_data->radiobox + tree_data->imagebox > 1) {
|
2005-06-28 04:43:10 +00:00
|
|
|
g_printerr (_("You should use only one List dialog type.\n"));
|
|
|
|
data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-07-20 08:23:32 +00:00
|
|
|
gtk_builder_connect_signals (builder, NULL);
|
2003-01-03 13:26:04 +00:00
|
|
|
|
2009-07-20 08:23:32 +00:00
|
|
|
dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_tree_dialog"));
|
2003-01-03 13:26:04 +00:00
|
|
|
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
g_signal_connect (G_OBJECT (dialog), "response",
|
|
|
|
G_CALLBACK (zenity_tree_dialog_response), data);
|
Fix up the response signal handlers. Use returns of 0 for 'Ok' and
2003-01-07 Glynn Foster <glynn.foster@sun.com>
* src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c,
src/tree.c, src/zenity.glade, src/zenity.h: Fix up
the response signal handlers. Use returns of 0 for
'Ok' and 'Close', 1 for 'Cancel' and 'Escape' and
-1 for 'Uh Oh'. Get stuff printing to stderr. Fix up
the error handling that I thought was improved,
although still have issues with popt callback getting
called numerous times because of more than one instance
of the same kind is being used in poptOption.
* TODO: Update accordingly.
2003-01-07 13:22:57 +00:00
|
|
|
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
if (data->dialog_title)
|
|
|
|
gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);
|
2003-01-03 13:26:04 +00:00
|
|
|
|
2011-07-26 17:00:28 +00:00
|
|
|
if (data->ok_label) {
|
|
|
|
button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_tree_ok_button"));
|
|
|
|
gtk_button_set_label (GTK_BUTTON (button), data->ok_label);
|
|
|
|
gtk_button_set_image (GTK_BUTTON (button),
|
|
|
|
gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (data->cancel_label) {
|
|
|
|
button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_tree_cancel_button"));
|
|
|
|
gtk_button_set_label (GTK_BUTTON (button), data->cancel_label);
|
|
|
|
gtk_button_set_image (GTK_BUTTON (button),
|
|
|
|
gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON));
|
|
|
|
}
|
|
|
|
|
2009-07-20 08:23:32 +00:00
|
|
|
text = gtk_builder_get_object (builder, "zenity_tree_text");
|
2004-04-28 12:06:02 +00:00
|
|
|
|
|
|
|
if (tree_data->dialog_text)
|
2005-11-15 04:14:35 +00:00
|
|
|
gtk_label_set_markup (GTK_LABEL (text), g_strcompress (tree_data->dialog_text));
|
2004-04-28 12:06:02 +00:00
|
|
|
|
Add new notification icon. Update for new files. Restructure code a little
2004-09-13 Glynn Foster <glynn.foster@sun.com>
* data/Makefile.am, data/zenity-notification.png: Add new
notification icon.
* src/Makefile.am: Update for new files.
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/progress.c, src/text.c, src/tree.c, src/msg.c: Restructure code a
little bit for new utility functions for setting window icons.
* src/eggtrayicon.c, src/eggtrayicon.h: New files for notification area
support.
* src/main.c, src/notification.c, src/util.c, src/util.h, src/zenity.h:
Add support for notification area.
* data/zenity.1, help/*: Update docs for notification and new file
selection changes.
2004-09-13 07:51:51 +00:00
|
|
|
zenity_util_set_window_icon (dialog, data->window_icon, ZENITY_IMAGE_FULLPATH ("zenity-list.png"));
|
2003-01-03 13:26:04 +00:00
|
|
|
|
2004-03-19 02:28:30 +00:00
|
|
|
if (data->width > -1 || data->height > -1)
|
|
|
|
gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height);
|
2003-04-13 15:42:41 +00:00
|
|
|
|
2009-07-20 08:23:32 +00:00
|
|
|
tree_view = gtk_builder_get_object (builder, "zenity_tree_view");
|
2003-01-03 13:26:04 +00:00
|
|
|
|
2005-06-27 04:27:15 +00:00
|
|
|
if (!(tree_data->radiobox || tree_data->checkbox))
|
2009-07-20 08:23:32 +00:00
|
|
|
g_signal_connect (tree_view, "row-activated",
|
2005-06-27 04:27:15 +00:00
|
|
|
G_CALLBACK (zenity_tree_row_activated), data);
|
|
|
|
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
/* Create an empty list store */
|
|
|
|
model = g_object_new (GTK_TYPE_LIST_STORE, NULL);
|
2003-01-03 13:26:04 +00:00
|
|
|
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
if (tree_data->editable)
|
|
|
|
column_types = g_new (GType, n_columns + 1);
|
|
|
|
else
|
|
|
|
column_types = g_new (GType, n_columns);
|
2003-01-03 13:26:04 +00:00
|
|
|
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
for (i = 0; i < n_columns; i++) {
|
|
|
|
/* Have the limitation that the radioboxes and checkboxes are in the first column */
|
|
|
|
if (i == 0 && (tree_data->checkbox || tree_data->radiobox))
|
|
|
|
column_types[i] = G_TYPE_BOOLEAN;
|
|
|
|
else
|
|
|
|
column_types[i] = G_TYPE_STRING;
|
|
|
|
}
|
2003-01-03 13:26:04 +00:00
|
|
|
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
if (tree_data->editable)
|
|
|
|
column_types[n_columns] = G_TYPE_BOOLEAN;
|
2003-01-28 14:58:30 +00:00
|
|
|
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
if (tree_data->editable)
|
|
|
|
gtk_list_store_set_column_types (model, n_columns + 1, column_types);
|
|
|
|
else
|
|
|
|
gtk_list_store_set_column_types (model, n_columns, column_types);
|
2003-01-03 13:26:04 +00:00
|
|
|
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), GTK_TREE_MODEL (model));
|
2003-01-03 13:26:04 +00:00
|
|
|
|
2005-06-27 03:13:37 +00:00
|
|
|
if (!(tree_data->radiobox || tree_data->checkbox)) {
|
|
|
|
if (tree_data->multi)
|
|
|
|
gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)),
|
|
|
|
GTK_SELECTION_MULTIPLE);
|
|
|
|
else
|
|
|
|
gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)),
|
|
|
|
GTK_SELECTION_SINGLE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)),
|
|
|
|
GTK_SELECTION_NONE);
|
2003-01-28 14:58:30 +00:00
|
|
|
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
column_index = 0;
|
2003-01-06 15:06:17 +00:00
|
|
|
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
for (tmp = tree_data->columns; tmp; tmp = tmp->next) {
|
|
|
|
if (!first_column) {
|
|
|
|
if (tree_data->checkbox || tree_data->radiobox) {
|
|
|
|
GtkCellRenderer *cell_renderer;
|
|
|
|
|
|
|
|
cell_renderer = gtk_cell_renderer_toggle_new ();
|
2005-06-28 11:11:50 +00:00
|
|
|
|
2003-04-13 15:42:41 +00:00
|
|
|
if (tree_data->radiobox) {
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
g_object_set (G_OBJECT (cell_renderer), "radio", TRUE, NULL);
|
2006-07-26 23:17:04 +00:00
|
|
|
g_object_set_data (G_OBJECT (model), "radio", GINT_TO_POINTER (1));
|
2003-04-13 15:42:41 +00:00
|
|
|
}
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
|
2005-06-28 11:11:50 +00:00
|
|
|
g_signal_connect (cell_renderer, "toggled",
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
G_CALLBACK (zenity_tree_toggled_callback), model);
|
|
|
|
|
|
|
|
column = gtk_tree_view_column_new_with_attributes (tmp->data,
|
|
|
|
cell_renderer,
|
|
|
|
"active", column_index, NULL);
|
2012-07-19 17:22:25 +00:00
|
|
|
} else if (tree_data->imagebox) {
|
|
|
|
GtkCellRenderer *cell_renderer = gtk_cell_renderer_pixbuf_new ();
|
|
|
|
column = gtk_tree_view_column_new_with_attributes (tmp->data,
|
|
|
|
cell_renderer, NULL);
|
|
|
|
gtk_tree_view_column_set_cell_data_func (column, cell_renderer,
|
|
|
|
zenity_load_pixbuf, NULL, NULL);
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (tree_data->editable) {
|
|
|
|
GtkCellRenderer *cell_renderer;
|
|
|
|
|
|
|
|
cell_renderer = gtk_cell_renderer_text_new ();
|
|
|
|
g_signal_connect (G_OBJECT (cell_renderer), "edited",
|
|
|
|
G_CALLBACK (zenity_cell_edited_callback),
|
|
|
|
gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view)));
|
2006-07-26 23:17:04 +00:00
|
|
|
g_object_set_data (G_OBJECT (cell_renderer), "column", GINT_TO_POINTER (column_index));
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
|
|
|
|
column = gtk_tree_view_column_new_with_attributes (tmp->data,
|
|
|
|
cell_renderer,
|
|
|
|
"text", column_index,
|
|
|
|
"editable", n_columns,
|
|
|
|
NULL);
|
2005-07-01 21:28:36 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
column = gtk_tree_view_column_new_with_attributes (tmp->data,
|
|
|
|
gtk_cell_renderer_text_new (),
|
|
|
|
"text", column_index,
|
|
|
|
NULL);
|
|
|
|
}
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
|
|
|
|
gtk_tree_view_column_set_sort_column_id (column, column_index);
|
|
|
|
gtk_tree_view_column_set_resizable (column, TRUE);
|
|
|
|
}
|
2005-07-01 21:28:36 +00:00
|
|
|
if (zenity_tree_column_is_hidden (1))
|
|
|
|
gtk_tree_view_column_set_visible (column, FALSE);
|
|
|
|
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
first_column = TRUE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (tree_data->editable) {
|
|
|
|
GtkCellRenderer *cell_renderer;
|
|
|
|
|
|
|
|
cell_renderer = gtk_cell_renderer_text_new ();
|
|
|
|
g_signal_connect (G_OBJECT (cell_renderer), "edited",
|
|
|
|
G_CALLBACK (zenity_cell_edited_callback),
|
|
|
|
gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view)));
|
2006-07-26 23:17:04 +00:00
|
|
|
g_object_set_data (G_OBJECT (cell_renderer), "column", GINT_TO_POINTER (column_index));
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
|
|
|
|
column = gtk_tree_view_column_new_with_attributes (tmp->data,
|
|
|
|
cell_renderer,
|
|
|
|
"text", column_index,
|
|
|
|
"editable", n_columns,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
column = gtk_tree_view_column_new_with_attributes (tmp->data,
|
|
|
|
gtk_cell_renderer_text_new (),
|
|
|
|
"text", column_index, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_tree_view_column_set_sort_column_id (column, column_index);
|
|
|
|
gtk_tree_view_column_set_resizable (column, TRUE);
|
2005-07-01 21:28:36 +00:00
|
|
|
|
|
|
|
if (zenity_tree_column_is_hidden (column_index + 1))
|
|
|
|
gtk_tree_view_column_set_visible (column, FALSE);
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
}
|
2005-06-28 11:11:50 +00:00
|
|
|
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column);
|
|
|
|
column_index++;
|
|
|
|
}
|
2003-01-03 13:26:04 +00:00
|
|
|
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (tree_view), TRUE);
|
2003-01-03 13:26:04 +00:00
|
|
|
|
2009-08-10 03:10:53 +00:00
|
|
|
if (tree_data->hide_header)
|
|
|
|
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tree_view), FALSE);
|
|
|
|
|
2003-05-05 17:17:02 +00:00
|
|
|
if (tree_data->radiobox || tree_data->checkbox) {
|
2005-01-17 01:33:23 +00:00
|
|
|
if (tree_data->data && *tree_data->data)
|
2003-05-05 17:17:02 +00:00
|
|
|
zenity_tree_fill_entries (GTK_TREE_VIEW (tree_view), tree_data->data, n_columns, TRUE, tree_data->editable);
|
|
|
|
else
|
|
|
|
zenity_tree_fill_entries_from_stdin (GTK_TREE_VIEW (tree_view), n_columns, TRUE, tree_data->editable);
|
|
|
|
}
|
|
|
|
else {
|
2005-01-17 01:33:23 +00:00
|
|
|
if (tree_data->data && *tree_data->data)
|
2003-05-05 17:17:02 +00:00
|
|
|
zenity_tree_fill_entries (GTK_TREE_VIEW (tree_view), tree_data->data, n_columns, FALSE, tree_data->editable);
|
|
|
|
else
|
|
|
|
zenity_tree_fill_entries_from_stdin (GTK_TREE_VIEW (tree_view), n_columns, FALSE, tree_data->editable);
|
|
|
|
}
|
2003-01-03 13:26:04 +00:00
|
|
|
|
Add from the 2 Sebastian's, and make email addresses more spam proof.
2004-04-26 Glynn Foster <glynn.foster@sun.com>
* THANKS, src/about.c: Add from the 2 Sebastian's, and make
email addresses more spam proof.
* src/calendar.c, src/entry.c, src/fileselection.c, src/msg.c,
* src/progress.c, src/text.c, src/tree.c, src/util.c,
* src/util.h: Patch from Sebastian Kapfer to make all zenity
dialogs transients of the parent xterm. Fixes #136226.
* src/zenity.glade: Patch from Sebastian Heinlein to
improve things HIG wise. Fixes #140745.
2004-04-26 04:41:25 +00:00
|
|
|
zenity_util_show_dialog (dialog);
|
2007-08-13 20:36:29 +00:00
|
|
|
|
|
|
|
if(data->timeout_delay > 0) {
|
2011-06-16 14:07:58 +00:00
|
|
|
g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog);
|
2007-08-13 20:36:29 +00:00
|
|
|
}
|
|
|
|
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
gtk_main ();
|
2003-01-03 13:26:04 +00:00
|
|
|
|
2009-07-20 08:23:32 +00:00
|
|
|
g_object_unref (builder);
|
2003-01-03 13:26:04 +00:00
|
|
|
}
|
|
|
|
|
2003-01-13 16:48:45 +00:00
|
|
|
static void
|
2003-01-14 01:52:23 +00:00
|
|
|
zenity_tree_dialog_get_selected (GtkTreeModel *model, GtkTreePath *path_buf, GtkTreeIter *iter, GtkTreeView *tree_view)
|
2003-01-13 16:48:45 +00:00
|
|
|
{
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
GValue value = {0, };
|
2005-06-30 23:43:23 +00:00
|
|
|
gint n_columns, i;
|
2004-07-19 01:01:28 +00:00
|
|
|
|
|
|
|
n_columns = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tree_view), "n_columns"));
|
2003-01-13 16:48:45 +00:00
|
|
|
|
2004-07-19 01:01:28 +00:00
|
|
|
if (print_all_columns) {
|
|
|
|
for (i = 0; i < n_columns; i++) {
|
|
|
|
gtk_tree_model_get_value (model, iter, i, &value);
|
2003-01-13 16:48:45 +00:00
|
|
|
|
2008-04-10 09:57:14 +00:00
|
|
|
selected = g_slist_append (selected, g_value_dup_string (&value));
|
2004-07-19 01:01:28 +00:00
|
|
|
g_value_unset (&value);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-06-30 23:43:23 +00:00
|
|
|
for (i = 0; print_columns[i] != 0; i++) {
|
|
|
|
gtk_tree_model_get_value (model, iter, print_columns[i] - 1, &value);
|
2004-07-19 01:01:28 +00:00
|
|
|
|
2008-04-10 09:57:14 +00:00
|
|
|
selected = g_slist_append (selected, g_value_dup_string (&value));
|
2005-06-30 23:43:23 +00:00
|
|
|
g_value_unset (&value);
|
2004-07-19 01:01:28 +00:00
|
|
|
}
|
2003-01-13 16:48:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2004-07-19 01:01:28 +00:00
|
|
|
zenity_tree_dialog_toggle_get_selected (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, GtkTreeView *tree_view)
|
2003-01-13 16:48:45 +00:00
|
|
|
{
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
GValue toggle_value = {0, };
|
2005-07-08 23:21:34 +00:00
|
|
|
gint n_columns, i;
|
2004-07-19 01:01:28 +00:00
|
|
|
|
|
|
|
n_columns = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tree_view), "n_columns"));
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
|
|
|
|
gtk_tree_model_get_value (model, iter, 0, &toggle_value);
|
|
|
|
|
|
|
|
if (g_value_get_boolean (&toggle_value)) {
|
|
|
|
GValue value = {0, };
|
2004-07-19 01:01:28 +00:00
|
|
|
|
|
|
|
if (print_all_columns) {
|
|
|
|
for (i = 1; i < n_columns; i++) {
|
|
|
|
gtk_tree_model_get_value (model, iter, i, &value);
|
|
|
|
|
2008-04-10 09:57:14 +00:00
|
|
|
selected = g_slist_append (selected, g_value_dup_string (&value));
|
2004-07-19 01:01:28 +00:00
|
|
|
g_value_unset (&value);
|
|
|
|
}
|
|
|
|
g_value_unset (&toggle_value);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2005-06-30 23:43:23 +00:00
|
|
|
for (i = 0; print_columns[i] != 0; i++) {
|
2007-05-14 22:07:13 +00:00
|
|
|
gtk_tree_model_get_value (model, iter, print_columns[i] - 1, &value);
|
2004-07-19 01:01:28 +00:00
|
|
|
|
2008-04-10 09:57:14 +00:00
|
|
|
selected = g_slist_append (selected, g_value_dup_string (&value));
|
2005-06-30 23:43:23 +00:00
|
|
|
g_value_unset (&value);
|
2004-07-19 01:01:28 +00:00
|
|
|
}
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
}
|
2005-06-30 23:43:23 +00:00
|
|
|
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
g_value_unset (&toggle_value);
|
2005-06-30 23:43:23 +00:00
|
|
|
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
return FALSE;
|
2003-01-13 16:48:45 +00:00
|
|
|
}
|
|
|
|
|
2003-01-14 01:52:23 +00:00
|
|
|
static void
|
|
|
|
zenity_tree_dialog_output (void)
|
|
|
|
{
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
GSList *tmp;
|
|
|
|
|
|
|
|
for (tmp = selected; tmp; tmp = tmp->next) {
|
|
|
|
if (tmp->next != NULL) {
|
2003-07-13 23:03:18 +00:00
|
|
|
g_print ("%s%s", (gchar *) tmp->data, separator);
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
}
|
|
|
|
else
|
2003-07-13 23:03:18 +00:00
|
|
|
g_print ("%s\n", (gchar *) tmp->data);
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
}
|
|
|
|
|
2005-06-30 23:43:23 +00:00
|
|
|
g_free (print_columns);
|
2005-07-01 21:28:36 +00:00
|
|
|
g_free (hide_columns);
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
g_free (separator);
|
|
|
|
g_slist_foreach (selected, (GFunc) g_free, NULL);
|
|
|
|
selected = NULL;
|
2003-01-14 01:52:23 +00:00
|
|
|
}
|
|
|
|
|
Fix up the response signal handlers. Use returns of 0 for 'Ok' and
2003-01-07 Glynn Foster <glynn.foster@sun.com>
* src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c,
src/tree.c, src/zenity.glade, src/zenity.h: Fix up
the response signal handlers. Use returns of 0 for
'Ok' and 'Close', 1 for 'Cancel' and 'Escape' and
-1 for 'Uh Oh'. Get stuff printing to stderr. Fix up
the error handling that I thought was improved,
although still have issues with popt callback getting
called numerous times because of more than one instance
of the same kind is being used in poptOption.
* TODO: Update accordingly.
2003-01-07 13:22:57 +00:00
|
|
|
static void
|
|
|
|
zenity_tree_dialog_response (GtkWidget *widget, int response, gpointer data)
|
2003-01-03 13:26:04 +00:00
|
|
|
{
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
ZenityData *zen_data = data;
|
2009-07-20 08:23:32 +00:00
|
|
|
GObject *tree_view;
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
GtkTreeSelection *selection;
|
|
|
|
GtkTreeModel *model;
|
|
|
|
|
|
|
|
switch (response) {
|
|
|
|
case GTK_RESPONSE_OK:
|
2009-07-20 08:23:32 +00:00
|
|
|
tree_view = gtk_builder_get_object (builder, "zenity_tree_view");
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view));
|
|
|
|
|
|
|
|
if (gtk_tree_model_get_column_type (model, 0) == G_TYPE_BOOLEAN)
|
2004-07-19 01:01:28 +00:00
|
|
|
gtk_tree_model_foreach (model, (GtkTreeModelForeachFunc) zenity_tree_dialog_toggle_get_selected,
|
|
|
|
GTK_TREE_VIEW (tree_view));
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
else {
|
|
|
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));
|
|
|
|
gtk_tree_selection_selected_foreach (selection,
|
|
|
|
(GtkTreeSelectionForeachFunc) zenity_tree_dialog_get_selected,
|
|
|
|
GTK_TREE_VIEW (tree_view));
|
|
|
|
}
|
|
|
|
zenity_tree_dialog_output ();
|
2011-06-17 13:47:07 +00:00
|
|
|
zenity_util_exit_code_with_data(ZENITY_OK, zen_data);
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GTK_RESPONSE_CANCEL:
|
2003-06-07 14:41:56 +00:00
|
|
|
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL);
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
/* Esc dialog */
|
2003-06-07 14:41:56 +00:00
|
|
|
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC);
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com>
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
Mass indentation cleanup. Make sure the glade dialogs aren't initially
visible because this avoids a visibility jump. Apparently == TRUE is
bad mojo. Fix up.
2003-03-10 17:11:18 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-05-08 20:14:58 +00:00
|
|
|
if (channel != NULL && g_io_channel_get_flags (channel) & G_IO_FLAG_IS_READABLE)
|
2011-07-26 13:08:31 +00:00
|
|
|
g_io_channel_shutdown (channel, TRUE, NULL);
|
|
|
|
|
2004-07-19 01:13:40 +00:00
|
|
|
gtk_main_quit ();
|
2003-01-03 13:26:04 +00:00
|
|
|
}
|
2005-06-27 04:27:15 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
zenity_tree_row_activated (GtkTreeView *tree_view, GtkTreePath *tree_path,
|
|
|
|
GtkTreeViewColumn *tree_col, gpointer data)
|
|
|
|
{
|
|
|
|
ZenityData *zen_data = data;
|
|
|
|
GtkTreeSelection *selection;
|
2012-07-19 17:22:25 +00:00
|
|
|
|
2005-06-27 04:27:15 +00:00
|
|
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));
|
|
|
|
gtk_tree_selection_selected_foreach (selection,
|
|
|
|
(GtkTreeSelectionForeachFunc) zenity_tree_dialog_get_selected,
|
|
|
|
GTK_TREE_VIEW (tree_view));
|
|
|
|
|
|
|
|
zenity_tree_dialog_output ();
|
|
|
|
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK);
|
|
|
|
gtk_main_quit ();
|
|
|
|
}
|
2005-06-30 23:43:23 +00:00
|
|
|
|
2005-07-01 21:28:36 +00:00
|
|
|
static gboolean
|
|
|
|
zenity_tree_column_is_hidden (gint column_index)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
if (hide_columns != NULL)
|
|
|
|
for (i = 0; hide_columns[i] != 0; i++)
|
|
|
|
if (hide_columns[i] == column_index)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2005-06-30 23:43:23 +00:00
|
|
|
static gint *
|
|
|
|
zenity_tree_extract_column_indexes (char *indexes, int n_columns)
|
|
|
|
{
|
|
|
|
char **tmp;
|
|
|
|
gint *result;
|
|
|
|
gint i, j, index;
|
|
|
|
|
|
|
|
tmp = g_strsplit (indexes,
|
|
|
|
PRINT_HIDE_COLUMN_SEPARATOR, 0);
|
|
|
|
|
|
|
|
result = g_new (gint, 1);
|
|
|
|
|
|
|
|
for (j = i = 0; tmp[i] != NULL; i++) {
|
|
|
|
index = atoi (tmp[i]);
|
|
|
|
|
|
|
|
if (index > 0 && index <= n_columns) {
|
|
|
|
result[j] = index;
|
|
|
|
j++;
|
2006-04-17 04:11:15 +00:00
|
|
|
result = g_renew (gint, result, j + 1);
|
2005-06-30 23:43:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
result[j] = 0;
|
|
|
|
|
|
|
|
g_strfreev (tmp);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|