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;
}
GtkWidget* create_icon_window()
{
	GtkWidget *hbox, *btn;
	GdkPixbuf *pixbuf;
	gint i;
	
	_icon_window = gtk_window_new(GTK_WINDOW_POPUP);
	hbox = gtk_hbox_new(FALSE, 0);
	gtk_container_add(GTK_CONTAINER(_icon_window), hbox);
	for(i=0; i <XFCE_N_BUILTIN_ICON_CATEGORIES; ++i)
	{
		pixbuf = xfce_icon_theme_load_category(DEFAULT_ICON_THEME, i, 16);
		btn = xfce_iconbutton_new();
		gtk_button_set_relief (GTK_BUTTON (btn), GTK_RELIEF_NONE);
		xfce_iconbutton_set_pixbuf(XFCE_ICONBUTTON (btn), pixbuf);
		UNREF(pixbuf);
		gtk_box_pack_start(GTK_BOX(hbox), btn, TRUE, TRUE, 1);
		g_signal_connect(btn, "clicked", G_CALLBACK(btn_clicked), (gpointer)i);
		g_signal_connect_swapped(btn, "clicked", G_CALLBACK(gtk_widget_hide), (gpointer)_icon_window);
		gtk_widget_show(btn);
	}
	btn = gtk_button_new_with_label(" ... ");
	gtk_button_set_relief (GTK_BUTTON (btn), GTK_RELIEF_NONE);
	gtk_box_pack_start(GTK_BOX(hbox), btn, TRUE, TRUE, 1);
	g_signal_connect(btn, "clicked", G_CALLBACK(btn_clicked), (gpointer)XFCE_ICON_CATEGORY_EXTERN);
	g_signal_connect_swapped(btn, "clicked", G_CALLBACK(gtk_widget_hide), (gpointer)_icon_window);
	gtk_widget_show(btn);
	//XFCE_ICON_CATEGORY_STOCK
	
	gtk_widget_show(hbox);
	
	return _icon_window;
}
Example #3
0
GtkWidget *get_button(i3_ws *w)
{
	GtkWidget *button = gtk_button_new();
	gtk_button_set_label(GTK_BUTTON(button), w->name);

	g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(button_click_cb), NULL);
	gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);

	GdkColor color;

	if (w->visible) {
		gdk_color_parse("#949289", &color);
		gtk_widget_modify_bg(GTK_WIDGET(button), GTK_STATE_NORMAL, &color);
		gtk_widget_modify_bg(GTK_WIDGET(button), GTK_STATE_PRELIGHT, &color);
		gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_HALF);
	}


	if (w->focused) {
		gdk_color_parse("#285577", &color);
		gtk_widget_modify_bg(GTK_WIDGET(button), GTK_STATE_NORMAL, &color);
		gtk_widget_modify_bg(GTK_WIDGET(button), GTK_STATE_PRELIGHT, &color);
		gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_HALF);
	}

	if (w->urgent) {
		gdk_color_parse("#9F0000", &color);
		gtk_widget_modify_bg(GTK_WIDGET(button), GTK_STATE_NORMAL, &color);
		gtk_widget_modify_bg(GTK_WIDGET(button), GTK_STATE_PRELIGHT, &color);
		gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_HALF);
	}

	return button;
}
Example #4
0
void
go_combo_box_set_relief (GOComboBox *combo, GtkReliefStyle relief)
{
	g_return_if_fail (IS_GO_COMBO_BOX (combo));

	gtk_button_set_relief (GTK_BUTTON (combo->priv->arrow_button), relief);
	if (GTK_IS_BUTTON (combo->priv->display_widget))
		gtk_button_set_relief (GTK_BUTTON (combo->priv->display_widget), relief);
}
Example #5
0
void addButton(Action action)
{
	GtkWidget *vboxWidget = NULL;
	GtkWidget *buttonWidget = NULL;
	GtkWidget *imageWidget = NULL;
	GtkWidget *labelWidget = NULL;
	gchar *imgpath = NULL;
	gchar *markup = NULL;

	g_assert(action != ACTION_NONE);

	printMessage(MSG_VERB, "Add button: %s\n", getActionStr(action));

	if (myTheme.bt_img) {
		imgpath = getButtonImagePath(action);
		if (imgpath) {
			imageWidget = gtk_image_new_from_file(imgpath);
			g_free(imgpath);
		}
		else
			imageWidget = gtk_image_new_from_stock(GTK_STOCK_MISSING_IMAGE, GTK_ICON_SIZE_LARGE_TOOLBAR);
	}

	vboxWidget = gtk_vbox_new(FALSE, 0);

	buttonWidget = gtk_button_new();

	if (myTheme.bt_relief == T_BT_RELIEF_NONE)
		gtk_button_set_relief(GTK_BUTTON(buttonWidget), GTK_RELIEF_NONE);
	if (myTheme.bt_relief == T_BT_RELIEF_NORMAL)
		gtk_button_set_relief(GTK_BUTTON(buttonWidget), GTK_RELIEF_NORMAL);

	gtk_widget_modify_bg(buttonWidget, GTK_STATE_NORMAL, &myTheme.win_bg_color);
	gtk_widget_set_can_focus(buttonWidget, FALSE);

	gtk_container_set_border_width(GTK_CONTAINER(buttonWidget), myTheme.bt_spacing / 2);
	/*gtk_container_add(GTK_CONTAINER(buttonWidget), imageWidget);*/
	gtk_button_set_image(GTK_BUTTON(buttonWidget), imageWidget);

	gtk_box_pack_start(GTK_BOX(vboxWidget), buttonWidget, TRUE, TRUE, 0);
	g_signal_connect(buttonWidget, "clicked", G_CALLBACK(onButtonClick), (gpointer) action);

	if (myTheme.bt_labels) {
		markup = g_markup_printf_escaped(myTheme.bt_labels_style, myOptions.labels[action]);
		labelWidget = gtk_label_new(markup);
		gtk_label_set_markup(GTK_LABEL(labelWidget), markup);
		g_free(markup);
		gtk_box_pack_end(GTK_BOX(vboxWidget), labelWidget, TRUE, TRUE, 0);
	}

	/*gdk_color_parse("white", &color);
	gtk_widget_modify_fg(labelWidget, GTK_STATE_NORMAL, &color);*/

	gtk_box_pack_start(GTK_BOX(hboxButtonWidget), vboxWidget, TRUE, TRUE, 0);

}
static void
gtk_scale_button_init (GtkScaleButton *button)
{
  GtkScaleButtonPrivate *priv;

  button->priv = priv = GET_PRIVATE (button);

  priv->timeout = FALSE;
  priv->click_id = 0;
  priv->click_timeout = CLICK_TIMEOUT;
  priv->orientation = GTK_ORIENTATION_VERTICAL;

  gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
  gtk_button_set_focus_on_click (GTK_BUTTON (button), FALSE);

  /* image */
  priv->image = gtk_image_new ();
  gtk_container_add (GTK_CONTAINER (button), priv->image);
  gtk_widget_show_all (priv->image);

  /* window */
  priv->dock = gtk_window_new (GTK_WINDOW_POPUP);
  gtk_widget_set_name (priv->dock, "gtk-scalebutton-popup-window");
  g_signal_connect (priv->dock, "button-press-event",
		    G_CALLBACK (cb_dock_button_press), button);
  g_signal_connect (priv->dock, "key-release-event",
		    G_CALLBACK (cb_dock_key_release), button);
  g_signal_connect (priv->dock, "grab-notify",
		    G_CALLBACK (cb_dock_grab_notify), button);
  g_signal_connect (priv->dock, "grab-broken-event",
		    G_CALLBACK (cb_dock_grab_broken_event), button);
  gtk_window_set_decorated (GTK_WINDOW (priv->dock), FALSE);

  /* + */
  button->plus_button = gtk_button_new_with_label ("+");
  gtk_button_set_relief (GTK_BUTTON (button->plus_button), GTK_RELIEF_NONE);
  g_signal_connect (button->plus_button, "button-press-event",
		    G_CALLBACK (cb_button_press), button);
  g_signal_connect (button->plus_button, "button-release-event",
		    G_CALLBACK (cb_button_release), button);

  /* - */
  button->minus_button = gtk_button_new_with_label ("-");
  gtk_button_set_relief (GTK_BUTTON (button->minus_button), GTK_RELIEF_NONE);
  g_signal_connect (button->minus_button, "button-press-event",
		   G_CALLBACK (cb_button_press), button);
  g_signal_connect (button->minus_button, "button-release-event",
		    G_CALLBACK (cb_button_release), button);

  priv->adjustment = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 100.0, 2, 20, 0));
  g_object_ref_sink (priv->adjustment);
}
static void
gdl_dock_item_grip_instance_init (GdlDockItemGrip *grip)
{
    GtkWidget *image;

    GTK_WIDGET_SET_FLAGS (grip, GTK_NO_WINDOW);
    
    grip->_priv = g_new0 (GdlDockItemGripPrivate, 1);
    grip->_priv->icon_pixbuf_valid = FALSE;
    grip->_priv->icon_pixbuf = NULL;
    grip->_priv->title_layout = NULL;

    gtk_widget_push_composite_child ();
    grip->_priv->close_button = gtk_button_new ();
    gtk_widget_pop_composite_child ();
    
    GTK_WIDGET_UNSET_FLAGS (grip->_priv->close_button, GTK_CAN_FOCUS);
    gtk_widget_set_parent (grip->_priv->close_button, GTK_WIDGET (grip));
    gtk_button_set_relief (GTK_BUTTON (grip->_priv->close_button), GTK_RELIEF_NONE);
    gtk_widget_show (grip->_priv->close_button);

    image = gtk_image_new_from_stock (GDL_STOCK_CLOSE, GTK_ICON_SIZE_MENU);
    gtk_container_add (GTK_CONTAINER (grip->_priv->close_button), image);
    gtk_widget_show (image);

    g_signal_connect (G_OBJECT (grip->_priv->close_button), "clicked",
                      G_CALLBACK (gdl_dock_item_grip_close_clicked), grip);

    gtk_widget_push_composite_child ();
    grip->_priv->iconify_button = gtk_button_new ();
    gtk_widget_pop_composite_child ();
    
    GTK_WIDGET_UNSET_FLAGS (grip->_priv->iconify_button, GTK_CAN_FOCUS);
    gtk_widget_set_parent (grip->_priv->iconify_button, GTK_WIDGET (grip));
    gtk_button_set_relief (GTK_BUTTON (grip->_priv->iconify_button), GTK_RELIEF_NONE);
    gtk_widget_show (grip->_priv->iconify_button);

    image = gtk_image_new_from_stock (GDL_STOCK_MENU_RIGHT, GTK_ICON_SIZE_MENU);
    gtk_container_add (GTK_CONTAINER (grip->_priv->iconify_button), image);
    gtk_widget_show (image);

    g_signal_connect (G_OBJECT (grip->_priv->iconify_button), "clicked",
                      G_CALLBACK (gdl_dock_item_grip_iconify_clicked), grip);

    grip->_priv->tooltips = gtk_tooltips_new ();
    g_object_ref (grip->_priv->tooltips);
    gtk_object_sink (GTK_OBJECT (grip->_priv->tooltips));
    gtk_tooltips_set_tip (grip->_priv->tooltips, grip->_priv->iconify_button,
                          _("Iconify"), _("Iconify this dock"));
    gtk_tooltips_set_tip (grip->_priv->tooltips, grip->_priv->close_button,
                          _("Close"), _("Close this dock"));
}
static GObject *
terminal_tab_label_constructor (GType type,
                                guint n_construct_properties,
                                GObjectConstructParam *construct_params)
{
  GObject *object;
  TerminalTabLabel *tab_label;
  TerminalTabLabelPrivate *priv;
  GtkWidget *hbox, *label, *close_button, *image;

  object = G_OBJECT_CLASS (terminal_tab_label_parent_class)->constructor
             (type, n_construct_properties, construct_params);

  tab_label = TERMINAL_TAB_LABEL (object);
  hbox = GTK_WIDGET (tab_label);
  priv = tab_label->priv;

  g_assert (priv->screen != NULL);
  
  gtk_box_set_spacing (GTK_BOX (hbox), SPACING);

  priv->label = label = gtk_label_new (NULL);
  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
  gtk_misc_set_padding (GTK_MISC (label), 0, 0);
  gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
  gtk_label_set_single_line_mode (GTK_LABEL (label), TRUE);

  gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);

  priv->close_button = close_button = gtk_button_new ();
  gtk_button_set_relief (GTK_BUTTON (close_button), GTK_RELIEF_NONE);
  gtk_button_set_focus_on_click (GTK_BUTTON (close_button), FALSE);
  gtk_button_set_relief (GTK_BUTTON (close_button), GTK_RELIEF_NONE);
  gtk_widget_set_name (close_button, "gnome-terminal-tab-close-button");
  gtk_widget_set_tooltip_text (close_button, _("Close tab"));

  image = gtk_image_new_from_stock (GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU);
  gtk_container_add (GTK_CONTAINER (close_button), image);
  gtk_box_pack_end (GTK_BOX (hbox), close_button, FALSE, FALSE, 0);

  sync_tab_label (priv->screen, NULL, label);
  g_signal_connect (priv->screen, "notify::title",
                    G_CALLBACK (sync_tab_label), label);

  g_signal_connect (close_button, "clicked",
		    G_CALLBACK (close_button_clicked_cb), tab_label);

  gtk_widget_show_all (hbox);

  return object;
}
Example #9
0
static gboolean gtkButtonEnterLeaveEvent(GtkWidget *widget, GdkEventCrossing *evt, Ihandle *ih)
{
  /* Used only when FLAT=Yes */

  iupgtkEnterLeaveEvent(widget, evt, ih);
  (void)widget;

  if (evt->type == GDK_ENTER_NOTIFY)
    gtk_button_set_relief((GtkButton*)ih->handle, GTK_RELIEF_NORMAL);
  else  if (evt->type == GDK_LEAVE_NOTIFY)               
    gtk_button_set_relief((GtkButton*)ih->handle, GTK_RELIEF_NONE);

  return FALSE;
}
Example #10
0
void
catalogs__gth_browser_update_extra_widget_cb (GthBrowser *browser)
{
	BrowserData *data;
	GthFileData *location_data;

	data = g_object_get_data (G_OBJECT (browser), BROWSER_DATA_KEY);

	location_data = gth_browser_get_location_data (browser);
	if (GTH_IS_FILE_SOURCE_CATALOGS (gth_browser_get_location_source (browser))
	    && ! _g_content_type_is_a (g_file_info_get_content_type (location_data->info), "gthumb/library"))
	{
		if (data->properties_button == NULL) {
			data->properties_button = gtk_button_new ();
			gtk_container_add (GTK_CONTAINER (data->properties_button), gtk_image_new_from_icon_name ("document-properties-symbolic", GTK_ICON_SIZE_MENU));
			g_object_add_weak_pointer (G_OBJECT (data->properties_button), (gpointer *)&data->properties_button);
			gtk_button_set_relief (GTK_BUTTON (data->properties_button), GTK_RELIEF_NONE);
			gtk_widget_set_tooltip_text (data->properties_button, _("Catalog Properties"));
			gtk_widget_show_all (data->properties_button);
			gtk_box_pack_start (GTK_BOX (gth_location_bar_get_action_area (GTH_LOCATION_BAR (gth_browser_get_location_bar (browser)))),
					    data->properties_button,
					    FALSE,
					    FALSE,
					    0);
			g_signal_connect (data->properties_button,
					  "clicked",
					  G_CALLBACK (properties_button_clicked_cb),
					  browser);
		}
	}
	else if (GTH_IS_FILE_SOURCE_VFS (gth_browser_get_location_source (browser))) {
		if (data->organize_button == NULL) {
			data->organize_button = gtk_button_new ();
			gtk_container_add (GTK_CONTAINER (data->organize_button), gtk_label_new (_("Organize")));
			gtk_widget_set_tooltip_text (data->organize_button, _("Automatically organize files by date"));
			g_object_add_weak_pointer (G_OBJECT (data->organize_button), (gpointer *)&data->organize_button);
			gtk_button_set_relief (GTK_BUTTON (data->organize_button), GTK_RELIEF_NONE);
			gtk_widget_show_all (data->organize_button);
			gtk_box_pack_start (GTK_BOX (gth_location_bar_get_action_area (GTH_LOCATION_BAR (gth_browser_get_location_bar (browser)))),
					    data->organize_button,
					    FALSE,
					    FALSE,
					    0);
			g_signal_connect (data->organize_button,
					  "clicked",
					  G_CALLBACK (organize_button_clicked_cb),
					  browser);
		}
	}
}
Example #11
0
/*
 * Create the individual color buttons
 *
 * Utility function
 */
