static GtkWidget *
cc_sharing_panel_new_media_sharing_row (const char     *uri_or_path,
                                        CcSharingPanel *self)
{
  GtkWidget *row, *box, *w;
  GUserDirectory dir = G_USER_N_DIRECTORIES;
  GIcon *icon;
  guint i;
  char *basename, *path;
  GFile *file;

  file = g_file_new_for_commandline_arg (uri_or_path);
  path = g_file_get_path (file);
  g_object_unref (file);

  row = gtk_list_box_row_new ();
  box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
  gtk_container_set_border_width (GTK_CONTAINER (box), 12);
  gtk_container_add (GTK_CONTAINER (row), box);

  /* Find the icon and create it */
  for (i = 0; i < G_USER_N_DIRECTORIES; i++)
    {
      if (g_strcmp0 (path, g_get_user_special_dir (i)) == 0)
        {
          dir = i;
          break;
        }
    }

  icon = special_directory_get_gicon (dir);
  w = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_MENU);
  gtk_widget_set_margin_end (w, 12);
  gtk_container_add (GTK_CONTAINER (box), w);
  g_object_unref (icon);

  /* Label */
  basename = g_filename_display_basename (path);
  w = gtk_label_new (basename);
  g_free (basename);
  gtk_container_add (GTK_CONTAINER (box), w);

  /* Remove button */
  w = gtk_button_new_from_icon_name ("window-close-symbolic", GTK_ICON_SIZE_SMALL_TOOLBAR);
  gtk_button_set_relief (GTK_BUTTON (w), GTK_RELIEF_NONE);
  gtk_widget_set_margin_top (w, 3);
  gtk_widget_set_margin_bottom (w, 3);
  gtk_widget_set_margin_end (w, 12);
  gtk_widget_set_valign (w, GTK_ALIGN_CENTER);
  gtk_box_pack_end (GTK_BOX (box), w, FALSE, FALSE, 0);
  g_signal_connect (G_OBJECT (w), "clicked",
                    G_CALLBACK (cc_sharing_panel_remove_folder), self);
  g_object_set_data (G_OBJECT (w), "row", row);

  g_object_set_data_full (G_OBJECT (row), "path", g_strdup (path), g_free);

  gtk_widget_show_all (row);

  return row;
}
Exemplo n.º 2
0
int
main (int argc,
      char **argv)
{
  GdkPixbuf *pixbuf, *otherpix;
  GtkWidget *image, *image2, *hbox, *vbox, *label, *toplevel;
  GIcon *emblemed;
  GEmblem *emblem;
  gchar *str;

  gtk_init (&argc, &argv);

  pixbuf = gdk_pixbuf_new_from_file ("apple-red.png", NULL);
  toplevel = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
  gtk_container_add (GTK_CONTAINER (toplevel), hbox);

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
  gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);

  image = gtk_image_new_from_gicon (G_ICON (pixbuf), GTK_ICON_SIZE_DIALOG);
  gtk_box_pack_start (GTK_BOX (vbox), image, FALSE, FALSE, 0);

  label = gtk_label_new (NULL);
  str = g_strdup_printf ("Normal icon, hash %u", g_icon_hash (G_ICON (pixbuf)));
  gtk_label_set_label (GTK_LABEL (label), str);
  gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);

  otherpix = gdk_pixbuf_new_from_file ("gnome-textfile.png", NULL);
  emblem = g_emblem_new (G_ICON (otherpix));
  emblemed = g_emblemed_icon_new (G_ICON (pixbuf), emblem);

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
  gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
  
  image2 = gtk_image_new_from_gicon (emblemed, GTK_ICON_SIZE_DIALOG);
  gtk_box_pack_start (GTK_BOX (vbox), image2, FALSE, FALSE, 0);

  label = gtk_label_new (NULL);
  str = g_strdup_printf ("Emblemed icon, hash %u", g_icon_hash (emblemed));
  gtk_label_set_label (GTK_LABEL (label), str);
  gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);

  gtk_widget_show_all (toplevel);

  g_signal_connect (toplevel, "delete-event",
		    G_CALLBACK (gtk_main_quit), NULL);

  gtk_main ();

  return 0;
}
Exemplo n.º 3
0
/* This function shows a menu for the user to select which item to launch. */
void show_menu(pqi inst)
{
	menu_iter iter; int i = 0,
	orient = mate_panel_applet_get_orient(inst->applet);
	GtkMenu* menu = GTK_MENU(gtk_menu_new());
	gboolean reverse;
	
	if (inst->clicked && inst->items)
	{
		reverse = (orient == MATE_PANEL_APPLET_ORIENT_UP);
		for (reverse? menu_iterate_rbegin(inst,&iter,inst->show_primary):menu_iterate_begin(inst,&iter,inst->show_primary); iter.valid; menu_iter_next(&iter))
		{
			GtkWidget *mi = gtk_image_menu_item_new(),
			          *lbl = gtk_label_new(iter.text),
			          *icon = gtk_image_new_from_gicon(iter.icon, GTK_ICON_SIZE_DND);
			gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(mi), icon);
			gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(mi), TRUE);
			gtk_label_set_justify(GTK_LABEL(lbl),GTK_JUSTIFY_LEFT);
			gtk_misc_set_alignment(GTK_MISC(lbl),0,0.5);
			gtk_container_add(GTK_CONTAINER(mi),lbl);
			gtk_widget_show_all(mi);
			gtk_menu_insert(menu,mi,i++);
			g_signal_connect(G_OBJECT(mi), "activate", G_CALLBACK(menu_launch), iter.si);
		}
		
		gtk_menu_attach_to_widget(menu,inst->box,NULL);
		gtk_menu_popup(menu,NULL,NULL,set_to_corner, inst, 1, 0);
	}
	inst->clicked = FALSE;
}
static void
connect_proxy_cb (GtkActionGroup *action_group,
                  GtkAction *action,
                  GtkWidget *proxy,
                  gpointer dummy)
{
	GtkLabel *label;
	GIcon *icon;

	if (!GTK_IS_MENU_ITEM (proxy))
		return;

	label = GTK_LABEL (gtk_bin_get_child (GTK_BIN (proxy)));

	gtk_label_set_use_underline (label, FALSE);
	gtk_label_set_ellipsize (label, PANGO_ELLIPSIZE_END);
	gtk_label_set_max_width_chars (label, MENU_ITEM_MAX_WIDTH_CHARS);

	icon = g_object_get_data (G_OBJECT (action), "menu-icon");

	if (icon != NULL) {
		gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (proxy),
					       gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_MENU));
	}
}
static GtkWidget *
menu_item_for_filename (UmPhotoDialog *um,
                        const char    *filename)
{
        GtkWidget *image, *menuitem;
        GFile *file;
        GIcon *icon;

        file = g_file_new_for_path (filename);
        icon = g_file_icon_new (file);
        g_object_unref (file);
        image = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_DIALOG);
        g_object_unref (icon);

        menuitem = gtk_menu_item_new ();
        gtk_container_add (GTK_CONTAINER (menuitem), image);
        gtk_widget_show_all (menuitem);

        g_object_set_data_full (G_OBJECT (menuitem), "filename",
                                g_strdup (filename), (GDestroyNotify) g_free);
        g_signal_connect (G_OBJECT (menuitem), "activate",
                          G_CALLBACK (stock_icon_selected), um);

        return menuitem;
}
Exemplo n.º 6
0
static void
add_provider_to_list (GisGoaPage *page, const char *provider_type)
{
  GisGoaPagePrivate *priv = gis_goa_page_get_instance_private (page);
  GtkWidget *row;
  GtkWidget *box;
  GtkWidget *image;
  GtkWidget *label;
  GtkWidget *checkmark;
  GtkWidget *account_label;
  GIcon *icon;
  gchar *markup;
  GoaProvider *provider;
  ProviderWidget *provider_widget;

  provider = goa_provider_get_for_provider_type (provider_type);
  if (provider == NULL)
    return;

  row = gtk_list_box_row_new ();
  box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
  gtk_widget_set_hexpand (box, TRUE);

  icon = goa_provider_get_provider_icon (provider, NULL);
  image = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_DIALOG);

  markup = g_strdup_printf ("<b>%s</b>", goa_provider_get_provider_name (provider, NULL));
  label = gtk_label_new (NULL);
  gtk_label_set_markup (GTK_LABEL (label), markup);
  g_free (markup);

  checkmark = gtk_image_new_from_icon_name ("object-select-symbolic", GTK_ICON_SIZE_MENU);

  account_label = gtk_label_new (NULL);

  gtk_box_pack_start (GTK_BOX (box), image, FALSE, FALSE, 0);
  gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
  gtk_box_pack_end (GTK_BOX (box), checkmark, FALSE, FALSE, 8);
  gtk_box_pack_end (GTK_BOX (box), account_label, FALSE, FALSE, 0);

  gtk_container_add (GTK_CONTAINER (row), box);

  gtk_widget_show (label);
  gtk_widget_show (image);
  gtk_widget_show (box);
  gtk_widget_show (row);

  provider_widget = g_new0 (ProviderWidget, 1);
  provider_widget->page = page;
  provider_widget->provider = provider;
  provider_widget->row = row;
  provider_widget->checkmark = checkmark;
  provider_widget->account_label = account_label;

  g_object_set_data_full (G_OBJECT (row), "widget", provider_widget, g_free);

  g_hash_table_insert (priv->providers, (char *) provider_type, provider_widget);

  gtk_container_add (GTK_CONTAINER (priv->accounts_list), row);
}
Exemplo n.º 7
0
static GtkWidget *
clone_image_menu_size (GtkImage *image)
{
  GtkImageType storage_type = gtk_image_get_storage_type (image);

  if (storage_type == GTK_IMAGE_STOCK)
    {
      gchar *stock_id;
      GtkWidget *widget;
      G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
      gtk_image_get_stock (image, &stock_id, NULL);
      widget = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_MENU);
      G_GNUC_END_IGNORE_DEPRECATIONS;
      return widget;
    }
  else if (storage_type == GTK_IMAGE_ICON_NAME)
    {
      const gchar *icon_name;
      gtk_image_get_icon_name (image, &icon_name, NULL);
      return gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
    }
  else if (storage_type == GTK_IMAGE_ICON_SET)
    {
      GtkWidget *widget;
      GtkIconSet *icon_set;
      G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
      gtk_image_get_icon_set (image, &icon_set, NULL);
      widget = gtk_image_new_from_icon_set (icon_set, GTK_ICON_SIZE_MENU);
      G_GNUC_END_IGNORE_DEPRECATIONS;
      return widget;
    }
  else if (storage_type == GTK_IMAGE_GICON)
    {
      GIcon *icon;
      gtk_image_get_gicon (image, &icon, NULL);
      return gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_MENU);
    }
  else if (storage_type == GTK_IMAGE_PIXBUF)
    {
      gint width, height;
      
      if (gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &width, &height))
	{
	  GdkPixbuf *src_pixbuf, *dest_pixbuf;
	  GtkWidget *cloned_image;

	  src_pixbuf = gtk_image_get_pixbuf (image);
	  dest_pixbuf = gdk_pixbuf_scale_simple (src_pixbuf, width, height,
						 GDK_INTERP_BILINEAR);

	  cloned_image = gtk_image_new_from_pixbuf (dest_pixbuf);
	  g_object_unref (dest_pixbuf);

	  return cloned_image;
	}
    }

  return NULL;
}
static void
place_query_info_ready (GObject *source,
                        GAsyncResult *res,
                        gpointer user_data)
{
  GtkWidget *row, *box, *w;
  Place *place;
  GFileInfo *info;
  const gchar *desktop_path;
  gchar *path;

  info = g_file_query_info_finish (G_FILE (source), res, NULL);
  if (!info)
    return;

  row = user_data;
  place = g_object_get_data (G_OBJECT (row), "place");
  g_clear_object (&place->cancellable);

  box = gtk_bin_get_child (GTK_BIN (row));

  /* FIXME: GLib is currently buggy and returns a non-existent icon name
   * when asked for the desktop symbolic icon.
   */
  desktop_path = g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP);
  path = g_file_get_path (G_FILE (source));

  if (g_strcmp0 (path, desktop_path) == 0)
    place->icon = g_themed_icon_new ("folder-symbolic");
  else
    place->icon = g_object_ref (g_file_info_get_symbolic_icon (info));

  if (g_strcmp0 (path, g_get_home_dir ()) == 0)
    place->settings_key = TRACKER_KEY_SINGLE_DIRECTORIES;
  else
    place->settings_key = TRACKER_KEY_RECURSIVE_DIRECTORIES;

  g_free (path);

  w = gtk_image_new_from_gicon (place->icon, GTK_ICON_SIZE_MENU);
  gtk_container_add (GTK_CONTAINER (box), w);

  w = gtk_label_new (place->display_name);
  gtk_container_add (GTK_CONTAINER (box), w);

  w = gtk_switch_new ();
  gtk_box_pack_end (GTK_BOX (box), w, FALSE, FALSE, 0);
  g_settings_bind_with_mapping (tracker_preferences, place->settings_key,
                                w, "active",
                                G_SETTINGS_BIND_DEFAULT,
                                switch_tracker_get_mapping,
                                switch_tracker_set_mapping,
                                place, NULL);

  gtk_widget_show_all (row);
  g_object_unref (info);
}
Exemplo n.º 9
0
void
gdm_extension_list_add_extension (GdmExtensionList  *extension_list,
                                  GdmLoginExtension *extension)
{
        GtkWidget *image;
        GtkWidget *button;
        GIcon     *icon;
        char      *description;

        if (extension_list->priv->extensions == NULL) {
                button = gtk_radio_button_new (NULL);
        } else {
                GdmLoginExtension *previous_extension;
                GtkRadioButton *previous_button;

                previous_extension = GDM_LOGIN_EXTENSION (extension_list->priv->extensions->data);
                previous_button = GTK_RADIO_BUTTON (g_object_get_data (G_OBJECT (previous_extension), "gdm-extension-list-button"));
                button = gtk_radio_button_new_from_widget (previous_button);
        }
        g_object_set_data (G_OBJECT (extension), "gdm-extension-list-button", button);

        g_object_set (G_OBJECT (button), "draw-indicator", FALSE, NULL);
        g_object_set_data (G_OBJECT (button), "gdm-extension", extension);
        g_signal_connect_swapped (button, "toggled",
                                  G_CALLBACK (on_extension_toggled),
                                  extension_list);

        gtk_button_set_focus_on_click (GTK_BUTTON (button), FALSE);
        gtk_widget_set_sensitive (button, gdm_login_extension_is_enabled (extension));

        g_signal_connect_swapped (G_OBJECT (extension), "enabled",
                                  G_CALLBACK (on_extension_enabled),
                                  extension_list);

        g_signal_connect_swapped (G_OBJECT (extension), "disabled",
                                  G_CALLBACK (on_extension_disabled),
                                  extension_list);

        icon = gdm_login_extension_get_icon (extension);
        image = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_SMALL_TOOLBAR);
        g_object_unref (icon);

        gtk_widget_show (image);
        gtk_container_add (GTK_CONTAINER (button), image);
        description = gdm_login_extension_get_description (extension);
        gtk_widget_set_tooltip_text (button, description);
        g_free (description);
        gtk_widget_show (button);

        gtk_container_add (GTK_CONTAINER (extension_list->priv->box), button);
        extension_list->priv->extensions = g_list_append (extension_list->priv->extensions,
                                                g_object_ref (extension));

        if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button))) {
                g_signal_emit (extension_list, signals[ACTIVATED], 0, extension);
        }
}
Exemplo n.º 10
0
GtkWidget *
get_icon (gchar *icon)
{
  GIcon *gi;
  GtkWidget *retval;

  gi = g_themed_icon_new_with_default_fallbacks (icon);
  retval = gtk_image_new_from_gicon (gi, GTK_ICON_SIZE_BUTTON);
  g_object_unref (gi);

  return retval;
}
Exemplo n.º 11
0
static VALUE
rg_initialize(int argc, VALUE *argv, VALUE self)
{
    VALUE image;
    GtkWidget *widget = NULL;

    rb_scan_args(argc, argv, "01", &image);
    if (NIL_P(image)) {
        widget = gtk_image_new();
    } else if (TYPE(image) == T_HASH) {
        VALUE stock, icon_name, icon_set, gicon, file, pixbuf, animation, size, buffer;
        rbg_scan_options(image,
                         "stock", &stock,
                         "icon_name", &icon_name,
                         "icon_set", &icon_set,
                         "gicon", &gicon,
                         "file", &file,
                         "pixbuf", &pixbuf,
                         "animation", &animation,
                         "size", &size,
                         NULL);

        if (!NIL_P(stock))
            widget = gtk_image_new_from_stock(RVAL2GLIBID(stock, buffer), RVAL2GTKICONSIZE(size));
        else if (!NIL_P(icon_name))
            widget = gtk_image_new_from_icon_name(RVAL2CSTR(icon_name), RVAL2GTKICONSIZE(size));
        else if (!NIL_P(icon_set))
            widget = gtk_image_new_from_icon_set(RVAL2GTKICONSET(icon_set), RVAL2GTKICONSIZE(size));
        else if (!NIL_P(gicon))
            widget = gtk_image_new_from_gicon(RVAL2GICON(gicon), RVAL2GTKICONSIZE(size));
        else if (!NIL_P(file))
            widget = gtk_image_new_from_file(RVAL2CSTR(file));
        else if (!NIL_P(pixbuf))
            widget = gtk_image_new_from_pixbuf(RVAL2GDKPIXBUF(pixbuf));
        else if (!NIL_P(animation))
            widget = gtk_image_new_from_animation(RVAL2GDKPIXBUFANIMATION(animation));
    } else {
        GType gtype = RVAL2GTYPE(image);

        if (gtype == GDK_TYPE_PIXBUF)
            widget = gtk_image_new_from_pixbuf(RVAL2GDKPIXBUF(image));
        else if (g_type_is_a(gtype, GDK_TYPE_PIXBUF_ANIMATION))
            widget = gtk_image_new_from_animation(RVAL2GDKPIXBUFANIMATION(image));
    }
    if (!widget)
        rb_raise(rb_eArgError, "Invalid arguments.");

    RBGTK_INITIALIZE(self, widget);

    return Qnil;
}
Exemplo n.º 12
0
static GtkWidget *menu_item_new_with_icon_text(GIcon *icon, const char *text) 
{
    GtkWidget *menuitem = gtk_menu_item_new();
    GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6);
    GtkWidget *image = gtk_image_new_from_gicon(icon, GTK_ICON_SIZE_LARGE_TOOLBAR);
    GtkWidget *label = gtk_label_new(text);

    gtk_image_set_pixel_size(GTK_IMAGE(image), 24);
    gtk_box_pack_start(GTK_BOX(box), image, FALSE, FALSE, 0);
    gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0);

    gtk_container_add(GTK_CONTAINER(menuitem), box);

    return menuitem;
}
Exemplo n.º 13
0
/**
 * gtk_action_create_icon:
 * @action: the action object
 * @icon_size: (type int): the size of the icon that should be created.
 *
 * This function is intended for use by action implementations to
 * create icons displayed in the proxy widgets.
 *
 * Returns: (transfer none): a widget that displays the icon for this action.
 *
 * Since: 2.4
 */
