Esempio n. 1
0
static void
terminal_profile_editor_focus_widget (GtkWidget *editor,
                                      const char *widget_name)
{
	GtkBuilder *builder;
	GtkWidget *widget, *page, *page_parent;

	if (widget_name == NULL)
		return;

	builder = g_object_get_data (G_OBJECT (editor), "builder");
	widget = GTK_WIDGET (gtk_builder_get_object (builder, widget_name));
	if (widget == NULL)
		return;

	page = widget;
	while (page != NULL &&
	        (page_parent = gtk_widget_get_parent (page)) != NULL &&
	        !GTK_IS_NOTEBOOK (page_parent))
		page = page_parent;

	page_parent = gtk_widget_get_parent (page);
	if (page != NULL && GTK_IS_NOTEBOOK (page_parent))
	{
		GtkNotebook *notebook;

		notebook = GTK_NOTEBOOK (page_parent);
		gtk_notebook_set_current_page (notebook, gtk_notebook_page_num (notebook, page));
	}

	if (gtk_widget_is_sensitive (widget))
		gtk_widget_grab_focus (widget);
}
Esempio n. 2
0
static bool
childrenUseEvent(GtkWidget *widget, GdkEventButton *event, bool inNoteBook)
{
    // accept, by default
    bool usable = true;

    // get children and check
    GList *children = gtk_container_get_children(GTK_CONTAINER(widget));
    for (GList *child = children;child && usable;child = g_list_next(child)) {
        // cast child to GtkWidget
        if (GTK_IS_WIDGET(child->data)) {
            GtkWidget *childWidget = GTK_WIDGET(child->data);
            GdkWindow *window = nullptr;

            // check widget state and type
            if (gtk_widget_get_state(childWidget) == GTK_STATE_PRELIGHT) {
                // if widget is prelight, we don't need to check where event
                // happen, any prelight widget indicate we can't do a move
                usable = false;
                continue;
            }

            window = gtk_widget_get_window(childWidget);
            if (!(window && gdk_window_is_visible(window)))
                continue;

            if (GTK_IS_NOTEBOOK(childWidget))
                inNoteBook = true;

            if(!(event && withinWidget(childWidget, event)))
                continue;

            // check special cases for which grab should not be enabled
            if((isBlackListed(G_OBJECT(childWidget))) ||
               (GTK_IS_NOTEBOOK(widget) && Tab::isLabel(GTK_NOTEBOOK(widget),
                                                         childWidget)) ||
               (GTK_IS_BUTTON(childWidget) &&
                gtk_widget_get_state(childWidget) != GTK_STATE_INSENSITIVE) ||
               (gtk_widget_get_events(childWidget) &
                (GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK)) ||
               (GTK_IS_MENU_ITEM(childWidget)) ||
               (GTK_IS_SCROLLED_WINDOW(childWidget) &&
                (!inNoteBook || gtk_widget_is_focus(childWidget)))) {
                usable = false;
            }

            // if child is a container and event has been accepted so far,
            // also check it, recursively
            if (usable && GTK_IS_CONTAINER(childWidget)) {
                usable = childrenUseEvent(childWidget, event, inNoteBook);
            }
        }
    }
    if (children) {
        g_list_free(children);
    }
    return usable;
}
Esempio n. 3
0
/**
 * callback for fullscreen mode gtk_container_foreach()
 */
