コード例 #1
0
static GObject *
gdict_speller_constructor (GType                  type,
			   guint                  n_params,
			   GObjectConstructParam *params)
{
  GObject *object;
  GdictSpeller *speller;
  GdictSpellerPrivate *priv;
  GtkWidget *sw;
  GtkCellRenderer *renderer;
  GtkTreeViewColumn *column;
  GtkWidget *hbox;

  object = G_OBJECT_CLASS (gdict_speller_parent_class)->constructor (type,
  						                     n_params,
								     params);
  speller = GDICT_SPELLER (object);
  priv = speller->priv;

  sw = gtk_scrolled_window_new (NULL, NULL);
  gtk_widget_set_vexpand (sw, TRUE);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
  				  GTK_POLICY_AUTOMATIC,
  				  GTK_POLICY_AUTOMATIC);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
  				       GTK_SHADOW_IN);
  gtk_box_pack_start (GTK_BOX (speller), sw, TRUE, TRUE, 0);
  gtk_widget_show (sw);

  renderer = gtk_cell_renderer_text_new ();
  column = gtk_tree_view_column_new_with_attributes ("matches",
		  				     renderer,
						     "text", MATCH_COLUMN_WORD,
						     NULL);

  priv->treeview = gtk_tree_view_new ();
  gtk_tree_view_set_model (GTK_TREE_VIEW (priv->treeview),
		           GTK_TREE_MODEL (priv->store));
  gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (priv->treeview), FALSE);
  gtk_tree_view_append_column (GTK_TREE_VIEW (priv->treeview), column);
  g_signal_connect (priv->treeview, "row-activated",
		    G_CALLBACK (row_activated_cb), speller);
  gtk_container_add (GTK_CONTAINER (sw), priv->treeview);
  gtk_widget_show (priv->treeview);

  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);

  priv->clear_button = gtk_button_new ();
  gtk_button_set_image (GTK_BUTTON (priv->clear_button),
                        gtk_image_new_from_icon_name ("edit-clear",
                                                      GTK_ICON_SIZE_SMALL_TOOLBAR));
  g_signal_connect (priv->clear_button, "clicked",
		    G_CALLBACK (clear_button_clicked_cb),
		    speller);
  gtk_box_pack_start (GTK_BOX (hbox), priv->clear_button, FALSE, FALSE, 0);
  gtk_widget_show (priv->clear_button);
  gtk_widget_set_tooltip_text (priv->clear_button,
                               _("Clear the list of similar words"));

  gtk_box_pack_end (GTK_BOX (speller), hbox, FALSE, FALSE, 0);
  gtk_widget_show (hbox);

  return object;
}
コード例 #2
0
ファイル: FskGtkWindow.c プロジェクト: kouis3940/kinomajs
////////////// Main and Init /////////////////
static void FskGtkWindowLoop(void *refcon)
{
	FskWindow 		fskWindow = (FskWindow)refcon;
	FskGtkWindow	gtkWin = (FskGtkWindow)fskWindow->gtkWin;
	GtkWidget		*win;
	GdkPixbuf		*iconBuf;

	// Start GTK special initialization
	XInitThreads(); //fix a xcb issue happened when using multithread gtk, see http://stackoverflow.com/a/18690540/472927
	gtk_init(NULL, NULL);

	gtkWin->owner = fskWindow;
	gtkWin->window = win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_default_size(win, 750, 505);

	//	Set App Icon
	char *iconPath = FskStrDoCat(FskGetApplicationPath(), "fsk.png");
	iconBuf = gdk_pixbuf_new_from_file(iconPath, NULL);
	if(iconBuf != NULL) {
		gtk_window_set_icon(GTK_WINDOW(win), iconBuf);
		g_object_unref(G_OBJECT(iconBuf));
	}
	FskMemPtrDispose(iconPath);

	gtkWin->vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
	gtk_container_add(GTK_CONTAINER(win), gtkWin->vbox);
	gtk_widget_show(gtkWin->vbox);

	gtkWin->menubar = gtk_menu_bar_new();
	gtk_widget_show(gtkWin->menubar);

	gtkWin->da = gtk_drawing_area_new();

	gtk_widget_show(gtkWin->da);

	gtkWin->accelGroup = gtk_accel_group_new();
	gtk_window_add_accel_group(GTK_WINDOW(win), gtkWin->accelGroup);

	FskMutexNew(&gtkWin->bufMutex, "drawAreaBuffer");

	gtkWin->queue = g_async_queue_new();
	gtk_widget_add_events(GTK_WIDGET(win), GDK_EXPOSURE_MASK | GDK_KEY_PRESS_MASK);
	gtk_widget_add_events(GTK_WIDGET(gtkWin->da), GDK_ALL_EVENTS_MASK);

	g_signal_connect(win, "destroy", 			G_CALLBACK(app_quit), gtkWin);	
	g_signal_connect(win, "key-press-event", 	G_CALLBACK(on_key_press), gtkWin);
	g_signal_connect(win, "key-release-event", 	G_CALLBACK(on_key_release), gtkWin);
	g_signal_connect(win, "configure-event", 	G_CALLBACK(configure_event_win), gtkWin);

	// If want to resize draw-area, it will be the event receiver.
	g_signal_connect(gtkWin->da, "configure-event", 	G_CALLBACK(configure_event_cb), gtkWin);
	g_signal_connect(gtkWin->da, "draw", 				G_CALLBACK(draw_callback), gtkWin);
	g_signal_connect(gtkWin->da, "button-press-event", 	G_CALLBACK(on_button_press), gtkWin);
	g_signal_connect(gtkWin->da, "button-release-event",G_CALLBACK(on_button_release), gtkWin);
	g_signal_connect(gtkWin->da, "motion-notify-event", G_CALLBACK(motion_notify), gtkWin);

	gtk_box_pack_start(GTK_BOX(gtkWin->vbox), gtkWin->menubar, FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX(gtkWin->vbox), gtkWin->da, TRUE, TRUE, 0); // Set all to true!

	gdk_threads_add_idle(idle_func, gtkWin);
	//gtk_widget_show_all(win);

	FskThreadInitializationComplete(FskThreadGetCurrent());

	gtk_main();
}
コード例 #3
0
ファイル: files.c プロジェクト: Jeija/gtkterm
void send_raw_file(GtkAction *action, gpointer data)
{
	GtkWidget *file_select;

	file_select = gtk_file_chooser_dialog_new(_("Send RAW File"),
	              GTK_WINDOW(Fenetre),
	              GTK_FILE_CHOOSER_ACTION_OPEN,
	              GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
	              GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
	              NULL);

	if(fic_defaut != NULL)
		gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(file_select), fic_defaut);

	if(gtk_dialog_run(GTK_DIALOG(file_select)) == GTK_RESPONSE_ACCEPT)
	{
		gchar *fileName;
		gchar *msg;

		fileName = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(file_select));

		if(!g_file_test(fileName, G_FILE_TEST_IS_REGULAR))
		{
			msg = g_strdup_printf(_("Error opening file\n"));
			show_message(msg, MSG_ERR);
			g_free(msg);
			g_free(fileName);
			gtk_widget_destroy(file_select);
			return;
		}

		Fichier = open(fileName, O_RDONLY);
		if(Fichier != -1)
		{
			GtkWidget *Bouton_annuler, *Box;

			fic_defaut = g_strdup(fileName);
			msg = g_strdup_printf(_("%s : transfer in progress..."), fileName);

			gtk_statusbar_push(GTK_STATUSBAR(StatusBar), id, msg);
			car_written = 0;
			current_buffer_position = 0;
			bytes_read = 0;
			nb_car = lseek(Fichier, 0L, SEEK_END);
			lseek(Fichier, 0L, SEEK_SET);

			Window = gtk_dialog_new();
			gtk_window_set_title(GTK_WINDOW(Window), msg);
			g_free(msg);
			Box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10);
			gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(Window))), Box);
			ProgressBar = gtk_progress_bar_new();

			gtk_box_pack_start(GTK_BOX(Box), ProgressBar, FALSE, FALSE, 5);

			Bouton_annuler = gtk_button_new_with_label(_("Cancel"));
			g_signal_connect(GTK_WIDGET(Bouton_annuler), "clicked", G_CALLBACK(close_all), NULL);

			gtk_container_add(GTK_CONTAINER(gtk_dialog_get_action_area(GTK_DIALOG(Window))), Bouton_annuler);

			g_signal_connect(GTK_WIDGET(Window), "delete_event", G_CALLBACK(close_all), NULL);

			gtk_window_set_default_size(GTK_WINDOW(Window), 250, 100);
			gtk_window_set_modal(GTK_WINDOW(Window), TRUE);
			gtk_widget_show_all(Window);

			add_input();
		}
		else
		{
			msg = g_strdup_printf(_("Cannot read file %s: %s\n"), fileName, strerror(errno));
			show_message(msg, MSG_ERR);
			g_free(msg);
		}
		g_free(fileName);
	}
	gtk_widget_destroy(file_select);
}
コード例 #4
0
GtkWidget *
do_sidebar (GtkWidget *do_widget)
{
  static GtkWidget *window = NULL;
  GtkWidget *sidebar;
  GtkWidget *stack;
  GtkWidget *box;
  GtkWidget *widget;
  GtkWidget *header;
  const gchar* pages[] = {
    "Welcome to GTK+",
    "GtkStackSidebar Widget",
    "Automatic navigation",
    "Consistent appearance",
    "Scrolling",
    "Page 6",
    "Page 7",
    "Page 8",
    "Page 9",
    NULL
  };
  const gchar *c = NULL;
  guint i;

  if (!window)
    {
      window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
      gtk_window_set_resizable (GTK_WINDOW (window), TRUE);
      gtk_widget_set_size_request (window, 500, 350);

      header = gtk_header_bar_new ();
      gtk_header_bar_set_show_close_button (GTK_HEADER_BAR(header), TRUE);
      gtk_window_set_titlebar (GTK_WINDOW(window), header);
      gtk_window_set_title (GTK_WINDOW(window), "Stack Sidebar");

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

      box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
      sidebar = gtk_stack_sidebar_new ();
      gtk_box_pack_start (GTK_BOX (box), sidebar, FALSE, FALSE);

      stack = gtk_stack_new ();
      gtk_stack_set_transition_type (GTK_STACK (stack), GTK_STACK_TRANSITION_TYPE_SLIDE_UP_DOWN);
      gtk_stack_sidebar_set_stack (GTK_STACK_SIDEBAR (sidebar), GTK_STACK (stack));

      /* Separator between sidebar and stack */
      widget = gtk_separator_new (GTK_ORIENTATION_VERTICAL);
      gtk_box_pack_start (GTK_BOX(box), widget, FALSE, FALSE);

      gtk_box_pack_start (GTK_BOX (box), stack, TRUE, TRUE);

      for (i=0; (c = *(pages+i)) != NULL; i++ )
        {
          if (i == 0)
            {
              widget = gtk_image_new_from_icon_name ("help-about", GTK_ICON_SIZE_MENU);
              gtk_image_set_pixel_size (GTK_IMAGE (widget), 256);
            }
          else
            {
              widget = gtk_label_new (c);
            }
          gtk_stack_add_named (GTK_STACK (stack), widget, c);
          gtk_container_child_set (GTK_CONTAINER (stack), widget, "title", c, NULL);
        }

       gtk_container_add (GTK_CONTAINER (window), box);
    }

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

  return window;
}
コード例 #5
0
ファイル: properties.c プロジェクト: GNOME/gnome-robots
/**
 * show_properties_dialog
 *
 * Description:
 * displays the properties dialog
 **/
