Esempio n. 1
0
static void
gimp_procedure_action_connect_proxy (GtkAction *action,
                                     GtkWidget *proxy)
{
  GimpProcedureAction *procedure_action = GIMP_PROCEDURE_ACTION (action);

  GTK_ACTION_CLASS (parent_class)->connect_proxy (action, proxy);

  if (GTK_IS_IMAGE_MENU_ITEM (proxy) && procedure_action->procedure)
    {
      GdkPixbuf *pixbuf;

      g_object_get (procedure_action->procedure,
                    "icon-pixbuf", &pixbuf,
                    NULL);

      if (pixbuf)
        {
          GtkSettings *settings = gtk_widget_get_settings (proxy);
          gint         width;
          gint         height;
          GtkWidget   *image;

          gtk_icon_size_lookup_for_settings (settings, GTK_ICON_SIZE_MENU,
                                             &width, &height);

          if (width  != gdk_pixbuf_get_width  (pixbuf) ||
              height != gdk_pixbuf_get_height (pixbuf))
            {
              GdkPixbuf *copy;

              copy = gdk_pixbuf_scale_simple (pixbuf, width, height,
                                              GDK_INTERP_BILINEAR);
              g_object_unref (pixbuf);
              pixbuf = copy;
            }

          image = gtk_image_new_from_pixbuf (pixbuf);
          gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (proxy), image);
          g_object_unref (pixbuf);
        }
    }
}
Esempio n. 2
0
void wxColourDialog::DialogToColourData()
{
    GtkColorSelection* sel = GTK_COLOR_SELECTION(
        gtk_color_selection_dialog_get_color_selection(
        GTK_COLOR_SELECTION_DIALOG(m_widget)));

#ifdef __WXGTK3__
    GdkRGBA clr;
    gtk_color_selection_get_current_rgba(sel, &clr);
#else
    GdkColor clr;
    gtk_color_selection_get_current_color(sel, &clr);
#endif
    m_data.SetColour(clr);

    // Extract custom palette:

    GtkSettings *settings = gtk_widget_get_settings(GTK_WIDGET(sel));
    gchar *pal;
    g_object_get(settings, "gtk-color-palette", &pal, NULL);

    GdkColor *colors;
    gint n_colors;
    if (gtk_color_selection_palette_from_string(pal, &colors, &n_colors))
    {
#if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */
#   pragma ivdep
#   pragma swp
#   pragma unroll
#   pragma prefetch
#   if 0
#       pragma simd noassert
#   endif
#endif /* VDM auto patch */
        for (int i = 0; i < n_colors && i < wxColourData::NUM_CUSTOM; i++)
        {
            m_data.SetCustomColour(i, wxColour(colors[i]));
        }
        g_free(colors);
    }

    g_free(pal);
}
static void
gtk_application_window_real_realize (GtkWidget *widget)
{
  GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (widget);
  GtkSettings *settings;

  settings = gtk_widget_get_settings (widget);

  g_signal_connect (settings, "notify::gtk-shell-shows-app-menu",
                    G_CALLBACK (gtk_application_window_shell_shows_app_menu_changed), window);
  g_signal_connect (settings, "notify::gtk-shell-shows-menubar",
                    G_CALLBACK (gtk_application_window_shell_shows_menubar_changed), window);

  GTK_WIDGET_CLASS (gtk_application_window_parent_class)->realize (widget);

  gtk_application_window_update_shell_shows_app_menu (window, settings);
  gtk_application_window_update_shell_shows_menubar (window, settings);
  gtk_application_window_update_menubar (window);
}
Esempio n. 4
0
static void
gsr2_scroll_value_changed_cb (GtkAdjustment *adj, gpointer user_data)
{
    GNCSplitReg2 *gsr = user_data;
    GncTreeModelSplitReg *model;
    gchar *text;
    gint  trans_position;

    model = gnc_ledger_display2_get_split_model_register (gsr->ledger);

    trans_position = gtk_adjustment_get_value (adj);

    text = gnc_tree_model_split_reg_get_tooltip (model, trans_position);

    g_object_set (gtk_widget_get_settings (gsr->scroll_bar), "gtk-tooltip-timeout", 2, NULL);

    gtk_widget_set_tooltip_text (gsr->scroll_bar, text);

    g_free (text);
}
/* Button up/down is being pressed. Update the time. */
static gboolean
hildon_time_picker_key_repeat_timeout           (gpointer tpicker)
{
    HildonTimePicker *picker;
    HildonTimePickerPrivate *priv = NULL;
    gint newval = 0;
    gint key_repeat = 0;

    picker = HILDON_TIME_PICKER(tpicker);
    g_assert(picker != NULL);

    priv = HILDON_TIME_PICKER_GET_PRIVATE (tpicker);
    g_assert (priv);

    /* Change the time, wrapping if needed */
    newval = priv->minutes + priv->mul;
    if (newval < 0)
        newval += MINS_IN_24H;

    hildon_time_picker_change_time (picker, newval);

    if (priv->start_key_repeat)
    {
        /* Get button press repeater timeout from settings (in milliseconds) */
        g_object_get (gtk_widget_get_settings ((GtkWidget *) tpicker), 
                        "gtk-timeout-repeat", &key_repeat, NULL);

        key_repeat *= 8;
            
        /* This is the first repeat. Shorten the timeout to key_repeat
           (instead of the first time's 3*key_repeat) */
        priv->timer_id = gdk_threads_add_timeout (key_repeat,
                hildon_time_picker_key_repeat_timeout,
                picker);
        priv->start_key_repeat = FALSE;

        return FALSE;
    }

    return TRUE;
}
Esempio n. 6
0
static gboolean
gimp_tool_check_click_distance (GimpTool         *tool,
                                const GimpCoords *coords,
                                guint32           time,
                                GimpDisplay      *display)
{
  GimpDisplayShell *shell;
  gint              double_click_time;
  gint              double_click_distance;

  if (! tool->in_click_distance)
    return FALSE;

  shell = gimp_display_get_shell (display);

  g_object_get (gtk_widget_get_settings (GTK_WIDGET (shell)),
                "gtk-double-click-time",     &double_click_time,
                "gtk-double-click-distance", &double_click_distance,
                NULL);

  if ((time - tool->button_press_time) > double_click_time)
    {
      tool->in_click_distance = FALSE;
    }
  else
    {
      GimpDisplayShell *shell = gimp_display_get_shell (display);
      gdouble           dx;
      gdouble           dy;

      dx = SCALEX (shell, tool->button_press_coords.x - coords->x);
      dy = SCALEY (shell, tool->button_press_coords.y - coords->y);

      if ((SQR (dx) + SQR (dy)) > SQR (double_click_distance))
        {
          tool->in_click_distance = FALSE;
        }
    }

  return tool->in_click_distance;
}
Esempio n. 7
0
static
gboolean
gsr2_scroll_button_event_cb (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
{
    GNCSplitReg2 *gsr = user_data;
    GncTreeModelSplitReg *model;
    gint trans_position;

    model = gnc_ledger_display2_get_split_model_register (gsr->ledger);

    trans_position = gtk_adjustment_get_value (gsr->scroll_adj);

    gnc_tree_model_split_reg_set_current_trans_by_position (model, trans_position);

//FIXME should we store what it was...
    g_object_set (gtk_widget_get_settings (gsr->scroll_bar), "gtk-tooltip-timeout", 500, NULL);

    g_signal_emit_by_name (model, "refresh_trans");

    return FALSE;
}
Esempio n. 8
0
static GtkWidget *
about_wireshark_page_new(void)
{
  GtkWidget   *main_vb, *msg_label /*, *icon*/;
  gchar       *message;

  main_vb = gtk_vbox_new(FALSE, 6);
  gtk_container_set_border_width(GTK_CONTAINER(main_vb), 12);

#if GTK_CHECK_VERSION(2,9,0)
  g_object_set(gtk_widget_get_settings(main_vb),
    "gtk-label-select-on-focus", FALSE, NULL);
#endif

  about_wireshark(top_level, main_vb);

  /* Construct the message string */
  message = g_strdup_printf(
       "Version " VERSION "%s\n"
       "\n"
       "%s"
       "\n"
       "%s"
       "\n"
       "%s"
       "\n"
       "Wireshark is Open Source Software released under the GNU General Public License.\n"
       "\n"
       "Check the man page and http://www.wireshark.org for more information.",
       wireshark_svnversion, get_copyright_info(), comp_info_str->str,
       runtime_info_str->str);

  msg_label = gtk_label_new(message);
  g_free(message);
  gtk_label_set_justify(GTK_LABEL(msg_label), GTK_JUSTIFY_FILL);
  gtk_label_set_selectable(GTK_LABEL(msg_label), TRUE);
  gtk_container_add(GTK_CONTAINER(main_vb), msg_label);

  return main_vb;
}
Esempio n. 9
0
/**
 * gtk_expander_set_expanded:
 * @expander: a #GtkExpander
 * @expanded: whether the child widget is revealed
 *
 * Sets the state of the expander. Set to %TRUE, if you want
 * the child widget to be revealed, and %FALSE if you want the
 * child widget to be hidden.
 *
 * Since: 2.4
 **/
void
gtk_expander_set_expanded (GtkExpander *expander,
			   gboolean     expanded)
{
  GtkExpanderPrivate *priv;

  g_return_if_fail (GTK_IS_EXPANDER (expander));

  priv = expander->priv;

  expanded = expanded != FALSE;

  if (priv->expanded != expanded)
    {
      GtkSettings *settings = gtk_widget_get_settings (GTK_WIDGET (expander));
      gboolean     enable_animations;

      priv->expanded = expanded;

      g_object_get (settings, "gtk-enable-animations", &enable_animations, NULL);

      if (enable_animations && gtk_widget_get_realized (GTK_WIDGET (expander)))
	{
	  gtk_expander_start_animation (expander);
	}
      else
	{
	  priv->expander_style = expanded ? GTK_EXPANDER_EXPANDED :
					    GTK_EXPANDER_COLLAPSED;

	  if (GTK_BIN (expander)->child)
	    {
	      gtk_widget_set_child_visible (GTK_BIN (expander)->child, priv->expanded);
	      gtk_widget_queue_resize (GTK_WIDGET (expander));
	    }
	}

      g_object_notify (G_OBJECT (expander), "expanded");
    }
}
Esempio n. 10
0
static void
_gtk_gesture_multi_press_update_timeout (GtkGestureMultiPress *gesture)
{
    GtkGestureMultiPressPrivate *priv;
    guint double_click_time;
    GtkSettings *settings;
    GtkWidget *widget;

    priv = gtk_gesture_multi_press_get_instance_private (gesture);

    if (priv->double_click_timeout_id)
        g_source_remove (priv->double_click_timeout_id);

    widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (gesture));
    settings = gtk_widget_get_settings (widget);
    g_object_get (settings, "gtk-double-click-time", &double_click_time, NULL);

    priv->double_click_timeout_id =
        gdk_threads_add_timeout (double_click_time,
                                 _double_click_timeout_cb,
                                 gesture);
}
Esempio n. 11
0
/**
 * ephy_notebook_prev_page:
 * @notebook: an #EphyNotebook
 *
 * Advances to the previous page in the @notebook. Note that unlike
 * gtk_notebook_next_page() this method will wrap around if
 * #GtkSettings:gtk-keynav-wrap-around is set.
 **/