static void
fullscreen_toggle_widget_visible(GtkWidget *wid, gpointer user_data) {
	gchar* data_label;
	struct FullscreenData *fdata;
	gboolean old_v;
	gchar *propName;

	fdata = user_data;

	// remove shadow of scrolled window
	if (GTK_IS_SCROLLED_WINDOW(wid)) {
		GtkShadowType shadow_type;

		data_label = "fullscreen_shadow_type";
		propName = "shadow-type";

		if (fdata->visible == FALSE) {
			g_object_get(G_OBJECT(wid),
					propName, &shadow_type, NULL);
			g_object_set(G_OBJECT(wid),
					propName, GTK_SHADOW_NONE, NULL);
			g_object_set_data(G_OBJECT(wid), data_label,
					GINT_TO_POINTER(shadow_type));
		} else {
			shadow_type = GPOINTER_TO_INT(g_object_steal_data(
						G_OBJECT(wid), data_label));
			if (shadow_type && shadow_type != GTK_SHADOW_NONE) {
				g_object_set(G_OBJECT(wid),
						propName, shadow_type, NULL);
			}
		}
	}

	if (wid == fdata->me && !GTK_IS_NOTEBOOK(wid)) {
		return;
	}

	data_label = "fullscreen_visible";
	if (GTK_IS_NOTEBOOK(wid)) {
		propName = "show-tabs";
	} else {
		propName = "visible";
	}

	if (fdata->visible == FALSE) {
		g_object_get(G_OBJECT(wid), propName, &old_v, NULL);
		g_object_set(G_OBJECT(wid), propName, FALSE, NULL);
		g_object_set_data(G_OBJECT(wid), data_label,
				GINT_TO_POINTER(old_v));
	} else {
		old_v = GPOINTER_TO_INT(g_object_steal_data(
					G_OBJECT(wid), data_label));
		if (old_v == TRUE) {
			g_object_set(G_OBJECT(wid), propName, TRUE, NULL);
		}
	}
}
Esempio n. 4
0
static GtkWidget *
gnc_prefs_find_page (GtkNotebook *notebook, const gchar *name)
{
    int n_pages, i;
    GtkWidget *child;
    const gchar *child_name;

    g_return_val_if_fail (GTK_IS_NOTEBOOK (notebook), NULL);
    g_return_val_if_fail (name, NULL);

    ENTER("");

    n_pages = gtk_notebook_get_n_pages (notebook);

    for (i = 0; i < n_pages; i++)
    {
        child = gtk_notebook_get_nth_page (notebook, i);
        g_return_val_if_fail (child, NULL);

        child_name = gtk_notebook_get_tab_label_text (notebook, child);
        g_return_val_if_fail (child_name, NULL);

        if (g_utf8_collate (name, child_name) == 0)
        {
            LEAVE("found at index: %d", i);
            return child;
        }
    }

    LEAVE("not found");
    return NULL;
}
Esempio n. 5
0
static gboolean 
gail_switch_page_watcher (GSignalInvocationHint *ihint,
                          guint                  n_param_values,
                          const GValue          *param_values,
                          gpointer               data)
{
  GObject *object;
  GtkWidget *widget;
  GtkNotebook *notebook;

  object = g_value_get_object (param_values + 0);
  g_return_val_if_fail (GTK_IS_WIDGET(object), FALSE);

  widget = GTK_WIDGET (object);

  if (!GTK_IS_NOTEBOOK (widget))
    return TRUE;

  notebook = GTK_NOTEBOOK (widget);
  if (!notebook->focus_tab)
    return TRUE;

  gail_focus_notify_when_idle (widget);
  return TRUE;
}
Esempio n. 6
0
static void
jam_dialog_set_contents_container(GtkDialog *dlg, GtkWidget *container) {
	gtk_container_set_border_width(GTK_CONTAINER(container), 12);
	gtk_box_pack_start(GTK_BOX(dlg->vbox), container, TRUE, TRUE, 0);
	gtk_widget_show_all(dlg->vbox);
	if (GTK_IS_NOTEBOOK(container))
		gtk_dialog_set_has_separator(dlg, FALSE);
}
Esempio n. 7
0
static AtkObject*
get_accessible_for_widget (GtkWidget *widget,
                           gboolean  *transient)
{
  AtkObject *obj = NULL;

  *transient = FALSE;
  if (!widget)
    return NULL;

  if (GTK_IS_ENTRY (widget))
    ;
  else if (GTK_IS_NOTEBOOK (widget)) 
    {
      GtkNotebook *notebook;
      gint page_num = -1;

      notebook = GTK_NOTEBOOK (widget);
      page_num = gtk_notebook_get_current_page (notebook);
      if (page_num != -1)
        {
          obj = gtk_widget_get_accessible (widget);
          obj = atk_object_ref_accessible_child (obj, page_num);
          g_object_unref (obj);
        }
    }
  else if (GTK_IS_TOGGLE_BUTTON (widget))
    {
      GtkWidget *other_widget = gtk_widget_get_parent (widget);
      if (GTK_IS_COMBO_BOX (other_widget))
        {
          gail_set_focus_widget (other_widget, widget);
          widget = other_widget;
        }
    }
  if (obj == NULL)
    {
      AtkObject *focus_object;

      obj = gtk_widget_get_accessible (widget);
      focus_object = g_object_get_qdata (G_OBJECT (obj), quark_focus_object);
      /*
       * We check whether the object for this focus_object has been deleted.
       * This can happen when navigating to an empty directory in nautilus. 
       * See bug #141907.
       */
      if (ATK_IS_GOBJECT_ACCESSIBLE (focus_object))
        {
          if (!atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (focus_object)))
            focus_object = NULL;
        }
      if (focus_object)
        obj = focus_object;
    }

  return obj;
}
Esempio n. 8
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);
    }
}
Esempio n. 9
0
AtkObject*
gail_notebook_page_new (GtkNotebook *notebook, 
                        gint        pagenum)
{
  GObject *object;
  AtkObject *atk_object;
  GailNotebookPage *page;
  GtkWidget *child;
  GtkWidget *label;
  GList *list;
  
  g_return_val_if_fail (GTK_IS_NOTEBOOK (notebook), NULL);

  child = gtk_notebook_get_nth_page (notebook, pagenum);

  if (!child)
    return NULL;

  object = g_object_new (GAIL_TYPE_NOTEBOOK_PAGE, NULL);
  g_return_val_if_fail (object != NULL, NULL);

  page = GAIL_NOTEBOOK_PAGE (object);
  page->notebook = notebook;
  g_object_add_weak_pointer (G_OBJECT (page->notebook), (gpointer *)&page->notebook);
  page->index = pagenum;
  list = g_list_nth (notebook->children, pagenum);
  page->page = list->data;
  page->textutil = NULL;
  
  atk_object = ATK_OBJECT (page);
  atk_object->role = ATK_ROLE_PAGE_TAB;
  atk_object->layer = ATK_LAYER_WIDGET;

  page->notify_child_added_id = gdk_threads_add_idle (notify_child_added, atk_object);
  /*
   * We get notified of changes to the label
   */
  label = get_label_from_notebook_page (page);
  if (GTK_IS_LABEL (label))
    {
      if (gtk_widget_get_mapped (label))
        gail_notebook_page_init_textutil (page, label);
      else
        g_signal_connect (label,
                          "map",
                          G_CALLBACK (gail_notebook_page_label_map_gtk),
                          page);
    }

  return atk_object;
}
Esempio n. 10
0
/**
 * seahorse_prefs_remove_tab:
 * @swidget: The preferences window
 * @tab: The tab to be removed
 *
 * Removes a tab from the preferences window
 **/