static GtkWidget *
go_color_palette_button_new (GOColorPalette *pal, GtkGrid *grid,
			     GONamedColor const *color_name,
			     gint col, gint row)
{
	GtkWidget *button, *swatch, *box;
	GdkRGBA   gdk;

	swatch = gtk_drawing_area_new ();
	g_signal_connect (G_OBJECT (swatch), "draw", G_CALLBACK (draw_color_cb),
	                  GUINT_TO_POINTER (color_name->color));
	gtk_widget_override_background_color (swatch, GTK_STATE_FLAG_NORMAL,
	        go_color_to_gdk_rgba (color_name->color, &gdk));
	gtk_widget_set_size_request (swatch, COLOR_PREVIEW_WIDTH, COLOR_PREVIEW_HEIGHT);

	/* Wrap inside a vbox with a border so that we can see the focus indicator */
	box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	gtk_container_set_border_width (GTK_CONTAINER (box), 2);
	gtk_box_pack_start (GTK_BOX (box), GTK_WIDGET (swatch), TRUE, TRUE, 0);

	button = gtk_button_new ();
	gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
	gtk_container_add (GTK_CONTAINER (button), box);
	gtk_widget_set_tooltip_text (button, _(color_name->name));

	gtk_grid_attach (grid, button, col, row, 1, 1);

	g_object_connect (button,
		"signal::button_release_event", G_CALLBACK (cb_swatch_release_event), pal,
		"signal::key_press_event", G_CALLBACK (cb_swatch_key_press), pal,
		NULL);
	return swatch;
}
Example #12
0
void Notebook::GTKAddCloseButtonAndReorderable(int idx)
{
    MyNotebookPage *pg = (MyNotebookPage*) wxNotebook::GetNotebookPage(idx);
    wxWindow* page = GetPage((size_t)idx);
    // Place a close button
    if(HasCloseButton()) {
        GtkWidget *image;
        MyGtkPageInfo *pgInfo = new MyGtkPageInfo;
        pgInfo->m_button = gtk_button_new();
        pgInfo->m_box    = pg->m_box;
        pgInfo->m_book   = this;

        image  = gtk_image_new_from_stock (GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU);
        gtk_widget_set_size_request(image, 12, 12);
        gtk_button_set_image (GTK_BUTTON(pgInfo->m_button), image);
        gtk_widget_set_name  (pgInfo->m_button, "tab-close-button");
        gtk_button_set_relief(GTK_BUTTON(pgInfo->m_button), GTK_RELIEF_NONE);
        gtk_box_pack_end     (GTK_BOX(pg->m_box), pgInfo->m_button, FALSE, FALSE, 0);
        // wxGTK has already used gtk_box_pack_end for the tab's label, so atm the close button will be on the left
        // so re-order it to position 0, which in a GTK_PACK_END box means the far right
        gtk_box_reorder_child(GTK_BOX(pg->m_box), pgInfo->m_button, 0);
        gtk_box_set_spacing  (GTK_BOX(pg->m_box), 5);
#ifdef __WXGTK3__
        g_signal_connect (pgInfo->m_button, "clicked", G_CALLBACK (OnNotebookButtonClicked), pgInfo);
#else
        gtk_signal_connect (GTK_OBJECT (pgInfo->m_button), "clicked", GTK_SIGNAL_FUNC (OnNotebookButtonClicked), pgInfo);
#endif
        m_gtk_page_info[page] = pgInfo;
        GTKShowCloseButton(idx);
    }

    // Make this tab re-orderable
    gtk_notebook_set_tab_reorderable(GTK_NOTEBOOK(this->m_widget), page->m_widget, true);
    g_signal_connect(GTK_NOTEBOOK(this->m_widget), "page-reordered", G_CALLBACK(OnPageReordered), this);
}
Example #13
0
static GtkWidget *
peacock_file_client_create_tab_widget (PeacockFileClient *fileClient,
				       PeacockWindow *window)
{
	GtkWidget *retval;
	GtkWidget *close_button;
	GtkWidget *close_icon;
	GtkWidget *label;

	retval = gtk_hbox_new (FALSE, 0);

	label = gtk_label_new (fileClient->uri ? fileClient->uri : "Untitled");
	gtk_box_pack_start_defaults (GTK_BOX (retval), label);
	gtk_widget_show (label);

	/* We save a pointer so we can update it on Save As. */
	g_object_set_data (G_OBJECT (retval), VIEW_TAB_TEXT_TAG, label);

	close_button = gtk_button_new ();
	gtk_button_set_relief (GTK_BUTTON (close_button), GTK_RELIEF_NONE);
	gtk_box_pack_start_defaults (GTK_BOX (retval), close_button);
	g_signal_connect (G_OBJECT (close_button), "clicked", G_CALLBACK (peacock_file_client_tab_widget_close_clicked_cb), window);
	gtk_widget_show (close_button);

	close_icon = gtk_image_new_from_stock (GTK_STOCK_CLOSE,
					       GTK_ICON_SIZE_MENU);
	gtk_container_add (GTK_CONTAINER (close_button), close_icon);
	gtk_widget_show (close_icon);

	gtk_widget_show_all (retval);

	return retval;
}
Example #14
0
static void
gtk_button_set_property (GObject         *object,
                         guint            prop_id,
                         const GValue    *value,
                         GParamSpec      *pspec)
{
  GtkButton *button = GTK_BUTTON (object);

  switch (prop_id)
    {
    case PROP_LABEL:
      gtk_button_set_label (button, g_value_get_string (value));
      break;
    case PROP_RELIEF:
      gtk_button_set_relief (button, g_value_get_enum (value));
      break;
    case PROP_USE_UNDERLINE:
      gtk_button_set_use_underline (button, g_value_get_boolean (value));
      break;
    case PROP_ICON_NAME:
      gtk_button_set_icon_name (button, g_value_get_string (value));
      break;
    case PROP_ACTION_NAME:
      gtk_button_set_action_name (GTK_ACTIONABLE (button), g_value_get_string (value));
      break;
    case PROP_ACTION_TARGET:
      gtk_button_set_action_target_value (GTK_ACTIONABLE (button), g_value_get_variant (value));
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
    }
}
Example #15
0
/* Create a new tab. */
LXTab * lxterminal_tab_label_new(const gchar * str)
{
    /* Allocate LXTab structure. */
    LXTab * tab = g_slice_new0(LXTab);

    /* Create a horizontal box as the toplevel. */
    tab->main = gtk_hbox_new(FALSE, 4);

    /* Create the Close button. */
    tab->close_btn = gtk_button_new();
    gtk_button_set_relief(GTK_BUTTON(tab->close_btn), GTK_RELIEF_NONE);
    gtk_button_set_focus_on_click(GTK_BUTTON(tab->close_btn), FALSE);
    gtk_container_add(GTK_CONTAINER(tab->close_btn), gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU));

    /* Make the button as small as possible. */
    GtkRcStyle * rcstyle = gtk_rc_style_new();
    rcstyle->xthickness = rcstyle->ythickness = 0;
    gtk_widget_modify_style(tab->close_btn, rcstyle);
    gtk_rc_style_unref(rcstyle),

    /* Create the label. */
    tab->label = gtk_label_new(str);
    gtk_widget_set_size_request(GTK_WIDGET(tab->label), 100, -1);
    gtk_label_set_ellipsize(GTK_LABEL(tab->label), PANGO_ELLIPSIZE_END);
    gtk_misc_set_alignment(GTK_MISC(tab->label), 0.0, 0.5);
    gtk_misc_set_padding(GTK_MISC(tab->label), 0, 0);

    /* Pack everything, show the widget and return. */
    gtk_box_pack_start(GTK_BOX(tab->main), tab->label, TRUE, TRUE, 0);
    gtk_box_pack_start(GTK_BOX(tab->main), tab->close_btn, FALSE, FALSE, 0);
    gtk_widget_show_all(tab->main);
    return tab;
}
Example #16
0
static int
deskno_constructor(Plugin *p, char** fp)
{
    deskno *dc;
    GtkWidget *button;

    ENTER;
    dc = g_new0(deskno, 1);
    g_return_val_if_fail(dc != NULL, 0);
    p->priv = dc;

    dc->main = gtk_event_box_new();
    dc->tip  = gtk_tooltips_new();
    button = gtk_button_new();
    gtk_button_set_relief(GTK_BUTTON(button),GTK_RELIEF_NONE);
    g_signal_connect (G_OBJECT (button), "clicked", G_CALLBACK (clicked), (gpointer) dc);
    dc->namew = gtk_label_new("ww");
    gtk_container_add(GTK_CONTAINER(button), dc->namew);
    name_update(button, dc);
    g_signal_connect (G_OBJECT (fbev), "current_desktop", G_CALLBACK (name_update), (gpointer) dc);

    p->pwid = button;
    gtk_widget_show_all(p->pwid);

    RET(1);
}
Example #17
0
// helper to create a dropdown menu item
void wxToolBarTool::CreateDropDown()
{
    gtk_tool_item_set_homogeneous(m_item, false);
    GtkOrientation orient = GTK_ORIENTATION_HORIZONTAL;
    GtkArrowType arrowType = GTK_ARROW_DOWN;
    if (GetToolBar()->HasFlag(wxTB_LEFT | wxTB_RIGHT))
    {
        orient = GTK_ORIENTATION_VERTICAL;
        arrowType = GTK_ARROW_RIGHT;
    }
    GtkWidget* box = gtk_box_new(orient, 0);
    GtkWidget* arrow = gtk_arrow_new(arrowType, GTK_SHADOW_NONE);
    GtkWidget* tool_button = gtk_bin_get_child(GTK_BIN(m_item));
    g_object_ref(tool_button);
    gtk_container_remove(GTK_CONTAINER(m_item), tool_button);
    gtk_container_add(GTK_CONTAINER(box), tool_button);
    g_object_unref(tool_button);
    GtkWidget* arrow_button = gtk_toggle_button_new();
    gtk_button_set_relief(GTK_BUTTON(arrow_button),
        gtk_tool_item_get_relief_style(GTK_TOOL_ITEM(m_item)));
    gtk_container_add(GTK_CONTAINER(arrow_button), arrow);
    gtk_container_add(GTK_CONTAINER(box), arrow_button);
    gtk_widget_show_all(box);
    gtk_container_add(GTK_CONTAINER(m_item), box);

    g_signal_connect(arrow_button, "toggled", G_CALLBACK(arrow_toggled), this);
    g_signal_connect(arrow_button, "button_press_event",
        G_CALLBACK(arrow_button_press_event), this);
}
Example #18
0
bool wxBitmapToggleButton::Create(wxWindow *parent, wxWindowID id,
                            const wxBitmap &label, const wxPoint &pos,
                            const wxSize &size, long style,
                            const wxValidator& validator,
                            const wxString &name)
{
    if (!PreCreation(parent, pos, size) ||
       !CreateBase(parent, id, pos, size, style, validator, name ))
    {
        wxFAIL_MSG(wxT("wxBitmapToggleButton creation failed"));
        return false;
    }

    // Create the gtk widget.
    m_widget = gtk_toggle_button_new();
    g_object_ref(m_widget);

    if (style & wxNO_BORDER)
        gtk_button_set_relief( GTK_BUTTON(m_widget), GTK_RELIEF_NONE );

    m_bitmap = label;
    OnSetBitmap();

    g_signal_connect (m_widget, "clicked",
                      G_CALLBACK (gtk_togglebutton_clicked_callback),
                      this);

    m_parent->DoAddChild(this);

    PostCreation(size);

    return true;
}
static GtkWidget *
garu_headerbar_create_settings_button (GaruHeaderbar *self)
{
  GList           *list;
  GtkWidget       *button, *image;
  GaruApplication *app;
  GMenuModel      *menu_model;

  app = GARU_APPLICATION (g_application_get_default ());

  list = gtk_container_get_children (GTK_CONTAINER (self));
  list = g_list_last (list);
  button = gtk_menu_button_new ();
  gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
  image = gtk_image_new_from_icon_name ("emblem-system-symbolic",
                                        GTK_ICON_SIZE_SMALL_TOOLBAR);
  gtk_button_set_image (GTK_BUTTON (button), image);
  gtk_widget_show (button);
  gtk_box_pack_start (GTK_BOX (list->data), button, FALSE, FALSE, 0);

  /* create menu */
  menu_model = G_MENU_MODEL (garu_application_get_menu (app));
  gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (button), menu_model);
  g_print ("Removiendo\n");
  g_object_unref (menu_model);

  return button;
}
Example #20
0
static GtkWidget*
button_create(GtkWidget *widget, GtkSizeGroup *sg, const gchar *icon_name,
              const gchar *label, gint type)
{
    GtkWidget *button;

    if (register_icon(icon_name)) {
        GtkWidget *img = gtk_image_new_from_stock(icon_name, GTK_ICON_SIZE_MENU);
        button = gtk_button_new();
        gtk_container_add(GTK_CONTAINER(button), img);
    } else {
        button = gtk_button_new_with_label(label);
    }

    set_button_style(button, type);

    gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
    gtk_size_group_add_widget(sg, button);
    g_object_set_data(G_OBJECT(button), OBJECT_DATA_BUTTON_TYPE,
                      GINT_TO_POINTER(BUTTON_PROP));

    g_signal_connect(G_OBJECT(button), "button-press-event",
                     G_CALLBACK(button_pressed), widget);

    return button;
}
Example #21
0
/* create button with stock item
 *
 * in: label - label for button        (label=NULL  to disable label, label=-1 to disable button relief)
 *     stock - stock icon identifier
 */
