Example #1
0
static void
background_loaded_cb (GObject      *source,
                      GAsyncResult *res,
                      gpointer      data)
{
  BackgroundData *bd = data;
  GtkWidget *child;
  GdkPixbuf *pixbuf;
  GError *error = NULL;

  pixbuf = gdk_pixbuf_new_from_stream_finish (res, &error);
  if (error)
    {
      g_warning ("Error loading '%s': %s", bd->filename, error->message);
      g_error_free (error);
      return;
    }

  child = gtk_image_new_from_pixbuf (pixbuf);
  gtk_widget_show (child);
  gtk_flow_box_insert (GTK_FLOW_BOX (bd->flowbox), child, -1);
  child = gtk_widget_get_parent (child);
  g_object_set_data_full (G_OBJECT (child), "filename", bd->filename, g_free);
  g_free (bd);
}
Example #2
0
static void
populate_flowbox (GtkWidget *button, GtkWidget *flowbox)
{
  const gchar *location;
  GDir *dir;
  GError *error = NULL;
  const gchar *name;
  gchar *filename;
  GFile *file;
  GInputStream *stream;
  BackgroundData *bd;
  GdkPixbuf *pixbuf;
  GtkWidget *child;

  g_signal_handlers_disconnect_by_func (button, populate_flowbox, flowbox);

  pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 110, 70);
  gdk_pixbuf_fill (pixbuf, 0xffffffff);
  child = gtk_image_new_from_pixbuf (pixbuf);
  gtk_widget_show (child);
  gtk_flow_box_insert (GTK_FLOW_BOX (flowbox), child, -1);

  location = "/usr/share/backgrounds/gnome";
  dir = g_dir_open (location, 0, &error);
  if (error)
    {
      g_warning ("%s", error->message);
      g_error_free (error);
      return;
    }

  while ((name = g_dir_read_name (dir)) != NULL)
    {
      filename = g_build_filename (location, name, NULL);
      file = g_file_new_for_path (filename);
      stream = G_INPUT_STREAM (g_file_read (file, NULL, &error));
      if (error)
        {
          g_warning ("%s", error->message);
          g_clear_error (&error);
          g_free (filename); 
        }
      else
        {
          bd = g_new (BackgroundData, 1);
          bd->flowbox = flowbox;
          bd->filename = filename;
          gdk_pixbuf_new_from_stream_at_scale_async (stream, 110, 110, TRUE, NULL, 
                                                     background_loaded_cb, bd);
        }

      g_object_unref (file);
      g_object_unref (stream);
    }

  g_dir_close (dir);
}
Example #3
0
static GtkWidget *
add_section (GtkWidget   *box,
             const gchar *heading)
{
  GtkWidget *label;
  GtkWidget *section;

  label = gtk_label_new (heading);
  gtk_label_set_xalign (GTK_LABEL (label), 0.0);
  gtk_widget_set_margin_top (label, 10);
  gtk_widget_set_margin_bottom (label, 10);
  gtk_box_pack_start (GTK_BOX (box), label, FALSE, TRUE, 0);
  section = gtk_flow_box_new ();
  gtk_widget_set_halign (section, GTK_ALIGN_START);
  gtk_flow_box_set_selection_mode (GTK_FLOW_BOX (section), GTK_SELECTION_NONE);
  gtk_flow_box_set_min_children_per_line (GTK_FLOW_BOX (section), 2);
  gtk_flow_box_set_max_children_per_line (GTK_FLOW_BOX (section), 20);
  gtk_box_pack_start (GTK_BOX (box), section, FALSE, TRUE, 0);

  return section;
}
/**
 * gs_shell_overview_get_categories_cb:
 **/
