Example #1
0
/*
 * Gets the properties of the widget. This is used for both displaying the
 * properties in the property editor, and also for saving the properties.
 */
static void
gb_handle_box_get_properties(GtkWidget *widget, GbWidgetGetArgData *data)
{
  gint i;

  for (i = 0; i < sizeof (GbShadowValues) / sizeof (GbShadowValues[0]); i++)
    {
      if (GbShadowValues[i] == GTK_HANDLE_BOX (widget)->shadow_type)
	gb_widget_output_choice (data, Shadow, i, GbShadowSymbols[i]);
    }

  for (i = 0; i < sizeof (GbPositionValues) / sizeof (GbPositionValues[0]);
       i++)
    {
      if (GbPositionValues[i] == GTK_HANDLE_BOX (widget)->handle_position)
	gb_widget_output_choice (data, Position, i, GbPositionSymbols[i]);
    }

  for (i = 0; i < sizeof (GbPositionValues) / sizeof (GbPositionValues[0]);
       i++)
    {
      if (GbPositionValues[i] == GTK_HANDLE_BOX (widget)->snap_edge)
	gb_widget_output_choice (data, SnapEdge, i, GbPositionSymbols[i]);
    }
}
Example #2
0
/*
 * Sets the properties of the widget. This is used for both applying the
 * properties changed in the property editor, and also for loading.
 */
