Exemplo n.º 1
0
static void
add_button (GtkWidget   *section,
            const gchar *css_name)
{
  GtkWidget *image, *button;
  GdkDisplay *display;
  GdkCursor *cursor;

  display = gtk_widget_get_display (section);
  cursor = gdk_cursor_new_from_name (display, css_name);
  if (cursor == NULL)
    image = gtk_image_new_from_icon_name ("image-missing", GTK_ICON_SIZE_MENU);
  else
    {
      gchar *path;

      path = g_strdup_printf ("/cursors/%s_cursor.png", css_name);
      g_strdelimit (path, "-", '_');
      image = gtk_image_new_from_resource (path);
      g_free (path);
    }
  gtk_widget_set_size_request (image, 32, 32);
  button = gtk_button_new ();
  gtk_container_add (GTK_CONTAINER (button), image);
  gtk_style_context_add_class (gtk_widget_get_style_context (button), "image-button");
  g_signal_connect (button, "clicked", G_CALLBACK (set_cursor), cursor);

  gtk_widget_set_tooltip_text (button, css_name);
  gtk_container_add (GTK_CONTAINER (section), button);
}
void WebInspectorProxy::createInspectorWindow()
{
    if (m_client.openWindow(this))
        return;

    ASSERT(!m_inspectorWindow);
    m_inspectorWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);

    GtkWidget* inspectedViewParent = gtk_widget_get_toplevel(m_page->viewWidget());
    if (WebCore::widgetIsOnscreenToplevelWindow(inspectedViewParent))
        gtk_window_set_transient_for(GTK_WINDOW(m_inspectorWindow), GTK_WINDOW(inspectedViewParent));

#if GTK_CHECK_VERSION(3, 10, 0)
    m_headerBar = gtk_header_bar_new();
    gtk_header_bar_set_show_close_button(GTK_HEADER_BAR(m_headerBar), TRUE);

    m_dockBottomButton = gtk_button_new();
    g_object_add_weak_pointer(G_OBJECT(m_dockBottomButton), reinterpret_cast<void**>(&m_dockBottomButton));
    g_signal_connect(m_dockBottomButton, "clicked", G_CALLBACK(dockButtonClicked), this);
    gtk_widget_set_sensitive(m_dockBottomButton, canAttach());
    gtk_button_set_relief(GTK_BUTTON(m_dockBottomButton), GTK_RELIEF_NONE);
    gtk_button_set_image(GTK_BUTTON(m_dockBottomButton), gtk_image_new_from_resource("/org/webkitgtk/inspector/UserInterface/Images/DockBottom.svg"));
    gtk_header_bar_pack_start(GTK_HEADER_BAR(m_headerBar), m_dockBottomButton);
    gtk_widget_show(m_dockBottomButton);

    m_dockRightButton = gtk_button_new();
    g_object_add_weak_pointer(G_OBJECT(m_dockRightButton), reinterpret_cast<void**>(&m_dockRightButton));
    g_signal_connect(m_dockRightButton, "clicked", G_CALLBACK(dockButtonClicked), this);
    gtk_widget_set_sensitive(m_dockRightButton, canAttach());
    gtk_button_set_relief(GTK_BUTTON(m_dockRightButton), GTK_RELIEF_NONE);
    gtk_button_set_image(GTK_BUTTON(m_dockRightButton), gtk_image_new_from_resource("/org/webkitgtk/inspector/UserInterface/Images/DockRight.svg"));
    gtk_header_bar_pack_start(GTK_HEADER_BAR(m_headerBar), m_dockRightButton);
    gtk_widget_show(m_dockRightButton);

    gtk_window_set_titlebar(GTK_WINDOW(m_inspectorWindow), m_headerBar);
    gtk_widget_show(m_headerBar);