void
show_properties_dialog (void)
{
  GtkWidget *notebook;
  GtkWidget *cpage;
  GtkWidget *gpage;
  GtkWidget *kpage;
  GtkWidget *label;
  GtkWidget *hbox;
  GtkWidget *vbox;
  GtkWidget *typemenu;
  GtkWidget *pmapmenu;
  GtkWidget *chkbox;
  GtkWidget *safe_chkbox;
  GtkWidget *grid;
  GtkWidget *dbut;
  GtkWidget *w;
  GtkWidget *controls_list;

  if (propbox)
    return;

  propbox = gtk_dialog_new_with_buttons (_("Preferences"),
					 GTK_WINDOW (window),
					 GTK_DIALOG_USE_HEADER_BAR,
					 NULL);
  gtk_container_set_border_width (GTK_CONTAINER (propbox), 5);
  gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (propbox))), 2);
  /* Set up notebook and add it to hbox of the gtk_dialog */
  g_signal_connect (G_OBJECT (propbox), "destroy",
		    G_CALLBACK (gtk_widget_destroyed), &propbox);

  notebook = gtk_notebook_new ();
  gtk_container_set_border_width (GTK_CONTAINER (notebook), 5);
  gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (propbox))),
              notebook, TRUE, TRUE, 0);

  /* The configuration page */
  cpage = gtk_box_new (GTK_ORIENTATION_VERTICAL, 18);
  gtk_container_set_border_width (GTK_CONTAINER (cpage), 12);

  grid = gtk_grid_new ();
  gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
  gtk_grid_set_column_spacing (GTK_GRID (grid), 12);
  gtk_box_pack_start (GTK_BOX (cpage), grid, FALSE, FALSE, 0);

  label = gtk_label_new (_("Game Type"));
  gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 1);

  typemenu = gtk_combo_box_text_new ();
  fill_typemenu (typemenu);
  gtk_grid_attach (GTK_GRID (grid), typemenu, 1, 0, 1, 1);

  g_signal_connect (G_OBJECT (typemenu), "changed",
		    G_CALLBACK (type_selection), NULL);

  chkbox = gtk_check_button_new_with_mnemonic (_("_Use safe moves"));
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chkbox),
				properties.safe_moves);
  gtk_grid_attach (GTK_GRID (grid), chkbox, 0, 1, 2, 1);
  gtk_widget_set_tooltip_text (chkbox,
                               _("Prevent accidental moves that result in getting killed."));
  safe_chkbox = chkbox;

  chkbox = gtk_check_button_new_with_mnemonic (_("U_se super safe moves"));
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chkbox),
				properties.super_safe_moves);
  g_signal_connect (G_OBJECT (chkbox), "clicked",
		    (GCallback) super_safe_cb, NULL);
  gtk_grid_attach (GTK_GRID (grid), chkbox, 0, 2, 2, 1);
  gtk_widget_set_tooltip_text (chkbox,
                               _("Prevents all moves that result in getting killed."));
  gtk_widget_set_sensitive (chkbox, properties.safe_moves);

  g_signal_connect (G_OBJECT (safe_chkbox), "clicked",
		    (GCallback) safe_cb, (gpointer) chkbox);

  chkbox = gtk_check_button_new_with_mnemonic (_("_Enable sounds"));
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chkbox), properties.sound);
  g_signal_connect (G_OBJECT (chkbox), "clicked",
		    (GCallback) sound_cb, NULL);
  gtk_grid_attach (GTK_GRID (grid), chkbox, 0, 3, 2, 1);
  gtk_widget_set_tooltip_text (chkbox,
                               _("Play sounds for events like winning a level and dying."));

  label = gtk_label_new_with_mnemonic (_("Game"));
  gtk_notebook_append_page (GTK_NOTEBOOK (notebook), cpage, label);


  /* The graphics page */
  gpage = gtk_box_new (GTK_ORIENTATION_VERTICAL, 18);
  gtk_container_set_border_width (GTK_CONTAINER (gpage), 12);

  grid = gtk_grid_new ();
  gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
  gtk_grid_set_column_spacing (GTK_GRID (grid), 12);
  gtk_box_pack_start (GTK_BOX (gpage), grid, FALSE, FALSE, 0);

  label = gtk_label_new_with_mnemonic (_("_Image theme:"));
  gtk_widget_set_hexpand (label, TRUE);
  gtk_widget_set_halign (label, GTK_ALIGN_START);
  gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 1);

  pmapmenu = make_theme_menu ();
  g_signal_connect (G_OBJECT (pmapmenu), "changed",
		    G_CALLBACK (pmap_selection), NULL);
  gtk_label_set_mnemonic_widget (GTK_LABEL (label), pmapmenu);

  gtk_grid_attach (GTK_GRID (grid), pmapmenu, 1, 0, 1, 1);

  label = gtk_label_new_with_mnemonic (_("_Background color:"));
  gtk_widget_set_halign (label, GTK_ALIGN_START);
  gtk_grid_attach (GTK_GRID (grid), label, 0, 1, 1, 1);

  w = gtk_color_button_new ();
  gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (w), &properties.bgcolour);
  g_signal_connect (G_OBJECT (w), "color_set",
		    G_CALLBACK (bg_color_callback), NULL);
  gtk_label_set_mnemonic_widget (GTK_LABEL (label), w);

  gtk_grid_attach (GTK_GRID (grid), w, 1, 1, 1, 1);

  label = gtk_label_new_with_mnemonic (_("Appearance"));
  gtk_notebook_append_page (GTK_NOTEBOOK (notebook), gpage, label);

  /* The keyboard page */
  kpage = gtk_box_new (GTK_ORIENTATION_VERTICAL, 18);
  gtk_container_set_border_width (GTK_CONTAINER (kpage), 12);

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
  gtk_box_pack_start (GTK_BOX (kpage), vbox, TRUE, TRUE, 0);

  controls_list = games_controls_list_new (settings);
  games_controls_list_add_controls (GAMES_CONTROLS_LIST (controls_list),
				    "key00", _("Key to move NW"), g_settings_get_default_value (settings, "key00"),
				    "key01", _("Key to move N"), g_settings_get_default_value (settings, "key01"),
				    "key02", _("Key to move NE"), g_settings_get_default_value (settings, "key02"),
				    "key03", _("Key to move W"), g_settings_get_default_value (settings, "key03"),
				    "key04", _("Key to hold"), g_settings_get_default_value (settings, "key04"),
				    "key05", _("Key to move E"), g_settings_get_default_value (settings, "key05"),
				    "key06", _("Key to move SW"), g_settings_get_default_value (settings, "key06"),
				    "key07", _("Key to move S"), g_settings_get_default_value (settings, "key07"),
				    "key08", _("Key to move SE"), g_settings_get_default_value (settings, "key08"),
                                    NULL);

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

  hbox = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
  gtk_button_box_set_layout (GTK_BUTTON_BOX (hbox), GTK_BUTTONBOX_START);
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);

  dbut = gtk_button_new_with_mnemonic (_("_Restore Defaults"));
  g_signal_connect (G_OBJECT (dbut), "clicked",
		    G_CALLBACK (defkey_cb), NULL);
  gtk_box_pack_start (GTK_BOX (hbox), dbut, FALSE, FALSE, 0);

  label = gtk_label_new_with_mnemonic (_("Keyboard"));
  gtk_notebook_append_page (GTK_NOTEBOOK (notebook), kpage, label);


  g_signal_connect (G_OBJECT (propbox), "delete_event",
		    G_CALLBACK (delete_cb), NULL);
  g_signal_connect (G_OBJECT (propbox), "response",
		    G_CALLBACK (apply_cb), NULL);

  gtk_widget_show_all (propbox);
}
コード例 #6
0
static void
add_device_secondary (CcPowerPanel *panel,
                      GVariant *device,
                      guint *secondary_devices_cnt)
{
  CcPowerPanelPrivate *priv = panel->priv;
  const gchar *icon_name = NULL;
  gdouble percentage;
  guint64 time;
  UpDeviceKind kind;
  UpDeviceState state;
  GtkWidget *vbox;
  GtkWidget *hbox;
  GtkWidget *widget;
  GString *status;
  GString *description;
  gboolean show_caution = FALSE;

  g_variant_get (device,
                 "(susdut)",
                 NULL,
                 &kind,
                 NULL,
                 &percentage,
                 &state,
                 &time);

  switch (kind)
    {
      case UP_DEVICE_KIND_UPS:
        icon_name = "uninterruptible-power-supply";
        show_caution = TRUE;
        break;
      case UP_DEVICE_KIND_MOUSE:
        icon_name = "input-mouse";
        break;
      case UP_DEVICE_KIND_KEYBOARD:
        icon_name = "input-keyboard";
        break;
      case UP_DEVICE_KIND_TABLET:
        icon_name = "input-tablet";
        break;
      case UP_DEVICE_KIND_PDA:
        icon_name = "pda";
        break;
      case UP_DEVICE_KIND_PHONE:
        icon_name = "phone";
        break;
      case UP_DEVICE_KIND_MEDIA_PLAYER:
        icon_name = "multimedia-player";
        break;
      case UP_DEVICE_KIND_COMPUTER:
        icon_name = "computer";
        show_caution = TRUE;
        break;
      default:
        icon_name = "battery";
        break;
    }

  switch (kind)
    {
      case UP_DEVICE_KIND_MOUSE:
        /* TRANSLATORS: secondary battery */
        description = g_string_new (_("Wireless mouse"));
        break;
      case UP_DEVICE_KIND_KEYBOARD:
        /* TRANSLATORS: secondary battery */
        description = g_string_new (_("Wireless keyboard"));
        break;
      case UP_DEVICE_KIND_UPS:
        /* TRANSLATORS: secondary battery */
        description = g_string_new (_("Uninterruptible power supply"));
        break;
      case UP_DEVICE_KIND_PDA:
        /* TRANSLATORS: secondary battery */
        description = g_string_new (_("Personal digital assistant"));
        break;
      case UP_DEVICE_KIND_PHONE:
        /* TRANSLATORS: secondary battery */
        description = g_string_new (_("Cellphone"));
        break;
      case UP_DEVICE_KIND_MEDIA_PLAYER:
        /* TRANSLATORS: secondary battery */
        description = g_string_new (_("Media player"));
        break;
      case UP_DEVICE_KIND_TABLET:
        /* TRANSLATORS: secondary battery */
        description = g_string_new (_("Tablet"));
        break;
      case UP_DEVICE_KIND_COMPUTER:
        /* TRANSLATORS: secondary battery */
        description = g_string_new (_("Computer"));
        break;
      default:
        /* TRANSLATORS: secondary battery, misc */
        description = g_string_new (_("Battery"));
        break;
    }
  g_string_prepend (description, "<b>");
  g_string_append (description, "</b>");

  switch (state)
    {
      case UP_DEVICE_STATE_CHARGING:
      case UP_DEVICE_STATE_PENDING_CHARGE:
        /* TRANSLATORS: secondary battery */
        status = g_string_new(C_("Battery power", "Charging"));
        break;
      case UP_DEVICE_STATE_DISCHARGING:
      case UP_DEVICE_STATE_PENDING_DISCHARGE:
        if (percentage < 10 && show_caution)
          {
            /* TRANSLATORS: secondary battery */
            status = g_string_new (C_("Battery power", "Caution"));
          }
        else if (percentage < 30)
          {
            /* TRANSLATORS: secondary battery */
            status = g_string_new (C_("Battery power", "Low"));
          }
        else
          {
            /* TRANSLATORS: secondary battery */
            status = g_string_new (C_("Battery power", "Good"));
          }
        break;
      case UP_DEVICE_STATE_FULLY_CHARGED:
        /* TRANSLATORS: primary battery */
        status = g_string_new(C_("Battery power", "Charging - fully charged"));
        break;
      case UP_DEVICE_STATE_EMPTY:
        /* TRANSLATORS: primary battery */
        status = g_string_new(C_("Battery power", "Empty"));
        break;
      default:
        status = g_string_new (up_device_state_to_string (state));
        break;
    }
  g_string_prepend (status, "<small>");
  g_string_append (status, "</small>");

  /* create the new widget */
  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
  gtk_widget_set_hexpand (hbox, TRUE);
  widget = gtk_image_new ();
  gtk_misc_set_alignment (GTK_MISC (widget), 0.5f, 0.0f);
  gtk_image_set_from_icon_name (GTK_IMAGE (widget), icon_name, GTK_ICON_SIZE_DND);
  gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
  widget = gtk_label_new ("");
  gtk_misc_set_alignment (GTK_MISC (widget), 0.0f, 0.5f);
  gtk_label_set_markup (GTK_LABEL (widget), description->str);
  gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
  widget = gtk_label_new ("");
  gtk_misc_set_alignment (GTK_MISC (widget), 0.0f, 0.5f);
  gtk_label_set_markup (GTK_LABEL (widget), status->str);
  gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
  widget = gtk_progress_bar_new ();
  gtk_widget_set_margin_right (widget, 32);
  gtk_widget_set_margin_top (widget, 3);
  gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (widget), percentage / 100.0f);
  gtk_box_pack_start (GTK_BOX (vbox), widget, TRUE, TRUE, 0);
  gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);

  /* add to the grid */
  widget = WID ("grid_secondary");

  /* two devices wide */
  gtk_grid_attach (GTK_GRID (widget), hbox,
                   *secondary_devices_cnt % 2,
                   (*secondary_devices_cnt / 2) - 1,
                   1, 1);
  (*secondary_devices_cnt)++;

  /* show panel */
  widget = WID ("box_secondary");
  gtk_widget_show_all (widget);

  g_string_free (description, TRUE);
  g_string_free (status, TRUE);
}
コード例 #7
0
GtkWidget *
gimp_blend_options_gui (GimpToolOptions *tool_options)
{
  GObject   *config = G_OBJECT (tool_options);
  GtkWidget *vbox   = gimp_paint_options_gui (tool_options);
  GtkWidget *vbox2;
  GtkWidget *frame;
  GtkWidget *scale;
  GtkWidget *combo;
  GtkWidget *button;

  /*  the gradient  */
  button = gimp_prop_gradient_box_new (NULL, GIMP_CONTEXT (tool_options),
                                       _("Gradient"), 2,
                                       "gradient-view-type",
                                       "gradient-view-size",
                                       "gradient-reverse",
                                       "gimp-gradient-editor");
  gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
  gtk_widget_show (button);

  /*  the gradient type menu  */
  combo = gimp_prop_enum_combo_box_new (config, "gradient-type", 0, 0);
  gimp_int_combo_box_set_label (GIMP_INT_COMBO_BOX (combo), _("Shape"));
  g_object_set (combo, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
  gimp_enum_combo_box_set_stock_prefix (GIMP_ENUM_COMBO_BOX (combo),
                                        "gimp-gradient");
  gtk_box_pack_start (GTK_BOX (vbox), combo, FALSE, FALSE, 0);
  gtk_widget_show (combo);

  /*  the repeat option  */
  combo = gimp_prop_enum_combo_box_new (config, "gradient-repeat", 0, 0);
  gimp_int_combo_box_set_label (GIMP_INT_COMBO_BOX (combo), _("Repeat"));
  g_object_set (combo, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
  gtk_box_pack_start (GTK_BOX (vbox), combo, FALSE, FALSE, 0);
  gtk_widget_show (combo);

  g_signal_connect (config, "notify::gradient-type",
                    G_CALLBACK (blend_options_gradient_type_notify),
                    combo);

  /*  the offset scale  */
  scale = gimp_prop_spin_scale_new (config, "offset",
                                    _("Offset"),
                                    1.0, 10.0, 1);
  gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
  gtk_widget_show (scale);

  /*  the dither toggle  */
  button = gimp_prop_check_button_new (config, "dither",
                                       _("Dithering"));
  gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
  gtk_widget_show (button);

  /*  supersampling options  */
  vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
  frame = gimp_prop_expanding_frame_new (config, "supersample",
                                         _("Adaptive supersampling"),
                                         vbox2, NULL);
  gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
  gtk_widget_show (frame);

  /*  max depth scale  */
  scale = gimp_prop_spin_scale_new (config, "supersample-depth",
                                    _("Max depth"),
                                    1.0, 1.0, 0);
  gtk_box_pack_start (GTK_BOX (vbox2), scale, FALSE, FALSE, 0);
  gtk_widget_show (scale);

  /*  threshold scale  */
  scale = gimp_prop_spin_scale_new (config, "supersample-threshold",
                                    _("Threshold"),
                                    0.01, 0.1, 2);
  gtk_box_pack_start (GTK_BOX (vbox2), scale, FALSE, FALSE, 0);
  gtk_widget_show (scale);

  return vbox;
}
コード例 #8
0
static void
bluetooth_chooser_init(BluetoothChooser *self)
{
	BluetoothChooserPrivate *priv = BLUETOOTH_CHOOSER_GET_PRIVATE(self);

	GtkWidget *vbox;
	GtkWidget *hbox;

	gtk_widget_push_composite_child ();

	g_object_set (G_OBJECT (self), "orientation", GTK_ORIENTATION_VERTICAL, NULL);

	priv->client = bluetooth_client_new ();

	/* Setup the widget itself */
	gtk_box_set_spacing (GTK_BOX(self), 18);
	gtk_container_set_border_width (GTK_CONTAINER(self), 0);

	vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
	gtk_widget_show (vbox);
	gtk_box_pack_start (GTK_BOX (self), vbox, TRUE, TRUE, 0);

	/* The treeview label */
	priv->search_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 24);
	gtk_widget_set_name (priv->search_hbox, "search_hbox");
	if (priv->show_searching)
		gtk_widget_show (priv->search_hbox);
	gtk_box_pack_end (GTK_BOX (vbox), priv->search_hbox, FALSE, TRUE, 0);
	gtk_widget_set_no_show_all (priv->search_hbox, TRUE);

	/* Setup the adapter disco mode callback for the search button */
	priv->adapter_model = bluetooth_client_get_adapter_model (priv->client);
	g_signal_connect (priv->adapter_model, "row-changed",
			  G_CALLBACK (adapter_model_row_changed), self);

	/* The searching label */
	hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
	gtk_widget_set_name (hbox, "searching label hbox");
	priv->spinner = gtk_spinner_new ();
	gtk_container_add (GTK_CONTAINER (hbox), priv->spinner);
	gtk_widget_show (priv->spinner);
	priv->search_label = gtk_label_new (_("Searching for devices…"));
	gtk_container_add (GTK_CONTAINER (hbox), priv->search_label);
	gtk_widget_show (priv->search_label);
	gtk_widget_show (hbox);

	if (priv->show_searching) {
		gboolean discovering;

		g_object_get (G_OBJECT (priv->client), "default-adapter-discovering", &discovering, NULL);
		set_search_label (self, discovering);
	}

	gtk_box_pack_start (GTK_BOX (priv->search_hbox), hbox, FALSE, TRUE, 0);

	/* The treeview */
	priv->scrolled_window = create_treeview (self);
	gtk_widget_show_all (priv->scrolled_window);
	gtk_box_pack_start (GTK_BOX (vbox), priv->scrolled_window, TRUE, TRUE, 0);
	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
	gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (priv->scrolled_window), GTK_SHADOW_IN);

	/* The filters */
	priv->device_type_filter_model = GTK_TREE_MODEL (gtk_list_store_new (DEVICE_TYPE_FILTER_NUM_COLS,
						         G_TYPE_STRING, G_TYPE_INT));
	priv->filters_vbox = bluetooth_filter_widget_new ();
	gtk_widget_show (priv->filters_vbox);
	gtk_box_pack_start (GTK_BOX (self), priv->filters_vbox, FALSE, TRUE, 0);
	gtk_widget_set_no_show_all (priv->filters_vbox, TRUE);

	/* if filters are not visible hide the vbox */
	if (!priv->show_device_type && !priv->show_device_category)
		gtk_widget_hide (priv->filters_vbox);

	priv->default_adapter_changed_id = g_signal_connect (priv->client, "notify::default-adapter",
							     G_CALLBACK (default_adapter_changed), self);

	g_signal_connect(self, "notify::device-type-filter",
			 G_CALLBACK(filter_type_changed_cb), NULL);
	g_signal_connect(self, "notify::device-category-filter",
			 G_CALLBACK(filter_category_changed_cb), NULL);

	gtk_widget_pop_composite_child ();
}
コード例 #9
0
ファイル: progress.c プロジェクト: DeforaOS/Accessories
static int _progress(Prefs * prefs, char * argv[])
{
	Progress p;
	struct stat st;
	GtkWidget * vbox;
	GtkWidget * hbox;
	GtkSizeGroup * left;
	GtkSizeGroup * right;
	GtkWidget * widget;
	PangoFontDescription * bold;
	char const * q;
	unsigned long id;
  
	memset(&p, 0, sizeof(p));
	p.prefs = prefs;
	if(prefs->bufsiz == 0)
		errno = EINVAL;
	if(prefs->bufsiz == 0 || (p.buf = malloc(prefs->bufsiz)) == NULL)
		return _progress_error(&p, "malloc", 1);
	p.bufsiz = prefs->bufsiz;
	if(pipe(p.fds) != 0)
		return _progress_error(&p, "pipe", 1);
	if((p.pid = fork()) == -1)
	{
		close(p.fds[0]);
		close(p.fds[1]);
		return _progress_error(&p, "fork", 1);
	}
	if(p.pid != 0)
		return _progress_exec(&p, argv);
	close(p.fds[0]);
	if(gettimeofday(&p.tv, NULL) != 0)
		return _progress_error(&p, "gettimeofday", 1);
	if(prefs->filename == NULL)
		prefs->filename = _("Standard input");
	else if((p.fd = open(prefs->filename, O_RDONLY)) < 0)
		return _progress_error(&p, prefs->filename, 1);
	else if(fstat(p.fd, &st) == 0 && S_ISREG(st.st_mode))
		prefs->length = st.st_size;
	p.in_channel = g_io_channel_unix_new(p.fd);
	g_io_channel_set_encoding(p.in_channel, NULL, NULL);
	p.in_id = 0;
	g_idle_add(_progress_idle_in, &p);
	p.out_channel = g_io_channel_unix_new(p.fds[1]);
	g_io_channel_set_encoding(p.out_channel, NULL, NULL);
	p.out_id = 0;
	/* graphical interface */
	if((prefs->flags & PREFS_x) == 0)
	{
		p.window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
#if GTK_CHECK_VERSION(3, 0, 0) && !GTK_CHECK_VERSION(3, 14, 0)
		gtk_window_set_has_resize_grip(GTK_WINDOW(p.window), FALSE);
#endif
		gtk_window_set_title(GTK_WINDOW(p.window), prefs->title != NULL
				? prefs->title : _("Progress"));
		g_signal_connect_swapped(p.window, "delete-event", G_CALLBACK(
					_progress_closex), p.window);
	}
	else
	{
		p.window = gtk_plug_new(0);
		g_signal_connect_swapped(p.window, "embedded", G_CALLBACK(
					_progress_embedded), &p);
	}
#if GTK_CHECK_VERSION(3, 0, 0)
	vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
	hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
#else
	vbox = gtk_vbox_new(FALSE, 0);
	hbox = gtk_hbox_new(FALSE, 0);
#endif
	left = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
	right = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
	/* file */
	widget = gtk_label_new(_("File: "));
	bold = pango_font_description_new();
	pango_font_description_set_weight(bold, PANGO_WEIGHT_BOLD);
#if GTK_CHECK_VERSION(3, 0, 0)
	gtk_widget_override_font(widget, bold);
	g_object_set(widget, "halign", GTK_ALIGN_START, NULL);
#else
	gtk_widget_modify_font(widget, bold);
	gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5);
#endif
	gtk_size_group_add_widget(left, widget);
	gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, TRUE, 0);
	if((q = g_filename_to_utf8(prefs->filename, -1, NULL, NULL, NULL))
			== NULL)
		q = prefs->filename;
	widget = gtk_label_new(q);
	gtk_label_set_ellipsize(GTK_LABEL(widget), PANGO_ELLIPSIZE_MIDDLE);
#if GTK_CHECK_VERSION(3, 0, 0)
	g_object_set(widget, "halign", GTK_ALIGN_START, NULL);
#else
	gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5);
#endif
	gtk_size_group_add_widget(right, widget);
	gtk_box_pack_start(GTK_BOX(hbox), widget, TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
	/* done */
#if GTK_CHECK_VERSION(3, 0, 0)
	hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
#else
	hbox = gtk_hbox_new(FALSE, 0);
#endif
	widget = gtk_label_new(_("Done: "));
#if GTK_CHECK_VERSION(3, 0, 0)
	gtk_widget_override_font(widget, bold);
	g_object_set(widget, "halign", GTK_ALIGN_START, NULL);
#else
	gtk_widget_modify_font(widget, bold);
	gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5);
#endif
	gtk_size_group_add_widget(left, widget);
	gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, TRUE, 0);
	p.done = gtk_label_new(_("0.0 kB"));
#if GTK_CHECK_VERSION(3, 0, 0)
	g_object_set(p.done, "halign", GTK_ALIGN_START, NULL);
#else
	gtk_misc_set_alignment(GTK_MISC(p.done), 0.0, 0.5);
#endif
	gtk_size_group_add_widget(right, p.done);
	gtk_box_pack_start(GTK_BOX(hbox), p.done, TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 4);
	/* remaining */
#if GTK_CHECK_VERSION(3, 0, 0)
	hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
#else
	hbox = gtk_hbox_new(FALSE, 0);
#endif
	widget = gtk_label_new(_("Remaining: "));
#if GTK_CHECK_VERSION(3, 0, 0)
	gtk_widget_override_font(widget, bold);
	g_object_set(widget, "halign", GTK_ALIGN_START, NULL);
#else
	gtk_widget_modify_font(widget, bold);
	gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5);
#endif
	gtk_size_group_add_widget(left, widget);
	gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, TRUE, 0);
	p.remaining = gtk_label_new("");
	g_timeout_add(250, _progress_timeout, &p);
#if GTK_CHECK_VERSION(3, 0, 0)
	g_object_set(p.remaining, "halign", GTK_ALIGN_START, NULL);
#else
	gtk_misc_set_alignment(GTK_MISC(p.remaining), 0.0, 0.5);
#endif
	gtk_size_group_add_widget(right, p.remaining);
	gtk_box_pack_start(GTK_BOX(hbox), p.remaining, TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 4);
	/* progress */
	p.progress = gtk_progress_bar_new();
	p.pulse = 0;
	if(prefs->prefix != NULL)
	{
#if GTK_CHECK_VERSION(3, 0, 0)
		hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
#else
		hbox = gtk_hbox_new(FALSE, 0);
#endif
		widget = gtk_label_new(prefs->prefix);
#if GTK_CHECK_VERSION(3, 0, 0)
		g_object_set(widget, "halign", GTK_ALIGN_START, NULL);
#else
		gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5);