void
ephy_notebook_prev_page (EphyNotebook *notebook)
{
  gint current_page;

  g_assert (EPHY_IS_NOTEBOOK (notebook));

  current_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));

  if (current_page > 0)
    gtk_notebook_prev_page (GTK_NOTEBOOK (notebook));
  else {
    gboolean wrap_around;

    g_object_get (gtk_widget_get_settings (GTK_WIDGET (notebook)),
                  "gtk-keynav-wrap-around", &wrap_around,
                  NULL);

    if (wrap_around)
      gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), -1);
  }
}
Esempio n. 12
0
static GtkRevealerTransitionType
effective_transition (GtkRevealer *revealer)
{
  GtkRevealerPrivate *priv = gtk_revealer_get_instance_private (revealer);
  gboolean animations_enabled;

  g_object_get (gtk_widget_get_settings (GTK_WIDGET (revealer)),
                "gtk-enable-animations", &animations_enabled,
                NULL);
  if (!animations_enabled)
    return GTK_REVEALER_TRANSITION_TYPE_NONE;

  if (gtk_widget_get_direction (GTK_WIDGET (revealer)) == GTK_TEXT_DIR_RTL)
    {
      if (priv->transition_type == GTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT)
        return GTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT;
      else if (priv->transition_type == GTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT)
        return GTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT;
    }

  return priv->transition_type;
}
Esempio n. 13
0
static void
ephy_title_box_switch_to_entry_after_double_click_time (EphyTitleBox *title_box)
{
  gint double_click_time;

  if (title_box->switch_to_entry_timeout_id > 0)
    return;

  LOG ("switch_to_entry_after_double_click_time title-box %p switch_to_entry_timeout_id %u",
       title_box, title_box->switch_to_entry_timeout_id);

  g_object_get (gtk_widget_get_settings (GTK_WIDGET (title_box)),
                "gtk-double-click-time", &double_click_time,
                NULL);

  /* We don't want to wait the maximum time allowed between two
   * clicks before showing the entry. A quarter of this time is enough.
   */
  title_box->switch_to_entry_timeout_id = g_timeout_add (double_click_time / 4,
                                                         ephy_title_box_switch_to_entry_timeout_cb,
                                                         title_box);
}
Esempio n. 14
0
void
nautilus_notebook_prev_page (NautilusNotebook *notebook)
{
	gint current_page;

	g_return_if_fail (NAUTILUS_IS_NOTEBOOK (notebook));

	current_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));

	if (current_page > 0)
		gtk_notebook_prev_page (GTK_NOTEBOOK (notebook));
	else {
		gboolean  wrap_around;

		g_object_get (gtk_widget_get_settings (GTK_WIDGET (notebook)),
			      "gtk-keynav-wrap-around", &wrap_around,
			      NULL);

		if (wrap_around)
			gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), -1);
	}
}
Esempio n. 15
0
/*
 * We need to override this because when we don't show the tabs, like in
 * fullscreen we need to have wrap around too
 */
static gboolean
gedit_notebook_change_current_page (GtkNotebook *notebook,
				    gint         offset)
{
	gboolean wrap_around;
	gint current;

	current = gtk_notebook_get_current_page (notebook);

	if (current != -1)
	{
		current = current + offset;

		g_object_get (gtk_widget_get_settings (GTK_WIDGET (notebook)),
			      "gtk-keynav-wrap-around", &wrap_around,
			      NULL);

		if (wrap_around)
		{
			if (current < 0)
			{
				current = gtk_notebook_get_n_pages (notebook) - 1;
			}
			else if (current >= gtk_notebook_get_n_pages (notebook))
			{
				current = 0;
			}
		}

		gtk_notebook_set_current_page (notebook, current);
	}
	else
	{
		gtk_widget_error_bell (GTK_WIDGET (notebook));
	}

	return TRUE;
}
static GtkWidget* inputMethodsMenuItem (WebKitWebView* webView)
{
    if (gtk_major_version > 2 || (gtk_major_version == 2 && gtk_minor_version >= 10)) {
        GtkSettings* settings = webView ? gtk_widget_get_settings(GTK_WIDGET(webView)) : gtk_settings_get_default();

        gboolean showMenu = TRUE;
        if (settings)
            g_object_get(settings, "gtk-show-input-method-menu", &showMenu, NULL);
        if (!showMenu)
            return 0;
    }

    GtkWidget* menuitem = gtk_image_menu_item_new_with_mnemonic(
        _("Input _Methods"));

    WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW_GET_PRIVATE(webView);
    GtkWidget* imContextMenu = gtk_menu_new();
    gtk_im_multicontext_append_menuitems(GTK_IM_MULTICONTEXT(priv->imContext), GTK_MENU_SHELL(imContextMenu));

    gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), imContextMenu);

    return menuitem;
}
Esempio n. 17
0
static gboolean
gtk_expander_drag_motion (GtkWidget        *widget,
			  GdkDragContext   *context,
			  gint              x,
			  gint              y,
			  guint             time)
{
  GtkExpander *expander = GTK_EXPANDER (widget);
  GtkExpanderPrivate *priv = expander->priv;

  if (!priv->expanded && !priv->expand_timer)
    {
      GtkSettings *settings;
      guint timeout;

      settings = gtk_widget_get_settings (widget);
      g_object_get (settings, "gtk-timeout-expand", &timeout, NULL);

      priv->expand_timer = gdk_threads_add_timeout (timeout, (GSourceFunc) expand_timeout, expander);
    }

  return TRUE;
}
Esempio n. 18
0
static gboolean
gimp_tag_popup_scroll_timeout_initial (gpointer data)
{
  GimpTagPopup *popup = data;
  guint         timeout;
  gboolean      touchscreen_mode;

  g_object_get (gtk_widget_get_settings (GTK_WIDGET (popup)),
                "gtk-timeout-repeat",   &timeout,
                "gtk-touchscreen-mode", &touchscreen_mode,
                NULL);

  gimp_tag_popup_scroll_by (popup, popup->scroll_step);

  gimp_tag_popup_remove_scroll_timeout (popup);

  popup->scroll_timeout_id =
    gdk_threads_add_timeout (timeout,
                             gimp_tag_popup_scroll_timeout,
                             popup);

  return FALSE;
}
Esempio n. 19
0
static void
editing_started_cb (GtkCellRenderer     *renderer,
                    GtkCellEditable     *editable,
                    gchar               *path,
                    struct editing_data *data)
{
    gchar *name;
    gint   len;
    gint   dot;
    gchar *s;