#endif

    updateInspectorWindowTitle();
    gtk_window_set_default_size(GTK_WINDOW(m_inspectorWindow), initialWindowWidth, initialWindowHeight);

    gtk_container_add(GTK_CONTAINER(m_inspectorWindow), m_inspectorView);
    gtk_widget_show(m_inspectorView);

    g_object_add_weak_pointer(G_OBJECT(m_inspectorWindow), reinterpret_cast<void**>(&m_inspectorWindow));
    gtk_window_present(GTK_WINDOW(m_inspectorWindow));
}
Exemplo n.º 3
0
MidiogreApp *midiogre_app_init(void)
{
    MidiogreApp *app;

    GtkWidget *header;
    GtkWidget *separator;
    GtkWidget *scrolled;
    GtkWidget *label,*frame;
    GtkWidget *button;
    GtkBox *box;

    gint i;
    GError *err;

    /* Allocate app */
    app = calloc(1, sizeof(MidiogreApp));


    /* Setup window */
    app->window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL));
    gtk_window_set_default_size(GTK_WINDOW(app->window), 600, 400);
    g_signal_connect(app->window, "destroy", G_CALLBACK(gtk_widget_destroyed), NULL);
    g_signal_connect(app->window, "key-release-event", G_CALLBACK(key_event), NULL);
    gtk_window_set_icon(app->window,gdk_pixbuf_new_from_resource("/org/prozum/midiogre/midiogre_logo.png",&err));


    /* Setup header bar */
    header = gtk_header_bar_new();
    gtk_header_bar_set_title (GTK_HEADER_BAR(header), "Midiogre");
    gtk_window_set_titlebar(app->window, header);

    /* Setup close button */
    button = gtk_button_new();
    gtk_container_add (GTK_CONTAINER(button), gtk_image_new_from_resource("/org/prozum/midiogre/icons/window-close-symbolic.symbolic.png"));
    gtk_header_bar_pack_end(GTK_HEADER_BAR(header), button);
    g_signal_connect_swapped(button, "clicked", G_CALLBACK(gtk_main_quit), app->window);


    /* Add seperator */
    separator = gtk_separator_new(GTK_ORIENTATION_VERTICAL);
    gtk_header_bar_pack_end(GTK_HEADER_BAR(header), separator);


    /* Setup folder button */
    button = gtk_button_new();
    gtk_container_add (GTK_CONTAINER(button), gtk_image_new_from_resource("/org/prozum/midiogre/icons/document-open-symbolic.symbolic.png"));
    gtk_header_bar_pack_end(GTK_HEADER_BAR(header), button);
    g_signal_connect_swapped(button, "clicked", G_CALLBACK(folder_chooser), app->window);

    /* Global horizontal box */
    app->win_box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0));
    gtk_container_add(GTK_CONTAINER(app->window), GTK_WIDGET(app->win_box));


    /* Scroll container for sidepanel */
    scrolled = gtk_scrolled_window_new(NULL, NULL);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (scrolled), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
    gtk_box_pack_start(app->win_box, scrolled, FALSE, FALSE, 0);


    /* Sidepanel box */
    app->panel_box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, 0));
    gtk_container_add(GTK_CONTAINER (scrolled), GTK_WIDGET(app->panel_box));
    gtk_container_set_border_width(GTK_CONTAINER(app->panel_box), 10);


    /* Frame with favorit info */
    frame = gtk_frame_new("Favorite");
    gtk_box_pack_start(app->panel_box, frame, FALSE, FALSE, 0);
    app->fav_box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, 0));
    gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(app->fav_box));


    /* Current favorite */
    app->fav_title_label = GTK_LABEL(gtk_label_new(""));
    gtk_label_set_max_width_chars(app->fav_title_label, 20);
    gtk_label_set_width_chars(app->fav_title_label, 20);
    gtk_box_pack_start(app->fav_box, GTK_WIDGET(app->fav_title_label), FALSE, FALSE, 0);
    app->fav_artist_label = GTK_LABEL(gtk_label_new("No favorite selected!"));
    gtk_label_set_max_width_chars(app->fav_artist_label, 20);
    gtk_label_set_width_chars(app->fav_artist_label, 20);
    gtk_box_pack_start(app->fav_box, GTK_WIDGET(app->fav_artist_label), FALSE, FALSE, 0);
    app->fav_album_label = GTK_LABEL(gtk_label_new(""));
    gtk_label_set_max_width_chars(app->fav_album_label, 20);
    gtk_label_set_width_chars(app->fav_album_label, 20);
    gtk_box_pack_start(app->fav_box, GTK_WIDGET(app->fav_album_label), FALSE, FALSE, 0);


    /* Frame with search criteria widgets */
    frame = gtk_frame_new("Search");
    gtk_box_pack_start(app->panel_box, frame, FALSE, FALSE, 0);

    app->search_box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, 10));
    gtk_container_set_border_width(GTK_CONTAINER(app->search_box), 10);

    gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(app->search_box));


    /* Title entry */
    frame = gtk_frame_new("Title");
    gtk_box_pack_start(app->search_box, frame, FALSE, FALSE, 0);

    box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0));
    gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(box));
    gtk_container_set_border_width(GTK_CONTAINER(box), 10);

    app->title_entry = GTK_ENTRY(gtk_entry_new());
    gtk_box_pack_start(box, GTK_WIDGET(app->title_entry), TRUE, FALSE, 0);


    /* Artist entry */
    frame = gtk_frame_new("Artist");
    gtk_box_pack_start(app->search_box, frame, FALSE, FALSE, 0);
    gtk_container_set_border_width(GTK_CONTAINER(box), 10);

    box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0));
    gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(box));
    gtk_container_set_border_width(GTK_CONTAINER(box), 10);

    app->artist_entry = GTK_ENTRY(gtk_entry_new());
    gtk_box_pack_start(box, GTK_WIDGET(app->artist_entry), TRUE, FALSE, 0);


    /* Album entry */
    frame = gtk_frame_new("Album");
    gtk_box_pack_start(app->search_box, frame, FALSE, FALSE, 0);

    box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0));
    gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(box));
    gtk_container_set_border_width(GTK_CONTAINER(box), 10);

    app->album_entry = GTK_ENTRY(gtk_entry_new());
    gtk_box_pack_start(box, GTK_WIDGET(app->album_entry), TRUE, FALSE, 0);


    /* Instrument class buttons */
    frame = gtk_frame_new("Instrument Classes");
    gtk_box_pack_start(app->search_box, frame, FALSE, FALSE, 0);

    app->instr_grid = GTK_GRID(gtk_grid_new());

