Compare commits

...

9 Commits

Author SHA1 Message Date
Matthias Clasen
fd8306f340 Remove lies
We forgot the documentation when we simplified the GtkApplication
session api.
2012-05-11 17:42:47 -04:00
Benjamin Otte
e12b785653 tests: USE ALL THE WORDS! 2012-05-11 04:46:40 +02:00
Benjamin Otte
fe421e1a7d listview: Reduce the amount of widgets we pre-allocate for sizing
This is getting kinda dangerous because we imply that a child is at
least 4px high by now.
2012-05-11 04:46:40 +02:00
Benjamin Otte
3bb8419dff listview: Implement scrolling 2012-05-11 04:46:40 +02:00
Benjamin Otte
b5dc516704 iconview: Don't draw unallocated items
This is more a workaround for Clutter-GTK than anything else. Most of
all, it makes gnome-boxes start again.
2012-05-09 14:12:24 +02:00
Benjamin Otte
e34702911b listview: Add a scrollbar
The scrollbar doesn't do anything. It's just put in the correct place.
2012-05-09 08:31:26 +02:00
Benjamin Otte
5822782963 listview: Add vfuncs for widget management
No public API yet, I don't have a good one...
2012-05-09 07:49:45 +02:00
Benjamin Otte
02bc5022fa tests: Add testlistview 2012-05-09 05:06:56 +02:00
Benjamin Otte
b794cdbb0a listview: Add skeleton
The widget doesn't do very much yet. But at least it prints lots of
"Hello world".
2012-05-09 05:06:22 +02:00
8 changed files with 7245 additions and 8 deletions

View File

@@ -31,18 +31,18 @@
</thead>
<tbody>
<row><entry>EggSMClient::quit-requested</entry><entry>instead of calling will_quit (FALSE,...) in response to this signal, install an inhibitor</entry></row>
<row><entry>EggSMClient::quit</entry><entry>the #GtkApplication::quit signal</entry></row>
<row><entry>EggSMClient::quit-cancelled</entry><entry></entry></row>
<row><entry>EggSMClient::quit</entry><entry>the #GApplication::shutdown signal</entry></row>
<row><entry>EggSMClient::quit-cancelled</entry><entry>-</entry></row>
<row><entry>egg_sm_client_will_quit</entry><entry>instead of calling will_quit (FALSE,...), install an inhibitor</entry></row>
<row><entry>egg_sm_client_end_session</entry><entry>gtk_application_end_session()</entry></row>
<row><entry>egg_sm_client_end_session</entry><entry>-</entry></row>
</tbody>
</tgroup>
</table>
<para>
At this point, GtkApplication has no special support for state saving.
Applications can use GSettings or GKeyFile and save as much state as
they see fit in response to #GtkApplication::quit or whenever they
consider appropriate.
At this point, GtkApplication has no special support for state saving
and restarting. Applications can use GSettings or GKeyFile and save as
much state as they see fit in response to #GApplication::shutdown or
whenever they consider appropriate.
</para>
</chapter>

View File

@@ -267,6 +267,7 @@ gtk_public_h_sources = \
gtklayout.h \
gtklinkbutton.h \
gtkliststore.h \
gtklistview.h \
gtklockbutton.h \
gtkmain.h \
gtkmenu.h \
@@ -726,6 +727,7 @@ gtk_base_c_sources = \
gtklayout.c \
gtklinkbutton.c \
gtkliststore.c \
gtklistview.c \
gtklockbutton.c \
gtkmain.c \
gtkmarshalers.c \

View File

@@ -124,6 +124,7 @@
#include <gtk/gtklayout.h>
#include <gtk/gtklinkbutton.h>
#include <gtk/gtkliststore.h>
#include <gtk/gtklistview.h>
#include <gtk/gtklockbutton.h>
#include <gtk/gtkmain.h>
#include <gtk/gtkmenu.h>

View File