void 
seahorse_prefs_remove_tab (SeahorseWidget *swidget, GtkWidget *tab)
{
    GtkWidget *tabs;
    gint pos;
    
    g_return_if_fail (GTK_IS_WIDGET (tab));
    
    tabs = GTK_WIDGET (seahorse_widget_get_widget (swidget, "notebook"));
    g_return_if_fail (GTK_IS_NOTEBOOK (tabs));
    
    pos = gtk_notebook_page_num (GTK_NOTEBOOK (tabs), tab);
    if (pos != -1)
        gtk_notebook_remove_page (GTK_NOTEBOOK (tabs), pos);
}
Esempio n. 11
0
static AtkObject *
gtk_widget_accessible_get_parent (AtkObject *accessible)
{
  AtkObject *parent;
  GtkWidget *widget, *parent_widget;

  widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible));
  if (widget == NULL)
    return NULL;

  parent = accessible->accessible_parent;
  if (parent != NULL)
    return parent;

  parent_widget = gtk_widget_get_parent (widget);
  if (parent_widget == NULL)
    return NULL;

  /* For a widget whose parent is a GtkNoteBook, we return the
   * accessible object corresponding the GtkNotebookPage containing
   * the widget as the accessible parent.
   */
  if (GTK_IS_NOTEBOOK (parent_widget))
    {
      gint page_num;
      GtkWidget *child;
      GtkNotebook *notebook;

      page_num = 0;
      notebook = GTK_NOTEBOOK (parent_widget);
      while (TRUE)
        {
          child = gtk_notebook_get_nth_page (notebook, page_num);
          if (!child)
            break;
          if (child == widget)
            {
              parent = gtk_widget_get_accessible (parent_widget);
              parent = atk_object_ref_accessible_child (parent, page_num);
              g_object_unref (parent);
              return parent;
            }
          page_num++;
        }
    }
  parent = gtk_widget_get_accessible (parent_widget);
  return parent;
}
/* A tab of a browser was reordered */
static void _interface_tweaks_on_tab_reordered(InterfaceTweaks *self,
												GtkWidget *inChild,
												guint inPageNumber,
												gpointer inUserData)
{
	g_return_if_fail(IS_INTERFACE_TWEAKS(self));
	g_return_if_fail(MIDORI_IS_VIEW(inChild));
	g_return_if_fail(GTK_IS_NOTEBOOK(inUserData));

	InterfaceTweaksPrivate	*priv=self->priv;
	MidoriView				*view=MIDORI_VIEW(inChild);
	GtkNotebook				*notebook=GTK_NOTEBOOK(inUserData);
	MidoriBrowser			*browser;
	gboolean				minimized;
	gint					firstMaximizedPosition;

	/* Check if tab we should group minimized tabs to front */
	if(!priv->groupMinimizedTabs) return;

	/* Check if tab was minimized */
	minimized=FALSE;
	g_object_get(view, "minimized", &minimized, NULL);

	/* Get browser of tab */
	browser=midori_browser_get_for_widget(GTK_WIDGET(view));
	if(!browser) return;

	/* Find position of first maximized tab */
	firstMaximizedPosition=_interface_tweak_get_browser_first_maximized_tab_position(browser, view);

	/* If tab is maximized then it moves away from front and
	 * the position must be decreased by one to get the first maximized tab
	 */
	if(!minimized) firstMaximizedPosition--;

	/* Reorder tab now */
	if(firstMaximizedPosition<0) firstMaximizedPosition=0;
	if((minimized==TRUE && inPageNumber>=firstMaximizedPosition) ||
		(minimized==FALSE && inPageNumber<firstMaximizedPosition))
	{
		g_signal_handlers_block_by_func(view, G_CALLBACK(_interface_tweaks_on_notify_minimized_tab_for_group_tabs), self);

		gtk_notebook_reorder_child(GTK_NOTEBOOK(notebook), GTK_WIDGET(view), firstMaximizedPosition);

		g_signal_handlers_unblock_by_func(view, G_CALLBACK(_interface_tweaks_on_notify_minimized_tab_for_group_tabs), self);
	}
}
Esempio n. 13
0
void
setup(GtkWidget *widget)
{
    QTC_RET_IF_FAIL(widget);
    GtkWidget *parent = nullptr;

    if (GTK_IS_WINDOW(widget) &&
        !gtk_window_get_decorated(GTK_WINDOW(widget))) {
        return;
    }

    if (GTK_IS_EVENT_BOX(widget) &&
        gtk_event_box_get_above_child(GTK_EVENT_BOX(widget)))
        return;

    parent = gtk_widget_get_parent(widget);

    // widgets used in tabs also must be ignored (happens, unfortunately)
    if (GTK_IS_NOTEBOOK(parent) && Tab::isLabel(GTK_NOTEBOOK(parent), widget))
        return;

    /*
      check event mask (for now we only need to do that for GtkWindow)
      The idea is that if the window has been set to receive button_press
      and button_release events (which is not done by default), it likely
      means that it does something with such events, in which case we should
      not use them for grabbing
    */
    if (oneOf(gTypeName(widget), "GtkWindow") &&
        (gtk_widget_get_events(widget) &
         (GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK)))
        return;

    GtkWidgetProps props(widget);
    if (!isFakeGtk() && !props->wmMoveHacked) {
        props->wmMoveHacked = true;
        gtk_widget_add_events(widget, GDK_BUTTON_RELEASE_MASK |
                              GDK_BUTTON_PRESS_MASK | GDK_LEAVE_NOTIFY_MASK |
                              GDK_BUTTON1_MOTION_MASK);
        registerBtnReleaseHook();
        props->wmMoveDestroy.conn("destroy-event", destroy);
        props->wmMoveStyleSet.conn("style-set", styleSet);
        props->wmMoveMotion.conn("motion-notify-event", motion);
        props->wmMoveLeave.conn("leave-notify-event", leave);
        props->wmMoveButtonPress.conn("button-press-event", buttonPress);
    }
}
Esempio n. 14
0
void
dialog_tool_preset_to_range (GenericToolState *state)
{
	GnmRange const *sel;
	GtkWidget *w;

	g_return_if_fail (state != NULL);
	g_return_if_fail (state->gdao != NULL);

	sel = selection_first_range (state->sv, NULL, NULL);
	gnm_dao_load_range (GNM_DAO (state->gdao), sel);
	gnm_dao_focus_output_range (GNM_DAO (state->gdao));

	w = glade_xml_get_widget (state->gui, "notebook1");
	g_return_if_fail (w && GTK_IS_NOTEBOOK (w));
	gtk_notebook_set_current_page (GTK_NOTEBOOK(w), 0);
}
Esempio n. 15
0
static void cl_get_window_style_state (GtkWidget *widget, GtkStyle **style, GtkStateType *state_type)
{
	GtkStyle *windowstyle = NULL;
	GtkWidget *tmpwidget = widget;
	GtkStateType windowstate;
	
	if (widget && GTK_IS_ENTRY (widget))
		tmpwidget = tmpwidget->parent;
	
	while (tmpwidget && GTK_WIDGET_NO_WINDOW (tmpwidget) && !GTK_IS_NOTEBOOK(tmpwidget))
	{
		tmpwidget = tmpwidget->parent;
	}

	*style     = tmpwidget->style;
	*state_type = GTK_WIDGET_STATE(tmpwidget);
}
Esempio n. 16
0
void
on_clear_history_activate (gpointer notebook, GtkWidget *menu_item)
{
	Netinfo *netinfo;

	g_return_if_fail (GTK_IS_NOTEBOOK (notebook));

	/* Pages all share a history id for host entry except whois */
	netinfo = g_object_get_data (G_OBJECT (notebook), "pinger");
	gn_combo_history_clear (netinfo->history);

	netinfo = g_object_get_data (G_OBJECT (notebook), "finger");
	gn_combo_history_clear (netinfo->history);
	gn_combo_history_clear (netinfo->history_user);

	netinfo = g_object_get_data (G_OBJECT (notebook), "whois");
	gn_combo_history_clear (netinfo->history);
}
Esempio n. 17
0
void
on_copy_activate (gpointer notebook, GtkWidget *menu_item)
{
	gint page;
	Netinfo *netinfo;

	g_return_if_fail (GTK_IS_NOTEBOOK (notebook));

	page = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));

	netinfo = get_netinfo_for_page (GTK_NOTEBOOK (notebook), page);
	if (!netinfo)
		return;

	if (netinfo->copy_output != NULL) {
		(netinfo->copy_output) ((gpointer) netinfo, NULL);
	}
}
Esempio n. 18
0
static bool
useEvent(GtkWidget *widget, GdkEventButton *event)
{
    if(lastRejectedEvent && lastRejectedEvent==event)
        return false;

    if(!GTK_IS_CONTAINER(widget))
        return true;

    // if widget is a notebook, accept if there is no hovered tab
    if (GTK_IS_NOTEBOOK(widget)) {
        return (!Tab::hasVisibleArrows(GTK_NOTEBOOK(widget)) &&
                Tab::currentHoveredIndex(widget) == -1 &&
                childrenUseEvent(widget, event, false));
    } else {
        return childrenUseEvent(widget, event, false);
    }
}
Esempio n. 19
0
    //____________________________________________________________________________________________
    gboolean Animations::realizationHook( GSignalInvocationHint*, guint, const GValue* params, gpointer data )
    {

        // get widget from params
        GtkWidget* widget( GTK_WIDGET( g_value_get_object( params ) ) );

        // check type
        if( !GTK_IS_WIDGET( widget ) ) return FALSE;

        if( GTK_IS_NOTEBOOK( widget ) )
        { gtk_notebook_set_show_border( GTK_NOTEBOOK(widget), FALSE ); }

        #if ENABLE_GROUPBOX_HACK
        if( GTK_IS_LABEL( widget ) &&  GTK_IS_FRAME( gtk_widget_get_parent( widget ) ) )
        {

            GtkFrame *frame( GTK_FRAME( gtk_widget_get_parent( widget ) ) );
            if( widget == gtk_frame_get_label_widget( frame ) && !Gtk::gtk_widget_find_parent( widget, "GtkPizza" ) )
            {
                #if OXYGEN_DEBUG
                std::cout
                    << "Oxygen::Animations::realizationHook -"
                    << " widget: " << widget << " (" << G_OBJECT_TYPE_NAME( widget ) << ")"
                    << " parent: " << frame << " (" << G_OBJECT_TYPE_NAME( frame ) << ")"
                    << std::endl;
                #endif

                // modify alignment
                gtk_frame_set_label_align( frame, 0.5, 0.0 );
                gtk_frame_set_shadow_type( frame, GTK_SHADOW_OUT );

                // register to engine
                Animations& animations( *static_cast<Animations*>(data) );
                animations.groupBoxLabelEngine().registerWidget( widget );
                animations.groupBoxLabelEngine().adjustSize( widget );

            }

        }
        #endif

        return TRUE;

    }