#if GTK_MINOR_VERSION >= 12
    gtk_widget_set_margin_start(GTK_WIDGET(app->instr_grid), 10);
    gtk_widget_set_margin_end(GTK_WIDGET(app->instr_grid), 10);
#else
    gtk_widget_set_margin_left(GTK_WIDGET(app->instr_grid), 10);
    gtk_widget_set_margin_right(GTK_WIDGET(app->instr_grid), 10);
#endif
    gtk_widget_set_margin_bottom(GTK_WIDGET(app->instr_grid), 10);
    gtk_widget_set_margin_top(GTK_WIDGET(app->instr_grid), 10);
    gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(app->instr_grid));


    for (i = 0; i < INSTR_CLASSES; i++) {

        label = gtk_label_new(instrument_classes[i]);
        gtk_widget_set_halign(GTK_WIDGET(label), GTK_ALIGN_START);
        gtk_grid_attach(app->instr_grid, label, 1, i + 1, 1, 1);

        app->instr_buttons[i] = GTK_CHECK_BUTTON(gtk_check_button_new());
        gtk_widget_set_halign(GTK_WIDGET(app->instr_buttons[i]), GTK_ALIGN_END);
        gtk_grid_attach(app->instr_grid, GTK_WIDGET(app->instr_buttons[i]), 2, i + 1, 1, 1);
    }


    /* Result spinbutton */
    frame = gtk_frame_new("Max result");
    gtk_box_pack_start(app->search_box, frame, FALSE, FALSE, 0);

    box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0));
    gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(box));
    gtk_container_set_border_width(GTK_CONTAINER(box), 10);

    app->result_spinbutton = GTK_SPIN_BUTTON(gtk_spin_button_new_with_range(1, 100, 1));
    gtk_spin_button_set_value(app->result_spinbutton, 25);

    gtk_box_pack_start(box, GTK_WIDGET(app->result_spinbutton), TRUE, TRUE, 0);

    /* Search button */
    app->search_button = GTK_BUTTON(gtk_button_new_with_label("Search"));
    gtk_box_pack_start(app->search_box, GTK_WIDGET(app->search_button), FALSE, FALSE, 0);
    g_signal_connect_swapped(app->search_button, "clicked", G_CALLBACK(search_event), app);


    /* Songboxes notebook (Tabsview) */
    app->song_notebook = GTK_NOTEBOOK(gtk_notebook_new());
    gtk_widget_set_hexpand(GTK_WIDGET(app->song_notebook), TRUE);
    gtk_box_pack_start(app->win_box, GTK_WIDGET(app->song_notebook), TRUE, TRUE, 0);


    /* Add song boxes */
    app->songboxes[SONGBOX_ALPHA] = songbox_new(app->song_notebook, "Alphabetical");
    app->songboxes[SONGBOX_FPRNT] = songbox_new(app->song_notebook, "Fingerprint");
    app->songboxes[SONGBOX_BEST]  = songbox_new(app->song_notebook, "Best Match");
    app->songboxes[SONGBOX_POP]   = songbox_new(app->song_notebook, "Popularity");
    app->songboxes[SONGBOX_NEW]   = songbox_new(app->song_notebook, "Newest");


    /* Show all widgets */
    gtk_widget_show_all(GTK_WIDGET(app->window));


    /* Allocate song queue */
    app->songs[SONGBOX_ALPHA]   = g_queue_new();
    app->songs[SONGBOX_FPRNT]   = g_queue_new();
    app->songs[SONGBOX_BEST]    = g_queue_new();
    app->songs[SONGBOX_POP]     = g_queue_new();
    app->songs[SONGBOX_NEW]     = g_queue_new();


    return app;
}
Exemplo n.º 4
0
GtkWidget *
do_images (GtkWidget *do_widget)
{
  GtkWidget *frame;
  GtkWidget *vbox;
  GtkWidget *image;
  GtkWidget *label;
  GtkWidget *button;
  GIcon     *gicon;

  if (!window)
    {
      window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
      gtk_window_set_screen (GTK_WINDOW (window),
                             gtk_widget_get_screen (do_widget));
      gtk_window_set_title (GTK_WINDOW (window), "Images");

      g_signal_connect (window, "destroy",
                        G_CALLBACK (gtk_widget_destroyed), &window);
      g_signal_connect (window, "destroy",
                        G_CALLBACK (cleanup_callback), NULL);

      gtk_container_set_border_width (GTK_CONTAINER (window), 8);

      vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
      gtk_container_set_border_width (GTK_CONTAINER (vbox), 8);
      gtk_container_add (GTK_CONTAINER (window), vbox);

      label = gtk_label_new (NULL);
      gtk_label_set_markup (GTK_LABEL (label),
                            "<u>Image loaded from a file</u>");
      gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);

      frame = gtk_frame_new (NULL);
      gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
      gtk_widget_set_halign (frame, GTK_ALIGN_CENTER);
      gtk_widget_set_valign (frame, GTK_ALIGN_CENTER);
      gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);

      image = gtk_image_new_from_icon_name ("gtk3-demo", GTK_ICON_SIZE_DIALOG);

      gtk_container_add (GTK_CONTAINER (frame), image);


      /* Animation */

      label = gtk_label_new (NULL);
      gtk_label_set_markup (GTK_LABEL (label),
                            "<u>Animation loaded from a file</u>");
      gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);

      frame = gtk_frame_new (NULL);
      gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
      gtk_widget_set_halign (frame, GTK_ALIGN_CENTER);
      gtk_widget_set_valign (frame, GTK_ALIGN_CENTER);
      gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);

      image = gtk_image_new_from_resource ("/images/floppybuddy.gif");

      gtk_container_add (GTK_CONTAINER (frame), image);

      /* Symbolic icon */

      label = gtk_label_new (NULL);
      gtk_label_set_markup (GTK_LABEL (label),
                            "<u>Symbolic themed icon</u>");
      gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);

      frame = gtk_frame_new (NULL);
      gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
      gtk_widget_set_halign (frame, GTK_ALIGN_CENTER);
      gtk_widget_set_valign (frame, GTK_ALIGN_CENTER);
      gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);

      gicon = g_themed_icon_new_with_default_fallbacks ("battery-caution-charging-symbolic");
      image = gtk_image_new_from_gicon (gicon, GTK_ICON_SIZE_DIALOG);

      gtk_container_add (GTK_CONTAINER (frame), image);


      /* Progressive */

      label = gtk_label_new (NULL);
      gtk_label_set_markup (GTK_LABEL (label),
                            "<u>Progressive image loading</u>");
      gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);

      frame = gtk_frame_new (NULL);
      gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
      gtk_widget_set_halign (frame, GTK_ALIGN_CENTER);
      gtk_widget_set_valign (frame, GTK_ALIGN_CENTER);
      gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);

      /* Create an empty image for now; the progressive loader
       * will create the pixbuf and fill it in.
       */
      image = gtk_image_new_from_pixbuf (NULL);
      gtk_container_add (GTK_CONTAINER (frame), image);

      start_progressive_loading (image);

      /* Sensitivity control */
      button = gtk_toggle_button_new_with_mnemonic ("_Insensitive");
      gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);

      g_signal_connect (button, "toggled",
                        G_CALLBACK (toggle_sensitivity_callback),
                        vbox);
    }

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

  return window;
}
Exemplo n.º 5
0
static void
add_data_tab (const gchar *demoname)
{
  gchar *resource_dir, *resource_name, *content_type, *content_mime;
  gchar **resources;
  GBytes *bytes;
  GtkWidget *widget, *label;
  guint i;

  resource_dir = g_strconcat ("/", demoname, NULL);
  resources = g_resources_enumerate_children (resource_dir, 0, NULL);
  if (resources == NULL)
    {
      g_free (resource_dir);
      return;
    }

  for (i = 0; resources[i]; i++)
    {
      resource_name = g_strconcat (resource_dir, "/", resources[i], NULL);
      bytes = g_resources_lookup_data (resource_name, 0, NULL);
      g_assert (bytes);

      content_type = g_content_type_guess (resource_name,
                                           g_bytes_get_data (bytes, NULL),
                                           g_bytes_get_size (bytes),
                                           NULL);
      content_mime = g_content_type_get_mime_type (content_type);

      /* In theory we should look at all the mime types gdk-pixbuf supports
       * and go from there, but we know what file types we've added.
       */
      if (g_content_type_is_a (content_mime, "image/png") ||
          g_content_type_is_a (content_mime, "image/gif") ||
          g_content_type_is_a (content_mime, "image/jpeg"))
        {
          widget = gtk_image_new_from_resource (resource_name);
        }
      else if (g_content_type_is_a (content_mime, "text/plain") ||
               g_content_type_is_a (content_mime, "application/x-ext-ui") ||
               g_content_type_is_a (content_mime, "text/css"))
        {
          GtkTextBuffer *buffer;
          GtkWidget *textview;

          widget = create_text (&textview, FALSE);
          buffer = gtk_text_buffer_new (NULL);
          gtk_text_buffer_set_text (buffer, g_bytes_get_data (bytes, NULL), g_bytes_get_size (bytes));
          gtk_text_view_set_buffer (GTK_TEXT_VIEW (textview), buffer);
        }
      else
        {

          g_warning ("Don't know how to display resource '%s' of type '%s'\n", resource_name, content_mime);
          widget = NULL;
        }

      gtk_widget_show_all (widget);
      label = gtk_label_new (resources[i]);
      gtk_widget_show (label);
      gtk_notebook_append_page (GTK_NOTEBOOK (notebook), widget, label);
      gtk_container_child_set (GTK_CONTAINER (notebook),
                               GTK_WIDGET (widget),
                               "tab-expand", TRUE,
                               NULL);

      g_free (content_mime);
      g_free (content_type);
      g_free (resource_name);
      g_bytes_unref (bytes);
    }

  g_strfreev (resources);
  g_free (resource_dir);
}
Exemplo n.º 6
0
static void
add_data_tab (const gchar *demoname)
{
  gchar *resource_dir, *resource_name;
  gchar **resources;
  GtkWidget *widget, *label;
  guint i;

  resource_dir = g_strconcat ("/", demoname, NULL);
  resources = g_resources_enumerate_children (resource_dir, 0, NULL);
  if (resources == NULL)
    {
      g_free (resource_dir);
      return;
    }

  for (i = 0; resources[i]; i++)
    {
      resource_name = g_strconcat (resource_dir, "/", resources[i], NULL);

      widget = gtk_image_new_from_resource (resource_name);
      if (gtk_image_get_pixbuf (GTK_IMAGE (widget)) == NULL &&
          gtk_image_get_animation (GTK_IMAGE (widget)) == NULL)
        {
          GBytes *bytes;

          /* So we've used the best API available to figure out it's
           * not an image. Let's try something else then.
           */
          g_object_ref_sink (widget);
          g_object_unref (widget);

          bytes = g_resources_lookup_data (resource_name, 0, NULL);
          g_assert (bytes);

          if (g_utf8_validate (g_bytes_get_data (bytes, NULL), g_bytes_get_size (bytes), NULL))
            {
              /* Looks like it parses as text. Dump it into a textview then! */
              GtkTextBuffer *buffer;
              GtkWidget *textview;

              widget = create_text (&textview, FALSE);
              buffer = gtk_text_buffer_new (NULL);
              gtk_text_buffer_set_text (buffer, g_bytes_get_data (bytes, NULL), g_bytes_get_size (bytes));
              gtk_text_view_set_buffer (GTK_TEXT_VIEW (textview), buffer);
            }
          else
            {
              g_warning ("Don't know how to display resource '%s'\n", resource_name);
              widget = NULL;
            }

          g_bytes_unref (bytes);
        }

      gtk_widget_show_all (widget);
      label = gtk_label_new (resources[i]);
      gtk_widget_show (label);
      gtk_notebook_append_page (GTK_NOTEBOOK (notebook), widget, label);
      gtk_container_child_set (GTK_CONTAINER (notebook),
                               GTK_WIDGET (widget),
                               "tab-expand", TRUE,
                               NULL);

      g_free (resource_name);
    }

  g_strfreev (resources);
  g_free (resource_dir);
}
Exemplo n.º 7
0
Arquivo: textview.c Projeto: GYGit/gtk
static void
attach_widgets (GtkTextView *text_view)
{
  GtkTextIter iter;
  GtkTextBuffer *buffer;
  int i;

  buffer = gtk_text_view_get_buffer (text_view);

  gtk_text_buffer_get_start_iter (buffer, &iter);

  i = 0;
  while (find_anchor (&iter))
    {
      GtkTextChildAnchor *anchor;
      GtkWidget *widget;

      anchor = gtk_text_iter_get_child_anchor (&iter);

      if (i == 0)
        {
          widget = gtk_button_new_with_label ("Click Me");

          g_signal_connect (widget, "clicked",
                            G_CALLBACK (easter_egg_callback),
                            NULL);
        }
      else if (i == 1)
        {
          widget = gtk_combo_box_text_new ();

          gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Option 1");
          gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Option 2");
          gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Option 3");
        }
      else if (i == 2)
        {
          widget = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, NULL);
          gtk_range_set_range (GTK_RANGE (widget), 0, 100);
          gtk_widget_set_size_request (widget, 70, -1);
        }
      else if (i == 3)
        {
          widget = gtk_image_new_from_resource ("/textview/floppybuddy.gif");
        }
      else if (i == 4)
        {
          widget = gtk_entry_new ();
        }
      else
        {
          widget = NULL; /* avoids a compiler warning */
          g_assert_not_reached ();
        }

      gtk_text_view_add_child_at_anchor (text_view,
                                         widget,
                                         anchor);

      gtk_widget_show_all (widget);

      ++i;
    }
}