コード例 #1
0
ファイル: psppire-dialog.c プロジェクト: student-t/PSPP
static void
psppire_dialog_get_property (GObject         *object,
			     guint            prop_id,
			     GValue          *value,
			     GParamSpec      *pspec)
{
  PsppireDialog *dialog = PSPPIRE_DIALOG (object);

  switch (prop_id)
    {
    case PROP_ORIENTATION:
      {
	if ( GTK_IS_VBOX (dialog->box) || GTK_VPANED (dialog->box))
	  g_value_set_enum (value, PSPPIRE_VERTICAL);
	else if ( GTK_IS_HBOX (dialog->box) || GTK_HPANED (dialog->box))
	  g_value_set_enum (value, PSPPIRE_HORIZONTAL);
	else if ( GTK_IS_TABLE (dialog->box))
	  g_value_set_enum (value, PSPPIRE_TABULAR);
      }
      break;
    case PROP_SLIDING:
      g_value_set_boolean (value, dialog->slidable);
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
    };
}
コード例 #2
0
/* This tries to find the pixmap and label in the message box. */
static void
get_message_box_widgets (GtkWidget *dialog,
			 GtkWidget **pixmap,
			 GtkWidget **label)
{
  GtkWidget *vbox, *hbox;
  GtkBoxChild *child;
  GList *elem;

  *pixmap = NULL;
  *label = NULL;

  vbox = GNOME_DIALOG (dialog)->vbox;
  if (!vbox || !GTK_IS_VBOX (vbox))
    return;

  elem = GTK_BOX (vbox)->children;
  child = (GtkBoxChild*)elem->data;
  if (!child || !GTK_IS_HBOX (child->widget))
    return;
  hbox = child->widget;

  elem = GTK_BOX (hbox)->children;
  while (elem)
    {
      child = (GtkBoxChild*)elem->data;
      if (GTK_IS_LABEL (child->widget))
	*label = child->widget;
      if (GNOME_IS_PIXMAP (child->widget))
	*pixmap = child->widget;

      elem = elem->next;
    }
}
コード例 #3
0
ファイル: gtk.c プロジェクト: Centuriondan/xlennart
static void
set_label(GtkWidget *dialog, const char *str) {
	GList *list;
	GtkWidget *hbox = NULL;

	list = gtk_container_children(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox));
	while (list != NULL) {
		GtkWidget *w = (GtkWidget *) list->data;
		list = g_list_next(list);
		if (GTK_IS_HBOX(w)) {
			hbox = w;
			break;
		}
	}
	if (hbox == NULL)
		return;
	list = gtk_container_children(GTK_CONTAINER(hbox));
	while (list != NULL) {
		GtkWidget *w = (GtkWidget *) list->data;
		list = g_list_next(list);
		if (GTK_IS_LABEL(w)) {
			gtk_label_set_text(GTK_LABEL(w), str);
			return;
		}
	}
}
コード例 #4
0
void fixup_labels( GObject *gobject, GParamSpec *arg1, gpointer user_data )
{
    /* TODO: handle 'use-markup' getting changed also */

    if ( arg1 && arg1->name && (strcmp("label", arg1->name) == 0) ) {
        GSList* proxies = gtk_action_get_proxies( GTK_ACTION(gobject) );
        gchar* str = 0;
        g_object_get( gobject, "label", &str, NULL );
        (void)user_data;
        while ( proxies ) {
            if ( GTK_IS_TOOL_ITEM(proxies->data) ) {
                /* Search for the things we built up in create_tool_item() */
                GList* children = gtk_container_get_children( GTK_CONTAINER(proxies->data) );
                if ( children && children->data ) {
                    if ( GTK_IS_HBOX(children->data) ) {
                        children = gtk_container_get_children( GTK_CONTAINER(children->data) );
                        if ( children && g_list_next(children) ) {
                            GtkWidget* child = GTK_WIDGET( g_list_next(children)->data );
                            if ( GTK_IS_LABEL(child) ) {
                                GtkLabel* lbl = GTK_LABEL(child);
                                if ( EGE_OUTPUT_ACTION(gobject)->private_data->useMarkup ) {
                                    gtk_label_set_markup( lbl, str );
                                } else {
                                    gtk_label_set_text( lbl, str );
                                }
                            }
                        }
                    }
                }
            }
            proxies = g_slist_next( proxies );
        }
        g_free( str );
    }
}
コード例 #5
0
void RenderThemeGtk::refreshComboBoxChildren() const
{
    gtkComboBox(); // Ensure that we've initialized the combo box.

    // Some themes look at widget ancestry to determine how to render widgets, so
    // get the GtkButton that is the actual child of the combo box.
    gtk_container_forall(GTK_CONTAINER(m_gtkComboBox), getGtkComboBoxButton, &m_gtkComboBoxButton);
    ASSERT(m_gtkComboBoxButton);
    setupWidget(m_gtkComboBoxButton);
    g_object_add_weak_pointer(G_OBJECT(m_gtkComboBoxButton), reinterpret_cast<gpointer*>(&m_gtkComboBoxButton));

    ComboBoxWidgetPieces pieces = { 0, 0 };
    GtkWidget* buttonChild = gtk_bin_get_child(GTK_BIN(gtkComboBoxButton()));
    if (GTK_IS_HBOX(buttonChild))
        gtk_container_forall(GTK_CONTAINER(buttonChild), getGtkComboBoxPieces, &pieces);
    else if (GTK_IS_ARROW(buttonChild))
        pieces.arrow = buttonChild;

    ASSERT(pieces.arrow);
    m_gtkComboBoxArrow = pieces.arrow;
    setupWidget(m_gtkComboBoxArrow);
    // When the style changes, the combo box may destroy its children.
    g_object_add_weak_pointer(G_OBJECT(m_gtkComboBoxArrow), reinterpret_cast<gpointer*>(&m_gtkComboBoxArrow));

    m_gtkComboBoxSeparator = pieces.separator;
    if (m_gtkComboBoxSeparator) {
        setupWidget(m_gtkComboBoxSeparator);
        // When the style changes, the combo box may destroy its children.
        g_object_add_weak_pointer(G_OBJECT(m_gtkComboBoxSeparator), reinterpret_cast<gpointer*>(&m_gtkComboBoxSeparator));
    }
}
コード例 #6
0
ファイル: dates_callbacks.c プロジェクト: GNOME/dates
/* From contacts src/contacts-utils.c */
static GList *
contacts_set_widget_desensitive_recurse (GtkWidget *widget, GList **widgets)
{
	if (GTK_IS_WIDGET (widget)) {
		if (GTK_WIDGET_SENSITIVE (widget) &&
		    GTK_WIDGET_VISIBLE (widget)) {
			gtk_widget_set_sensitive (widget, FALSE);
			*widgets = g_list_append (*widgets, widget);
		}
		
		if (GTK_IS_TABLE (widget) || GTK_IS_HBOX (widget) ||
		    GTK_IS_VBOX (widget) || GTK_IS_EVENT_BOX (widget)) {
			GList *c, *children = gtk_container_get_children (
				GTK_CONTAINER (widget));
			
			for (c = children; c; c = c->next) {
				contacts_set_widget_desensitive_recurse (
					c->data, widgets);
			}
			g_list_free (children);
		}
	}
	
	return *widgets;
}
コード例 #7
0
ファイル: frame.cpp プロジェクト: Richard-Ni/wxWidgets
void wxFrame::SetToolBar(wxToolBar *toolbar)
{
    m_frameToolBar = toolbar;
    if (toolbar)
    {
        if (toolbar->IsVertical())
        {
            // Vertical toolbar and m_wxwindow go into an hbox, inside the
            // vbox (m_mainWidget). hbox is created on demand.
            GtkWidget* hbox = gtk_widget_get_parent(m_wxwindow);
            if (!GTK_IS_HBOX(hbox))
            {
                hbox = gtk_hbox_new(false, 0);
                gtk_widget_show(hbox);
                gtk_container_add(GTK_CONTAINER(m_mainWidget), hbox);
                gtk_widget_reparent(m_wxwindow, hbox);
            }
            gtk_widget_reparent(toolbar->m_widget, hbox);
            gtk_box_set_child_packing(GTK_BOX(hbox),
                toolbar->m_widget, false, false, 0, GTK_PACK_START);

            int pos = 0;  // left
            if (toolbar->HasFlag(wxTB_RIGHT))
                pos = 1;  // right
            gtk_box_reorder_child(GTK_BOX(hbox), toolbar->m_widget, pos);
        }
        else
        {
            // Horizontal toolbar goes into vbox (m_mainWidget)
            gtk_widget_reparent(toolbar->m_widget, m_mainWidget);
            gtk_box_set_child_packing(GTK_BOX(m_mainWidget),
                toolbar->m_widget, false, false, 0, GTK_PACK_START);

            int pos = 0;  // top
            if (m_frameMenuBar)
                pos = 1;  // below menubar
            if (toolbar->HasFlag(wxTB_BOTTOM))
                pos += 2;  // below client area (m_wxwindow)
            gtk_box_reorder_child(
                GTK_BOX(m_mainWidget), toolbar->m_widget, pos);
        }

        // disconnect wxWindowGTK "size_request" handler,
        // it interferes with sizing of detached GtkHandleBox
        gulong handler_id = g_signal_handler_find(
            toolbar->m_widget,
            GSignalMatchType(G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_DATA),
            g_signal_lookup("size_request", GTK_TYPE_WIDGET),
            0, NULL, NULL, toolbar);
        if (handler_id != 0)
            g_signal_handler_disconnect(toolbar->m_widget, handler_id);

        // reset size request to allow native sizing to work
        gtk_widget_set_size_request(toolbar->m_widget, -1, -1);
    }
    // make sure next size_allocate causes a wxSizeEvent
    m_oldClientWidth = 0;
}
コード例 #8
0
ファイル: cpufreq-applet.c プロジェクト: dnk/mate-applets
cpufreq_applet_size_request (GtkWidget *widget, GtkRequisition *requisition)
#endif
{
	CPUFreqApplet *applet;
	gint           labels_width = 0;
	gint           width;

	applet = CPUFREQ_APPLET (widget);

#if !GTK_CHECK_VERSION (3, 0, 0)
	GTK_WIDGET_CLASS (cpufreq_applet_parent_class)->size_request (widget, requisition);
#endif

	if (applet->orient == MATE_PANEL_APPLET_ORIENT_LEFT ||
	    applet->orient == MATE_PANEL_APPLET_ORIENT_RIGHT)
		return;


 	if (applet->show_freq) {
		labels_width += cpufreq_applet_get_max_label_width (applet) + 2;
 	}
 
 	if (applet->show_perc) {
		labels_width += cpufreq_applet_get_max_perc_width (applet);
 	}
 
 	if (applet->show_unit) {
		labels_width += cpufreq_applet_get_max_unit_width (applet);
	}

	if (applet->show_icon) {
#if GTK_CHECK_VERSION (3, 0, 0)
		gint icon_width;

		gtk_widget_get_preferred_width (applet->icon, &icon_width, NULL);
		width = gtk_orientable_get_orientation (GTK_ORIENTABLE (applet->box)) == GTK_ORIENTATION_HORIZONTAL ?
			labels_width + icon_width + 2 :
			MAX (labels_width, icon_width + 2);
#else
		GtkRequisition req;

		gtk_widget_size_request (applet->icon, &req);
		width = GTK_IS_HBOX (applet->box) ?
			labels_width + req.width + 2 :
			MAX (labels_width, req.width + 2);
#endif
	} else {
		width = labels_width;
	}

#if GTK_CHECK_VERSION (3, 0, 0)
	*minimum_width = *natural_width = width;
#else
	requisition->width = width;
#endif
}
コード例 #9
0
ファイル: gtk-utils.c プロジェクト: ejona86/quarry
static void
do_align_left_widgets (GtkWidget *first_level_child, GtkSizeGroup *size_group)
{
  if (GTK_IS_HBOX (first_level_child)
      || GTK_IS_HBUTTON_BOX (first_level_child)) {
    GtkSizeGroup *size_group_copy = size_group;

    gtk_container_foreach (GTK_CONTAINER (first_level_child),
			   (GtkCallback) do_align_left_widget,
			   &size_group_copy);
  }
  else if (GTK_IS_CONTAINER (first_level_child)) {
    gtk_container_foreach (GTK_CONTAINER (first_level_child),
			   (GtkCallback) do_align_left_widgets, size_group);
  }
}
コード例 #10
0
ファイル: frame.cpp プロジェクト: Kaoswerk/newton-dynamics
void wxFrame::SetToolBar(wxToolBar *toolbar)
{
    m_frameToolBar = toolbar;
    if (toolbar)
    {
        if (toolbar->IsVertical())
        {
            // Vertical toolbar and m_wxwindow go into an hbox, inside the
            // vbox (m_mainWidget). hbox is created on demand.
            GtkWidget* hbox = gtk_widget_get_parent(m_wxwindow);
            if (!GTK_IS_HBOX(hbox))
            {
                hbox = gtk_hbox_new(false, 0);
                gtk_widget_show(hbox);
                gtk_container_add(GTK_CONTAINER(m_mainWidget), hbox);
                gtk_widget_reparent(m_wxwindow, hbox);
            }
            gtk_widget_reparent(toolbar->m_widget, hbox);
            gtk_box_set_child_packing(GTK_BOX(hbox),
                toolbar->m_widget, false, false, 0, GTK_PACK_START);

            int pos = 0;  // left
            if (toolbar->HasFlag(wxTB_RIGHT))
                pos = 1;  // right
            gtk_box_reorder_child(GTK_BOX(hbox), toolbar->m_widget, pos);
        }
        else
        {
            // Horizontal toolbar goes into vbox (m_mainWidget)
            gtk_widget_reparent(toolbar->m_widget, m_mainWidget);
            gtk_box_set_child_packing(GTK_BOX(m_mainWidget),
                toolbar->m_widget, false, false, 0, GTK_PACK_START);

            int pos = 0;  // top
            if (m_frameMenuBar)
                pos = 1;  // below menubar
            if (toolbar->HasFlag(wxTB_BOTTOM))
                pos += 2;  // below client area (m_wxwindow)
            gtk_box_reorder_child(
                GTK_BOX(m_mainWidget), toolbar->m_widget, pos);
        }
        // reset size request to allow native sizing to work
        gtk_widget_set_size_request(toolbar->m_widget, -1, -1);
    }
    // make sure next size_allocate causes a wxSizeEvent
    m_oldClientWidth = 0;
}
コード例 #11
0
ファイル: composewindowtype.c プロジェクト: SpOOnman/claws
/* this is pretty ugly, as the compose struct does not maintain a pointer to the account selection combo */
static PyObject* ComposeWindow_get_account_selection(clawsmail_ComposeWindowObject *self, PyObject *args)
{
  GList *children, *walk;

  children = gtk_container_get_children(GTK_CONTAINER(self->compose->header_table));
  for(walk = children; walk; walk = walk->next) {
    if(GTK_IS_HBOX(walk->data)) {
      GList *children2, *walk2;
      children2 = gtk_container_get_children(GTK_CONTAINER(walk->data));
      for(walk2 = children2; walk2; walk2 = walk2->next) {
        if(GTK_IS_EVENT_BOX(walk2->data)) {
          return get_gobj_from_address(gtk_container_get_children(GTK_CONTAINER(walk2->data))->data);
        }
      }
    }
  }
  Py_INCREF(Py_None);
  return Py_None;
}
コード例 #12
0
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;
}
コード例 #13
0
static void
rejilla_file_chooser_find_pane (GtkWidget *child,
				gpointer footer)
{
	if (GTK_IS_PANED (child)) {
		GList *children_vbox;
		GList *iter_vbox;
		GtkWidget *vbox;

		vbox = gtk_paned_get_child2 (GTK_PANED (child));
		children_vbox = gtk_container_get_children (GTK_CONTAINER (vbox));
		for (iter_vbox = children_vbox; iter_vbox; iter_vbox = iter_vbox->next) {
			if (GTK_IS_HBOX (iter_vbox->data)) {
				GtkPackType packing;

				gtk_box_query_child_packing (GTK_BOX (vbox),
							     GTK_WIDGET (iter_vbox->data),
							     NULL,
							     NULL,
							     NULL,
							     &packing);

				if (packing == GTK_PACK_START) {
					GtkRequisition total_request, footer_request;

					gtk_widget_size_request (GTK_WIDGET (vbox),
								 &total_request);
					gtk_widget_size_request (GTK_WIDGET (iter_vbox->data),
								 &footer_request);
					*((gint *) footer) = total_request.height - footer_request.height;
					break;
				}
			}
		}
		g_list_free (children_vbox);
	}
	else if (GTK_IS_CONTAINER (child)) {
		gtk_container_foreach (GTK_CONTAINER (child),
				       rejilla_file_chooser_find_pane,
				       footer);
	}
}
コード例 #14
0
ファイル: he-check-button.c プロジェクト: rlevi/xournal
static void
he_check_button_style_set                         (GtkWidget *widget,
                                                 GtkStyle  *previous_style)
{
    guint horizontal_spacing, vertical_spacing, image_spacing;
    HeCheckButtonPrivate *priv = HE_CHECK_BUTTON_GET_PRIVATE (widget);

    if (GTK_WIDGET_CLASS (he_check_button_parent_class)->style_set)
        GTK_WIDGET_CLASS (he_check_button_parent_class)->style_set (widget, previous_style);

    /* Prevent infinite recursion when calling set_logical_font() and
     * set_logical_color() */
    if (priv->setting_style)
        return;

    /* Get horizontal-spacing style property from ourself */
    gtk_widget_style_get (widget, "horizontal-spacing", &horizontal_spacing, NULL);

    /* Get vertical-spacing style property of HildonButton from theme */
    GtkStyle *style = gtk_rc_get_style_by_paths (gtk_widget_get_settings (widget),
    		"*.*Button-finger", NULL, HILDON_TYPE_BUTTON);
    vertical_spacing = get_style_property_long (style, HILDON_TYPE_BUTTON, "vertical-spacing");

    /* Get image-spacing style property of HildonCheckButton from theme */
    style = gtk_rc_get_style_by_paths (gtk_widget_get_settings (widget),
    		NULL, "*.HildonCheckButton", HILDON_TYPE_CHECK_BUTTON);
    image_spacing = get_style_property_long (style, GTK_TYPE_BUTTON, "image-spacing");

    /* Setting values we got from above */
    if (GTK_IS_HBOX (priv->label_box)) {
        gtk_box_set_spacing (GTK_BOX (priv->label_box), horizontal_spacing);
    } else {
        gtk_box_set_spacing (GTK_BOX (priv->label_box), vertical_spacing);
    }

    if (GTK_IS_BOX (priv->hbox)) {
        gtk_box_set_spacing (priv->hbox, image_spacing);
    }

    set_logical_font (widget);
    set_logical_color (widget);
}
コード例 #15
0
static void
cpufreq_applet_size_request (GtkWidget *widget, GtkRequisition *requisition)
{
	CPUFreqApplet *applet;
	gint           labels_width = 0;
	gint           width;

	applet = CPUFREQ_APPLET (widget);

	GTK_WIDGET_CLASS (cpufreq_applet_parent_class)->size_request (widget, requisition);

	if (applet->orient == MATE_PANEL_APPLET_ORIENT_LEFT ||
	    applet->orient == MATE_PANEL_APPLET_ORIENT_RIGHT)
		return;

	if (applet->show_freq) {
		labels_width += cpufreq_applet_get_max_label_width (applet) + 2;
	}

	if (applet->show_perc) {
		labels_width += cpufreq_applet_get_max_perc_width (applet);
	}

	if (applet->show_unit) {
		labels_width += cpufreq_applet_get_max_unit_width (applet);
	}

	if (applet->show_icon) {
		GtkRequisition req;

		gtk_widget_size_request (applet->icon, &req);
		width = GTK_IS_HBOX (applet->box) ?
			labels_width + req.width + 2 :
			MAX (labels_width, req.width + 2);
	} else {
		width = labels_width;
	}

	requisition->width = width;
}
コード例 #16
0
ファイル: widget_utils.c プロジェクト: xaizek/vide
GtkWidget *
add_separator (GtkWidget * box, gint fill, gint pad)
{
  GtkWidget *sep;

  if (GTK_IS_HBOX (box))
    {
      sep = gtk_vseparator_new ();
      gtk_box_pack_start (GTK_BOX (box), sep, fill, TRUE, pad);
    }
  else if (GTK_IS_VBOX (box))
    {
      sep = gtk_hseparator_new ();
      gtk_box_pack_start (GTK_BOX (box), sep, fill, TRUE, pad);
    }
  else
    {
      return NULL;
    }

  gtk_widget_show (sep);
  return sep;
}
コード例 #17
0
ファイル: dialog-preferences.c プロジェクト: 814ckf0x/gnucash
/** Connect one dialog widget to the appropriate callback function for
 *  its type.
 *
 *  @internal
 *
 *  @param name The name of the widget.
 *
 *  @param widget A pointer to the widget.
 *
 *  @param dialog A pointer to the dialog.
 */