/**
 * hildon_wizard_dialog_new:
 * @parent: a #GtkWindow
 * @wizard_name: the name of dialog
 * @notebook: the notebook to be shown on the dialog
 *
 * Creates a new #HildonWizardDialog.
 *
 * Returns: a new #HildonWizardDialog
 */
GtkWidget*
hildon_wizard_dialog_new                        (GtkWindow *parent,
                                                 const char *wizard_name,
                                                 GtkNotebook *notebook)
{
    GtkWidget *widget;

    g_return_val_if_fail (GTK_IS_NOTEBOOK (notebook), NULL);

    widget = GTK_WIDGET (g_object_new
            (HILDON_TYPE_WIZARD_DIALOG,
             "wizard-name", wizard_name,
             "wizard-notebook", notebook, NULL));

    if (parent)
        gtk_window_set_transient_for (GTK_WINDOW (widget), parent);

    return widget;
}
Esempio n. 21
0
static void
gnc_prefs_sort_pages (GtkNotebook *notebook)
{
    gint n_pages, i;
    GList *tabs = NULL, *iter = NULL;

    g_return_if_fail (GTK_IS_NOTEBOOK (notebook));

    /* gather tabs */
    n_pages = gtk_notebook_get_n_pages (notebook);
    for (i = n_pages - 1; i >= 0; i--)
        tabs = g_list_prepend (tabs, gtk_notebook_get_nth_page (notebook, i));

    /* sort in local copy */
    tabs = g_list_sort_with_data (tabs, (GCompareDataFunc) tab_cmp, notebook);

    /* reorder tabs */
    for (i = 0, iter = tabs; iter; i++, iter = iter->next)
        gtk_notebook_reorder_child (notebook, GTK_WIDGET (iter->data), i);

    g_list_free (tabs);
}
Esempio n. 22
0
    //_____________________________________________
    GdkRectangle TabWidgetStateData::dirtyRect( void ) const
    {

        // FIXME: it might be enough to union the rects of the current and previous tab
        if( GTK_IS_NOTEBOOK( _target ) )
        {

            GdkRectangle rect( Gtk::gdk_rectangle() );
            Gtk::gtk_notebook_get_tabbar_rect( GTK_NOTEBOOK( _target ), &rect );

            #if OXYGEN_DEBUG
            std::cerr << "Oxygen::TabWidgetData::dirtyRect - " << rect << std::endl;
            #endif

            return rect;

        } else {

            return Gtk::gtk_widget_get_allocation( _target );

        }

    }
