当前位置: 首页>>代码示例>>C++>>正文


C++ GTK_WIDGET函数代码示例

本文整理汇总了C++中GTK_WIDGET函数的典型用法代码示例。如果您正苦于以下问题:C++ GTK_WIDGET函数的具体用法?C++ GTK_WIDGET怎么用?C++ GTK_WIDGET使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了GTK_WIDGET函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: remove_notebook

static void
remove_notebook (GeditMultiNotebook *mnb,
		 GtkWidget          *notebook)
{
	GtkWidget *parent;
	GtkWidget *grandpa;
	GList *children;
	GtkWidget *new_notebook;
	GList *current;

	if (mnb->priv->notebooks->next == NULL)
	{
		g_warning ("You are trying to remove the main notebook");
		return;
	}

	current = g_list_find (mnb->priv->notebooks,
			       notebook);

	if (current->next != NULL)
	{
		new_notebook = GTK_WIDGET (current->next->data);
	}
	else
	{
		new_notebook = GTK_WIDGET (mnb->priv->notebooks->data);
	}

	parent = gtk_widget_get_parent (notebook);

	/* Now we destroy the widget, we get the children of parent and we destroy
	  parent too as the parent is an useless paned. Finally we add the child
	  into the grand parent */
	g_object_ref (notebook);
	mnb->priv->removing_notebook = TRUE;

	gtk_widget_destroy (notebook);

	mnb->priv->notebooks = g_list_remove (mnb->priv->notebooks,
					      notebook);

	mnb->priv->removing_notebook = FALSE;

	children = gtk_container_get_children (GTK_CONTAINER (parent));
	if (children->next != NULL)
	{
		g_warning ("The parent is not a paned");
		return;
	}
	grandpa = gtk_widget_get_parent (parent);

	g_object_ref (children->data);
	gtk_container_remove (GTK_CONTAINER (parent),
			      GTK_WIDGET (children->data));
	gtk_widget_destroy (parent);
	gtk_container_add (GTK_CONTAINER (grandpa),
			   GTK_WIDGET (children->data));
	g_object_unref (children->data);
	g_list_free (children);

	disconnect_notebook_signals (mnb, notebook);

	g_signal_emit (G_OBJECT (mnb), signals[NOTEBOOK_REMOVED], 0, notebook);
	g_object_unref (notebook);

	/* Let's make the active notebook grab the focus */
	gtk_widget_grab_focus (new_notebook);
}
开发者ID:hameelas,项目名称:gedit,代码行数:68,代码来源:gedit-multi-notebook.c

示例2: monitor_create_options

static void monitor_create_options(Control *control, GtkContainer *container, GtkWidget *done)
{
    t_global_monitor *global;
    GtkBox           *vbox, *global_vbox, *net_hbox;
    GtkWidget        *device_label, *unit_label[SUM], *max_label[SUM];
    GtkWidget        *sep1, *sep2;
    GtkBox           *update_hbox;
    GtkWidget        *update_label, *update_unit_label;
    GtkWidget        *color_label[SUM];
    GtkWidget        *align;
    GtkBox           *color_hbox[SUM];
    GtkSizeGroup     *sg;
    gint             i;
    gchar            buffer[BUFSIZ];
    gchar            *color_text[] = { 
                        N_("Bar color (incoming):"), 
                        N_("Bar color (outgoing):") 
                     };
    gchar            *maximum_text_label[] = {
                        N_("Maximum (incoming):"),
                        N_("Maximum (outgoing):")
                     };
    
    sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
    
    global = (t_global_monitor *)control->data;
    global->opt_dialog = gtk_widget_get_toplevel(done);
    
    global_vbox = GTK_BOX(gtk_vbox_new(FALSE, 5));
    gtk_container_add(GTK_CONTAINER(container), GTK_WIDGET(global_vbox));

    gtk_widget_show_all(GTK_WIDGET(global_vbox));

    vbox = GTK_BOX(gtk_vbox_new(FALSE, 5));
    gtk_widget_show(GTK_WIDGET(vbox));

    global->monitor->opt_vbox = GTK_BOX(gtk_vbox_new(FALSE, 5));
    gtk_widget_show(GTK_WIDGET(global->monitor->opt_vbox));

    /* Displayed text */
    global->monitor->opt_hbox = GTK_BOX(gtk_hbox_new(FALSE, 5));
    gtk_widget_show(GTK_WIDGET(global->monitor->opt_hbox));
    
    global->monitor->opt_use_label =
        gtk_check_button_new_with_mnemonic(_("Text to display:"));
    gtk_widget_show(global->monitor->opt_use_label);
    gtk_box_pack_start(GTK_BOX(global->monitor->opt_hbox),
                       GTK_WIDGET(global->monitor->opt_use_label),
                       FALSE, FALSE, 0);
    gtk_size_group_add_widget(sg, global->monitor->opt_use_label);

    global->monitor->opt_entry = gtk_entry_new();
    gtk_entry_set_max_length(GTK_ENTRY(global->monitor->opt_entry),
                             MAX_LENGTH);
    gtk_entry_set_text(GTK_ENTRY(global->monitor->opt_entry),
                       global->monitor->options.label_text);
    gtk_widget_show(global->monitor->opt_entry);
    gtk_box_pack_start(GTK_BOX(global->monitor->opt_hbox),
                       GTK_WIDGET(global->monitor->opt_entry),
                   FALSE, FALSE, 0);

    gtk_box_pack_start(GTK_BOX(global->monitor->opt_vbox),
                       GTK_WIDGET(global->monitor->opt_hbox),
                       FALSE, FALSE, 0);

    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(global->monitor->opt_use_label),
                                 global->monitor->options.use_label);
    gtk_widget_set_sensitive(GTK_WIDGET(global->monitor->opt_entry),
                             global->monitor->options.use_label);
                             
    /* Network device */
    net_hbox = GTK_BOX(gtk_hbox_new(FALSE, 5));
    gtk_box_pack_start(GTK_BOX(global->monitor->opt_vbox),
                        GTK_WIDGET(net_hbox), FALSE, FALSE, 0);

    device_label = gtk_label_new(_("Network device:"));
    gtk_misc_set_alignment(GTK_MISC(device_label), 0, 0.5);
    gtk_widget_show(GTK_WIDGET(device_label));
    gtk_box_pack_start(GTK_BOX(net_hbox), GTK_WIDGET(device_label),
                       FALSE, FALSE, 0);

    global->monitor->net_entry = gtk_entry_new();
    gtk_entry_set_max_length(GTK_ENTRY(global->monitor->net_entry),
                             MAX_LENGTH);
    gtk_entry_set_text(GTK_ENTRY(global->monitor->net_entry),
                       global->monitor->options.network_device);
    gtk_widget_show(global->monitor->opt_entry);

    gtk_box_pack_start(GTK_BOX(net_hbox), GTK_WIDGET(global->monitor->net_entry),
                       FALSE, FALSE, 0);
    
    gtk_size_group_add_widget(sg, device_label);

    gtk_widget_show_all(GTK_WIDGET(net_hbox));
    
    
    /* Update timevalue */
    update_hbox = GTK_BOX(gtk_hbox_new(FALSE, 5));
    gtk_box_pack_start(GTK_BOX(global->monitor->opt_vbox),
                        GTK_WIDGET(update_hbox), FALSE, FALSE, 0);
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:xfce-goodies-svn,代码行数:101,代码来源:netload.c

