static void
set_fixed_style (EggEditableToolbar *t, GtkToolbarStyle style)
{
  g_return_if_fail (GTK_IS_TOOLBAR (t->priv->fixed_toolbar));
  gtk_toolbar_set_style (GTK_TOOLBAR (t->priv->fixed_toolbar),
  			 style == GTK_TOOLBAR_ICONS ? GTK_TOOLBAR_BOTH_HORIZ : style);
}
Example #2
0
/*
 * Creates a new GtkWidget of class GtkRadioButton, performing any specialized
 * initialization needed for the widget to work correctly in this environment.
 * If a dialog box is used to initialize the widget, return NULL from this
 * function, and call data->callback with your new widget when it is done.
 * If the widget needs a special destroy handler, add a signal here.
 */
GtkWidget *
gb_radio_button_new (GbWidgetNewData * data)
{
  GtkWidget *new_widget;
  GSList *group_list = NULL;

  /* SPECIAL CODE: to handle toolbar buttons. */
  if (data->parent && GTK_IS_TOOLBAR (data->parent))
    {
      new_widget = gb_toolbar_new_toolbar_button (data, GTK_TOOLBAR_CHILD_RADIOBUTTON);
      if (new_widget)
	return new_widget;
    }

  if (data->parent)
    gtk_container_foreach (GTK_CONTAINER (data->parent),
			   (GtkCallback) find_parents_group, &group_list);

  if (data->action == GB_CREATING)
    new_widget = gtk_radio_button_new_with_label (group_list, data->name);
  else
    {
      new_widget = gtk_radio_button_new (group_list);
      gtk_container_add (GTK_CONTAINER (new_widget), editor_new_placeholder());
    }
  return new_widget;
}
Example #3
0
static void
gail_container_real_initialize (AtkObject *obj,
                                gpointer  data)
{
  GailContainer *container = GAIL_CONTAINER (obj);
  guint handler_id;

  ATK_OBJECT_CLASS (parent_class)->initialize (obj, data);

  container->children = gtk_container_get_children (GTK_CONTAINER (data));

  /*
   * We store the handler ids for these signals in case some objects
   * need to remove these handlers.
   */
  handler_id = g_signal_connect (data,
                                 "add",
                                 G_CALLBACK (gail_container_add_gtk),
                                 obj);
  g_object_set_data (G_OBJECT (obj), "gail-add-handler-id", 
                     GUINT_TO_POINTER (handler_id));
  handler_id = g_signal_connect (data,
                                 "remove",
                                 G_CALLBACK (gail_container_remove_gtk),
                                 obj);
  g_object_set_data (G_OBJECT (obj), "gail-remove-handler-id", 
                     GUINT_TO_POINTER (handler_id));

  if (GTK_IS_TOOLBAR (data))
    obj->role = ATK_ROLE_TOOL_BAR;
  else if (GTK_IS_VIEWPORT (data))
    obj->role = ATK_ROLE_VIEWPORT;
  else
    obj->role = ATK_ROLE_PANEL;
}
Example #4
0
void
aurora_get_parent_bg (const GtkWidget *widget, AuroraRGB *color)
{
	GtkStateType state_type;
	const GtkWidget *parent;
	GdkColor *gcolor;
	gboolean stop;
	GtkShadowType shadow = GTK_SHADOW_NONE;
	
	if (widget == NULL)
		return;
	
	parent = widget->parent;
	stop = FALSE;
	
	while (parent && !stop)
	{
		stop = FALSE;

		stop |= !GTK_WIDGET_NO_WINDOW (parent);
		stop |= GTK_IS_NOTEBOOK (parent) &&
		        gtk_notebook_get_show_tabs (GTK_NOTEBOOK (parent)) &&
		        gtk_notebook_get_show_border (GTK_NOTEBOOK (parent));

		if (GTK_IS_FRAME(parent))
		{
			shadow = gtk_frame_get_shadow_type(GTK_FRAME(parent));
			stop |= (shadow != GTK_SHADOW_NONE);
		}
		else if (GTK_IS_TOOLBAR (parent))
		{
			gtk_widget_style_get (GTK_WIDGET (parent), "shadow-type", &shadow, NULL);
			
			stop |= (shadow != GTK_SHADOW_NONE);
		}

		if (!stop)
			parent = parent->parent;
	}

	if (parent == NULL)
		return;
	
	state_type = GTK_WIDGET_STATE (parent);
	
	gcolor = &parent->style->bg[state_type];
	
	aurora_gdk_color_to_rgb (gcolor, &color->r, &color->g, &color->b);
    
    if (GTK_IS_FRAME (parent) && shadow != GTK_SHADOW_NONE) {
         if (shadow == (GTK_SHADOW_IN || GTK_SHADOW_ETCHED_IN))
         	aurora_shade (color, color, 0.97);
         else
            aurora_shade (color, color, 1.04);
    }
}
static void
unparent_fixed (EggEditableToolbar *etoolbar)
{
  GtkWidget *toolbar, *dock;
  g_return_if_fail (GTK_IS_TOOLBAR (etoolbar->priv->fixed_toolbar));

  toolbar = etoolbar->priv->fixed_toolbar;
  dock = get_dock_nth (etoolbar, 0);

  if (dock && gtk_widget_get_parent (toolbar) != NULL)
    {
      gtk_container_remove (GTK_CONTAINER (dock), toolbar);
    }
}
Example #6
0
void
c_main_window_pack_tools (CMainWindow * self,
                          GtkToolbar  * tools)
{
  g_return_if_fail (C_IS_MAIN_WINDOW (self));
  g_return_if_fail (GTK_IS_TOOLBAR (tools));

  if (C_MAIN_WINDOW_GET_IFACE (self)->pack_tools)
    {
      C_MAIN_WINDOW_GET_IFACE (self)->pack_tools (self, tools);
    }
  else
    {
      g_warning ("%s doesn't implement pack_tools()",
                 G_OBJECT_TYPE_NAME (self));
    }
}
Example #7
0
static gint
get_space_size (GtkToolItem *tool_item)
{
  gint space_size = _gtk_toolbar_get_default_space_size();
  GtkWidget *parent;

  parent = gtk_widget_get_parent (GTK_WIDGET (tool_item));

  if (GTK_IS_TOOLBAR (parent))
    {
      gtk_widget_style_get (parent,
                            "space-size", &space_size,
                            NULL);
    }
  
  return space_size;
}
Example #8
0
static void
gnc_embedded_window_add_widget (GtkUIManager *merge,
                                GtkWidget *widget,
                                GncEmbeddedWindow *window)
{
    GncEmbeddedWindowPrivate *priv;

    ENTER("merge %p, new widget %p, window %p", merge, widget, window);
    priv = GNC_EMBEDDED_WINDOW_GET_PRIVATE(window);
    if (GTK_IS_TOOLBAR (widget))
    {
        priv->toolbar = widget;
    }

    gtk_box_pack_start (GTK_BOX (priv->menu_dock), widget, FALSE, FALSE, 0);
    gtk_widget_show (widget);
    LEAVE(" ");
}
Example #9
0
void
gtk_utils_set_toolbar_buttons_sensitive (GtkToolbar *toolbar,
					 gboolean are_sensitive, ...)
{
  GtkUtilsToolbarCallbackArguments callback_arguments;

  g_return_if_fail (GTK_IS_TOOLBAR (toolbar));
  g_return_if_fail (toolbar_button_entry_quark);

  callback_arguments.are_sensitive = are_sensitive;
  va_start (callback_arguments.entries, are_sensitive);

  gtk_container_foreach (GTK_CONTAINER (toolbar),
			 (GtkCallback) set_toolbar_item_sensitive,
			 &callback_arguments);

  va_end (callback_arguments.entries);
}
static gboolean process_tab( GtkWidget* widget, int direction )
{
    gboolean handled = FALSE;
    GtkWidget* parent = gtk_widget_get_parent(widget);
    GtkWidget* gp = parent ? gtk_widget_get_parent(parent) : 0;
    GtkWidget* ggp = gp ? gtk_widget_get_parent(gp) : 0;

    if ( ggp && GTK_IS_TOOLBAR(ggp) ) {
        GList* kids = gtk_container_get_children( GTK_CONTAINER(ggp) );
        if ( kids ) {
            GtkWidget* curr = widget;
            while ( curr && (gtk_widget_get_parent(curr) != ggp) ) {
                curr = gtk_widget_get_parent( curr );
            }
            if ( curr ) {
                GList* mid = g_list_find( kids, curr );
                while ( mid ) {
                    mid = ( direction < 0 ) ? g_list_previous(mid) : g_list_next(mid);
                    if ( mid && GTK_IS_TOOL_ITEM(mid->data) ) {
                        /* potential target */
                        GtkWidget* child = gtk_bin_get_child( GTK_BIN(mid->data) );
                        if ( child && GTK_IS_HBOX(child) ) { /* could be ours */
                            GList* subChildren = gtk_container_get_children( GTK_CONTAINER(child) );
                            if ( subChildren ) {
                                GList* last = g_list_last(subChildren);
                                if ( last && GTK_IS_SPIN_BUTTON(last->data) && GTK_WIDGET_IS_SENSITIVE( GTK_WIDGET(last->data) ) ) {
                                    gtk_widget_grab_focus( GTK_WIDGET(last->data) );
                                    handled = TRUE;
                                    mid = 0; /* to stop loop */
                                }

                                g_list_free(subChildren);
                            }
                        }
                    }
                }
            }
            g_list_free( kids );
        }
    }

    return handled;
}
Example #11
0
/*
 * Creates a new GtkWidget of class GtkRadioToolButton, performing any specialized
 * initialization needed for the widget to work correctly in this environment.
 * If a dialog box is used to initialize the widget, return NULL from this
 * function, and call data->callback with your new widget when it is done.
 */
