Commit f82ca65b authored by Matthias Clasen's avatar Matthias Clasen Committed by Matthias Clasen

Use GtkTreeViewRowSeparatorFunc instead of GtkCellRendererSepText.

Sat Aug  7 18:19:03 2004  Matthias Clasen  <maclas@gmx.de>

	* gtk/gtkfilechooserdefault.c (save_folder_combo_create):
	(shortcuts_list_create): Use GtkTreeViewRowSeparatorFunc
	instead of GtkCellRendererSepText.  (#147864)

	* gtk/gtkcellrendererseptext.[hc]: Removed.

	* gtk/Makefile.am: Remove gtkcellrendererseptext.[hc]

Sat Aug  7 18:15:15 2004  Matthias Clasen  <maclas@gmx.de>

	* gtk/gtkcombobox.c (gtk_combo_box_menu_row_deleted):
	(gtk_combo_box_menu_row_inserted):
	(gtk_combo_box_menu_row_changed): Correctly handle
	insertion and deletion of separators in menu mode.
parent 5f7fbb27
Sat Aug 7 18:19:03 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtkfilechooserdefault.c (save_folder_combo_create):
(shortcuts_list_create): Use GtkTreeViewRowSeparatorFunc
instead of GtkCellRendererSepText. (#147864)
* gtk/gtkcellrendererseptext.[hc]: Removed.
* gtk/Makefile.am: Remove gtkcellrendererseptext.[hc]
Sat Aug 7 18:15:15 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtkcombobox.c (gtk_combo_box_menu_row_deleted):
(gtk_combo_box_menu_row_inserted):
(gtk_combo_box_menu_row_changed): Correctly handle
insertion and deletion of separators in menu mode.
2004-08-07 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkevents-win32.c (handle_configure_event,
......
Sat Aug 7 18:19:03 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtkfilechooserdefault.c (save_folder_combo_create):
(shortcuts_list_create): Use GtkTreeViewRowSeparatorFunc
instead of GtkCellRendererSepText. (#147864)
* gtk/gtkcellrendererseptext.[hc]: Removed.
* gtk/Makefile.am: Remove gtkcellrendererseptext.[hc]
Sat Aug 7 18:15:15 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtkcombobox.c (gtk_combo_box_menu_row_deleted):
(gtk_combo_box_menu_row_inserted):
(gtk_combo_box_menu_row_changed): Correctly handle
insertion and deletion of separators in menu mode.
2004-08-07 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkevents-win32.c (handle_configure_event,
......
Sat Aug 7 18:19:03 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtkfilechooserdefault.c (save_folder_combo_create):
(shortcuts_list_create): Use GtkTreeViewRowSeparatorFunc
instead of GtkCellRendererSepText. (#147864)
* gtk/gtkcellrendererseptext.[hc]: Removed.
* gtk/Makefile.am: Remove gtkcellrendererseptext.[hc]
Sat Aug 7 18:15:15 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtkcombobox.c (gtk_combo_box_menu_row_deleted):
(gtk_combo_box_menu_row_inserted):
(gtk_combo_box_menu_row_changed): Correctly handle
insertion and deletion of separators in menu mode.
2004-08-07 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkevents-win32.c (handle_configure_event,
......
Sat Aug 7 18:19:03 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtkfilechooserdefault.c (save_folder_combo_create):
(shortcuts_list_create): Use GtkTreeViewRowSeparatorFunc
instead of GtkCellRendererSepText. (#147864)
* gtk/gtkcellrendererseptext.[hc]: Removed.
* gtk/Makefile.am: Remove gtkcellrendererseptext.[hc]
Sat Aug 7 18:15:15 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtkcombobox.c (gtk_combo_box_menu_row_deleted):
(gtk_combo_box_menu_row_inserted):
(gtk_combo_box_menu_row_changed): Correctly handle
insertion and deletion of separators in menu mode.
2004-08-07 Tor Lillqvist <tml@iki.fi>
* gdk/win32/gdkevents-win32.c (handle_configure_event,
......
......@@ -276,7 +276,6 @@ gtk_semi_private_h_sources = \
# GTK+ header files that don't get installed
gtk_private_h_sources = \
gtkcellrendererseptext.h\
gtkentryprivate.h \
gtkfilechooserembed.h \
gtkfilechooserentry.h \
......@@ -327,7 +326,6 @@ gtk_c_sources = \
gtkcellrenderercombo.c \
gtkcellrendererpixbuf.c \
gtkcellrendererprogress.c \
gtkcellrendererseptext.c\
gtkcellrenderertext.c \
gtkcellrenderertoggle.c \
gtkcellview.c \
......
/* GTK - The GIMP Toolkit
* gtkcellrendererseptext.h: Cell renderer for text or a separator
* Copyright (C) 2003, Ximian, Inc.
*
* Author: Federico Mena-Quintero <federico@ximian.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <config.h>
#include "gtkcellrendererseptext.h"
static void gtk_cell_renderer_sep_get_size (GtkCellRenderer *cell,
GtkWidget *widget,
GdkRectangle *cell_area,
gint *x_offset,
gint *y_offset,
gint *width,
gint *height);
static void gtk_cell_renderer_sep_text_render (GtkCellRenderer *cell,
GdkWindow *window,
GtkWidget *widget,
GdkRectangle *background_area,
GdkRectangle *cell_area,
GdkRectangle *expose_area,
GtkCellRendererState flags);
static GtkCellRendererTextClass *parent_class;
static void
gtk_cell_renderer_sep_text_class_init (GtkCellRendererSepTextClass *class)
{
GtkCellRendererClass *cell_renderer_class;
cell_renderer_class = GTK_CELL_RENDERER_CLASS (class);
parent_class = g_type_class_peek_parent (class);
cell_renderer_class->get_size = gtk_cell_renderer_sep_get_size;
cell_renderer_class->render = gtk_cell_renderer_sep_text_render;
}
GType
_gtk_cell_renderer_sep_text_get_type (void)
{
static GType cell_type = 0;
if (!cell_type)
{
static const GTypeInfo cell_info =
{
sizeof (GtkCellRendererSepTextClass),
NULL, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc) gtk_cell_renderer_sep_text_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GtkCellRendererSepText),
0, /* n_preallocs */
NULL, /* instance_init */
NULL, /* value_table */
};
cell_type = g_type_register_static (GTK_TYPE_CELL_RENDERER_TEXT, "GtkCellRendererSepText",
&cell_info, 0);
}
return cell_type;
}
static void
gtk_cell_renderer_sep_get_size (GtkCellRenderer *cell,
GtkWidget *widget,
GdkRectangle *cell_area,
gint *x_offset,
gint *y_offset,
gint *width,
gint *height)
{
GtkCellRendererSepText *st;
const char *text;
st = GTK_CELL_RENDERER_SEP_TEXT (cell);
text = st->renderer_text.text;
if (!text)
{
if (width)
*width = cell->xpad * 2 + 1;
if (height)
*height = cell->ypad * 2 + 1;
if (x_offset) *x_offset = 0;
if (y_offset) *y_offset = 0;
}
else
{
GTK_CELL_RENDERER_CLASS (parent_class)->get_size (cell, widget, cell_area, x_offset, y_offset, width, height);
}
}
static void
gtk_cell_renderer_sep_text_render (GtkCellRenderer *cell,
GdkWindow *window,
GtkWidget *widget,
GdkRectangle *background_area,
GdkRectangle *cell_area,
GdkRectangle *expose_area,
GtkCellRendererState flags)
{
GtkCellRendererSepText *st;
const char *text;
st = GTK_CELL_RENDERER_SEP_TEXT (cell);
text = st->renderer_text.text;
if (!text)
gtk_paint_hline (gtk_widget_get_style (widget),
window,
GTK_WIDGET_STATE (widget),
expose_area,
widget,
NULL,
cell_area->x,
cell_area->x + cell_area->width,
cell_area->y + cell_area->height / 2);
else
GTK_CELL_RENDERER_CLASS (parent_class)->render (cell, window, widget, background_area, cell_area, expose_area, flags);
}
GtkCellRenderer *
_gtk_cell_renderer_sep_text_new (void)
{
return g_object_new (GTK_TYPE_CELL_RENDERER_SEP_TEXT, NULL);
}
/* GTK - The GIMP Toolkit
* gtkcellrendererseptext.h: Cell renderer for text or a separator
* Copyright (C) 2003, Ximian, Inc.
*
* Author: Federico Mena-Quintero <federico@ximian.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GTK_CELL_RENDERER_SEP_TEXT_H__
#define __GTK_CELL_RENDERER_SEP_TEXT_H__
#include <gtk/gtkcellrenderertext.h>
G_BEGIN_DECLS
#define GTK_TYPE_CELL_RENDERER_SEP_TEXT (_gtk_cell_renderer_sep_text_get_type ())
#define GTK_CELL_RENDERER_SEP_TEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_CELL_RENDERER_SEP_TEXT, GtkCellRendererSepText))
#define GTK_CELL_RENDERER_SEP_TEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_CELL_RENDERER_SEP_TEXT, GtkCellRendererSepTextClass))
#define GTK_IS_CELL_RENDERER_SEP_TEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_CELL_RENDERER_SEP_TEXT))
#define GTK_IS_CELL_RENDERER_SEP_TEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_CELL_RENDERER_SEP_TEXT))
#define GTK_CELL_RENDERER_SEP_TEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CELL_RENDERER_SEP_TEXT, GtkCellRendererSepTextClass))
typedef struct _GtkCellRendererSepText GtkCellRendererSepText;
typedef struct _GtkCellRendererSepTextClass GtkCellRendererSepTextClass;
struct _GtkCellRendererSepText
{
GtkCellRendererText renderer_text;
};
struct _GtkCellRendererSepTextClass
{
GtkCellRendererTextClass parent_class;
};
GType _gtk_cell_renderer_sep_text_get_type (void) G_GNUC_CONST;
GtkCellRenderer *_gtk_cell_renderer_sep_text_new (void);
G_END_DECLS
#endif
......@@ -2361,7 +2361,13 @@ gtk_combo_box_menu_fill_level (GtkComboBox *combo_box,
is_separator = FALSE;
if (is_separator)
item = gtk_separator_menu_item_new ();
{
item = gtk_separator_menu_item_new ();
g_object_set_data_full (G_OBJECT (item),
"gtk-combo-box-item-path",
gtk_tree_model_get_path (model, &iter),
(GDestroyNotify)gtk_tree_path_free);
}
else
{
item = gtk_cell_view_menu_item_new (combo_box, model, &iter);
......@@ -2523,8 +2529,7 @@ static void
gtk_combo_box_relayout (GtkComboBox *combo_box)
{
GList *list, *j;
GtkWidget *menu, *item;
gint row, col, width;
GtkWidget *menu;
menu = combo_box->priv->popup_widget;
......@@ -2726,7 +2731,11 @@ find_menu_by_path (GtkWidget *menu,
item = NULL;
for (i = list; i; i = i->next)
{
if (GTK_IS_CELL_VIEW (GTK_BIN (i->data)->child))
if (GTK_IS_SEPARATOR_MENU_ITEM (i->data))
{
mpath = gtk_tree_path_copy (g_object_get_data (G_OBJECT (i->data), "gtk-combo-box-item-path"));
}
else if (GTK_IS_CELL_VIEW (GTK_BIN (i->data)->child))
{
if (skip)
{
......@@ -2735,32 +2744,35 @@ find_menu_by_path (GtkWidget *menu,
}
mpath = gtk_cell_view_get_displayed_row (GTK_CELL_VIEW (GTK_BIN (i->data)->child));
/* this case is necessary, since the row reference of
* the cell view may already be updated after a deletion
*/
if (!mpath)
{
item = i->data;
break;
}
if (gtk_tree_path_compare (mpath, path) == 0)
}
else
continue;
/* this case is necessary, since the row reference of
* the cell view may already be updated after a deletion
*/
if (!mpath)
{
item = i->data;
break;
}
if (gtk_tree_path_compare (mpath, path) == 0)
{
gtk_tree_path_free (mpath);
item = i->data;
break;
}
if (gtk_tree_path_is_ancestor (mpath, path))
{
submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (i->data));
if (submenu != NULL)
{
gtk_tree_path_free (mpath);
item = i->data;
item = find_menu_by_path (submenu, path, TRUE);
break;
}
if (gtk_tree_path_is_ancestor (mpath, path))
{
submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (i->data));
if (submenu != NULL)
{
gtk_tree_path_free (mpath);
item = find_menu_by_path (submenu, path, TRUE);
break;
}
}
gtk_tree_path_free (mpath);
}
gtk_tree_path_free (mpath);
}
g_list_free (list);
......@@ -2808,6 +2820,7 @@ gtk_combo_box_menu_row_inserted (GtkTreeModel *model,
GtkTreePath *ppath;
GtkTreeIter piter;
gint depth, pos;
gboolean is_separator;
if (!combo_box->priv->popup_widget)
return;
......@@ -2854,13 +2867,30 @@ gtk_combo_box_menu_row_inserted (GtkTreeModel *model,
pos += 1;
}
item = gtk_cell_view_menu_item_new (combo_box, model, iter);
gtk_widget_show (item);
if (combo_box->priv->row_separator_func)
is_separator = (*combo_box->priv->row_separator_func) (model, iter,
combo_box->priv->row_separator_data);
else
is_separator = FALSE;
g_signal_connect (item, "activate",
G_CALLBACK (gtk_combo_box_menu_item_activate),
combo_box);
if (is_separator)
{
item = gtk_separator_menu_item_new ();
g_object_set_data_full (G_OBJECT (item),
"gtk-combo-box-item-path",
gtk_tree_path_copy (path),
(GDestroyNotify)gtk_tree_path_free);
}
else
{
item = gtk_cell_view_menu_item_new (combo_box, model, iter);
g_signal_connect (item, "activate",
G_CALLBACK (gtk_combo_box_menu_item_activate),
combo_box);
}
gtk_widget_show (item);
gtk_menu_shell_insert (GTK_MENU_SHELL (menu), item, pos);
}
......@@ -2902,16 +2932,28 @@ gtk_combo_box_menu_row_changed (GtkTreeModel *model,
GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
GtkWidget *item;
gint width;
gboolean is_separator;
if (!combo_box->priv->popup_widget)
return;
if (combo_box->priv->wrap_width)
item = find_menu_by_path (combo_box->priv->popup_widget, path, FALSE);
if (combo_box->priv->row_separator_func)
is_separator = (*combo_box->priv->row_separator_func) (model, iter,
combo_box->priv->row_separator_data);
else
is_separator = FALSE;
if (is_separator != GTK_IS_SEPARATOR_MENU_ITEM (item))
{
item = find_menu_by_path (combo_box->priv->popup_widget, path, FALSE);
gtk_combo_box_relayout_item (combo_box, item, iter, NULL);
gtk_combo_box_menu_row_deleted (model, path, combo_box);
gtk_combo_box_menu_row_inserted (model, path, iter, combo_box);
}
if (combo_box->priv->wrap_width)
gtk_combo_box_relayout_item (combo_box, item, iter, NULL);
width = gtk_combo_box_calc_requested_width (combo_box, path);
if (width > combo_box->priv->width)
......
......@@ -25,7 +25,7 @@
#include "gtkbutton.h"
#include "gtkcelllayout.h"
#include "gtkcellrendererpixbuf.h"
#include "gtkcellrendererseptext.h"
#include "gtkcellrenderertext.h"
#include "gtkcellrenderertext.h"
#include "gtkcheckmenuitem.h"
#include "gtkcombobox.h"
......@@ -2546,6 +2546,24 @@ shortcuts_selection_changed_cb (GtkTreeSelection *selection,
bookmarks_check_remove_sensitivity (impl);
}
static gboolean
shortcuts_row_separator_func (GtkTreeModel *model,
GtkTreeIter *iter,
gpointer data)
{
gint column = GPOINTER_TO_INT (data);
gchar *text;
gtk_tree_model_get (model, iter, column, &text, -1);
if (!text)
return TRUE;
g_free (text);
return FALSE;
}
/* Creates the widgets for the shortcuts and bookmarks tree */
static GtkWidget *
shortcuts_list_create (GtkFileChooserDefault *impl)
......@@ -2630,12 +2648,17 @@ shortcuts_list_create (GtkFileChooserDefault *impl)
"visible", SHORTCUTS_COL_PIXBUF_VISIBLE,
NULL);
renderer = _gtk_cell_renderer_sep_text_new ();
renderer = gtk_cell_renderer_text_new ();
gtk_tree_view_column_pack_start (column, renderer, TRUE);
gtk_tree_view_column_set_attributes (column, renderer,
"text", SHORTCUTS_COL_NAME,
NULL);
gtk_tree_view_set_row_separator_func (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view),
shortcuts_row_separator_func,
GINT_TO_POINTER (SHORTCUTS_COL_NAME),
NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (impl->browse_shortcuts_tree_view), column);
return swin;
......@@ -3094,13 +3117,18 @@ save_folder_combo_create (GtkFileChooserDefault *impl)
"sensitive", SHORTCUTS_COL_PIXBUF_VISIBLE,
NULL);
cell = _gtk_cell_renderer_sep_text_new ();
cell = gtk_cell_renderer_text_new ();
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), cell, TRUE);
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), cell,
"text", SHORTCUTS_COL_NAME,
"sensitive", SHORTCUTS_COL_PIXBUF_VISIBLE,
NULL);
gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (combo),
shortcuts_row_separator_func,
GINT_TO_POINTER (SHORTCUTS_COL_NAME),
NULL);
g_signal_connect (combo, "changed",
G_CALLBACK (save_folder_combo_changed_cb), impl);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment