Exemple #1
0
static void
ekiga_window_init_dialpad (EkigaWindow *mw)
{
  GtkWidget *dialpad = NULL;
  GtkWidget *grid = NULL;

  grid = gtk_grid_new ();
  gtk_grid_set_row_spacing (GTK_GRID (grid), 18);
  gtk_container_set_border_width (GTK_CONTAINER (grid), 18);

  dialpad = ekiga_dialpad_new (mw->priv->accel);
  gtk_widget_set_hexpand (dialpad, FALSE);
  gtk_widget_set_vexpand (dialpad, FALSE);
  gtk_widget_set_halign (dialpad, GTK_ALIGN_CENTER);
  gtk_widget_set_valign (dialpad, GTK_ALIGN_CENTER);
  gtk_grid_attach (GTK_GRID (grid), dialpad, 0, 0, 1, 1);
  g_signal_connect (dialpad, "button-clicked",
                    G_CALLBACK (dialpad_button_clicked_cb), mw);

  mw->priv->entry = ekiga_window_uri_entry_new (mw);
  gtk_widget_set_hexpand (dialpad, TRUE);
  gtk_widget_set_vexpand (dialpad, TRUE);
  gtk_widget_set_halign (mw->priv->entry, GTK_ALIGN_FILL);
  gtk_widget_set_valign (mw->priv->entry, GTK_ALIGN_END);
  gtk_grid_attach_next_to (GTK_GRID (grid), mw->priv->entry, dialpad,
                           GTK_POS_BOTTOM, 1, 1);

  gtk_stack_add_named (GTK_STACK (mw->priv->main_stack), grid, "dialpad");
  gtk_container_child_set (GTK_CONTAINER (mw->priv->main_stack),
                           grid,
                           "icon-name", "input-dialpad-symbolic", NULL);

  g_signal_connect (mw, "key-press-event",
                    G_CALLBACK (key_press_event_cb), mw);
}
Exemple #2
0
static void
pnl_tab_update_edge (PnlTab *self)
{
  g_assert (PNL_IS_TAB (self));

  switch (self->edge)
    {
    case GTK_POS_TOP:
      gtk_label_set_angle (self->title, 0.0);
      gtk_widget_set_hexpand (GTK_WIDGET (self), TRUE);
      gtk_widget_set_vexpand (GTK_WIDGET (self), FALSE);
      break;

    case GTK_POS_BOTTOM:
      gtk_label_set_angle (self->title, 0.0);
      gtk_widget_set_hexpand (GTK_WIDGET (self), TRUE);
      gtk_widget_set_vexpand (GTK_WIDGET (self), FALSE);
      break;

    case GTK_POS_LEFT:
      gtk_label_set_angle (self->title, -90.0);
      gtk_widget_set_hexpand (GTK_WIDGET (self), FALSE);
      gtk_widget_set_vexpand (GTK_WIDGET (self), TRUE);
      break;

    case GTK_POS_RIGHT:
      gtk_label_set_angle (self->title, 90.0);
      gtk_widget_set_hexpand (GTK_WIDGET (self), FALSE);
      gtk_widget_set_vexpand (GTK_WIDGET (self), TRUE);
      break;

    default:
      g_assert_not_reached ();
    }
}
static void
add_entry (GtkWidget     *grid1,
           GtkWidget     *grid2,
           const gchar   *text,
           GtkWidget    **out_entry)
{
  GtkStyleContext *context;
  GtkWidget *label;
  GtkWidget *entry;

  label = gtk_label_new_with_mnemonic (text);
  context = gtk_widget_get_style_context (label);
  gtk_style_context_add_class (context, GTK_STYLE_CLASS_DIM_LABEL);
  gtk_widget_set_vexpand (label, TRUE);
  gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
  gtk_container_add (GTK_CONTAINER (grid1), label);

  entry = gtk_entry_new ();
  gtk_widget_set_hexpand (entry, TRUE);
  gtk_widget_set_vexpand (entry, TRUE);
  gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
  gtk_entry_set_max_length (GTK_ENTRY (entry), 132);
  gtk_container_add (GTK_CONTAINER (grid2), entry);

  gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);
  if (out_entry != NULL)
    *out_entry = entry;
}
Exemple #4
0
static void
change_orientation (GtkWidget *button, GtkWidget *toolbar)
{
  GtkWidget *grid;
  GtkOrientation orientation;

  grid = gtk_widget_get_parent (toolbar);
  if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
    orientation = GTK_ORIENTATION_VERTICAL;
  else
    orientation = GTK_ORIENTATION_HORIZONTAL;

  g_object_ref (toolbar);
  gtk_container_remove (GTK_CONTAINER (grid), toolbar);
  gtk_orientable_set_orientation (GTK_ORIENTABLE (toolbar), orientation);
  if (orientation == GTK_ORIENTATION_HORIZONTAL)
    {
      gtk_widget_set_hexpand (toolbar, TRUE);
      gtk_widget_set_vexpand (toolbar, FALSE);
      gtk_grid_attach (GTK_GRID (grid), toolbar, 0, 0, 2, 1);
    }
  else
    {
      gtk_widget_set_hexpand (toolbar, FALSE);
      gtk_widget_set_vexpand (toolbar, TRUE);
      gtk_grid_attach (GTK_GRID (grid), toolbar, 0, 0, 1, 5);
    }
  g_object_unref (toolbar);
}
Exemple #5
0
/** \brief  Create cartridge preview widget
 *
 * \return  GtkGrid
 */
GtkWidget *crt_preview_widget_create(void)
{
    GtkWidget *grid;
    GtkWidget *label;
    GtkWidget *scroll;
    int row;

    grid = uihelpers_create_grid_with_label("CRT Header:", 2);
    gtk_grid_set_column_spacing(GTK_GRID(grid), 16);
    gtk_grid_set_row_spacing(GTK_GRID(grid), 8);
    row = 1;

    label = create_label("ID:");
    crtid_label = create_label("<unknown>");
    gtk_grid_attach(GTK_GRID(grid), label, 0, row, 1, 1);
    gtk_grid_attach(GTK_GRID(grid), crtid_label, 1, row, 1, 1);
    row++;

    label = create_label("Name:");
    crtname_label = create_label("<unknown>");
    gtk_grid_attach(GTK_GRID(grid), label, 0, row, 1, 1);
    gtk_grid_attach(GTK_GRID(grid), crtname_label, 1, row, 1, 1);
    row++;

    label = create_label("EXROM:");
    exrom_label = create_label("<unknown>");
    gtk_grid_attach(GTK_GRID(grid), label, 0, row, 1, 1);
    gtk_grid_attach(GTK_GRID(grid), exrom_label, 1, row, 1, 1);
    row++;

    label = create_label("GAME:");
    game_label = create_label("<unknown>");
    gtk_grid_attach(GTK_GRID(grid), label, 0, row, 1, 1);
    gtk_grid_attach(GTK_GRID(grid), game_label, 1, row, 1, 1);
    row++;

    label = gtk_label_new(NULL);
    gtk_widget_set_halign(label, GTK_ALIGN_START);
    gtk_label_set_markup(GTK_LABEL(label), "<b>CHIP packets:</b>");
    gtk_grid_attach(GTK_GRID(grid), label, 0, row, 2, 1);
    row++;

    scroll = gtk_scrolled_window_new(NULL, NULL);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll),
            GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
    gtk_widget_set_vexpand(scroll, TRUE);
    chip_tree = create_tree_view();
    gtk_widget_set_vexpand(chip_tree, TRUE);
    gtk_container_add(GTK_CONTAINER(scroll), chip_tree);
    gtk_grid_attach(GTK_GRID(grid), scroll, 0, row, 2, 1);

    gtk_widget_show_all(grid);
    return grid;
}
Exemple #6
0
static GtkWidget *
test_stacking (void)
{
  GtkWidget *win;
  GtkWidget *overlay;
  GtkWidget *main_child;
  GtkWidget *label;
  GtkWidget *child;
  GtkWidget *grid;
  GtkWidget *check1;
  GtkWidget *check2;
  GdkRGBA color;

  win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (win), "Stacking");

  grid = gtk_grid_new ();
  overlay = gtk_overlay_new ();
  main_child = gtk_event_box_new ();
  gdk_rgba_parse (&color, "green");
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
  gtk_widget_override_background_color (main_child, 0, &color);
G_GNUC_END_IGNORE_DEPRECATIONS
  gtk_widget_set_hexpand (main_child, TRUE);
  gtk_widget_set_vexpand (main_child, TRUE);
  label = gtk_label_new ("Main child");
  child = gtk_label_new ("Overlay");
  gtk_widget_set_halign (child, GTK_ALIGN_END);
  gtk_widget_set_valign (child, GTK_ALIGN_END);

  check1 = gtk_check_button_new_with_label ("Show main");
  g_object_bind_property (main_child, "visible", check1, "active", G_BINDING_BIDIRECTIONAL);

  check2 = gtk_check_button_new_with_label ("Show overlay");
  g_object_bind_property (child, "visible", check2, "active", G_BINDING_BIDIRECTIONAL);
  gtk_container_add (GTK_CONTAINER (main_child), label);
  gtk_container_add (GTK_CONTAINER (overlay), main_child);
  gtk_overlay_add_overlay (GTK_OVERLAY (overlay), child);
  gtk_grid_attach (GTK_GRID (grid), overlay, 1, 0, 1, 3);
  gtk_container_add (GTK_CONTAINER (win), grid);

  gtk_grid_attach (GTK_GRID (grid), check1, 0, 0, 1, 1);
  gtk_grid_attach (GTK_GRID (grid), check2, 0, 1, 1, 1);
  child = gtk_label_new ("");
  gtk_widget_set_vexpand (child, TRUE);
  gtk_grid_attach (GTK_GRID (grid), child, 0, 2, 1, 1);

  return win;
}
Exemple #7
0
static void
spanning_grid (void)
{
  GtkWidget *window;
  GtkWidget *g;
  GtkWidget *c;

  /* inspired by bug 698660
   * the row/column that are empty except for the spanning
   * child need to stay collapsed
   */

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (window), "Spanning");

  g = gtk_grid_new ();
  gtk_container_add (GTK_CONTAINER (window), g);

  c = test_widget ("0", "blue");
  gtk_widget_set_hexpand (c, TRUE);
  gtk_grid_attach (GTK_GRID (g), c, 0, 4, 4, 1);

  c = test_widget ("1", "green");
  gtk_widget_set_vexpand (c, TRUE);
  gtk_grid_attach (GTK_GRID (g), c, 4, 0, 1, 4);

  c = test_widget ("2", "red");
  gtk_widget_set_hexpand (c, TRUE);
  gtk_widget_set_vexpand (c, TRUE);
  gtk_grid_attach (GTK_GRID (g), c, 3, 3, 1, 1);

  c = test_widget ("3", "yellow");
  gtk_grid_attach (GTK_GRID (g), c, 0, 3, 2, 1);

  c = test_widget ("4", "orange");
  gtk_grid_attach (GTK_GRID (g), c, 3, 0, 1, 2);

  c = test_widget ("5", "purple");
  gtk_grid_attach (GTK_GRID (g), c, 1, 1, 1, 1);

  c = test_widget ("6", "white");
  gtk_grid_attach (GTK_GRID (g), c, 0, 1, 1, 1);

  c = test_widget ("7", "cyan");
  gtk_grid_attach (GTK_GRID (g), c, 1, 0, 1, 1);

  gtk_widget_show_all (window);
}
Exemple #8
0
static void
photos_error_box_constructed (GObject *object)
{
  PhotosErrorBox *self = PHOTOS_ERROR_BOX (object);

  G_OBJECT_CLASS (photos_error_box_parent_class)->constructed (object);

  gtk_widget_set_halign (GTK_WIDGET (self), GTK_ALIGN_CENTER);
  gtk_widget_set_hexpand (GTK_WIDGET (self), TRUE);
  gtk_widget_set_valign (GTK_WIDGET (self), GTK_ALIGN_CENTER);
  gtk_widget_set_vexpand (GTK_WIDGET (self), TRUE);
  gtk_orientable_set_orientation (GTK_ORIENTABLE (self), GTK_ORIENTATION_VERTICAL);
  gtk_grid_set_row_spacing (GTK_GRID (self), 12);

  self->image = gtk_image_new_from_icon_name ("dialog-error", GTK_ICON_SIZE_INVALID);
  gtk_image_set_pixel_size (GTK_IMAGE (self->image), 128);
  gtk_widget_set_halign (self->image, GTK_ALIGN_CENTER);
  gtk_widget_set_valign (self->image, GTK_ALIGN_CENTER);
  gtk_container_add (GTK_CONTAINER (self), self->image);

  self->primary_label = gtk_label_new (NULL);
  gtk_label_set_use_markup (GTK_LABEL (self->primary_label), TRUE);
  gtk_widget_set_halign (self->primary_label, GTK_ALIGN_CENTER);
  gtk_widget_set_valign (self->primary_label, GTK_ALIGN_CENTER);
  gtk_container_add (GTK_CONTAINER (self), self->primary_label);

  self->secondary_label = gtk_label_new (NULL);
  gtk_label_set_use_markup (GTK_LABEL (self->secondary_label), TRUE);
  gtk_label_set_line_wrap (GTK_LABEL (self->secondary_label), TRUE);
  gtk_widget_set_halign (self->secondary_label, GTK_ALIGN_CENTER);
  gtk_widget_set_valign (self->secondary_label, GTK_ALIGN_CENTER);
  gtk_container_add (GTK_CONTAINER (self), self->secondary_label);

  gtk_widget_show_all (GTK_WIDGET (self));
}
Exemple #9
0
static void digital_clock_init(DigitalClock * dclock)
{

    DigitalClockPriv *priv;
    GtkWidget *w = GTK_WIDGET(dclock);

    dclock->priv = DIGITAL_CLOCK_GET_PRIV(dclock);
    priv = dclock->priv;
    priv->x = priv->y = 0;
    priv->width = priv->height = -1;
    priv->fsiz = 0;
    priv->mode12 = TRUE;

    priv->time_val=g_slice_alloc0(LENTIMESTR);

//  g_signal_connect (G_OBJECT (dclock), "draw", G_CALLBACK (_draw), dclock);
    dclock->priv->timeoutid =
	g_timeout_add(TimeOutVal, (GSourceFunc) flushtime_cb, dclock);

    GtkStyleContext *stylecontext = gtk_widget_get_style_context(w);
    gtk_style_context_add_class(stylecontext, GTK_STYLE_CLASS_BUTTON);
    gtk_style_context_add_class(stylecontext, "suggested-action");

    gtk_widget_set_hexpand(w,TRUE);
    gtk_widget_set_vexpand(w,TRUE);

}
Exemple #10
0
/* test GTK_ALIGN_FILL handling */
static GtkWidget *
test_fullwidth (void)
{
  GtkWidget *win;
  GtkWidget *overlay;
  GtkWidget *text;
  GtkWidget *child;

  win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (win), "Full-width");

  overlay = gtk_overlay_new ();
  gtk_container_add (GTK_CONTAINER (win), overlay);

  text = gtk_text_view_new ();
  gtk_widget_set_size_request (text, 200, 200);
  gtk_widget_set_hexpand (text, TRUE);
  gtk_widget_set_vexpand (text, TRUE);
  gtk_container_add (GTK_CONTAINER (overlay), text);

  child = gtk_label_new ("Fullwidth top overlay");
  gtk_widget_set_halign (child, GTK_ALIGN_FILL);
  gtk_widget_set_valign (child, GTK_ALIGN_START);
  gtk_overlay_add_overlay (GTK_OVERLAY (overlay), child);
  g_object_set (child, "margin", 4, NULL);

  return win;
}
Exemple #11
0
static GtkWidget *
create_complex_popover (GtkWidget       *parent,
                        GtkPositionType  pos)
{
  GtkWidget *popover, *window, *content;
  GtkBuilder *builder;

  builder = gtk_builder_new ();
  gtk_builder_add_from_resource (builder, "/popover/popover.ui", NULL);
  window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
  content = gtk_bin_get_child (GTK_BIN (window));
  g_object_ref (content);
  gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (content)),
                        content);
  gtk_widget_destroy (window);
  g_object_unref (builder);

  popover = create_popover (parent, content, GTK_POS_BOTTOM);
  g_object_unref (content);

  gtk_widget_set_size_request (popover, 200, -1);
  gtk_widget_set_vexpand (popover, TRUE);

  gtk_widget_set_margin_start (popover, 10);
  gtk_widget_set_margin_end (popover, 10);
  gtk_widget_set_margin_bottom (popover, 10);

  return popover;
}
Exemple #12
0
GtkWidget *
gml_gtk_widget_new ()
{
    GtkWidget *obj;

    obj = g_object_new (GML_TYPE_GTK_WIDGET, NULL);

    GmlGtkWidget *gml = GML_GTK_WIDGET (obj);
    GtkGrid *grid = GTK_GRID (obj);

    gml->clutter_widget = gtk_clutter_embed_new ();
    gtk_widget_set_size_request (gml->clutter_widget, gml->width, gml->height);
    gml->stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (gml->clutter_widget));
    clutter_stage_set_color (CLUTTER_STAGE (gml->stage), &(gml->stage_color));
    clutter_actor_show (gml->stage);

    gtk_widget_set_vexpand (gml->clutter_widget, TRUE);
    gtk_widget_set_valign (gml->clutter_widget, GTK_ALIGN_FILL);
    gtk_widget_set_hexpand (gml->clutter_widget, TRUE);
    gtk_widget_set_halign (gml->clutter_widget, GTK_ALIGN_FILL);

    gtk_grid_attach (grid, gml->clutter_widget, 0, 0, 1, 1);

    return obj;
}
Exemple #13
0
static GtkWidget* ink_radio_action_create_tool_item( GtkAction* action )
{
    InkRadioAction* act = INK_RADIO_ACTION( action );
    GtkWidget* item = GTK_RADIO_ACTION_CLASS(ink_radio_action_parent_class)->parent_class.parent_class.create_tool_item(action);

    if ( act->private_data->iconId ) {
        if ( GTK_IS_TOOL_BUTTON(item) ) {
            GtkToolButton* button = GTK_TOOL_BUTTON(item);

            GtkWidget* child = sp_icon_new( act->private_data->iconSize, act->private_data->iconId );

#if GTK_CHECK_VERSION(3,0,0)
	    gtk_widget_set_hexpand(child, FALSE);
	    gtk_widget_set_vexpand(child, FALSE);
            gtk_tool_button_set_icon_widget(button, child);
#else
            GtkWidget* align = gtk_alignment_new( 0.5, 0.5, 0.0, 0.0 );
            gtk_container_add( GTK_CONTAINER(align), child );
            gtk_tool_button_set_icon_widget( button, align );
#endif
        } else {
            // For now trigger a warning but don't do anything else
            GtkToolButton* button = GTK_TOOL_BUTTON(item);
            (void)button;
        }
    }

    // TODO investigate if needed
    gtk_widget_show_all( item );

    return item;
}
Exemple #14
0
static void ink_toggle_action_update_icon( InkToggleAction* action )
{
    if ( action ) {
        GSList* proxies = gtk_action_get_proxies( GTK_ACTION(action) );
        while ( proxies ) {
            if ( GTK_IS_TOOL_ITEM(proxies->data) ) {
                if ( GTK_IS_TOOL_BUTTON(proxies->data) ) {
                    GtkToolButton* button = GTK_TOOL_BUTTON(proxies->data);

                    GtkWidget* child = sp_icon_new( action->private_data->iconSize, action->private_data->iconId );

#if GTK_CHECK_VERSION(3,0,0)
		    gtk_widget_set_hexpand(child, FALSE);
		    gtk_widget_set_vexpand(child, FALSE);
		    gtk_widget_show_all(child);
		    gtk_tool_button_set_icon_widget(button, child);
#else
                    GtkWidget* align = gtk_alignment_new( 0.5, 0.5, 0.0, 0.0 );
                    gtk_container_add( GTK_CONTAINER(align), child );
                    gtk_widget_show_all( align );
                    gtk_tool_button_set_icon_widget( button, align );
#endif
                }
            }

            proxies = g_slist_next( proxies );
        }
    }
}
Exemple #15
0
static GtkWidget* ink_toggle_action_create_tool_item( GtkAction* action )
{
    InkToggleAction* act = INK_TOGGLE_ACTION( action );

    GtkWidget* item = GTK_TOGGLE_ACTION_CLASS(ink_toggle_action_parent_class)->parent_class.create_tool_item(action);
    if ( GTK_IS_TOOL_BUTTON(item) ) {
        GtkToolButton* button = GTK_TOOL_BUTTON(item);
        if ( act->private_data->iconId ) {
            GtkWidget* child = sp_icon_new( act->private_data->iconSize, act->private_data->iconId );

#if GTK_CHECK_VERSION(3,0,0)
	    gtk_widget_set_hexpand(child, FALSE);
	    gtk_widget_set_vexpand(child, FALSE);
	    gtk_tool_button_set_icon_widget(button, child);
#else
            GtkWidget* align = gtk_alignment_new( 0.5, 0.5, 0.0, 0.0 );
            gtk_container_add( GTK_CONTAINER(align), child );
            gtk_tool_button_set_icon_widget( button, align );
#endif
        } else {
            gchar *label = 0;
            g_object_get( G_OBJECT(action), "short_label", &label, NULL );
            gtk_tool_button_set_label( button, label );
            g_free( label );
            label = 0;
        }
    } else {
        // For now trigger a warning but don't do anything else
        GtkToolButton* button = GTK_TOOL_BUTTON(item);
        (void)button;
    }
    gtk_widget_show_all( item );

    return item;
}
Exemple #16
0
static void
photos_dropdown_add_manager (PhotosDropdown *self, PhotosBaseManager *mngr)
{
  GMenu *menu;
  GtkWidget *popover;
  GtkWidget *w;
  PhotosBaseModel *model;

  model = photos_base_model_new (mngr);
  self->models = g_list_prepend (self->models, g_object_ref (model));

  /* HACK: see https://bugzilla.gnome.org/show_bug.cgi?id=733977 */
  popover = gtk_popover_new (NULL);
  menu = photos_base_model_get_model (model);
  gtk_popover_bind_model (GTK_POPOVER (popover), G_MENU_MODEL (menu), "app");
  w = g_object_ref (gtk_bin_get_child (GTK_BIN (popover)));
  gtk_container_remove (GTK_CONTAINER (popover), w);
  gtk_container_add (GTK_CONTAINER (self->grid), w);
  g_object_unref (w);
  gtk_widget_set_valign (w, GTK_ALIGN_START);
  gtk_widget_set_vexpand (w, TRUE);
  gtk_widget_destroy (popover);

  g_object_unref (model);
}
Exemple #17
0
/*
 * create_page:
 * @child: the #CheeseWidget to pack into the container
 * @button: the #GtkButton for taking a photo
 *
 * Create the widgets for the #CheeseAvatarWidget and pack them into a
 * container.
 *
 * Returns: a #GtkBox containing the individual #CheeseAvatarWidget widgets
 */
static GtkWidget *
create_page (GtkWidget *child,
             GtkWidget *button)
{
    GtkWidget *vgrid, *bar;
    GtkStyleContext *context;

    vgrid = gtk_grid_new ();
    gtk_grid_attach (GTK_GRID (vgrid),
                     child, 0, 0, 1, 1);
    gtk_widget_set_hexpand (child, TRUE);
    gtk_widget_set_vexpand (child, TRUE);

    bar = gtk_header_bar_new ();
    context = gtk_widget_get_style_context (GTK_WIDGET (bar));
    gtk_style_context_remove_class (context, "header-bar");
    gtk_style_context_add_class (context, "inline-toolbar");
    gtk_style_context_add_class (context, "toolbar");
    gtk_style_context_add_class (context, GTK_STYLE_CLASS_HORIZONTAL);

    g_object_set (G_OBJECT (button), "margin-top", 6, "margin-bottom", 6, NULL);
    gtk_header_bar_set_custom_title (GTK_HEADER_BAR (bar), button);
    gtk_grid_attach (GTK_GRID (vgrid),
                     bar, 0, 1, 1, 1);

    return vgrid;
}
Exemple #18
0
static void
empty_line (void)
{
  GtkWidget *window;
  GtkWidget *grid;
  GtkWidget *child;

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (window), "Empty row");
  grid = gtk_grid_new ();
  gtk_container_add (GTK_CONTAINER (window), grid);

  gtk_grid_set_row_spacing (GTK_GRID (grid), 10);
  gtk_grid_set_column_spacing (GTK_GRID (grid), 10);

  child = test_widget ("(0, 0)", "red");
  gtk_grid_attach (GTK_GRID (grid), child, 0, 0, 1, 1);
  gtk_widget_set_hexpand (child, TRUE);
  gtk_widget_set_vexpand (child, TRUE);

  gtk_grid_attach (GTK_GRID (grid), test_widget ("(0, 1)", "blue"), 0, 1, 1, 1);

  gtk_grid_attach (GTK_GRID (grid), test_widget ("(10, 0)", "green"), 10, 0, 1, 1);
  gtk_grid_attach (GTK_GRID (grid), test_widget ("(10, 1)", "magenta"), 10, 1, 1, 1);

  gtk_widget_show_all (window);
}
Exemple #19
0
static void
populate_action_arguments_grid (GtkWidget                     *grid,
                                GList                         *arguments,
                                GUPnPServiceActionArgDirection direction,
                                GUPnPServiceIntrospection     *introspection)
{
        GList *arg_node;
        GtkWidget *last_aligner_grid = NULL;

        g_assert (introspection != NULL);

        prepare_action_arguments_grid (GTK_CONTAINER (grid),
                                       direction,
                                       arguments);

        gtk_widget_set_size_request (dialog, 0, 0);

        for (arg_node = arguments;
             arg_node;
             arg_node = arg_node->next) {
                GUPnPServiceActionArgInfo *arg_info;
                GtkWidget                 *aligner_grid;
                GtkWidget                 *label;
                GtkWidget                 *input_widget;

                arg_info = (GUPnPServiceActionArgInfo *) arg_node->data;

                /* First add the name */
                /* GTK_ALIGN_START seems to have a bug in a size group:
                 * use a container for alignment */
                aligner_grid = gtk_grid_new ();
                gtk_grid_attach_next_to (GTK_GRID (grid),
                                         aligner_grid,
                                         last_aligner_grid,
                                         GTK_POS_BOTTOM,
                                         1, 1);
                last_aligner_grid = aligner_grid;

                label = gtk_label_new (arg_info->name);
                gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
                gtk_widget_set_vexpand (label, TRUE);
                gtk_widget_set_halign (label, GTK_ALIGN_START);
                gtk_grid_attach (GTK_GRID (aligner_grid), label,
                                 0, 0, 1, 1);
                gtk_size_group_add_widget (label_container_group,
                                           aligner_grid);
                gtk_widget_show_all (aligner_grid);

                /* Then the input widget */
                input_widget = create_widget_for_argument (arg_info,
                                                           introspection);
                gtk_widget_set_hexpand (input_widget, TRUE);
                gtk_grid_attach_next_to (GTK_GRID (grid),
                                         input_widget,
                                         aligner_grid,
                                         GTK_POS_RIGHT,
                                         1,1);
                gtk_widget_show_all (input_widget);
        }
}
Exemple #20
0
void
hig_workarea_add_wide_tall_control (GtkWidget * t, guint * row, GtkWidget * w)
{
    gtk_widget_set_hexpand (w, TRUE);
    gtk_widget_set_vexpand (w, TRUE);
    hig_workarea_add_wide_control (t, row, w);
}
Exemple #21
0
/* {{{ append_sprite_pic(…) - append an image to a sprite */
static Sprite *append_sprite_pic(Sprite *s, GdkPixbuf *pic) {
	debug(">>> append_sprite_pic()");
	/* FIXME animated images must be supported */
	GtkWidget *w = gtk_image_new_from_pixbuf(pic);
	if (w == NULL) {
		warn("append_sprite_pic(): gtk_image_new_from_pixbuf()");
		goto LBL_return;
	}
	gtk_widget_set_vexpand(w, TRUE);
	gtk_widget_set_hexpand(w, TRUE);
	gtk_widget_set_vexpand_set(w, TRUE);
	gtk_widget_set_hexpand_set(w, TRUE);
	/* shrink large images */
	float width = (float)gdk_pixbuf_get_width(pic);
	float height = (float)gdk_pixbuf_get_height(pic);
	float ratio = (float)width / height;
	/* FIXME avoid magic numbers */
	if ((ratio > 1) && (width > 128)) {
		width = 128;
		height = ratio * width;
	} else if ((ratio <= 1) && (height > 128)) {
		height = 128;
		width = height * ratio;
	}
	gtk_widget_set_size_request(w, (gint)width, (gint)height);
	append_sprite_widget(s, w);
	LBL_return:
	debug("<<< append_sprite_pic()");
	return s;
}
Exemple #22
0
GtkWidget *
create_clipping_page (void)
{
  GtkWidget *vbox, *scrolled_win, *canvas;

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 4);
  g_object_set (vbox, "margin", 4, NULL);
  gtk_widget_show (vbox);

  scrolled_win = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_win),
				       GTK_SHADOW_IN);
  gtk_widget_show (scrolled_win);
  gtk_box_pack_start (GTK_BOX (vbox), scrolled_win);
  gtk_widget_set_halign (scrolled_win, GTK_ALIGN_FILL);
  gtk_widget_set_valign (scrolled_win, GTK_ALIGN_FILL);
  gtk_widget_set_hexpand (scrolled_win, TRUE);
  gtk_widget_set_vexpand (scrolled_win, TRUE);

  canvas = goo_canvas_new ();
  gtk_widget_set_size_request (canvas, 600, 450);
  goo_canvas_set_bounds (GOO_CANVAS (canvas), 0, 0, 1000, 1000);
  gtk_widget_show (canvas);
  gtk_container_add (GTK_CONTAINER (scrolled_win), canvas);

  setup_canvas (GOO_CANVAS (canvas));

  return vbox;
}
Exemple #23
0
GtkWidget *
do_foreigndrawing (GtkWidget *do_widget)
{
  static GtkWidget *window = NULL;

  if (!window)
    {
      GtkWidget *box;
      GtkWidget *da;

      window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
      gtk_window_set_title (GTK_WINDOW (window), "Foreign drawing");
      gtk_window_set_display (GTK_WINDOW (window),
                              gtk_widget_get_display (do_widget));
      g_signal_connect (window, "destroy",
                        G_CALLBACK (gtk_widget_destroyed), &window);

      box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
      gtk_container_add (GTK_CONTAINER (window), box);
      da = gtk_drawing_area_new ();
      gtk_drawing_area_set_content_width (GTK_DRAWING_AREA (da), 400);
      gtk_drawing_area_set_content_height (GTK_DRAWING_AREA (da), 400);
      gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (da), draw_func, NULL, NULL);
      gtk_widget_set_hexpand (da, TRUE);
      gtk_widget_set_vexpand (da, TRUE);
      gtk_container_add (GTK_CONTAINER (box), da);
    }

  if (!gtk_widget_get_visible (window))
    gtk_widget_show (window);
  else
    gtk_widget_destroy (window);

  return window;
}
Exemple #24
0
/** \brief  Create VSID main widget
 *
 * \return  GtkGrid
 */
GtkWidget *vsid_main_widget_create(void)
{
    GtkWidget *grid;

    grid = vice_gtk3_grid_new_spaced(32, 32);
    g_object_set(G_OBJECT(grid),
            "margin-left", 16,
            "margin-right", 16,
            "margin-top", 16,
            "margin-bottom", 16,
            NULL);

    tune_info_widget = vsid_tune_info_widget_create();
    gtk_grid_attach(GTK_GRID(grid), tune_info_widget, 0, 0, 1, 1);

    control_widget = vsid_control_widget_create();
    gtk_grid_attach(GTK_GRID(grid), control_widget, 0, 1, 1, 1);

    mixer_widget = vsid_mixer_widget_create();
    gtk_grid_attach(GTK_GRID(grid), mixer_widget, 0, 2, 1, 1);

    stil_widget = hvsc_stil_widget_create();
    gtk_widget_set_vexpand(stil_widget, TRUE);
    gtk_grid_attach(GTK_GRID(grid), stil_widget, 1, 0, 1, 4);

#if 0
    playlist_widget = vsid_playlist_widget_create();
    gtk_grid_attach(GTK_GRID(grid), playlist_widget, 2, 0, 1, 4);
#endif
    gtk_widget_show_all(grid);
    main_widget = grid;
    return grid;
}
Exemple #25
0
static void
gs_editor_refresh_choice (GsEditor *self)
{
	GPtrArray *apps;
	GtkContainer *container;

	/* add all apps */
	container = GTK_CONTAINER (gtk_builder_get_object (self->builder,
							   "flowbox_main"));
	gs_container_remove_all (GTK_CONTAINER (container));
	apps = as_store_get_apps (self->store);
	for (guint i = 0; i < apps->len; i++) {
		AsApp *item = g_ptr_array_index (apps, i);
		GtkWidget *tile = NULL;
		g_autoptr(GsApp) app = NULL;

		app = gs_editor_convert_app (self, item);
		tile = gs_summary_tile_new (app);
		g_signal_connect (tile, "clicked",
				  G_CALLBACK (gs_editor_app_tile_clicked_cb),
				  self);
		gtk_widget_set_visible (tile, TRUE);
		gtk_widget_set_vexpand (tile, FALSE);
		gtk_widget_set_hexpand (tile, FALSE);
		gtk_widget_set_size_request (tile, 300, 50);
		gtk_widget_set_valign (tile, GTK_ALIGN_START);
		gtk_container_add (GTK_CONTAINER (container), tile);
	}
}
Exemple #26
0
static void
scrolling (void)
{
  GtkWidget *window;
  GtkWidget *sw;
  GtkWidget *viewport;
  GtkWidget *grid;
  GtkWidget *child;
  gint i;

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (window), "Scrolling");
  sw = gtk_scrolled_window_new (NULL, NULL);
  viewport = gtk_viewport_new (NULL, NULL);
  grid = gtk_grid_new ();

  gtk_container_add (GTK_CONTAINER (window), sw);
  gtk_container_add (GTK_CONTAINER (sw), viewport);
  gtk_container_add (GTK_CONTAINER (viewport), grid);

  child = oriented_test_widget ("#800080", "#800080", -45.0);
  gtk_grid_attach (GTK_GRID (grid), child, 0, 0, 1, 1);
  gtk_widget_set_hexpand (child, TRUE);
  gtk_widget_set_vexpand (child, TRUE);

  for (i = 1; i < 16; i++)
    {
      gchar *color;
      color = g_strdup_printf ("#%02x00%02x", 128 + 8*i, 128 - 8*i);
      child = test_widget (color, color);
      gtk_grid_attach (GTK_GRID (grid), child, 0, i, i + 1, 1);
      gtk_widget_set_hexpand (child, TRUE);
      g_free (color);
    }

  for (i = 1; i < 16; i++)
    {
      gchar *color;
      color = g_strdup_printf ("#%02x00%02x", 128 - 8*i, 128 + 8*i);
      child = oriented_test_widget (color, color, -90.0);
      gtk_grid_attach (GTK_GRID (grid), child, i, 0, 1, i);
      gtk_widget_set_vexpand (child, TRUE);
      g_free (color);
    }

  gtk_widget_show_all (window);
}
Exemple #27
0
static gboolean ask_and_delete(gpointer user_data)
{
  GList *empty_dirs = (GList *)user_data;
  const int n_empty_dirs = g_list_length(empty_dirs);

  GtkWidget *dialog;
  GtkWidget *win = dt_ui_main_window(darktable.gui->ui);

  dialog = gtk_message_dialog_new(GTK_WINDOW(win), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION,
                                  GTK_BUTTONS_YES_NO,
                                  ngettext("do you want to remove this empty directory?",
                                           "do you want to remove these empty directories?", n_empty_dirs));

  gtk_window_set_title(GTK_WINDOW(dialog),
                       ngettext("remove empty directory?", "remove empty directories?", n_empty_dirs));

  GtkWidget *content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog));

  GtkWidget *scroll = gtk_scrolled_window_new(NULL, NULL);
  gtk_widget_set_vexpand(scroll, TRUE);
  gtk_widget_set_margin_start(scroll, DT_PIXEL_APPLY_DPI(10));
  gtk_widget_set_margin_end(scroll, DT_PIXEL_APPLY_DPI(10));
  gtk_widget_set_margin_top(scroll, DT_PIXEL_APPLY_DPI(0));
  gtk_widget_set_margin_bottom(scroll, DT_PIXEL_APPLY_DPI(0));

  GtkListStore *store = gtk_list_store_new(1, G_TYPE_STRING);

  for(GList *list_iter = empty_dirs; list_iter; list_iter = g_list_next(list_iter))
  {
    GtkTreeIter iter;
    gtk_list_store_append(store, &iter);
    gtk_list_store_set(store, &iter, 0, list_iter->data, -1);
  }

  GtkWidget *tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
  gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree), FALSE);

  GtkTreeViewColumn *column = gtk_tree_view_column_new_with_attributes(_("name"), gtk_cell_renderer_text_new(),
                                                                       "text", 0, NULL);
  gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);

  gtk_container_add(GTK_CONTAINER(scroll), tree);
  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);

  gtk_container_add(GTK_CONTAINER(content_area), scroll);

  gtk_widget_show_all(dialog); // needed for the content area!

  gint res = gtk_dialog_run(GTK_DIALOG(dialog));
  gtk_widget_destroy(dialog);
  if(res == GTK_RESPONSE_YES)
    for(GList *iter = empty_dirs; iter; iter = g_list_next(iter))
      rmdir((char *)iter->data);

  g_list_free_full(empty_dirs, g_free);
  g_object_unref(store);

  return FALSE;
}
Exemple #28
0
extern void create_label(const gchar *message)
{
	label = gtk_label_new(message);
	gtk_widget_set_hexpand( label, TRUE );
	gtk_widget_set_vexpand( label, TRUE );

	return;
}
Gtk::Widget * Ganash::ApplicationWindow::setupUi()
{
  GtkWidget *vbox;
  GtkWidget *menubar;
  GtkWidget *toolbar;
  GtkWidget *dockbar;
  GtkWidget *statusbar;

  vbox      = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
  menubar   = setupMenu()->gobj();//gtk_menu_bar_new();
  toolbar   = setupTool()->gobj();//gtk_toolbar_new();
  dockbar   = setupDock()->gobj();
  statusbar = gtk_statusbar_new();

  gtk_widget_set_vexpand(vbox, TRUE);
  gtk_widget_set_vexpand(dockbar, TRUE);
  //gtk_widget_set_vexpand(toolbar, FALSE);

  // ----------------

  Gtk::Toolbar *tools = new Gtk::Toolbar();
  //tools->set_property("orientation", Gtk::ORIENTATION_VERTICAL);
  //tools->set_property("toolbar-style", Gtk::TOOLBAR_ICONS);
  //tools->set_property("icon-size", Gtk::ICON_SIZE_SMALL_TOOLBAR);
  //tools->set_property("icon-size", Gtk::ICON_SIZE_LARGE_TOOLBAR);

  Gtk::ToolButton *cursor5_tool = new Gtk::ToolButton(Gtk::StockID(Ganash::Ui::Stock::SELECT));
  Gtk::ToolButton *cursor6_tool = new Gtk::ToolButton(Gtk::StockID(Ganash::Ui::Stock::TRANSFORM));
  tools->insert(*cursor5_tool, 0);
  tools->insert(*cursor6_tool, 1);
  // ----


  gtk_container_add(GTK_CONTAINER(vbox), menubar);
  gtk_container_add(GTK_CONTAINER(vbox), toolbar);
  gtk_container_add(GTK_CONTAINER(vbox), GTK_WIDGET(tools->gobj()));
  gtk_container_add(GTK_CONTAINER(vbox), dockbar);
  //gtk_container_add(GTK_CONTAINER(vbox), statusbar);

  _menubar   = Glib::wrap(menubar);
  _toolbar   = Glib::wrap(toolbar);
  _dockbar   = Glib::wrap(dockbar);
  _statusbar = Glib::wrap(statusbar);
  return Glib::wrap(vbox);
}
Exemple #30
0
static GtkTextBuffer *message_window(void)
{
    GtkTextBuffer *buffer;
    GtkWidget *vbox, *result, *ok;
    GtkWindow *window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL));
    gtk_window_set_title(GTK_WINDOW(window), _("Messages"));
    gtk_widget_set_size_request(GTK_WIDGET(window), SIZEX, SIZEY);
    gtk_window_set_transient_for(GTK_WINDOW(window), GTK_WINDOW(main_window));
    gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER_ON_PARENT);
    gtk_window_set_destroy_with_parent(GTK_WINDOW(window), TRUE);

    vbox = gtk_grid_new();
    gtk_container_add (GTK_CONTAINER (window), vbox);

    result = gtk_text_view_new();
    ok = gtk_button_new_with_label(_("OK"));

    GtkWidget *scrolled_window = gtk_scrolled_window_new(NULL, NULL);
    gtk_container_set_border_width(GTK_CONTAINER(scrolled_window), 10);