#endif
		gtk_size_group_add_widget(left, widget);
		gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, TRUE, 0);
		gtk_size_group_add_widget(right, p.progress);
		gtk_box_pack_start(GTK_BOX(hbox), p.progress, TRUE, TRUE, 0);
		gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 4);
	}
	else
		gtk_box_pack_start(GTK_BOX(vbox), p.progress, TRUE, TRUE, 4);
	/* cancel */
#if GTK_CHECK_VERSION(3, 0, 0)
	hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
#else
	hbox = gtk_hbox_new(FALSE, 0);
#endif
#if GTK_CHECK_VERSION(3, 10, 0)
	widget = gtk_button_new_with_label(_("Cancel"));
	gtk_button_set_image(GTK_BUTTON(widget),
			gtk_image_new_from_icon_name(GTK_STOCK_CANCEL,
				GTK_ICON_SIZE_BUTTON));
#else
	widget = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
#endif
	g_signal_connect(G_OBJECT(widget), "clicked", G_CALLBACK(
				_progress_cancel), NULL);
	gtk_box_pack_end(GTK_BOX(hbox), widget, FALSE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
	gtk_container_add(GTK_CONTAINER(p.window), vbox);
	gtk_container_set_border_width(GTK_CONTAINER(p.window), 4);
	gtk_widget_show_all(vbox);
	if((prefs->flags & PREFS_x) == 0)
		/* show the window */
		gtk_widget_show(p.window);
	else
	{
		/* print the window ID and force a flush */
		id = gtk_plug_get_id(GTK_PLUG(p.window));
		printf("%lu\n", id);
		fclose(stdout);
	}
	gtk_main();
	close(p.fd);
	close(p.fds[1]);
	return p.ret;
}
コード例 #10
0
ファイル: testbuttons.c プロジェクト: BoozzyAmdJin/gtk-
int main (int argc, char *argv[])
{
	GtkWidget *window, *box, *button, *hbox;
        gchar *text;
	gboolean use_underline, use_stock;
	GtkWidget *image, *label;

	gtk_init (&argc, &argv);

	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

	box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);

	gtk_container_add (GTK_CONTAINER (window), box);

	hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
	gtk_container_add (GTK_CONTAINER (box), hbox);
	button = gtk_button_new_from_stock (GTK_STOCK_SAVE);
	gtk_container_add (GTK_CONTAINER (hbox), button);

	g_object_get (button,
                      "label", &text,
                      "use-stock", &use_stock,
                      "use-underline", &use_underline,
		      "image", &image,
                      NULL);
	text = g_strdup_printf ("label: \"%s\" image: %p use-stock: %s use-underline: %s\n", text, image, use_stock ? "TRUE" : "FALSE", use_underline ? "TRUE" : "FALSE");
	label = gtk_label_new (text);
	g_free (text);
	gtk_container_add (GTK_CONTAINER (hbox), label);

	hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
	gtk_container_add (GTK_CONTAINER (box), hbox);
	button = g_object_new (GTK_TYPE_BUTTON,
                               "label", "document-save",
			       "use-stock", TRUE,
			       NULL);
	gtk_container_add (GTK_CONTAINER (hbox), button);

	g_object_get (button,
                      "label", &text,
                      "use-stock", &use_stock,
                      "use-underline", &use_underline,
		      "image", &image,
                      NULL);
	text = g_strdup_printf ("label: \"%s\" image: %p use-stock: %s use-underline: %s\n", text, image, use_stock ? "TRUE" : "FALSE", use_underline ? "TRUE" : "FALSE");
	label = gtk_label_new (text);
	g_free (text);
	gtk_container_add (GTK_CONTAINER (hbox), label);

	hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
	gtk_container_add (GTK_CONTAINER (box), hbox);
	button = gtk_button_new_with_label ("_Save");
	gtk_container_add (GTK_CONTAINER (hbox), button);

	g_object_get (button,
                      "label", &text,
                      "use-stock", &use_stock,
                      "use-underline", &use_underline,
		      "image", &image,
                      NULL);
	text = g_strdup_printf ("label: \"%s\" image: %p use-stock: %s use-underline: %s\n", text, image, use_stock ? "TRUE" : "FALSE", use_underline ? "TRUE" : "FALSE");
	label = gtk_label_new (text);
	g_free (text);
	gtk_container_add (GTK_CONTAINER (hbox), label);

	hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
	gtk_container_add (GTK_CONTAINER (box), hbox);
	button = gtk_button_new_with_mnemonic ("_Save");
	gtk_container_add (GTK_CONTAINER (hbox), button);

	g_object_get (button,
                      "label", &text,
                      "use-stock", &use_stock,
                      "use-underline", &use_underline,
		      "image", &image,
                      NULL);
	text = g_strdup_printf ("label: \"%s\" image: %p use-stock: %s use-underline: %s\n", text, image, use_stock ? "TRUE" : "FALSE", use_underline ? "TRUE" : "FALSE");
	label = gtk_label_new (text);
	g_free (text);
	gtk_container_add (GTK_CONTAINER (hbox), label);

	hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
	gtk_container_add (GTK_CONTAINER (box), hbox);
	button = gtk_button_new_with_label ("_Save");
	gtk_button_set_image (GTK_BUTTON (button), gtk_image_new_from_stock (GTK_STOCK_ABOUT, GTK_ICON_SIZE_BUTTON));
	gtk_container_add (GTK_CONTAINER (hbox), button);

	g_object_get (button,
                      "label", &text,
                      "use-stock", &use_stock,
                      "use-underline", &use_underline,
		      "image", &image,
                      NULL);
	text = g_strdup_printf ("label: \"%s\" image: %p use-stock: %s use-underline: %s\n", text, image, use_stock ? "TRUE" : "FALSE", use_underline ? "TRUE" : "FALSE");
	label = gtk_label_new (text);
	g_free (text);
	gtk_container_add (GTK_CONTAINER (hbox), label);

	hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
	gtk_container_add (GTK_CONTAINER (box), hbox);
	button = gtk_button_new_with_mnemonic ("_Save");
	gtk_button_set_image (GTK_BUTTON (button), gtk_image_new_from_stock (GTK_STOCK_ABOUT, GTK_ICON_SIZE_BUTTON));
	gtk_container_add (GTK_CONTAINER (hbox), button);
	g_object_get (button,
                      "label", &text,
                      "use-stock", &use_stock,
                      "use-underline", &use_underline,
		      "image", &image,
                      NULL);
	text = g_strdup_printf ("label: \"%s\" image: %p use-stock: %s use-underline: %s\n", text, image, use_stock ? "TRUE" : "FALSE", use_underline ? "TRUE" : "FALSE");
	label = gtk_label_new (text);
	g_free (text);
	gtk_container_add (GTK_CONTAINER (hbox), label);

	gtk_widget_show_all (window);

	gtk_main ();

	return 0;
}
コード例 #11
0
ファイル: ec_gtk_plugins.c プロジェクト: sakhoshdel/ettercap
/*
 * plugin management
 */