@@ -2996,7 +2996,7 @@ gtk_icon_view_paint_item (GtkIconView *icon_view,
GtkIconViewPrivate *priv = icon_view->priv;
GtkCellAreaContext *context;
if (priv->model == NULL)
if (priv->model == NULL || item->cell_area.width <= 0 || item->cell_area.height <= 0)
return;
_gtk_icon_view_set_cell_data (icon_view, item);

7052
gtk/gtklistview.c Normal file

File diff suppressed because it is too large Load Diff

128
gtk/gtklistview.h Normal file
View File

@@ -0,0 +1,128 @@
/* gtklistview.h
* Copyright (C) 2012 Benjamin Otte <otte@redhat.com>
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk.h> can be included directly."
#endif
#ifndef __GTK_LIST_VIEW_H__
#define __GTK_LIST_VIEW_H__
#include <gtk/gtkcontainer.h>
#include <gtk/gtktreemodel.h>
#include <gtk/gtkcellrenderer.h>
#include <gtk/gtkcellarea.h>
#include <gtk/gtkselection.h>
#include <gtk/gtktooltip.h>
G_BEGIN_DECLS
#define GTK_TYPE_LIST_VIEW (gtk_list_view_get_type ())
#define GTK_LIST_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_LIST_VIEW, GtkListView))
#define GTK_LIST_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_LIST_VIEW, GtkListViewClass))
#define GTK_IS_LIST_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_LIST_VIEW))
#define GTK_IS_LIST_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_LIST_VIEW))
#define GTK_LIST_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_LIST_VIEW, GtkListViewClass))
typedef struct _GtkListView GtkListView;
typedef struct _GtkListViewClass GtkListViewClass;
typedef struct _GtkListViewPrivate GtkListViewPrivate;
#if 0
/**
* GtkListViewForeachFunc:
* @list_view: a #GtkListView
* @path: The #GtkTreePath of a selected row
* @data: user data
*
* A function used by gtk_list_view_selected_foreach() to map all
* selected rows. It will be called on every selected row in the view.
*/
typedef void (* GtkListViewForeachFunc) (GtkListView *list_view,
GtkTreePath *path,
gpointer data);
#endif
struct _GtkListView
{
GtkContainer parent;
/*< private >*/
GtkListViewPrivate *priv;
};
struct _GtkListViewClass
{
GtkContainerClass parent_class;
void (* item_activated) (GtkListView *list_view,
GtkTreePath *path);
void (* selection_changed) (GtkListView *list_view);
/* Key binding signals */
void (* select_all) (GtkListView *list_view);
void (* unselect_all) (GtkListView *list_view);
void (* select_cursor_item) (GtkListView *list_view);
void (* toggle_cursor_item) (GtkListView *list_view);
gboolean (* move_cursor) (GtkListView *list_view,
GtkMovementStep step,
gint count);
gboolean (* activate_cursor_item) (GtkListView *list_view);
/* Padding for future expansion */
void (*_gtk_reserved1) (void);
void (*_gtk_reserved2) (void);
void (*_gtk_reserved3) (void);
void (*_gtk_reserved4) (void);
};
GType gtk_list_view_get_type (void) G_GNUC_CONST;
GtkWidget * gtk_list_view_new (void);
GtkWidget * gtk_list_view_new_with_model (GtkTreeModel *model);
void gtk_list_view_set_model (GtkListView *list_view,
GtkTreeModel *model);
GtkTreeModel * gtk_list_view_get_model (GtkListView *list_view);
void gtk_list_view_set_selection_mode (GtkListView *list_view,
GtkSelectionMode mode);
GtkSelectionMode gtk_list_view_get_selection_mode (GtkListView *list_view);
gboolean gtk_list_view_get_visible_range (GtkListView *list_view,
GtkTreePath **start_path,
GtkTreePath **end_path);
#if 0
/* for when we support selections, we want to imitate Iconview API */
void gtk_list_view_selected_foreach (GtkListView *list_view,
GtkListViewForeachFunc func,
gpointer data);
void gtk_list_view_select_path (GtkListView *list_view,
GtkTreePath *path);
void gtk_list_view_unselect_path (GtkListView *list_view,
GtkTreePath *path);
gboolean gtk_list_view_path_is_selected (GtkListView *list_view,
GtkTreePath *path);
GList * gtk_list_view_get_selected_items (GtkListView *list_view);
void gtk_list_view_select_all (GtkListView *list_view);
void gtk_list_view_unselect_all (GtkListView *list_view);
#endif
G_END_DECLS
#endif /* __GTK_LIST_VIEW_H__ */

View File

@@ -108,6 +108,7 @@ noinst_PROGRAMS = $(TEST_PROGS) \
testtooltips \
testexpand \
testexpander \
testlistview \
testvolumebutton \
testscrolledwindow \
testswitch \
@@ -232,6 +233,7 @@ testtreemenu_DEPENDENCIES = $(TEST_DEPS)
testwindows_DEPENDENCIES = $(TEST_DEPS)
testexpand_DEPENDENCIES = $(TEST_DEPS)
testexpander_DEPENDENCIES = $(TEST_DEPS)
testlistview_DEPENDENCIES = $(TEST_DEPS)
testswitch_DEPENDENCIES = $(TEST_DEPS)
styleexamples_DEPENDENCIES = $(TEST_DEPS)
testtoplevelembed_DEPENDENCIES = $(TEST_DEPS)
@@ -409,6 +411,8 @@ testexpand_SOURCES = testexpand.c
testexpander_SOURCES = testexpander.c
testlistview_SOURCES = testlistview.c
testswitch_SOURCES = testswitch.c
styleexamples_SOURCES = styleexamples.c

50
tests/testlistview.c Normal file
View File

@@ -0,0 +1,50 @@
#include <gtk/gtk.h>
static GtkTreeModel *
create_treemodel (void)
{
GtkListStore *store;
char *all_the_words;
char **words;
guint i;
store = gtk_list_store_new (1, G_TYPE_STRING);
if (!g_file_get_contents ("/usr/share/dict/words", &all_the_words, NULL, NULL))
return GTK_TREE_MODEL (store);
words = g_strsplit (all_the_words, "\n", -1);
g_free (all_the_words);
for (i = 0; words[i]; i++)
{
gtk_list_store_insert_with_values (store, NULL, -1, 0, words[i], -1);
}
g_print ("created GtkListStore with %u items\n", gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), NULL));
return GTK_TREE_MODEL (store);
}
int
main (int argc, char *argv[])
{
GtkWidget *window, *list;
GtkTreeModel *model;
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (window, "delete-event", G_CALLBACK (gtk_main_quit), NULL);
model = create_treemodel ();
list = gtk_list_view_new_with_model (model);
g_object_unref (model);
gtk_container_add (GTK_CONTAINER (window), list);
gtk_widget_show_all (window);
gtk_main ();
return 0;
}