#if (GTKVER == 3) && GTK_CHECK_VERSION(3,8,0)
    gtk_container_add(GTK_CONTAINER(scrolled_window), result);
#else
    gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window), result);
#endif

    gtk_grid_attach(GTK_GRID(vbox), scrolled_window, 0, 0, 1, 1);
    gtk_widget_set_hexpand(scrolled_window, TRUE);
    gtk_widget_set_vexpand(scrolled_window, TRUE);
    gtk_grid_attach(GTK_GRID(vbox), ok,            0, 2, 1, 1);
    gtk_widget_show_all(GTK_WIDGET(window));
    buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(result));

    PangoFontDescription *font_desc = pango_font_description_from_string("Courier 10");
    gtk_widget_override_font (GTK_WIDGET(result), font_desc);
    pango_font_description_free (font_desc);

    g_signal_connect (G_OBJECT (window), "delete_event",
                      G_CALLBACK (delete_event_message), NULL);
    g_signal_connect (G_OBJECT (window), "destroy",
                      G_CALLBACK (destroy_message), NULL);

    g_signal_connect(G_OBJECT(ok), "button-press-event", G_CALLBACK(ok_cb), window);

    gtk_text_buffer_create_tag (buffer, "red",
                                "foreground", "red", NULL);  
    gtk_text_view_set_editable(GTK_TEXT_VIEW(result), FALSE);

    gtk_text_buffer_create_tag (buffer, "bold",
                                "weight", PANGO_WEIGHT_BOLD, NULL);  
    gtk_text_buffer_create_tag (buffer, "underline",
			      "underline", PANGO_UNDERLINE_SINGLE, NULL);
    gtk_text_buffer_create_tag (buffer, "heading",
                                "weight", PANGO_WEIGHT_BOLD,
                                "size", 15 * PANGO_SCALE,
                                NULL);
    return buffer;
}