Esempio n. 23
0
static bool
withinWidget(GtkWidget *widget, GdkEventButton *event)
{
    // get top level widget
    GtkWidget *topLevel=gtk_widget_get_toplevel(widget);;
    GdkWindow *window = topLevel ? gtk_widget_get_window(topLevel) : nullptr;

    if (window) {
        QtcRect allocation;
        int           wx=0, wy=0, nx=0, ny=0;

        // translate widget position to topLevel
        gtk_widget_translate_coordinates(widget, topLevel, wx, wy, &wx, &wy);

        // translate to absolute coordinates
        gdk_window_get_origin(window, &nx, &ny);
        wx += nx;
        wy += ny;

        // get widget size.
        // for notebooks, only consider the tabbar rect
        if (GTK_IS_NOTEBOOK(widget)) {
            QtcRect widgetAlloc = Widget::getAllocation(widget);
            allocation = Tab::getTabbarRect(GTK_NOTEBOOK(widget));
            allocation.x += wx - widgetAlloc.x;
            allocation.y += wy - widgetAlloc.y;
        } else {
            allocation = Widget::getAllocation(widget);
            allocation.x = wx;
            allocation.y = wy;
        }

        return allocation.x<=event->x_root && allocation.y<=event->y_root &&
            (allocation.x+allocation.width)>event->x_root && (allocation.y+allocation.height)>event->y_root;
    }
    return true;
}
Esempio n. 24
0
void
pannode_delete (struct pan_node *xq)
{
  gint id;

  acc_debug ("delete accxq: %p\n", xq);

  if (xq->accxq && xq->accxq->panlist)
    {
      xq->accxq->panlist = g_list_remove (xq->accxq->panlist, xq);
    }

  if (GTK_IS_NOTEBOOK (xq->parent))
    {
      id = gtk_notebook_page_num (GTK_NOTEBOOK (xq->parent), xq->widget);
      gtk_notebook_remove_page (GTK_NOTEBOOK (xq->parent), id);
    }

  if (xq->qipu)
    {
      qipu_destroy (xq->qipu);
    }

  g_list_free (xq->cur_moves);
  xq->cur_moves = NULL;

  if (xq->parterthread)
    {
      g_thread_join (xq->parterthread);
    }
  session_delete (xq->session);
  if (xq->name)
    {
      g_free (xq->name);
    }
  free (xq);
}
Esempio n. 25
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);
}
Esempio n. 26
0
static AtkObject*
gail_get_accessible_for_widget (GtkWidget *widget,
                                gboolean  *transient)
{
  AtkObject *obj = NULL;
  GType gnome_canvas;

  gnome_canvas = g_type_from_name ("GnomeCanvas");

  *transient = FALSE;
  if (!widget)
    return NULL;

  if (GTK_IS_ENTRY (widget))
    {
      GtkWidget *other_widget = widget->parent;
      if (GTK_IS_COMBO (other_widget))
        {
          gail_set_focus_widget (other_widget, widget);
          widget = other_widget;
        }
    } 
  else if (GTK_IS_NOTEBOOK (widget)) 
    {
      GtkNotebook *notebook;
      gint page_num = -1;

      notebook = GTK_NOTEBOOK (widget);
      /*
       * Report the currently focused tab rather than the currently selected tab
       */
      if (notebook->focus_tab)
        {
          page_num = g_list_index (notebook->children, notebook->focus_tab->data);
        }
      if (page_num != -1)
        {
          obj = gtk_widget_get_accessible (widget);
          obj = atk_object_ref_accessible_child (obj, page_num);
          g_object_unref (obj);
        }
    }
  else if (GTK_CHECK_TYPE ((widget), gnome_canvas))
    {
      GObject *focused_item;
      GValue value = {0, };

      g_value_init (&value, G_TYPE_OBJECT);
      g_object_get_property (G_OBJECT (widget), "focused_item", &value);
      focused_item = g_value_get_object (&value);

      if (focused_item)
        {
          AtkObject *tmp;

          obj = atk_gobject_accessible_for_object (G_OBJECT (focused_item));
          tmp = g_object_get_qdata (G_OBJECT (obj), quark_focus_object);
          if (tmp != NULL)
            obj = tmp;
        }
    }
  else if (GTK_IS_TOGGLE_BUTTON (widget))
    {
      GtkWidget *other_widget = widget->parent;
      if (GTK_IS_COMBO_BOX (other_widget))
        {
          gail_set_focus_widget (other_widget, widget);
          widget = other_widget;
        }
    }
  if (obj == NULL)
    {
      AtkObject *focus_object;

      obj = gtk_widget_get_accessible (widget);
      focus_object = g_object_get_qdata (G_OBJECT (obj), quark_focus_object);
      /*
       * We check whether the object for this focus_object has been deleted.
       * This can happen when navigating to an empty directory in nautilus. 
       * See bug #141907.
       */
      if (ATK_IS_GOBJECT_ACCESSIBLE (focus_object))
        {
          if (!atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (focus_object)))
            focus_object = NULL;
        }
      if (focus_object)
        obj = focus_object;
    }

  return obj;
}
Esempio n. 27
0
/*!
  \brief bind_data() is a recursive function that is called for every container
  widget in a glade frame and it's purpose is to search the datamap file passed
  for the widget names in the glade file and if it's fond in the datamap to
  load all the attribues listed and bind them to the object using GTK+'s
  object model.
  \param widget is the widget passed to load attributes on
  \param user_data is the pointer to a BingGroup structure.
  */