static GtkWidget*
gb_radio_tool_button_new (GbWidgetNewData *data)
{
  GtkWidget *new_widget, *image;
  GbWidget *pixmap_gbwidget;
  GSList *group_list = NULL;

  /* When creating a radiotoolbutton we try to place it in the same group
     as other radiotoolbuttons in the same toolbar. */
  if (data->action == GB_CREATING)
    {
      GtkWidget *parent = data->parent;
      while (parent && !GTK_IS_TOOLBAR (parent))
	parent = parent->parent;
      if (parent)
	gb_widget_children_foreach (parent,
				    (GtkCallback) find_parents_group,
				    &group_list);
    }

  /* Place the pixmap icon in the button initially (even when loading). */
  pixmap_gbwidget = gb_widget_lookup_class ("GtkImage");
  if (pixmap_gbwidget)
    {
      image = gtk_image_new_from_pixmap (pixmap_gbwidget->gdkpixmap,
					 pixmap_gbwidget->mask);
    }
  else
    {
      image = gtk_image_new ();
      g_warning ("Couldn't find GtkPixmap data");
    }
  gtk_widget_show (image);

  new_widget = (GtkWidget*) gtk_radio_tool_button_new (group_list);

  gtk_tool_button_set_label (GTK_TOOL_BUTTON (new_widget), "");
  gtk_tool_button_set_icon_widget (GTK_TOOL_BUTTON (new_widget), image);

  return new_widget;
}
Example #12
0
/*!
* Set "toolbars detachable" setting.
*/
void EV_GnomeToolbar::setDetachable(gboolean detachable)
{
	if (detachable && GTK_IS_TOOLBAR(gtk_bin_get_child(GTK_BIN(m_wHandleBox)))) {
		// not detachable -> detachable
		GtkWidget *box = gtk_handle_box_new();
		gtk_handle_box_set_shadow_type(GTK_HANDLE_BOX(box), GTK_SHADOW_NONE);
		gtk_widget_reparent(m_wToolbar, box);
		gtk_container_add(GTK_CONTAINER(m_wHandleBox), box);
		if (!isHidden()) {
			gtk_widget_show(box);
		}
	}
	else if (!detachable && GTK_IS_HANDLE_BOX(gtk_bin_get_child(GTK_BIN(m_wHandleBox)))) {
		// detachable -> not detachable
		GtkWidget *box = gtk_bin_get_child(GTK_BIN(m_wHandleBox));
		g_object_ref(G_OBJECT(box));
		gtk_container_remove(GTK_CONTAINER(m_wHandleBox), box);
		gtk_widget_reparent(m_wToolbar, m_wHandleBox);
		g_object_unref(G_OBJECT(box));
	}
}
Example #13
0
void
clearlooks_get_parent_bg (const GtkWidget *widget, CairoColor *color)
{
	GtkStateType state_type;
	const GtkWidget *parent;
	GdkColor *gcolor;
	
	if (widget == NULL)
		return;
	
	parent = widget->parent;
	
	while (parent && GTK_WIDGET_NO_WINDOW (parent) && !((GTK_IS_NOTEBOOK (parent)) || (GTK_IS_TOOLBAR (parent))))
		parent = parent->parent;

	if (parent == NULL)
		return;
	
	state_type = GTK_WIDGET_STATE (parent);
	
	gcolor = &parent->style->bg[state_type];
	
	ge_gdk_color_to_cairo (gcolor, color);
}
void
egg_editable_toolbar_set_fixed (EggEditableToolbar *etoolbar,
				GtkToolbar *toolbar)
{
  EggEditableToolbarPrivate *priv = etoolbar->priv;

  g_return_if_fail (!toolbar || GTK_IS_TOOLBAR (toolbar));

  if (priv->fixed_toolbar)
    {
      unparent_fixed (etoolbar);
      g_object_unref (priv->fixed_toolbar);
      priv->fixed_toolbar = NULL;
    }

  if (toolbar)
    {
      priv->fixed_toolbar = GTK_WIDGET (toolbar);
      gtk_toolbar_set_show_arrow (toolbar, FALSE);
      g_object_ref_sink (toolbar);
    }

  update_fixed (etoolbar);
}
Example #15
0
File: tasks.c Project: rosedu/osmo
void
add_tasks_toolbar_widget (GtkUIManager *tasks_uim_widget, GtkWidget *widget, gpointer user_data) {

GtkWidget *handle_box;

    GUI *appGUI = (GUI *)user_data;

    if (GTK_IS_TOOLBAR (widget)) {

        appGUI->tsk->tasks_toolbar = GTK_TOOLBAR (widget);

        handle_box = gtk_handle_box_new ();
        gtk_widget_show (handle_box);
        gtk_container_add (GTK_CONTAINER (handle_box), widget);
        gtk_box_pack_start (appGUI->tsk->vbox, handle_box, FALSE, FALSE, 0);
        g_signal_connect_swapped (widget, "destroy", 
                                  G_CALLBACK (gtk_widget_destroy), handle_box);

    } else {
        gtk_box_pack_start (GTK_BOX(appGUI->tsk->vbox), widget, FALSE, FALSE, 0);
    }

    gtk_widget_show (widget);
}
static void
unset_fixed_style (EggEditableToolbar *t)
{
  g_return_if_fail (GTK_IS_TOOLBAR (t->priv->fixed_toolbar));
  gtk_toolbar_unset_style (GTK_TOOLBAR (t->priv->fixed_toolbar));
}
Example #17
0
/* Outputs source to add a child menu to a BonoboDock. */
static void
gb_bonobo_dock_item_write_add_child_source (GtkWidget * parent,
					   const gchar *parent_name,
					   GtkWidget *child,
					   GbWidgetWriteSourceData * data)
{
  GnomeApp *app;

  /* If we're adding a dock item to a GnomeApp's dock, we use
     the special functions to add it here. */
  if ((app = glade_gnome_is_app_dock_item (parent)))
    {
      /* Children of floating items are added as normal. */
      if (BONOBO_DOCK_ITEM (parent)->is_floating)
	{
	  source_add (data, "  gtk_container_add (GTK_CONTAINER (%s), %s);\n",
		      parent_name, data->wname);
	}
      else if (GTK_IS_MENU_BAR (child))
	{
	  source_add (data,
		      "  gnome_app_create_menus (GNOME_APP (%s), %s_uiinfo);\n",
		      data->component_name, data->real_wname);

	  /* Output the code to install the menu hints, if the GnomeApp has
	     a status bar. This must be output after the code to create the
	     GnomeAppBar is output, so we add it to the same buffer as the
	     signal connections. */
	  if (app->statusbar)
	    {
	      source_add_to_buffer (data, GLADE_SIGNAL_CONNECTIONS,
				    "  gnome_app_install_menu_hints (GNOME_APP (%s), %s_uiinfo);\n",
				    data->component_name, data->real_wname);
	    }
	}
      else
	{
	  BonoboDockPlacement placement;
	  BonoboDockItemBehavior behavior;
	  const gchar *placement_string;
	  gint idx, band_num, position, offset;
	  gchar *prefix, *prefix2;

	  if (gb_bonobo_dock_item_find_position (BONOBO_DOCK_ITEM (parent),
						&placement, &band_num,
						&position, &offset))
	    {
	      idx = glade_util_int_array_index (GladePlacementValues,
						GladePlacementSize,
						placement);
	      if (idx == -1)
		{
		  g_warning ("BonoboDock placement not found");
		  placement = 0;
		}
	      placement_string = GladePlacementSymbols[idx];

	      if (GTK_IS_TOOLBAR (child))
		{
		  source_add (data,
			      "  gnome_app_add_toolbar (GNOME_APP (%s), GTK_TOOLBAR (%s), %s,\n",
			      data->component_name, data->wname,
			      source_make_string (data->wname, FALSE));
		}
	      else
		{
		  source_add (data,
			      "  gnome_app_add_docked (GNOME_APP (%s), %s, %s,\n",
			      data->component_name, data->wname,
			      source_make_string (data->wname, FALSE));
		}

	      source_add (data, "                                ");
	      behavior = BONOBO_DOCK_ITEM (parent)->behavior;
	      prefix = "";
	      prefix2 = "\n                                | ";
	      if (behavior == BONOBO_DOCK_ITEM_BEH_NORMAL)
		{
		  source_add (data, "%sBONOBO_DOCK_ITEM_BEH_NORMAL", prefix);
		}
	      else
		{
		  if (behavior & BONOBO_DOCK_ITEM_BEH_EXCLUSIVE)
		    {
		      source_add (data, "%sBONOBO_DOCK_ITEM_BEH_EXCLUSIVE",
				  prefix);
		      prefix = prefix2;
		    }
		  if (behavior & BONOBO_DOCK_ITEM_BEH_NEVER_FLOATING)
		    {
		      source_add (data, "%sBONOBO_DOCK_ITEM_BEH_NEVER_FLOATING",
				  prefix);
		      prefix = prefix2;
		    }
		  if (behavior & BONOBO_DOCK_ITEM_BEH_NEVER_VERTICAL)
		    {
		      source_add (data, "%sBONOBO_DOCK_ITEM_BEH_NEVER_VERTICAL",
				  prefix);
		      prefix = prefix2;
		    }
		  if (behavior & BONOBO_DOCK_ITEM_BEH_NEVER_HORIZONTAL)
		    {
		      source_add (data, "%sBONOBO_DOCK_ITEM_BEH_NEVER_HORIZONTAL",
				  prefix);
		      prefix = prefix2;
		    }
		  if (behavior & BONOBO_DOCK_ITEM_BEH_LOCKED)
		    {
		      source_add (data, "%sBONOBO_DOCK_ITEM_BEH_LOCKED",
				  prefix);
		      prefix = prefix2;
		    }
		}

	      source_add (data,
			  ",\n"
			  "                                %s, %i, %i, %i);\n",
			  placement_string, band_num, position, offset);
	    }
	}
    }
  else
    {
      g_warning ("Skipping adding dock item to parent - unimplemented.");
    }
}