GtkWidget *
gtk_action_create_icon (GtkAction *action, GtkIconSize icon_size)
{
  g_return_val_if_fail (GTK_IS_ACTION (action), NULL);

  if (action->private_data->stock_id &&
      gtk_icon_factory_lookup_default (action->private_data->stock_id))
    return gtk_image_new_from_stock (action->private_data->stock_id, icon_size);
  else if (action->private_data->gicon)
    return gtk_image_new_from_gicon (action->private_data->gicon, icon_size);
  else if (action->private_data->icon_name)
    return gtk_image_new_from_icon_name (action->private_data->icon_name, icon_size);
  else
    return NULL;
}
Exemplo n.º 14
0
static void
setup_an_item (AppletUserMenu *menu,
	       GtkWidget      *submenu,
	       int             is_submenu)
{
	GtkWidget *image = NULL;

	menu->menuitem = gtk_image_menu_item_new_with_mnemonic (menu->text);
	if (menu->gicon) {
		image = gtk_image_new_from_gicon (menu->gicon,
						  GTK_ICON_SIZE_MENU);
		gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu->menuitem),
					       image);
	}
	gtk_widget_show (menu->menuitem);

	g_signal_connect (G_OBJECT (menu->menuitem), "destroy",
			  G_CALLBACK (gtk_widget_destroyed),
			  &menu->menuitem);

	if(submenu)
		gtk_menu_shell_append (GTK_MENU_SHELL (submenu), menu->menuitem);

	/*if an item not a submenu*/
	if (!is_submenu) {
		g_signal_connect (menu->menuitem, "activate",
				  G_CALLBACK (applet_callback_callback),
				  menu);
		g_signal_connect (submenu, "destroy",
				  G_CALLBACK (gtk_widget_destroyed),
				  &menu->submenu);
	/* if the item is a submenu and doesn't have it's menu
	   created yet*/
	} else if (!menu->submenu) {
		menu->submenu = gtk_menu_new ();
	}

	if(menu->submenu) {
		gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu->menuitem),
					  menu->submenu);
		g_signal_connect (G_OBJECT (menu->submenu), "destroy",
				    G_CALLBACK (gtk_widget_destroyed),
				    &menu->submenu);
	}

	gtk_widget_set_sensitive(menu->menuitem,menu->sensitive);
}
Exemplo n.º 15
0
static void set_icon(AnacondaDiskOverview *widget, const char *icon_name) {
    GError *err = NULL;
    GIcon *base_icon, *emblem_icon, *icon;
    GEmblem *emblem = NULL;
    gchar *file;

    if (!icon_name)
        return;

    if (widget->priv->kind_icon)
        gtk_widget_destroy(widget->priv->kind_icon);

    if (widget->priv->chosen) {
        base_icon = g_icon_new_for_string(icon_name, &err);
        if (!base_icon) {
            fprintf(stderr, "could not create icon: %s\n", err->message);
            g_error_free(err);
            return;
        }

        file = g_strdup_printf("%s/pixmaps/anaconda-selected-icon.svg", get_widgets_datadir());
        emblem_icon = g_icon_new_for_string(file, &err);
        g_free(file);
        if (!emblem_icon) {
            fprintf(stderr, "could not create emblem: %s\n", err->message);
            g_error_free(err);
        }
        else {
            emblem = g_emblem_new(emblem_icon);
        }

        icon = g_emblemed_icon_new(base_icon, emblem);
        g_object_unref(base_icon);
    }
    else {
        icon = g_icon_new_for_string(icon_name, &err);
        if (!icon) {
            fprintf(stderr, "could not create icon: %s\n", err->message);
            g_error_free(err);
            return;
        }
    }

    widget->priv->kind_icon = gtk_image_new_from_gicon(icon, GTK_ICON_SIZE_DIALOG);
    gtk_image_set_pixel_size(GTK_IMAGE(widget->priv->kind_icon), ICON_SIZE);
}
static void
add_application (CcNotificationsPanel *panel,
                 Application          *app)
{
  GtkWidget *box, *w;
  GIcon *icon;

  icon = g_app_info_get_icon (app->app_info);
  if (icon == NULL)
    icon = g_themed_icon_new ("application-x-executable");
  else
    g_object_ref (icon);

  box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
  g_object_set_qdata_full (G_OBJECT (box), application_quark (),
                           app, (GDestroyNotify) application_free);

  gtk_container_add (GTK_CONTAINER (panel->list_box), box);

  w = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_DIALOG);
  gtk_widget_set_margin_left (w, 12);
  gtk_container_add (GTK_CONTAINER (box), w);
  g_object_unref (icon);

  w = gtk_label_new (g_app_info_get_name (app->app_info));
  gtk_container_add (GTK_CONTAINER (box), w);

  w = gtk_label_new ("");
  g_settings_bind_with_mapping (app->settings, "enable",
                                w, "label",
                                G_SETTINGS_BIND_GET |
                                G_SETTINGS_BIND_NO_SENSITIVITY,
                                on_off_label_mapping_get,
                                NULL,
                                NULL,
                                NULL);
  gtk_widget_set_margin_right (w, 12);
  gtk_widget_set_valign (w, GTK_ALIGN_CENTER);
  gtk_box_pack_end (GTK_BOX (box), w, FALSE, FALSE, 0);

  gtk_widget_show_all (box);

  g_hash_table_add (panel->known_applications, g_strdup (app->canonical_app_id));
}
Exemplo n.º 17
0
static void
thunar_uca_editor_set_icon_name (ThunarUcaEditor *uca_editor,
                                 const gchar     *icon_name)
{
    GIcon     *icon = NULL;
    GtkWidget *image;
    GtkWidget *label;

    g_return_if_fail (THUNAR_UCA_IS_EDITOR (uca_editor));

    /* drop the previous button child */
    if (gtk_bin_get_child (GTK_BIN (uca_editor->icon_button)) != NULL)
        gtk_widget_destroy (gtk_bin_get_child (GTK_BIN (uca_editor->icon_button)));

    /* setup the icon button */
    if (icon_name != NULL)
        icon = g_icon_new_for_string (icon_name, NULL);

    if (G_LIKELY (icon != NULL))
    {
        /* setup an image for the icon */
        image = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_DIALOG);
        g_object_set (image, "icon-size", GTK_ICON_SIZE_DND, NULL);
        gtk_container_add (GTK_CONTAINER (uca_editor->icon_button), image);
        gtk_widget_show (image);

        /* remember the name for the icon */
        g_object_set_data_full (G_OBJECT (uca_editor->icon_button), "thunar-uca-icon-name", g_strdup (icon_name), g_free);

        /* release the icon */
        g_object_unref (G_OBJECT (icon));
    }
    else
    {
        /* reset the remembered icon name */
        g_object_set_data (G_OBJECT (uca_editor->icon_button), "thunar-uca-icon-name", NULL);

        /* setup a label to tell that no icon was selected */
        label = gtk_label_new (_("No icon"));
        gtk_container_add (GTK_CONTAINER (uca_editor->icon_button), label);
        gtk_widget_show (label);
    }
}
static void
photos_dlna_renderers_dialog_add_renderer (PhotosDlnaRenderersDialog *self, PhotosDlnaRenderer *renderer)
{
  PhotosDlnaRenderersDialogPrivate *priv = self->priv;
  GIcon *icon;
  GtkWidget *row;
  GtkWidget *row_grid;
  GtkWidget *image;
  GtkWidget *label;
  const gchar *name;

  row = gtk_list_box_row_new ();
  gtk_container_add (GTK_CONTAINER (priv->listbox), row);

  row_grid = gtk_grid_new ();
  gtk_container_set_border_width (GTK_CONTAINER (row_grid), 12);
  gtk_orientable_set_orientation (GTK_ORIENTABLE (row_grid), GTK_ORIENTATION_HORIZONTAL);
  gtk_grid_set_column_spacing (GTK_GRID (row_grid), 12);
  gtk_container_add (GTK_CONTAINER (row), row_grid);

  g_object_set_data_full (G_OBJECT (row), "renderer", renderer, g_object_unref);

  name = photos_dlna_renderer_get_friendly_name (renderer);

  icon = g_themed_icon_new_with_default_fallbacks (PHOTOS_ICON_VIDEO_DISPLAY_SYMBOLIC);
  image = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_DIALOG);

  g_object_ref (image); /* keep a ref for the following async call and release it in the callback */
  photos_dlna_renderer_get_icon (renderer,
                                 "",
                                 "",
                                 GTK_ICON_SIZE_DIALOG,
                                 NULL,
                                 photos_dlna_renderers_dialog_set_icon_cb,
                                 image);

  gtk_container_add (GTK_CONTAINER (row_grid), image);

  label = gtk_label_new (NULL);
  gtk_label_set_text (GTK_LABEL (label), name);
  gtk_container_add (GTK_CONTAINER (row_grid), label);
}
Exemplo n.º 19
0
//gqk
static void
fcitx_im_widget_init(FcitxImWidget* self)
{
    self->builder = gtk_builder_new();
    gtk_builder_add_from_resource(self->builder, "/org/fcitx/fcitx-config-gtk3/im_widget.ui", NULL);

#define _GET_OBJECT(NAME) \
    self->NAME = (typeof(self->NAME)) gtk_builder_get_object(self->builder, #NAME);

    _GET_OBJECT(imstore)
    _GET_OBJECT(imview)
    _GET_OBJECT(addimbutton)
    _GET_OBJECT(delimbutton)
    _GET_OBJECT(moveupbutton)
    _GET_OBJECT(movedownbutton)
    _GET_OBJECT(configurebutton)
    _GET_OBJECT(default_layout_button)
    _GET_OBJECT(scrolledwindow)
    _GET_OBJECT(toolbar)

    GtkTreeSelection* selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(self->imview));
    g_signal_connect(G_OBJECT(selection), "changed",
                     G_CALLBACK(_fcitx_im_widget_im_selection_changed), self);


    GtkStyleContext* context;
    context = gtk_widget_get_style_context (self->scrolledwindow);
    gtk_style_context_set_junction_sides (context, GTK_JUNCTION_BOTTOM);
    context = gtk_widget_get_style_context (self->toolbar);
    gtk_style_context_set_junction_sides (context, GTK_JUNCTION_TOP);
    gtk_style_context_add_class (context, "inline-toolbar");

    gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(self->addimbutton), gtk_image_new_from_gicon(g_themed_icon_new_with_default_fallbacks("list-add-symbolic"), GTK_ICON_SIZE_BUTTON));
    gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(self->delimbutton), gtk_image_new_from_gicon(g_themed_icon_new_with_default_fallbacks("list-remove-symbolic"), GTK_ICON_SIZE_BUTTON));
    gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(self->moveupbutton), gtk_image_new_from_gicon(g_themed_icon_new_with_default_fallbacks("go-up-symbolic"), GTK_ICON_SIZE_BUTTON));
    gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(self->movedownbutton), gtk_image_new_from_gicon(g_themed_icon_new_with_default_fallbacks("go-down-symbolic"), GTK_ICON_SIZE_BUTTON));
    gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(self->configurebutton), gtk_image_new_from_gicon(g_themed_icon_new_with_default_fallbacks("preferences-system-symbolic"), GTK_ICON_SIZE_BUTTON));
    gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(self->default_layout_button), gtk_image_new_from_gicon(g_themed_icon_new_with_default_fallbacks("input-keyboard-symbolic"), GTK_ICON_SIZE_BUTTON));

    g_signal_connect(G_OBJECT(self->addimbutton), "clicked", G_CALLBACK(_fcitx_im_widget_addim_button_clicked), self);
    g_signal_connect(G_OBJECT(self->delimbutton), "clicked", G_CALLBACK(_fcitx_im_widget_delim_button_clicked), self);
    g_signal_connect(G_OBJECT(self->moveupbutton), "clicked", G_CALLBACK(_fcitx_im_widget_moveup_button_clicked), self);
    g_signal_connect(G_OBJECT(self->movedownbutton), "clicked", G_CALLBACK(_fcitx_im_widget_movedown_button_clicked), self);
    g_signal_connect(G_OBJECT(self->configurebutton), "clicked", G_CALLBACK(_fcitx_im_widget_configure_button_clicked), self);
    g_signal_connect(G_OBJECT(self->default_layout_button), "clicked", G_CALLBACK(_fcitx_im_widget_default_layout_button_clicked), self);
    g_signal_connect(G_OBJECT(self->imview), "row-activated", G_CALLBACK(_fcitx_im_widget_row_activated), self);
}
Exemplo n.º 20
0
/* internal */
GtkWidget *get_close_tab_widget(Document *document)
{
  GtkWidget *hbox;
  GtkWidget *close_button;
  hbox = gtk_hbox_new(FALSE, 0);
  close_button = gedit_close_button_new ();
  gtk_widget_set_tooltip_text(close_button, _("Close Tab"));

  g_signal_connect(G_OBJECT(close_button), "clicked", G_CALLBACK(on_tab_close_activate), document);
  /* load file icon */
  GtkWidget *label;
  GIcon *doc_icon;
  g_object_get(document, "editor_label", &label, "icon", &doc_icon, NULL);
  GtkWidget *icon= gtk_image_new_from_gicon (doc_icon, GTK_ICON_SIZE_SMALL_TOOLBAR);
  gtk_widget_show (icon);
  gtk_box_pack_start(GTK_BOX(hbox), icon, FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
  gtk_box_pack_end(GTK_BOX(hbox), close_button, FALSE, FALSE, 0);
  gtk_widget_show(close_button);
  gtk_widget_show(hbox);
  return hbox;
}
Exemplo n.º 21
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.º 22
0
static void
bjb_empty_results_box_constructed (GObject *object)
{
  BjbEmptyResultsBox *self;
  BjbEmptyResultsBoxPrivate *priv;
  GtkStyleContext *context;
  GtkWidget *labels_grid;
  gchar *label, *markup;
  GFile *note_icon_file;
  GIcon *icon;

  G_OBJECT_CLASS (bjb_empty_results_box_parent_class)->constructed (object);
  self = BJB_EMPTY_RESULTS_BOX (object);
  priv = self->priv;

  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_HORIZONTAL);
  gtk_grid_set_column_spacing (GTK_GRID (self), 12);

  context = gtk_widget_get_style_context (GTK_WIDGET (self));
  gtk_style_context_add_class (context, "dim-label");

  note_icon_file = g_file_new_for_uri ("resource://org/gnome/bijiben/note-symbolic.svg");
  icon = g_file_icon_new (note_icon_file);
  g_object_unref (note_icon_file);

  priv->image  = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_DIALOG);
  g_object_unref (icon);

  gtk_container_add (GTK_CONTAINER (self), priv->image);

  labels_grid = gtk_grid_new ();
  gtk_orientable_set_orientation (GTK_ORIENTABLE (labels_grid), GTK_ORIENTATION_VERTICAL);
  gtk_grid_set_row_spacing (GTK_GRID (labels_grid), 0);
  gtk_widget_set_valign (labels_grid, GTK_ALIGN_START);
  gtk_container_add (GTK_CONTAINER (self), labels_grid);

  label = _("No notes");
  markup = g_markup_printf_escaped ("<big><b>%s</b></big>", label);

  priv->primary_label = gtk_label_new (NULL);
  gtk_label_set_markup (GTK_LABEL (priv->primary_label), markup);
  g_free (markup);

  gtk_widget_set_halign (priv->primary_label, GTK_ALIGN_START);
  gtk_widget_set_vexpand (priv->primary_label, TRUE);
  gtk_label_set_use_markup (GTK_LABEL (priv->primary_label), TRUE);
  gtk_container_add (GTK_CONTAINER (labels_grid), priv->primary_label);


  self->priv->type = BJB_EMPTY_RESULTS_TYPE;
  label = "";
  self->priv->details_label = GTK_LABEL (gtk_label_new (label));
  gtk_label_set_use_markup (GTK_LABEL (self->priv->details_label), TRUE);
  gtk_widget_set_halign (priv->primary_label, GTK_ALIGN_START);
  // xalign: 0,
  // max_width_chars: 24,
  // wrap: true

  gtk_container_add (GTK_CONTAINER (labels_grid), GTK_WIDGET (self->priv->details_label));

  gtk_widget_set_valign (priv->primary_label, GTK_ALIGN_CENTER);
  gtk_widget_show_all (GTK_WIDGET (self));
}
static void
search_panel_add_one_app_info (CcSearchPanel *self,
                               GAppInfo *app_info,
                               gboolean default_enabled)
{
  GtkWidget *row, *box, *w;
  GIcon *icon;

  /* gnome-control-center is special cased in the shell,
     and is not configurable */
  if (g_strcmp0 (g_app_info_get_id (app_info),
                 "gnome-control-center.desktop") == 0)
    return;

  /* reset valignment of the list box */
  gtk_widget_set_valign (self->priv->list_box, GTK_ALIGN_FILL);

  row = gtk_list_box_row_new ();
  box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
  gtk_container_add (GTK_CONTAINER (row), box);
  gtk_widget_set_hexpand (box, TRUE);
  gtk_container_set_border_width (GTK_CONTAINER (box), 6);
  g_object_set_data_full (G_OBJECT (row), "app-info",
                          g_object_ref (app_info), g_object_unref);
  g_object_set_data (G_OBJECT (row), "self", self);
  gtk_container_add (GTK_CONTAINER (self->priv->list_box), row);

  icon = g_app_info_get_icon (app_info);
  if (icon == NULL)
    icon = g_themed_icon_new ("application-x-executable");
  else
    g_object_ref (icon);

  w = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_DIALOG);
  gtk_container_add (GTK_CONTAINER (box), w);
  g_object_unref (icon);

  w = gtk_label_new (g_app_info_get_name (app_info));
  gtk_container_add (GTK_CONTAINER (box), w);

  w = gtk_switch_new ();
  gtk_widget_set_valign (w, GTK_ALIGN_CENTER);
  gtk_box_pack_end (GTK_BOX (box), w, FALSE, FALSE, 0);

  if (default_enabled)
    {
      g_settings_bind_with_mapping (self->priv->search_settings, "disabled",
                                    w, "active",
                                    G_SETTINGS_BIND_DEFAULT,
                                    switch_settings_mapping_get_default_enabled,
                                    switch_settings_mapping_set_default_enabled,
                                    row, NULL);
    }
  else
    {
      g_settings_bind_with_mapping (self->priv->search_settings, "enabled",
                                    w, "active",
                                    G_SETTINGS_BIND_DEFAULT,
                                    switch_settings_mapping_get_default_disabled,
                                    switch_settings_mapping_set_default_disabled,
                                    row, NULL);
    }

  gtk_widget_show_all (row);
}
/* returns TRUE if a folder window should be opened */
static gboolean
do_autorun_for_content_type (GMount *mount,
                             const char *x_content_type,
                             CsdAutorunOpenWindow open_window_func,
                             gpointer user_data)
{
	AutorunDialogData *data;
	GtkWidget *dialog;
	GtkWidget *hbox;
	GtkWidget *vbox;
	GtkWidget *label;
	GtkWidget *combo_box;
	GtkWidget *always_check_button;
	GtkWidget *eject_button;
	GtkWidget *image;
	char *markup;
	char *content_description;
	char *mount_name;
	GIcon *icon;
	GdkPixbuf *pixbuf;
	int icon_size;
	gboolean user_forced_dialog;
	gboolean pref_ask;
	gboolean pref_start_app;
	gboolean pref_ignore;
	gboolean pref_open_folder;
	char *media_greeting;
	gboolean ret;

	ret = FALSE;
	mount_name = NULL;

	if (g_content_type_is_a (x_content_type, "x-content/win32-software")) {
		/* don't pop up the dialog anyway if the content type says
 		 * windows software.
 		 */
		goto out;
	}

	user_forced_dialog = is_shift_pressed ();

	csd_autorun_get_preferences (x_content_type, &pref_start_app, &pref_ignore, &pref_open_folder);
	pref_ask = !pref_start_app && !pref_ignore && !pref_open_folder;

	if (user_forced_dialog) {
		goto show_dialog;
	}

	if (!pref_ask && !pref_ignore && !pref_open_folder) {
		GAppInfo *app_info;
		app_info = g_app_info_get_default_for_type (x_content_type, FALSE);
		if (app_info != NULL) {
			csd_autorun_launch_for_mount (mount, app_info);
		}
		goto out;
	}

	if (pref_open_folder) {
		ret = TRUE;
		goto out;
	}

	if (pref_ignore) {
		goto out;
	}

show_dialog:

	mount_name = g_mount_get_name (mount);

	dialog = gtk_dialog_new ();

	hbox = gtk_hbox_new (FALSE, 12);
	gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), hbox, TRUE, TRUE, 0);
	gtk_container_set_border_width (GTK_CONTAINER (hbox), 12);

	icon = g_mount_get_icon (mount);
	icon_size = get_icon_size_for_stock_size (GTK_ICON_SIZE_DIALOG);
	image = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_DIALOG);
	pixbuf = render_icon (icon, icon_size);
	gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.0);
	gtk_box_pack_start (GTK_BOX (hbox), image, TRUE, TRUE, 0);
	/* also use the icon on the dialog */
	gtk_window_set_title (GTK_WINDOW (dialog), mount_name);
	gtk_window_set_icon (GTK_WINDOW (dialog), pixbuf);
	gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
	g_object_unref (icon);
	if (pixbuf) {
		g_object_unref (pixbuf);
	}
	vbox = gtk_vbox_new (FALSE, 12);
	gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);

	label = gtk_label_new (NULL);


	/* Customize greeting for well-known x-content types */
	if (strcmp (x_content_type, "x-content/audio-cdda") == 0) {
		media_greeting = _("You have just inserted an Audio CD.");
	} else if (strcmp (x_content_type, "x-content/audio-dvd") == 0) {
		media_greeting = _("You have just inserted an Audio DVD.");
	} else if (strcmp (x_content_type, "x-content/video-dvd") == 0) {
		media_greeting = _("You have just inserted a Video DVD.");
	} else if (strcmp (x_content_type, "x-content/video-vcd") == 0) {
		media_greeting = _("You have just inserted a Video CD.");
	} else if (strcmp (x_content_type, "x-content/video-svcd") == 0) {
		media_greeting = _("You have just inserted a Super Video CD.");
	} else if (strcmp (x_content_type, "x-content/blank-cd") == 0) {
		media_greeting = _("You have just inserted a blank CD.");
	} else if (strcmp (x_content_type, "x-content/blank-dvd") == 0) {
		media_greeting = _("You have just inserted a blank DVD.");
	} else if (strcmp (x_content_type, "x-content/blank-cd") == 0) {
		media_greeting = _("You have just inserted a blank Blu-Ray disc.");
	} else if (strcmp (x_content_type, "x-content/blank-cd") == 0) {
		media_greeting = _("You have just inserted a blank HD DVD.");
	} else if (strcmp (x_content_type, "x-content/image-photocd") == 0) {
		media_greeting = _("You have just inserted a Photo CD.");
	} else if (strcmp (x_content_type, "x-content/image-picturecd") == 0) {
		media_greeting = _("You have just inserted a Picture CD.");
	} else if (strcmp (x_content_type, "x-content/image-dcf") == 0) {
		media_greeting = _("You have just inserted a medium with digital photos.");
	} else if (strcmp (x_content_type, "x-content/audio-player") == 0) {
		media_greeting = _("You have just inserted a digital audio player.");
	} else if (g_content_type_is_a (x_content_type, "x-content/software")) {
		media_greeting = _("You have just inserted a medium with software intended to be automatically started.");
	} else {
		/* fallback to generic greeting */
		media_greeting = _("You have just inserted a medium.");
	}
	markup = g_strdup_printf ("<big><b>%s %s</b></big>", media_greeting, _("Choose what application to launch."));
	gtk_label_set_markup (GTK_LABEL (label), markup);
	g_free (markup);
	gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
	gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
	gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0);

	label = gtk_label_new (NULL);
	content_description = g_content_type_get_description (x_content_type);
	markup = g_strdup_printf (_("Select how to open \"%s\" and whether to perform this action in the future for other media of type \"%s\"."), mount_name, content_description);
	g_free (content_description);
	gtk_label_set_markup (GTK_LABEL (label), markup);
	g_free (markup);
	gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
	gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
	gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 0);
	
	data = g_new0 (AutorunDialogData, 1);
	data->dialog = dialog;
	data->mount = g_object_ref (mount);
	data->remember = !pref_ask;
	data->selected_ignore = pref_ignore;
	data->x_content_type = g_strdup (x_content_type);
	data->selected_app = g_app_info_get_default_for_type (x_content_type, FALSE);
	data->open_window_func = open_window_func;
	data->user_data = user_data;

	combo_box = gtk_app_chooser_button_new (x_content_type);
	prepare_combo_box (combo_box, data);
	g_signal_connect (G_OBJECT (combo_box),
			  "key-press-event",
			  G_CALLBACK (combo_box_enter_ok),
			  dialog);

	gtk_box_pack_start (GTK_BOX (vbox), combo_box, TRUE, TRUE, 0);

	always_check_button = gtk_check_button_new_with_mnemonic (_("_Always perform this action"));
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (always_check_button), data->remember);
	g_signal_connect (G_OBJECT (always_check_button),
			  "toggled",
			  G_CALLBACK (autorun_always_toggled),
			  data);
	gtk_box_pack_start (GTK_BOX (vbox), always_check_button, TRUE, TRUE, 0);

	gtk_dialog_add_buttons (GTK_DIALOG (dialog), 
				GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
				GTK_STOCK_OK, GTK_RESPONSE_OK,
				NULL);
	gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
	
	if (g_mount_can_eject (mount)) {
		GtkWidget *eject_image;
		eject_button = gtk_button_new_with_mnemonic (_("_Eject"));
		eject_image = gtk_image_new_from_icon_name ("media-eject", GTK_ICON_SIZE_BUTTON);
		gtk_button_set_image (GTK_BUTTON (eject_button), eject_image);
		data->should_eject = TRUE;
	} else {
		eject_button = gtk_button_new_with_mnemonic (_("_Unmount"));
		data->should_eject = FALSE;
	}
	gtk_dialog_add_action_widget (GTK_DIALOG (dialog), eject_button, AUTORUN_DIALOG_RESPONSE_EJECT);
	gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (gtk_dialog_get_action_area (GTK_DIALOG (dialog))), eject_button, TRUE);

	/* show the dialog */
	gtk_widget_show_all (dialog);

	g_signal_connect (G_OBJECT (dialog),
			  "response",
			  G_CALLBACK (autorun_dialog_response),
			  data);

	g_signal_connect (G_OBJECT (data->mount),
			  "unmounted",
			  G_CALLBACK (autorun_dialog_mount_unmounted),
			  data);