static void
gs_shell_overview_get_categories_cb (GObject *source_object,
				     GAsyncResult *res,
				     gpointer user_data)
{
	GsShellOverview *self = GS_SHELL_OVERVIEW (user_data);
	GsShellOverviewPrivate *priv = gs_shell_overview_get_instance_private (self);
	GsPluginLoader *plugin_loader = GS_PLUGIN_LOADER (source_object);
	GList *l;
	GsCategory *cat;
	GtkWidget *tile;
	gboolean has_category = FALSE;
	g_autoptr(GError) error = NULL;
	g_autoptr(GsAppList) list = NULL;

	list = gs_plugin_loader_get_categories_finish (plugin_loader, res, &error);
	if (list == NULL) {
		if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
			g_warning ("failed to get categories: %s", error->message);
		goto out;
	}
	gs_container_remove_all (GTK_CONTAINER (priv->flowbox_categories));

	for (l = list; l; l = l->next) {
		cat = GS_CATEGORY (l->data);
		if (gs_category_get_size (cat) == 0)
			continue;
		tile = gs_category_tile_new (cat);
		g_signal_connect (tile, "clicked",
				  G_CALLBACK (category_tile_clicked), self);
		gtk_flow_box_insert (GTK_FLOW_BOX (priv->flowbox_categories), tile, -1);
		gtk_widget_set_can_focus (gtk_widget_get_parent (tile), FALSE);
		has_category = TRUE;
	}
out:
	if (has_category) {
		priv->empty = FALSE;
	}
	gtk_widget_set_visible (priv->category_heading, has_category);

	priv->loading_categories = FALSE;
	priv->refresh_count--;
	if (priv->refresh_count == 0) {
		priv->cache_valid = TRUE;
		g_signal_emit (self, signals[SIGNAL_REFRESHED], 0);
	}
}
Example #5
0
static void agreement_app_window_init(AgreementAppWindow *win)
{
    gtk_window_set_title(GTK_WINDOW(win), "Agreement");
    gtk_window_set_default_size(GTK_WINDOW(win), 800, 500);

    GtkWidget* grid;
    grid = gtk_grid_new();
    gtk_container_add(GTK_CONTAINER(win), grid);

    GtkWidget *view;
    view = gtk_text_view_new();
    gtk_widget_set_hexpand(view, true);
    gtk_widget_set_vexpand(view, true);
    gtk_grid_attach(GTK_GRID(grid), view, 0, 0, 1, 1);

    agreement_text_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(view));
    gtk_text_buffer_set_text(agreement_text_buffer, "No file loaded", -1);

    GtkWidget *flow_box;
    flow_box = gtk_flow_box_new();
    gtk_flow_box_set_min_children_per_line(GTK_FLOW_BOX(flow_box), 2);
    gtk_widget_set_halign(flow_box, GTK_ALIGN_CENTER);
    gtk_grid_attach(GTK_GRID(grid), flow_box, 0, 1, 1, 1);

    GtkWidget *no_button;
    no_button = gtk_button_new_from_icon_name("window-close", GTK_ICON_SIZE_BUTTON);
    gtk_button_set_always_show_image(GTK_BUTTON(no_button), true);
    gtk_button_set_label(GTK_BUTTON(no_button), "No, I do not agree");
    gtk_container_add(GTK_CONTAINER(flow_box), no_button);

    GtkWidget *yes_button;
    yes_button = gtk_button_new_from_icon_name("go-next", GTK_ICON_SIZE_BUTTON);
    gtk_button_set_always_show_image(GTK_BUTTON(yes_button), true);
    gtk_button_set_label(GTK_BUTTON(yes_button), "Yes, I agree");
    gtk_container_add(GTK_CONTAINER(flow_box), yes_button);

    gtk_widget_show_all(GTK_WIDGET(win));
}
Example #6
0
static GtkWidget *
create_window (void)
{
  GtkWidget *window, *hbox, *vbox, *flowbox_cntl, *items_cntl;
  GtkWidget *flowbox, *widget, *expander, *swindow;

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  hbox   = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
  vbox   = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);

  gtk_container_set_border_width (GTK_CONTAINER (window), 8);

  gtk_widget_show (vbox);
  gtk_widget_show (hbox);
  gtk_container_add (GTK_CONTAINER (window), hbox);
  gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);

  swindow = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swindow),
                                  GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);

  gtk_widget_show (swindow);
  gtk_box_pack_start (GTK_BOX (hbox), swindow, TRUE, TRUE, 0);

  flowbox = gtk_flow_box_new ();
  gtk_widget_set_halign (flowbox, GTK_ALIGN_END);
  the_flowbox = (GtkFlowBox *)flowbox;
  gtk_widget_set_halign (flowbox, INITIAL_HALIGN);
  gtk_widget_set_valign (flowbox, INITIAL_VALIGN);
  gtk_flow_box_set_column_spacing (GTK_FLOW_BOX (flowbox), INITIAL_CSPACING);
  gtk_flow_box_set_row_spacing (GTK_FLOW_BOX (flowbox), INITIAL_RSPACING);
  gtk_flow_box_set_min_children_per_line (GTK_FLOW_BOX (flowbox), INITIAL_MINIMUM_LENGTH);
  gtk_flow_box_set_max_children_per_line (GTK_FLOW_BOX (flowbox), INITIAL_MAXIMUM_LENGTH);
  gtk_widget_show (flowbox);
  gtk_container_add (GTK_CONTAINER (swindow), flowbox);

  gtk_flow_box_set_hadjustment (GTK_FLOW_BOX (flowbox),
                                gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (swindow)));
  gtk_flow_box_set_vadjustment (GTK_FLOW_BOX (flowbox),
                                gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (swindow)));

  g_signal_connect (flowbox, "child-activated", G_CALLBACK (on_child_activated), NULL);
  g_signal_connect (flowbox, "selected-children-changed", G_CALLBACK (on_selected_children_changed), NULL);

  /* Add Flowbox test control frame */
  expander = gtk_expander_new ("Flow Box controls");
  gtk_expander_set_expanded (GTK_EXPANDER (expander), TRUE);
  flowbox_cntl = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
  gtk_widget_show (flowbox_cntl);
  gtk_widget_show (expander);
  gtk_container_add (GTK_CONTAINER (expander), flowbox_cntl);
  gtk_box_pack_start (GTK_BOX (vbox), expander, FALSE, FALSE, 0);

  widget = gtk_check_button_new_with_label ("Homogeneous");
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);
  gtk_widget_show (widget);

  gtk_widget_set_tooltip_text (widget, "Set whether the items should be displayed at the same size");
  gtk_box_pack_start (GTK_BOX (flowbox_cntl), widget, FALSE, FALSE, 0);

  g_signal_connect (G_OBJECT (widget), "toggled",
                    G_CALLBACK (homogeneous_toggled), flowbox);

  widget = gtk_check_button_new_with_label ("Activate on single click");
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);
  g_object_bind_property (widget, "active",
                          flowbox, "activate-on-single-click",
                          G_BINDING_SYNC_CREATE);
  gtk_widget_show (widget);
  gtk_box_pack_start (GTK_BOX (flowbox_cntl), widget, FALSE, FALSE, 0);

  /* Add alignment controls */
  widget = gtk_combo_box_text_new ();
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Fill");
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Start");
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "End");
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Center");
  gtk_combo_box_set_active (GTK_COMBO_BOX (widget), INITIAL_HALIGN);
  gtk_widget_show (widget);

  gtk_widget_set_tooltip_text (widget, "Set the horizontal alignment policy");
  gtk_box_pack_start (GTK_BOX (flowbox_cntl), widget, FALSE, FALSE, 0);

  g_signal_connect (G_OBJECT (widget), "changed",
                    G_CALLBACK (horizontal_alignment_changed), flowbox);

  widget = gtk_combo_box_text_new ();
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Fill");
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Start");
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "End");
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Center");
  gtk_combo_box_set_active (GTK_COMBO_BOX (widget), INITIAL_VALIGN);
  gtk_widget_show (widget);

  gtk_widget_set_tooltip_text (widget, "Set the vertical alignment policy");
  gtk_box_pack_start (GTK_BOX (flowbox_cntl), widget, FALSE, FALSE, 0);

  g_signal_connect (G_OBJECT (widget), "changed",
                    G_CALLBACK (vertical_alignment_changed), flowbox);

  /* Add Orientation control */
  widget = gtk_combo_box_text_new ();
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Horizontal");
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Vertical");
  gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
  gtk_widget_show (widget);

  gtk_widget_set_tooltip_text (widget, "Set the flowbox orientation");
  gtk_box_pack_start (GTK_BOX (flowbox_cntl), widget, FALSE, FALSE, 0);

  g_signal_connect (G_OBJECT (widget), "changed",
                    G_CALLBACK (orientation_changed), flowbox);

  /* Add selection mode control */
  widget = gtk_combo_box_text_new ();
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "None");
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Single");
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Browse");
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Multiple");
  gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 1);
  gtk_widget_show (widget);

  gtk_widget_set_tooltip_text (widget, "Set the selection mode");
  gtk_box_pack_start (GTK_BOX (flowbox_cntl), widget, FALSE, FALSE, 0);

  g_signal_connect (G_OBJECT (widget), "changed",
                    G_CALLBACK (selection_mode_changed), flowbox);

  /* Add minimum line length in items control */
  widget = gtk_spin_button_new_with_range (1, 10, 1);
  gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), INITIAL_MINIMUM_LENGTH);
  gtk_widget_show (widget);

  gtk_widget_set_tooltip_text (widget, "Set the minimum amount of items per line before wrapping");
  gtk_box_pack_start (GTK_BOX (flowbox_cntl), widget, FALSE, FALSE, 0);

  g_signal_connect (G_OBJECT (widget), "changed",
                    G_CALLBACK (line_length_changed), flowbox);
  g_signal_connect (G_OBJECT (widget), "value-changed",
                    G_CALLBACK (line_length_changed), flowbox);

  /* Add natural line length in items control */
  widget = gtk_spin_button_new_with_range (1, 10, 1);
  gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), INITIAL_MAXIMUM_LENGTH);
  gtk_widget_show (widget);

  gtk_widget_set_tooltip_text (widget, "Set the natural amount of items per line ");
  gtk_box_pack_start (GTK_BOX (flowbox_cntl), widget, FALSE, FALSE, 0);

  g_signal_connect (G_OBJECT (widget), "changed",
                    G_CALLBACK (max_line_length_changed), flowbox);
  g_signal_connect (G_OBJECT (widget), "value-changed",
                    G_CALLBACK (max_line_length_changed), flowbox);

  /* Add horizontal/vertical spacing controls */
  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
  gtk_widget_show (hbox);

  widget = gtk_label_new ("H Spacing");
  gtk_widget_show (widget);
  gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);

  widget = gtk_spin_button_new_with_range (0, 30, 1);
  gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), INITIAL_CSPACING);
  gtk_widget_show (widget);

  gtk_widget_set_tooltip_text (widget, "Set the horizontal spacing between children");
  gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);

  g_signal_connect (G_OBJECT (widget), "changed",
                    G_CALLBACK (spacing_changed), GINT_TO_POINTER (GTK_ORIENTATION_HORIZONTAL));
  g_signal_connect (G_OBJECT (widget), "value-changed",
                    G_CALLBACK (spacing_changed), GINT_TO_POINTER (GTK_ORIENTATION_HORIZONTAL));

  gtk_box_pack_start (GTK_BOX (flowbox_cntl), hbox, FALSE, FALSE, 0);

  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
  gtk_widget_show (hbox);

  widget = gtk_label_new ("V Spacing");
  gtk_widget_show (widget);
  gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);

  widget = gtk_spin_button_new_with_range (0, 30, 1);
  gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), INITIAL_RSPACING);
  gtk_widget_show (widget);

  gtk_widget_set_tooltip_text (widget, "Set the vertical spacing between children");
  gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);

  g_signal_connect (G_OBJECT (widget), "changed",
                    G_CALLBACK (spacing_changed), GINT_TO_POINTER (GTK_ORIENTATION_VERTICAL));
  g_signal_connect (G_OBJECT (widget), "value-changed",
                    G_CALLBACK (spacing_changed), GINT_TO_POINTER (GTK_ORIENTATION_VERTICAL));

  gtk_box_pack_start (GTK_BOX (flowbox_cntl), hbox, FALSE, FALSE, 0);

  /* filtering and sorting */

  widget = gtk_check_button_new_with_label ("Filter");
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);
  gtk_widget_show (widget);

  gtk_widget_set_tooltip_text (widget, "Set whether some items should be filtered out");
  gtk_box_pack_start (GTK_BOX (flowbox_cntl), widget, FALSE, FALSE, 0);

  g_signal_connect (G_OBJECT (widget), "toggled",
                    G_CALLBACK (filter_toggled), flowbox);

  widget = gtk_check_button_new_with_label ("Sort");
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);
  gtk_widget_show (widget);

  gtk_widget_set_tooltip_text (widget, "Set whether items should be sorted");
  gtk_box_pack_start (GTK_BOX (flowbox_cntl), widget, FALSE, FALSE, 0);

  g_signal_connect (G_OBJECT (widget), "toggled",
                    G_CALLBACK (sort_toggled), flowbox);


  /* Add test items control frame */
  expander = gtk_expander_new ("Test item controls");
  gtk_expander_set_expanded (GTK_EXPANDER (expander), TRUE);
  items_cntl = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
  gtk_widget_show (items_cntl);
  gtk_widget_show (expander);
  gtk_container_add (GTK_CONTAINER (expander), items_cntl);
  gtk_box_pack_start (GTK_BOX (vbox), expander, FALSE, FALSE, 0);

  /* Add Items control */
  widget = gtk_combo_box_text_new ();
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Simple");
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Focus");
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Wrappy");
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Stock");
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Images");
  gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
  gtk_widget_show (widget);

  gtk_widget_set_tooltip_text (widget, "Set the item set to use");
  gtk_box_pack_start (GTK_BOX (items_cntl), widget, FALSE, FALSE, 0);

  g_signal_connect (G_OBJECT (widget), "changed",
                    G_CALLBACK (items_changed), flowbox);


  /* Add Text Orientation control */
  widget = gtk_combo_box_text_new ();
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Horizontal");
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (widget), "Vertical");
  gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
  gtk_widget_show (widget);

  gtk_widget_set_tooltip_text (widget, "Set the item's text orientation (cant be done for stock buttons)");
  gtk_box_pack_start (GTK_BOX (items_cntl), widget, FALSE, FALSE, 0);

  g_signal_connect (G_OBJECT (widget), "changed",
                    G_CALLBACK (text_orientation_changed), flowbox);

  populate_items (GTK_FLOW_BOX (flowbox));

  /* This line was added only for the convenience of reproducing
   * a height-for-width inside GtkScrolledWindow bug (bug 629778).
   *   -Tristan
   */
  gtk_window_set_default_size (GTK_WINDOW (window), 390, -1);

  return window;
}
Example #7
0
static void
gs_editor_startup_cb (GtkApplication *application, GsEditor *self)
{
	GtkTextBuffer *buffer;
	GtkWidget *main_window;
	GtkWidget *widget;
	gboolean ret;
	guint retval;
	g_autoptr(GError) error = NULL;

	/* get UI */
	retval = gtk_builder_add_from_resource (self->builder,
						"/org/gnome/Software/Editor/gs-editor.ui",
						&error);
	if (retval == 0) {
		g_warning ("failed to load ui: %s", error->message);
		return;
	}

	/* load all system appstream */
	as_store_set_add_flags (self->store_global, AS_STORE_ADD_FLAG_USE_MERGE_HEURISTIC);
	ret = as_store_load (self->store_global,
			     AS_STORE_LOAD_FLAG_IGNORE_INVALID |
			     AS_STORE_LOAD_FLAG_APP_INFO_SYSTEM |
			     AS_STORE_LOAD_FLAG_APPDATA |
			     AS_STORE_LOAD_FLAG_DESKTOP,
			     self->cancellable,
			     &error);
	if (!ret) {
		g_warning ("failed to load global store: %s", error->message);
		return;
	}

	/* load all the IDs into the completion model */
	gs_editor_load_completion_model (self);

	self->featured_tile1 = gs_feature_tile_new (NULL);
	self->upgrade_banner = gs_upgrade_banner_new ();
	widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "box_featured"));
	gtk_container_add (GTK_CONTAINER (widget), self->featured_tile1);
	gtk_container_add (GTK_CONTAINER (widget), self->upgrade_banner);

	widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "textview_css"));
	buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (widget));
	g_signal_connect (buffer, "changed",
			  G_CALLBACK (gs_design_dialog_buffer_changed_cb), self);

	widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "flowbox_main"));
	gtk_flow_box_set_sort_func (GTK_FLOW_BOX (widget),
				    gs_editor_flow_box_sort_cb,
				    self, NULL);

	widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "button_save"));
	g_signal_connect (widget, "clicked",
			  G_CALLBACK (gs_editor_button_save_clicked_cb), self);

	widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "button_new_feature"));
	g_signal_connect (widget, "clicked",
			  G_CALLBACK (gs_editor_button_new_feature_clicked_cb), self);

	widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "button_new_os_upgrade"));
	g_signal_connect (widget, "clicked",
			  G_CALLBACK (gs_editor_button_new_os_upgrade_clicked_cb), self);

	widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "button_new"));
	g_signal_connect (widget, "clicked",
			  G_CALLBACK (gs_editor_button_new_clicked_cb), self);

	widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "button_remove"));
	g_signal_connect (widget, "clicked",
			  G_CALLBACK (gs_editor_button_remove_clicked_cb), self);

	widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "button_import"));
	g_signal_connect (widget, "clicked",
			  G_CALLBACK (gs_editor_button_import_clicked_cb), self);

	widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "button_back"));
	g_signal_connect (widget, "clicked",
			  G_CALLBACK (gs_editor_button_back_clicked_cb), self);

	widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "button_menu"));
	g_signal_connect (widget, "clicked",
			  G_CALLBACK (gs_editor_button_menu_clicked_cb), self);

	widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "button_notification_dismiss"));
	g_signal_connect (widget, "clicked",
			  G_CALLBACK (gs_editor_button_notification_dismiss_clicked_cb), self);

	widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "button_notification_undo_remove"));
	g_signal_connect (widget, "clicked",
			  G_CALLBACK (gs_editor_button_undo_remove_clicked_cb), self);

	widget = GTK_WIDGET (gtk_builder_get_object (self->builder,
						     "checkbutton_editors_pick"));
	g_signal_connect (widget, "toggled",
			  G_CALLBACK (gs_editor_checkbutton_editors_pick_cb), self);
	widget = GTK_WIDGET (gtk_builder_get_object (self->builder,
						     "checkbutton_category_featured"));
	g_signal_connect (widget, "toggled",
			  G_CALLBACK (gs_editor_checkbutton_category_featured_cb), self);

	widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "entry_desktop_id"));
	g_signal_connect (widget, "notify::text",
			  G_CALLBACK (gs_editor_entry_desktop_id_notify_cb), self);

	widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "entry_name"));
	g_signal_connect (widget, "notify::text",
			  G_CALLBACK (gs_editor_entry_name_notify_cb), self);

	widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "entry_summary"));
	g_signal_connect (widget, "notify::text",
			  G_CALLBACK (gs_editor_entry_summary_notify_cb), self);

	widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "window_main"));
	g_signal_connect (widget, "delete_event",
			  G_CALLBACK (gs_editor_delete_event_cb), self);

	/* clear entries */
	gs_editor_refresh_choice (self);
	gs_editor_refresh_details (self);
	gs_editor_refresh_file (self, NULL);

	/* set the appropriate page */
	gs_editor_set_page (self, "none");

	main_window = GTK_WIDGET (gtk_builder_get_object (self->builder, "window_main"));
	gtk_application_add_window (application, GTK_WINDOW (main_window));
	gtk_widget_show (main_window);
}
/* The multi-press gesture used by the flowbox to select a child
 * forbid us to use dnd so we need to catch it here and select yourself
 * the child
 */