void gtkui_plugin_mgmt(void)
{
   GtkWidget *scrolled, *vbox;
   GtkCellRenderer   *renderer;
   GtkTreeViewColumn *column;

   DEBUG_MSG("gtk_plugin_mgmt");
   
   /* if the object already exist, set the focus to it */
   if (plugins_window) {
      if(GTK_IS_WINDOW (plugins_window))
         gtk_window_present(GTK_WINDOW (plugins_window));
      else
         gtkui_page_present(plugins_window);
      return;
   }

   plugins_window = gtkui_page_new("Plugins", &gtkui_plug_destroy, &gtkui_plugins_detach);
   
#if GTK_CHECK_VERSION(3, 0, 0)
   vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
#else
   vbox = gtk_vbox_new(FALSE, 0);
#endif
   gtk_container_add(GTK_CONTAINER (plugins_window), vbox);
   gtk_widget_show(vbox);
   
  /* list */
   scrolled = gtk_scrolled_window_new(NULL, NULL);
   gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (scrolled), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
   gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW (scrolled), GTK_SHADOW_IN);
   gtk_box_pack_start(GTK_BOX(vbox), scrolled, TRUE, TRUE, 0);
   gtk_widget_show(scrolled);
   
   treeview = gtk_tree_view_new();
   gtk_container_add(GTK_CONTAINER (scrolled), treeview);
   gtk_widget_show(treeview);

   selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
   gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
   g_signal_connect (G_OBJECT (treeview), "row_activated", G_CALLBACK (gtkui_select_plugin), NULL);
   
   renderer = gtk_cell_renderer_text_new ();
   column = gtk_tree_view_column_new_with_attributes (" ", renderer, "text", 0, NULL);
   gtk_tree_view_column_set_sort_column_id (column, 0);
   gtk_tree_view_append_column (GTK_TREE_VIEW(treeview), column);

   renderer = gtk_cell_renderer_text_new ();
   column = gtk_tree_view_column_new_with_attributes ("Name", renderer, "text", 1, NULL);
   gtk_tree_view_column_set_sort_column_id (column, 1);
   gtk_tree_view_append_column (GTK_TREE_VIEW(treeview), column);

   renderer = gtk_cell_renderer_text_new ();
   column = gtk_tree_view_column_new_with_attributes ("Version", renderer, "text", 2, NULL);
   gtk_tree_view_column_set_sort_column_id (column, 2);
   gtk_tree_view_append_column (GTK_TREE_VIEW(treeview), column);

   renderer = gtk_cell_renderer_text_new ();
   column = gtk_tree_view_column_new_with_attributes ("Info", renderer, "text", 3, NULL);
   gtk_tree_view_column_set_sort_column_id (column, 3);
   gtk_tree_view_append_column (GTK_TREE_VIEW(treeview), column);

   /* create the array for the list widget */
   /* or refreshes it if it exists */
   gtkui_create_plug_array();
   gtk_tree_view_set_model(GTK_TREE_VIEW (treeview), GTK_TREE_MODEL (ls_plugins));   

   gtk_widget_show(plugins_window);
}
コード例 #12
0
ファイル: gtkmain.c プロジェクト: ks6g10/cymplayer
GtkWidget * create_videobox(entry * argEntry) 
{
	GtkWidget * top;
	GtkWidget * box;
	GtkWidget * title;
	GtkWidget * author;
	GtkWidget * duration;
	GtkWidget * thumboverlay; /*GTKoverlay to overlay author and duration over the image thumb.*/
	GtkWidget * thumb;
	
	GdkRGBA * bgcolor = NULL;
	uint8_t colorret =0;




	if(argEntry == (entry *) NULL)
		return (GtkWidget *) NULL;
	//construction


	top = gtk_event_box_new();
	box = gtk_box_new(GTK_ORIENTATION_VERTICAL,0);

	get_thumb_filename(argEntry);

	thumb = gtk_image_new_from_file(argEntry->fields[THUMBLOC]);


	title    = gtk_label_new(argEntry->fields[TITLE]);
	author   = gtk_label_new(argEntry->fields[AUTHOR]);
	duration = gtk_label_new(argEntry->fields[DURATION]);
	thumboverlay = gtk_overlay_new();
	

	gtk_label_set_ellipsize(GTK_LABEL(title),PANGO_ELLIPSIZE_END);
	gtk_label_set_ellipsize(GTK_LABEL(author),PANGO_ELLIPSIZE_END);
	gtk_label_set_line_wrap(GTK_LABEL(title),gtk_true());
	gtk_widget_set_tooltip_text(title,argEntry->fields[TITLE]);

	gtk_widget_set_size_request(thumboverlay,120,20);
	gtk_widget_set_size_request(top,ENTRYWIDTH,ENTRYHEIGHT);
	gtk_widget_set_valign(author,GTK_ALIGN_START);
	gtk_widget_set_halign(author,GTK_ALIGN_START);
	gtk_widget_set_valign(duration,GTK_ALIGN_END);
	gtk_widget_set_halign(duration,GTK_ALIGN_END);
	

	//Adding widgets
	gtk_container_add(GTK_CONTAINER(thumboverlay), thumb);
	gtk_container_add(GTK_CONTAINER(top), box);
	
	gtk_overlay_add_overlay(GTK_OVERLAY(thumboverlay),author);
	gtk_overlay_add_overlay(GTK_OVERLAY(thumboverlay),duration);

	gtk_box_set_homogeneous(GTK_BOX(box),FALSE);
	gtk_box_pack_start(GTK_BOX(box),title,FALSE,FALSE,0);
	gtk_box_pack_start(GTK_BOX(box),thumboverlay,FALSE,FALSE,0);



	//Color
	
	bgcolor = get_bgcolor(argEntry->fields[AUTHOR]);
	colorret = adjust_titlecolor(bgcolor);
	gtk_widget_override_color(title,GTK_STATE_FLAG_NORMAL,RGBARRAY[colorret]);
	gtk_widget_override_background_color(top,GTK_STATE_FLAG_NORMAL,bgcolor);
	free(bgcolor);
	
//	gtk_widget_add_events(thumb, GDK_BUTTON_MOTION_MASK);
	g_signal_connect(top,"button-press-event",G_CALLBACK(get_ytstream),argEntry->fields[ID]);
	
	gtk_widget_override_background_color(thumboverlay,GTK_STATE_FLAG_NORMAL,&BLACK);
	gtk_widget_override_color(author,GTK_STATE_FLAG_NORMAL,&WHITE);
	gtk_widget_override_color(duration,GTK_STATE_FLAG_NORMAL,&WHITE);
		
	gtk_widget_show_all(top);
	return top;	
}
コード例 #13
0
gint
main (gint argc, gchar * argv[])
{
  LocalState state;
  GtkWidget *area, *combo, *w;
  const gchar *uri;

  XInitThreads ();

  gst_init (&argc, &argv);
  gtk_init (&argc, &argv);

  if (argc < 2) {
    g_print ("Usage: 3dvideo <uri-to-play>\n");
    return 1;
  }

  uri = argv[1];

  GstElement *pipeline = gst_element_factory_make ("playbin", NULL);
  GstBin *sinkbin = (GstBin *) gst_parse_bin_from_description ("glupload ! glcolorconvert ! glviewconvert name=viewconvert ! glimagesink name=sink", TRUE, NULL);
#if USE_GLCONVERT_FOR_INPUT
  GstElement *glconvert = gst_bin_get_by_name (sinkbin, "viewconvert");
#endif
  GstElement *videosink = gst_bin_get_by_name (sinkbin, "sink");

  /* Get defaults */
  g_object_get (pipeline, "video-multiview-mode", &state.in_mode,
      "video-multiview-flags", &state.in_flags, NULL);
  gst_child_proxy_get (GST_CHILD_PROXY (videosink), "sink::output-multiview-mode", &state.out_mode,
      "sink::output-multiview-flags", &state.out_flags, NULL);

  detect_mode_from_uri (&state, uri);

  g_return_val_if_fail (pipeline != NULL, 1);
  g_return_val_if_fail (videosink != NULL, 1);

  g_object_set (G_OBJECT (pipeline), "video-sink", sinkbin, NULL);
  g_object_set (G_OBJECT (pipeline), "uri", uri, NULL);

#if USE_GLCONVERT_FOR_INPUT
  g_object_set (G_OBJECT (glconvert), "input-mode-override", state.in_mode,
      NULL);
  g_object_set (G_OBJECT (glconvert), "input-flags-override", state.in_flags,
      NULL);
#else
  g_object_set (G_OBJECT (pipeline), "video-multiview-mode", state.in_mode,
      NULL);
  g_object_set (G_OBJECT (pipeline), "video-multiview-flags", state.in_flags,
      NULL);
#endif

  /* Connect to bus for signal handling */
  GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
  gst_bus_add_signal_watch (bus);
  g_signal_connect (bus, "message::error", G_CALLBACK (end_stream_cb),
      pipeline);
  g_signal_connect (bus, "message::warning", G_CALLBACK (end_stream_cb),
      pipeline);
  g_signal_connect (bus, "message::eos", G_CALLBACK (end_stream_cb), pipeline);

  gst_element_set_state (pipeline, GST_STATE_READY);

  area = gtk_drawing_area_new ();
  gst_bus_set_sync_handler (bus, (GstBusSyncHandler) create_window, area, NULL);
  gst_object_unref (bus);

  /* Toplevel window */
  GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_default_size (GTK_WINDOW (window), 800, 600);
  gtk_window_set_title (GTK_WINDOW (window), "Stereoscopic video demo");
  GdkGeometry geometry;
  geometry.min_width = 1;
  geometry.min_height = 1;
  geometry.max_width = -1;
  geometry.max_height = -1;
  gtk_window_set_geometry_hints (GTK_WINDOW (window), window, &geometry,
      GDK_HINT_MIN_SIZE);

  GtkWidget *vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
  gtk_container_add (GTK_CONTAINER (window), vbox);

  /* area where the video is drawn */
  gtk_box_pack_start (GTK_BOX (vbox), area, TRUE, TRUE, 0);

  /* Buttons to control the pipeline state */
  GtkWidget *table = gtk_grid_new ();
  gtk_container_add (GTK_CONTAINER (vbox), table);

  GtkWidget *button_state_ready = gtk_button_new_with_label ("Stop");
  g_signal_connect (G_OBJECT (button_state_ready), "clicked",
      G_CALLBACK (button_state_ready_cb), pipeline);
  gtk_grid_attach (GTK_GRID (table), button_state_ready, 1, 0, 1, 1);
  gtk_widget_show (button_state_ready);

  //control state paused
  GtkWidget *button_state_paused = gtk_button_new_with_label ("Pause");
  g_signal_connect (G_OBJECT (button_state_paused), "clicked",
      G_CALLBACK (button_state_paused_cb), pipeline);
  gtk_grid_attach (GTK_GRID (table), button_state_paused, 2, 0, 1, 1);
  gtk_widget_show (button_state_paused);

  //control state playing
  GtkWidget *button_state_playing = gtk_button_new_with_label ("Play");
  g_signal_connect (G_OBJECT (button_state_playing), "clicked",
      G_CALLBACK (button_state_playing_cb), pipeline);
  gtk_grid_attach (GTK_GRID (table), button_state_playing, 3, 0, 1, 1);
  //gtk_widget_show (button_state_playing);

  w = gst_mview_widget_new (FALSE);
  combo = GST_MVIEW_WIDGET (w)->mode_selector;
  gtk_combo_box_set_active_id (GTK_COMBO_BOX (combo),
      enum_value_to_nick (GST_TYPE_VIDEO_MULTIVIEW_FRAME_PACKING,
          state.in_mode));
#if USE_GLCONVERT_FOR_INPUT
  g_signal_connect (G_OBJECT (combo), "changed",
      G_CALLBACK (set_mview_input_mode), glconvert);
#else
  g_signal_connect (G_OBJECT (combo), "changed",
      G_CALLBACK (set_mview_input_mode), pipeline);
#endif

  g_object_set (G_OBJECT (w), "flags", state.in_flags, NULL);
#if USE_GLCONVERT_FOR_INPUT
  g_signal_connect (G_OBJECT (w), "notify::flags",
      G_CALLBACK (input_flags_changed), glconvert);
#else
  g_signal_connect (G_OBJECT (w), "notify::flags",
      G_CALLBACK (input_flags_changed), pipeline);
#endif
  gtk_container_add (GTK_CONTAINER (vbox), w);

  w = gst_mview_widget_new (TRUE);
  combo = GST_MVIEW_WIDGET (w)->mode_selector;
  gtk_combo_box_set_active_id (GTK_COMBO_BOX (combo),
      enum_value_to_nick (GST_TYPE_VIDEO_MULTIVIEW_MODE, state.out_mode));
  g_signal_connect (G_OBJECT (combo), "changed",
      G_CALLBACK (set_mview_output_mode), videosink);

  g_object_set (G_OBJECT (w), "flags", state.out_flags, NULL);
  g_signal_connect (G_OBJECT (w), "notify::flags",
      G_CALLBACK (output_flags_changed), videosink);
  g_signal_connect (G_OBJECT (w), "notify::downmix-mode",
      G_CALLBACK (downmix_method_changed), videosink);
  gtk_container_add (GTK_CONTAINER (vbox), w);

  //configure the pipeline
  g_signal_connect (G_OBJECT (window), "delete-event", G_CALLBACK (destroy_cb),
      pipeline);

  gtk_widget_realize (area);

  /* Redraw needed when paused or stopped (PAUSED or READY) */
  g_signal_connect (area, "draw", G_CALLBACK (draw_cb), videosink);
  g_signal_connect(area, "configure-event", G_CALLBACK(resize_cb), videosink);

  gtk_widget_show_all (window);

  gst_element_set_state (pipeline, GST_STATE_PLAYING);

  gtk_main ();

  return 0;
}
コード例 #14
0
ファイル: keybinds.c プロジェクト: BucketPW/pomfit
void keybinds_window_create (void) {

	int i;
	GtkWidget *vbox_kb_m, *hbox_kb_s, *hbox_kb_lay;
	GtkWidget *but_kb_close, *but_kb_save, *but_kb_reset;
	GtkWidget *lab_kb_e, *hbox_kb_bind[4], *entry_kb_test;
	GtkWidget *vbox_kb_s1, *vbox_kb_s2, *hbox_kb_m;

	win_kb_main = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	gtk_window_set_title(GTK_WINDOW(win_kb_main), "Pomf it! - Keybinds Settings");
	g_signal_connect(win_kb_main, "destroy", G_CALLBACK(keybinds_window_destroy), NULL);
	gtk_container_set_border_width(GTK_CONTAINER(win_kb_main), 10);
	gtk_window_resize(GTK_WINDOW(win_kb_main), 500, 200);
	gtk_window_set_position(GTK_WINDOW(win_kb_main), GTK_WIN_POS_CENTER);

	vbox_kb_m = gtk_box_new(GTK_ORIENTATION_VERTICAL , 0);
	gtk_container_add(GTK_CONTAINER(win_kb_main), vbox_kb_m);

	hbox_kb_m = gtk_box_new(GTK_ORIENTATION_HORIZONTAL , 0);
	gtk_container_add(GTK_CONTAINER(vbox_kb_m), hbox_kb_m);

	vbox_kb_s1 = gtk_box_new(GTK_ORIENTATION_VERTICAL , 0);
	gtk_container_add(GTK_CONTAINER(hbox_kb_m), vbox_kb_s1);

	vbox_kb_s2 = gtk_box_new(GTK_ORIENTATION_VERTICAL , 0);
	gtk_container_add(GTK_CONTAINER(hbox_kb_m), vbox_kb_s2);

    lab_kb_e = gtk_label_new("File Upload:");
	gtk_box_pack_start (GTK_BOX(vbox_kb_s1), GTK_WIDGET(lab_kb_e), FALSE, FALSE, 5);
	lab_kb_e = gtk_label_new("Capture Area & UP:");
	gtk_box_pack_start (GTK_BOX(vbox_kb_s1), GTK_WIDGET(lab_kb_e), TRUE, FALSE, 5);
	lab_kb_e = gtk_label_new("Capture Window & UP:");
	gtk_box_pack_start (GTK_BOX(vbox_kb_s1), GTK_WIDGET(lab_kb_e), FALSE, FALSE, 5);
	lab_kb_e = gtk_label_new("Capture Fullscreen & UP:");
	gtk_box_pack_start (GTK_BOX(vbox_kb_s1), GTK_WIDGET(lab_kb_e), TRUE, FALSE, 5);
	lab_kb_e = gtk_label_new("Capture Area:");
	gtk_box_pack_start (GTK_BOX(vbox_kb_s1), GTK_WIDGET(lab_kb_e), FALSE, FALSE, 5);
	lab_kb_e = gtk_label_new("Capture Window:");
	gtk_box_pack_start (GTK_BOX(vbox_kb_s1), GTK_WIDGET(lab_kb_e), TRUE, FALSE, 5);
	lab_kb_e = gtk_label_new("Capture Fullscreen:");
	gtk_box_pack_start (GTK_BOX(vbox_kb_s1), GTK_WIDGET(lab_kb_e), FALSE, FALSE, 5);
	lab_kb_e = gtk_label_new("Open URL(s):");
	gtk_box_pack_start (GTK_BOX(vbox_kb_s1), GTK_WIDGET(lab_kb_e), TRUE, FALSE, 5);

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

		hbox_kb_bind[i] = gtk_box_new(GTK_ORIENTATION_HORIZONTAL ,4);
		gtk_container_add (GTK_CONTAINER(vbox_kb_s2),hbox_kb_bind[i]);

		com_kb_mod1[i] = gtk_combo_box_text_new();
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_mod1[i]), NULL, "");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_mod1[i]), NULL, "<CTRL>");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_mod1[i]), NULL, "<SHIFT>");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_mod1[i]), NULL, "<ALT>");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_mod1[i]), NULL, "<WIN>");
		gtk_container_add(GTK_CONTAINER(hbox_kb_bind[i]), com_kb_mod1[i]);

		com_kb_mod2[i] = gtk_combo_box_text_new();
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_mod2[i]), NULL, "");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_mod2[i]), NULL, "<CTRL>");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_mod2[i]), NULL, "<SHIFT>");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_mod2[i]), NULL, "<ALT>");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_mod2[i]), NULL, "<WIN>");
		gtk_container_add(GTK_CONTAINER(hbox_kb_bind[i]), com_kb_mod2[i]);

		com_kb_key[i] = gtk_combo_box_text_new();
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "!");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "\"");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "#");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "$");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "%");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "&");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "'");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "(");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, ")");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "*");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "+");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, ",");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "-");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, ".");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "/");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "0");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "1");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "2");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "3");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "4");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "5");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "6");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "7");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "8");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "9");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, ":");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, ";");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "<");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "=");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, ">");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "?");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "@");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "A");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "B");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "C");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "D");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "E");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "F");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "G");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "H");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "I");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "J");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "K");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "L");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "M");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "N");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "O");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "P");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "Q");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "R");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "S");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "T");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "U");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "V");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "W");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "X");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "Y");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "Z");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "[");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "\\");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "]");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "^");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "_");
		gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(com_kb_key[i]), NULL, "`");
		gtk_combo_box_set_active(GTK_COMBO_BOX(com_kb_key[i]), 0);
		gtk_combo_box_set_wrap_width (GTK_COMBO_BOX(com_kb_key[i]), 8);
		gtk_container_add(GTK_CONTAINER(hbox_kb_bind[i]), com_kb_key[i]);

		sw_kb[i] = gtk_switch_new();
		gtk_container_add(GTK_CONTAINER(hbox_kb_bind[i]), sw_kb[i]);

	}
	keybinds_window_create_set_actives();

	hbox_kb_lay = gtk_box_new(GTK_ORIENTATION_HORIZONTAL , 5);
	gtk_container_add(GTK_CONTAINER(vbox_kb_m), hbox_kb_lay);

	lab_kb_e = gtk_label_new("Wait...What's my keyboard layout again ? ..");
	gtk_box_pack_start (GTK_BOX(hbox_kb_lay), GTK_WIDGET(lab_kb_e), FALSE, FALSE, 5);

	entry_kb_test = gtk_entry_new ();
	gtk_container_add(GTK_CONTAINER(hbox_kb_lay), entry_kb_test);

	hbox_kb_s = gtk_box_new(GTK_ORIENTATION_HORIZONTAL , 0);
	gtk_box_pack_end(GTK_BOX(vbox_kb_m), hbox_kb_s, FALSE, FALSE, 0);

	but_kb_reset = gtk_button_new_with_label("Reset Settings");
	g_signal_connect(but_kb_reset,"clicked",G_CALLBACK(keybinds_conf_default), NULL);
	gtk_container_add(GTK_CONTAINER(hbox_kb_s), but_kb_reset);

	but_kb_close = gtk_button_new_with_label("    Close    ");
	g_signal_connect(but_kb_close,"clicked",G_CALLBACK(keybinds_window_destroy), NULL);
	gtk_box_pack_end(GTK_BOX(hbox_kb_s),GTK_WIDGET(but_kb_close),FALSE,FALSE,0);

	but_kb_save = gtk_button_new_with_label("Save & Close");
	g_signal_connect(but_kb_save,"clicked",G_CALLBACK(keybinds_conf_save), NULL);
	gtk_box_pack_end(GTK_BOX(hbox_kb_s),GTK_WIDGET(but_kb_save),FALSE,FALSE,0);

	gtk_widget_show_all(win_kb_main);
}
コード例 #15
0
ファイル: applet.c プロジェクト: mate-desktop/mate-netbook
static gboolean
cw_applet_fill (MatePanelApplet *applet,
                const gchar *iid,
                gpointer     data)
{
  WinPickerApp *app;
  GtkWidget *eb, *tasks, *title;
  gchar *ui_path;
  GtkActionGroup *action_group;
  GObjectClass *object_class;

  if (strcmp (iid, "MateWindowPicker") != 0)
    return FALSE;

  bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
  textdomain (GETTEXT_PACKAGE);

  /* Have our background automatically painted. */
  mate_panel_applet_set_background_widget (MATE_PANEL_APPLET (applet), GTK_WIDGET (applet));

  wnck_set_client_type (WNCK_CLIENT_TYPE_PAGER);

  app = g_slice_new0 (WinPickerApp);
  mainapp = app;

  object_class = G_OBJECT_GET_CLASS (G_OBJECT(applet));
  object_class->finalize = cw_applet_finalize;
  parent_class = g_type_class_peek_parent (object_class);

  /* gsettings prefs */
  app->settings = mate_panel_applet_settings_new (applet, APPLET_SCHEMA);
  g_signal_connect (app->settings, "changed::" SHOW_WIN_KEY,
                    G_CALLBACK (on_show_all_windows_changed), app);
  g_signal_connect (app->settings, "changed::" SHOW_HOME_TITLE_KEY,
                    G_CALLBACK (on_show_home_title_changed), app);
  g_signal_connect (app->settings, "changed::" BOLD_WINDOW_TITLE_KEY,
                    G_CALLBACK (on_bold_window_title_changed), app);

  app->applet = GTK_WIDGET (applet);
  force_no_focus_padding (GTK_WIDGET (applet));
  gtk_container_set_border_width (GTK_CONTAINER (applet), 0);

  eb = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
  gtk_container_add (GTK_CONTAINER (applet), eb);
  gtk_container_set_border_width (GTK_CONTAINER (eb), 0);

  tasks = app->tasks = task_list_get_default ();
  gtk_box_pack_start (GTK_BOX (eb), tasks, FALSE, FALSE, 0);

  title = app->title = task_title_new ();
  gtk_box_pack_start (GTK_BOX (eb), title, TRUE, TRUE, 0);

  gtk_widget_show_all (GTK_WIDGET (applet));

  on_show_all_windows_changed (app->settings, SHOW_WIN_KEY, app);
  on_show_home_title_changed (app->settings, SHOW_HOME_TITLE_KEY, app);
  on_bold_window_title_changed (app->settings, BOLD_WINDOW_TITLE_KEY, app);

  action_group = gtk_action_group_new ("MateWindowPicker Applet Actions");
  gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
  gtk_action_group_add_actions (action_group,
                                window_picker_menu_actions,
                                G_N_ELEMENTS (window_picker_menu_actions),
                                app);
  ui_path = g_build_filename (MATEWINDOWPICKER_MENU_UI_DIR, "mate-window-picker-applet-menu.xml", NULL);
  mate_panel_applet_setup_menu_from_file (MATE_PANEL_APPLET (app->applet),
                                          ui_path, action_group);
  g_free (ui_path);
  g_object_unref (action_group);

  mate_panel_applet_set_flags (MATE_PANEL_APPLET (applet),
                               MATE_PANEL_APPLET_EXPAND_MAJOR
                               | MATE_PANEL_APPLET_EXPAND_MINOR
                               | MATE_PANEL_APPLET_HAS_HANDLE);

  return TRUE;
}
コード例 #16
0
static void
gcal_toolbar_set_overview_mode (GcalToolbar *toolbar)
{
  GcalToolbarPrivate *priv;
  GtkStyleContext *context;
  GtkWidget *button;

  g_return_if_fail (GCAL_IS_TOOLBAR (toolbar));
  priv = toolbar->priv;

  /* add */
  if (priv->add_button == NULL)
    {
      priv->add_button = gtk_button_new_with_label (_("New Event"));
      g_object_ref_sink (priv->add_button);

      gtk_widget_set_size_request (priv->add_button, 100, -1);
      context = gtk_widget_get_style_context (priv->add_button);
      gtk_style_context_add_class (context, "suggested-action");

      g_signal_connect (priv->add_button,
                        "clicked",
                        G_CALLBACK (gcal_toolbar_add_event),
                        toolbar);
    }
  gtk_container_add (GTK_CONTAINER (priv->left_item), priv->add_button);
  gtk_widget_show_all (priv->add_button);

  /* views_box */
  if (priv->views_box == NULL)
    {
      priv->views_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
      g_object_ref_sink (priv->views_box);
      gtk_widget_set_hexpand (priv->views_box, TRUE);

      context = gtk_widget_get_style_context (priv->views_box);
      gtk_style_context_add_class (context, "linked");

      /* day */
      button = gtk_toggle_button_new_with_label (_("Day"));
      gtk_widget_set_size_request (button, 80, -1);

      context = gtk_widget_get_style_context (button);
      gtk_style_context_add_class (context, "raised");

      gtk_container_add (GTK_CONTAINER (priv->views_box), button);

      g_object_set_data (G_OBJECT (button),
                        "view-type",
                        GUINT_TO_POINTER (GCAL_WINDOW_VIEW_DAY));
      g_signal_connect (button,
                        "toggled",
                        G_CALLBACK (gcal_toolbar_view_changed),
                        toolbar);

      /* week */
      button = gtk_toggle_button_new_with_label (_("Week"));
      gtk_widget_set_size_request (button, 80, -1);

      context = gtk_widget_get_style_context (button);
      gtk_style_context_add_class (context, "raised");

      gtk_container_add (GTK_CONTAINER (priv->views_box), button);

      g_object_set_data (G_OBJECT (button),
                        "view-type",
                        GUINT_TO_POINTER (GCAL_WINDOW_VIEW_WEEK));
      g_signal_connect (button,
                        "toggled",
                        G_CALLBACK (gcal_toolbar_view_changed),
                        toolbar);

      /* month */
      button = gtk_toggle_button_new_with_label (_("Month"));
      gtk_widget_set_size_request (button, 80, -1);

      context = gtk_widget_get_style_context (button);
      gtk_style_context_add_class (context, "raised");

      gtk_container_add (GTK_CONTAINER (priv->views_box), button);

      g_object_set_data (G_OBJECT (button),
                        "view-type",
                        GUINT_TO_POINTER (GCAL_WINDOW_VIEW_MONTH));
      g_signal_connect (button,
                        "toggled",
                        G_CALLBACK (gcal_toolbar_view_changed),
                        toolbar);

      /* year */
      button = gtk_toggle_button_new_with_label (_("Year"));
      gtk_widget_set_size_request (button, 80, -1);

      context = gtk_widget_get_style_context (button);
      gtk_style_context_add_class (context, "raised");

      gtk_container_add (GTK_CONTAINER (priv->views_box), button);

      g_object_set_data (G_OBJECT (button),
                        "view-type",
                        GUINT_TO_POINTER (GCAL_WINDOW_VIEW_YEAR));
      g_signal_connect (button,
                        "toggled",
                        G_CALLBACK (gcal_toolbar_view_changed),
                        toolbar);

      /* list */
      button = gtk_toggle_button_new_with_label (_("List"));
      gtk_widget_set_size_request (button, 80, -1);

      context = gtk_widget_get_style_context (button);
      gtk_style_context_add_class (context, "raised");

      gtk_container_add (GTK_CONTAINER (priv->views_box), button);

      g_object_set_data (G_OBJECT (button),
                        "view-type",
                        GUINT_TO_POINTER (GCAL_WINDOW_VIEW_LIST));
      g_signal_connect (button,
                        "toggled",
                        G_CALLBACK (gcal_toolbar_view_changed),
                        toolbar);
    }
  gtk_container_add (GTK_CONTAINER (priv->central_item), priv->views_box);
  gtk_widget_show_all (priv->views_box);

  /* right_box */
  if (priv->right_box == NULL)
    {
      priv->right_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
      g_object_ref_sink (priv->right_box);
      gtk_widget_set_hexpand (priv->right_box, TRUE);
      gtk_box_set_spacing (GTK_BOX (priv->right_box), 6);

      /* sources_button */
      priv->sources_button = gtk_toggle_button_new ();
      gtk_container_add (
          GTK_CONTAINER (priv->sources_button),
          gtk_image_new_from_icon_name ("x-office-calendar-symbolic",
                                        GTK_ICON_SIZE_MENU));

      context = gtk_widget_get_style_context (priv->sources_button);
      gtk_style_context_add_class (context, "raised");

      gtk_container_add (GTK_CONTAINER (priv->right_box),
                         priv->sources_button);

      g_signal_connect (priv->sources_button,
                        "clicked",
                        G_CALLBACK (gcal_toolbar_sources_shown),
                        toolbar);

      /* search_button */
      priv->search_button = gtk_button_new ();
      gtk_container_add (
          GTK_CONTAINER (priv->search_button),
          gtk_image_new_from_icon_name ("folder-saved-search-symbolic",
                                        GTK_ICON_SIZE_MENU));

      context = gtk_widget_get_style_context (priv->search_button);
      gtk_style_context_add_class (context, "raised");

      gtk_container_add (GTK_CONTAINER (priv->right_box),
                         priv->search_button);

      g_signal_connect (priv->search_button,
                        "clicked",
                        G_CALLBACK (gcal_toolbar_search_events),
                        toolbar);
    }
  gtk_container_add (GTK_CONTAINER (priv->right_item), priv->right_box);
  gtk_widget_show_all (priv->sources_button);
}
コード例 #17
0
ファイル: applet.c プロジェクト: mate-desktop/mate-netbook
static void
display_prefs_dialog (GtkAction       *action,
                      WinPickerApp *applet)
{
  GtkWidget *window, *box, *vbox, *nb, *hbox, *label, *check, *button;

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (window), _("Preferences"));
  gtk_window_set_icon_name (GTK_WINDOW (window), "preferences-system-windows");
  gtk_window_set_type_hint (GTK_WINDOW (window),
                            GDK_WINDOW_TYPE_HINT_DIALOG);
  gtk_container_set_border_width (GTK_CONTAINER (window), 12);

  box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
  gtk_container_add (GTK_CONTAINER (window), box);

  nb = gtk_notebook_new ();
  g_object_set (nb, "show-tabs", FALSE, "show-border", TRUE, NULL);
  gtk_box_pack_start (GTK_BOX (box), nb, TRUE, TRUE, 0);

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
  gtk_container_set_border_width (GTK_CONTAINER (vbox), 8);
  gtk_notebook_append_page (GTK_NOTEBOOK (nb), vbox, NULL);

  check = gtk_check_button_new_with_label (_("Show all windows"));
  gtk_widget_set_tooltip_text (GTK_WIDGET (check),
                               _("Show windows from all workspaces."));
  gtk_box_pack_start (GTK_BOX (vbox), check, FALSE, TRUE, 0);
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check),
                                g_settings_get_boolean (mainapp->settings, SHOW_WIN_KEY));
  g_signal_connect (check, "toggled",
                    G_CALLBACK (on_show_win_key_checkbox_toggled), NULL);

  check = gtk_check_button_new_with_label (_("Show desktop title and logout button"));
  gtk_widget_set_tooltip_text (GTK_WIDGET (check),
                               _("Show a title for the desktop when no window is selected, and append a logout button."));
  gtk_box_pack_start (GTK_BOX (vbox), check, FALSE, TRUE, 0);
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check),
                                g_settings_get_boolean (mainapp->settings, SHOW_HOME_TITLE_KEY));
  g_signal_connect (check, "toggled",
                    G_CALLBACK (on_show_home_title_checkbox_toggled), NULL);

  check = gtk_check_button_new_with_label (_("Bold windows title"));
  gtk_widget_set_tooltip_text (GTK_WIDGET (check),
                               _("Show windows title with a bold face."));
  gtk_box_pack_start (GTK_BOX (vbox), check, FALSE, TRUE, 0);
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check),
                                g_settings_get_boolean (mainapp->settings, BOLD_WINDOW_TITLE_KEY));
  g_signal_connect (check, "toggled",
                    G_CALLBACK (on_bold_window_title_checkbox_toggled), NULL);

  check = gtk_label_new (" ");
  gtk_box_pack_start (GTK_BOX (vbox), check, TRUE, TRUE, 0);

  gtk_widget_set_size_request (nb, -1, 100);

  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
  gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 0);

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

  button = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
  gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);

  gtk_widget_show_all (window);

  g_signal_connect (window, "delete-event",
                    G_CALLBACK (gtk_widget_destroy), window);

  g_signal_connect (window, "destroy",
                    G_CALLBACK (gtk_widget_destroy), window);
  g_signal_connect_swapped (button, "clicked",
                            G_CALLBACK (gtk_widget_destroy), window);

  gtk_window_present (GTK_WINDOW (window));
}
コード例 #18
0
static GtkWidget *
create_listbox_row (gpointer item,
                    gpointer user_data)
{
  PpJob     *job = (PpJob *)item;
  GtkWidget *box;
  GtkWidget *widget;
  gchar     *title;
  gchar     *state_string = NULL;
  gint       job_state;

  g_object_get (job, "title", &title, "state", &job_state, NULL);

  switch (job_state)
    {
      case IPP_JOB_PENDING:
        /* Translators: Job's state (job is waiting to be printed) */
        state_string = g_strdup (C_("print job", "Pending"));
        break;
      case IPP_JOB_HELD:
        /* Translators: Job's state (job is held for printing) */
        state_string = g_strdup (C_("print job", "Paused"));
        break;
      case IPP_JOB_PROCESSING:
        /* Translators: Job's state (job is currently printing) */
        state_string = g_strdup (C_("print job", "Processing"));
        break;
      case IPP_JOB_STOPPED:
        /* Translators: Job's state (job has been stopped) */
        state_string = g_strdup (C_("print job", "Stopped"));
        break;
      case IPP_JOB_CANCELED:
        /* Translators: Job's state (job has been canceled) */
        state_string = g_strdup (C_("print job", "Canceled"));
        break;
      case IPP_JOB_ABORTED:
        /* Translators: Job's state (job has aborted due to error) */
        state_string = g_strdup (C_("print job", "Aborted"));
        break;
      case IPP_JOB_COMPLETED:
        /* Translators: Job's state (job has completed successfully) */
        state_string = g_strdup (C_("print job", "Completed"));
        break;
    }

  box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
  g_object_set (box, "margin", 6, NULL);
  gtk_container_set_border_width (GTK_CONTAINER (box), 2);

  widget = gtk_label_new (title);
  gtk_widget_set_halign (widget, GTK_ALIGN_START);
  gtk_box_pack_start (GTK_BOX (box), widget, TRUE, TRUE, 10);

  widget = gtk_label_new (state_string);
  gtk_widget_set_halign (widget, GTK_ALIGN_END);
  gtk_widget_set_margin_end (widget, 64);
  gtk_box_pack_start (GTK_BOX (box), widget, FALSE, FALSE, 10);

  widget = gtk_button_new_from_icon_name (job_state == IPP_JOB_HELD ? "media-playback-start-symbolic" : "media-playback-pause-symbolic",
                                          GTK_ICON_SIZE_SMALL_TOOLBAR);
  g_signal_connect (widget, "clicked", G_CALLBACK (job_pause_cb), item);
  gtk_box_pack_start (GTK_BOX (box), widget, FALSE, FALSE, 4);

  widget = gtk_button_new_from_icon_name ("edit-delete-symbolic",
                                          GTK_ICON_SIZE_SMALL_TOOLBAR);
  g_signal_connect (widget, "clicked", G_CALLBACK (job_stop_cb), item);
  gtk_box_pack_start (GTK_BOX (box), widget, FALSE, FALSE, 4);

  gtk_widget_show_all (box);

  return box;
}
コード例 #19
0
ファイル: max-rgb.c プロジェクト: AdamGrzonkowski/gimp-1
/* dialog stuff */
static gint
max_rgb_dialog (GimpDrawable *drawable)
{
  GtkWidget *dialog;
  GtkWidget *main_vbox;
  GtkWidget *preview;
  GtkWidget *frame;
  GtkWidget *max;
  GtkWidget *min;
  gboolean   run;

  gimp_ui_init (PLUG_IN_BINARY, TRUE);

  dialog = gimp_dialog_new (_("Maximum RGB Value"), PLUG_IN_ROLE,
                            NULL, 0,
                            gimp_standard_help_func, PLUG_IN_PROC,

                            GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                            GTK_STOCK_OK,     GTK_RESPONSE_OK,

                            NULL);

  gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
                                           GTK_RESPONSE_OK,
                                           GTK_RESPONSE_CANCEL,
                                           -1);

  gimp_window_set_transient (GTK_WINDOW (dialog));

  main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
  gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
  gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
                      main_vbox, TRUE, TRUE, 0);
  gtk_widget_show (main_vbox);

  preview = gimp_zoom_preview_new_from_drawable_id (drawable->drawable_id);
  gtk_box_pack_start (GTK_BOX (main_vbox), preview, TRUE, TRUE, 0);
  gtk_widget_show (preview);

  g_signal_connect_swapped (preview, "invalidated",
                            G_CALLBACK (main_function),
                            drawable);

  frame = gimp_int_radio_group_new (FALSE, NULL,
                                    G_CALLBACK (gimp_radio_button_update),
                                    &pvals.max_p, pvals.max_p,

                                    _("_Hold the maximal channels"),
                                    MAX_CHANNELS, &max,

                                    _("Ho_ld the minimal channels"),
                                    MIN_CHANNELS, &min,

                                    NULL);

  g_signal_connect_swapped (max, "toggled",
                            G_CALLBACK (gimp_preview_invalidate),
                            preview);
  g_signal_connect_swapped (min, "toggled",
                            G_CALLBACK (gimp_preview_invalidate),
                            preview);

  gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
  gtk_widget_show (frame);

  gtk_widget_show (dialog);

  run = (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK);

  gtk_widget_destroy (dialog);

  return run;
}
コード例 #20
0
void
gstyle_eyedropper_set_source_event (GstyleEyedropper *self,
                                    GdkEvent         *event)
{
  GtkWidget *source;
  GtkStyleContext *context;
  GtkWidget *box;
  GtkWidget *swatch;
  GdkGrabStatus status;
  gint x_root, y_root;
  gint x, y;

  g_return_if_fail (GSTYLE_IS_EYEDROPPER (self));
  g_return_if_fail (event != NULL);

  self->seat = g_object_ref (gdk_event_get_seat (event));
  source = gtk_get_event_widget (event);
  self->screen = gdk_event_get_screen (event);
  g_signal_connect_swapped (self->screen,
                            "size-changed",
                            G_CALLBACK (gstyle_eyedropper_screen_size_changed_cb),
                            self);

  self->window = g_object_ref_sink (gtk_window_new (GTK_WINDOW_POPUP));
  gtk_window_set_screen (GTK_WINDOW (self->window),self->screen);
  gtk_widget_set_name (self->window, "gstyleeyedropper");
  context = gtk_widget_get_style_context (self->window);
  self->default_provider = gstyle_css_provider_init_default (gtk_style_context_get_screen (context));

  box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
  gtk_container_add (GTK_CONTAINER (self->window), box);

  self->zoom_area = gtk_drawing_area_new ();
  gtk_widget_set_size_request (self->zoom_area, ZOOM_AREA_WIDTH, ZOOM_AREA_HEIGHT);
  gtk_container_add (GTK_CONTAINER (box), self->zoom_area);

  swatch = g_object_new (GSTYLE_TYPE_COLOR_WIDGET,
                         "fallback-name-kind", GSTYLE_COLOR_KIND_RGB_HEX6,
                         "fallback-name-visible", TRUE,
                         "color", self->color,
                         NULL);
  gtk_container_add (GTK_CONTAINER (box), swatch);

  g_signal_connect_object (self->zoom_area,
                           "draw",
                           G_CALLBACK (gstyle_eyedropper_zoom_area_draw_cb),
                           self,
                           G_CONNECT_SWAPPED);

  self->screen_width = gdk_screen_get_width (self->screen);
  self->screen_height = gdk_screen_get_height (self->screen);
  gstyle_eyedropper_event_get_root_coords (self, event, &x_root, &y_root);
  gstyle_eyedropper_calculate_window_position (self, GTK_WINDOW (self->window), x_root, y_root, &x, &y);
  gtk_window_move (GTK_WINDOW (self->window), x, y);
  gtk_widget_show_all (self->window);

  gtk_widget_add_events (self->window,
                         GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK);

  self->cursor = gdk_cursor_new_from_name (gdk_screen_get_display (self->screen), "cell");
  gtk_grab_add (self->window);
  status = gdk_seat_grab (self->seat,
                          gtk_widget_get_window (source),
                          GDK_SEAT_CAPABILITY_ALL,
                          FALSE,
                          self->cursor,
                          event,
                          NULL, NULL);

  if (status != GDK_GRAB_SUCCESS)
    {
      g_warning ("grab failed status:%i\n", status);
      return;
    }

  self->motion_notify_handler_id =
    g_signal_connect_swapped (self->window, "motion-notify-event",
                              G_CALLBACK (gstyle_eyedropper_pointer_motion_notify_cb),
                              self);

  self->pointer_pressed_handler_id =
    g_signal_connect_swapped (self->window,
                              "button-press-event",
                              G_CALLBACK (gstyle_eyedropper_pointer_pressed_cb),
                              self);

  self->pointer_wheel_handler_id =
    g_signal_connect_swapped (self->window,
                              "scroll-event",
                              G_CALLBACK (gstyle_eyedropper_pointer_wheel_cb),
                              self);

  self->key_handler_id =
    g_signal_connect_swapped (self->window,
                              "key-press-event",
                              G_CALLBACK (gstyle_eyedropper_key_pressed_cb),
                              self);

  self->grab_broken_handler_id =
    g_signal_connect_swapped (self->window,
                              "grab-broken-event",
                              G_CALLBACK (gstyle_eyedropper_grab_broken_cb),
                              self);
}
コード例 #21
0
int
main (int argc, char **argv)
{
    GdkScreen *screen;
    GtkWidget *nb;
    GtkWidget *general_vbox;
    GtkWidget *behaviour_vbox;
    GtkWidget *placement_vbox;
    GtkWidget *widget;
    GtkWidget *vbox;
    GtkWidget *vbox1;
    GtkWidget *hbox;
    GtkWidget *hbox1;
    GtkWidget *hbox2;
    GtkWidget *hbox3;
    GtkWidget *content_area;
    gchar *str;
    const char *current_wm;
    int i;

    bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
    bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
    textdomain (GETTEXT_PACKAGE);

    gtk_init (&argc, &argv);

    screen = gdk_display_get_default_screen (gdk_display_get_default ());
    current_wm = gdk_x11_screen_get_window_manager_name (screen);

    if (g_strcmp0 (current_wm, WM_COMMON_METACITY) == 0) {
        mate_metacity_config_tool ();
        return 0;
    }

    if (g_strcmp0 (current_wm, WM_COMMON_MARCO) != 0) {
        wm_unsupported ();
        return 1;
    }

    marco_settings = g_settings_new (MARCO_SCHEMA);

    /* Window */
    dialog_win = gtk_dialog_new_with_buttons (_("Window Preferences"),
                                              NULL,
                                              GTK_DIALOG_MODAL,
                                              GTK_STOCK_HELP,
                                              GTK_RESPONSE_HELP,
                                              GTK_STOCK_CLOSE,
                                              GTK_RESPONSE_CLOSE,
                                              NULL);
    //gtk_window_set_resizable (GTK_WINDOW (dialog_win), FALSE);
    gtk_window_set_icon_name (GTK_WINDOW (dialog_win), "preferences-system-windows");
    gtk_container_set_border_width (GTK_CONTAINER (dialog_win), 10);

    nb = gtk_notebook_new ();

    general_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
    behaviour_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
    placement_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);

    widget = gtk_label_new (_("General"));
    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
    gtk_box_pack_start (GTK_BOX (hbox), general_vbox, FALSE, FALSE, 6);
    gtk_notebook_append_page (GTK_NOTEBOOK (nb), hbox, widget);

    widget = gtk_label_new (_("Behaviour"));
    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
    gtk_box_pack_start (GTK_BOX (hbox), behaviour_vbox, FALSE, FALSE, 6);
    gtk_notebook_append_page (GTK_NOTEBOOK (nb), hbox, widget);

    widget = gtk_label_new (_("Placement"));
    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
    gtk_box_pack_start (GTK_BOX (hbox), placement_vbox, FALSE, FALSE, 6);
    gtk_notebook_append_page (GTK_NOTEBOOK (nb), hbox, widget);

    /* Compositing manager */
    widget = title_label_new (N_("Compositing Manager"));
    gtk_box_pack_start (GTK_BOX (general_vbox), widget, FALSE, FALSE, 6);

    vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
    hbox1 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);

    compositing_checkbutton = gtk_check_button_new_with_mnemonic (_("Enable software _compositing window manager"));
    compositing_fast_alt_tab_checkbutton = gtk_check_button_new_with_mnemonic (_("Disable _thumbnails in Alt-Tab"));
    gtk_box_pack_start (GTK_BOX (vbox), compositing_checkbutton, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (hbox1), compositing_fast_alt_tab_checkbutton, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (vbox), hbox1, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (general_vbox), hbox, FALSE, FALSE, 6);

    /* Titlebar buttons */
    widget = title_label_new (N_("Titlebar Buttons"));
    gtk_box_pack_start (GTK_BOX (general_vbox), widget, FALSE, FALSE, 6);

    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
    widget = gtk_label_new (_("Position:"));
    gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 6);
    titlebar_layout_optionmenu = gtk_combo_box_text_new ();
    gtk_box_pack_start (GTK_BOX (hbox), titlebar_layout_optionmenu, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (general_vbox), hbox, FALSE, FALSE, 6);

    /* New Windows */
    widget = title_label_new (N_("New Windows"));
    gtk_box_pack_start (GTK_BOX (placement_vbox), widget, FALSE, FALSE, 6);

    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
    center_new_windows_checkbutton = gtk_check_button_new_with_mnemonic (_("Center _new windows"));
    gtk_box_pack_start (GTK_BOX (hbox), center_new_windows_checkbutton, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (placement_vbox), hbox, FALSE, FALSE, 6);

    /* Window Snapping */
    widget = title_label_new (N_("Window Snapping"));
    gtk_box_pack_start (GTK_BOX (placement_vbox), widget, FALSE, FALSE, 6);

    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
    side_by_side_tiling_checkbutton = gtk_check_button_new_with_mnemonic (_("Enable side by side _tiling"));
    gtk_box_pack_start (GTK_BOX (hbox), side_by_side_tiling_checkbutton, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (placement_vbox), hbox, FALSE, FALSE, 6);

    /* Window Selection */
    widget = title_label_new (N_("Window Selection"));
    gtk_box_pack_start (GTK_BOX (behaviour_vbox), widget, FALSE, FALSE, 6);

    vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
    vbox1 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
    hbox1 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
    hbox2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
    hbox3 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);

    focus_mode_checkbutton = gtk_check_button_new_with_mnemonic (_("_Select windows when the mouse moves over them"));
    gtk_box_pack_start (GTK_BOX (vbox), focus_mode_checkbutton, FALSE, FALSE, 6);

    focus_mode_mouse_checkbutton = gtk_check_button_new_with_mnemonic (_("U_nselect windows when the mouse leaves them"));
    gtk_box_pack_start (GTK_BOX (hbox1), focus_mode_mouse_checkbutton, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 6);

    autoraise_checkbutton = gtk_check_button_new_with_mnemonic (_("_Raise selected windows after an interval"));
    gtk_box_pack_start (GTK_BOX (hbox2), autoraise_checkbutton, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (vbox1), hbox2, FALSE, FALSE, 6);

    autoraise_delay_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
    autoraise_delay_slider = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0, 10, 0.2);

    widget = gtk_label_new_with_mnemonic (_("_Interval before raising:"));
    gtk_box_pack_start (GTK_BOX (autoraise_delay_hbox), widget, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (autoraise_delay_hbox), autoraise_delay_slider, TRUE, TRUE, 6);
    gtk_label_set_mnemonic_widget (GTK_LABEL (widget), autoraise_delay_slider);
    widget = gtk_label_new (_("seconds"));
    gtk_range_set_increments (GTK_RANGE (autoraise_delay_slider), 0.2, 1.0);
    gtk_box_pack_start (GTK_BOX (autoraise_delay_hbox), widget, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (vbox1), autoraise_delay_hbox, FALSE, FALSE, 6);

    gtk_box_pack_start (GTK_BOX (hbox3), vbox1, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (vbox), hbox3, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (behaviour_vbox), hbox, FALSE, FALSE, 6);

    /* Titlebar Action */
    widget = title_label_new (N_("Titlebar Action"));
    gtk_box_pack_start (GTK_BOX (behaviour_vbox), widget, FALSE, FALSE, 6);

    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
    widget = gtk_label_new_with_mnemonic (_("_Double-click titlebar to perform this action:"));
    gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 6);
    double_click_titlebar_optionmenu = gtk_combo_box_text_new ();
    gtk_label_set_mnemonic_widget (GTK_LABEL (widget), double_click_titlebar_optionmenu);
    gtk_box_pack_start (GTK_BOX (hbox), double_click_titlebar_optionmenu, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (behaviour_vbox), hbox, FALSE, FALSE, 6);

    /* Movement Key */
    widget = title_label_new (N_("Movement Key"));
    gtk_box_pack_start (GTK_BOX (behaviour_vbox), widget, FALSE, FALSE, 6);

    vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);

    widget = gtk_label_new_with_mnemonic (_("To move a window, press-and-hold this key then grab the window:"));