out:
	g_free (mount_name);
	return ret;
}
Exemplo n.º 25
0
void main_window_enable_csd(MainWindow *wnd)
{
	GIcon *open_icon;
	GIcon *fullscreen_icon;
	GIcon *menu_icon;

	open_icon = g_themed_icon_new_with_default_fallbacks
				("list-add-symbolic");

	fullscreen_icon = g_themed_icon_new_with_default_fallbacks
				("view-fullscreen-symbolic");

	menu_icon = g_themed_icon_new_with_default_fallbacks
				("view-list-symbolic");

	wnd->playlist_width = PLAYLIST_DEFAULT_WIDTH+PLAYLIST_CSD_OFFSET;
	wnd->open_hdr_btn = gtk_menu_button_new();
	wnd->fullscreen_hdr_btn = gtk_button_new();
	wnd->menu_hdr_btn = gtk_menu_button_new();

	gtk_widget_set_can_focus(wnd->open_hdr_btn, FALSE);
	gtk_widget_set_can_focus(wnd->fullscreen_hdr_btn, FALSE);
	gtk_widget_set_can_focus(wnd->menu_hdr_btn, FALSE);

	gtk_button_set_image
		(	GTK_BUTTON(wnd->fullscreen_hdr_btn),
			gtk_image_new_from_gicon
				(fullscreen_icon, GTK_ICON_SIZE_MENU ));

	gtk_button_set_image
		(	GTK_BUTTON(wnd->open_hdr_btn),
			gtk_image_new_from_gicon
				(open_icon, GTK_ICON_SIZE_MENU ));

	gtk_button_set_image
		(	GTK_BUTTON(wnd->menu_hdr_btn),
			gtk_image_new_from_gicon
				(menu_icon, GTK_ICON_SIZE_MENU ));

	gtk_menu_button_set_menu_model
		(	GTK_MENU_BUTTON(wnd->open_hdr_btn),
			G_MENU_MODEL(open_btn_build_menu()) );

	gtk_menu_button_set_menu_model
		(	GTK_MENU_BUTTON(wnd->menu_hdr_btn),
			G_MENU_MODEL(menu_btn_build_menu()) );

	gtk_header_bar_pack_start
		(GTK_HEADER_BAR(wnd->header_bar), wnd->open_hdr_btn);

	gtk_header_bar_pack_end
		(GTK_HEADER_BAR(wnd->header_bar), wnd->menu_hdr_btn);

	gtk_header_bar_pack_end
		(GTK_HEADER_BAR(wnd->header_bar), wnd->fullscreen_hdr_btn);

	gtk_actionable_set_action_name
		(GTK_ACTIONABLE(wnd->fullscreen_hdr_btn), "app.fullscreen");

	gtk_paned_set_position(	GTK_PANED(wnd->vid_area_paned),
				MAIN_WINDOW_DEFAULT_WIDTH
				-PLAYLIST_DEFAULT_WIDTH
				-PLAYLIST_CSD_OFFSET );

	gtk_window_set_titlebar(GTK_WINDOW(wnd), wnd->header_bar);
	gtk_window_set_title(GTK_WINDOW(wnd), g_get_application_name());
}
Exemplo n.º 26
0
void _fcitx_main_window_add_addon_page(FcitxMainWindow* self)
{
    /* load addon */
    FcitxAddon* addon;
    utarray_new(self->addons, &addonicd);
    FcitxAddonsLoad(self->addons);

    GtkWidget* vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);

    /* advance check box */
    self->advancecheckbox = gtk_check_button_new_with_label(_("Advance"));
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(self->advancecheckbox), FALSE);
    g_signal_connect(G_OBJECT(self->advancecheckbox), "toggled", G_CALLBACK(_fcitx_main_window_checkbox_changed), self);

    /* filter entry */
    self->filterentry = gtk_entry_new();
    gtk_entry_set_icon_from_gicon (GTK_ENTRY (self->filterentry),
                                    GTK_ENTRY_ICON_SECONDARY,
                                    g_themed_icon_new_with_default_fallbacks("edit-clear"));
    g_object_set(G_OBJECT(self->filterentry), "margin", 5, NULL);