    g_signal_handler_disconnect (renderer, data->editing_started_sid);
    data->editing_started_sid = 0;

    data->editing_done_sid = g_signal_connect (editable, "editing-done",
            (GCallback) editing_done_cb, data);
    data->key_press_event_sid = g_signal_connect (editable, "key-press-event",
            (GCallback) _key_press_ctrl_a_cb, NULL);

    /* do not select the whole name */
    g_object_set (gtk_widget_get_settings ((GtkWidget *) editable),
            "gtk-entry-select-on-focus", FALSE, NULL);
    /* locate the dot before the extension */
    name = donna_node_get_name (data->node);
    dot = -1;
    for (len = 1, s = g_utf8_next_char (name);
            *s != '\0';
            ++len, s = g_utf8_next_char (s))
    {
        if (*s == '.')
            dot = len;
    }
    g_free (name);
    /* select only up to the .ext, or all if no .ext found */
    gtk_editable_select_region ((GtkEditable *) editable, 0, dot);
}
Esempio n. 20
0
static void
gtk_image_menu_item_screen_changed (GtkWidget *widget,
                                    GdkScreen *previous_screen)
{
    GtkSettings *settings;
    gulong show_image_connection;

    if (!gtk_widget_has_screen (widget))
        return;

    settings = gtk_widget_get_settings (widget);

    show_image_connection =
        g_signal_handler_find (settings, G_SIGNAL_MATCH_FUNC, 0, 0,
                               NULL, gtk_image_menu_item_setting_changed, NULL);

    if (show_image_connection)
        return;

    g_signal_connect (settings, "notify::gtk-menu-images",
                      G_CALLBACK (gtk_image_menu_item_setting_changed), NULL);

    show_image_change_notify (GTK_IMAGE_MENU_ITEM (widget));
}
Esempio n. 21
0
static GtkWidget *
gimp_container_box_get_preview (GimpDocked   *docked,
                                GimpContext  *context,
                                GtkIconSize   size)
{
  GimpContainerBox  *box  = GIMP_CONTAINER_BOX (docked);
  GimpContainerView *view = GIMP_CONTAINER_VIEW (docked);
  GimpContainer     *container;
  GtkWidget         *preview;
  gint               width;
  gint               height;
  gint               border_width = 1;
  const gchar       *prop_name;

  container = gimp_container_view_get_container (view);

  g_return_val_if_fail (container != NULL, NULL);

  gtk_icon_size_lookup_for_settings (gtk_widget_get_settings (GTK_WIDGET (box)),
                                     size, &width, &height);

  prop_name = gimp_context_type_to_prop_name (container->children_type);

  preview = gimp_prop_view_new (G_OBJECT (context), prop_name,
                                context, height);
  GIMP_VIEW (preview)->renderer->size = -1;

  gimp_container_view_get_view_size (view, &border_width);

  border_width = MIN (1, border_width);

  gimp_view_renderer_set_size_full (GIMP_VIEW (preview)->renderer,
                                    width, height, border_width);

  return preview;
}
Esempio n. 22
0
static gboolean
gimp_tag_popup_button_scroll (GimpTagPopup   *popup,
                              GdkEventButton *event)
{
  if (popup->upper_arrow_prelight || popup->lower_arrow_prelight)
    {
      gboolean touchscreen_mode;

      g_object_get (gtk_widget_get_settings (GTK_WIDGET (popup)),
                    "gtk-touchscreen-mode", &touchscreen_mode,
                    NULL);

      if (touchscreen_mode)
        gimp_tag_popup_handle_scrolling (popup,
                                         event->x_root,
                                         event->y_root,
                                         event->type == GDK_BUTTON_PRESS,
                                         FALSE);

      return TRUE;
    }

  return FALSE;
}
Esempio n. 23
0
static Tcolsel *colsel_dialog(Tbfwin *bfwin,const gchar *setcolor, gint modal, gint startpos, gint endpos) {
	Tcolsel *csd;
	GtkWidget *vbox, *hbox, *but;
	GdkColor gcolor;
	const gchar *this_color=setcolor;
	csd = g_new0(Tcolsel, 1);
	/* warning: bfwin might be NULL if this dialog is started by return_color() */
	csd->bfwin = bfwin;
	csd->is_modal = modal;
	csd->startpos = startpos;
	csd->endpos = endpos;
	csd->returnval = setcolor ? g_strdup(setcolor) : g_strdup("");
	
	DEBUG_MSG("colsel_dialog, malloced at %p, setcolor=%s\n", csd, setcolor);
	csd->win = window_full2(_("Bluefish: Select color"), GTK_WIN_POS_CENTER, 12, G_CALLBACK(colsel_destroy_lcb), csd, TRUE, bfwin?bfwin->main_window:NULL);
	vbox = gtk_vbox_new(FALSE, 0);
	gtk_container_add(GTK_CONTAINER(csd->win), vbox);
	csd->csel = gtk_color_selection_new();
	gtk_color_selection_set_has_opacity_control(GTK_COLOR_SELECTION(csd->csel), FALSE);
	if (this_color) {
		if (gdk_color_parse(this_color, &gcolor)) {
			gtk_color_selection_set_current_color(GTK_COLOR_SELECTION(csd->csel), &gcolor);
		} else {
			this_color=NULL;
		}
	}
	gtk_color_selection_set_has_palette(GTK_COLOR_SELECTION(csd->csel), TRUE);
	gtk_box_pack_start(GTK_BOX(vbox), csd->csel, TRUE, TRUE, 0);

	hbox = gtk_hbox_new(FALSE, 0);
	gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 12);
#if GTK_CHECK_VERSION(3,0,0)
	hbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
#else
	hbox = gtk_hbutton_box_new();