#if GTK_CHECK_VERSION (3, 16, 0)
    gtk_label_set_xalign (GTK_LABEL (widget), 0.0);
    gtk_label_set_yalign (GTK_LABEL (widget), 0.0);
#else
    gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.0);
#endif
    gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 6);

    alt_click_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
    gtk_label_set_mnemonic_widget (GTK_LABEL (widget), alt_click_vbox);
    gtk_box_pack_start (GTK_BOX (vbox), alt_click_vbox, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 6);
    gtk_box_pack_start (GTK_BOX (behaviour_vbox), hbox, FALSE, FALSE, 6);

    reload_mouse_modifiers ();

    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (titlebar_layout_optionmenu), _("Right"));
    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (titlebar_layout_optionmenu), _("Left"));
    str = g_settings_get_string (marco_settings, MARCO_BUTTON_LAYOUT_KEY);
    gtk_combo_box_set_active (GTK_COMBO_BOX (titlebar_layout_optionmenu),
                              g_strcmp0 (str, MARCO_BUTTON_LAYOUT_RIGHT) == 0 ? 0 : 1);
    g_free (str);

    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (double_click_titlebar_optionmenu), _("Roll up"));
    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (double_click_titlebar_optionmenu), _("Maximize"));
    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (double_click_titlebar_optionmenu), _("Maximize Horizontally"));
    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (double_click_titlebar_optionmenu), _("Maximize Vertically"));
    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (double_click_titlebar_optionmenu), _("Minimize"));
    gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (double_click_titlebar_optionmenu), _("None"));
    gtk_combo_box_set_active (GTK_COMBO_BOX (double_click_titlebar_optionmenu),
                              g_settings_get_enum (marco_settings, MARCO_DOUBLE_CLICK_TITLEBAR_KEY));

    set_alt_click_value ();
    gtk_range_set_value (GTK_RANGE (autoraise_delay_slider),
                         g_settings_get_int (marco_settings, MARCO_AUTORAISE_DELAY_KEY) / 1000.0);
    gtk_combo_box_set_active (GTK_COMBO_BOX (double_click_titlebar_optionmenu),
                              g_settings_get_enum (marco_settings, MARCO_DOUBLE_CLICK_TITLEBAR_KEY));

    g_signal_connect (G_OBJECT (dialog_win), "response",
                      G_CALLBACK (response_cb), NULL);

    g_signal_connect (G_OBJECT (dialog_win), "destroy",
                      G_CALLBACK (gtk_main_quit), NULL);

    g_signal_connect (marco_settings, "changed",
                      G_CALLBACK (marco_settings_changed_callback), NULL);

    g_settings_bind (marco_settings,
                     MARCO_COMPOSITING_MANAGER_KEY,
                     compositing_checkbutton,
                     "active",
                     G_SETTINGS_BIND_DEFAULT);

    g_settings_bind (marco_settings,
                     MARCO_COMPOSITING_FAST_ALT_TAB_KEY,
                     compositing_fast_alt_tab_checkbutton,
                     "active",
                     G_SETTINGS_BIND_DEFAULT);

    g_settings_bind (marco_settings,
                     MARCO_SIDE_BY_SIDE_TILING_KEY,
                     side_by_side_tiling_checkbutton,
                     "active",
                     G_SETTINGS_BIND_DEFAULT);

    g_settings_bind (marco_settings,
                     MARCO_CENTER_NEW_WINDOWS_KEY,
                     center_new_windows_checkbutton,
                     "active",
                     G_SETTINGS_BIND_DEFAULT);

    g_signal_connect (marco_settings, "changed::" MARCO_FOCUS_KEY,
                      G_CALLBACK (mouse_focus_changed_callback), NULL);
    /* Initialize the checkbox state appropriately */
    mouse_focus_changed_callback(marco_settings, MARCO_FOCUS_KEY, NULL);

    g_signal_connect (focus_mode_checkbutton, "toggled",
                      G_CALLBACK (mouse_focus_toggled_callback), NULL);
    g_signal_connect (focus_mode_mouse_checkbutton, "toggled",
                      G_CALLBACK (mouse_focus_toggled_callback), NULL);

    g_settings_bind (marco_settings,
                     MARCO_AUTORAISE_KEY,
                     autoraise_checkbutton,
                     "active",
                     G_SETTINGS_BIND_DEFAULT);

    g_signal_connect (autoraise_delay_slider, "value_changed",
                      G_CALLBACK (autoraise_delay_value_changed_callback), NULL);

    g_signal_connect (double_click_titlebar_optionmenu, "changed",
                      G_CALLBACK (double_click_titlebar_changed_callback), NULL);

    g_signal_connect (titlebar_layout_optionmenu, "changed",
                      G_CALLBACK (titlebar_layout_changed_callback), NULL);

    g_signal_connect (G_OBJECT (screen), "window_manager_changed",
                      G_CALLBACK (wm_changed_callback), NULL);

    i = 0;
    while (i < n_mouse_modifiers) {
        g_signal_connect (G_OBJECT (mouse_modifiers[i].radio), "toggled",
                          G_CALLBACK (alt_click_radio_toggled_callback),
                          &mouse_modifiers[i]);
        ++i;
    }

    /* update sensitivity */
    update_sensitivity ();

    capplet_set_icon (dialog_win, "preferences-system-windows");
    content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog_win));
    gtk_box_pack_start (GTK_BOX (content_area), nb, TRUE, TRUE, 0);
    gtk_widget_show_all (dialog_win);

    gtk_main ();

    g_object_unref (marco_settings);

    return 0;
}
コード例 #22
0
ファイル: testtreeview.c プロジェクト: sam-m888/gtk
int
main (int    argc,
      char **argv)
{
  GtkWidget *window;
  GtkWidget *sw;
  GtkWidget *tv;
  GtkWidget *box;
  GtkWidget *combo_box;
  GtkTreeModel *model;
  GdkContentFormats *targets;
  gint i;
  
  gtk_init ();

  if (g_getenv ("RTL"))
    gtk_widget_set_default_direction (GTK_TEXT_DIR_RTL);

  our_pixbuf = gdk_pixbuf_new_from_xpm_data ((const char **) book_closed_xpm);  
  
#if 0
  models[MODEL_TYPES] = GTK_TREE_MODEL (gtk_tree_model_types_new ());
#endif
  models[MODEL_LIST] = create_list_model ();
  models[MODEL_TREE] = create_tree_model ();

  model = create_list_model ();
  models[MODEL_SORTED_LIST] = gtk_tree_model_sort_new_with_model (model);
  g_object_unref (model);

  model = create_tree_model ();
  models[MODEL_SORTED_TREE] = gtk_tree_model_sort_new_with_model (model);
  g_object_unref (model);

  models[MODEL_EMPTY_LIST] = GTK_TREE_MODEL (gtk_list_store_new (1, G_TYPE_INT));
  models[MODEL_EMPTY_TREE] = GTK_TREE_MODEL (gtk_tree_store_new (1, G_TYPE_INT));
  
  models[MODEL_NULL] = NULL;

  run_automated_tests ();
  
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
  gtk_window_set_default_size (GTK_WINDOW (window), 430, 400);

  box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);

  gtk_container_add (GTK_CONTAINER (window), box);

  tv = gtk_tree_view_new_with_model (models[0]);
  g_signal_connect (tv, "row-activated", G_CALLBACK (on_row_activated), NULL);

  targets = gdk_content_formats_new (row_targets, G_N_ELEMENTS (row_targets));
  gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (tv),
					  GDK_BUTTON1_MASK,
                                          targets,
					  GDK_ACTION_MOVE | GDK_ACTION_COPY);

  gtk_tree_view_enable_model_drag_dest (GTK_TREE_VIEW (tv),
                                        targets,
					GDK_ACTION_MOVE | GDK_ACTION_COPY);
  gdk_content_formats_unref (targets);
  
  /* Model menu */
  combo_box = gtk_combo_box_text_new ();
  gtk_widget_set_halign (combo_box, GTK_ALIGN_CENTER);
  for (i = 0; i < MODEL_LAST; i++)
      gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box), model_names[i]);

  gtk_container_add (GTK_CONTAINER (box), combo_box);
  g_signal_connect (combo_box,
                    "changed",
                    G_CALLBACK (model_selected),
		    tv);
  
  /* Columns menu */
  combo_box = gtk_combo_box_text_new ();
  gtk_widget_set_halign (combo_box, GTK_ALIGN_CENTER);
  for (i = 0; i < COLUMNS_LAST; i++)
      gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box), column_type_names[i]);

  gtk_container_add (GTK_CONTAINER (box), combo_box);

  set_columns_type (GTK_TREE_VIEW (tv), COLUMNS_LOTS);
  gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box), COLUMNS_LOTS);

  g_signal_connect (combo_box,
                    "changed",
                    G_CALLBACK (columns_selected),
                    tv);
  
  sw = gtk_scrolled_window_new (NULL, NULL);
  gtk_widget_set_hexpand (sw, TRUE);
  gtk_widget_set_vexpand (sw, TRUE);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
                                  GTK_POLICY_AUTOMATIC,
                                  GTK_POLICY_AUTOMATIC);
  
  gtk_container_add (GTK_CONTAINER (box), sw);
  
  gtk_container_add (GTK_CONTAINER (sw), tv);
  
  gtk_widget_show (window);
  
  gtk_main ();

  return 0;
}
コード例 #23
0
ファイル: levels.c プロジェクト: christte/darktable
void gui_init(dt_iop_module_t *self)
{
  self->gui_data = malloc(sizeof(dt_iop_levels_gui_data_t));
  dt_iop_levels_gui_data_t *c = (dt_iop_levels_gui_data_t *)self->gui_data;
  dt_iop_levels_params_t *p = (dt_iop_levels_params_t *)self->params;

  dt_pthread_mutex_init(&c->lock, NULL);

  dt_pthread_mutex_lock(&c->lock);
  c->auto_levels[0] = NAN;
  c->auto_levels[1] = NAN;
  c->auto_levels[2] = NAN;
  c->hash = 0;
  dt_pthread_mutex_unlock(&c->lock);

  c->modes = NULL;

  c->mouse_x = c->mouse_y = -1.0;
  c->dragging = 0;
  c->activeToggleButton = NULL;
  c->last_picked_color = -1;
  self->widget = GTK_WIDGET(gtk_box_new(GTK_ORIENTATION_VERTICAL, 5));
  dt_gui_add_help_link(self->widget, dt_get_help_url(self->op));

  c->mode = dt_bauhaus_combobox_new(self);
  dt_bauhaus_widget_set_label(c->mode, NULL, _("mode"));

  dt_bauhaus_combobox_add(c->mode, C_("mode", "manual"));
  c->modes = g_list_append(c->modes, GUINT_TO_POINTER(LEVELS_MODE_MANUAL));

  dt_bauhaus_combobox_add(c->mode, _("automatic"));
  c->modes = g_list_append(c->modes, GUINT_TO_POINTER(LEVELS_MODE_AUTOMATIC));

  dt_bauhaus_combobox_set_default(c->mode, LEVELS_MODE_MANUAL);
  dt_bauhaus_combobox_set(c->mode, g_list_index(c->modes, GUINT_TO_POINTER(p->mode)));
  gtk_box_pack_start(GTK_BOX(self->widget), c->mode, TRUE, TRUE, 0);

  c->mode_stack = gtk_stack_new();
  gtk_stack_set_homogeneous(GTK_STACK(c->mode_stack),FALSE);
  gtk_box_pack_start(GTK_BOX(self->widget), c->mode_stack, TRUE, TRUE, 0);

  c->area = GTK_DRAWING_AREA(dtgtk_drawing_area_new_with_aspect_ratio(9.0 / 16.0));
  GtkWidget *vbox_manual = GTK_WIDGET(gtk_box_new(GTK_ORIENTATION_VERTICAL, 5));
  gtk_box_pack_start(GTK_BOX(vbox_manual), GTK_WIDGET(c->area), TRUE, TRUE, 0);

  gtk_widget_set_tooltip_text(GTK_WIDGET(c->area),_("drag handles to set black, gray, and white points. "
                                                    "operates on L channel."));

  gtk_widget_add_events(GTK_WIDGET(c->area), GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK
                                             | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
                                             | GDK_LEAVE_NOTIFY_MASK | darktable.gui->scroll_mask);
  g_signal_connect(G_OBJECT(c->area), "draw", G_CALLBACK(dt_iop_levels_area_draw), self);
  g_signal_connect(G_OBJECT(c->area), "button-press-event", G_CALLBACK(dt_iop_levels_button_press), self);
  g_signal_connect(G_OBJECT(c->area), "button-release-event", G_CALLBACK(dt_iop_levels_button_release), self);
  g_signal_connect(G_OBJECT(c->area), "motion-notify-event", G_CALLBACK(dt_iop_levels_motion_notify), self);
  g_signal_connect(G_OBJECT(c->area), "leave-notify-event", G_CALLBACK(dt_iop_levels_leave_notify), self);
  g_signal_connect(G_OBJECT(c->area), "scroll-event", G_CALLBACK(dt_iop_levels_scroll), self);

  GtkWidget *autobutton = gtk_button_new_with_label(_("auto"));
  gtk_widget_set_tooltip_text(autobutton, _("apply auto levels"));
  gtk_widget_set_size_request(autobutton, -1, DT_PIXEL_APPLY_DPI(24));

  c->blackpick = dtgtk_togglebutton_new(dtgtk_cairo_paint_colorpicker, CPF_STYLE_FLAT, NULL);
  gtk_widget_set_tooltip_text(c->blackpick, _("pick black point from image"));

  c->greypick = dtgtk_togglebutton_new(dtgtk_cairo_paint_colorpicker, CPF_STYLE_FLAT, NULL);
  gtk_widget_set_tooltip_text(c->greypick, _("pick medium gray point from image"));

  c->whitepick = dtgtk_togglebutton_new(dtgtk_cairo_paint_colorpicker, CPF_STYLE_FLAT, NULL);
  gtk_widget_set_tooltip_text(c->whitepick, _("pick white point from image"));

  GdkRGBA color = { 0 };
  color.alpha = 1.0;
  dtgtk_togglebutton_override_color(DTGTK_TOGGLEBUTTON(c->blackpick), &color);
  color.red = color.green = color.blue = 0.5;
  dtgtk_togglebutton_override_color(DTGTK_TOGGLEBUTTON(c->greypick), &color);
  color.red = color.green = color.blue = 1.0;
  dtgtk_togglebutton_override_color(DTGTK_TOGGLEBUTTON(c->whitepick), &color);

  GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, DT_PIXEL_APPLY_DPI(10));
  gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(autobutton), TRUE, TRUE, 0);
  gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(c->blackpick), TRUE, TRUE, 0);
  gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(c->greypick), TRUE, TRUE, 0);
  gtk_box_pack_end(GTK_BOX(box), GTK_WIDGET(c->whitepick), TRUE, TRUE, 0);

  gtk_box_pack_start(GTK_BOX(vbox_manual), box, TRUE, TRUE, 0);

  gtk_widget_show_all(vbox_manual);
  gtk_stack_add_named(GTK_STACK(c->mode_stack), vbox_manual, "manual");

  c->percentile_black = dt_bauhaus_slider_new_with_range(self, 0.0f, 100.0f, .1f, p->percentiles[0], 3);
  gtk_widget_set_tooltip_text(c->percentile_black, _("black percentile"));
  dt_bauhaus_slider_set_format(c->percentile_black, "%.1f%%");
  dt_bauhaus_widget_set_label(c->percentile_black, NULL, _("black"));

  c->percentile_grey = dt_bauhaus_slider_new_with_range(self, 0.0f, 100.0f, .1f, p->percentiles[1], 3);
  gtk_widget_set_tooltip_text(c->percentile_grey, _("gray percentile"));
  dt_bauhaus_slider_set_format(c->percentile_grey, "%.1f%%");
  dt_bauhaus_widget_set_label(c->percentile_grey, NULL, _("gray"));

  c->percentile_white = dt_bauhaus_slider_new_with_range(self, 0.0f, 100.0f, .1f, p->percentiles[2], 3);
  gtk_widget_set_tooltip_text(c->percentile_white, _("white percentile"));
  dt_bauhaus_slider_set_format(c->percentile_white, "%.1f%%");
  dt_bauhaus_widget_set_label(c->percentile_white, NULL, _("white"));

  GtkWidget *vbox_automatic = GTK_WIDGET(gtk_box_new(GTK_ORIENTATION_VERTICAL, 5));
  gtk_box_pack_start(GTK_BOX(vbox_automatic), GTK_WIDGET(c->percentile_black), FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(vbox_automatic), GTK_WIDGET(c->percentile_grey), FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(vbox_automatic), GTK_WIDGET(c->percentile_white), FALSE, FALSE, 0);

  gtk_widget_show_all(vbox_automatic);
  gtk_stack_add_named(GTK_STACK(c->mode_stack), vbox_automatic, "automatic");

  switch(p->mode)
  {
    case LEVELS_MODE_AUTOMATIC:
      gtk_stack_set_visible_child_name(GTK_STACK(c->mode_stack), "automatic");
      break;
    case LEVELS_MODE_MANUAL:
    default:
      gtk_stack_set_visible_child_name(GTK_STACK(c->mode_stack), "manual");
      break;
  }

  g_signal_connect(G_OBJECT(c->mode), "value-changed", G_CALLBACK(dt_iop_levels_mode_callback), self);
  g_signal_connect(G_OBJECT(c->percentile_black), "value-changed",
                   G_CALLBACK(dt_iop_levels_percentiles_callback), self);
  g_signal_connect(G_OBJECT(c->percentile_grey), "value-changed",
                   G_CALLBACK(dt_iop_levels_percentiles_callback), self);
  g_signal_connect(G_OBJECT(c->percentile_white), "value-changed",
                   G_CALLBACK(dt_iop_levels_percentiles_callback), self);

  g_signal_connect(G_OBJECT(autobutton), "clicked", G_CALLBACK(dt_iop_levels_autoadjust_callback),
                   (gpointer)self);
  g_signal_connect(G_OBJECT(c->blackpick), "toggled", G_CALLBACK(dt_iop_color_picker_callback), &c->color_picker);
  g_signal_connect(G_OBJECT(c->greypick), "toggled", G_CALLBACK(dt_iop_color_picker_callback), &c->color_picker);
  g_signal_connect(G_OBJECT(c->whitepick), "toggled", G_CALLBACK(dt_iop_color_picker_callback), &c->color_picker);

  dt_iop_init_picker(&c->color_picker, self, DT_COLOR_PICKER_POINT, _iop_color_picker_get_set,
                     _iop_color_picker_apply, _iop_color_picker_update);
}
コード例 #24
0
ファイル: form_data_layout.c プロジェクト: GNOME/libgda
GtkWidget *
do_form_data_layout (GtkWidget *do_widget)
{  
	if (!window) {
		GdaStatement *stmt;
		GtkWidget *vbox;
		GtkWidget *label;
		GdaDataModel *model;
		GtkWidget *form;
		GdauiRawForm *raw_form;
		
		window = gtk_dialog_new_with_buttons ("Form with custom data layout",
						      GTK_WINDOW (do_widget),
						      0,
						      "Close", GTK_RESPONSE_NONE,
						      NULL);
		
		g_signal_connect (window, "response",
				  G_CALLBACK (gtk_widget_destroy), NULL);
		g_signal_connect (window, "destroy",
				  G_CALLBACK (gtk_widget_destroyed), &window);
		
		vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
		gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (window))),
				    vbox, TRUE, TRUE, 0);
		gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
		
		label = gtk_label_new ("The following GdauiForm widget displays information about customers,\n"
				       "using a paned container where the right part is used to display\n"
				       "a picture of the customer.\n");
		gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
		
		/* Create the demo widget: select all the customers and computes the total
		 * amount of orders they have spent */
		stmt = gda_sql_parser_parse_string (demo_parser, 
						    "select c.id, c.name, c.country, c.city, c.photo, c.comments, sum (od.quantity * (1 - od.discount/100) * p.price) as total_orders from customers c left join orders o on (c.id=o.customer) left join order_contents od on (od.order_id=o.id) left join products p on (p.ref = od.product_ref) group by c.id order by total_orders desc",
						    NULL, NULL);
		model = gda_connection_statement_execute_select (demo_cnc, stmt, NULL, NULL);
		g_object_unref (stmt);
		form = gdaui_form_new (model);
		g_object_unref (model);

		/* hide the ID data entry */
		g_object_get (G_OBJECT (form), "raw-form", &raw_form, NULL);
		gdaui_basic_form_entry_set_visible (GDAUI_BASIC_FORM (raw_form),
						    gda_set_get_holder (gdaui_basic_form_get_data_set (GDAUI_BASIC_FORM (raw_form)),
									"id"), FALSE);

		/* request custom layout:
		   <gdaui_form name="customers" container="hpaned">
		     <gdaui_section title="Summary">
		       <gdaui_column>
		         <gdaui_entry name="id"/>
			 <gdaui_entry name="name" label="Customer name"/>
			 <gdaui_entry name="comments" label="Comments" plugin="text"/>
			 <gdaui_entry name="total_orders" label="Total ordered" plugin="number:NB_DECIMALS=2;CURRENCY=€"/>
		       </gdaui_column>
		     </gdaui_section>
		     <gdaui_section title="Photo">
		       <gdaui_column>
		         <gdaui_entry name="photo" plugin="picture"/>
		       </gdaui_column>
		     </gdaui_section>
		   </gdaui_form>
		 */
		gchar *filename;
		filename = demo_find_file ("custom_layout.xml", NULL);
		gdaui_basic_form_set_layout_from_file (GDAUI_BASIC_FORM (raw_form), filename, "customers");
		g_free (filename);

		/* we don't need the raw_form's reference anymore */
		g_object_unref (G_OBJECT (raw_form));

		gtk_box_pack_start (GTK_BOX (vbox), form, TRUE, TRUE, 0);
	}

	gboolean visible;
	g_object_get (G_OBJECT (window), "visible", &visible, NULL);
	if (!visible)
		gtk_widget_show_all (window);
	else {
		gtk_widget_destroy (window);
		window = NULL;
	}

	return window;
}
コード例 #25
0
ファイル: notebook.cpp プロジェクト: CodeSmithyIDE/wxWidgets
bool wxNotebook::InsertPage( size_t position,
                             wxNotebookPage* win,
                             const wxString& text,
                             bool select,
                             int imageId )
{
    wxCHECK_MSG( m_widget != NULL, false, wxT("invalid notebook") );

    wxCHECK_MSG( win->GetParent() == this, false,
               wxT("Can't add a page whose parent is not the notebook!") );

    wxCHECK_MSG( position <= GetPageCount(), false,
                 wxT("invalid page index in wxNotebookPage::InsertPage()") );

    // Hack Alert! (Part II): See above in wxNotebook::AddChildGTK
    // why this has to be done.
    gtk_widget_unparent(win->m_widget);

    if (m_themeEnabled)
        win->SetThemeEnabled(true);

    GtkNotebook *notebook = GTK_NOTEBOOK(m_widget);

    wxGtkNotebookPage* pageData = new wxGtkNotebookPage;

    m_pages.insert(m_pages.begin() + position, win);
    m_pagesData.Insert(position, pageData);

    // set the label image and text
    // this must be done before adding the page, as GetPageText
    // and GetPageImage will otherwise return wrong values in
    // the page-changed event that results from inserting the
    // first page.
    pageData->m_imageIndex = imageId;

    pageData->m_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 1);