#if GTK_CHECK_VERSION(3,2,0)
    gtk_entry_set_placeholder_text(GTK_ENTRY (self->filterentry), _("Search Addon"));
#endif
    g_signal_connect(G_OBJECT(self->filterentry), "icon-press", G_CALLBACK (icon_press_cb), NULL);

    /* list view */
    self->addonstore = gtk_list_store_new(N_COLUMNS, G_TYPE_POINTER);
    for (addon = (FcitxAddon *) utarray_front(self->addons);
         addon != NULL;
         addon = (FcitxAddon *) utarray_next(self->addons, addon)) {
        GtkTreeIter iter;
        gtk_list_store_append(self->addonstore, &iter);
        gtk_list_store_set(self->addonstore, &iter, LIST_ADDON, addon, -1);
    }

    self->filtermodel = gtk_tree_model_filter_new(GTK_TREE_MODEL(self->addonstore), NULL);

    gtk_tree_model_filter_set_visible_func(GTK_TREE_MODEL_FILTER(self->filtermodel),
                                           (GtkTreeModelFilterVisibleFunc) _filter_addon_func,
                                           self,
                                           NULL);
    self->addonview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(self->filtermodel));

    /* add column check box */
    self->togglecell = gtk_cell_renderer_toggle_new();
    self->checkboxcolumn = gtk_tree_view_column_new_with_attributes("Enable", self->togglecell, NULL);
    gtk_tree_view_column_set_visible(self->checkboxcolumn, FALSE);
    gtk_tree_view_append_column(GTK_TREE_VIEW(self->addonview), self->checkboxcolumn);
    gtk_cell_layout_set_cell_data_func(GTK_CELL_LAYOUT(self->checkboxcolumn),
                                       self->togglecell,
                                       _fcitx_main_window_enabled_data_func,
                                       NULL,
                                       NULL);

    /* add column text */
    GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
    GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes("Name", renderer, NULL);
    gtk_tree_view_append_column(GTK_TREE_VIEW(self->addonview), column);
    gtk_cell_layout_set_cell_data_func(GTK_CELL_LAYOUT(column),
                                       renderer,
                                       _fcitx_main_window_name_data_func,
                                       NULL,
                                       NULL);

    /* add addon list to vbox */
    GtkWidget* swin = gtk_scrolled_window_new(NULL, NULL);
    g_object_set(swin, "hscrollbar-policy", GTK_POLICY_NEVER, NULL);
    g_object_set(self->addonview, "headers-visible", FALSE, NULL);
    gtk_container_add(GTK_CONTAINER(swin), self->addonview);
    gtk_box_pack_start(GTK_BOX(vbox), swin, TRUE, TRUE, 0);
    g_object_set(G_OBJECT(swin), "margin-left", 5, "margin-right", 5, "shadow-type", GTK_SHADOW_IN, NULL);

    g_signal_connect(G_OBJECT(self->togglecell), "toggled",
                     G_CALLBACK(_fcitx_main_window_toggled_cb), GTK_TREE_MODEL(self->addonstore));

    gtk_box_pack_start(GTK_BOX(vbox), self->advancecheckbox, FALSE, TRUE, 0);
    g_object_set(G_OBJECT(self->advancecheckbox), "margin-left", 5, "margin-right", 5, NULL);
    gtk_box_pack_start(GTK_BOX(vbox), self->filterentry, FALSE, TRUE, 5);

    /* configure button */
    GtkWidget* hbuttonbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
    gtk_box_pack_start(GTK_BOX(vbox), hbuttonbox, FALSE, TRUE, 0);
    g_object_set(G_OBJECT(hbuttonbox), "margin", 5, NULL);

    self->button = gtk_button_new_with_label(_("Configure"));
    gtk_widget_set_sensitive(self->button, FALSE);
    gtk_button_set_image(GTK_BUTTON(self->button), gtk_image_new_from_gicon(g_themed_icon_new_with_default_fallbacks("preferences-system"), GTK_ICON_SIZE_BUTTON));
    gtk_box_pack_start(GTK_BOX(hbuttonbox), self->button, TRUE, TRUE, 0);
    g_signal_connect(G_OBJECT(self->button), "clicked", G_CALLBACK(_fcitx_main_window_configure_button_clicked), self);

    GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(self->addonview));
    gtk_tree_selection_set_mode(selection, GTK_SELECTION_BROWSE);
    g_signal_connect(G_OBJECT(selection), "changed",
                     G_CALLBACK(_fcitx_main_window_addon_selection_changed), self);
    g_signal_connect(G_OBJECT(self->filterentry), "changed", G_CALLBACK(_fcitx_main_window_filtertext_changed), self);
    gtk_tree_model_filter_refilter(GTK_TREE_MODEL_FILTER(self->filtermodel));

    g_signal_connect(G_OBJECT(self->addonview),
                     "row-activated",
                     G_CALLBACK(_fcitx_main_window_addon_row_activated), self);

    _fcitx_main_window_add_page(self, _("Addon"), vbox);
}
Exemplo n.º 27
0
int
main (int argc, char **argv)
{
  GtkWidget *window, *grid;
  GtkWidget *label, *image, *box;
  GtkIconTheme *theme;
  GdkPixbuf *pixbuf;
  GtkIconSet *iconset;
  GtkIconSource *iconsource;
  gchar *icon_name = "gnome-terminal";
  gchar *anim_filename = NULL;
  GIcon *icon;
  GFile *file;

  gtk_init (&argc, &argv);

  if (argc > 1)
    icon_name = argv[1];

  if (argc > 2)
    anim_filename = argv[2];

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  grid = gtk_grid_new ();
  gtk_container_add (GTK_CONTAINER (window), grid);

  label = gtk_label_new ("symbolic size");
  gtk_grid_attach (GTK_GRID (grid), label, 1, 0, 1, 1);
  label = gtk_label_new ("fixed size");
  gtk_grid_attach (GTK_GRID (grid), label, 2, 0, 1, 1);

  label = gtk_label_new ("GTK_IMAGE_PIXBUF");
  gtk_grid_attach (GTK_GRID (grid), label, 0, 1, 1, 1);

  theme = gtk_icon_theme_get_default ();
  pixbuf = gtk_icon_theme_load_icon (theme, icon_name, 48, 0, NULL);
  image = gtk_image_new_from_pixbuf (pixbuf);
  box = gtk_event_box_new ();
  gtk_container_add (GTK_CONTAINER (box), image);
  gtk_grid_attach (GTK_GRID (grid), box, 2, 1, 1, 1);

  gtk_drag_source_set (box, GDK_BUTTON1_MASK, 
		       NULL, 0,
		       GDK_ACTION_COPY);
  gtk_drag_source_add_image_targets (box);
  g_signal_connect (box, "drag_begin", G_CALLBACK (drag_begin), image);
  g_signal_connect (box, "drag_data_get", G_CALLBACK (drag_data_get), image);

  gtk_drag_dest_set (box,
                     GTK_DEST_DEFAULT_MOTION |
                     GTK_DEST_DEFAULT_HIGHLIGHT |
                     GTK_DEST_DEFAULT_DROP,
                     NULL, 0, GDK_ACTION_COPY);
  gtk_drag_dest_add_image_targets (box);
  g_signal_connect (box, "drag_data_received", 
		    G_CALLBACK (drag_data_received), image);

  label = gtk_label_new ("GTK_IMAGE_STOCK");
  gtk_grid_attach (GTK_GRID (grid), label, 0, 2, 1, 1);

  image = gtk_image_new_from_stock (GTK_STOCK_REDO, GTK_ICON_SIZE_DIALOG);
  gtk_grid_attach (GTK_GRID (grid), image, 1, 2, 1, 1);

  label = gtk_label_new ("GTK_IMAGE_ICON_SET");
  gtk_grid_attach (GTK_GRID (grid), label, 0, 3, 1, 1);

  iconsource = gtk_icon_source_new ();
  gtk_icon_source_set_icon_name (iconsource, icon_name);
  iconset = gtk_icon_set_new ();
  gtk_icon_set_add_source (iconset, iconsource);
  image = gtk_image_new_from_icon_set (iconset, GTK_ICON_SIZE_DIALOG);
  gtk_grid_attach (GTK_GRID (grid), image, 1, 3, 1, 1);

  label = gtk_label_new ("GTK_IMAGE_ICON_NAME");
  gtk_grid_attach (GTK_GRID (grid), label, 0, 4, 1, 1);
  image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_DIALOG);
  gtk_grid_attach (GTK_GRID (grid), image, 1, 4, 1, 1);
  image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_DIALOG);
  gtk_image_set_pixel_size (GTK_IMAGE (image), 30);
  gtk_grid_attach (GTK_GRID (grid), image, 2, 4, 1, 1);

  label = gtk_label_new ("GTK_IMAGE_GICON");
  gtk_grid_attach (GTK_GRID (grid), label, 0, 5, 1, 1);
  icon = g_themed_icon_new_with_default_fallbacks ("folder-remote");
  image = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_DIALOG);
  g_object_unref (icon);
  gtk_grid_attach (GTK_GRID (grid), image, 1, 5, 1, 1);
  file = g_file_new_for_path ("apple-red.png");
  icon = g_file_icon_new (file);
  image = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_DIALOG);
  g_object_unref (icon);
  gtk_image_set_pixel_size (GTK_IMAGE (image), 30);
  gtk_grid_attach (GTK_GRID (grid), image, 2, 5, 1, 1);

  
  if (anim_filename)
    {
      label = gtk_label_new ("GTK_IMAGE_ANIMATION (from file)");
      gtk_grid_attach (GTK_GRID (grid), label, 0, 6, 1, 1);
      image = gtk_image_new_from_file (anim_filename);
      gtk_image_set_pixel_size (GTK_IMAGE (image), 30);
      gtk_grid_attach (GTK_GRID (grid), image, 2, 6, 1, 1);

      /* produce high load */
      g_signal_connect_after (image, "draw",
                              G_CALLBACK (anim_image_draw),
                              NULL);
    }

  gtk_widget_show_all (window);

  gtk_main ();

  return 0;
}
static void
brasero_project_type_chooser_build_recent (BraseroProjectTypeChooser *self,
					   GtkRecentManager *recent)
{
	GtkSizeGroup *image_group;
	GtkSizeGroup *group;
	GList *list = NULL;
	gchar *filename;
	GList *recents;
	GList *iter;

	recents = gtk_recent_manager_get_items (recent);
	for (iter = recents; iter; iter = iter->next) {
		GtkRecentInfo *info;
		const gchar *mime;

		info = iter->data;
		mime = gtk_recent_info_get_mime_type (info);
		if (!mime)
			continue;

		/* filter those we want */
		if (strcmp (mime, "application/x-brasero")
		&&  strcmp (mime, "application/x-cd-image")
		&&  strcmp (mime, "application/x-cdrdao-toc")
		&&  strcmp (mime, "application/x-toc")
		&&  strcmp (mime, "application/x-cue")
		&&  strcmp (mime, "audio/x-scpls")
		&&  strcmp (mime, "audio/x-ms-asx")
		&&  strcmp (mime, "audio/x-mp3-playlist")
		&&  strcmp (mime, "audio/x-mpegurl"))
			continue;

		/* sort */
		list = g_list_insert_sorted (list,
					     info,
					     brasero_project_type_chooser_sort_recent);
		if (g_list_length (list) > 5)
			list = g_list_delete_link (list, g_list_last (list));
	}

	group = gtk_size_group_new (GTK_SIZE_GROUP_BOTH);
	image_group = gtk_size_group_new (GTK_SIZE_GROUP_BOTH);

	/* If a project was left unfinished last time then add another entry */
	filename = g_build_filename (g_get_user_config_dir (),
				     "brasero",
				     BRASERO_SESSION_TMP_PROJECT_PATH,
				     NULL);
	if (g_file_test (filename, G_FILE_TEST_EXISTS)) {
		gchar *uri;
		GtkWidget *link;
		GtkWidget *image;

		uri = g_filename_to_uri (filename, NULL, NULL);

		image = gtk_image_new_from_icon_name ("brasero", GTK_ICON_SIZE_BUTTON);
		gtk_size_group_add_widget (image_group, image);

		link = gtk_button_new_with_label (_("Last _Unsaved Project"));
		g_object_set_data_full (G_OBJECT (link),
					"BraseroButtonURI", uri,
					g_free);

		gtk_button_set_relief (GTK_BUTTON (link), GTK_RELIEF_NONE);
		gtk_button_set_alignment (GTK_BUTTON (link), 0.0, 0.5);
		gtk_button_set_focus_on_click (GTK_BUTTON (link), FALSE);
		gtk_button_set_image (GTK_BUTTON (link), image);
		gtk_button_set_use_underline (GTK_BUTTON (link), TRUE);
		g_signal_connect (link,
				  "clicked",
				  G_CALLBACK (brasero_project_type_chooser_last_unsaved_clicked_cb),
				  self);

		gtk_widget_show (link);
		gtk_widget_set_tooltip_text (link, _("Load the last project that was not burned and not saved"));
		gtk_box_pack_start (GTK_BOX (self->priv->recent_box), link, FALSE, TRUE, 0);

		gtk_size_group_add_widget (group, link);
	}
	g_free (filename);

	for (iter = list; iter; iter = iter->next) {
		GtkRecentInfo *info;
		GList *child_iter;
		const gchar *name;
		GIcon *icon;
		GtkWidget *image;
		const gchar *uri;
		GtkWidget *child;
		GtkWidget *link;
		GList *children;
		gchar *tooltip;

		info = iter->data;

		tooltip = gtk_recent_info_get_uri_display (info);

		icon = gtk_recent_info_get_gicon (info);
		image = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_BUTTON);
		g_object_unref (icon);
		gtk_size_group_add_widget (image_group, image);

		gtk_widget_show (image);
		gtk_widget_set_tooltip_text (image, tooltip);

		name = gtk_recent_info_get_display_name (info);
		uri = gtk_recent_info_get_uri (info);

		/* Don't use mnemonics with filenames */
		link = gtk_button_new_with_label (name);
		g_object_set_data_full (G_OBJECT (link),
					"BraseroButtonURI", g_strdup (uri),
					g_free);

		gtk_button_set_relief (GTK_BUTTON (link), GTK_RELIEF_NONE);
		gtk_button_set_image (GTK_BUTTON (link), image);
		gtk_button_set_alignment (GTK_BUTTON (link), 0.0, 0.5);
		gtk_button_set_focus_on_click (GTK_BUTTON (link), FALSE);
		g_signal_connect (link,
				  "clicked",
				  G_CALLBACK (brasero_project_type_chooser_recent_clicked_cb),
				  self);
		gtk_widget_show (link);

		gtk_widget_set_tooltip_text (link, tooltip);
		gtk_box_pack_start (GTK_BOX (self->priv->recent_box), link, FALSE, TRUE, 0);

		g_free (tooltip);

		gtk_size_group_add_widget (group, link);

		/* That's a tedious hack to avoid mnemonics which are hardcoded
		 * when you add an image to a button. BUG? */
		if (!GTK_IS_BIN (link))
			continue;

		child = gtk_bin_get_child (GTK_BIN (link));
		if (!GTK_IS_ALIGNMENT (child))
			continue;

		gtk_alignment_set (GTK_ALIGNMENT (child),
				   0.0,
				   0.5,
				   1.0,
				   1.0);

		child = gtk_bin_get_child (GTK_BIN (child));
		if (!GTK_IS_BOX (child))
			continue;

		children = gtk_container_get_children (GTK_CONTAINER (child));
		for (child_iter = children; child_iter; child_iter = child_iter->next) {
			GtkWidget *widget;

			widget = child_iter->data;
			if (GTK_IS_LABEL (widget)) {
				gtk_label_set_use_underline (GTK_LABEL (widget), FALSE);
				gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);

				/* Make sure that the name is not too long */
				gtk_box_set_child_packing (GTK_BOX (child),
							   widget,
							   TRUE,
							   TRUE,
							   0,
							   GTK_PACK_START);
				gtk_label_set_ellipsize (GTK_LABEL (widget),
							 PANGO_ELLIPSIZE_END);
				break;
			}
		}
		g_list_free (children);
	}
	g_object_unref (image_group);
	g_object_unref (group);

	if (!g_list_length (list)) {
		GtkWidget *label;
		gchar *string;

		string = g_strdup_printf ("<i>%s</i>", _("No recently used project"));
		label = gtk_label_new (string);
		gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
		g_free (string);

		gtk_widget_show (label);
		gtk_box_pack_start (GTK_BOX (self->priv->recent_box), label, FALSE, FALSE, 0);
	}

	g_list_free (list);

	g_list_foreach (recents, (GFunc) gtk_recent_info_unref, NULL);
	g_list_free (recents);
}
Exemplo n.º 29
0
Arquivo: images.c Projeto: GNOME/gtk
GtkWidget *
do_images (GtkWidget *do_widget)
{
  GtkWidget *video;
  GtkWidget *frame;
  GtkWidget *vbox;
  GtkWidget *hbox;
  GtkWidget *base_vbox;
  GtkWidget *image;
  GtkWidget *picture;
  GtkWidget *label;
  GtkWidget *button;
  GdkPaintable *paintable;
  GIcon *gicon;

  if (!window)
    {
      window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
      gtk_window_set_display (GTK_WINDOW (window),
                              gtk_widget_get_display (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);

      base_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
      g_object_set (base_vbox, "margin", 16, NULL);
      gtk_container_add (GTK_CONTAINER (window), base_vbox);

      hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 16);
      gtk_container_add (GTK_CONTAINER (base_vbox), hbox);

      vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
      gtk_container_add (GTK_CONTAINER (hbox), vbox);

      label = gtk_label_new (NULL);
      gtk_label_set_markup (GTK_LABEL (label),
                            "<u>Image loaded from a file</u>");
      gtk_container_add (GTK_CONTAINER (vbox), label);

      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_container_add (GTK_CONTAINER (vbox), frame);

      image = gtk_image_new_from_icon_name ("gtk3-demo");
      gtk_image_set_icon_size (GTK_IMAGE (image), GTK_ICON_SIZE_LARGE);

      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_container_add (GTK_CONTAINER (vbox), label);

      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_container_add (GTK_CONTAINER (vbox), frame);

      picture = gtk_picture_new_for_resource ("/images/floppybuddy.gif");

      gtk_container_add (GTK_CONTAINER (frame), picture);

      /* Symbolic icon */

      label = gtk_label_new (NULL);
      gtk_label_set_markup (GTK_LABEL (label),
                            "<u>Symbolic themed icon</u>");
      gtk_container_add (GTK_CONTAINER (vbox), label);

      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_container_add (GTK_CONTAINER (vbox), frame);

      gicon = g_themed_icon_new_with_default_fallbacks ("battery-caution-charging-symbolic");
      image = gtk_image_new_from_gicon (gicon);
      gtk_image_set_icon_size (GTK_IMAGE (image), GTK_ICON_SIZE_LARGE);

      gtk_container_add (GTK_CONTAINER (frame), image);


      /* Progressive */
      vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
      gtk_container_add (GTK_CONTAINER (hbox), vbox);

      label = gtk_label_new (NULL);
      gtk_label_set_markup (GTK_LABEL (label),
                            "<u>Progressive image loading</u>");
      gtk_container_add (GTK_CONTAINER (vbox), label);

      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_container_add (GTK_CONTAINER (vbox), frame);

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

      start_progressive_loading (picture);

      /* Video */
      vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
      gtk_container_add (GTK_CONTAINER (hbox), vbox);

      label = gtk_label_new (NULL);
      gtk_label_set_markup (GTK_LABEL (label),
                            "<u>Displaying video</u>");
      gtk_container_add (GTK_CONTAINER (vbox), label);

      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_container_add (GTK_CONTAINER (vbox), frame);

      video = gtk_video_new_for_resource ("/images/gtk-logo.webm");
      gtk_media_stream_set_loop (gtk_video_get_media_stream (GTK_VIDEO (video)), TRUE);
      gtk_container_add (GTK_CONTAINER (frame), video);

      /* Widget paintables */
      vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
      gtk_container_add (GTK_CONTAINER (hbox), vbox);

      label = gtk_label_new (NULL);
      gtk_label_set_markup (GTK_LABEL (label),
                            "<u>GtkWidgetPaintable</u>");
      gtk_container_add (GTK_CONTAINER (vbox), label);

      paintable = gtk_widget_paintable_new (do_widget);
      picture = gtk_picture_new_for_paintable (paintable);
      gtk_widget_set_size_request (picture, 100, 100);
      gtk_widget_set_valign (picture, GTK_ALIGN_START);
      gtk_container_add (GTK_CONTAINER (vbox), picture);

      /* Sensitivity control */
      button = gtk_toggle_button_new_with_mnemonic ("_Insensitive");
      gtk_container_add (GTK_CONTAINER (base_vbox), button);

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

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

  return window;
}
Exemplo n.º 30
0
gint
main (gint argc, gchar **argv)
{
  GtkWidget *window, *toolbar, *grid, *treeview, *scrolled_window;
  GtkWidget *hbox, *hbox1, *hbox2, *checkbox, *option_menu, *menu;
  gint i;
  static const gchar *toolbar_styles[] = { "icons", "text", "both (vertical)",
					   "both (horizontal)" };
  GtkToolItem *item;
  GtkListStore *store;
  GtkWidget *image;
  GtkWidget *menuitem;
  GtkWidget *button;
  GtkWidget *label;
  GIcon *gicon;
  GSList *group;
  
  gtk_init (&argc, &argv);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

  g_signal_connect (window, "destroy", G_CALLBACK(gtk_main_quit), NULL);

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

  toolbar = gtk_toolbar_new ();
  gtk_widget_set_vexpand (toolbar, TRUE);
  gtk_grid_attach (GTK_GRID (grid), toolbar, 0, 0, 2, 1);

  hbox1 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 3);
  gtk_container_set_border_width (GTK_CONTAINER (hbox1), 5);
  gtk_widget_set_vexpand (hbox1, TRUE);
  gtk_grid_attach (GTK_GRID (grid), hbox1, 1, 1, 1, 1);

  hbox2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
  gtk_container_set_border_width (GTK_CONTAINER (hbox2), 5);
  gtk_widget_set_vexpand (hbox2, TRUE);
  gtk_grid_attach (GTK_GRID (grid), hbox2, 1, 2, 1, 1);

  checkbox = gtk_check_button_new_with_mnemonic("_Vertical");
  gtk_box_pack_start (GTK_BOX (hbox1), checkbox, FALSE, FALSE, 0);
  g_signal_connect (checkbox, "toggled",
		    G_CALLBACK (change_orientation), toolbar);

  checkbox = gtk_check_button_new_with_mnemonic("_Show Arrow");
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbox), TRUE);
  gtk_box_pack_start (GTK_BOX (hbox1), checkbox, FALSE, FALSE, 0);
  g_signal_connect (checkbox, "toggled",
		    G_CALLBACK (change_show_arrow), toolbar);

  checkbox = gtk_check_button_new_with_mnemonic("_Set Toolbar Style:");
  g_signal_connect (checkbox, "toggled", G_CALLBACK (set_toolbar_style_toggled), toolbar);
  gtk_box_pack_start (GTK_BOX (hbox1), checkbox, FALSE, FALSE, 0);

  option_menu = gtk_combo_box_text_new ();
  gtk_widget_set_sensitive (option_menu, FALSE);  
  g_object_set_data (G_OBJECT (checkbox), "option-menu", option_menu);
  
  for (i = 0; i < G_N_ELEMENTS (toolbar_styles); i++)
    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (option_menu), toolbar_styles[i]);
  gtk_combo_box_set_active (GTK_COMBO_BOX (option_menu),
                            gtk_toolbar_get_style (GTK_TOOLBAR (toolbar)));
  gtk_box_pack_start (GTK_BOX (hbox2), option_menu, FALSE, FALSE, 0);
  g_signal_connect (option_menu, "changed",
		    G_CALLBACK (change_toolbar_style), toolbar);

  checkbox = gtk_check_button_new_with_mnemonic("_Set Icon Size:"); 
  g_signal_connect (checkbox, "toggled", G_CALLBACK (set_icon_size_toggled), toolbar);
  gtk_box_pack_start (GTK_BOX (hbox2), checkbox, FALSE, FALSE, 0);

  option_menu = gtk_combo_box_text_new ();
  g_object_set_data (G_OBJECT (checkbox), "option-menu", option_menu);
  gtk_widget_set_sensitive (option_menu, FALSE);
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (option_menu), "small toolbar");
  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (option_menu), "large toolbar");

  gtk_box_pack_start (GTK_BOX (hbox2), option_menu, FALSE, FALSE, 0);
  g_signal_connect (option_menu, "changed",
		    G_CALLBACK (icon_size_history_changed), toolbar);
  
  scrolled_window = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
				  GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
  gtk_widget_set_hexpand (scrolled_window, TRUE);
  gtk_widget_set_vexpand (scrolled_window, TRUE);
  gtk_grid_attach (GTK_GRID (grid), scrolled_window, 1, 3, 1, 1);

  store = create_items_list (&treeview);
  gtk_container_add (GTK_CONTAINER (scrolled_window), treeview);
  
  item = gtk_tool_button_new (NULL, NULL);
  gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (item), "document-new");
  gtk_tool_button_set_label (GTK_TOOL_BUTTON (item), "Custom label");
  add_item_to_list (store, item, "New");
  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
  gdk_threads_add_timeout (3000, (GSourceFunc) timeout_cb, item);
  gtk_tool_item_set_expand (item, TRUE);

  menu = gtk_menu_new ();
  for (i = 0; i < 20; i++)
    {
      char *text;
      text = g_strdup_printf ("Menuitem %d", i);
      menuitem = gtk_menu_item_new_with_label (text);
      g_free (text);
      gtk_widget_show (menuitem);
      gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
    }

  item = gtk_menu_tool_button_new (NULL, NULL);
  gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (item), "document-open");
  gtk_tool_button_set_label (GTK_TOOL_BUTTON (item), "Open");
  gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (item), menu);
  add_item_to_list (store, item, "Open");
  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
  gdk_threads_add_timeout (3000, (GSourceFunc) timeout_cb1, item);
 
  menu = gtk_menu_new ();
  for (i = 0; i < 20; i++)
    {
      char *text;
      text = g_strdup_printf ("A%d", i);
      menuitem = gtk_menu_item_new_with_label (text);
      g_free (text);
      gtk_widget_show (menuitem);
      gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
    }

  item = gtk_menu_tool_button_new (NULL, NULL);
  gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (item), "go-previous");
  gtk_tool_button_set_label (GTK_TOOL_BUTTON (item), "Back");
  gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (item), menu);
  add_item_to_list (store, item, "BackWithHistory");
  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
 
  item = gtk_separator_tool_item_new ();
  add_item_to_list (store, item, "-----");    
  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
  
  image = gtk_image_new_from_icon_name ("dialog-warning", GTK_ICON_SIZE_DIALOG);
  item = gtk_tool_item_new ();
  gtk_widget_show (image);
  gtk_container_add (GTK_CONTAINER (item), image);
  add_item_to_list (store, item, "(Custom Item)");    
  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
  
  item = gtk_tool_button_new (NULL, NULL);
  gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (item), "go-previous");
  gtk_tool_button_set_label (GTK_TOOL_BUTTON (item), "Back");
  add_item_to_list (store, item, "Back");    
  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);

  item = gtk_separator_tool_item_new ();
  add_item_to_list (store, item, "-----");  
  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
  
  item = gtk_tool_button_new (NULL, NULL);
  gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (item), "go-next");
  gtk_tool_button_set_label (GTK_TOOL_BUTTON (item), "Forward");
  add_item_to_list (store, item, "Forward");  
  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);

  item = gtk_toggle_tool_button_new ();
  gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (item), "format-text-bold");
  g_signal_connect (item, "toggled", G_CALLBACK (bold_toggled), NULL);
  add_item_to_list (store, item, "Bold");  
  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
  gtk_widget_set_sensitive (GTK_WIDGET (item), FALSE);

  item = gtk_separator_tool_item_new ();
  add_item_to_list (store, item, "-----");  
  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
  gtk_tool_item_set_expand (item, TRUE);
  gtk_separator_tool_item_set_draw (GTK_SEPARATOR_TOOL_ITEM (item), FALSE);
  g_assert (gtk_toolbar_get_nth_item (GTK_TOOLBAR (toolbar), 0) != 0);
  
  item = gtk_radio_tool_button_new (NULL);
  gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (item), "format-justify-left");
  group = gtk_radio_tool_button_get_group (GTK_RADIO_TOOL_BUTTON (item));
  add_item_to_list (store, item, "Left");
  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
  
  
  item = gtk_radio_tool_button_new (group);
  gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (item), "format-justify-center");
  make_prop_editor (G_OBJECT (item));

  group = gtk_radio_tool_button_get_group (GTK_RADIO_TOOL_BUTTON (item));
  add_item_to_list (store, item, "Center");
  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);

  item = gtk_radio_tool_button_new (group);
  gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (item), "format-justify-right");
  add_item_to_list (store, item, "Right");
  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);

  item = gtk_tool_button_new (gtk_image_new_from_file ("apple-red.png"), "_Apple");
  add_item_to_list (store, item, "Apple");
  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
  gtk_tool_button_set_use_underline (GTK_TOOL_BUTTON (item), TRUE);

  gicon = g_content_type_get_icon ("video/ogg");
  image = gtk_image_new_from_gicon (gicon, GTK_ICON_SIZE_LARGE_TOOLBAR);
  g_object_unref (gicon);
  item = gtk_tool_button_new (image, "Video");
  add_item_to_list (store, item, "Video");
  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);

  image = gtk_image_new_from_icon_name ("utilities-terminal", GTK_ICON_SIZE_LARGE_TOOLBAR);
  item = gtk_tool_button_new (image, "Terminal");
  add_item_to_list (store, item, "Terminal");
  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);

  image = gtk_spinner_new ();
  gtk_spinner_start (GTK_SPINNER (image));
  item = gtk_tool_button_new (image, "Spinner");
  add_item_to_list (store, item, "Spinner");
  gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);

  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
  gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
  gtk_widget_set_hexpand (hbox, TRUE);
  gtk_grid_attach (GTK_GRID (grid), hbox, 1, 4, 1, 1);

  button = gtk_button_new_with_label ("Drag me to the toolbar");
  gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);

  label = gtk_label_new ("Drop index:");
  gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);

  label = gtk_label_new ("");
  gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);

  checkbox = gtk_check_button_new_with_mnemonic("_Right to left");
  if (gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL)
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbox), TRUE);
  else
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbox), FALSE);
  g_signal_connect (checkbox, "toggled", G_CALLBACK (rtl_toggled), NULL);

  gtk_box_pack_end (GTK_BOX (hbox), checkbox, FALSE, FALSE, 0);
  
  gtk_drag_source_set (button, GDK_BUTTON1_MASK,
		       target_table, G_N_ELEMENTS (target_table),
		       GDK_ACTION_MOVE);
  gtk_drag_dest_set (toolbar, GTK_DEST_DEFAULT_DROP,
		     target_table, G_N_ELEMENTS (target_table),
		     GDK_ACTION_MOVE);
  g_signal_connect (toolbar, "drag_motion",
		    G_CALLBACK (toolbar_drag_motion), NULL);
  g_signal_connect (toolbar, "drag_leave",
		    G_CALLBACK (toolbar_drag_leave), NULL);
  g_signal_connect (toolbar, "drag_drop",
		    G_CALLBACK (toolbar_drag_drop), label);

  gtk_widget_show_all (window);

  make_prop_editor (G_OBJECT (toolbar));

  g_signal_connect (window, "delete_event", G_CALLBACK (gtk_main_quit), NULL);
  
  g_signal_connect (toolbar, "popup_context_menu", G_CALLBACK (popup_context_menu), NULL);
  
  gtk_main ();
  
  return 0;
}