GtkWidget*
gui_stock_label_button(gchar *label, const gchar *stock) {

	GtkWidget *button;
	GtkWidget *alignment;
	GtkWidget *hbox;
	GtkWidget *image;

	button = g_object_new (GTK_TYPE_BUTTON, "visible", TRUE, NULL);

        if (label== (gchar *)-1) {
                gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
        }

	alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
	hbox = gtk_hbox_new (FALSE, 2);
	gtk_container_add (GTK_CONTAINER (alignment), hbox);

	image = gtk_image_new_from_stock (stock, GTK_ICON_SIZE_BUTTON);

        if (image) {
		gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, TRUE, 0);
        }

        if (label != NULL && label != (gchar *)-1) {
		gtk_box_pack_start (GTK_BOX (hbox),
		g_object_new (GTK_TYPE_LABEL, "label", label, "use_underline", TRUE, NULL),
		FALSE, TRUE, 0);
        }

	gtk_widget_show_all (alignment);
	gtk_container_add (GTK_CONTAINER (button), alignment);

	return button;
}
void ZLGtkApplicationWindow::addToolbarItem(ZLApplication::Toolbar::ItemPtr item) {
	if (item->type() == ZLApplication::Toolbar::Item::BUTTON) {
		const ZLApplication::Toolbar::ButtonItem &buttonItem = (const ZLApplication::Toolbar::ButtonItem&)*item;
		static const std::string imagePrefix = ZLibrary::ApplicationImageDirectory() + ZLibrary::FileNameDelimiter;
		GtkWidget *image = gtk_image_new_from_file((imagePrefix + buttonItem.iconName() + ".png").c_str());
		GtkWidget *button = gtk_button_new();
		gtk_button_set_relief((GtkButton*)button, GTK_RELIEF_NONE);
		GTK_WIDGET_UNSET_FLAGS(button, GTK_CAN_FOCUS);
		gtk_container_add(GTK_CONTAINER(button), image);

		// toolbar with standard buttons is too wide for zaurus screen
		GdkImage *gdkImage = GTK_IMAGE(image)->data.image.image;
		int w = gdkImage->width;
		int h = gdkImage->height;
		gtk_widget_set_usize(button, w + 6, h + 6);

		gtk_container_add(GTK_CONTAINER(myToolbar), button);
		shared_ptr<ZLApplication::Action> action = application().action(buttonItem.actionId());
		if (!action.isNull()) {
			ZLGtkSignalUtil::connectSignal(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(actionSlot), &*action);
		}
		myButtons[item] = button;
		gtk_widget_show_all(GTK_WIDGET(button));
	}
}
Example #23
0
GtkWidget* new_button_with_icon(GtkIconTheme *theme,
                                const gchar *icon_name,
                                gboolean toolbar,
                                gboolean toggle,
                                const gchar *description)
{
        GtkWidget *button;
        GtkWidget *image;
        gint size;

        size = toolbar ? GTK_ICON_SIZE_SMALL_TOOLBAR : GTK_ICON_SIZE_DIALOG;
        image = gtk_image_new_from_icon_name(icon_name, size);
        /* Create the button */
        if (toggle)
                button = gtk_toggle_button_new();
        else
                button = gtk_button_new();
        gtk_widget_set_can_focus(button, FALSE);
        if (!toolbar)
                gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
        gtk_container_add(GTK_CONTAINER(button), image);

        /* Set a helpful tooltip for toolbar buttons */
        if (toolbar)
                gtk_widget_set_tooltip_text(button, description);
        return button;
}
Example #24
0
static void
gb_folder_tb_widget_rebuild_impl (GbTbWidget *w)
{
	GbFolderTbWidgetPrivate *p = GB_FOLDER_TB_WIDGET (w)->priv;
	GbFolder *folder = GB_FOLDER (gb_tb_widget_get_bookmark (w));

	g_return_if_fail (GB_IS_FOLDER (folder));

	if (!p->mainwid)
	{
		p->mainwid = gtk_toggle_button_new ();
		gtk_widget_show (p->mainwid);
		gtk_box_pack_start (GTK_BOX (w), p->mainwid, FALSE, FALSE, 0);

		g_signal_connect (p->mainwid, "button-press-event", 
				  G_CALLBACK (gb_folder_tb_widget_button_press_event_cb), w);
		g_signal_connect (p->mainwid, "toggled", 
				  G_CALLBACK (gb_folder_tb_widget_toggled_cb), w);
	}

	if (gtk_bin_get_child (GTK_BIN (p->mainwid)))
	{
		gtk_container_remove (GTK_CONTAINER (p->mainwid),
				      gtk_bin_get_child (GTK_BIN (p->mainwid)));
	}
	
	gb_widgets_fill_tb_item (GTK_CONTAINER (p->mainwid), GB_BOOKMARK (folder), NULL);

	gtk_button_set_relief (GTK_BUTTON (p->mainwid), GTK_RELIEF_NONE);
	GTK_WIDGET_SET_FLAGS (GTK_BUTTON (p->mainwid), GTK_CAN_FOCUS);

	gb_tb_widget_setup_context_menu (w, p->mainwid);
	gb_bookmark_dnd_drag_dest_set (GTK_BIN (p->mainwid)->child, GB_BOOKMARK (folder));
}
static void remmina_chain_button_init(RemminaChainButton* cb)
{
    GtkWidget* widget;
    GtkWidget* image;
    GdkPixbuf* pixbuf;

    pixbuf = gdk_pixbuf_new_from_xpm_data(line_up_xpm);
    image = gtk_image_new_from_pixbuf(pixbuf);
    g_object_unref(pixbuf);
    gtk_widget_show(image);
    gtk_grid_attach(GTK_GRID(cb), image, 0, 0, 1, 1);

    widget = gtk_button_new();
    gtk_widget_show(widget);
    gtk_button_set_relief(GTK_BUTTON(widget), GTK_RELIEF_NONE);
    gtk_grid_attach(GTK_GRID(cb), widget, 0, 1, 1, 1);
    g_signal_connect(G_OBJECT(widget), "clicked", G_CALLBACK(remmina_chain_button_on_clicked), cb);

    image = gtk_image_new();
    gtk_widget_show(image);
    gtk_container_add(GTK_CONTAINER(widget), image);
    cb->chain_image = image;

    pixbuf = gdk_pixbuf_new_from_xpm_data(line_down_xpm);
    image = gtk_image_new_from_pixbuf(pixbuf);
    g_object_unref(pixbuf);
    gtk_widget_show(image);
    gtk_grid_attach(GTK_GRID(cb), image, 0, 2, 1, 1);

    cb->chained = FALSE;
}
Example #26
0
static GtkWidget *newTabLabel(OovStringRef const tabText, GtkWidget *viewTopParent)
    {
    GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
    gtk_container_add(GTK_CONTAINER(box), gtk_label_new(tabText));
    GtkButton *button = GTK_BUTTON(gtk_button_new());
    gtk_button_set_relief(button, GTK_RELIEF_NORMAL);
    gtk_button_set_focus_on_click(button, false);
    gtk_button_set_image(button,
            gtk_image_new_from_icon_name("window-close", GTK_ICON_SIZE_SMALL_TOOLBAR)); //GTK_ICON_SIZE_MENU));

    char const * const data = "* {\n"
        "-GtkButton-default-border : 0px;\n"
        "-GtkButton-default-outside-border : 0px;\n"
        "-GtkButton-inner-border: 0px;\n"
        "-GtkWidget-focus-line-width : 0px;\n"
        "-GtkWidget-focus-padding : 0px;\n"
        "padding: 0px;\n"
        "}";
    GtkCssProvider *provider = gtk_css_provider_new();
    gtk_css_provider_load_from_data(provider, data, -1, NULL);
    GtkStyleContext *context = gtk_widget_get_style_context(GTK_WIDGET(button));
    gtk_style_context_add_provider(context, GTK_STYLE_PROVIDER(provider),
            GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
//    gtk_box_pack_start(box, button, False, False, 0);
    gtk_container_add(GTK_CONTAINER(box), GTK_WIDGET(button));

    g_signal_connect(button, "clicked", G_CALLBACK(onTabLabelCloseClicked), viewTopParent);
    gtk_widget_show_all(box);
    return box;

    }
Example #27
0
// helper to create a dropdown menu item
void wxToolBarTool::CreateDropDown()
{
    gtk_tool_item_set_homogeneous(m_item, false);
    GtkWidget* box;
    GtkWidget* arrow;
    if (GetToolBar()->HasFlag(wxTB_LEFT | wxTB_RIGHT))
    {
        box = gtk_vbox_new(false, 0);
        arrow = gtk_arrow_new(GTK_ARROW_RIGHT, GTK_SHADOW_NONE);
    }
    else
    {
        box = gtk_hbox_new(false, 0);
        arrow = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_NONE);
    }
    GtkWidget* tool_button = GTK_BIN(m_item)->child;
    gtk_widget_reparent(tool_button, box);
    GtkWidget* arrow_button = gtk_toggle_button_new();
    gtk_button_set_relief(GTK_BUTTON(arrow_button),
        gtk_tool_item_get_relief_style(GTK_TOOL_ITEM(m_item)));
    gtk_container_add(GTK_CONTAINER(arrow_button), arrow);
    gtk_container_add(GTK_CONTAINER(box), arrow_button);
    gtk_widget_show_all(box);
    gtk_container_add(GTK_CONTAINER(m_item), box);

    g_signal_connect(arrow_button, "toggled", G_CALLBACK(arrow_toggled), this);
    g_signal_connect(arrow_button, "button_press_event",
        G_CALLBACK(arrow_button_press_event), this);
}
Example #28
0
File: skin.c Project: XQF/xqf
GtkWidget *create_color_menu (void (*callback) (GtkWidget*, int)) {
	GtkWidget *menu;
	GtkWidget *menu_item;
	GtkWidget *button;
	int i;

	menu = gtk_menu_new ();

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

		/* ugly, ugly, ugly... */

		button = gtk_button_new_with_label (" ");
		gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_HALF);
		gtk_widget_set_sensitive (button, FALSE);
		gtk_widget_set_usize (button, 40, -1);
		gtk_widget_show (button);

		menu_item = gtk_menu_item_new ();
		gtk_container_add (GTK_CONTAINER (menu_item), button);
		gtk_menu_append (GTK_MENU (menu), menu_item);
		g_signal_connect (menu_item, "activate", G_CALLBACK (callback), GINT_TO_POINTER(i));
		gtk_widget_show (menu_item);

		set_bg_color (menu_item, i);
		set_bg_color (button, i);
	}

	return menu;
}
Example #29
0
static void
gtk_button_set_property (GObject         *object,
                         guint            prop_id,
                         const GValue    *value,
                         GParamSpec      *pspec)
{
  GtkButton *button;

  button = GTK_BUTTON (object);

  switch (prop_id)
    {
    case PROP_LABEL:
      gtk_button_set_label (button, g_value_get_string (value));
      break;
    case PROP_RELIEF:
      gtk_button_set_relief (button, g_value_get_enum (value));
      break;
    case PROP_USE_UNDERLINE:
      gtk_button_set_use_underline (button, g_value_get_boolean (value));
      break;
    case PROP_USE_STOCK:
      gtk_button_set_use_stock (button, g_value_get_boolean (value));
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
    }
}
static void add_button (MMConversation *mmconv)
{
	PurpleConversation *conv = mmconv->conv;
	
	GtkWidget *button, *image, *sep;
	gchar *file_path;

	button = gtk_toggle_button_new();
	gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);

	g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(music_button_toggled), mmconv);

	file_path = g_build_filename(DATADIR, "pixmaps", "purple", "buttons",
										"music.png", NULL);
	image = gtk_image_new_from_file(file_path);
	g_free(file_path);

	gtk_container_add((GtkContainer *)button, image);
	
	sep = gtk_vseparator_new();
	
	mmconv->seperator = sep;
	mmconv->button = button;
	
	gtk_widget_show(sep);
	gtk_widget_show(image);
	gtk_widget_show(button);
	
	gtk_box_pack_start(GTK_BOX(PIDGIN_CONVERSATION(conv)->toolbar), sep, FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX(PIDGIN_CONVERSATION(conv)->toolbar), button, FALSE, FALSE, 0);
}