#ifndef __WXGTK3__
    gtk_container_set_border_width(GTK_CONTAINER(pageData->m_box), 2);
#endif

    pageData->m_image = NULL;
    if (imageId != -1)
    {
        if (HasImageList())
        {
            const wxBitmap bitmap = GetImageList()->GetBitmap(imageId);
            pageData->m_image = gtk_image_new_from_pixbuf(bitmap.GetPixbuf());
            gtk_box_pack_start(GTK_BOX(pageData->m_box),
                pageData->m_image, false, false, m_padding);
        }
        else
        {
            wxFAIL_MSG("invalid notebook imagelist");
        }
    }

    /* set the label text */
    pageData->m_label = gtk_label_new(wxGTK_CONV(wxStripMenuCodes(text)));
    gtk_box_pack_end(GTK_BOX(pageData->m_box),
        pageData->m_label, false, false, m_padding);

    gtk_widget_show_all(pageData->m_box);
    gtk_notebook_insert_page(notebook, win->m_widget, pageData->m_box, position);

    /* apply current style */
#ifdef __WXGTK3__
    GTKApplyStyle(pageData->m_label, NULL);
#else
    GtkRcStyle *style = GTKCreateWidgetStyle();
    if ( style )
    {
        gtk_widget_modify_style(pageData->m_label, style);
        g_object_unref(style);
    }