#endif
	gtk_button_box_set_layout(GTK_BUTTON_BOX(hbox), GTK_BUTTONBOX_END);
	gtk_box_set_spacing(GTK_BOX(hbox), 12);
	gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);

	but = bf_stock_cancel_button(G_CALLBACK(colsel_cancel_clicked_lcb), csd);
	gtk_box_pack_start(GTK_BOX(hbox), but, TRUE, TRUE, 0);
	but = bf_stock_ok_button(G_CALLBACK(colsel_ok_clicked_lcb), csd);
	gtk_window_set_default(GTK_WINDOW(csd->win), but);
	gtk_box_pack_start(GTK_BOX(hbox), but, TRUE, TRUE, 0);

	if (bfwin && bfwin->session->colorlist) {
		GtkSettings* gtksettings;
		/* Note that this function can only be called when the GtkWidget is attached to a toplevel, since the settings object is specific to a particular GdkScreen.  */
		gtksettings = gtk_widget_get_settings(GTK_WIDGET(csd->csel));
		if (gtksettings) {
			gchar *strings;
			DEBUG_MSG("pallette list=%d\n",g_list_length(bfwin->session->colorlist));
			bfwin->session->colorlist = limit_stringlist(bfwin->session->colorlist, 20, TRUE);
			DEBUG_MSG("pallette list=%d\n",g_list_length(bfwin->session->colorlist));
			strings = stringlist_to_string(bfwin->session->colorlist, ":");
			strings[strlen(strings)-1] = '\0';
			/* this property may contain max 20 colors, otherwise gtk will crash */
			g_object_set(G_OBJECT(gtksettings), "gtk-color-palette", strings, NULL);
			g_free(strings);
		} 
/*		DEBUG_MSG("colsel_dialog, setting palette from %s\n", strings);
		if (gtk_color_selection_palette_from_string(strings, &gcolorarr, &num)) {
			DEBUG_MSG("num=%d, gcolorarr=%p\n",num,gcolorarr);
		} else {
			DEBUG_MSG("hmm, failed to parse our string :(\n");
		} */
	}

	gtk_widget_show_all(csd->win);

	DEBUG_MSG("colsel_dialog, finished\n");
	return csd;
}
Esempio n. 24
0
MidoriBrowser*
midori_private_app_new (const gchar* config,
                        const gchar* webapp,
                        gchar**      open_uris,
                        gchar**      execute_commands,
                        gint         inactivity_reset,
                        const gchar* block_uris)
{
    guint i;

    midori_paths_init (MIDORI_RUNTIME_MODE_PRIVATE, config);
#ifndef HAVE_WEBKIT2
    g_object_set_data (G_OBJECT (webkit_get_default_session ()), "pass-through-console", (void*)1);
#endif

    /* Mask the timezone, which can be read by Javascript */
    g_setenv ("TZ", "UTC", TRUE);

    MidoriBrowser* browser = midori_browser_new ();
    g_signal_connect (browser, "new-window",
        G_CALLBACK (midori_frontend_browser_new_window_cb), NULL);

    MidoriWebSettings* settings = midori_settings_new_full (NULL);
    g_object_set (settings,
                  "preferred-languages", "en",
                  "enable-private-browsing", TRUE,
    #ifdef HAVE_LIBSOUP_2_29_91
                  "first-party-cookies-only", TRUE,
    #endif
                  "enable-html5-database", FALSE,
                  "enable-html5-local-storage", FALSE,
                  "enable-offline-web-application-cache", FALSE,
    /* Arguably DNS prefetching is or isn't a privacy concern. For the
     * lack of more fine-grained control we'll go the safe route. */
                  "enable-dns-prefetching", FALSE,
                  "strip-referer", TRUE,
                  "show-panel", FALSE,
                  "last-window-state", MIDORI_WINDOW_NORMAL,
                  "inactivity-reset", inactivity_reset,
                  "block-uris", block_uris,
                  NULL);
    midori_load_soup_session (settings);

    /* In-memory trash for re-opening closed tabs */
    KatzeArray* trash = katze_array_new (KATZE_TYPE_ITEM);
    g_signal_connect_after (trash, "add-item",
      G_CALLBACK (midori_trash_add_item_no_save_cb), NULL);

    KatzeArray* search_engines = midori_search_engines_new_from_folder (NULL);
    g_object_set (browser,
                  "settings", settings,
                  "trash", trash,
                  "search-engines", search_engines,
                  NULL);
    g_object_unref (settings);
    g_object_unref (trash);
    g_object_unref (search_engines);

    midori_browser_set_action_visible (browser, "Tools", FALSE);
    midori_browser_set_action_visible (browser, "ClearPrivateData", FALSE);
#if ENABLE_ADDSPEEDDIAL
    midori_browser_set_action_visible (browser, "AddSpeedDial", FALSE);
#endif
    #if GTK_CHECK_VERSION (3, 0, 0)
    g_object_set (gtk_widget_get_settings (GTK_WIDGET (browser)),
                  "gtk-application-prefer-dark-theme", TRUE,
                  NULL);
    #endif

    if (webapp != NULL)
    {
        gchar* tmp_uri = sokoke_magic_uri (webapp, FALSE, TRUE);
        g_object_set (settings, "homepage", tmp_uri, NULL);
        midori_browser_add_uri (browser, tmp_uri);
        g_free (tmp_uri);
    }

    for (i = 0; open_uris && open_uris[i]; i++)
    {
        gchar* new_uri = sokoke_magic_uri (open_uris[i], FALSE, TRUE);
        midori_browser_add_uri (browser, new_uri);
        g_free (new_uri);
    }
    if (midori_browser_get_n_pages (browser) == 0)
        midori_browser_add_uri (browser, "about:private");
    gtk_widget_show (GTK_WIDGET (browser));

    for (i = 0; execute_commands && execute_commands[i]; i++)
    {
        midori_browser_assert_action (browser, execute_commands[i]);
        midori_browser_activate_action (browser, execute_commands[i]);
    }

    /* FIXME need proper stock extension mechanism */
//由于整合了若干预置扩展,此处相应修改
#if 0
    midori_browser_activate_action (browser, "libtransfers." G_MODULE_SUFFIX "=true");
    midori_browser_activate_action (browser, "libabout." G_MODULE_SUFFIX "=true");
    midori_browser_activate_action (browser, "libopen-with." G_MODULE_SUFFIX "=true");
#else
    midori_browser_activate_action (browser, "libtransfers." G_MODULE_SUFFIX "=true");
    midori_browser_activate_action (browser, "libbuiltinextension." G_MODULE_SUFFIX "=true");
#endif
    
    g_assert (g_module_error () == NULL);

    return browser;
}
Esempio n. 25
0
/* part stolen from pidgin/gtkconv.c */
static GtkWidget *
capture_rename (PurplePlugin * plugin, const gchar * entry_init) {
    GdkColor red = { 0, 65535, 0, 0 };
    GtkWidget *dlgbox_rename;
    GtkWidget *hbox;
    GtkWidget *label;
    GtkWidget *entry;
    GtkWidget *warn_label;
    GtkWidget *gtkconv_window;
    GtkWidget *blist_window;
    GtkWidget *img;
    GtkWidget *content_area;

    img =
        gtk_image_new_from_stock (PIDGIN_STOCK_DIALOG_QUESTION,
                                  gtk_icon_size_from_name
                                  (PIDGIN_ICON_SIZE_TANGO_HUGE));
    gtkconv_window = get_receiver_window (plugin);
    blist_window = pidgin_blist_get_default_gtk_blist ()->window;

    dlgbox_rename = gtk_dialog_new_with_buttons (DLGBOX_CAPNAME_TITLE,
                                                 GTK_WINDOW ((gtkconv_window)
                                                             ? gtkconv_window
                                                             : blist_window),
                                                 GTK_DIALOG_MODAL |
                                                 GTK_DIALOG_DESTROY_WITH_PARENT,
                                                 GTK_STOCK_OK,
                                                 GTK_RESPONSE_OK, NULL);

#if GTK_CHECK_VERSION(2,14,0)
    content_area = gtk_dialog_get_content_area (GTK_DIALOG (dlgbox_rename));
#else
    content_area = GTK_DIALOG (dlgbox_rename)->vbox;
#endif

    gtk_dialog_set_default_response (GTK_DIALOG (dlgbox_rename),
                                     GTK_RESPONSE_OK);

    gtk_container_set_border_width (GTK_CONTAINER
                                    (dlgbox_rename), PIDGIN_HIG_BOX_SPACE);
    gtk_window_set_resizable (GTK_WINDOW (dlgbox_rename), FALSE);
    gtk_dialog_set_has_separator (GTK_DIALOG (dlgbox_rename), FALSE);
    gtk_box_set_spacing (GTK_BOX (content_area), PIDGIN_HIG_BORDER);
    gtk_container_set_border_width (GTK_CONTAINER (content_area),
                                    PIDGIN_HIG_BOX_SPACE);

    hbox = gtk_hbox_new (FALSE, PIDGIN_HIG_BORDER);
    gtk_container_add (GTK_CONTAINER (content_area), hbox);
    gtk_box_pack_start (GTK_BOX (hbox), img, FALSE, FALSE, 0);

    gtk_misc_set_alignment (GTK_MISC (img), 0, 0);
    label = gtk_label_new (DLGBOX_CAPNAME_LABEL);

    warn_label = gtk_label_new (NULL);

    gtk_widget_modify_fg (warn_label, GTK_STATE_NORMAL, &red);
    gtk_label_set_text (GTK_LABEL (warn_label), DLGBOX_CAPNAME_WARNEXISTS);
    gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
    gtk_box_pack_start (GTK_BOX (content_area), warn_label, FALSE, FALSE, 0);
    entry = gtk_entry_new ();

    gtk_entry_set_text (GTK_ENTRY (entry), entry_init);

    gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);

    g_object_set (gtk_widget_get_settings (entry),
                  "gtk-entry-select-on-focus", FALSE, NULL);
    g_signal_connect (G_OBJECT (entry), "changed",
                      G_CALLBACK (set_sensitive_if_input_and_noexist),
                      dlgbox_rename /* plugin */ );
    g_signal_connect (G_OBJECT (entry), "focus-out-event",
                      G_CALLBACK (entry_select_filename_in_focus_cb), plugin);

    g_signal_connect (G_OBJECT (entry), "focus-in-event",
                      G_CALLBACK (entry_select_filename_in_focus_cb), plugin);
    gtk_box_pack_start (GTK_BOX (hbox), entry, FALSE, FALSE, 0);

    gtk_widget_show (label);
    gtk_widget_show (entry);
    gtk_widget_show (img);
    gtk_widget_show (hbox);
    gtk_widget_show (content_area);

    g_object_set_data (G_OBJECT (dlgbox_rename), "entry", entry);
    g_object_set_data (G_OBJECT (dlgbox_rename), "warn-label", warn_label);
    return dlgbox_rename;
}
Esempio n. 26
0
static GtkWidget *
display_simple_dialog(gint type, gint btn_mask, char *message)
{
  GtkWidget   *win, *main_vb, *top_hb, *msg_vb, *type_pm, *msg_label, *ask_cb,
              *bbox, *ok_bt, *yes_bt, *bt, *save_bt, *dont_save_bt;
  GdkPixmap   *pixmap;
  GdkBitmap   *mask;
  GtkStyle    *style;
  GdkColormap *cmap;
  const gchar **icon;

  /* Main window */
  switch (type) {
  case ESD_TYPE_WARN :
    icon = stock_dialog_warning_48_xpm;
    break;
  case ESD_TYPE_CONFIRMATION:
    icon = stock_dialog_warning_48_xpm;
    break;
  case ESD_TYPE_ERROR:
    icon = stock_dialog_error_48_xpm;
    break;
  case ESD_TYPE_STOP :
    icon = stock_dialog_stop_48_xpm;
    break;
  case ESD_TYPE_INFO :
  default :
    icon = stock_dialog_info_48_xpm;
    break;
  }

  /*
   * The GNOME HIG:
   *
   *	http://developer.gnome.org/projects/gup/hig/1.0/windows.html#alert-windows
   *
   * says that the title should be empty for alert boxes, so there's "less
   * visual noise and confounding text."
   *
   * The Windows HIG:
   *
   *	http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwue/html/ch09f.asp
   *
   * says it should
   *
   *	...appropriately identify the source of the message -- usually
   *	the name of the object.  For example, if the message results
   *	from editing a document, the title text is the name of the
   *	document, optionally followed by the application name.  If the
   *	message results from a non-document object, then use the
   *	application name."
   *
   * and notes that the title is important "because message boxes might
   * not always the the result of current user interaction" (e.g., some
   * app might randomly pop something up, e.g. some browser letting you
   * know that it couldn't fetch something because of a timeout).
   *
   * It also says not to use "warning" or "caution", as there's already
   * an icon that tells you what type of alert it is, and that you
   * shouldn't say "error", as that provides no useful information.
   *
   * So we give it a title on Win32, and don't give it one on UN*X.
   * For now, we give it a Win32 title of just "Wireshark"; we should
   * arguably take an argument for the title.
   */
  if(btn_mask == ESD_BTN_NONE) {
	win = splash_window_new();
  } else {
#ifdef _WIN32
    win = dlg_window_new("Wireshark");
#else
    win = dlg_window_new("");
#endif
  }

  gtk_window_set_modal(GTK_WINDOW(win), TRUE);
  gtk_container_set_border_width(GTK_CONTAINER(win), 6);

  /* Container for our rows */
  main_vb = gtk_vbox_new(FALSE, 12);
  gtk_container_add(GTK_CONTAINER(win), main_vb);
  gtk_widget_show(main_vb);

  /* Top row: Icon and message text */
  top_hb = gtk_hbox_new(FALSE, 12);
  gtk_container_set_border_width(GTK_CONTAINER(main_vb), 6);
  gtk_container_add(GTK_CONTAINER(main_vb), top_hb);
  gtk_widget_show(top_hb);

  /* icon */
  style = gtk_widget_get_style(win);
  cmap  = gdk_colormap_get_system();
  pixmap = gdk_pixmap_colormap_create_from_xpm_d(NULL, cmap,  &mask,
    &style->bg[GTK_STATE_NORMAL], (gchar **) icon);
  type_pm = gtk_image_new_from_pixmap(pixmap, mask);
  gtk_misc_set_alignment (GTK_MISC (type_pm), 0.5f, 0.0f);
  gtk_container_add(GTK_CONTAINER(top_hb), type_pm);
  gtk_widget_show(type_pm);

  /* column for message and optional check button */
  msg_vb = gtk_vbox_new(FALSE, 6);
  gtk_box_set_spacing(GTK_BOX(msg_vb), 24);
  gtk_container_add(GTK_CONTAINER(top_hb), msg_vb);
  gtk_widget_show(msg_vb);

  /* message */
  msg_label = gtk_label_new(message);

  gtk_label_set_markup(GTK_LABEL(msg_label), message);
  gtk_label_set_selectable(GTK_LABEL(msg_label), TRUE);
#if GTK_CHECK_VERSION(2,9,0)
  g_object_set(gtk_widget_get_settings(msg_label),
    "gtk-label-select-on-focus", FALSE, NULL);
#endif

  gtk_label_set_justify(GTK_LABEL(msg_label), GTK_JUSTIFY_FILL);
  gtk_misc_set_alignment (GTK_MISC (type_pm), 0.5f, 0.0f);
  gtk_container_add(GTK_CONTAINER(msg_vb), msg_label);
  gtk_label_set_line_wrap(GTK_LABEL(msg_label), TRUE);
  gtk_widget_show(msg_label);

  if(btn_mask == ESD_BTN_NONE) {
	gtk_widget_show(win);
	return win;
  }

  /* optional check button */
  ask_cb = gtk_check_button_new_with_label("replace with text...");
  gtk_container_add(GTK_CONTAINER(msg_vb), ask_cb);
  g_object_set_data(G_OBJECT(win), CHECK_BUTTON, ask_cb);

  /* Button row */
  switch(btn_mask) {
  case(ESD_BTN_OK):
    bbox = dlg_button_row_new(GTK_STOCK_OK, NULL);
    break;
  case(ESD_BTN_OK | ESD_BTN_CANCEL):
    bbox = dlg_button_row_new(GTK_STOCK_OK, GTK_STOCK_CANCEL, NULL);
    break;
  case(ESD_BTN_CLEAR | ESD_BTN_CANCEL):
    bbox = dlg_button_row_new(GTK_STOCK_CLEAR, GTK_STOCK_CANCEL, NULL);
    break;
  case(ESD_BTNS_YES_NO_CANCEL):
    bbox = dlg_button_row_new(GTK_STOCK_YES, GTK_STOCK_NO, GTK_STOCK_CANCEL, NULL);
    break;
  case(ESD_BTNS_SAVE_DONTSAVE_CANCEL):
    bbox = dlg_button_row_new(GTK_STOCK_SAVE, WIRESHARK_STOCK_DONT_SAVE, GTK_STOCK_CANCEL, NULL);
    break;
  case(ESD_BTNS_SAVE_QUIT_DONTSAVE_CANCEL):
    bbox = dlg_button_row_new(GTK_STOCK_SAVE, WIRESHARK_STOCK_QUIT_DONT_SAVE, GTK_STOCK_CANCEL, NULL);
    break;
  case(ESD_BTNS_YES_NO):
    bbox = dlg_button_row_new(GTK_STOCK_YES, GTK_STOCK_NO, NULL);
    break;
  default:
    g_assert_not_reached();
    bbox = NULL;
    break;
  }
  gtk_container_add(GTK_CONTAINER(main_vb), bbox);
  gtk_widget_show(bbox);

  ok_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_OK);
  if(ok_bt) {
      g_object_set_data(G_OBJECT(ok_bt), CALLBACK_BTN_KEY, GINT_TO_POINTER(ESD_BTN_OK));
      g_signal_connect(ok_bt, "clicked", G_CALLBACK(simple_dialog_cancel_cb), win);
  }

  save_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_SAVE);
  if (save_bt) {
      g_object_set_data(G_OBJECT(save_bt), CALLBACK_BTN_KEY, GINT_TO_POINTER(ESD_BTN_SAVE));
      g_signal_connect(save_bt, "clicked", G_CALLBACK(simple_dialog_cancel_cb), win);
  }

  dont_save_bt = g_object_get_data(G_OBJECT(bbox), WIRESHARK_STOCK_DONT_SAVE);
  if (dont_save_bt) {
      g_object_set_data(G_OBJECT(dont_save_bt), CALLBACK_BTN_KEY, GINT_TO_POINTER(ESD_BTN_DONT_SAVE));
      g_signal_connect(dont_save_bt, "clicked", G_CALLBACK(simple_dialog_cancel_cb), win);
  }
  
  dont_save_bt = g_object_get_data(G_OBJECT(bbox), WIRESHARK_STOCK_QUIT_DONT_SAVE);
  if (dont_save_bt) {
      g_object_set_data(G_OBJECT(dont_save_bt), CALLBACK_BTN_KEY, GINT_TO_POINTER(ESD_BTN_QUIT_DONT_SAVE));
      g_signal_connect(dont_save_bt, "clicked", G_CALLBACK(simple_dialog_cancel_cb), win);
  }
  bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLEAR);
  if(bt) {
      g_object_set_data(G_OBJECT(bt), CALLBACK_BTN_KEY, GINT_TO_POINTER(ESD_BTN_CLEAR));
      g_signal_connect(bt, "clicked", G_CALLBACK(simple_dialog_cancel_cb), win);
  }

  yes_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_YES);
  if(yes_bt) {
      g_object_set_data(G_OBJECT(yes_bt), CALLBACK_BTN_KEY, GINT_TO_POINTER(ESD_BTN_YES));
      g_signal_connect(yes_bt, "clicked", G_CALLBACK(simple_dialog_cancel_cb), win);
  }

  bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_NO);
  if(bt) {
      g_object_set_data(G_OBJECT(bt), CALLBACK_BTN_KEY, GINT_TO_POINTER(ESD_BTN_NO));
      g_signal_connect(bt, "clicked", G_CALLBACK(simple_dialog_cancel_cb), win);
  }

  bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CANCEL);
  if(bt) {
      g_object_set_data(G_OBJECT(bt), CALLBACK_BTN_KEY, GINT_TO_POINTER(ESD_BTN_CANCEL));
      window_set_cancel_button(win, bt, simple_dialog_cancel_cb);
  }

  if(!bt) {
      if(yes_bt) {
          window_set_cancel_button(win, yes_bt, simple_dialog_cancel_cb);
      } else {
          window_set_cancel_button(win, ok_bt, simple_dialog_cancel_cb);
      }
  }

  dlg_button_focus_nth(bbox, 0);

  gtk_widget_show(win);

  return win;
}
static gboolean
gossip_cell_renderer_expander_activate (GtkCellRenderer      *cell,
                                        GdkEvent             *event,
                                        GtkWidget            *widget,
                                        const gchar          *path_string,
                                        const GdkRectangle   *background_area,
                                        const GdkRectangle   *cell_area,
                                        GtkCellRendererState flags)
{
    GossipCellRendererExpander     *expander;
    GossipCellRendererExpanderPriv *priv;
    GtkTreePath                    *path;
    GtkSettings                    *settings;
    gboolean                        animate = FALSE;
    gboolean                        expanding;
    gboolean                        in_cell;
    int                             mouse_x;
    int                             mouse_y;

    expander = GOSSIP_CELL_RENDERER_EXPANDER (cell);
    priv = GET_PRIV (cell);

    if (!GTK_IS_TREE_VIEW (widget) || !priv->activatable)
        return FALSE;

    path = gtk_tree_path_new_from_string (path_string);

    gtk_widget_get_pointer (widget, &mouse_x, &mouse_y);
    gtk_tree_view_convert_widget_to_bin_window_coords (GTK_TREE_VIEW (widget),
                                                       mouse_x, mouse_y,
                                                       &mouse_x, &mouse_y);

    /* check if click is within the cell */
    if (mouse_x - cell_area->x >= 0
        && mouse_x - cell_area->x <= cell_area->width) {
        in_cell = TRUE;
    } else {
        in_cell = FALSE;
    }

    if (! in_cell) {
        return FALSE;
    }

#if 0
    if (gtk_tree_path_get_depth (path) > 1) {
        gtk_tree_path_free (path);
        return TRUE;
    }
#endif
    settings = gtk_widget_get_settings (GTK_WIDGET (widget));
    if (g_object_class_find_property (G_OBJECT_GET_CLASS (settings), "gtk-enable-animations")) {
        g_object_get (settings,
                      "gtk-enable-animations", &animate,
                      NULL);
    }

    if (gtk_tree_view_row_expanded (GTK_TREE_VIEW (widget), path)) {
        gtk_tree_view_collapse_row (GTK_TREE_VIEW (widget), path);
        expanding = FALSE;
    } else {
        gtk_tree_view_expand_row (GTK_TREE_VIEW (widget), path, FALSE);
        expanding = TRUE;
    }

    if (animate) {
        gossip_cell_renderer_expander_start_animation (expander,
                                                       GTK_TREE_VIEW (widget),
                                                       path,
                                                       expanding,
                                                       background_area);
    }

    gtk_tree_path_free (path);

    return TRUE;
}
Esempio n. 28
0
static void
gimp_tag_popup_handle_scrolling (GimpTagPopup *popup,
                                 gint          x,
                                 gint          y,
                                 gboolean      enter,
                                 gboolean      motion)
{
  GdkRectangle rect;
  gboolean     in_arrow;
  gboolean     scroll_fast = FALSE;
  gboolean     touchscreen_mode;

  g_object_get (gtk_widget_get_settings (GTK_WIDGET (popup)),
                "gtk-touchscreen-mode", &touchscreen_mode,
                NULL);

  /*  upper arrow handling  */

  get_arrows_sensitive_area (popup, &rect, NULL);

  in_arrow = FALSE;
  if (popup->arrows_visible    &&
      x >= rect.x              &&
      x <  rect.x + rect.width &&
      y >= rect.y              &&
      y <  rect.y + rect.height)
    {
      in_arrow = TRUE;
    }

  if (touchscreen_mode)
    popup->upper_arrow_prelight = in_arrow;

  if (popup->upper_arrow_state != GTK_STATE_INSENSITIVE)
    {
      gboolean arrow_pressed = FALSE;

      if (popup->arrows_visible)
        {
          if (touchscreen_mode)
            {
              if (enter && popup->upper_arrow_prelight)
                {
                  if (popup->scroll_timeout_id == 0)
                    {
                      gimp_tag_popup_remove_scroll_timeout (popup);
                      popup->scroll_step = -MENU_SCROLL_STEP2; /* always fast */

                      if (! motion)
                        {
                          /* Only do stuff on click. */
                          gimp_tag_popup_start_scrolling (popup);
                          arrow_pressed = TRUE;
                        }
                    }
                  else
                    {
                      arrow_pressed = TRUE;
                    }
                }
              else if (! enter)
                {
                  gimp_tag_popup_stop_scrolling (popup);
                }
            }
          else /* !touchscreen_mode */
            {
              scroll_fast = (y < rect.y + MENU_SCROLL_FAST_ZONE);

              if (enter && in_arrow &&
                  (! popup->upper_arrow_prelight ||
                   popup->scroll_fast != scroll_fast))
                {
                  popup->upper_arrow_prelight = TRUE;
                  popup->scroll_fast          = scroll_fast;

                  gimp_tag_popup_remove_scroll_timeout (popup);
                  popup->scroll_step = (scroll_fast ?
                                        -MENU_SCROLL_STEP2 : -MENU_SCROLL_STEP1);

                  popup->scroll_timeout_id =
                    gdk_threads_add_timeout (scroll_fast ?
                                             MENU_SCROLL_TIMEOUT2 :
                                             MENU_SCROLL_TIMEOUT1,
                                             gimp_tag_popup_scroll_timeout,
                                             popup);
                }
              else if (! enter && ! in_arrow && popup->upper_arrow_prelight)
                {
                  gimp_tag_popup_stop_scrolling (popup);
                }
            }
        }

      /*  gimp_tag_popup_start_scrolling() might have hit the top of the
       *  tag_popup, so check if the button isn't insensitive before
       *  changing it to something else.
       */
      if (popup->upper_arrow_state != GTK_STATE_INSENSITIVE)
        {
          GtkStateType arrow_state = GTK_STATE_NORMAL;

          if (arrow_pressed)
            arrow_state = GTK_STATE_ACTIVE;
          else if (popup->upper_arrow_prelight)
            arrow_state = GTK_STATE_PRELIGHT;

          if (arrow_state != popup->upper_arrow_state)
            {
              popup->upper_arrow_state = arrow_state;

              gdk_window_invalidate_rect (gtk_widget_get_window (GTK_WIDGET (popup)),
                                          &rect, FALSE);
            }
        }
    }

  /*  lower arrow handling  */

  get_arrows_sensitive_area (popup, NULL, &rect);

  in_arrow = FALSE;
  if (popup->arrows_visible    &&
      x >= rect.x              &&
      x <  rect.x + rect.width &&
      y >= rect.y              &&
      y <  rect.y + rect.height)
    {
      in_arrow = TRUE;
    }

  if (touchscreen_mode)
    popup->lower_arrow_prelight = in_arrow;

  if (popup->lower_arrow_state != GTK_STATE_INSENSITIVE)
    {
      gboolean arrow_pressed = FALSE;

      if (popup->arrows_visible)
        {
          if (touchscreen_mode)
            {
              if (enter && popup->lower_arrow_prelight)
                {
                  if (popup->scroll_timeout_id == 0)
                    {
                      gimp_tag_popup_remove_scroll_timeout (popup);
                      popup->scroll_step = MENU_SCROLL_STEP2; /* always fast */

                      if (! motion)
                        {
                          /* Only do stuff on click. */
                          gimp_tag_popup_start_scrolling (popup);
                          arrow_pressed = TRUE;
                        }
                    }
                  else
                    {
                      arrow_pressed = TRUE;
                    }
                }
              else if (! enter)
                {
                  gimp_tag_popup_stop_scrolling (popup);
                }
            }
          else /* !touchscreen_mode */
            {
              scroll_fast = (y > rect.y + rect.height - MENU_SCROLL_FAST_ZONE);

              if (enter && in_arrow &&
                  (! popup->lower_arrow_prelight ||
                   popup->scroll_fast != scroll_fast))
                {
                  popup->lower_arrow_prelight = TRUE;
                  popup->scroll_fast          = scroll_fast;

                  gimp_tag_popup_remove_scroll_timeout (popup);
                  popup->scroll_step = (scroll_fast ?
                                        MENU_SCROLL_STEP2 : MENU_SCROLL_STEP1);

                  popup->scroll_timeout_id =
                    gdk_threads_add_timeout (scroll_fast ?
                                             MENU_SCROLL_TIMEOUT2 :
                                             MENU_SCROLL_TIMEOUT1,
                                             gimp_tag_popup_scroll_timeout,
                                             popup);
                }
              else if (! enter && ! in_arrow && popup->lower_arrow_prelight)
                {
                  gimp_tag_popup_stop_scrolling (popup);
                }
            }
        }

      /*  gimp_tag_popup_start_scrolling() might have hit the bottom of the
       *  popup, so check if the button isn't insensitive before
       *  changing it to something else.
       */
      if (popup->lower_arrow_state != GTK_STATE_INSENSITIVE)
        {
          GtkStateType arrow_state = GTK_STATE_NORMAL;

          if (arrow_pressed)
            arrow_state = GTK_STATE_ACTIVE;
          else if (popup->lower_arrow_prelight)
            arrow_state = GTK_STATE_PRELIGHT;

          if (arrow_state != popup->lower_arrow_state)
            {
              popup->lower_arrow_state = arrow_state;

              gdk_window_invalidate_rect (gtk_widget_get_window (GTK_WIDGET (popup)),
                                          &rect, FALSE);
            }
        }
    }
}
Esempio n. 29
0
static void
gimp_controller_list_init (GimpControllerList *list)
{
  GtkWidget         *hbox;
  GtkWidget         *sw;
  GtkWidget         *tv;
  GtkTreeViewColumn *column;
  GtkCellRenderer   *cell;
  GtkWidget         *vbox;
  GtkWidget         *image;
  GtkIconSize        icon_size;
  gint               icon_width;
  gint               icon_height;
  GType             *controller_types;
  guint              n_controller_types;
  gint               i;

  gtk_orientable_set_orientation (GTK_ORIENTABLE (list),
                                  GTK_ORIENTATION_VERTICAL);

  list->gimp = NULL;

  list->hbox = hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
  gtk_box_pack_start (GTK_BOX (list), hbox, TRUE, TRUE, 0);
  gtk_widget_show (hbox);

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

  list->src = gtk_list_store_new (N_COLUMNS,
                                  G_TYPE_STRING,
                                  G_TYPE_STRING,
                                  G_TYPE_GTYPE);
  tv = gtk_tree_view_new_with_model (GTK_TREE_MODEL (list->src));
  g_object_unref (list->src);

  gtk_tree_view_set_headers_clickable (GTK_TREE_VIEW (tv), FALSE);

  column = gtk_tree_view_column_new ();
  gtk_tree_view_column_set_title (column, _("Available Controllers"));
  gtk_tree_view_append_column (GTK_TREE_VIEW (tv), column);

  cell = gtk_cell_renderer_pixbuf_new ();
  gtk_tree_view_column_pack_start (column, cell, FALSE);
  gtk_tree_view_column_set_attributes (column, cell,
                                       "icon-name", COLUMN_ICON,
                                       NULL);

  g_object_get (cell, "stock-size", &icon_size, NULL);

  cell = gtk_cell_renderer_text_new ();
  gtk_tree_view_column_pack_start (column, cell, TRUE);
  gtk_tree_view_column_set_attributes (column, cell,
                                       "text", COLUMN_NAME,
                                       NULL);

  gtk_container_add (GTK_CONTAINER (sw), tv);
  gtk_widget_show (tv);

  g_signal_connect_object (tv, "row-activated",
                           G_CALLBACK (gimp_controller_list_row_activated),
                           G_OBJECT (list), 0);

  list->src_sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (tv));
  gtk_tree_selection_set_mode (list->src_sel, GTK_SELECTION_BROWSE);

  g_signal_connect_object (list->src_sel, "changed",
                           G_CALLBACK (gimp_controller_list_src_sel_changed),
                           G_OBJECT (list), 0);

  controller_types = g_type_children (GIMP_TYPE_CONTROLLER,
                                      &n_controller_types);

  for (i = 0; i < n_controller_types; i++)
    {
      GimpControllerClass *controller_class;
      GtkTreeIter          iter;

      controller_class = g_type_class_ref (controller_types[i]);

      gtk_list_store_append (list->src, &iter);
      gtk_list_store_set (list->src, &iter,
                          COLUMN_ICON, controller_class->icon_name,
                          COLUMN_NAME, controller_class->name,
                          COLUMN_TYPE, controller_types[i],
                          -1);

      g_type_class_unref (controller_class);
    }

  g_free (controller_types);

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
  gtk_box_set_homogeneous (GTK_BOX (vbox), TRUE);
  gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
  gtk_widget_show (vbox);

  list->add_button = gtk_button_new ();
  gtk_box_pack_start (GTK_BOX (vbox), list->add_button, TRUE, FALSE, 0);
  gtk_widget_set_sensitive (list->add_button, FALSE);
  gtk_widget_show (list->add_button);

  image = gtk_image_new_from_icon_name ("go-next",
                                        GTK_ICON_SIZE_BUTTON);
  gtk_container_add (GTK_CONTAINER (list->add_button), image);
  gtk_widget_show (image);

  g_signal_connect (list->add_button, "clicked",
                    G_CALLBACK (gimp_controller_list_add_clicked),
                    list);

  g_object_add_weak_pointer (G_OBJECT (list->add_button),
                             (gpointer) &list->add_button);

  list->remove_button = gtk_button_new ();
  gtk_box_pack_start (GTK_BOX (vbox), list->remove_button, TRUE, FALSE, 0);
  gtk_widget_set_sensitive (list->remove_button, FALSE);
  gtk_widget_show (list->remove_button);

  image = gtk_image_new_from_icon_name ("go-previous",
                                        GTK_ICON_SIZE_BUTTON);
  gtk_container_add (GTK_CONTAINER (list->remove_button), image);
  gtk_widget_show (image);

  g_signal_connect (list->remove_button, "clicked",
                    G_CALLBACK (gimp_controller_list_remove_clicked),
                    list);

  g_object_add_weak_pointer (G_OBJECT (list->remove_button),
                             (gpointer) &list->remove_button);

  gtk_icon_size_lookup_for_settings (gtk_widget_get_settings (GTK_WIDGET (list)),
                                     icon_size, &icon_width, &icon_height);

  list->dest = gimp_container_tree_view_new (NULL, NULL, icon_height, 0);
  gimp_container_tree_view_set_main_column_title (GIMP_CONTAINER_TREE_VIEW (list->dest),
                                                  _("Active Controllers"));
  gtk_tree_view_set_headers_visible (GIMP_CONTAINER_TREE_VIEW (list->dest)->view,
                                     TRUE);
  gtk_box_pack_start (GTK_BOX (list->hbox), list->dest, TRUE, TRUE, 0);
  gtk_widget_show (list->dest);

  g_signal_connect_object (list->dest, "select-item",
                           G_CALLBACK (gimp_controller_list_select_item),
                           G_OBJECT (list), 0);
  g_signal_connect_object (list->dest, "activate-item",
                           G_CALLBACK (gimp_controller_list_activate_item),
                           G_OBJECT (list), 0);

  list->edit_button =
    gimp_editor_add_button (GIMP_EDITOR (list->dest),
                            "document-properties",
                            _("Configure the selected controller"),
                            NULL,
                            G_CALLBACK (gimp_controller_list_edit_clicked),
                            NULL,
                            list);
  list->up_button =
    gimp_editor_add_button (GIMP_EDITOR (list->dest),
                            "go-up",
                            _("Move the selected controller up"),
                            NULL,
                            G_CALLBACK (gimp_controller_list_up_clicked),
                            NULL,
                            list);
  list->down_button =
    gimp_editor_add_button (GIMP_EDITOR (list->dest),
                            "go-down",
                            _("Move the selected controller down"),
                            NULL,
                            G_CALLBACK (gimp_controller_list_down_clicked),
                            NULL,
                            list);

  gtk_widget_set_sensitive (list->edit_button, FALSE);
  gtk_widget_set_sensitive (list->up_button,   FALSE);
  gtk_widget_set_sensitive (list->down_button, FALSE);
}
Esempio n. 30
0
static int gtkButtonMapMethod(Ihandle* ih)
{
  int impress;
  char* value;

  value = iupAttribGet(ih, "IMAGE");
  if (value)
  {
    ih->data->type = IUP_BUTTON_IMAGE;

    value = iupAttribGet(ih, "TITLE");
    if (value && *value!=0)
      ih->data->type |= IUP_BUTTON_TEXT;
  }
  else
    ih->data->type = IUP_BUTTON_TEXT;

  if (ih->data->type == IUP_BUTTON_IMAGE &&
      iupAttribGet(ih, "IMPRESS") &&
      !iupAttribGetBoolean(ih, "IMPRESSBORDER"))
  {
    GtkWidget *img = gtk_image_new();
    ih->handle = gtk_event_box_new();
    gtk_container_add((GtkContainer*)ih->handle, img);
    gtk_widget_show(img);
    iupAttribSetStr(ih, "_IUPGTK_EVENTBOX", "1");
  }
  else
    ih->handle = gtk_button_new();

  if (!ih->handle)
    return IUP_ERROR;

  if (ih->data->type & IUP_BUTTON_IMAGE)
  {
    if (!iupAttribGet(ih, "_IUPGTK_EVENTBOX"))
    {
      gtk_button_set_image((GtkButton*)ih->handle, gtk_image_new());

      if (ih->data->type & IUP_BUTTON_TEXT)
      {
        GtkSettings* settings = gtk_widget_get_settings(ih->handle);
        g_object_set(settings, "gtk-button-images", (int)TRUE, NULL);

        gtk_button_set_label((GtkButton*)ih->handle, iupgtkStrConvertToUTF8(iupAttribGet(ih, "TITLE")));
      
#if GTK_CHECK_VERSION(2, 10, 0)
        gtk_button_set_image_position((GtkButton*)ih->handle, ih->data->img_position);  /* IUP and GTK have the same Ids */
#endif
      }
    }
  }
  else
  {
    char* title = iupAttribGet(ih, "TITLE");
    if (!title) 
    {
      if (iupAttribGet(ih, "BGCOLOR"))
      {
        int x=0, y=0;
        GtkWidget* frame = gtk_frame_new(NULL);
#if GTK_CHECK_VERSION(2, 18, 0)
        GtkWidget* drawarea = gtk_drawing_area_new();
        gtk_widget_set_has_window(drawarea, TRUE);
#else
        GtkWidget* drawarea = gtk_fixed_new();
        gtk_fixed_set_has_window(GTK_FIXED(drawarea), TRUE);
#endif
        gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);
        iupdrvButtonAddBorders(&x, &y);
        gtk_widget_set_size_request (frame, ih->currentwidth-x, ih->currentheight-y);
        gtk_container_add(GTK_CONTAINER(frame), drawarea);
        gtk_widget_show(drawarea);

        gtk_button_set_image((GtkButton*)ih->handle, frame);
      }
      else
        gtk_button_set_label((GtkButton*)ih->handle, "");
    }
    else
      gtk_button_set_label((GtkButton*)ih->handle, iupgtkStrConvertToUTF8(title));
  }

  /* add to the parent, all GTK controls must call this. */
  iupgtkAddToParent(ih);

  if (!iupAttribGetBoolean(ih, "CANFOCUS"))
    iupgtkSetCanFocus(ih->handle, 0);

  value = iupAttribGet(ih, "IMPRESS");
  impress = (ih->data->type & IUP_BUTTON_IMAGE && value)? 1: 0;
  if (!impress && iupAttribGetBoolean(ih, "FLAT"))
  {
    gtk_button_set_relief((GtkButton*)ih->handle, GTK_RELIEF_NONE);

    g_signal_connect(G_OBJECT(ih->handle), "enter-notify-event", G_CALLBACK(gtkButtonEnterLeaveEvent), ih);
    g_signal_connect(G_OBJECT(ih->handle), "leave-notify-event", G_CALLBACK(gtkButtonEnterLeaveEvent), ih);
  }
  else
  {
    if (!iupAttribGet(ih, "_IUPGTK_EVENTBOX"))
    {
      if (impress && !iupAttribGetStr(ih, "IMPRESSBORDER"))
        gtk_button_set_relief((GtkButton*)ih->handle, GTK_RELIEF_NONE);
      else
        gtk_button_set_relief((GtkButton*)ih->handle, GTK_RELIEF_NORMAL);
    }

    g_signal_connect(G_OBJECT(ih->handle), "enter-notify-event", G_CALLBACK(iupgtkEnterLeaveEvent), ih);
    g_signal_connect(G_OBJECT(ih->handle), "leave-notify-event", G_CALLBACK(iupgtkEnterLeaveEvent), ih);
  }

  g_signal_connect(G_OBJECT(ih->handle), "focus-in-event",     G_CALLBACK(iupgtkFocusInOutEvent), ih);
  g_signal_connect(G_OBJECT(ih->handle), "focus-out-event",    G_CALLBACK(iupgtkFocusInOutEvent), ih);
  g_signal_connect(G_OBJECT(ih->handle), "key-press-event",    G_CALLBACK(iupgtkKeyPressEvent), ih);
  g_signal_connect(G_OBJECT(ih->handle), "show-help",          G_CALLBACK(iupgtkShowHelp), ih);

  if (!iupAttribGet(ih, "_IUPGTK_EVENTBOX"))
    g_signal_connect(G_OBJECT(ih->handle), "clicked", G_CALLBACK(gtkButtonClicked), ih);

  g_signal_connect(G_OBJECT(ih->handle), "button-press-event", G_CALLBACK(gtkButtonEvent), ih);
  g_signal_connect(G_OBJECT(ih->handle), "button-release-event",G_CALLBACK(gtkButtonEvent), ih);

  gtk_widget_realize(ih->handle);

  /* update a mnemonic in a label if necessary */
  iupgtkUpdateMnemonic(ih);

  return IUP_NOERROR;
}