static void
gnc_prefs_connect_one (const gchar *name,
                       GtkWidget *widget,
                       gpointer user_data)
{
    /* These tests must be ordered from more specific widget to less
     * specific widget. */

    if (GTK_IS_FONT_BUTTON(widget))
    {
        DEBUG("  %s - entry", name);
        gnc_prefs_connect_font_button(GTK_FONT_BUTTON(widget));
    }
    else if (GTK_IS_RADIO_BUTTON(widget))
    {
        DEBUG("  %s - radio button", name);
        gnc_prefs_connect_radio_button(GTK_RADIO_BUTTON(widget));
    }
    else if (GTK_IS_CHECK_BUTTON(widget))
    {
        DEBUG("  %s - check button", name);
        gnc_prefs_connect_check_button(GTK_CHECK_BUTTON(widget));
    }
    else if (GTK_IS_SPIN_BUTTON(widget))
    {
        DEBUG("  %s - spin button", name);
        gnc_prefs_connect_spin_button(GTK_SPIN_BUTTON(widget));
    }
    else if (GTK_IS_COMBO_BOX(widget))
    {
        DEBUG("  %s - combo box", name);
        gnc_prefs_connect_combo_box(GTK_COMBO_BOX(widget));
    }
    else if (GTK_IS_ENTRY(widget))
    {
        DEBUG("  %s - entry", name);
        gnc_prefs_connect_entry(GTK_ENTRY(widget));
    }
    else if (GTK_IS_HBOX(widget))
    {
        /* Test custom widgets are all children of a hbox */
        GtkWidget *widget_child;
        GList* child = gtk_container_get_children(GTK_CONTAINER(widget));
        widget_child = child->data;
        g_list_free(child);
        DEBUG("  %s - hbox", name);
        DEBUG("Hbox widget type is %s and name is %s", gtk_widget_get_name(GTK_WIDGET(widget_child)), name);

        if (GNC_IS_CURRENCY_EDIT(widget_child))
        {
            DEBUG("  %s - currency_edit", name);
            gnc_prefs_connect_currency_edit(GNC_CURRENCY_EDIT(widget_child), name );
        }
        else if (GNC_IS_PERIOD_SELECT(widget_child))
        {
            DEBUG("  %s - period_Select", name);
            gnc_prefs_connect_period_select(GNC_PERIOD_SELECT(widget_child), name );
        }
        else if (GNC_IS_DATE_EDIT(widget_child))
        {
            DEBUG("  %s - date_edit", name);
            gnc_prefs_connect_date_edit(GNC_DATE_EDIT(widget_child), name );
        }
    }
    else
    {
        DEBUG("  %s - unsupported %s", name,
              G_OBJECT_TYPE_NAME(G_OBJECT(widget)));
    }
}
コード例 #18
0
ファイル: gaillabel.c プロジェクト: BYC/gtk
AtkRelationSet*
gail_label_ref_relation_set (AtkObject *obj)
{
  GtkWidget *widget;
  AtkRelationSet *relation_set;

  g_return_val_if_fail (GAIL_IS_LABEL (obj), NULL);

  widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (obj));
  if (widget == NULL)
    /*
     * State is defunct
     */
    return NULL;

  relation_set = ATK_OBJECT_CLASS (gail_label_parent_class)->ref_relation_set (obj);

  if (!atk_relation_set_contains (relation_set, ATK_RELATION_LABEL_FOR))
    {
      /*
       * Get the mnemonic widget
       *
       * The relation set is not updated if the mnemonic widget is changed
       */
      GtkWidget *mnemonic_widget = gtk_label_get_mnemonic_widget (GTK_LABEL (widget));

      if (mnemonic_widget)
        {
          AtkObject *accessible_array[1];
          AtkRelation* relation;

          if (!gtk_widget_get_can_focus (mnemonic_widget))
            {
            /*
             * Handle the case where a GtkFileChooserButton is specified as the 
             * mnemonic widget. use the combobox which is a child of the
             * GtkFileChooserButton as the mnemonic widget. See bug #359843.
             */
             if (GTK_IS_BOX (mnemonic_widget))
               {
                  GList *list, *tmpl;

                  list = gtk_container_get_children (GTK_CONTAINER (mnemonic_widget));
                  if (g_list_length (list) == 2)
                    {
                      tmpl = g_list_last (list);
                      if (GTK_IS_COMBO_BOX(tmpl->data))
                        {
                          mnemonic_widget = GTK_WIDGET(tmpl->data);
                        }
                    }
                  g_list_free (list);
                }
            /*
             * Handle the case where a GnomeIconEntry is specified as the 
             * mnemonic widget. use the button which is a grandchild of the
             * GnomeIconEntry as the mnemonic widget. See bug #133967.
             */
              else if (GTK_IS_BOX (mnemonic_widget))
                {
                  GList *list;

                  list = gtk_container_get_children (GTK_CONTAINER (mnemonic_widget));
                  if (g_list_length (list) == 1)
                    {
                      if (GTK_IS_ALIGNMENT (list->data))
                        {
                          GtkWidget *temp_widget;

                          temp_widget = gtk_bin_get_child (GTK_BIN (list->data));
                          if (GTK_IS_BUTTON (temp_widget))
                            mnemonic_widget = temp_widget;
                        }
                      else if (GTK_IS_HBOX (list->data))
                        {
                          GtkWidget *temp_widget;

                          temp_widget = GTK_WIDGET (list->data);
                          g_list_free (list);
                          list = gtk_container_get_children (GTK_CONTAINER (temp_widget));
                        }
                    }
                  g_list_free (list);
                }
            }
          accessible_array[0] = gtk_widget_get_accessible (mnemonic_widget);
          relation = atk_relation_new (accessible_array, 1,
                                       ATK_RELATION_LABEL_FOR);
          atk_relation_set_add (relation_set, relation);
          /*
           * Unref the relation so that it is not leaked.
           */
          g_object_unref (relation);
        }
    }
  return relation_set;
}
コード例 #19
0
ファイル: gtk2drawing.c プロジェクト: dslab-epfl/warr
static gint
ensure_combo_box_widgets()
{
    GtkWidget* buttonChild;

    if (gParts->comboBoxButtonWidget && gParts->comboBoxArrowWidget)
        return MOZ_GTK_SUCCESS;

    /* Create a ComboBox if needed */
    if (!gParts->comboBoxWidget) {
        gParts->comboBoxWidget = gtk_combo_box_new();
        setup_widget_prototype(gParts->comboBoxWidget);
    }

    /* Get its inner Button */
    gtk_container_forall(GTK_CONTAINER(gParts->comboBoxWidget),
                         moz_gtk_get_combo_box_inner_button,
                         NULL);

    if (gParts->comboBoxButtonWidget) {
        /* Get the widgets inside the Button */
        buttonChild = gtk_bin_get_child(GTK_BIN(gParts->comboBoxButtonWidget));
        if (GTK_IS_HBOX(buttonChild)) {
            /* appears-as-list = FALSE, cell-view = TRUE; the button
             * contains an hbox. This hbox is there because the ComboBox
             * needs to place a cell renderer, a separator, and an arrow in
             * the button when appears-as-list is FALSE. */
            gtk_container_forall(GTK_CONTAINER(buttonChild),
                                 moz_gtk_get_combo_box_button_inner_widgets,
                                 NULL);
        } else if(GTK_IS_ARROW(buttonChild)) {
            /* appears-as-list = TRUE, or cell-view = FALSE;
             * the button only contains an arrow */
            gParts->comboBoxArrowWidget = buttonChild;
            g_object_add_weak_pointer(G_OBJECT(buttonChild), (gpointer)
                                      &gParts->comboBoxArrowWidget);
            gtk_widget_realize(gParts->comboBoxArrowWidget);
            g_object_set_data(G_OBJECT(gParts->comboBoxArrowWidget),
                              "transparent-bg-hint", GINT_TO_POINTER(TRUE));
        }
    } else {
        /* Shouldn't be reached with current internal gtk implementation; we
         * use a generic toggle button as last resort fallback to avoid
         * crashing. */
        ensure_toggle_button_widget();
        gParts->comboBoxButtonWidget = gParts->toggleButtonWidget;
    }

    if (!gParts->comboBoxArrowWidget) {
        /* Shouldn't be reached with current internal gtk implementation;
         * we gParts->buttonArrowWidget as last resort fallback to avoid
         * crashing. */
        ensure_button_arrow_widget();
        gParts->comboBoxArrowWidget = gParts->buttonArrowWidget;
    }

    /* We don't test the validity of gParts->comboBoxSeparatorWidget since there
     * is none when "appears-as-list" = TRUE or "cell-view" = FALSE; if it
     * is invalid we just won't paint it. */

    return MOZ_GTK_SUCCESS;
}
コード例 #20
0
ファイル: ease-dialog-progress.c プロジェクト: rmujica/Nitido
EaseDialogProgress* ease_dialog_progress_construct_with_image (GType object_type, const char* title, gboolean cancellable, double max, GtkWindow* modal, GtkImage* image) {
#line 190 "ease-dialog-progress.c"
	EaseDialogProgress * self;
	GObject* _tmp0_;
	GtkHBox* hbox;
	GtkAlignment* align;
#line 77 "ease-dialog-progress.vala"
	g_return_val_if_fail (title != NULL, NULL);
#line 77 "ease-dialog-progress.vala"
	g_return_val_if_fail (image != NULL, NULL);
#line 80 "ease-dialog-progress.vala"
	self = (EaseDialogProgress*) ease_dialog_progress_construct (object_type, title, cancellable, max, modal);
#line 83 "ease-dialog-progress.vala"
	hbox = _g_object_ref0 ((_tmp0_ = gtk_builder_get_object (self->priv->builder, "hbox"), GTK_IS_HBOX (_tmp0_) ? ((GtkHBox*) _tmp0_) : NULL));
#line 84 "ease-dialog-progress.vala"
	align = g_object_ref_sink ((GtkAlignment*) gtk_alignment_new (0.5f, 0.5f, (float) 0, (float) 0));
#line 85 "ease-dialog-progress.vala"
	gtk_alignment_set_padding (align, (guint) 0, (guint) 0, (guint) 4, (guint) 4);
#line 86 "ease-dialog-progress.vala"
	gtk_container_add ((GtkContainer*) align, (GtkWidget*) image);
#line 87 "ease-dialog-progress.vala"
	gtk_widget_show ((GtkWidget*) align);
#line 88 "ease-dialog-progress.vala"
	gtk_widget_show ((GtkWidget*) image);
#line 89 "ease-dialog-progress.vala"
	gtk_box_pack_start ((GtkBox*) hbox, (GtkWidget*) align, FALSE, FALSE, (guint) 0);
#line 215 "ease-dialog-progress.c"
	_g_object_unref0 (align);
	_g_object_unref0 (hbox);
	return self;
}