G_MODULE_EXPORT void bind_data(GtkWidget *widget, gpointer user_data)
{
	BindGroup *bindgroup = (BindGroup *)user_data;
	ConfigFile *cfgfile = bindgroup->cfgfile;
	GHashTable *groups = bindgroup->groups;
	gchar * tmpbuf = NULL;
	gchar * section = NULL;
	gchar ** keys = NULL;
	gint num_keys = 0;
	gint offset = 0;
	gint page = 0;
	gint index = 0;
	gchar * initializer = NULL;
	GdkColor color;
	gchar *size = NULL;
	gint count = 0;
	gint tmpi = 0;
	gboolean hidden = FALSE;
	gchar *ptr = NULL;
	gchar **vector = NULL;
	gchar **vec2 = NULL;
	void (*func)(void) = NULL;
	GList *list = NULL;
	GList *list2 = NULL;
	const gchar *name = NULL;
	gboolean indexed = FALSE;
	Firmware_Details *firmware = NULL;
	GList ***ecu_widgets = NULL;
	GList *tab_widgets = NULL;
	void (*load_dep_obj)(GObject *, ConfigFile *,const gchar *,const gchar *) = NULL;

	ENTER();
	MTXDBG(TABLOADER,_("Entered"));
	ecu_widgets = (GList ***)DATA_GET(global_data,"ecu_widgets");
	firmware = (Firmware_Details *)DATA_GET(global_data,"firmware");

	g_return_if_fail(ecu_widgets);
	g_return_if_fail(firmware);

	if (!GTK_IS_WIDGET(widget))
	{
		EXIT();
		return;
	}

	if (GTK_IS_WIDGET(widget))
		if (GTK_IS_CONTAINER(widget))
			gtk_container_foreach(GTK_CONTAINER(widget),bind_data,user_data);
	name = gtk_widget_get_name(widget);
	if (!name)
	{
		EXIT();
		return;
	}

	if (NULL != (ptr = g_strrstr_len(name,strlen(name),"_of_")))
	{
		indexed = TRUE;
		ptr = g_strrstr_len(name,ptr-name,"_");
		tmpbuf = g_strdelimit(g_strdup(ptr),"_",' ');
		section = g_strndup(name,ptr-name);
		/*printf("(indexed) section is %s\n",section);*/
		gint result = sscanf(tmpbuf,"%d of %d",&index,&count);
		/*printf("sscanf result %i\n",result);*
		* printf("Found indexed value for \"%s\", index %i, count %i\n",tmpbuf,index,count);
		*/
		g_free(tmpbuf);
	}
	else
		section = g_strdup(name);

	if(cfg_read_string(cfgfile, section, "keys", &tmpbuf))
	{
		keys = parse_keys(tmpbuf,&num_keys,",");
		MTXDBG(TABLOADER,_("Number of keys for %s is %i\n"),section,num_keys);
		g_free(tmpbuf);
	}
	else 
	{
		g_free(section);
		EXIT();
		return;
	}

	page = -1;
	/* Store ptr to self in qdata, needed for bind_to_lists from groups*/
	OBJ_SET(widget,"self",widget);
	/* Bind the data in the "defaults" group per tab to EVERY var in that
	 * tab
	 */
	page = bind_group_data(cfgfile, G_OBJECT(widget), groups, "defaults");

	if(cfg_read_string(cfgfile, section, "group", &tmpbuf))
	{
		page = bind_group_data(cfgfile,G_OBJECT(widget),groups,tmpbuf);
		g_free(tmpbuf);
	}

	if ((!cfg_read_int(cfgfile, section, "page", &page)) && (page == -1))
	{
		MTXDBG(TABLOADER|CRITICAL,_("Object %s doesn't have a page assigned!!!!\n"),section);	

	}
	/* Bind widgets to lists if they have the bind_to_list flag set...
	 */
	tmpbuf = NULL;
	if (cfg_read_string(cfgfile, section, "bind_to_list", &tmpbuf))
	{
		bind_to_lists(widget, tmpbuf);
		g_free(tmpbuf);
	}
	if (cfg_read_boolean(cfgfile,section,"ellipsize",&tmpi))
	{
		if ((GTK_IS_LABEL(widget)) && (tmpi))
		{
			OBJ_SET(widget,"ellipsize_preferred",GINT_TO_POINTER(TRUE));
			if (DATA_GET(global_data,"ellipsize_tabs"))
				gtk_label_set_ellipsize(GTK_LABEL(widget),PANGO_ELLIPSIZE_END);
		}
	}

	/* Color selections */
	if (cfg_read_string(cfgfile, section, "active_fg", &tmpbuf))
	{
		gdk_color_parse(tmpbuf, &color);
		gtk_widget_modify_fg(widget, GTK_STATE_NORMAL, &color);
		g_free(tmpbuf);
	}
	if (cfg_read_string(cfgfile, section, "inactive_fg", &tmpbuf))
	{
		gdk_color_parse(tmpbuf, &color);
		gtk_widget_modify_fg(widget, GTK_STATE_INSENSITIVE, &color);
		g_free(tmpbuf);
	}

	/* If this widget has a "depend_on" tag we need to load the dependancy
	 * information  and store it for use when needed...
	 */
	if (cfg_read_string(cfgfile,section,"depend_on",&tmpbuf))
	{
		if (get_symbol("load_dependencies_obj",(void **)&load_dep_obj))
			load_dep_obj(G_OBJECT(widget),cfgfile,section,"depend_on");
		g_free(tmpbuf);
	}

	/* If this widget (a textview) has "create_tags" we call a special
	 * handler just for that..
	 */
	if (cfg_read_string(cfgfile,section,"create_tags",&tmpbuf))
	{
		load_tags(G_OBJECT(widget),cfgfile,section);
		g_free(tmpbuf);
	}

	/* If this widget has "tooltip" set the tip on the widget */
	if (cfg_read_string(cfgfile,section,"tooltip",&tmpbuf))
	{
		gtk_widget_set_tooltip_text(widget,tmpbuf);
		g_free(tmpbuf);
	}

	/* If this widget (a label) has "set_label" we set the label on it
	 */
	if (cfg_read_string(cfgfile,section,"set_label",&tmpbuf))
	{
/*		printf("setting label on %s to \"%s\"\n",glade_get_widget_name(widget),tmpbuf);*/
		gtk_label_set_text(GTK_LABEL(widget),tmpbuf);
		g_free(tmpbuf);
	}

	/* If this widget is temp dependant, set the current units on it 
	 */
	if (cfg_read_string(cfgfile,section,"temp_dep",&tmpbuf))
	{
		OBJ_SET(widget,"widget_temp",DATA_GET(global_data,"mtx_temp_units"));
		g_free(tmpbuf);
	}

	/* If this widget has "register_as", register it with the supplied name
	 */
	if (cfg_read_string(cfgfile,section,"register_as",&tmpbuf))
	{
		register_widget(tmpbuf,widget);
		g_free(tmpbuf);
	}
	/* If this widget has visible_functions defined */
	if (cfg_read_string(cfgfile,section,"visible_functions",&tmpbuf))
	{
		vector = g_strsplit(tmpbuf,",",-1);
		g_free(tmpbuf);
		for (guint i=0;i<g_strv_length(vector);i++)
		{
			vec2 = g_strsplit(vector[i],":",2);
			if (g_strv_length(vec2) != 2)
			{
				printf("ERROR in %s, visible_functions param is missing the framerate parameter (func:fps)\n",cfgfile->filename);
				g_strfreev(vec2);
				continue;
			}
			gint fps = (GINT)g_strtod(vec2[1],NULL);
			get_symbol(vec2[0],(void **)&func);
			if (func)
			{
				list = g_list_prepend(list,(gpointer)func);
				list2 = g_list_prepend(list2,GINT_TO_POINTER(fps));
			}
			g_strfreev(vec2);
		}
		g_strfreev(vector);
		OBJ_SET_FULL(widget,"func_list",list,g_list_free);
		OBJ_SET_FULL(widget,"func_fps_list",list2,g_list_free);
	}

	/* If this widget has "initializer" there's a global variable 
	 * with it's name on it 
	 */
	if (cfg_read_string(cfgfile,section,"initializer",&initializer))
	{
		gint widget_type = 0;
		if (!cfg_read_string(cfgfile,section,"widget_type",&tmpbuf))
			MTXDBG(TABLOADER|CRITICAL,_("Object %s has initializer, but no widget_type!!!!\n"),section);
		else
			widget_type = translate_string(tmpbuf);
		g_free(tmpbuf);
		switch (widget_type)
		{
			case MTX_RANGE:
				gtk_range_set_value(GTK_RANGE(widget),(GINT)DATA_GET(global_data,initializer));
				break;

			case MTX_SPINBUTTON:
				gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget),(GINT)DATA_GET(global_data,initializer));
				break;
			case MTX_ENTRY:
				gtk_entry_set_text(GTK_ENTRY(widget),(gchar *)DATA_GET(global_data,initializer));

			default:
				break;

		}
		g_free(initializer);
	}
	/* Hidden widgets have special handlers and should NOT be updated normally */
	cfg_read_boolean(cfgfile,section, "hidden", &hidden);
	offset = -1;
	cfg_read_int(cfgfile,section, "offset", &offset);
	if (offset >= 0 && indexed)
	{
		/*printf("indexed widget %s\n",name); */
		if (cfg_read_string(cfgfile, section, "size", &size))
		{
			offset += index * get_multiplier ((DataSize)translate_string (size));
			g_free(size);
		}
		else
		{
			if(OBJ_GET(widget, "size"))
			{
				offset += index * get_multiplier ((DataSize)(GINT)OBJ_GET(widget, "size"));
			}
			else
			{
				MTXDBG(TABLOADER|CRITICAL,_("Indexed Object %s has index and offset, but no size!!!!\n"),section);
				g_free(section);
				EXIT();
				return;
			}
		}
		/*printf("widget %s, offset %i\n",name,offset);*/
		OBJ_SET(widget,"offset",GINT_TO_POINTER(offset));
	}
	if (offset >= 0)
	{
		/* The way we do it now is to STORE widgets in LISTS for each
		 * offset, thus we can have multiple on screen controls bound
		 * to single data offset in the ECU
		 */
		if (page < 0)
		{
			MTXDBG(TABLOADER|CRITICAL,_("Attempting to append widget beyond bounds of Firmware Parameters,  there is a bug with this datamap widget %s, page %i, at offset %i...\n\n"),section,page,offset);
			g_free(section);
			EXIT();
			return;
		}
		if (page < firmware->total_pages)
		{
			if (offset >= firmware->page_params[page]->length)
				MTXDBG(TABLOADER|CRITICAL,_("Attempting to append widget beyond bounds of Firmware Parameters,  there is a bug with this datamap widget %s, at offset %i...\n\n"),section,offset);
			else if (!hidden)
			{

				tab_widgets = OBJ_GET(bindgroup->topframe,"tab_widgets");
				tab_widgets = g_list_prepend(tab_widgets, widget);
				OBJ_SET(bindgroup->topframe,"tab_widgets",tab_widgets);
				ecu_widgets[page][offset] = g_list_prepend(
						ecu_widgets[page][offset],
						(gpointer)widget);
			}
		}
		else
			MTXDBG(TABLOADER|CRITICAL,_("Attempting to append widget beyond bounds of Firmware Parameters, there is a bug with this datamap for widget %s, at page %i offset %i...\n\n"),section,page,offset);
	}

	/* If there is a "group" key in a section it means that it gets the
	 * rest of it's setting from the groupname listed.  This reduces
	 * redundant keys all throughout the file...
	 */
	bind_keys(G_OBJECT(widget), cfgfile, section, keys, num_keys);
	g_strfreev(keys);

	/* If this widget has the "choices" key (combobox)
	 */
	if (cfg_read_string(cfgfile,section,"choices",&tmpbuf))
	{
		combo_setup(G_OBJECT(widget),cfgfile,section);
		g_free(tmpbuf);
	}

	if (cfg_read_string(cfgfile,section,"post_functions_with_arg",&tmpbuf))
	{
		run_post_functions_with_arg(tmpbuf,widget);
		g_free(tmpbuf);
	}
	if (cfg_read_string(cfgfile,section,"post_functions",&tmpbuf))
	{
		run_post_functions(tmpbuf);
		g_free(tmpbuf);
	}
	if (cfg_read_boolean(cfgfile,section,"show_widget",&tmpi))
	{
		if (tmpi)
			gtk_widget_show(widget);
		else
			gtk_widget_hide(widget);
	}
	if (cfg_read_string(cfgfile,section,"set_tab_labels",&tmpbuf))
	{
		if (GTK_IS_NOTEBOOK(widget))
		{
			vector=g_strsplit(tmpbuf,",",-1);
			if (gtk_notebook_get_n_pages(GTK_NOTEBOOK(widget)) == g_strv_length(vector))
			{
				for (int i=0;i<g_strv_length(vector);i++)
				{
					gtk_notebook_set_tab_label_text(GTK_NOTEBOOK(widget),
							gtk_notebook_get_nth_page(GTK_NOTEBOOK(widget),i),
							vector[i]);
				}
			}
			g_strfreev(vector);
		}
		g_free(tmpbuf);
	}
	g_free(section);
	MTXDBG(TABLOADER,_("Leaving"));
	EXIT();
	return;
}
Esempio n. 28
0
/* Draw a normal (toggle)button. Not spinbuttons.*/ 
void cl_draw_button(GtkStyle *style, GdkWindow *window,
                    GtkStateType state_type, GtkShadowType shadow_type,
                    GdkRectangle *area,
                    GtkWidget *widget, const gchar *detail,
                    gint x, gint y, gint width, gint height)
{
	ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE(style);
	int my_state_type = (state_type == GTK_STATE_ACTIVE) ? 2 : 0;
	GdkGC *bg_gc = NULL;
	gboolean is_active = FALSE;
	CLRectangle r;
	
	/* Get the background color of the window we're on */
	bg_gc = cl_get_window_bg_gc(widget);
	
	cl_rectangle_set_button (&r, style, state_type,
	                         GTK_WIDGET_HAS_DEFAULT (widget),
	                         GTK_WIDGET_HAS_FOCUS (widget),
	                         CL_CORNER_ROUND, CL_CORNER_ROUND,
	                         CL_CORNER_ROUND, CL_CORNER_ROUND);
		
	if (state_type == GTK_STATE_ACTIVE)
		is_active = TRUE;

	if (GTK_IS_TOGGLE_BUTTON(widget) &&
	    gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget)) &&
	    state_type == GTK_STATE_PRELIGHT)
	{
		cl_rectangle_set_gradient (&r.fill_gradient, &clearlooks_style->shade[1], &clearlooks_style->shade[1]);
		r.topleft     = clearlooks_style->shade_gc[3];
		r.bottomright = clearlooks_style->shade_gc[1];
		
		is_active = TRUE;
	}	

	if (!is_active)
		r.fillgc = NULL;
		
	if (!GTK_IS_NOTEBOOK (widget->parent))
	{
		gdk_draw_rectangle (window, bg_gc, FALSE, x, y, width-1, height-1);
	
		/* Draw "sunken" look when border thickness is more than 2 pixels. */
		if (style->xthickness > 2 && style->ythickness > 2)
		cl_draw_inset (style, window, widget, area, x, y, width, height,
		               CL_CORNER_ROUND, CL_CORNER_ROUND,
		               CL_CORNER_ROUND, CL_CORNER_ROUND);
	}
	
	/* Draw "sunken" look when border thickness is more than 2 pixels.*/
	if (style->xthickness > 2 && style->ythickness > 2)
	{
		x++;
		y++;
		height-=2;
		width-=2;
	}
	
	/* Don't draw the normal gradient for normal buttons. */

	cl_rectangle_set_clip_rectangle (&r, area);
	cl_draw_rectangle (window, widget, style, x, y, width, height, &r);
	
	
	if (!is_active) 
	{
		int tmp_height = (float)height*0.25;
	
		gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area);
		
		draw_hgradient (window, style->bg_gc[state_type], style,
		                x+2,y+2,width-4,tmp_height,
		                &clearlooks_style->button_g1[state_type],
			            &clearlooks_style->button_g2[state_type]);
		
		draw_hgradient (window, style->bg_gc[state_type], style,
		                x+2, y+2+tmp_height, width-4, height-3-tmp_height*2,
		                &clearlooks_style->button_g2[state_type],
			            &clearlooks_style->button_g3[state_type]);
		
		draw_hgradient (window, style->bg_gc[state_type], style,
		                x+2,y+height-tmp_height-1,width-4,tmp_height,
		                &clearlooks_style->button_g3[state_type],
			            &clearlooks_style->button_g4[state_type]);

		gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL);
	}				
	
	cl_draw_shadow    (window, widget, style, x, y, width, height, &r);
	cl_rectangle_reset_clip_rectangle (&r);
}
Esempio n. 29
0
void
dialog_so_styled (WBCGtk *wbcg, GObject *so, GOStyle *default_style,
		  char const *title, so_styled_t extent)
{
	DialogSOStyled *state;
	GtkWidget	*dialog, *help, *editor;
	GOStyle *style;

	/* Only pop up one copy per workbook */
	if (gnm_dialog_raise_if_exists (wbcg, GNM_SO_STYLED_KEY)) {
		g_object_unref (default_style);
		return;
	}

	state = g_new0 (DialogSOStyled, 1);
	state->so    = G_OBJECT (so);
	state->wbcg  = wbcg;
	state->orig_props = go_object_properties_collect (so);
	force_new_style (state->so);

	dialog = gtk_dialog_new_with_buttons
		(title,
		 wbcg_toplevel (state->wbcg),
		 GTK_DIALOG_DESTROY_WITH_PARENT,
		 NULL, NULL);
	state->extent = extent;

	gnm_dialog_setup_destroy_handlers (GTK_DIALOG (dialog),
					   state->wbcg,
					   GNM_DIALOG_DESTROY_CURRENT_SHEET_REMOVED);

	help = gtk_dialog_add_button (GTK_DIALOG (dialog),
		GTK_STOCK_HELP,		GTK_RESPONSE_HELP);
	gnm_init_help_button (help, "sect-graphics-drawings");

	gtk_dialog_add_buttons (GTK_DIALOG (dialog),
		GNM_STOCK_CANCEL,	GTK_RESPONSE_CANCEL,
		GNM_STOCK_OK,		GTK_RESPONSE_OK,
		NULL);

	g_object_get (so, "style", &style, NULL);
	editor = go_style_get_editor (style, default_style,
				      GO_CMD_CONTEXT (wbcg), G_OBJECT (so));
	g_object_unref (style);

	gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
		editor, TRUE, TRUE, TRUE);
	g_object_unref (default_style);

	if (extent & SO_STYLED_TEXT) {
		GtkWidget *text_w = dialog_so_styled_text_widget (state);
		gtk_widget_show_all (text_w);
		if (GTK_IS_NOTEBOOK (editor))
			gtk_notebook_append_page (GTK_NOTEBOOK (editor),
						  text_w,
						  gtk_label_new (_("Content")));
		else
			gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
					    text_w, TRUE, TRUE, TRUE);
	}

	if (extent & SO_STYLED_LINE) {
		GtkWidget *w = dialog_so_styled_line_widget (state, "end-arrow");
		gtk_widget_show_all (w);
		if (GTK_IS_NOTEBOOK (editor))
			gtk_notebook_append_page (GTK_NOTEBOOK (editor), w,
						  gtk_label_new (_("Head")));
		else
			gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
					    w, TRUE, TRUE, TRUE);
	}

	if (extent & SO_STYLED_LINE) {
		GtkWidget *w = dialog_so_styled_line_widget (state, "start-arrow");
		gtk_widget_show_all (w);
		if (GTK_IS_NOTEBOOK (editor))
			gtk_notebook_append_page (GTK_NOTEBOOK (editor), w,
						  gtk_label_new (_("Tail")));
		else
			gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
					    w, TRUE, TRUE, TRUE);
	}

	g_signal_connect (G_OBJECT (dialog), "response",
		G_CALLBACK (cb_dialog_so_styled_response), state);
	gnm_keyed_dialog (state->wbcg, GTK_WINDOW (dialog),
		GNM_SO_STYLED_KEY);
	g_object_set_data_full (G_OBJECT (dialog),
		"state", state, (GDestroyNotify) dialog_so_styled_free);
	go_gtk_nonmodal_dialog (wbcg_toplevel (state->wbcg),
		GTK_WINDOW (dialog));
	wbc_gtk_attach_guru (state->wbcg, dialog);
	gtk_widget_show (dialog);
}