gdl-switcher.c revision 9da72320667347f97b641753dd3b4591f95df939
/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 8 -*- */
*
* Copyright (C) 2003 Ettore Perazzoli,
* 2007 Naba Kumar
*
* 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
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*
* Copied and adapted from ESidebar.[ch] from evolution
*
* Authors: Ettore Perazzoli <ettore@ximian.com>
* Naba Kumar <naba@gnome.org>
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "gdl-i18n.h"
#include "gdl-switcher.h"
#include "libgdlmarshal.h"
#include "libgdltypebuiltins.h"
GParamSpec *pspec);
GParamSpec *pspec);
const GdkPixbuf *pixbuf_icon,
/* static void gdl_switcher_remove_button (GdlSwitcher *switcher, gint switcher_id); */
enum {
};
typedef struct {
int id;
} Button;
struct _GdlSwitcherPrivate {
};
#define H_PADDING 2
#define V_PADDING 2
/* Utility functions. */
static void
{
}
static void
{
}
static Button *
{
button);
button);
g_object_ref (icon);
g_object_ref (hbox);
return button;
}
static void
{
button);
button);
}
static gint
{
static gint switcher_id_count = 0;
"__switcher_id"));
if (switcher_id <= 0) {
}
return switcher_id;
}
static void
{
GSList *p;
} else {
}
}
}
/* Callbacks. */
static void
{
int id = 0;
GSList *p;
return;
} else {
}
}
if (is_active)
{
}
}
/* Returns -1 if layout didn't happen because a resize request was queued */
static int
{
GtkRequisition client_requisition = {0,};
int btns_per_row;
int row_number;
int max_btn_width = 0, max_btn_height = 0;
int optimal_layout_width = 0;
int row_last;
int x, y;
int i;
int rows_count;
int last_buttons_height;
GTK_WIDGET_CLASS (gdl_switcher_parent_class)->size_request (GTK_WIDGET (switcher), &client_requisition);
if (num_btns == 0)
return y;
/* Figure out the max width and height */
&requisition);
}
/* Figure out how many rows and columns we'll use. */
/* If all the buttons could fit in the single row, have it so */
{
}
if (!icons_only) {
/* If using text buttons, we want to try to have a
* completely filled-in grid, but if we can't, we want
* the odd row to have just a single button.
*/
btns_per_row--;
}
if (num_btns % btns_per_row != 0)
rows_count++;
/* Assign buttons to rows */
row_number = p ? 1 : 0;
} else {
row_number = 0;
}
row_number ++;
}
/* If there are more than 1 row of buttons, save the current height
* requirement for subsequent size requests.
*/
if (row_last > 0)
{
} else { /* Otherwize clear it */
if (last_buttons_height >= 0) {
}
}
/* If it turns out that we now require smaller height for the buttons
* than it was last time, make a resize request to ensure our
* size requisition is properly communicated to the parent (otherwise
* parent tend to keep assuming the older size).
*/
{
return -1;
}
/* Layout the buttons. */
for (i = row_last; i >= 0; i --) {
int len, extra_width;
y -= max_btn_height;
/* Check for possible size over flow (taking into account client
* requisition
*/
/* We have an overflow: Insufficient allocation */
/* Request for a new resize */
return -1;
}
}
x = H_PADDING + allocation.x;
if (switcher_style == GDL_SWITCHER_STYLE_TEXT ||
else
extra_width = 0;
child_allocation.x = x;
child_allocation.y = y;
{
}
else
{
}
}
y -= V_PADDING;
}
for (i = 0; i <= row_last; i ++)
g_slist_free (rows [i]);
return y;
}
static void
{
int y;
y = layout_buttons (switcher);
if (y < 0) /* Layout did not happen and a resize was requested */
return;
}
else
/* Place the parent widget. */
child_allocation.x = allocation.x;
child_allocation.y = allocation.y;
GTK_WIDGET_CLASS (gdl_switcher_parent_class)->size_allocate (GTK_WIDGET (switcher), &child_allocation);
}
/* GtkContainer methods. */
static void
{
GSList *p;
if (include_internals) {
}
}
}
static void
{
GSList *p;
if (b->id == switcher_id) {
button_free (b);
break;
}
}
}
/* GtkWidget methods. */
static void
{
GSList *p;
gint button_height = 0;
return;
}
} else {
}
}
static void
{
}
static gint
{
GSList *p;
}
}
}
static void
{
GSList *p;
}
}
}
/* GObject methods. */
static void
{
switch (prop_id) {
case PROP_SWITCHER_STYLE:
break;
default:
break;
}
}
static void
{
switch (prop_id) {
case PROP_SWITCHER_STYLE:
break;
default:
break;
}
}
static void
{
#if HAVE_GNOME
if (priv->style_changed_id) {
priv->style_changed_id = 0;
}
#endif
}
static void
{
}
/* Signal handlers */
static void
{
}
static void
{
/* Change switcher button */
}
static void
{
(void)nb;
(void)page_num;
switcher_id, page);
}
static void
{
while (node)
{
if (switcher_id == id)
{
switcher);
switcher);
break;
}
}
}
/* Initialization. */
static void
{
_("Switcher buttons style"),
gtk_rc_parse_string ("style \"gdl-button-style\"\n"
"{\n"
"GtkWidget::focus-padding = 1\n"
"GtkWidget::focus-line-width = 1\n"
"xthickness = 0\n"
"ythickness = 0\n"
"}\n"
"widget \"*.gdl-button\" style \"gdl-button-style\"");
}
static void
{
/* notebook signals */
}
gdl_switcher_new (void)
{
return GTK_WIDGET (switcher);
}
void
const GdkPixbuf *pixbuf_icon,
{
switcher);
if (stock_id) {
} else if (pixbuf_icon) {
} else {
}
if (!label) {
} else {
}
tooltips);
switch (INTERNAL_MODE (switcher)) {
case GDL_SWITCHER_STYLE_TEXT:
break;
case GDL_SWITCHER_STYLE_ICON:
break;
case GDL_SWITCHER_STYLE_BOTH:
default:
break;
}
}
#if 0
static void
{
GSList *p;
{
break;
}
}
}
#endif
static void
{
/* Select the notebook page associated with this button */
}
{
switcher);
if (!tab_widget) {
}
switcher);
return ret_position;
}
static void
{
GSList *p;
return;
return;
switch (switcher_style) {
case GDL_SWITCHER_STYLE_TEXT:
break;
case GDL_SWITCHER_STYLE_ICON:
break;
case GDL_SWITCHER_STYLE_BOTH:
break;
default:
break;
}
}
}
static void
{
return;
if (switcher_style == GDL_SWITCHER_STYLE_NONE) {
}
else if (switcher_style == GDL_SWITCHER_STYLE_TABS) {
}
else
}
static void
{
GSList *p;
return;
if (show)
else
}
}
static GdlSwitcherStyle
{
return GDL_SWITCHER_STYLE_TABS;
}