static void
gstyle_color_widget_multipress_gesture_pressed (GtkGestureMultiPress *gesture,
                                                guint                 n_press,
                                                gdouble               x,
                                                gdouble               y,
                                                GstyleColorWidget    *self)
{
  GtkWidget *container;
  GtkWidget *child;
  GtkWidget *popover;
  GtkBuilder *builder;
  GtkWidget *button_rename;
  GtkWidget *button_remove;
  GtkWidget *ancestor;
  gint button;

  button = gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture));
  gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);

  child = gtk_widget_get_parent (GTK_WIDGET (self));
  if (child != NULL && button == GDK_BUTTON_PRIMARY)
    {
      if (GTK_IS_LIST_BOX_ROW (child))
        {
          container = gtk_widget_get_parent (GTK_WIDGET (child));
          if (container != NULL && GTK_IS_LIST_BOX (container))
            {
              gtk_list_box_select_row (GTK_LIST_BOX (container), GTK_LIST_BOX_ROW (child));
              gtk_widget_grab_focus (GTK_WIDGET (self));
              if (n_press == 2)
                g_signal_emit_by_name (container, "row-activated", child);
            }
        }
      else if (GTK_IS_FLOW_BOX_CHILD (child))
        {
          container = gtk_widget_get_parent (GTK_WIDGET (child));
          if (container != NULL && GTK_IS_FLOW_BOX (container))
            {
              gtk_flow_box_select_child (GTK_FLOW_BOX (container), GTK_FLOW_BOX_CHILD (child));
              gtk_widget_grab_focus (GTK_WIDGET (self));
              if (n_press == 2)
                g_signal_emit_by_name (container, "child-activated", child);
            }
        }
    }

  if (button == GDK_BUTTON_SECONDARY)
    {
      ancestor = gtk_widget_get_ancestor (GTK_WIDGET (self), GSTYLE_TYPE_PALETTE_WIDGET);
      if (ancestor != NULL)
        {
          builder = gtk_builder_new_from_resource ("/org/gnome/libgstyle/ui/gstyle-color-widget.ui");
          popover = GTK_WIDGET (gtk_builder_get_object (builder, "popover"));
          button_rename = GTK_WIDGET (gtk_builder_get_object (builder, "button_rename"));
          g_signal_connect_object (button_rename, "button-release-event",
                                   G_CALLBACK (popover_button_rename_clicked_cb), self, G_CONNECT_SWAPPED);

          button_remove = GTK_WIDGET (gtk_builder_get_object (builder, "button_remove"));
          g_signal_connect_object (button_remove, "button-release-event",
                                   G_CALLBACK (popover_button_remove_clicked_cb), self, G_CONNECT_SWAPPED);

          gtk_popover_set_relative_to (GTK_POPOVER (popover), GTK_WIDGET (self));
          g_signal_connect_swapped (popover, "closed", G_CALLBACK (contextual_popover_closed_cb), self);
          gtk_widget_show (popover);
          g_object_unref (builder);
        }
    }
}
Example #9
0
GtkFlowBox* cast_GtkFlowBox(GtkWidget* widget) {
    return GTK_FLOW_BOX(widget);
}