gdl-switcher.c revision 9f32e6203d2f30a5bd17dbb294c8956b714e59e6
/* -*- 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 version 2 of the GNU General Public
* License as published by the Free Software Foundation.
*
* This program 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
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; 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 "gdl-tools.h"
#include "libgdlmarshal.h"
#include "libgdltypebuiltins.h"
#if HAVE_GNOME
#include <gconf/gconf-client.h>
#endif
GParamSpec *pspec);
GParamSpec *pspec);
const GdkPixbuf *pixbuf_icon,
enum {
};
typedef struct {
int id;
} Button;
struct _GdlSwitcherPrivate {
};
#define H_PADDING 2
#define V_PADDING 2
/* Utility functions. */
static Button *
{
g_object_ref (icon);
g_object_ref (hbox);
return button;
}
static void
{
}
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
{
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;
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;
}
/* 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
{
}
static void
{
while (node)
{
if (switcher_id == id)
{
switcher);
switcher);
break;
}
}
}
/* Initialization. */
static void
{
_("Switcher buttons style"),
}
static void
{
/* notebook signals */
}
gdl_switcher_new (void)
{
return GTK_WIDGET (switcher);
}
void
{
switcher);
if (stock_id)
else if (pixbuf_icon)
else
if (!label) {
} else {
}
switch (INTERNAL_MODE (switcher)) {
case GDL_SWITCHER_STYLE_TEXT:
break;
case GDL_SWITCHER_STYLE_ICON:
break;
case GDL_SWITCHER_STYLE_BOTH:
default:
break;
}
}
static void
{
GSList *p;
{
break;
}
}
}
static void
{
/* Select the notebook page associated with this button */
}
{
switcher);
if (!tab_widget) {
}
switcher);
return ret_position;
}
static void
{
GSList *p;
if (switcher_style == GDL_SWITCHER_STYLE_TABS &&
return;
{
return;
}
return;
switch (switcher_style) {
case GDL_SWITCHER_STYLE_TEXT:
if (INTERNAL_MODE (switcher)
== GDL_SWITCHER_STYLE_ICON) {
}
break;
case GDL_SWITCHER_STYLE_ICON:
if (INTERNAL_MODE (switcher)
== GDL_SWITCHER_STYLE_TEXT) {
} else
break;
case GDL_SWITCHER_STYLE_BOTH:
if (INTERNAL_MODE (switcher)
== GDL_SWITCHER_STYLE_TEXT) {
} else {
}
TRUE, 0);
break;
default:
break;
}
FALSE, 0);
}
}
#if HAVE_GNOME
static GConfEnumStringPair toolbar_styles[] = {
{ GDL_SWITCHER_STYLE_TEXT, "text" },
{ GDL_SWITCHER_STYLE_ICON, "icons" },
{ GDL_SWITCHER_STYLE_BOTH, "both" },
{ GDL_SWITCHER_STYLE_BOTH, "both-horiz" },
{ GDL_SWITCHER_STYLE_BOTH, "both_horiz" },
{ -1, NULL }
};
static void
void *data)
{
char *val;
int switcher_style;
NULL);
}
static void
{
if (switcher_style == GDL_SWITCHER_STYLE_TABS &&
return;
return;
}
}
if (switcher_style != GDL_SWITCHER_STYLE_TOOLBAR) {
} else {
/* This is a little bit tricky, toolbar style is more
* of a meta-style where the actual style is dictated by
* the gnome toolbar setting, so that is why we have
* the is_toolbar_style bool - it tracks the toolbar
* style while the switcher_style member is the actual look and
* feel */
}
}
#else /* HAVE_GNOME */
static void
{
if (switcher_style == GDL_SWITCHER_STYLE_TABS &&
return;
return;
((switcher_style ==
}
#endif /* HAVE_GNOME */
static void
{
GSList *p;
return;
if (show)
else
}
}
static GdlSwitcherStyle
{
return GDL_SWITCHER_STYLE_TABS;
}