static void
gb_handle_box_set_properties(GtkWidget *widget, GbWidgetSetArgData *data)
{
  gchar *shadow, *position, *snap_edge;
  gint i;

  shadow = gb_widget_input_choice (data, Shadow);
  if (data->apply)
    {
      for (i = 0; i < sizeof (GbShadowValues) / sizeof (GbShadowValues[0]);
	   i++)
	{
	  if (!strcmp (shadow, GbShadowChoices[i])
	      || !strcmp (shadow, GbShadowSymbols[i]))
	    {
	      gtk_handle_box_set_shadow_type (GTK_HANDLE_BOX (widget),
					      GbShadowValues[i]);
	      break;
	    }
	}
    }

  position = gb_widget_input_choice (data, Position);
  if (data->apply)
    {
      for (i = 0; i < sizeof (GbPositionValues) / sizeof (GbPositionValues[0]);
	   i++)
	{
	  if (!strcmp (position, GbPositionChoices[i])
	      || !strcmp (position, GbPositionSymbols[i]))
	    {
	      gtk_handle_box_set_handle_position (GTK_HANDLE_BOX (widget),
						  GbPositionValues[i]);
	      break;
	    }
	}
    }

  snap_edge = gb_widget_input_choice (data, SnapEdge);
  if (data->apply)
    {
      for (i = 0; i < sizeof (GbPositionValues) / sizeof (GbPositionValues[0]);
	   i++)
	{
	  if (!strcmp (snap_edge, GbPositionChoices[i])
	      || !strcmp (snap_edge, GbPositionSymbols[i]))
	    {
	      gtk_handle_box_set_snap_edge (GTK_HANDLE_BOX (widget),
					    GbPositionValues[i]);
	      break;
	    }
	}
    }
}
GtkWidget *
nh_message_new()
{
    GtkWidget *message_h;
    GtkWidget *sw;
    GtkTextIter iter;
    GtkTextBuffer *t;

    message_h = gtk_handle_box_new();
    GTK_HANDLE_BOX(message_h)->shrink_on_detach = 1;
    
    message_text = gtk_text_view_new();
    gtk_widget_show(message_text);
    GTK_WIDGET_UNSET_FLAGS(message_text, GTK_CAN_FOCUS);
    gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(message_text), GTK_WRAP_WORD);
    t = gtk_text_view_get_buffer(GTK_TEXT_VIEW(message_text));
    gtk_text_buffer_create_tag(t, "warning", "foreground", "red", NULL);
    gtk_text_buffer_get_end_iter(t, &iter);
    gtk_text_buffer_create_mark(t, "nh_end", &iter, FALSE);

    sw = nh_gtk_new_and_add(gtk_scrolled_window_new(NULL, NULL), message_h, "");
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
      GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
    gtk_container_add(GTK_CONTAINER(sw), message_text);
 
    return message_h;
}
Example #4
0
bool wxToolBar::Create( wxWindow *parent,
                        wxWindowID id,
                        const wxPoint& pos,
                        const wxSize& size,
                        long style,
                        const wxString& name )
{
    if ( !PreCreation( parent, pos, size ) ||
         !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
    {
        wxFAIL_MSG( wxT("wxToolBar creation failed") );

        return false;
    }

    FixupStyle();

    m_toolbar = GTK_TOOLBAR( gtk_toolbar_new() );
#if !GTK_CHECK_VERSION(3,0,0) && !defined(GTK_DISABLE_DEPRECATED)
    if (gtk_check_version(2, 12, 0))
    {
        m_tooltips = gtk_tooltips_new();
        g_object_ref(m_tooltips);
        gtk_object_sink(GTK_OBJECT(m_tooltips));
    }
#endif
    GtkSetStyle();

    if (style & wxTB_DOCKABLE)
    {
        m_widget = gtk_handle_box_new();

        g_signal_connect(m_widget, "child_detached",
            G_CALLBACK(child_detached), NULL);
        g_signal_connect(m_widget, "child_attached",
            G_CALLBACK(child_attached), NULL);

        if (style & wxTB_FLAT)
            gtk_handle_box_set_shadow_type( GTK_HANDLE_BOX(m_widget), GTK_SHADOW_NONE );
    }
    else
    {
        m_widget = gtk_event_box_new();
        ConnectWidget( m_widget );
    }
    g_object_ref(m_widget);
    gtk_container_add(GTK_CONTAINER(m_widget), GTK_WIDGET(m_toolbar));
    gtk_widget_show(GTK_WIDGET(m_toolbar));

    m_parent->DoAddChild( this );

    PostCreation(size);

    g_signal_connect_after(m_toolbar, "size_request",
        G_CALLBACK(size_request), this);

    return true;
}
Example #5
0
bool wxToolBar::Create( wxWindow *parent,
                        wxWindowID id,
                        const wxPoint& pos,
                        const wxSize& size,
                        long style,
                        const wxString& name )
{
    m_needParent = true;
    m_insertCallback = (wxInsertChildFunction)wxInsertChildInToolBar;

    if ( !PreCreation( parent, pos, size ) ||
         !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
    {
        wxFAIL_MSG( wxT("wxToolBar creation failed") );

        return false;
    }

    FixupStyle();

    GtkOrientation orient;
    GtkToolbarStyle gtkStyle;
    GetGtkStyle(style, &orient, &gtkStyle);

    m_toolbar = GTK_TOOLBAR( gtk_toolbar_new(orient, gtkStyle) );

    SetToolSeparation(7);

    if (style & wxTB_DOCKABLE)
    {
        m_widget = gtk_handle_box_new();
        gtk_container_add( GTK_CONTAINER(m_widget), GTK_WIDGET(m_toolbar) );
        gtk_widget_show( GTK_WIDGET(m_toolbar) );

        if (style & wxTB_FLAT)
            gtk_handle_box_set_shadow_type( GTK_HANDLE_BOX(m_widget), GTK_SHADOW_NONE );
    }
    else
    {
        m_widget = gtk_event_box_new();
        gtk_container_add( GTK_CONTAINER(m_widget), GTK_WIDGET(m_toolbar) );
        ConnectWidget( m_widget );
        gtk_widget_show(GTK_WIDGET(m_toolbar));
    }

    gtk_toolbar_set_tooltips( GTK_TOOLBAR(m_toolbar), TRUE );

    if (style & wxTB_FLAT)
        gtk_toolbar_set_button_relief( GTK_TOOLBAR(m_toolbar), GTK_RELIEF_NONE );

    m_parent->DoAddChild( this );

    PostCreation(size);

    return true;
}
Example #6
0
/*
 * Creates a new GtkWidget of class GtkHandleBox, 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_handle_box_new (GbWidgetNewData * data)
{
  GtkWidget *new_widget = gtk_handle_box_new ();

  /* We set the snap edge to top, which matches the default handle position,
     since we don't support the default value of -1. */
  gtk_handle_box_set_snap_edge (GTK_HANDLE_BOX (new_widget), GTK_POS_TOP);

  if (data->action != GB_LOADING)
    gtk_container_add (GTK_CONTAINER (new_widget), editor_new_placeholder ());
  return new_widget;
}
/**
 * cact_main_toolbar_activate:
 * @window: this #CactMainWindow.
 * @toolbar_id: the id of the activated toolbar.
 * @ui_manager: the #GtkUIManager.
 * @is_active: whether this toolbar is activated or not.
 *
 * Activate or desactivate the toolbar.
 */
void
cact_main_toolbar_activate( CactMainWindow *window, int toolbar_id, GtkUIManager *ui_manager, gboolean is_active )
{
	static const gchar *thisfn = "cact_main_toolbar_activate";
	ToolbarProps *props;
	GtkWidget *toolbar, *hbox, *handle;
	gulong attach_id, detach_id;

	props = get_toolbar_properties( toolbar_id );
	if( !props ){
		return;
	}

	toolbar = gtk_ui_manager_get_widget( ui_manager, props->ui_path );
	g_debug( "%s: toolbar=%p, path=%s, ref_count=%d", thisfn, ( void * ) toolbar, props->ui_path, G_OBJECT( toolbar )->ref_count );
	hbox = base_window_get_widget( BASE_WINDOW( window ), "ToolbarHBox" );

	if( is_active ){
		handle = gtk_handle_box_new();
		gtk_handle_box_set_snap_edge( GTK_HANDLE_BOX( handle ), GTK_POS_LEFT );
		g_object_set_data( G_OBJECT( toolbar ), "cact-main-toolbar-handle", handle );
		attach_id = g_signal_connect( handle, "child-attached", (GCallback ) on_attach_toolbar, window );
		g_object_set_data( G_OBJECT( handle ), "cact-handle-attach-id", ( gpointer ) attach_id );
		detach_id = g_signal_connect( handle, "child-detached", (GCallback ) on_detach_toolbar, window );
		g_object_set_data( G_OBJECT( handle ), "cact-handle-detach-id", ( gpointer ) detach_id );
		g_object_weak_ref( G_OBJECT( handle ), ( GWeakNotify ) on_handle_finalize, NULL );
		gtk_container_add( GTK_CONTAINER( handle ), toolbar );
		gtk_container_add( GTK_CONTAINER( hbox ), handle );
		reorder_toolbars( hbox, toolbar_id, handle );
		gtk_widget_show_all( handle );

	} else {
		handle = ( GtkWidget * ) g_object_get_data( G_OBJECT( toolbar ), "cact-main-toolbar-handle" );
		detach_id = ( gulong ) g_object_get_data( G_OBJECT( handle ), "cact-handle-detach-id" );
		g_signal_handler_disconnect( handle, detach_id );
		attach_id = ( gulong ) g_object_get_data( G_OBJECT( handle ), "cact-handle-attach-id" );
		g_signal_handler_disconnect( handle, attach_id );
		gtk_container_remove( GTK_CONTAINER( handle ), toolbar );
		gtk_container_remove( GTK_CONTAINER( hbox ), handle );
	}

	na_settings_set_boolean( props->prefs_key, is_active );
}
Example #8
0
/*
 * Writes the source code needed to create this widget.
 * You have to output everything necessary to create the widget here, though
 * there are some convenience functions to help.
 */
static void
gb_handle_box_write_source (GtkWidget * widget, GbWidgetWriteSourceData * data)
{
  gint i;

  if (data->create_widget)
    {
      source_add (data, "  %s = gtk_handle_box_new ();\n", data->wname);
    }
  gb_widget_write_standard_source (widget, data);

  if (GTK_HANDLE_BOX (widget)->shadow_type != GTK_SHADOW_OUT)
    {
      for (i = 0; i < sizeof (GbShadowValues) / sizeof (GbShadowValues[0]);
	   i++)
	if (GbShadowValues[i] == GTK_HANDLE_BOX (widget)->shadow_type)
	  {
	    source_add (data,
			"  gtk_handle_box_set_shadow_type (GTK_HANDLE_BOX (%s), %s);\n",
			data->wname, GbShadowSymbols[i]);
	    break;
	  }
    }

  if (GTK_HANDLE_BOX (widget)->handle_position != GTK_POS_LEFT)
    {
      for (i = 0; i < sizeof (GbPositionValues) / sizeof (GbPositionValues[0]);
	   i++)
	{
	  if (GbPositionValues[i] == GTK_HANDLE_BOX (widget)->handle_position)
	    source_add (data,
		    "  gtk_handle_box_set_handle_position (GTK_HANDLE_BOX (%s), %s);\n",
			data->wname, GbPositionSymbols[i]);
	}
    }

  if (GTK_HANDLE_BOX (widget)->snap_edge != GTK_POS_TOP)
    {
      for (i = 0; i < sizeof (GbPositionValues) / sizeof (GbPositionValues[0]);
	   i++)
	{
	  if (GbPositionValues[i] == GTK_HANDLE_BOX (widget)->snap_edge)
	    source_add (data,
		    "  gtk_handle_box_set_snap_edge (GTK_HANDLE_BOX (%s), %s);\n",
			data->wname, GbPositionSymbols[i]);
	}
    }
}
Example #9
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));
	}
}
GtkWidget *
nh_message_new()
{
    GtkWidget *message_h;
    GtkWidget *message_hbox;

    message_h = gtk_handle_box_new();
    GTK_HANDLE_BOX(message_h)->shrink_on_detach = 1;

    message_hbox = nh_gtk_new_and_add(gtk_hbox_new(FALSE, 0), message_h, "");

    message_text = nh_gtk_new_and_pack(gtk_text_new(NULL, NULL),
      message_hbox, "", TRUE, TRUE, NH_PAD);

    GTK_WIDGET_UNSET_FLAGS(message_text, GTK_CAN_FOCUS);
    gtk_text_set_word_wrap((GtkText *) message_text, TRUE);

    (void)nh_gtk_new_and_pack(gtk_vscrollbar_new(GTK_TEXT(message_text)->vadj),
      message_hbox, "", FALSE, FALSE, NH_PAD);

    return message_h;
}