#endif

    if (select && GetPageCount() > 1)
    {
        SetSelection( position );
    }

    InvalidateBestSize();
    return true;
}
コード例 #26
0
ファイル: googlephoto.c プロジェクト: TurboGit/darktable
/* construct widget above */
void gui_init(struct dt_imageio_module_storage_t *self)
{
  self->gui_data = g_malloc0(sizeof(dt_storage_gphoto_gui_data_t));
  dt_storage_gphoto_gui_data_t *ui = self->gui_data;
  ui->gphoto_api = gphoto_api_init();

  self->widget = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);

  // create labels
  ui->label_album_title = GTK_LABEL(gtk_label_new(_("title")));
  ui->label_status = GTK_LABEL(gtk_label_new(NULL));

  gtk_widget_set_halign(GTK_WIDGET(ui->label_album_title), GTK_ALIGN_START);

  // create entries
  GtkListStore *model_username
      = gtk_list_store_new(COMBO_USER_MODEL_NB_COL, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
                           G_TYPE_STRING); // text, token, refresh_token, id
  ui->combo_username = GTK_COMBO_BOX(gtk_combo_box_new_with_model(GTK_TREE_MODEL(model_username)));
  GtkCellRenderer *p_cell = gtk_cell_renderer_text_new();
  g_object_set(G_OBJECT(p_cell), "ellipsize", PANGO_ELLIPSIZE_MIDDLE, "ellipsize-set", TRUE, "width-chars", 35,
               (gchar *)0);
  gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(ui->combo_username), p_cell, FALSE);
  gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(ui->combo_username), p_cell, "text", 0, NULL);

  ui->entry_album_title = GTK_ENTRY(gtk_entry_new());

  dt_gui_key_accel_block_on_focus_connect(GTK_WIDGET(ui->combo_username));
  dt_gui_key_accel_block_on_focus_connect(GTK_WIDGET(ui->entry_album_title));

  // retrieve saved accounts
  ui_refresh_users(ui);

  //////// album list /////////
  GtkWidget *albumlist = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
  GtkListStore *model_album
      = gtk_list_store_new(COMBO_ALBUM_MODEL_NB_COL, G_TYPE_STRING, G_TYPE_STRING); // name, id
  ui->combo_album = GTK_COMBO_BOX(gtk_combo_box_new_with_model(GTK_TREE_MODEL(model_album)));
  p_cell = gtk_cell_renderer_text_new();
  g_object_set(G_OBJECT(p_cell), "ellipsize", PANGO_ELLIPSIZE_MIDDLE, "ellipsize-set", TRUE, "width-chars", 35,
               (gchar *)0);
  gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(ui->combo_album), p_cell, FALSE);
  gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(ui->combo_album), p_cell, "text", 0, NULL);

  gtk_widget_set_sensitive(GTK_WIDGET(ui->combo_album), FALSE);
  gtk_combo_box_set_row_separator_func(ui->combo_album, combobox_separator, ui->combo_album, NULL);
  gtk_box_pack_start(GTK_BOX(albumlist), GTK_WIDGET(ui->combo_album), TRUE, TRUE, 0);

  ui->button_login = GTK_BUTTON(gtk_button_new_with_label(_("login")));
  ui->connected = FALSE;

  // pack the ui
  ////the auth box
  GtkWidget *hbox_auth = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5);
  GtkWidget *vbox_auth_labels = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
  GtkWidget *vbox_auth_fields = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
  gtk_box_pack_start(GTK_BOX(hbox_auth), vbox_auth_labels, FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(hbox_auth), vbox_auth_fields, TRUE, TRUE, 0);
  gtk_box_pack_start(GTK_BOX(self->widget), GTK_WIDGET(hbox_auth), TRUE, FALSE, 2);
  gtk_box_pack_start(GTK_BOX(vbox_auth_fields), GTK_WIDGET(ui->combo_username), TRUE, FALSE, 2);

  gtk_box_pack_start(GTK_BOX(vbox_auth_labels), GTK_WIDGET(gtk_label_new("")), TRUE, TRUE, 2);
  gtk_box_pack_start(GTK_BOX(vbox_auth_fields), GTK_WIDGET(ui->button_login), TRUE, FALSE, 2);

  gtk_box_pack_start(GTK_BOX(vbox_auth_fields), GTK_WIDGET(albumlist), TRUE, FALSE, 2);

  ////the album creation box
  ui->hbox_album = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5));
  gtk_widget_set_no_show_all(GTK_WIDGET(ui->hbox_album), TRUE); // hide it by default
  GtkWidget *vbox_album_labels = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
  GtkWidget *vbox_album_fields = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
  gtk_box_pack_start(GTK_BOX(self->widget), GTK_WIDGET(ui->hbox_album), TRUE, FALSE, 5);
  gtk_box_pack_start(GTK_BOX(ui->hbox_album), vbox_album_labels, FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(ui->hbox_album), vbox_album_fields, TRUE, TRUE, 0);
  gtk_box_pack_start(GTK_BOX(vbox_album_labels), GTK_WIDGET(ui->label_album_title), TRUE, TRUE, 0);
  gtk_box_pack_start(GTK_BOX(vbox_album_fields), GTK_WIDGET(ui->entry_album_title), TRUE, FALSE, 0);

  // connect buttons to signals
  g_signal_connect(G_OBJECT(ui->button_login), "clicked", G_CALLBACK(ui_login_clicked), (gpointer)ui);
  g_signal_connect(G_OBJECT(ui->combo_username), "changed", G_CALLBACK(ui_combo_username_changed),
                   (gpointer)ui);
  g_signal_connect(G_OBJECT(ui->combo_album), "changed", G_CALLBACK(ui_combo_album_changed), (gpointer)ui);

  g_object_unref(model_username);
  g_object_unref(model_album);
}
コード例 #27
0
static void _camera_import_dialog_new(_camera_import_dialog_t *data)
{
  data->dialog = gtk_dialog_new_with_buttons(_("import images from camera"), NULL, GTK_DIALOG_MODAL,
                                             _("cancel"), GTK_RESPONSE_NONE, C_("camera import", "import"),
                                             GTK_RESPONSE_ACCEPT, NULL);
  gtk_window_set_default_size(GTK_WINDOW(data->dialog), 100, 600);
  GtkWidget *content = gtk_dialog_get_content_area(GTK_DIALOG(data->dialog));

  // List - setup store
  data->store = gtk_list_store_new(2, GDK_TYPE_PIXBUF, G_TYPE_STRING);

  // IMPORT PAGE
  data->import.page = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5);
  gtk_container_set_border_width(GTK_CONTAINER(data->import.page), 5);

  // Top info
  data->import.info = gtk_label_new(_("please wait while prefetching thumbnails of images from camera..."));
  gtk_label_set_single_line_mode(GTK_LABEL(data->import.info), FALSE);
  gtk_widget_set_halign(data->import.info, GTK_ALIGN_START);
  gtk_box_pack_start(GTK_BOX(data->import.page), data->import.info, FALSE, FALSE, 0);

  // jobcode
  data->import.jobname
      = _camera_import_gconf_widget(data, _("jobcode"), "plugins/capture/camera/import/jobcode");
  gtk_box_pack_start(GTK_BOX(data->import.page), GTK_WIDGET(data->import.jobname->widget), FALSE, FALSE, 0);


  // Create the treview with list model data store
  data->import.treeview = gtk_scrolled_window_new(NULL, NULL);
  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(data->import.treeview), GTK_POLICY_NEVER,
                                 GTK_POLICY_ALWAYS);

  gtk_container_add(GTK_CONTAINER(data->import.treeview), gtk_tree_view_new());
  GtkTreeView *treeview = GTK_TREE_VIEW(gtk_bin_get_child(GTK_BIN(data->import.treeview)));

  GtkCellRenderer *renderer = gtk_cell_renderer_pixbuf_new();
  GtkTreeViewColumn *column
      = gtk_tree_view_column_new_with_attributes(_("thumbnail"), renderer, "pixbuf", 0, (char *)NULL);
  gtk_tree_view_append_column(treeview, column);

  renderer = gtk_cell_renderer_text_new();
  column = gtk_tree_view_column_new_with_attributes(_("storage file"), renderer, "text", 1, (char *)NULL);
  gtk_tree_view_append_column(treeview, column);
  gtk_tree_view_column_set_expand(column, TRUE);


  GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview);
  gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE);

  gtk_tree_view_set_model(treeview, GTK_TREE_MODEL(data->store));
  gtk_tree_view_set_headers_visible(treeview, FALSE);

  gtk_box_pack_start(GTK_BOX(data->import.page), data->import.treeview, TRUE, TRUE, 0);


  // SETTINGS PAGE
  data->settings.page = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5);
  gtk_container_set_border_width(GTK_CONTAINER(data->settings.page), 5);

  // general settings
  gtk_box_pack_start(GTK_BOX(data->settings.page), gtk_label_new(_("general")), FALSE, FALSE, 0);

  // ignoring of jpegs. hack while we don't handle raw+jpeg in the same directories.
  data->settings.general.ignore_jpeg = gtk_check_button_new_with_label(_("ignore JPEG files"));
  g_object_set(data->settings.general.ignore_jpeg, "tooltip-text",
               _("do not load files with an extension of .jpg or .jpeg. this can be useful when there are "
                 "raw+JPEG in a directory."),
               NULL);
  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(data->settings.general.ignore_jpeg),
                               dt_conf_get_bool("ui_last/import_ignore_jpegs"));
  gtk_box_pack_start(GTK_BOX(data->settings.page), data->settings.general.ignore_jpeg, FALSE, FALSE, 0);
  g_signal_connect(G_OBJECT(data->settings.general.ignore_jpeg), "clicked",
                   G_CALLBACK(_check_button_callback), data);

  GtkWidget *hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5);
  data->settings.general.date_override = gtk_check_button_new_with_label(_("override today's date"));
  gtk_box_pack_start(GTK_BOX(hbox), data->settings.general.date_override, FALSE, FALSE, 0);
  g_object_set(data->settings.general.date_override, "tooltip-text",
               _("check this, if you want to override the timestamp used when expanding variables:\n$(YEAR), "
                 "$(MONTH), $(DAY),\n$(HOUR), $(MINUTE), $(SECONDS)"),
               (char *)NULL);

  data->settings.general.date_entry = gtk_entry_new();
  gtk_widget_set_sensitive(data->settings.general.date_entry, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
                                                                  data->settings.general.date_override)));
  gtk_box_pack_start(GTK_BOX(hbox), data->settings.general.date_entry, TRUE, TRUE, 0);

  g_signal_connect(G_OBJECT(data->settings.general.date_override), "clicked",
                   G_CALLBACK(_check_button_callback), data);

  gtk_box_pack_start(GTK_BOX(data->settings.page), hbox, FALSE, FALSE, 0);


  // THE NOTEBOOK
  data->notebook = gtk_notebook_new();
  gtk_notebook_append_page(GTK_NOTEBOOK(data->notebook), data->import.page, gtk_label_new(_("images")));
  gtk_notebook_append_page(GTK_NOTEBOOK(data->notebook), data->settings.page, gtk_label_new(_("settings")));

  // end
  gtk_box_pack_start(GTK_BOX(content), data->notebook, TRUE, TRUE, 0);
  // gtk_widget_set_size_request(content, DT_PIXEL_APPLY_DPI(400), DT_PIXEL_APPLY_DPI(400));
}
コード例 #28
0
ファイル: googlephoto.c プロジェクト: TurboGit/darktable
/**
 * @see https://developers.google.com/accounts/docs/OAuth2InstalledApp
 * @returns NULL if the user cancels the operation or a valid token
 */