示例3: gail_focus_watcher

static gboolean
gail_focus_watcher (GSignalInvocationHint *ihint,
                    guint                  n_param_values,
                    const GValue          *param_values,
                    gpointer               data)
{
  GObject *object;
  GtkWidget *widget;
  GdkEvent *event;

  object = g_value_get_object (param_values + 0);
  g_return_val_if_fail (GTK_IS_WIDGET(object), FALSE);

  event = g_value_get_boxed (param_values + 1);
  widget = GTK_WIDGET (object);

  if (event->type == GDK_FOCUS_CHANGE) 
    {
      if (event->focus_change.in)
        {
          if (GTK_IS_WINDOW (widget))
            {
              GtkWindow *window;

              window = GTK_WINDOW (widget);
              if (window->focus_widget)
                {
                  /*
                   * If we already have a potential focus widget set this
                   * windows's focus widget to focus_before_menu so that 
                   * it will be reported when menu item is unset.
                   */
                  if (next_focus_widget)
                    {
                      if (GTK_IS_MENU_ITEM (next_focus_widget) &&
                          !focus_before_menu)
                        {
                          void *vp_focus_before_menu = &focus_before_menu;
                          focus_before_menu = window->focus_widget;
                          g_object_add_weak_pointer (G_OBJECT (focus_before_menu), vp_focus_before_menu);
                        }

                      return TRUE;
                    }
                  widget = window->focus_widget;
                }
              else if (window->type == GTK_WINDOW_POPUP) 
                {
	          if (GTK_IS_BIN (widget))
		    {
		      GtkWidget *child = gtk_bin_get_child (GTK_BIN (widget));

		      if (GTK_IS_WIDGET (child) && GTK_WIDGET_HAS_GRAB (child))
			{
			  if (GTK_IS_MENU_SHELL (child))
			    {
			      if (GTK_MENU_SHELL (child)->active_menu_item)
				{
				  /*
				   * We have a menu which has a menu item selected
				   * so we do not report focus on the menu.
				   */ 
				  return TRUE; 
				}
			    }
			  widget = child;
			} 
		    }
		  else /* popup window has no children; this edge case occurs in some custom code (OOo for instance) */
		    {
		      return TRUE;
		    }
                }
	      else /* Widget is a non-popup toplevel with no focus children; 
		      don't emit for this case either, as it's useless */
		{
		  return TRUE;
		}
            }
        }
      else
        {
          if (next_focus_widget)
            {
               GtkWidget *toplevel;

               toplevel = gtk_widget_get_toplevel (next_focus_widget);
               if (toplevel == widget)
                 next_focus_widget = NULL; 
            }
          /* focus out */
          widget = NULL;
        }
    }
  else
    {
      if (event->type == GDK_MOTION_NOTIFY && GTK_WIDGET_HAS_FOCUS (widget))
        {
          if (widget == focus_widget)
            {
//.........这里部分代码省略.........
开发者ID:batman52,项目名称:dingux-code,代码行数:101,代码来源:gail.c

示例4: gimp_color_picker_tool_info_create

static void
gimp_color_picker_tool_info_create (GimpColorPickerTool *picker_tool)
{
  GimpTool         *tool = GIMP_TOOL (picker_tool);
  GimpDisplayShell *shell;
  GtkWidget        *hbox;
  GtkWidget        *frame;
  GimpRGB           color;

  g_return_if_fail (tool->display != NULL);
  g_return_if_fail (tool->drawable != NULL);

  shell = gimp_display_get_shell (tool->display);

  picker_tool->gui = gimp_tool_gui_new (tool->tool_info,
                                        _("Color Picker Information"),
                                        gtk_widget_get_screen (GTK_WIDGET (shell)),
                                        gimp_widget_get_monitor (GTK_WIDGET (shell)),
                                        TRUE,

                                        GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,

                                        NULL);

  gimp_tool_gui_set_auto_overlay (picker_tool->gui, TRUE);
  gimp_tool_gui_set_focus_on_map (picker_tool->gui, FALSE);
  gimp_tool_gui_set_viewable (picker_tool->gui,
                              GIMP_VIEWABLE (tool->drawable));

  g_signal_connect (picker_tool->gui, "response",
                    G_CALLBACK (gimp_color_picker_tool_info_response),
                    picker_tool);

  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
  gtk_box_pack_start (GTK_BOX (gimp_tool_gui_get_vbox (picker_tool->gui)),
                      hbox, FALSE, FALSE, 0);
  gtk_widget_show (hbox);

  picker_tool->color_frame1 = gimp_color_frame_new ();
  gimp_color_frame_set_mode (GIMP_COLOR_FRAME (picker_tool->color_frame1),
                             GIMP_COLOR_FRAME_MODE_PIXEL);
  gtk_box_pack_start (GTK_BOX (hbox), picker_tool->color_frame1,
                      FALSE, FALSE, 0);
  gtk_widget_show (picker_tool->color_frame1);

  picker_tool->color_frame2 = gimp_color_frame_new ();
  gimp_color_frame_set_mode (GIMP_COLOR_FRAME (picker_tool->color_frame2),
                             GIMP_COLOR_FRAME_MODE_RGB);
  gtk_box_pack_start (GTK_BOX (hbox), picker_tool->color_frame2,
                      FALSE, FALSE, 0);
  gtk_widget_show (picker_tool->color_frame2);

  frame = gtk_frame_new (NULL);
  gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
  gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
  gtk_widget_show (frame);

  gimp_rgba_set (&color, 0.0, 0.0, 0.0, 0.0);
  picker_tool->color_area =
    gimp_color_area_new (&color,
                         gimp_drawable_has_alpha (tool->drawable) ?
                         GIMP_COLOR_AREA_LARGE_CHECKS :
                         GIMP_COLOR_AREA_FLAT,
                         GDK_BUTTON1_MASK | GDK_BUTTON2_MASK);
  gtk_widget_set_size_request (picker_tool->color_area, 48, -1);
  gtk_drag_dest_unset (picker_tool->color_area);
  gtk_container_add (GTK_CONTAINER (frame), picker_tool->color_area);
  gtk_widget_show (picker_tool->color_area);
}
开发者ID:Distrotech,项目名称:gimp,代码行数:69,代码来源:gimpcolorpickertool.c

示例5: monitor_new

static t_global_monitor * monitor_new(void)
{
    t_global_monitor *global;
    GtkRcStyle *rc;
    gint i;

    global = g_new(t_global_monitor, 1);
    global->timeout_id = 0;
    global->ebox = gtk_event_box_new();
    gtk_widget_show(global->ebox);
    global->box = gtk_hbox_new(FALSE, 0);
    gtk_widget_show(global->box);

    if (!tooltips) 
    {
        tooltips = gtk_tooltips_new();
    }

    global->monitor = g_new(t_monitor, 1);
    global->monitor->options.label_text = g_strdup(DEFAULT_TEXT);
    global->monitor->options.network_device = g_strdup(DEFAULT_DEVICE);
    global->monitor->options.old_network_device = g_strdup("");
    global->monitor->options.use_label = TRUE;
    global->monitor->options.auto_max = TRUE;
    global->monitor->options.update_interval = UPDATE_TIMEOUT;
    
    for (i = 0; i < SUM; i++)
    {
        gdk_color_parse(DEFAULT_COLOR[i], &global->monitor->options.color[i]);

        global->monitor->history[i][0] = 0;
        global->monitor->history[i][1] = 0;
        global->monitor->history[i][2] = 0;
        global->monitor->history[i][3] = 0;
        global->monitor->net_max[i]    = INIT_MAX;
        
        global->monitor->options.max[i] = INIT_MAX;
    }

    global->monitor->ebox = gtk_event_box_new();
    gtk_widget_show(global->monitor->ebox);

    global->monitor->box = GTK_WIDGET(gtk_hbox_new(FALSE, 0));
    gtk_container_set_border_width(GTK_CONTAINER(global->monitor->box),
                                   border_width);
    gtk_widget_show(GTK_WIDGET(global->monitor->box));

    gtk_container_add(GTK_CONTAINER(global->monitor->ebox),
                      GTK_WIDGET(global->monitor->box));

    global->monitor->label =
        gtk_label_new(global->monitor->options.label_text);
    gtk_widget_show(global->monitor->label);
    gtk_box_pack_start(GTK_BOX(global->monitor->box),
                       GTK_WIDGET(global->monitor->label),
                       FALSE, FALSE, 0);

    for (i = 0; i < SUM; i++)
    {
        global->monitor->status[i] = GTK_WIDGET(gtk_progress_bar_new());
        gtk_progress_bar_set_orientation(GTK_PROGRESS_BAR(global->monitor->status[i]),
                                     GTK_PROGRESS_BOTTOM_TO_TOP);

        rc = gtk_widget_get_modifier_style(GTK_WIDGET(global->monitor->status[i]));
        if (!rc) 
        {
            rc = gtk_rc_style_new();
        }
        else
        {
            rc->color_flags[GTK_STATE_PRELIGHT] |= GTK_RC_BG;
            rc->bg[GTK_STATE_PRELIGHT] = global->monitor->options.color[i];
        }

        gtk_widget_modify_style(GTK_WIDGET(global->monitor->status[i]), rc);
        gtk_widget_show(GTK_WIDGET(global->monitor->status[i]));

        gtk_box_pack_start(GTK_BOX(global->monitor->box),
                GTK_WIDGET(global->monitor->status[i]),
                FALSE, FALSE, 0);
    }

    gtk_box_pack_start(GTK_BOX(global->box),
                       GTK_WIDGET(global->monitor->ebox),
                       FALSE, FALSE, 0);


    gtk_container_add(GTK_CONTAINER(global->ebox), GTK_WIDGET(global->box));
    
    return global;
}
开发者ID:BackupTheBerlios,项目名称:xfce-goodies-svn,代码行数:91,代码来源:netload.c

示例6: gimp_color_tool_real_picked

static void
gimp_color_tool_real_picked (GimpColorTool      *color_tool,
                             GimpColorPickState  pick_state,
                             gdouble             x,
                             gdouble             y,
                             const Babl         *sample_format,
                             gpointer            pixel,
                             const GimpRGB      *color)
{
  GimpTool    *tool = GIMP_TOOL (color_tool);
  GimpContext *context;

  /*  use this tool's own options here (NOT color_tool->options)  */
  context = GIMP_CONTEXT (gimp_tool_get_options (tool));

  if (color_tool->pick_mode == GIMP_COLOR_PICK_MODE_FOREGROUND ||
      color_tool->pick_mode == GIMP_COLOR_PICK_MODE_BACKGROUND)
    {
      GtkWidget *widget;

      if (babl_format_is_palette (sample_format))
        {
          widget = gimp_dialog_factory_find_widget (gimp_dialog_factory_get_singleton (),
                                                    "gimp-indexed-palette");
          if (widget)
            {
              GtkWidget *editor = gtk_bin_get_child (GTK_BIN (widget));
              guchar    *index  = pixel;

              gimp_colormap_editor_set_index (GIMP_COLORMAP_EDITOR (editor),
                                              *index, NULL);
            }
        }

      widget = gimp_dialog_factory_find_widget (gimp_dialog_factory_get_singleton (),
                                                "gimp-palette-editor");
      if (widget)
        {
          GtkWidget *editor = gtk_bin_get_child (GTK_BIN (widget));
          gint       index;

          index = gimp_palette_editor_get_index (GIMP_PALETTE_EDITOR (editor),
                                                 color);
          if (index != -1)
            gimp_palette_editor_set_index (GIMP_PALETTE_EDITOR (editor),
                                           index, NULL);
        }
    }

  switch (color_tool->pick_mode)
    {
    case GIMP_COLOR_PICK_MODE_NONE:
      break;

    case GIMP_COLOR_PICK_MODE_FOREGROUND:
      gimp_context_set_foreground (context, color);
      break;

    case GIMP_COLOR_PICK_MODE_BACKGROUND:
      gimp_context_set_background (context, color);
      break;

    case GIMP_COLOR_PICK_MODE_PALETTE:
      {
        GimpDisplayShell *shell   = gimp_display_get_shell (tool->display);
        GdkScreen        *screen  = gtk_widget_get_screen (GTK_WIDGET (shell));
        gint              monitor = gimp_widget_get_monitor (GTK_WIDGET (shell));
        GtkWidget        *dockable;

        dockable =
          gimp_window_strategy_show_dockable_dialog (GIMP_WINDOW_STRATEGY (gimp_get_window_strategy (tool->display->gimp)),
                                                     tool->display->gimp,
                                                     gimp_dialog_factory_get_singleton (),
                                                     screen,
                                                     monitor,
                                                     "gimp-palette-editor");

        if (dockable)
          {
            GtkWidget *palette_editor;
            GimpData  *data;

            /* don't blink like mad when updating */
            if (pick_state != GIMP_COLOR_PICK_STATE_START)
              gimp_dockable_blink_cancel (GIMP_DOCKABLE (dockable));

            palette_editor = gtk_bin_get_child (GTK_BIN (dockable));

            data = gimp_data_editor_get_data (GIMP_DATA_EDITOR (palette_editor));

            if (! data)
              {
                data = GIMP_DATA (gimp_context_get_palette (context));

                gimp_data_editor_set_data (GIMP_DATA_EDITOR (palette_editor),
                                           data);
              }

            gimp_palette_editor_pick_color (GIMP_PALETTE_EDITOR (palette_editor),
                                            color, pick_state);
//.........这里部分代码省略.........
开发者ID:SHIVAPRASAD96,项目名称:gimp,代码行数:101,代码来源:gimpcolortool.c

示例7: impl_show_properties

static void
impl_show_properties (RBMediaPlayerSource *source, GtkWidget *info_box, GtkWidget *notebook)
{
	RBGenericPlayerSourcePrivate *priv = GET_PRIVATE (source);
	RhythmDBQueryModel *model;
	GtkBuilder *builder;
	GtkWidget *widget;
	GString *str;
	char *device_name;
	char *builder_file;
	char *vendor_name;
	char *model_name;
	char *serial_id;
	GObject *plugin;
	char *text;
	GList *output_formats;
	GList *t;

	g_object_get (source, "plugin", &plugin, NULL);
	builder_file = rb_find_plugin_data_file (plugin, "generic-player-info.ui");
	g_object_unref (plugin);

	if (builder_file == NULL) {
		g_warning ("Couldn't find generic-player-info.ui");
		return;
	}

	builder = rb_builder_load (builder_file, NULL);
	g_free (builder_file);

	if (builder == NULL) {
		rb_debug ("Couldn't load generic-player-info.ui");
		return;
	}

	/* 'basic' tab stuff */

	widget = GTK_WIDGET (gtk_builder_get_object (builder, "generic-player-basic-info"));
	gtk_box_pack_start (GTK_BOX (info_box), widget, TRUE, TRUE, 0);

	widget = GTK_WIDGET (gtk_builder_get_object (builder, "entry-device-name"));
	g_object_get (source, "name", &device_name, NULL);
	gtk_entry_set_text (GTK_ENTRY (widget), device_name);
	g_free (device_name);
	/* don't think we can support this..
	g_signal_connect (widget, "focus-out-event",
			  (GCallback)rb_mtp_source_name_changed_cb, source);
			  */

	g_object_get (source, "base-query-model", &model, NULL);
	widget = GTK_WIDGET (gtk_builder_get_object (builder, "num-tracks"));
	text = g_strdup_printf ("%d", gtk_tree_model_iter_n_children (GTK_TREE_MODEL (model), NULL));
	gtk_label_set_text (GTK_LABEL (widget), text);
	g_free (text);
	g_object_unref (model);

	widget = GTK_WIDGET (gtk_builder_get_object (builder, "num-playlists"));
	text = g_strdup_printf ("%d", g_list_length (priv->playlists));
	gtk_label_set_text (GTK_LABEL (widget), text);
	g_free (text);

	/* 'advanced' tab stuff */
	widget = GTK_WIDGET (gtk_builder_get_object (builder, "generic-player-advanced-tab"));
	gtk_notebook_append_page (GTK_NOTEBOOK (notebook), widget, gtk_label_new (_("Advanced")));

	g_object_get (priv->device_info,
		      "model", &model_name,
		      "vendor", &vendor_name,
		      "serial", &serial_id,
		      NULL);

	widget = GTK_WIDGET (gtk_builder_get_object (builder, "label-model-value"));
	gtk_label_set_text (GTK_LABEL (widget), model_name);

	widget = GTK_WIDGET (gtk_builder_get_object (builder, "label-manufacturer-value"));
	gtk_label_set_text (GTK_LABEL (widget), vendor_name);

	widget = GTK_WIDGET (gtk_builder_get_object (builder, "label-serial-number-value"));
	gtk_label_set_text (GTK_LABEL (widget), serial_id);

	g_free (model_name);
	g_free (vendor_name);
	g_free (serial_id);

	str = g_string_new ("");
	output_formats = rb_transfer_target_get_format_descriptions (RB_TRANSFER_TARGET (source));
	for (t = output_formats; t != NULL; t = t->next) {
		if (t != output_formats) {
			g_string_append (str, "\n");
		}
		g_string_append (str, t->data);
	}
	rb_list_deep_free (output_formats);

	widget = GTK_WIDGET (gtk_builder_get_object (builder, "audio-format-list"));
	gtk_label_set_text (GTK_LABEL (widget), str->str);
	g_string_free (str, TRUE);

	g_object_unref (builder);
}
开发者ID:arnaudlecam,项目名称:rhythmbox,代码行数:100,代码来源:rb-generic-player-source.c

示例8: xfce_plugin


//.........这里部分代码省略.........
    next_color = xfce_rc_read_int_entry(settings_ro, "next_color",
      next_color);
    viewer_text_overlay_enabled = xfce_rc_read_bool_entry(settings_ro,
      "viewer_text_overlay_enabled", viewer_text_overlay_enabled);
    viewer_text_overlay_format_string = xfce_rc_read_entry(settings_ro,
      "viewer_text_overlay_format_string",
      viewer_text_overlay_format_string.c_str());
    viewer_text_overlay_separator = xfce_rc_read_entry(settings_ro,
      "viewer_text_overlay_separator", viewer_text_overlay_separator.c_str());
    viewer_text_overlay_font = xfce_rc_read_entry(settings_ro,
      "viewer_text_overlay_font", viewer_text_overlay_font.c_str());
    viewer_text_overlay_color = xfce_rc_read_int_entry(settings_ro,
      "viewer_text_overlay_color", viewer_text_overlay_color);
    viewer_monitor_type_sync_enabled = xfce_rc_read_bool_entry(settings_ro,
      "viewer_monitor_type_sync_enabled", viewer_monitor_type_sync_enabled);

    // Enum is validated in set_viewer_text_overlay_position
    CanvasView::TextOverlayPosition text_overlay_position =
        static_cast<CanvasView::TextOverlayPosition>(
          xfce_rc_read_int_entry(settings_ro, "viewer_text_overlay_position",
                                 CanvasView::top_left));
    set_viewer_text_overlay_position(text_overlay_position);
  }
  
  // Loading icon
  try
  {
    icon = Gdk::Pixbuf::create_from_file(icon_path);
  }
  catch (...)
  {
    std::cerr <<
      String::ucompose(_("Hardware Monitor: cannot load the icon '%1'.\n"),
          icon_path);

    // It's a minor problem if we can't find the icon
    icon = Glib::RefPtr<Gdk::Pixbuf>();
  }

  // Configuring viewer type
  viewer_type_listener(viewer_type);

  /* Actually setting the viewer size has no effect in this function -
   * seems that it needs to be done in or after the mainloop kicks off */

  // Loading up monitors
  /* Plugin& is initialised from non-transient address of this ('this' itself
   * is an rvalue so not allowed for a reference) */
  monitor_seq mon = load_monitors(settings_ro, *this);
  for (monitor_iter i = mon.begin(), end = mon.end(); i != end; ++i)
    add_monitor(*i);

  // All settings loaded
  if (settings_ro)
    xfce_rc_close(settings_ro);

  /* Connect plugin signals to functions - since I'm not really interested
   * in the plugin but the plugin pointer, swapped results in the signal
   * handler getting the plugin reference first - the plugin pointer is
   * passed next, but since the handler only takes one parameter this is
   * discarded
   * Providing About option */
  g_signal_connect_swapped(xfce_plugin, "about", G_CALLBACK(display_about),
    this);

  // Hooking into Properties option
  g_signal_connect_swapped(xfce_plugin, "configure-plugin",
    G_CALLBACK(display_preferences), this);

  // Hooking into plugin destruction signal
  g_signal_connect_swapped(xfce_plugin, "free-data", G_CALLBACK(plugin_free),
    this);

  // Hooking into save signal
  g_signal_connect_swapped(xfce_plugin, "save", G_CALLBACK(save_monitors),
    this);

  /* Not needed as the canvas resizes on the fly
  // Hooking into size changed signal
  g_signal_connect(xfce_plugin, "size-changed", G_CALLBACK(size_changed),
    this);
  */

  // Adding configure and about to the plugin's right-click menu
  xfce_panel_plugin_menu_show_configure(xfce_plugin);
  xfce_panel_plugin_menu_show_about(xfce_plugin);

  /* Add plugin to panel - I need to turn the Plugin (which inherits from
   * Gtk::EventBox) into a GtkWidget* - to do this I get at the GObject
   * pointer underneath the gtkmm layer */
  gtk_container_add(GTK_CONTAINER(xfce_plugin), GTK_WIDGET(this->gobj()));

  // Initialising timer to run every second (by default) to trigger main_loop
  timer =
    Glib::signal_timeout().connect(sigc::mem_fun(*this, &Plugin::main_loop),
      update_interval);

  // Initial main_loop run
  main_loop();
}
开发者ID:xfce-mirror,项目名称:xfce4-hardware-monitor-plugin,代码行数:101,代码来源:plugin.cpp

示例9: nautilus_launch_desktop_file

void
nautilus_launch_desktop_file (GdkScreen   *screen,
			      const char  *desktop_file_uri,
			      const GList *parameter_uris,
			      GtkWindow   *parent_window)
{
	GError *error;
	char *message, *desktop_file_path;
	const GList *p;
	GList *files;
	int total, count;
	GFile *file, *desktop_file;
	GDesktopAppInfo *app_info;
	GdkAppLaunchContext *context;

	/* Don't allow command execution from remote locations
	 * to partially mitigate the security
	 * risk of executing arbitrary commands.
	 */
	desktop_file = g_file_new_for_uri (desktop_file_uri);
	desktop_file_path = g_file_get_path (desktop_file);
	if (!g_file_is_native (desktop_file)) {
		g_free (desktop_file_path);
		g_object_unref (desktop_file);
		eel_show_error_dialog
			(_("Sorry, but you cannot execute commands from "
			   "a remote site."), 
			 _("This is disabled due to security considerations."),
			 parent_window);
			 
		return;
	}
	g_object_unref (desktop_file);

	app_info = g_desktop_app_info_new_from_filename (desktop_file_path);
	g_free (desktop_file_path);
	if (app_info == NULL) {
		eel_show_error_dialog
			(_("There was an error launching the application."),
			 NULL,
			 parent_window);
		return;
	}
	
	/* count the number of uris with local paths */
	count = 0;
	total = g_list_length ((GList *) parameter_uris);
	files = NULL;
	for (p = parameter_uris; p != NULL; p = p->next) {
		file = g_file_new_for_uri ((const char *) p->data);
		if (g_file_is_native (file)) {
			count++;
		}
		files = g_list_prepend (files, file);
	}

	/* check if this app only supports local files */
	if (g_app_info_supports_files (G_APP_INFO (app_info)) &&
	    !g_app_info_supports_uris (G_APP_INFO (app_info)) &&
	    parameter_uris != NULL) {
		if (count == 0) {
			/* all files are non-local */
			eel_show_error_dialog
				(_("This drop target only supports local files."),
				 _("To open non-local files copy them to a local folder and then"
				   " drop them again."),
				 parent_window);

			g_list_free_full (files, g_object_unref);
			g_object_unref (app_info);
			return;
		} else if (count != total) {
			/* some files are non-local */
			eel_show_warning_dialog
				(_("This drop target only supports local files."),
				 _("To open non-local files copy them to a local folder and then"
				   " drop them again. The local files you dropped have already been opened."),
				 parent_window);
		}
	}

	error = NULL;
	context = gdk_display_get_app_launch_context (gtk_widget_get_display (GTK_WIDGET (parent_window)));
	/* TODO: Ideally we should accept a timestamp here instead of using GDK_CURRENT_TIME */
	gdk_app_launch_context_set_timestamp (context, GDK_CURRENT_TIME);
	gdk_app_launch_context_set_screen (context,
					   gtk_window_get_screen (parent_window));
	if (count == total) {
		/* All files are local, so we can use g_app_info_launch () with
		 * the file list we constructed before.
		 */
		g_app_info_launch (G_APP_INFO (app_info),
				   files,
				   G_APP_LAUNCH_CONTEXT (context),
				   &error);
	} else {
		/* Some files are non local, better use g_app_info_launch_uris ().
		 */
		g_app_info_launch_uris (G_APP_INFO (app_info),
					(GList *) parameter_uris,
//.........这里部分代码省略.........
开发者ID:KapTmaN,项目名称:nautilus,代码行数:101,代码来源:nautilus-program-choosing.c

示例10: panel_struts_allocate_struts

static gboolean
panel_struts_allocate_struts (PanelToplevel *toplevel,
			      GdkScreen     *screen,
			      int            monitor)
{
	GSList   *allocated = NULL;
	GSList   *l;
	gboolean  toplevel_changed = FALSE;

	for (l = panel_struts_list; l; l = l->next) {
		PanelStrut   *strut = l->data;
		PanelStrut   *overlap;
		GdkRectangle  geometry;
		int           monitor_x, monitor_y;
		int           monitor_width, monitor_height;
		gboolean      moved_down;
		int           skip;

		if (strut->screen != screen || strut->monitor != monitor)
			continue;

		panel_struts_get_monitor_geometry (strut->screen, strut->monitor,
						   &monitor_x, &monitor_y,
						   &monitor_width, &monitor_height);

		strut->allocated_strut_size  = strut->strut_size;
		strut->allocated_strut_start = strut->strut_start;
		strut->allocated_strut_end   = strut->strut_end;

		geometry = strut->geometry;

		moved_down = FALSE;
		skip = 0;
		while ((overlap = panel_struts_intersect (allocated, &geometry, skip)))
			skip = panel_struts_allocation_overlapped (
				strut, overlap, &geometry, &moved_down, skip);

		if (strut->orientation & PANEL_VERTICAL_MASK) {
			if (geometry.y < monitor_y) {
				geometry.height = geometry.y + geometry.height - monitor_y;
				geometry.y      = monitor_y;
			}
				
			if (geometry.y + geometry.height > monitor_y + monitor_height)
				geometry.height = monitor_y + monitor_height - geometry.y;
		}

		if (strut->allocated_geometry.x      != geometry.x     ||
		    strut->allocated_geometry.y      != geometry.y     ||
		    strut->allocated_geometry.width  != geometry.width ||
		    strut->allocated_geometry.height != geometry.height) {
			strut->allocated_geometry = geometry;

			if (strut->toplevel == toplevel)
				toplevel_changed = TRUE;
			else
				gtk_widget_queue_resize (GTK_WIDGET (strut->toplevel));
		}

		allocated = g_slist_append (allocated, strut);
	}

	g_slist_free (allocated);

	return toplevel_changed;
}
开发者ID:lanoxx,项目名称:gnome-panel,代码行数:66,代码来源:panel-struts.c

示例11: panel_struts_set_window_hint

void
panel_struts_set_window_hint (PanelToplevel *toplevel)
{
	GtkWidget  *widget;
	PanelStrut *strut;
	int         strut_size;
	int         monitor_x, monitor_y, monitor_width, monitor_height;
	int         screen_width, screen_height;
	int         leftmost, rightmost, topmost, bottommost;

	widget = GTK_WIDGET (toplevel);

	if (!gtk_widget_get_realized (widget))
		return;

	if (!(strut = panel_struts_find_strut (toplevel))) {
		panel_struts_unset_window_hint (toplevel);
		return;
	}

	strut_size = strut->allocated_strut_size;

	screen_width  = gdk_screen_get_width  (strut->screen);
	screen_height = gdk_screen_get_height (strut->screen);

	panel_struts_get_monitor_geometry (strut->screen,
					   strut->monitor,
					   &monitor_x,
					   &monitor_y,
					   &monitor_width,
					   &monitor_height);

        panel_multiscreen_is_at_visible_extreme (strut->monitor,
                                                 &leftmost,
                                                 &rightmost,
                                                 &topmost,
                                                 &bottommost);

	switch (strut->orientation) {
	case PANEL_ORIENTATION_TOP:
		if (monitor_y > 0)
			strut_size += monitor_y;
		if (!topmost) strut_size = 0;
		break;
	case PANEL_ORIENTATION_BOTTOM:
		if (monitor_y + monitor_height < screen_height)
			strut_size += screen_height - (monitor_y + monitor_height);
		if (!bottommost) strut_size = 0;
		break;
	case PANEL_ORIENTATION_LEFT:
		if (leftmost && monitor_x > 0)
			strut_size += monitor_x;
		if (!leftmost) strut_size = 0;
		break;
	case PANEL_ORIENTATION_RIGHT:
		if (monitor_x + monitor_width < screen_width)
			strut_size += screen_width - (monitor_x + monitor_width);
		if (!rightmost) strut_size = 0;
		break;
	default:
		g_assert_not_reached ();
		break;
	}

	panel_xutils_set_strut (gtk_widget_get_window (widget),
				strut->orientation,
				strut_size,
				strut->allocated_strut_start,
				strut->allocated_strut_end);
}
开发者ID:lanoxx,项目名称:gnome-panel,代码行数:70,代码来源:panel-struts.c

示例12: GTK_WIDGET

YC20UI2::YC20UI2()
{
	drawingArea = GTK_WIDGET(gtk_drawing_area_new());
	gtk_widget_ref(drawingArea);

	memset(draggablePerLV2Port, 0, sizeof(Wdgt::Draggable *)*27);

	// Gtk signals
	g_signal_connect (drawingArea, "size-request",         G_CALLBACK( lv2ui_size_request ), this);
	g_signal_connect (drawingArea, "size-allocate",        G_CALLBACK( lv2ui_size_allocate ), this);
	g_signal_connect (drawingArea, "expose-event",         G_CALLBACK( lv2ui_expose_event ), this);

	g_signal_connect (drawingArea, "motion-notify-event",  G_CALLBACK( lv2ui_motion_notify_event ), this);
	g_signal_connect (drawingArea, "button-press-event",   G_CALLBACK( lv2ui_button_press_event ), this);
	g_signal_connect (drawingArea, "button-release-event", G_CALLBACK( lv2ui_button_release_event ), this);
	
	g_signal_connect (drawingArea, "destroy",	       G_CALLBACK( lv2ui_destroy_widget ), this);

	// Event mask
	gint mask = gtk_widget_get_events(drawingArea);

	mask |= GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK;

	gtk_widget_set_events(drawingArea, mask);

	int c_idx = 3;

	// Pitch, volume & bass volume
	Wdgt::Draggable *pitch = wdgtPerLabel["pitch"];
	pitch->setPortIndex(c_idx++);

	Wdgt::Draggable *volume = wdgtPerLabel["volume"];
	volume->setPortIndex(c_idx++);

	Wdgt::Draggable *bass_v = wdgtPerLabel["bass volume"];
	bass_v->setPortIndex(c_idx++);

	// Vibrato section
	// Instead of the touch vibrato, we have a realism switch
	Wdgt::Draggable *realism = wdgtPerLabel["realism"];
	realism->setPortIndex(c_idx++);
	
	Wdgt::Draggable *vibrato = wdgtPerLabel["depth"];
	vibrato->setPortIndex(c_idx++);

	Wdgt::Draggable *v_speed = wdgtPerLabel["speed"];
	v_speed->setPortIndex(c_idx++);

	// Bass
	Wdgt::Draggable *bass_16 = wdgtPerLabel["16' b"];
	bass_16->setPortIndex(c_idx++);

	Wdgt::Draggable *bass_8 = wdgtPerLabel["8' b"];
	bass_8->setPortIndex(c_idx++);

	Wdgt::Draggable *bass_man = wdgtPerLabel["bass manual"];
	bass_man->setPortIndex(c_idx++);

	// Section I
	Wdgt::Draggable *sect1_16 = wdgtPerLabel["16' i"];
	sect1_16->setPortIndex(c_idx++);

	Wdgt::Draggable *sect1_8 = wdgtPerLabel["8' i"];
	sect1_8->setPortIndex(c_idx++);

	Wdgt::Draggable *sect1_4 = wdgtPerLabel["4' i"];
	sect1_4->setPortIndex(c_idx++);

	Wdgt::Draggable *sect1_2_2p3 = wdgtPerLabel["2 2/3' i"];
	sect1_2_2p3->setPortIndex(c_idx++);

	Wdgt::Draggable *sect1_2 = wdgtPerLabel["2' i"];
	sect1_2->setPortIndex(c_idx++);

	Wdgt::Draggable *sect1_1_3p5 = wdgtPerLabel["1 3/5' i"];
	sect1_1_3p5->setPortIndex(c_idx++);

	Wdgt::Draggable *sect1_1 = wdgtPerLabel["1' i"];
	sect1_1->setPortIndex(c_idx++);

	// Balance & Brightness
	Wdgt::Draggable *balance = wdgtPerLabel["balance"];
	balance->setPortIndex(c_idx++);

	Wdgt::Draggable *brightness = wdgtPerLabel["bright"];
	brightness->setPortIndex(c_idx++);

	// Section II
	Wdgt::Draggable *sect2_16 = wdgtPerLabel["16' ii"];
	sect2_16->setPortIndex(c_idx++);

	Wdgt::Draggable *sect2_8 = wdgtPerLabel["8' ii"];
	sect2_8->setPortIndex(c_idx++);

	Wdgt::Draggable *sect2_4 = wdgtPerLabel["4' ii"];
	sect2_4->setPortIndex(c_idx++);

	Wdgt::Draggable *sect2_2 = wdgtPerLabel["2' ii"];
	sect2_2->setPortIndex(c_idx++);

//.........这里部分代码省略.........
开发者ID:abrahamian,项目名称:foo-yc20,代码行数:101,代码来源:foo-yc20-ui2.cpp

示例13: _lib_modulelist_gui_update

static void _lib_modulelist_gui_update(struct dt_lib_module_t *module)
{
  gtk_widget_queue_draw(GTK_WIDGET(((dt_lib_modulelist_t *)module->data)->tree));
}
开发者ID:nlannuzel,项目名称:darktable,代码行数:4,代码来源:modulelist.c

示例14: _lib_modulelist_populate_callback

static void _lib_modulelist_populate_callback(gpointer instance, gpointer user_data)
{
  dt_lib_module_t *self = (dt_lib_module_t *)user_data;
  if(!self || !(self->data)) return;

  GtkListStore *store;
  GtkTreeIter iter;
  GtkWidget *view = GTK_WIDGET(((dt_lib_modulelist_t *)self->data)->tree);
  GtkCellRenderer *pix_renderer, *fav_renderer, *text_renderer;
  GdkRGBA color;
  GtkStyleContext *context = gtk_widget_get_style_context(view);
  gboolean color_found = gtk_style_context_lookup_color (context, "selected_bg_color", &color);
  if(!color_found)
  {
    color.red = 1.0;
    color.green = 0.0;
    color.blue = 0.0;
    color.alpha = 1.0;
  }

  store = gtk_list_store_new(NUM_COLS, GDK_TYPE_PIXBUF, G_TYPE_POINTER);
  gtk_tree_view_set_model(GTK_TREE_VIEW(view), GTK_TREE_MODEL(store));
  g_object_unref(store);

  gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(store), COL_MODULE, _lib_modulelist_gui_sort, NULL, NULL);
  gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(store), COL_MODULE, GTK_SORT_ASCENDING);

  pix_renderer = gtk_cell_renderer_pixbuf_new();
  g_object_set(pix_renderer, "cell-background-rgba", &color, NULL);

  fav_renderer = gtk_cell_renderer_pixbuf_new();
  cairo_surface_t *fav_cst = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, ICON_SIZE, ICON_SIZE);
  cairo_t *fav_cr = cairo_create(fav_cst);
  cairo_set_source_rgb(fav_cr, 0.7, 0.7, 0.7);
  dtgtk_cairo_paint_modulegroup_favorites(fav_cr, 0, 0, ICON_SIZE, ICON_SIZE, 0);
  guchar *data = cairo_image_surface_get_data(fav_cst);
  dt_draw_cairo_to_gdk_pixbuf(data, ICON_SIZE, ICON_SIZE);
  ((dt_lib_modulelist_t *)self->data)->fav_pixbuf
      = gdk_pixbuf_new_from_data(data, GDK_COLORSPACE_RGB, TRUE, 8, ICON_SIZE, ICON_SIZE,
                                 cairo_image_surface_get_stride(fav_cst), NULL, NULL);
  g_object_set(fav_renderer, "cell-background-rgba", &color, NULL);
  g_object_set(fav_renderer, "width", gdk_pixbuf_get_width(((dt_lib_modulelist_t *)self->data)->fav_pixbuf),
               NULL);

  text_renderer = gtk_cell_renderer_text_new();
  g_object_set(text_renderer, "cell-background-rgba", &color, NULL);

  gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view), FALSE);
  gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(view), FALSE);
  GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
  gtk_tree_selection_set_mode(selection, GTK_SELECTION_NONE);

  GtkTreeViewColumn *col;
  col = gtk_tree_view_get_column(GTK_TREE_VIEW(view), 0);
  if(col) gtk_tree_view_remove_column(GTK_TREE_VIEW(view), col);
  gtk_tree_view_insert_column_with_data_func(GTK_TREE_VIEW(view), 0, "favorite", fav_renderer,
                                             favorite_renderer_function, NULL, NULL);
  col = gtk_tree_view_get_column(GTK_TREE_VIEW(view), 1);
  if(col) gtk_tree_view_remove_column(GTK_TREE_VIEW(view), col);
  gtk_tree_view_insert_column_with_data_func(GTK_TREE_VIEW(view), 1, "image", pix_renderer,
                                             image_renderer_function, NULL, NULL);
  col = gtk_tree_view_get_column(GTK_TREE_VIEW(view), 2);
  if(col) gtk_tree_view_remove_column(GTK_TREE_VIEW(view), col);
  gtk_tree_view_insert_column_with_data_func(GTK_TREE_VIEW(view), 2, "name", text_renderer,
                                             text_renderer_function, NULL, NULL);

  /* go thru list of iop modules and add them to the list */
  GList *modules = g_list_last(darktable.iop);

  char datadir[PATH_MAX] = { 0 };
  dt_loc_get_datadir(datadir, sizeof(datadir));

  while(modules)
  {
    dt_iop_module_so_t *module = (dt_iop_module_so_t *)(modules->data);
    if(!dt_iop_so_is_hidden(module) && !(module->flags() & IOP_FLAGS_DEPRECATED))
    {
      GdkPixbuf *pixbuf;
      char filename[PATH_MAX] = { 0 };

      snprintf(filename, sizeof(filename), "%s/pixmaps/plugins/darkroom/%s.svg", datadir, module->op);
      pixbuf = load_image(filename);
      if(pixbuf) goto end;

      snprintf(filename, sizeof(filename), "%s/pixmaps/plugins/darkroom/%s.png", datadir, module->op);
      pixbuf = load_image(filename);
      if(pixbuf) goto end;

      snprintf(filename, sizeof(filename), "%s/pixmaps/plugins/darkroom/template.svg", datadir);
      pixbuf = load_image(filename);
      if(pixbuf) goto end;

      snprintf(filename, sizeof(filename), "%s/pixmaps/plugins/darkroom/template.png", datadir);
      pixbuf = load_image(filename);
      if(pixbuf) goto end;

      // wow, we could neither load the SVG nor the PNG files. something is fucked up.
      pixbuf = gdk_pixbuf_new_from_data(fallback_pixel, GDK_COLORSPACE_RGB, TRUE, 8, 1, 1, 4, NULL, NULL);

    end:
//.........这里部分代码省略.........
开发者ID:nlannuzel,项目名称:darktable,代码行数:101,代码来源:modulelist.c

示例15: get_child_position

static gboolean
get_child_position (GtkOverlay     *overlay,
                    GtkWidget      *widget,
                    GtkAllocation  *allocation,
                    GtkColorEditor *editor)
{
  GtkRequisition req;
  GtkAllocation alloc;
  gint s, e;

  gtk_widget_get_preferred_size (widget, &req, NULL);

  allocation->x = 0;
  allocation->y = 0;
  allocation->width = req.width;
  allocation->height = req.height;

  if (widget == editor->priv->sv_popup)
    {
      gtk_widget_translate_coordinates (editor->priv->sv_plane,
                                        gtk_widget_get_parent (editor->priv->grid),
                                        0, -6,
                                        &allocation->x, &allocation->y);
      if (gtk_widget_get_direction (GTK_WIDGET (overlay)) == GTK_TEXT_DIR_RTL)
        allocation->x = 0;
      else
        allocation->x = gtk_widget_get_allocated_width (GTK_WIDGET (overlay)) - req.width;
    }
  else if (widget == editor->priv->h_popup)
    {
      gtk_widget_get_allocation (editor->priv->h_slider, &alloc);
      gtk_range_get_slider_range (GTK_RANGE (editor->priv->h_slider), &s, &e);

      if (gtk_widget_get_direction (GTK_WIDGET (overlay)) == GTK_TEXT_DIR_RTL)
        gtk_widget_translate_coordinates (editor->priv->h_slider,
                                          gtk_widget_get_parent (editor->priv->grid),
                                          - req.width - 6, editor->priv->popup_position - req.height / 2,
                                          &allocation->x, &allocation->y);
      else
        gtk_widget_translate_coordinates (editor->priv->h_slider,
                                          gtk_widget_get_parent (editor->priv->grid),
                                          alloc.width + 6, editor->priv->popup_position - req.height / 2,
                                          &allocation->x, &allocation->y);
    }
  else if (widget == editor->priv->a_popup)
    {
      gtk_widget_get_allocation (editor->priv->a_slider, &alloc);
      gtk_range_get_slider_range (GTK_RANGE (editor->priv->a_slider), &s, &e);

      gtk_widget_translate_coordinates (editor->priv->a_slider,
                                        gtk_widget_get_parent (editor->priv->grid),
                                        editor->priv->popup_position - req.width / 2, - req.height - 6,
                                        &allocation->x, &allocation->y);
    }
  else
    return FALSE;

  allocation->x = CLAMP (allocation->x, 0, gtk_widget_get_allocated_width (GTK_WIDGET (overlay)) - req.width);
  allocation->y = CLAMP (allocation->y, 0, gtk_widget_get_allocated_height (GTK_WIDGET (overlay)) - req.height);

  return TRUE;
}
开发者ID:Vort,项目名称:gtk,代码行数:62,代码来源:gtkcoloreditor.c


注:本文中的GTK_WIDGET函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。