static int gphoto_get_user_auth_token(dt_storage_gphoto_gui_data_t *ui)
{
  ///////////// open the authentication url in a browser
  GError *error = NULL;
  gchar *params = NULL;
  params = dt_util_dstrcat(params,
                           GOOGLE_WS_BASE_URL
                           "o/oauth2/v2/auth?"
                           "client_id=%s&redirect_uri=urn:ietf:wg:oauth:2.0:oob"
                           "&scope=" GOOGLE_API_BASE_URL "auth/photoslibrary "
                           GOOGLE_API_BASE_URL "auth/userinfo.profile "
                           GOOGLE_API_BASE_URL "auth/userinfo.email"
                           "&response_type=code&access_type=offline",
                           ui->gphoto_api->google_client_id);

  if(!gtk_show_uri(gdk_screen_get_default(), params, gtk_get_current_event_time(), &error))
  {
    fprintf(stderr, "[gphoto] error opening browser: %s\n", error->message);
    g_error_free(error);
  }

  ////////////// build & show the validation dialog
  const gchar *text1 = _("step 1: a new window or tab of your browser should have been "
                         "loaded. you have to login into your google account there "
                         "and authorize darktable to upload photos before continuing.");
  const gchar *text2 = _("step 2: paste the verification code shown to you in the browser "
                         "and click the OK button once you are done.");

  GtkWidget *window = dt_ui_main_window(darktable.gui->ui);
  GtkDialog *gphoto_auth_dialog = GTK_DIALOG(
      gtk_message_dialog_new(GTK_WINDOW(window), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION,
                             GTK_BUTTONS_OK_CANCEL, _("google authentication")));
#ifdef GDK_WINDOWING_QUARTZ
  dt_osx_disallow_fullscreen(GTK_WIDGET(gphoto_auth_dialog));
#endif
  gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(gphoto_auth_dialog), "%s\n\n%s", text1, text2);

  GtkWidget *entry = gtk_entry_new();
  GtkWidget *hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5);
  gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(gtk_label_new(_("verification code:"))), FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(entry), TRUE, TRUE, 0);

  GtkWidget *gphotoauthdialog_vbox
      = gtk_message_dialog_get_message_area(GTK_MESSAGE_DIALOG(gphoto_auth_dialog));
  gtk_box_pack_end(GTK_BOX(gphotoauthdialog_vbox), hbox, TRUE, TRUE, 0);

  gtk_widget_show_all(GTK_WIDGET(gphoto_auth_dialog));

  ////////////// wait for the user to enter the verification code
  gint result;
  gchar *token = NULL;
  const char *replycode;
  while(TRUE)
  {
    result = gtk_dialog_run(GTK_DIALOG(gphoto_auth_dialog));
    if(result == GTK_RESPONSE_CANCEL) break;
    replycode = gtk_entry_get_text(GTK_ENTRY(entry));
    if(replycode == NULL || g_strcmp0(replycode, "") == 0)
    {
      gtk_message_dialog_format_secondary_markup(GTK_MESSAGE_DIALOG(gphoto_auth_dialog),
                                                 "%s\n\n%s\n\n<span foreground=\"" MSGCOLOR_RED
                                                 "\" ><small>%s</small></span>",
                                                 text1, text2, _("please enter the verification code"));
      continue;
    }
    else
    {
      token = g_strdup(replycode);
      break;
    }
  }
  gtk_widget_destroy(GTK_WIDGET(gphoto_auth_dialog));
  g_free(params);

  if(result == GTK_RESPONSE_CANCEL)
    return 1;

  // Interchange now the authorization_code for an access_token and refresh_token
  JsonObject *reply;

  params = NULL;
  params = dt_util_dstrcat(params, "code=%s&client_id=%s&client_secret=%s"
                           "&redirect_uri=" GOOGLE_URI "&grant_type=authorization_code",
                           token, ui->gphoto_api->google_client_id, ui->gphoto_api->google_client_secret);

  g_free(token);

  reply = gphoto_query_post_auth(ui->gphoto_api, GOOGLE_WS_BASE_URL "o/oauth2/token", params);

  gchar *access_token = g_strdup(json_object_get_string_member(reply, "access_token"));

  gchar *refresh_token = g_strdup(json_object_get_string_member(reply, "refresh_token"));

  ui->gphoto_api->token = access_token;
  ui->gphoto_api->refresh_token = refresh_token;

  g_free(params);

  return 0; // FIXME
}
コード例 #29
0
ファイル: table-preferences.c プロジェクト: zzeroo/libgda
static GtkWidget *
create_column_properties (TablePreferences *tpref)
{
	GtkWidget *combo, *label, *grid;
	GtkCellRenderer *renderer;

	grid = gtk_grid_new ();
	gtk_grid_set_row_spacing (GTK_GRID (grid), 5);
	gtk_grid_set_column_spacing (GTK_GRID (grid), 5);

	/* plugins combo */
	tpref->priv->plugins_model = GTK_TREE_MODEL (gtk_list_store_new (PL_NUM_COLUMNS,
									 G_TYPE_POINTER, G_TYPE_STRING));
	ForeachData data;
	data.type = 0;
	data.store = GTK_LIST_STORE (tpref->priv->plugins_model);
	g_hash_table_foreach (gdaui_plugins_hash, (GHFunc) plugin_hash_foreach_func, &data);

	combo = gtk_combo_box_new_with_model (tpref->priv->plugins_model);
	gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);
	tpref->priv->plugins_combo = combo;
	renderer = gtk_cell_renderer_text_new ();
	gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, FALSE);
	gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer,
					"text", PL_COLUMN_DESCR, 
					NULL);
	g_signal_connect (G_OBJECT (combo), "changed",
			  G_CALLBACK (plugins_combo_changed_cb), tpref);

	gtk_grid_attach (GTK_GRID (grid), combo, 1, 0, 1, 1);
	
	label = gtk_label_new (_("Data entry type:"));
	gtk_widget_set_tooltip_text (label, _("Defines how data for the selected column\n"
					      "will be displayed in forms. Leave 'Default' to have\n"
					      "the default display"));
	gtk_widget_set_halign (label, GTK_ALIGN_START);
	gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 1);
	
	/* plugin options */
	tpref->priv->options_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	gtk_grid_attach (GTK_GRID (grid), tpref->priv->options_vbox, 1, 1, 1, 1);
	tpref->priv->options_none = gtk_label_new (_("none"));
	gtk_widget_set_halign (tpref->priv->options_none, GTK_ALIGN_START);
	gtk_box_pack_start (GTK_BOX (tpref->priv->options_vbox), tpref->priv->options_none, FALSE, FALSE, 0);

	label = gtk_label_new (_("Options:"));
	gtk_widget_set_halign (label, GTK_ALIGN_START);
	gtk_grid_attach (GTK_GRID (grid), label, 0, 1, 1, 1);

	/* plugin preview */
	tpref->priv->preview_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	gtk_grid_attach (GTK_GRID (grid), tpref->priv->preview_vbox, 1, 2, 1, 1);
	tpref->priv->preview_none = gtk_label_new (_("none"));
	gtk_widget_set_halign (tpref->priv->preview_none, GTK_ALIGN_START);
	gtk_box_pack_start (GTK_BOX (tpref->priv->preview_vbox), tpref->priv->preview_none, FALSE, FALSE, 0);

	label = gtk_label_new (_("Preview:"));
	gtk_widget_set_tooltip_text (label, _("Free form to test the configured\n"
					      "data entry"));
	gtk_widget_set_halign (label, GTK_ALIGN_START);
	gtk_grid_attach (GTK_GRID (grid), label, 0, 2, 1, 1);

	gtk_widget_show_all (grid);

	return grid;
}
コード例 #30
0
void
procdialog_create_preferences_dialog (ProcData *procdata)
{
    static GtkWidget *dialog = NULL;

    typedef SpinButtonUpdater SBU;

    static SBU interval_updater("update-interval");
    static SBU graph_interval_updater("graph-update-interval");
    static SBU disks_interval_updater("disks-interval");

    GtkWidget *notebook;
    GtkWidget *proc_box;
    GtkWidget *sys_box;
    GtkWidget *main_vbox;
    GtkWidget *vbox, *vbox2, *vbox3;
    GtkWidget *hbox, *hbox2, *hbox3;
    GtkWidget *label;
    GtkAdjustment *adjustment;
    GtkWidget *spin_button;
    GtkWidget *check_button;
    GtkWidget *tab_label;
    GtkWidget *smooth_button;
    GtkSizeGroup *size;
    gfloat update;
    gchar *tmp;

    if (prefs_dialog)
        return;

    size = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);

    dialog = gtk_dialog_new_with_buttons (_("System Monitor Preferences"),
                                          GTK_WINDOW (procdata->app),
                                          GTK_DIALOG_DESTROY_WITH_PARENT,
                                          "gtk-help", GTK_RESPONSE_HELP,
                                          "gtk-close", GTK_RESPONSE_CLOSE,
                                          NULL);
    /* FIXME: we should not declare the window size, but let it's   */
    /* driven by window childs. The problem is that the fields list */
    /* have to show at least 4 items to respect HIG. I don't know   */
    /* any function to set list height by contents/items inside it. */
    gtk_window_set_default_size (GTK_WINDOW (dialog), 400, 500);
    gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
    prefs_dialog = dialog;

    main_vbox = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
    gtk_box_set_spacing (GTK_BOX (main_vbox), 2);

    notebook = gtk_notebook_new ();
    gtk_container_set_border_width (GTK_CONTAINER (notebook), 5);
    gtk_box_pack_start (GTK_BOX (main_vbox), notebook, TRUE, TRUE, 0);

    proc_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 18);
    gtk_container_set_border_width (GTK_CONTAINER (proc_box), 12);
    tab_label = gtk_label_new (_("Processes"));
    gtk_widget_show (tab_label);
    gtk_notebook_append_page (GTK_NOTEBOOK (notebook), proc_box, tab_label);

    vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
    gtk_box_pack_start (GTK_BOX (proc_box), vbox, FALSE, FALSE, 0);

    tmp = g_strdup_printf ("<b>%s</b>", _("Behavior"));
    label = gtk_label_new (NULL);
    gtk_label_set_xalign (GTK_LABEL (label), 0.0);
    gtk_label_set_markup (GTK_LABEL (label), tmp);
    g_free (tmp);
    gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);

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

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

    vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
    gtk_box_pack_start (GTK_BOX (hbox), vbox2, TRUE, TRUE, 0);

    hbox2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
    gtk_box_pack_start (GTK_BOX (vbox2), hbox2, FALSE, FALSE, 0);

    label = gtk_label_new_with_mnemonic (_("_Update interval in seconds:"));
    gtk_label_set_xalign (GTK_LABEL (label), 0.0);
    gtk_box_pack_start (GTK_BOX (hbox2), label, FALSE, FALSE, 0);

    hbox3 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
    gtk_box_pack_start (GTK_BOX (hbox2), hbox3, TRUE, TRUE, 0);

    update = (gfloat) procdata->config.update_interval;
    adjustment = (GtkAdjustment *) gtk_adjustment_new(update / 1000.0,
                                   MIN_UPDATE_INTERVAL / 1000,
                                   MAX_UPDATE_INTERVAL / 1000,
                                   0.25,
                                   1.0,
                                   0);

    spin_button = gtk_spin_button_new (adjustment, 1.0, 2);
    gtk_box_pack_start (GTK_BOX (hbox3), spin_button, FALSE, FALSE, 0);
    g_signal_connect (G_OBJECT (spin_button), "focus_out_event",
                      G_CALLBACK (SBU::callback), &interval_updater);
    gtk_label_set_mnemonic_widget (GTK_LABEL (label), spin_button);


    hbox2 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6);
    gtk_box_pack_start(GTK_BOX(vbox2), hbox2, FALSE, FALSE, 0);

    smooth_button = gtk_check_button_new_with_mnemonic(_("Enable _smooth refresh"));
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(smooth_button),
                                 g_settings_get_boolean(procdata->settings,
                                                        SmoothRefresh::KEY.c_str()));
    g_signal_connect(G_OBJECT(smooth_button), "toggled",
                     G_CALLBACK(smooth_refresh_toggled), procdata);
    gtk_box_pack_start(GTK_BOX(hbox2), smooth_button, TRUE, TRUE, 0);



    hbox2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
    gtk_box_pack_start (GTK_BOX (vbox2), hbox2, FALSE, FALSE, 0);

    check_button = gtk_check_button_new_with_mnemonic (_("Alert before ending or _killing processes"));
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button),
                                  procdata->config.show_kill_warning);
    g_signal_connect (G_OBJECT (check_button), "toggled",
                                G_CALLBACK (show_kill_dialog_toggled), procdata);
    gtk_box_pack_start (GTK_BOX (hbox2), check_button, FALSE, FALSE, 0);




    hbox2 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6);
    gtk_box_pack_start(GTK_BOX(vbox2), hbox2, FALSE, FALSE, 0);

    GtkWidget *solaris_button = gtk_check_button_new_with_mnemonic(_("Divide CPU usage by CPU count"));
    gtk_widget_set_tooltip_text(solaris_button, _("Solaris mode"));
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(solaris_button),
                                 g_settings_get_boolean(procdata->settings,
                                                        procman::settings::solaris_mode.c_str()));
    g_signal_connect(G_OBJECT(solaris_button), "toggled",
                     G_CALLBACK(solaris_mode_toggled), procdata);
    gtk_box_pack_start(GTK_BOX(hbox2), solaris_button, TRUE, TRUE, 0);




    hbox2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
    gtk_box_pack_start (GTK_BOX (vbox2), hbox2, FALSE, FALSE, 0);

    vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
    gtk_box_pack_start (GTK_BOX (proc_box), vbox, TRUE, TRUE, 0);

    tmp = g_strdup_printf ("<b>%s</b>", _("Information Fields"));
    label = gtk_label_new (NULL);
    gtk_label_set_xalign (GTK_LABEL (label), 0.0);
    gtk_label_set_markup (GTK_LABEL (label), tmp);
    g_free (tmp);
    gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);

    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
    gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);

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

    vbox2 = create_field_page (procdata->tree, "proctree", _("Process i_nformation shown in list:"));
    gtk_box_pack_start (GTK_BOX (hbox), vbox2, TRUE, TRUE, 0);

    sys_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
    gtk_container_set_border_width (GTK_CONTAINER (sys_box), 12);
    tab_label = gtk_label_new (_("Resources"));
    gtk_widget_show (tab_label);
    gtk_notebook_append_page (GTK_NOTEBOOK (notebook), sys_box, tab_label);

    vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
    gtk_box_pack_start (GTK_BOX (sys_box), vbox, FALSE, FALSE, 0);

    tmp = g_strdup_printf ("<b>%s</b>", _("Graphs"));
    label = gtk_label_new (NULL);
    gtk_label_set_xalign (GTK_LABEL (label), 0.0);
    gtk_label_set_markup (GTK_LABEL (label), tmp);
    g_free (tmp);
    gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, FALSE, 0);

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

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

    vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
    gtk_box_pack_start (GTK_BOX (hbox), vbox2, TRUE, TRUE, 0);

    hbox2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
    gtk_box_pack_start (GTK_BOX (vbox2), hbox2, FALSE, FALSE, 0);

    label = gtk_label_new_with_mnemonic (_("_Update interval in 1/10 sec:"));
    gtk_label_set_xalign (GTK_LABEL (label), 0.0);
    gtk_box_pack_start (GTK_BOX (hbox2), label, FALSE, FALSE, 0);
    gtk_size_group_add_widget (size, label);

    hbox3 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
    gtk_box_pack_start (GTK_BOX (hbox2), hbox3, TRUE, TRUE, 0);

    update = (gfloat) procdata->config.graph_update_interval;
    adjustment = (GtkAdjustment *) gtk_adjustment_new(update / 1000.0, 0.25,
                                                      100.0, 0.25, 1.0, 0);
    spin_button = gtk_spin_button_new (adjustment, 1.0, 2);
    g_signal_connect (G_OBJECT (spin_button), "focus_out_event",
                      G_CALLBACK(SBU::callback),
                      &graph_interval_updater);
    gtk_box_pack_start (GTK_BOX (hbox3), spin_button, FALSE, FALSE, 0);
    gtk_label_set_mnemonic_widget (GTK_LABEL (label), spin_button);


    GtkWidget *bits_button;
    bits_button = gtk_check_button_new_with_mnemonic(_("Show network speed in bits"));
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(bits_button),
                                 g_settings_get_boolean(procdata->settings,
                                                        procman::settings::network_in_bits.c_str()));

    g_signal_connect(G_OBJECT(bits_button), "toggled",
                     G_CALLBACK(network_in_bits_toggled), procdata);
    gtk_box_pack_start(GTK_BOX(vbox2), bits_button, TRUE, TRUE, 0);



    hbox2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
    gtk_box_pack_start (GTK_BOX (vbox2), hbox2, TRUE, TRUE, 0);

    /*
     * Devices
     */
    vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
    gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
    tab_label = gtk_label_new (_("File Systems"));
    gtk_widget_show (tab_label);
    gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox, tab_label);

    tmp = g_strdup_printf ("<b>%s</b>", _("File Systems"));
    label = gtk_label_new (NULL);
    gtk_label_set_xalign (GTK_LABEL (label), 0.0);
    gtk_label_set_markup (GTK_LABEL (label), tmp);
    g_free (tmp);
    gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);

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

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

    vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
    gtk_box_pack_start (GTK_BOX (hbox), vbox2, TRUE, TRUE, 0);

    hbox2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
    gtk_box_pack_start (GTK_BOX (vbox2), hbox2, FALSE, FALSE, 0);

    label = gtk_label_new_with_mnemonic (_("_Update interval in seconds:"));
    gtk_label_set_xalign (GTK_LABEL (label), 0.0);
    gtk_box_pack_start (GTK_BOX (hbox2), label, FALSE, FALSE, 0);

    hbox3 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
    gtk_box_pack_start (GTK_BOX (hbox2), hbox3, TRUE, TRUE, 0);

    update = (gfloat) procdata->config.disks_update_interval;
    adjustment = (GtkAdjustment *) gtk_adjustment_new (update / 1000.0, 1.0,
                                                       100.0, 1.0, 1.0, 0);
    spin_button = gtk_spin_button_new (adjustment, 1.0, 0);
    gtk_box_pack_start (GTK_BOX (hbox3), spin_button, FALSE, FALSE, 0);
    gtk_label_set_mnemonic_widget (GTK_LABEL (label), spin_button);
    g_signal_connect (G_OBJECT (spin_button), "focus_out_event",
                      G_CALLBACK(SBU::callback),
                      &disks_interval_updater);


    hbox2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
    gtk_box_pack_start (GTK_BOX (vbox2), hbox2, FALSE, FALSE, 0);
    check_button = gtk_check_button_new_with_mnemonic (_("Show _all file systems"));
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button),
                                  procdata->config.show_all_fs);
    g_signal_connect (G_OBJECT (check_button), "toggled",
                      G_CALLBACK (show_all_fs_toggled), procdata);
    gtk_box_pack_start (GTK_BOX (hbox2), check_button, FALSE, FALSE, 0);


    vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
    gtk_box_pack_start (GTK_BOX (vbox), vbox2, FALSE, FALSE, 0);

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

    tmp = g_strdup_printf ("<b>%s</b>", _("Information Fields"));
    label = gtk_label_new (NULL);
    gtk_label_set_xalign (GTK_LABEL (label), 0.0);
    gtk_label_set_markup (GTK_LABEL (label), tmp);
    g_free (tmp);
    gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);

    hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
    gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);

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

    vbox3 = create_field_page (procdata->disk_list, "disktreenew", _("File system i_nformation shown in list:"));
    gtk_box_pack_start (GTK_BOX (hbox), vbox3, TRUE, TRUE, 0);

    gtk_widget_show_all (dialog);
    g_signal_connect (G_OBJECT (dialog), "response",
                      G_CALLBACK (prefs_dialog_button_pressed), procdata);

    switch (procdata->config.current_tab) {
    case PROCMAN_TAB_SYSINFO:
    case PROCMAN_TAB_PROCESSES:
        gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 0);
        break;
    case PROCMAN_TAB_RESOURCES:
        gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 1);
        break;
    case PROCMAN_TAB_DISKS:
        gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 2);
        break;

    }
}