예제 #1
0
GtkWidget *
stroke_dialog_new (GimpItem    *item,
                   GimpContext *context,
                   const gchar *title,
                   const gchar *stock_id,
                   const gchar *help_id,
                   GtkWidget   *parent)
{
  GimpStrokeOptions *options;
  GimpStrokeOptions *saved_options;
  GimpImage         *image;
  GtkWidget         *dialog;
  GtkWidget         *main_vbox;
  GtkWidget         *radio_box;
  GtkWidget         *cairo_radio;
  GtkWidget         *paint_radio;
  GSList            *group;
  GtkWidget         *frame;

  g_return_val_if_fail (GIMP_IS_ITEM (item), NULL);
  g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
  g_return_val_if_fail (stock_id != NULL, NULL);
  g_return_val_if_fail (help_id != NULL, NULL);
  g_return_val_if_fail (parent == NULL || GTK_IS_WIDGET (parent), NULL);

  image = gimp_item_get_image (item);

  options = gimp_stroke_options_new (context->gimp, context, TRUE);

  saved_options = g_object_get_data (G_OBJECT (context->gimp),
                                     "saved-stroke-options");

  if (saved_options)
    gimp_config_sync (G_OBJECT (saved_options), G_OBJECT (options), 0);

  dialog = gimp_viewable_dialog_new (GIMP_VIEWABLE (item), context,
                                     title, "gimp-stroke-options",
                                     stock_id,
                                     _("Choose Stroke Style"),
                                     parent,
                                     gimp_standard_help_func,
                                     help_id,

                                     GIMP_STOCK_RESET, RESPONSE_RESET,
                                     GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                                     stock_id,         GTK_RESPONSE_OK,

                                     NULL);

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

  gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);

  g_signal_connect (dialog, "response",
                    G_CALLBACK (stroke_dialog_response),
                    dialog);

  g_object_set_data (G_OBJECT (dialog), "gimp-item", item);
  g_object_set_data_full (G_OBJECT (dialog), "gimp-stroke-options", options,
                          (GDestroyNotify) g_object_unref);

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

  radio_box = gimp_prop_enum_radio_box_new (G_OBJECT (options), "method",
                                            -1, -1);

  group = gtk_radio_button_get_group (g_object_get_data (G_OBJECT (radio_box),
                                                         "radio-button"));

  cairo_radio = g_object_ref (group->next->data);
  gtk_container_remove (GTK_CONTAINER (radio_box), cairo_radio);

  paint_radio = g_object_ref (group->data);
  gtk_container_remove (GTK_CONTAINER (radio_box), paint_radio);

  g_object_ref_sink (radio_box);
  g_object_unref (radio_box);

  {
    PangoFontDescription *font_desc;

    font_desc = pango_font_description_new ();
    pango_font_description_set_weight (font_desc, PANGO_WEIGHT_BOLD);

    gtk_widget_modify_font (gtk_bin_get_child (GTK_BIN (cairo_radio)),
                            font_desc);
    gtk_widget_modify_font (gtk_bin_get_child (GTK_BIN (paint_radio)),
                            font_desc);

    pango_font_description_free (font_desc);
  }


  /*  the stroke frame  */

  frame = gimp_frame_new (NULL);
  gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
  gtk_widget_show (frame);

  gtk_frame_set_label_widget (GTK_FRAME (frame), cairo_radio);
  g_object_unref (cairo_radio);

  {
    GtkWidget *stroke_editor;
    gdouble    xres;
    gdouble    yres;

    gimp_image_get_resolution (image, &xres, &yres);

    stroke_editor = gimp_stroke_editor_new (options, yres, FALSE);
    gtk_container_add (GTK_CONTAINER (frame), stroke_editor);
    gtk_widget_show (stroke_editor);

    g_object_bind_property (cairo_radio,   "active",
                            stroke_editor, "sensitive",
                            G_BINDING_SYNC_CREATE);
  }


  /*  the paint tool frame  */

  frame = gimp_frame_new (NULL);
  gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
  gtk_widget_show (frame);

  gtk_frame_set_label_widget (GTK_FRAME (frame), paint_radio);
  g_object_unref (paint_radio);

  {
    GtkWidget *vbox;
    GtkWidget *hbox;
    GtkWidget *label;
    GtkWidget *combo;
    GtkWidget *button;

    vbox = gtk_vbox_new (FALSE, 6);
    gtk_container_add (GTK_CONTAINER (frame), vbox);
    gtk_widget_show (vbox);

    g_object_bind_property (paint_radio, "active",
                            vbox,        "sensitive",
                            G_BINDING_SYNC_CREATE);

    hbox = gtk_hbox_new (FALSE, 6);
    gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
    gtk_widget_show (hbox);

    label = gtk_label_new (_("Paint tool:"));
    gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
    gtk_widget_show (label);

    combo = gimp_container_combo_box_new (image->gimp->paint_info_list,
                                          GIMP_CONTEXT (options),
                                          16, 0);
    gtk_box_pack_start (GTK_BOX (hbox), combo, TRUE, TRUE, 0);
    gtk_widget_show (combo);

    g_object_set_data (G_OBJECT (dialog), "gimp-tool-menu", combo);

    button = gimp_prop_check_button_new (G_OBJECT (options),
                                         "emulate-brush-dynamics",
                                         _("_Emulate brush dynamics"));
    gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
    gtk_widget_show (button);
  }

  return dialog;
}
예제 #2
0
void wibuti_widget_repack_with_string(WibutiWidget *self, const gchar *string) {
    int i;
#ifdef WIBUTI_WITH_BUTTONS
    for (i = WIBUTI_BUTTON_FIRST; i < WIBUTI_BUTTON_NUM; ++i) {
        g_object_ref(self->evbox[i]);
    }

    if (self->use_minimize) {
        gtk_container_remove(GTK_CONTAINER(self->box), GTK_WIDGET(self->evbox[WIBUTI_BUTTON_MINIMIZE]));
    }
    if (self->use_maximize) {
        gtk_container_remove(GTK_CONTAINER(self->box), GTK_WIDGET(self->evbox[WIBUTI_BUTTON_MAXIMIZE]));
        gtk_container_remove(GTK_CONTAINER(self->box), GTK_WIDGET(self->evbox[WIBUTI_BUTTON_RESTORE]));
    }
    if (self->use_close) {
        gtk_container_remove(GTK_CONTAINER(self->box), GTK_WIDGET(self->evbox[WIBUTI_BUTTON_CLOSE]));
    }

    self->use_close = self->use_maximize = self->use_minimize = FALSE;
#endif // WIBUTI_WITH_BUTTONS

#ifdef WIBUTI_WITH_TITLE
    g_object_ref(self->evbox_title);
    g_object_ref(self->evbox_icon);

    if (self->use_title) {
        gtk_container_remove(GTK_CONTAINER(self->box), GTK_WIDGET(self->evbox_title));
    }
    if (self->use_icon) {
        gtk_container_remove(GTK_CONTAINER(self->box), GTK_WIDGET(self->evbox_icon));
    }

    self->use_title = self->use_icon = FALSE;
#endif // WIBUTI_WITH_TITLE

    i = 0;
    while (string[i] != '\0') {
        switch (string[i]) {
#ifdef WIBUTI_WITH_BUTTONS
        case 'M': {
            gtk_box_pack_start(GTK_BOX(self->box), GTK_WIDGET(self->evbox[WIBUTI_BUTTON_MINIMIZE]), FALSE, TRUE,0);
            self->use_minimize = TRUE;
            break;
        }
        case 'R': {
            gtk_box_pack_start(GTK_BOX(self->box), GTK_WIDGET(self->evbox[WIBUTI_BUTTON_MAXIMIZE]), FALSE, TRUE,0);
            gtk_box_pack_start(GTK_BOX(self->box), GTK_WIDGET(self->evbox[WIBUTI_BUTTON_RESTORE]), FALSE, TRUE, 0);
            self->use_maximize = TRUE;
            break;
        }
        case 'X': {
            gtk_box_pack_start(GTK_BOX(self->box), GTK_WIDGET(self->evbox[WIBUTI_BUTTON_CLOSE]), FALSE, TRUE, 0);
            self->use_close = TRUE;
            break;
        }
#endif // WIBUTI_WITH_BUTTONS

#ifdef WIBUTI_WITH_TITLE
        case 'T': {
            gtk_box_pack_start(GTK_BOX(self->box), GTK_WIDGET(self->evbox_title), FALSE, TRUE, 4);
            wibuti_widget_set_expand_title(self, self->expand_title);
            self->use_title = TRUE;
            break;
        }
        case 'I': {
            gtk_box_pack_start(GTK_BOX(self->box), GTK_WIDGET(self->evbox_icon), FALSE, TRUE, 0);
            self->use_icon = TRUE;
            break;
        }
#endif // WIBUTI_WITH_TITLE
        }
        ++i;
    }

    /*#ifdef WIBUTI_WITH_BUTTONS // TODO: why this breaks applet?
    	g_object_unref(self->evbox_minimize);
    	g_object_unref(self->evbox_maximize);
    	g_object_unref(self->evbox_close);
    #endif // WIBUTI_WITH_BUTTONS

    #ifdef WIBUTI_WITH_TITLE
    	g_object_unref(self->evbox_title);
    	g_object_unref(self->evbox_icon);
    #endif // WIBUTI_WITH_TITLE*/
}
예제 #3
0
static void remove_all_callback (GtkWidget *widget, gpointer data)
{
    GtkWidget *container = static_cast<GtkWidget *> (data);
    gtk_container_remove (GTK_CONTAINER (container), widget);
}
IRC_Client_GUI_MessageHandler::IRC_Client_GUI_MessageHandler (Common_UI_GTKState* GTKState_in,
                                                              IRC_Client_GUI_Connection* connection_in,
                                                              RPG_Net_Protocol_IIRCControl* controller_in,
                                                              const std::string& id_in,
                                                              const std::string& UIFileDirectory_in,
                                                              GtkNotebook* parent_in)
 : CBData_ ()
 , displayQueue_ ()
 , lock_ ()
 , eventSourceID_ (0)
 , isFirstMemberListMsg_ (true)
 , parent_ (parent_in)
 , view_ (NULL)
{
  RPG_TRACE (ACE_TEXT ("IRC_Client_GUI_MessageHandler::IRC_Client_GUI_MessageHandler"));

  // sanity check(s)
  ACE_ASSERT (GTKState_in);
  ACE_ASSERT(connection_in);
  ACE_ASSERT(controller_in);
  ACE_ASSERT (!id_in.empty ());
  if (!Common_File_Tools::isDirectory (UIFileDirectory_in))
  {
    ACE_DEBUG ((LM_ERROR,
                ACE_TEXT ("invalid argument (was: \"%s\"): not a directory, returning\n"),
                ACE_TEXT (UIFileDirectory_in.c_str ())));
    return;
  } // end IF
  ACE_ASSERT (parent_in);

  // initialize cb data
  CBData_.GTKState = GTKState_in;
  CBData_.connection = connection_in;
  CBData_.id = id_in;
  CBData_.controller = controller_in;
  CBData_.channelModes = 0;

  // create new GtkBuilder
  GtkBuilder* builder_p = gtk_builder_new ();
  if (!builder_p)
  {
    ACE_DEBUG ((LM_CRITICAL,
                ACE_TEXT ("failed to allocate memory: \"%m\", returning\n")));
    return;
  } // end IF
  std::string ui_definition_filename = UIFileDirectory_in;
  ui_definition_filename += ACE_DIRECTORY_SEPARATOR_CHAR_A;
  ui_definition_filename += IRC_CLIENT_GUI_DEF_UI_CHANNEL_TAB_FILE;
  if (!Common_File_Tools::isReadable (ui_definition_filename))
  {
    ACE_DEBUG ((LM_ERROR,
                ACE_TEXT ("invalid UI file (was: \"%s\"): not readable, returning\n"),
                ACE_TEXT (ui_definition_filename.c_str ())));

    // clean up
    g_object_unref (G_OBJECT (builder_p));

    return;
  } // end IF

  // load widget tree
  GError* error = NULL;
  gtk_builder_add_from_file (builder_p,
                             ui_definition_filename.c_str (),
                             &error);
  if (error)
  {
    ACE_DEBUG ((LM_ERROR,
                ACE_TEXT ("failed to gtk_builder_add_from_file(\"%s\"): \"%s\", aborting\n"),
                ACE_TEXT (ui_definition_filename.c_str ()),
                ACE_TEXT (error->message)));

    // clean up
    g_error_free (error);
    g_object_unref (G_OBJECT (builder_p));

    return;
  } // end IF

  // setup auto-scrolling in textview
  view_ =
      GTK_TEXT_VIEW (gtk_builder_get_object (builder_p,
                                             ACE_TEXT_ALWAYS_CHAR ("channel_tab_textview")));
  ACE_ASSERT (view_);
  GtkTextIter iter;
  gtk_text_buffer_get_end_iter (gtk_text_view_get_buffer (view_),
                                &iter);
  gtk_text_buffer_create_mark (gtk_text_view_get_buffer (view_),
                               ACE_TEXT_ALWAYS_CHAR ("scroll"),
                               &iter,
                               TRUE);

  // enable multi-selection in treeview
  GtkTreeView* tree_view_p =
    GTK_TREE_VIEW (gtk_builder_get_object (builder_p,
                                           ACE_TEXT_ALWAYS_CHAR ("channel_tab_treeview")));
  ACE_ASSERT (tree_view_p);
  GtkTreeSelection* tree_selection_p =
    gtk_tree_view_get_selection (tree_view_p);
  ACE_ASSERT (tree_selection_p);
  gtk_tree_selection_set_mode (tree_selection_p,
                               GTK_SELECTION_MULTIPLE);

  // add the invite_channel_members_menu to the "Invite" menu item
  GtkMenu* menu_p =
    GTK_MENU (gtk_builder_get_object (builder_p,
                                      ACE_TEXT_ALWAYS_CHAR ("invite_channel_members_menu")));
  ACE_ASSERT (menu_p);
  GtkMenuItem* menu_item_p =
    GTK_MENU_ITEM (gtk_builder_get_object (builder_p,
                                           ACE_TEXT_ALWAYS_CHAR ("menuitem_invite")));
  ACE_ASSERT (menu_item_p);
  gtk_menu_item_set_submenu (menu_item_p, GTK_WIDGET (menu_p));

  // connect signal(s)
  GtkButton* button_p =
    GTK_BUTTON (gtk_builder_get_object (builder_p,
                                        ACE_TEXT_ALWAYS_CHAR ("channel_tab_label_button")));
  ACE_ASSERT (button_p);
  g_signal_connect (button_p,
                    ACE_TEXT_ALWAYS_CHAR ("clicked"),
                    G_CALLBACK (part_clicked_cb),
                    &CBData_);
  // toggle buttons
  GtkToggleButton* toggle_button_p =
    GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder_p,
                                               ACE_TEXT_ALWAYS_CHAR ("mode_key_toggle_button_p")));
  ACE_ASSERT (toggle_button_p);
  g_signal_connect (toggle_button_p,
                    ACE_TEXT_ALWAYS_CHAR ("toggled"),
                    G_CALLBACK (channel_mode_toggled_cb),
                    &CBData_);
  toggle_button_p =
    GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder_p,
                                               ACE_TEXT_ALWAYS_CHAR ("mode_voice_toggle_button_p")));
  ACE_ASSERT (toggle_button_p);
  g_signal_connect (toggle_button_p,
                    ACE_TEXT_ALWAYS_CHAR ("toggled"),
                    G_CALLBACK (channel_mode_toggled_cb),
                    &CBData_);
  toggle_button_p =
    GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder_p,
                                               ACE_TEXT_ALWAYS_CHAR ("mode_ban_toggle_button_p")));
  ACE_ASSERT (toggle_button_p);
  g_signal_connect (toggle_button_p,
                    ACE_TEXT_ALWAYS_CHAR ("toggled"),
                    G_CALLBACK (channel_mode_toggled_cb),
                    &CBData_);
  toggle_button_p =
    GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder_p,
                                               ACE_TEXT_ALWAYS_CHAR ("mode_userlimit_toggle_button_p")));
  ACE_ASSERT (toggle_button_p);
  g_signal_connect (toggle_button_p,
                    ACE_TEXT_ALWAYS_CHAR ("toggled"),
                    G_CALLBACK (channel_mode_toggled_cb),
                    &CBData_);
  toggle_button_p =
    GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder_p,
                                               ACE_TEXT_ALWAYS_CHAR ("mode_moderated_toggle_button_p")));
  ACE_ASSERT (toggle_button_p);
  g_signal_connect (toggle_button_p,
                    ACE_TEXT_ALWAYS_CHAR ("toggled"),
                    G_CALLBACK (channel_mode_toggled_cb),
                    &CBData_);
  toggle_button_p =
    GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder_p,
                                               ACE_TEXT_ALWAYS_CHAR ("mode_blockforeign_toggle_button_p")));
  ACE_ASSERT (toggle_button_p);
  g_signal_connect (toggle_button_p,
                    ACE_TEXT_ALWAYS_CHAR ("toggled"),
                    G_CALLBACK (channel_mode_toggled_cb),
                    &CBData_);
  toggle_button_p =
    GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder_p,
                                               ACE_TEXT_ALWAYS_CHAR ("mode_restricttopic_toggle_button_p")));
  ACE_ASSERT (toggle_button_p);
  g_signal_connect (toggle_button_p,
                    ACE_TEXT_ALWAYS_CHAR ("toggled"),
                    G_CALLBACK (channel_mode_toggled_cb),
                    &CBData_);
  toggle_button_p =
    GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder_p,
                                               ACE_TEXT_ALWAYS_CHAR ("mode_inviteonly_toggle_button_p")));
  ACE_ASSERT (toggle_button_p);
  g_signal_connect (toggle_button_p,
                    ACE_TEXT_ALWAYS_CHAR ("toggled"),
                    G_CALLBACK (channel_mode_toggled_cb),
                    &CBData_);
  toggle_button_p =
    GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder_p,
                                               ACE_TEXT_ALWAYS_CHAR ("mode_secret_toggle_button_p")));
  ACE_ASSERT (toggle_button_p);
  g_signal_connect (toggle_button_p,
                    ACE_TEXT_ALWAYS_CHAR ("toggled"),
                    G_CALLBACK (channel_mode_toggled_cb),
                    &CBData_);
  toggle_button_p =
    GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder_p,
                                               ACE_TEXT_ALWAYS_CHAR ("mode_private_toggle_button_p")));
  ACE_ASSERT (toggle_button_p);
  g_signal_connect (toggle_button_p,
                    ACE_TEXT_ALWAYS_CHAR ("toggled"),
                    G_CALLBACK (channel_mode_toggled_cb),
                    &CBData_);
  toggle_button_p =
    GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder_p,
                                               ACE_TEXT_ALWAYS_CHAR ("mode_operator_toggle_button_p")));
  ACE_ASSERT (toggle_button_p);
  g_signal_connect (toggle_button_p,
                    ACE_TEXT_ALWAYS_CHAR ("toggled"),
                    G_CALLBACK (channel_mode_toggled_cb),
                    &CBData_);
  // topic label
  GtkEventBox* event_box_p =
    GTK_EVENT_BOX (gtk_builder_get_object (builder_p,
                                           ACE_TEXT_ALWAYS_CHAR ("channel_tab_topic_label_eventbox")));
  ACE_ASSERT (event_box_p);
  g_signal_connect (event_box_p,
                    ACE_TEXT_ALWAYS_CHAR ("button-press-event"),
                    G_CALLBACK (topic_clicked_cb),
                    &CBData_);
  // context menu in treeview
  g_signal_connect (tree_view_p,
                    ACE_TEXT_ALWAYS_CHAR ("button-press-event"),
                    G_CALLBACK (members_clicked_cb),
                    &CBData_);
  // actions in treeview
  GtkAction* action_p =
    GTK_ACTION (gtk_builder_get_object (builder_p,
                                        ACE_TEXT_ALWAYS_CHAR ("action_msg")));
  ACE_ASSERT (action_p);
  g_signal_connect (action_p,
                    ACE_TEXT_ALWAYS_CHAR ("activate"),
                    G_CALLBACK (action_msg_cb),
                    &CBData_);
  action_p =
    GTK_ACTION (gtk_builder_get_object (builder_p,
                                        ACE_TEXT_ALWAYS_CHAR ("action_invite")));
  ACE_ASSERT (action_p);
  g_signal_connect (action_p,
                    ACE_TEXT_ALWAYS_CHAR ("activate"),
                    G_CALLBACK (action_invite_cb),
                    &CBData_);
  action_p =
    GTK_ACTION (gtk_builder_get_object (builder_p,
                                        ACE_TEXT_ALWAYS_CHAR ("action_info")));
  ACE_ASSERT (action_p);
  g_signal_connect (action_p,
                    ACE_TEXT_ALWAYS_CHAR ("activate"),
                    G_CALLBACK (action_info_cb),
                    &CBData_);
  action_p =
    GTK_ACTION (gtk_builder_get_object (builder_p,
                                        ACE_TEXT_ALWAYS_CHAR ("action_kick")));
  ACE_ASSERT (action_p);
  g_signal_connect (action_p,
                    ACE_TEXT_ALWAYS_CHAR ("activate"),
                    G_CALLBACK (action_kick_cb),
                    &CBData_);
  action_p =
    GTK_ACTION (gtk_builder_get_object (builder_p,
                                        ACE_TEXT_ALWAYS_CHAR ("action_ban")));
  ACE_ASSERT (action_p);
  g_signal_connect (action_p,
                    ACE_TEXT_ALWAYS_CHAR ("activate"),
                    G_CALLBACK (action_ban_cb),
                    &CBData_);

  // add new channel page to notebook (== server log)
  // retrieve (dummy) parent window
  GtkWindow* window_p =
    GTK_WINDOW (gtk_builder_get_object (builder_p,
                                        ACE_TEXT_ALWAYS_CHAR ("channel_tab_label_template")));
  ACE_ASSERT (window_p);
  // retrieve channel tab label
  GtkHBox* hbox_p =
    GTK_HBOX (gtk_builder_get_object (builder_p,
                                      ACE_TEXT_ALWAYS_CHAR ("channel_tab_label_hbox")));
  ACE_ASSERT (hbox_p);
  g_object_ref (hbox_p);
  gtk_container_remove (GTK_CONTAINER (window_p),
                        GTK_WIDGET (hbox_p));
  // set tab label
  GtkLabel* label_p =
    GTK_LABEL (gtk_builder_get_object (builder_p,
                                       ACE_TEXT_ALWAYS_CHAR ("channel_tab_label")));
  ACE_ASSERT (label_p);
  std::string page_tab_label_string;
  if (!RPG_Net_Protocol_Tools::isValidIRCChannelName (CBData_.id))
  {
    // --> private conversation window, modify label accordingly
    page_tab_label_string = ACE_TEXT_ALWAYS_CHAR ("[");
    page_tab_label_string += CBData_.id;
    page_tab_label_string += ACE_TEXT_ALWAYS_CHAR("]");

    // hide channel mode tab frame
    GtkFrame* frame_p =
      GTK_FRAME (gtk_builder_get_object (builder_p,
                                         ACE_TEXT_ALWAYS_CHAR ("channel_tab_mode_frame")));
    ACE_ASSERT (frame_p);
    gtk_widget_hide (GTK_WIDGET (frame_p));
    // hide channel tab treeview
    tree_view_p =
      GTK_TREE_VIEW (gtk_builder_get_object (builder_p,
                                             ACE_TEXT_ALWAYS_CHAR ("channel_tab_treeview")));
    ACE_ASSERT (tree_view_p);
    gtk_widget_hide (GTK_WIDGET (tree_view_p));

    // erase "topic" label
    label_p =
      GTK_LABEL (gtk_builder_get_object (builder_p,
                                         ACE_TEXT_ALWAYS_CHAR ("channel_tab_topic_label")));
    ACE_ASSERT (label_p);
    gtk_label_set_text (label_p, NULL);
  } // end IF
  else
    page_tab_label_string = CBData_.id;
  gtk_label_set_text (label_p,
                      page_tab_label_string.c_str ());
  // retrieve (dummy) parent window
  window_p =
    GTK_WINDOW (gtk_builder_get_object (builder_p,
                                        ACE_TEXT_ALWAYS_CHAR ("channel_tab_template")));
  ACE_ASSERT (window_p);
  // retrieve channel tab
  GtkVBox* vbox_p =
    GTK_VBOX (gtk_builder_get_object (builder_p,
                                      ACE_TEXT_ALWAYS_CHAR ("channel_tab_vbox")));
  ACE_ASSERT (vbox_p);
  g_object_ref (vbox_p);
  gtk_container_remove (GTK_CONTAINER (window_p),
                        GTK_WIDGET (vbox_p));
  gint page_num = gtk_notebook_append_page (parent_,
                                            GTK_WIDGET (vbox_p),
                                            GTK_WIDGET (hbox_p));
  if (page_num == -1)
  {
    ACE_DEBUG ((LM_ERROR,
                ACE_TEXT ("failed to gtk_notebook_append_page(%@), returning\n"),
                parent_));

    // clean up
    g_object_unref (hbox_p);
    g_object_unref (vbox_p);
    g_object_unref (G_OBJECT (builder_p));

    return;
  } // end IF
  g_object_unref (hbox_p);

  // allow reordering
  gtk_notebook_set_tab_reorderable (parent_,
                                    GTK_WIDGET (vbox_p),
                                    TRUE);
  g_object_unref (vbox_p);

  // activate new page (iff it's a channel tab !)
  if (RPG_Net_Protocol_Tools::isValidIRCChannelName (CBData_.id))
    gtk_notebook_set_current_page (parent_,
                                   page_num);

  builderLabel_ = connection_in->getLabel ();
  builderLabel_ += ACE_TEXT_ALWAYS_CHAR ("::");
  builderLabel_ += page_tab_label_string;
  // synch access
  {
    ACE_Guard<ACE_Thread_Mutex> aGuard (CBData_.GTKState->lock);

    CBData_.GTKState->builders[builderLabel_] =
        std::make_pair (ui_definition_filename, builder_p);
  } // end lock scope
}
예제 #5
0
static void
rb_static_playlist_source_constructed (GObject *object)
{
	RBStaticPlaylistSource *source;
	RBStaticPlaylistSourcePrivate *priv;
	RBPlaylistSource *psource;
	RBEntryView *songs;
	RBShell *shell;
	RhythmDBEntryType *entry_type;

	RB_CHAIN_GOBJECT_METHOD (rb_static_playlist_source_parent_class, constructed, object);

	source = RB_STATIC_PLAYLIST_SOURCE (object);
	priv = RB_STATIC_PLAYLIST_SOURCE_GET_PRIVATE (source);
	psource = RB_PLAYLIST_SOURCE (source);

	priv->base_model = rb_playlist_source_get_query_model (RB_PLAYLIST_SOURCE (psource));
	g_object_set (priv->base_model, "show-hidden", TRUE, NULL);
	g_object_ref (priv->base_model);
	g_signal_connect_object (priv->base_model,
				 "filter-entry-drop",
				 G_CALLBACK (rb_static_playlist_source_filter_entry_drop),
				 source, 0);

	priv->paned = gtk_vpaned_new ();

	g_object_get (source, "shell", &shell, NULL);
	priv->action_group = _rb_display_page_register_action_group (RB_DISPLAY_PAGE (source),
								     "StaticPlaylistActions",
								     NULL, 0,
								     shell);
	if (gtk_action_group_get_action (priv->action_group,
					 rb_static_playlist_source_radio_actions[0].name) == NULL) {
		gtk_action_group_add_radio_actions (priv->action_group,
						    rb_static_playlist_source_radio_actions,
						    G_N_ELEMENTS (rb_static_playlist_source_radio_actions),
						    0,
						    NULL,
						    NULL);
		rb_source_search_basic_create_for_actions (priv->action_group,
							   rb_static_playlist_source_radio_actions,
							   G_N_ELEMENTS (rb_static_playlist_source_radio_actions));
	}
	priv->default_search = rb_source_search_basic_new (RHYTHMDB_PROP_SEARCH_MATCH);

	g_object_unref (shell);

	g_object_get (source, "entry-type", &entry_type, NULL);
	priv->browser = rb_library_browser_new (rb_playlist_source_get_db (RB_PLAYLIST_SOURCE (source)),
						entry_type);
	if (entry_type != NULL) {
		g_object_unref (entry_type);
	}

	gtk_paned_pack1 (GTK_PANED (priv->paned), GTK_WIDGET (priv->browser), TRUE, FALSE);
	g_signal_connect_object (priv->browser, "notify::output-model",
				 G_CALLBACK (rb_static_playlist_source_browser_changed_cb),
				 source, 0);

	rb_library_browser_set_model (priv->browser, priv->base_model, FALSE);
	rb_static_playlist_source_do_query (source);

	/* reparent the entry view */
	songs = rb_source_get_entry_view (RB_SOURCE (source));
	g_object_ref (songs);
	gtk_container_remove (GTK_CONTAINER (source), GTK_WIDGET (songs));
	gtk_paned_pack2 (GTK_PANED (priv->paned), GTK_WIDGET (songs), TRUE, FALSE);
	gtk_container_add (GTK_CONTAINER (source), priv->paned);

	rb_source_bind_settings (RB_SOURCE (source), GTK_WIDGET (songs), priv->paned, GTK_WIDGET (priv->browser));
	g_object_unref (songs);

	/* watch these to find out when things are dropped into the entry view */
	g_signal_connect_object (priv->base_model, "row-inserted",
				 G_CALLBACK (rb_static_playlist_source_row_inserted),
				 source, 0);
	g_signal_connect_object (priv->base_model, "non-entry-dropped",
				 G_CALLBACK (rb_static_playlist_source_non_entry_dropped),
				 source, 0);
	g_signal_connect_object (priv->base_model, "rows-reordered",
				 G_CALLBACK (rb_static_playlist_source_rows_reordered),
				 source, 0);

	gtk_widget_show_all (GTK_WIDGET (source));
}
예제 #6
0
static void messageview_show_cb(GObject *obj, gpointer msgview,
				MsgInfo *msginfo, gboolean all_headers)
{
  MessageView *messageview;
  HeaderView *headerview;
  GtkWidget *hbox;
  gchar *msg_path;
  GtkWidget *copy_btn;
  GdkPixbuf* pbuf;
  GtkWidget* image;
  GtkTooltips *tip;
  GList* wl;
  gint i;
  gboolean bfound = FALSE;
  gpointer gdata;

  
#if DEBUG
  g_print("[DEBUG] test: %p: messageview_show (%p), all_headers: %d: %s\n",
	  obj, msgview, all_headers,
	  msginfo && msginfo->subject ? msginfo->subject : "");
#endif
  
  if (!msgview) {
    g_print("[DEBUG] msgview is NULL\n");
    return;
  }

  messageview = (MessageView*)msgview;
  if (!messageview) {
    g_print("[DEBUG] messageview is NULL\n");
    return;
  }

  headerview = messageview->headerview;
  if (!headerview) {
    g_print("[DEBUG] headerview is NULL\n");
    return;
  }
  
  hbox = headerview->hbox;
  if (!hbox) {
    g_print("[DEBUG] hbox is NULL\n");
    return;
  }

  wl = gtk_container_get_children(GTK_CONTAINER(hbox));

  i = g_list_length(wl)-1;

  /* search recently added GtkImage */
  while (i >= 0) {
    gdata = g_list_nth_data(wl, i);
    if (GTK_IS_BUTTON(gdata) && gdata != headerview->image) {
      /* remove from hbox */
      g_print("[DEBUG] GTK_IS_BUTTON %p\n", gdata);
#if DEBUG
      g_print("[DEBUG] remove button: %p\n", gicon);
#endif
      gtk_container_remove(GTK_CONTAINER(hbox), GTK_WIDGET(gdata));
    }
    i--;
  }


  msg_path = procmsg_get_message_file_path(msginfo);
                    

  debug_print("[DEBUG] msg_path:%s\n", msg_path);


  if (bfound != TRUE){
    copy_btn = gtk_button_new_from_stock(GTK_STOCK_FILE);
    gtk_box_pack_end(GTK_BOX(hbox), copy_btn, FALSE, FALSE, 0);

    pbuf = gdk_pixbuf_new_from_xpm_data((const char**)page_save);
    image = gtk_image_new_from_pixbuf(pbuf);
    
    gtk_button_set_image(GTK_BUTTON(copy_btn), image);
    gtk_button_set_label(GTK_BUTTON(copy_btn), "");

    tip = gtk_tooltips_new();
    gtk_tooltips_set_tip(tip, copy_btn, _("Copy this mail to clipboard."), NULL);

    g_signal_connect(G_OBJECT(copy_btn), "clicked",
		     G_CALLBACK(copy_btn_clicked), msginfo);
    
    gtk_widget_show(image);
    gtk_widget_show_all(copy_btn);

    debug_print("[DEBUG] copy mail to clipboard icon: %p\n", copy_btn);

  }

}
예제 #7
0
파일: tabwin.c 프로젝트: aylusltd/gretl
static void dock_viewer (GtkWidget *w, windata_t *vwin)
{
    tabwin_t *tabwin;
    GtkWidget *oldmain;
    GtkWidget *box;
    gulong handler_id;
    gchar *info = NULL;

    tabwin = (vwin->role == VIEW_MODEL)? tabmod : tabedit;
    if (tabwin == NULL) {
	return;
    }

#if TDEBUG
    fprintf(stderr, "dock_viewer: starting on vwin at %p\n",
	    (void *) vwin);
#endif

    oldmain = vwin->main;
    gtk_widget_hide(oldmain);

    /* disconnect */
    vwin->main = NULL;

    /* remove data, and also remove destruction-related signals,
       from stand-alone vwin->main */
    g_object_steal_data(G_OBJECT(oldmain), "vwin");
    g_signal_handlers_disconnect_by_func(oldmain,
					 free_windata,
					 vwin);
    g_signal_handlers_disconnect_by_func(oldmain,
					 query_save_text,
					 vwin);

    /* grab info for title */
    if (vwin->role == EDIT_SCRIPT) {
	info = g_strdup(vwin->fname);
    } else {
	const gchar *tmp = gtk_window_get_title(GTK_WINDOW(oldmain));

	if (!strncmp(tmp, "gretl: ", 7)) {
	    tmp += 7;
	}
	info = g_strdup(tmp);
    }    

    /* extract vwin->vbox from oldmain and trash oldmain */
    g_object_ref(vwin->vbox);
    gtk_container_remove(GTK_CONTAINER(oldmain), vwin->vbox);
    gtk_widget_destroy(oldmain);

#if TDEBUG
    fprintf(stderr, "dock_viewer: vwin->vbox at %p\n", 
	    (void *) vwin->vbox);
#endif

    if (vwin->role == EDIT_SCRIPT) {
	script_editor_show_new_open(vwin, TRUE);
    }

    /* extract vwin->mbar */
    g_object_ref(vwin->mbar);
    box = gtk_widget_get_parent(vwin->mbar);
    gtk_container_remove(GTK_CONTAINER(box), vwin->mbar);
    gtk_widget_destroy(box);

    /* create new vwin->main, etc. */
    vwin->main = gtk_hbox_new(FALSE, 0);
    g_object_set_data(G_OBJECT(vwin->main), "vwin", vwin);
    handler_id = g_signal_connect(G_OBJECT(vwin->main), "destroy", 
				  G_CALLBACK(free_windata), vwin);
    g_object_set_data(G_OBJECT(vwin->main), "destroy-id",
		      GUINT_TO_POINTER(handler_id));

    make_viewer_tab(tabwin, vwin, info);
    vwin->topmain = tabwin->main;
    vwin->flags = VWIN_TABBED;
    g_free(info);

    /* tweak vbox params and insert */
    gtk_box_set_spacing(GTK_BOX(vwin->vbox), 1);
    gtk_container_set_border_width(GTK_CONTAINER(vwin->vbox), 1);
    gtk_container_add(GTK_CONTAINER(vwin->main), vwin->vbox);
    g_object_unref(vwin->vbox);

    /* repack toolbar in tabwin */
    tabwin_register_toolbar(vwin);
    g_object_unref(vwin->mbar);

    show_tabbed_viewer(vwin);
    gtk_widget_grab_focus(vwin->text);

#if TDEBUG
    fprintf(stderr, "dock_viewer: done\n");
#endif
}
예제 #8
0
/**
*  \param selection Selection to use; should not be NULL.
*/
static void
sp_item_widget_setup ( SPWidget *spw, Inkscape::Selection *selection )
{
    g_assert (selection != NULL);

    if (gtk_object_get_data (GTK_OBJECT (spw), "blocked"))
        return;

    if (!selection->singleItem()) {
        gtk_widget_set_sensitive (GTK_WIDGET (spw), FALSE);
        return;
    } else {
        gtk_widget_set_sensitive (GTK_WIDGET (spw), TRUE);
    }

    gtk_object_set_data (GTK_OBJECT (spw), "blocked", GUINT_TO_POINTER (TRUE));

    SPItem *item = selection->singleItem();

    /* Sensitive */
    GtkWidget *w = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (spw), "sensitive"));
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w), item->isLocked());

    /* Hidden */
    w = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (spw), "hidden"));
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), item->isExplicitlyHidden());

    if (SP_OBJECT_IS_CLONED (item)) {

        /* ID */
        w = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (spw), "id"));
        gtk_entry_set_text (GTK_ENTRY (w), "");
        gtk_widget_set_sensitive (w, FALSE);
        w = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (spw), "id_label"));
        gtk_label_set_text (GTK_LABEL (w), _("Ref"));

        /* Label */
        w = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (spw), "label"));
        gtk_entry_set_text (GTK_ENTRY (w), "");
        gtk_widget_set_sensitive (w, FALSE);
        w = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (spw), "label_label"));
        gtk_label_set_text (GTK_LABEL (w), _("Ref"));

    } else {
        SPObject *obj = (SPObject*)item;

        /* ID */
        w = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (spw), "id"));
        gtk_entry_set_text (GTK_ENTRY (w), obj->getId());
        gtk_widget_set_sensitive (w, TRUE);
        w = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (spw), "id_label"));
        gtk_label_set_markup_with_mnemonic (GTK_LABEL (w), _("_Id"));

        /* Label */
        w = GTK_WIDGET(gtk_object_get_data (GTK_OBJECT (spw), "label"));
        gtk_entry_set_text (GTK_ENTRY (w), obj->defaultLabel());
        gtk_widget_set_sensitive (w, TRUE);

        /* Title */
        w = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(spw), "title"));
        gchar *title = obj->title();
        if (title) {
            gtk_entry_set_text(GTK_ENTRY(w), title);
            g_free(title);
        }
        else gtk_entry_set_text(GTK_ENTRY(w), "");
        gtk_widget_set_sensitive(w, TRUE);

        /* Description */
        w = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(spw), "desc"));
        GtkTextBuffer *buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(w));
        gchar *desc = obj->desc();
        if (desc) {
            gtk_text_buffer_set_text(buf, desc, -1);
            g_free(desc);
        } else {
            gtk_text_buffer_set_text(buf, "", 0);
        }
        w = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(spw), "desc_frame"));
        gtk_widget_set_sensitive(w, TRUE);

        w = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(spw), "interactivity"));

        GtkWidget* int_table = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(spw), "interactivity_table"));
        if (int_table){
            gtk_container_remove(GTK_CONTAINER(w), int_table);
        }

        const gchar* int_labels[10] = {"onclick", "onmouseover", "onmouseout", "onmousedown", "onmouseup", "onmousemove","onfocusin", "onfocusout", "onactivate", "onload"};

        int_table = sp_attribute_table_new (obj, 10, int_labels, int_labels);
        gtk_widget_show_all (int_table);
        gtk_object_set_data(GTK_OBJECT(spw), "interactivity_table", int_table);

        gtk_container_add (GTK_CONTAINER (w), int_table);

    }

    gtk_object_set_data (GTK_OBJECT (spw), "blocked", GUINT_TO_POINTER (FALSE));


} // end of sp_item_widget_setup()
예제 #9
0
/*
 * Helper for statusbar_widgets_emptying()
 */
static void
foreach_remove_a_child(GtkWidget *widget, gpointer data) {
    gtk_container_remove(GTK_CONTAINER(data), widget);
}
static void
populate_ui (NetDeviceEthernet *device)
{
        GList *children, *c;
        GSList *connections, *l;
        NMConnection *connection;
        gint n_connections;

        children = gtk_container_get_children (GTK_CONTAINER (device->list));
        for (c = children; c; c = c->next) {
                gtk_container_remove (GTK_CONTAINER (device->list), c->data);
        }
        g_list_free (children);

        children = gtk_container_get_children (GTK_CONTAINER (device->details));
        for (c = children; c; c = c->next) {
                gtk_container_remove (GTK_CONTAINER (device->details), c->data);
        }
        g_list_free (children);

        connections = net_device_get_valid_connections (NET_DEVICE (device));
        for (l = connections; l; l = l->next) {
                NMConnection *connection = l->data;
                if (!g_object_get_data (G_OBJECT (connection), "removed_signal_handler")) {
                        g_signal_connect (connection, "removed",
                                          G_CALLBACK (connection_removed), device);
                        g_object_set_data (G_OBJECT (connection), "removed_signal_handler", GINT_TO_POINTER (TRUE));
                }
        }
        n_connections = g_slist_length (connections);

        if (n_connections > 4) {
                gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (device->scrolled_window),
                                                GTK_POLICY_NEVER,
                                                GTK_POLICY_AUTOMATIC);
                gtk_widget_set_vexpand (device->scrolled_window, TRUE);
        } else {
                gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (device->scrolled_window),
                                                GTK_POLICY_NEVER,
                                                GTK_POLICY_NEVER);
                gtk_widget_set_vexpand (device->scrolled_window, FALSE);
        }

        if (n_connections > 1) {
                gtk_widget_hide (device->details);
                gtk_widget_hide (device->details_button);
                for (l = connections; l; l = l->next) {
                        NMConnection *connection = l->data;
                        add_row (device, connection);
                }
                gtk_widget_show (device->scrolled_window);
        } else if (n_connections == 1) {
                connection = connections->data;
                gtk_widget_hide (device->scrolled_window);
                add_details (device->details, net_device_get_nm_device (NET_DEVICE (device)), connection);
                gtk_widget_show_all (device->details);
                gtk_widget_show (device->details_button);
                g_object_set_data (G_OBJECT (device->details_button), "row", device->details_button);
                g_object_set_data (G_OBJECT (device->details_button), "connection", connection);

        } else {
                gtk_widget_hide (device->scrolled_window);
                gtk_widget_hide (device->details);
                gtk_widget_hide (device->details_button);
        }

        g_slist_free (connections);
}
예제 #11
0
static void
cpufreq_applet_refresh (CPUFreqApplet *applet)
{
        gint      total_size = 0;
        gint      panel_size, label_size;
        gint      unit_label_size, pixmap_size;
        gint      size_step = 12;
	gboolean  horizontal;
        gboolean  do_unref = FALSE;

        panel_size = applet->size - 1; /* 1 pixel margin */

	horizontal = (applet->orient == MATE_PANEL_APPLET_ORIENT_UP ||
		      applet->orient == MATE_PANEL_APPLET_ORIENT_DOWN);

        /* We want a fixed label size, the biggest */
	if (horizontal)
		label_size = cpufreq_applet_get_widget_size (applet, applet->label);
	else
		label_size = cpufreq_applet_get_max_label_width (applet);
        total_size += label_size;

	if (horizontal)
		unit_label_size = cpufreq_applet_get_widget_size (applet, applet->unit_label);
	else
		unit_label_size = cpufreq_applet_get_max_unit_width (applet);
        total_size += unit_label_size;

        pixmap_size = cpufreq_applet_get_widget_size (applet, applet->icon);
        total_size += pixmap_size;

        if (applet->box) {
                do_unref = TRUE;
                g_object_ref (applet->icon);
                gtk_container_remove (GTK_CONTAINER (applet->box), applet->icon);
		if (applet->labels_box) {
                        g_object_ref (applet->label);
                        gtk_container_remove (GTK_CONTAINER (applet->labels_box), applet->label);
                        g_object_ref (applet->unit_label);
                        gtk_container_remove (GTK_CONTAINER (applet->labels_box), applet->unit_label);
                }
                gtk_widget_destroy (applet->box);
        }

	if (horizontal) {
#if GTK_CHECK_VERSION (3, 0, 0)
		applet->labels_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
		if ((label_size + pixmap_size) <= panel_size)
			applet->box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
		else
			applet->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
	} else {
                if (total_size <= panel_size) {
                        applet->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
                        applet->labels_box  = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
                } else if ((label_size + unit_label_size) <= (panel_size - size_step)) {
                        applet->box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
                        applet->labels_box  = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
                } else {
                        applet->box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
                        applet->labels_box  = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
#else
		applet->labels_box = gtk_hbox_new (FALSE, 2);
		if ((label_size + pixmap_size) <= panel_size)
			applet->box = gtk_vbox_new (FALSE, 2);
		else
			applet->box = gtk_hbox_new (FALSE, 2);
	} else {
                if (total_size <= panel_size) {
                        applet->box = gtk_hbox_new (FALSE, 2);
                        applet->labels_box  = gtk_hbox_new (FALSE, 2);
                } else if ((label_size + unit_label_size) <= (panel_size - size_step)) {
                        applet->box = gtk_vbox_new (FALSE, 2);
                        applet->labels_box  = gtk_hbox_new (FALSE, 2);
                } else {
                        applet->box = gtk_vbox_new (FALSE, 2);
                        applet->labels_box  = gtk_vbox_new (FALSE, 2);
#endif
                }
	}

        gtk_box_pack_start (GTK_BOX (applet->labels_box), applet->label, FALSE, FALSE, 0);
        gtk_box_pack_start (GTK_BOX (applet->labels_box), applet->unit_label, FALSE, FALSE, 0);
        gtk_box_pack_start (GTK_BOX (applet->box), applet->icon, FALSE, FALSE, 0);

        gtk_box_pack_start (GTK_BOX (applet->box), applet->labels_box, FALSE, FALSE, 0);
        gtk_widget_show (applet->labels_box);

        gtk_container_add (GTK_CONTAINER (applet->container), applet->box);
        gtk_widget_show (applet->box);

        if (do_unref) {
                g_object_unref (applet->label);
                g_object_unref (applet->unit_label);
                g_object_unref (applet->icon);
        }
}
예제 #12
0
static void empty_container(GtkWidget *widget, gpointer data)
{
    gtk_container_remove(GTK_CONTAINER(data), widget);
}
예제 #13
0
static void
he_check_button_construct_child                   (HeCheckButton *button)
{
    HeCheckButtonPrivate *priv = HE_CHECK_BUTTON_GET_PRIVATE (button);
    GtkWidget *child;
    gint image_spacing;
    const gchar *title, *value;

    /* Don't do anything if the button is not constructed yet */
    if (G_UNLIKELY (priv->label_box == NULL))
        return;

    /* Don't do anything if the button has no contents */
    title = gtk_label_get_text (priv->title);
    value = gtk_label_get_text (priv->value);

    if (!title[0] && !value[0])
        return;

    /* Remove the parent if there is one */
    if (priv->cell_view) {
		g_object_ref (priv->cell_view);
		if (priv->cell_view->parent != NULL)
			gtk_container_remove (GTK_CONTAINER (priv->cell_view->parent), priv->cell_view);
	}

    if (priv->label_box->parent != NULL) {
        gtk_container_remove (GTK_CONTAINER (priv->label_box->parent), priv->label_box);
    }

    /* Remove the child from the container and add priv->alignment */
    child = gtk_bin_get_child (GTK_BIN (button));
    if (child != NULL && child != priv->alignment) {
        gtk_container_remove (GTK_CONTAINER (button), child);
        child = NULL;
    }

    if (child == NULL) {
        gtk_container_add (GTK_CONTAINER (button), GTK_WIDGET (priv->alignment));
    }

    /* Create a new hbox */
    if (priv->hbox) {
        gtk_container_remove (GTK_CONTAINER (priv->alignment), GTK_WIDGET (priv->hbox));
    }
    gtk_widget_style_get (GTK_WIDGET (button), "image-spacing", &image_spacing, NULL);
    priv->hbox = GTK_BOX (gtk_hbox_new (FALSE, image_spacing));
    gtk_container_add (GTK_CONTAINER (priv->alignment), GTK_WIDGET (priv->hbox));

    /* All left align */
    gtk_alignment_set(GTK_ALIGNMENT(priv->alignment), 0, 0.5, -1, -1);

    /* Add check box and box with labels */
    gtk_box_pack_start (priv->hbox, priv->cell_view, FALSE, FALSE, 0);
    gtk_box_pack_start (priv->hbox, priv->label_box, TRUE, TRUE, 0);

    /* Remove the ref */
    g_object_unref (priv->cell_view);

    /* Show everything */
    gtk_widget_show_all (GTK_WIDGET (priv->alignment));
}
예제 #14
0
void
mousepad_util_dialog_header (GtkDialog   *dialog,
                             const gchar *title,
                             const gchar *subtitle,
                             const gchar *iconname)
{
  gchar     *full_title;
  GtkWidget *vbox, *ebox, *hbox;
  GtkWidget *icon, *label, *line;
  GtkWidget *dialog_vbox;
  GtkStyle  *style;

  /* remove the main vbox */
  dialog_vbox = gtk_bin_get_child (GTK_BIN (dialog));
  g_object_ref (G_OBJECT (dialog_vbox));
  gtk_container_remove (GTK_CONTAINER (dialog), dialog_vbox);

  /* add a new vbox to the main window */
  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
  gtk_container_add (GTK_CONTAINER (dialog), vbox);
  gtk_widget_show (vbox);

  /* event box for the background color */
  ebox = gtk_event_box_new ();
  gtk_box_pack_start (GTK_BOX (vbox), ebox, FALSE, FALSE, 0);
  style = gtk_widget_get_style (ebox);
  gtk_widget_modify_bg (ebox, GTK_STATE_NORMAL, &style->base[GTK_STATE_NORMAL]);
  gtk_widget_show (ebox);

  /* create a hbox */
  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
  gtk_container_set_border_width (GTK_CONTAINER (hbox), 6);
  gtk_container_add (GTK_CONTAINER (ebox), hbox);
  gtk_widget_show (hbox);

  /* title icon */
  icon = gtk_image_new_from_icon_name (iconname, GTK_ICON_SIZE_DIALOG);
  gtk_box_pack_start (GTK_BOX (hbox), icon, FALSE, FALSE, 0);
  gtk_widget_show (icon);

  /* create the title */
  full_title = g_strdup_printf ("<b><big>%s</big></b>\n%s", title, subtitle);

  /* title label */
  label = gtk_label_new (full_title);
  gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
  gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
  gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
  gtk_widget_show (label);

  /* cleanup */
  g_free (full_title);

  /* add the separator between header and content */
  line = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
  gtk_box_pack_start (GTK_BOX (vbox), line, FALSE, FALSE, 0);
  gtk_widget_show (line);

  /* add the main dialog box to the new vbox */
  gtk_box_pack_start (GTK_BOX (vbox), dialog_vbox, TRUE, TRUE, 0);
  g_object_unref (G_OBJECT (dialog_vbox));
}
예제 #15
0
static void
remove_all_cb (GtkWidget *widget, gpointer user_data)
{
	GtkContainer *container = GTK_CONTAINER (user_data);
	gtk_container_remove (container, widget);
}
예제 #16
0
파일: sheets.c 프로젝트: AmiGanguli/dia
gboolean
sheets_dialog_create(void)
{
  GList *plugin_list;
  GSList *sheets_list;
  GtkWidget *option_menu;
  GtkWidget *sw;
  GtkWidget *wrapbox;
  gchar *sheet_left;
  gchar *sheet_right;

  if (sheets_mods_list)
    {
      /* not sure if I understood the data structure
       * but simply leaking isn't acceptable ... --hb
       */
      g_slist_foreach(sheets_mods_list, (GFunc)g_free, NULL);
      g_slist_free(sheets_mods_list);
    }
  sheets_mods_list = NULL;

  if (sheets_dialog == NULL)
  {
    sheets_dialog = create_sheets_main_dialog();
    if (!sheets_dialog) {
      /* don not let a broken builder file crash Dia */
      g_warning("SheetDialog creation failed");
      return FALSE;
    }
    /* Make sure to null our pointer when destroyed */
    g_signal_connect (G_OBJECT (sheets_dialog), "destroy",
		      G_CALLBACK (gtk_widget_destroyed),
		      &sheets_dialog);

    sheet_left = NULL;
    sheet_right = NULL;
  }
  else
  {
    option_menu = lookup_widget(sheets_dialog, "optionmenu_left");
    sheet_left = g_object_get_data(G_OBJECT(option_menu),
                                   "active_sheet_name");

    option_menu = lookup_widget(sheets_dialog, "optionmenu_right");
    sheet_right = g_object_get_data(G_OBJECT(option_menu),
                                    "active_sheet_name");

    wrapbox = lookup_widget(sheets_dialog, "wrapbox_left");
    if (wrapbox)
      gtk_widget_destroy(wrapbox);

    wrapbox = lookup_widget(sheets_dialog, "wrapbox_right");
    if (wrapbox)
      gtk_widget_destroy(wrapbox);
  }

  if (custom_type_symbol == NULL)
  {
    /* This little bit identifies a custom object symbol so we can tell the
       difference later between a SVG shape and a Programmed shape */

    custom_type_symbol = NULL;
    for (plugin_list = dia_list_plugins(); plugin_list != NULL;
         plugin_list = g_list_next(plugin_list))
    {
       PluginInfo *info = plugin_list->data;

       custom_type_symbol = (gpointer)dia_plugin_get_symbol (info,
                                                             "custom_type");
       if (custom_type_symbol)
         break;
    }
  }

  if (!custom_type_symbol)
  {
    message_warning (_("Can't get symbol 'custom_type' from any module.\n"
		       "Editing shapes is disabled."));
    return FALSE;
  }

  for (sheets_list = get_sheets_list(); sheets_list;
       sheets_list = g_slist_next(sheets_list))
    sheets_append_sheet_mods(sheets_list->data);
    
  sw = lookup_widget(sheets_dialog, "scrolledwindow_right");
  /* In case glade already add a child to scrolledwindow */
  wrapbox = gtk_bin_get_child (GTK_BIN(sw));
  if (wrapbox)
    gtk_container_remove(GTK_CONTAINER(sw), wrapbox);
  wrapbox = gtk_hwrap_box_new(FALSE);
  g_object_ref(wrapbox);
  g_object_set_data(G_OBJECT(sheets_dialog), "wrapbox_right", wrapbox);
  gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw), wrapbox);
  gtk_wrap_box_set_justify(GTK_WRAP_BOX(wrapbox), GTK_JUSTIFY_TOP);
  gtk_wrap_box_set_line_justify(GTK_WRAP_BOX(wrapbox), GTK_JUSTIFY_LEFT);
  gtk_widget_show(wrapbox);
  g_object_set_data(G_OBJECT(wrapbox), "is_left", FALSE);
  option_menu = lookup_widget(sheets_dialog, "optionmenu_right");
  sheets_optionmenu_create(option_menu, wrapbox, sheet_right);

  sw = lookup_widget(sheets_dialog, "scrolledwindow_left");
  /* In case glade already add a child to scrolledwindow */
  wrapbox = gtk_bin_get_child (GTK_BIN(sw));
  if (wrapbox)
    gtk_container_remove(GTK_CONTAINER(sw), wrapbox);
  wrapbox = gtk_hwrap_box_new(FALSE);
  g_object_ref(wrapbox);
  g_object_set_data(G_OBJECT(sheets_dialog), "wrapbox_left", wrapbox);
  gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw), wrapbox);
  gtk_wrap_box_set_justify(GTK_WRAP_BOX(wrapbox), GTK_JUSTIFY_TOP);
  gtk_wrap_box_set_line_justify(GTK_WRAP_BOX(wrapbox), GTK_JUSTIFY_LEFT);
  gtk_widget_show(wrapbox);
  g_object_set_data(G_OBJECT(wrapbox), "is_left", (gpointer)TRUE);
  option_menu = lookup_widget(sheets_dialog, "optionmenu_left");
  sheets_optionmenu_create(option_menu, wrapbox, sheet_left);

  return TRUE;
}
예제 #17
0
void on_button_clicked (GtkWidget *button, gpointer user_data)
{
	int x_pos, y_pos;
	int current_pos;	
	gchar file_name[MAXSIZE];	
	struct pos *temp_undo_store_positions;
		
	temp_undo_store_positions = (struct pos *)(malloc(sizeof(struct pos)));
	current_pos = (gint) gtk_object_get_data (GTK_OBJECT(button), "current_pos");

			
	if ( is_legal_slide(current_pos, vacant_pos) ){
       		gtk_widget_set_sensitive(undo_button,TRUE); /* Activate undo button*/
		max_undos_supported_count++;	
			
		x_pos = vacant_pos%4; y_pos = (int)(vacant_pos/4);
		
		 if(temp_undo_store_positions){    
		     temp_undo_store_positions->attach_in_vac_pos = vacant_pos;
	             temp_undo_store_positions->link = undo_store_positions;
		     undo_store_positions = temp_undo_store_positions;		     
		 }else{
			 g_print("unable to allocate memory from heap for undo strcut");			 
			 gtk_main_quit();
			/* Quit application */
		 }

		no_of_valid_undos++;		
		gtk_container_remove (GTK_CONTAINER(table1), button);
		gtk_table_attach (GTK_TABLE (table1), 
			button, x_pos, x_pos + 1, y_pos, y_pos + 1,
			(GtkAttachOptions) GTK_FILL | GTK_EXPAND,
			(GtkAttachOptions) GTK_FILL | GTK_EXPAND,
			(GtkAttachOptions) 1, 1);

		gtk_object_set_data (GTK_OBJECT(button), "current_pos",(gpointer) vacant_pos);
		vacant_pos = current_pos;
		move_no++;
		
		if ( has_player_won() )	{
			gtk_statusbar_push (GTK_STATUSBAR(statusbar1), 0, g_strdup_printf("Eureka You Won the Game with in %i Moves", move_no));		    	     gtk_widget_hide (table1);
			image = gtk_image_new ();
		        sprintf(file_name,"%swon.png",IMAGES_DIR);
		        gtk_image_set_from_file (GTK_IMAGE(image), file_name);
		        gtk_object_ref(GTK_OBJECT(table1));
		        gtk_container_remove (GTK_CONTAINER(alignment1), table1);
		        gtk_container_add (GTK_CONTAINER(alignment1), image);
		        gtk_widget_show (image);
		}else
			gtk_statusbar_push (GTK_STATUSBAR(statusbar1), 0, g_strdup_printf("Move No.: %i", move_no));
	}
	else
		gtk_statusbar_push (GTK_STATUSBAR(statusbar1), 0, "Wrong Move !");


	if(max_undos_supported_count > NO_OF_UNDOS_SUPPORTED){
		max_undos_supported_count=NO_OF_UNDOS_SUPPORTED;		
		free_last_element_in_undo_stack(&undo_store_positions);		
	}

}
static void
um_account_dialog_init (UmAccountDialog *self)
{
        GtkBuilder *builder;
        GtkWidget *widget;
        const gchar *filename;
        GError *error = NULL;
        GtkDialog *dialog;
        GtkWidget *content;
        GtkWidget *actions;
        GtkWidget *box;

        builder = gtk_builder_new ();
        gtk_builder_set_translation_domain (builder, GETTEXT_PACKAGE);
        filename = UIDIR "/account-dialog.ui";
        if (!g_file_test (filename, G_FILE_TEST_EXISTS))
                filename = "data/account-dialog.ui";
        if (!gtk_builder_add_from_file (builder, filename, &error)) {
                g_error ("%s", error->message);
                g_error_free (error);
                return;
        }

        dialog = GTK_DIALOG (self);
        actions = gtk_dialog_get_action_area (dialog);
        content = gtk_dialog_get_content_area (dialog);
        gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
        gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
        gtk_window_set_title (GTK_WINDOW (dialog), " ");
        gtk_window_set_icon_name (GTK_WINDOW (dialog), "system-users");

        /* Rearrange the bottom of dialog, so we can have spinner on left */
        g_object_ref (actions);
        box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
        gtk_container_remove (GTK_CONTAINER (content), actions);
        gtk_box_pack_end (GTK_BOX (box), actions, FALSE, TRUE, 0);
        gtk_box_pack_end (GTK_BOX (content), box, TRUE, TRUE, 0);
        gtk_widget_show (box);
        g_object_unref (actions);

        /* Create the spinner, but don't show it yet */
        self->spinner = GTK_SPINNER (gtk_spinner_new ());
        widget = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
        gtk_alignment_set_padding (GTK_ALIGNMENT (widget), 0, 0, 12, 6);
        gtk_box_pack_start (GTK_BOX (box), widget, FALSE, FALSE, 0);
        gtk_container_add (GTK_CONTAINER (widget), GTK_WIDGET (self->spinner));
        gtk_widget_show (widget);

        gtk_dialog_add_button (dialog, _("Cancel"), GTK_RESPONSE_CANCEL);
        widget = gtk_dialog_add_button (dialog, _("_Add"), GTK_RESPONSE_OK);
        gtk_widget_grab_default (widget);

        widget = (GtkWidget *) gtk_builder_get_object (builder, "account-dialog");
        gtk_container_add (GTK_CONTAINER (content), widget);
        self->container_widget = widget;

        local_init (self, builder);
        enterprise_init (self, builder);
        join_init (self, builder);
        mode_init (self, builder);

        g_object_unref (builder);
}
예제 #19
0
파일: tabwin.c 프로젝트: aylusltd/gretl
void undock_tabbed_viewer (GtkWidget *w, windata_t *vwin)
{
    tabwin_t *tabwin = vwin_get_tabwin(vwin);
    GtkNotebook *notebook = GTK_NOTEBOOK(tabwin->tabs);
    gint pg = gtk_notebook_page_num(notebook, vwin->main);
    GtkWidget *hbox = vwin->main;
    gulong handler_id;
    gchar *title;

    if (gtk_notebook_get_n_pages(notebook) < 2) {
	/* we won't do this if there's only one page in the
	   viewer */
	return;
    }

#if TDEBUG
    fprintf(stderr, "undock_tabbed_viewer: starting on vwin at %p\n",
	    (void *) vwin);
#endif

    /* disconnect stuff */
    vwin->main = vwin->topmain = NULL;

    /* remove signals and data from hbox (ex vwin->main) */
    g_object_steal_data(G_OBJECT(hbox), "vwin");
    g_signal_handlers_disconnect_by_func(hbox,
					 free_windata,
					 vwin);
    handler_id = GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(vwin->mbar),
						    "destroy-id"));
    if (handler_id > 0) {
	g_signal_handler_disconnect(vwin->mbar, handler_id);
	g_object_steal_data(G_OBJECT(vwin->mbar), "destroy-id");
    }

    /* extract vwin->vbox from its tabbed holder */
    g_object_ref(vwin->vbox);
    gtk_container_remove(GTK_CONTAINER(hbox), vwin->vbox);
    gtk_notebook_remove_page(notebook, pg);

    /* tweak vbox params */
    gtk_box_set_spacing(GTK_BOX(vwin->vbox), 4);
    gtk_container_set_border_width(GTK_CONTAINER(vwin->vbox), 4);

    /* build new shell for @vwin */
    vwin->main = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    title = title_from_vwin(vwin);
    gtk_window_set_title(GTK_WINDOW(vwin->main), title);
    g_free(title);
    handler_id = g_signal_connect(G_OBJECT(vwin->main), "destroy", 
				  G_CALLBACK(free_windata), vwin);
    g_object_set_data(G_OBJECT(vwin->main), "destroy-id",
		      GUINT_TO_POINTER(handler_id));
    g_object_set_data(G_OBJECT(vwin->main), "vwin", vwin);
    size_new_toplevel(vwin);

#if TDEBUG
    fprintf(stderr, "*** undock_tabbed_viewer: new main=%p, mbar=%p\n", 
	    (void *) vwin->main, (void *) vwin->mbar);
#endif

    /* add box for toolbar, pack it, drop extra ref., then
       remove the "tabbed" flag (note that the tabbed flag
       is wanted so that vwin_pack_toolbar will put the
       toolbar up top)
    */
    vwin_pack_toolbar(vwin);
    g_object_unref(vwin->mbar);
    vwin->flags &= ~VWIN_TABBED;

    if (vwin->role == EDIT_SCRIPT) {
	script_editor_show_new_open(vwin, FALSE);
    }

    /* put vbox into new top-level window and drop extra ref. */
    gtk_container_add(GTK_CONTAINER(vwin->main), vwin->vbox);
    g_object_unref(vwin->vbox);

    /* connect delete signal for single-script window */
    g_signal_connect(G_OBJECT(vwin->main), "delete-event", 
		     G_CALLBACK(query_save_text), vwin);

    /* add to window list and attach window-key signals */
    window_list_add(vwin->main, vwin->role);

    /* add key-catcher for single-item window */
    g_signal_connect(G_OBJECT(vwin->main), "key-press-event", 
		     G_CALLBACK(catch_viewer_key), vwin);

#ifndef G_OS_WIN32
    set_wm_icon(vwin->main);
#endif

    gtk_widget_show(vwin->main);
    gtk_widget_grab_focus(vwin->text);

#if TDEBUG
    fprintf(stderr, "undock_tabbed_viewer: done\n");
#endif
}
예제 #20
0
파일: ec_gtk.c 프로젝트: mfer/ettercap
/* returns a parent widget to pack the contents of the page into */
GtkWidget *gtkui_page_new(char *title, void (*callback)(void), void (*detacher)(GtkWidget *)) {
   GtkWidget *parent, *label;
   GtkWidget *hbox, *button, *image;

   /* a container to hold the close button and tab label */
   hbox = gtk_hbox_new(FALSE, 0);
   gtk_widget_show(hbox);

   /* the label for the tab title */
   label = gtk_label_new(title);
   gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
   gtk_widget_show(label);

   /* the close button */
   button = gtk_button_new();
   gtk_button_set_relief(GTK_BUTTON (button), GTK_RELIEF_NONE);
   gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
   gtk_widget_set_size_request(button, 20, 20);
   gtk_widget_show(button);

   /* an image for the button */
   image = gtk_image_new_from_stock (GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU);
   gtk_container_add(GTK_CONTAINER (button), image);
   gtk_widget_show(image);

   /* a parent to pack the contents into */
   parent = gtk_frame_new(NULL);
   gtk_frame_set_shadow_type(GTK_FRAME(parent), GTK_SHADOW_NONE);
   gtk_widget_show(parent);

   if(!notebook && notebook_frame) {
      gtk_container_remove(GTK_CONTAINER (notebook_frame), gtk_bin_get_child(GTK_BIN (notebook_frame)));

      notebook = gtk_notebook_new();
      gtk_notebook_set_tab_pos(GTK_NOTEBOOK (notebook), GTK_POS_TOP);
      gtk_notebook_set_scrollable(GTK_NOTEBOOK (notebook), TRUE);
      gtk_container_add(GTK_CONTAINER (notebook_frame), notebook);
      gtk_widget_show(notebook);

      #if GTK_MINOR_VERSION == 2
      g_signal_connect(G_OBJECT (notebook), "switch-page", G_CALLBACK(gtkui_page_defocus_tabs), NULL);
      #endif 

      gtkui_create_tab_menu();
   }

   gtk_notebook_append_page(GTK_NOTEBOOK(notebook), parent, hbox);

   /* attach callback to destroy the tab/page */
   g_signal_connect(G_OBJECT (button), "clicked", G_CALLBACK(gtkui_page_close), parent);

   /* attach callback to do specific clean-up */
   if(callback)
      g_object_set_data(G_OBJECT (parent), "destroy", callback);

   if(detacher)
      g_object_set_data(G_OBJECT (parent), "detach", detacher);

   gtkui_page_present(parent);

   return(parent);
}
예제 #21
0
void gif_receive_messages(void *server)
{
	int server_sockfd = *(int *)server;
	gifhdr_t *gifheader;
	int rcv_status;
	char *gifdata, *gifbuffer;
	char PATHNAME[MAX_PATH_LENGTH];

	pthread_t pthd = pthread_self();

	while(1)
	{
		gifbuffer = (char *) malloc(BUFF_SIZE);
		rcv_status = recv(server_sockfd, gifbuffer, BUFF_SIZE, 0);

		if(rcv_status < 0) //发生错误
		{
			gdk_threads_enter();
			message_dialog(GTK_MESSAGE_INFO, strerror(errno));
			gdk_threads_leave();
			pthread_cancel(pthd); //非正常退出
		}
		else if(rcv_status == 0) //断开连接
		{
			contacts_chat_window_id_t *ptr;
			GtkWidget *widget;

			gdk_threads_enter();
			message_dialog(GTK_MESSAGE_INFO, "Server Disconnected");
			gdk_threads_leave();

			while(head != NULL) // freeing the allocated spaces for linked list
			{
				ptr = head;
				head = head->next;
				free(ptr);
			}

			gdk_threads_enter();

			gtk_container_remove(GTK_CONTAINER(scrolledwindow1), tree);
			widget = lookup_widget(gifmain, "butConnect");
			gtk_widget_set_sensitive(widget, TRUE);
			widget = lookup_widget(gifmain, "mnuConnect");
			gtk_widget_set_sensitive(widget, TRUE);
			widget = lookup_widget(gifmain, "mnuDisconect");
			gtk_widget_set_sensitive(widget, FALSE);
			widget = lookup_widget(gifmain, "butAdd");
			gtk_widget_set_sensitive(widget, FALSE);
			widget = lookup_widget(gifmain, "mnuAdd");
			gtk_widget_set_sensitive(widget, FALSE);
			widget = lookup_widget(gifmain, "mnuDelete");
			gtk_widget_set_sensitive(widget, FALSE);
			widget = lookup_widget(gifmain, "butConf");
			gtk_widget_set_sensitive(widget, FALSE);
			widget = lookup_widget(gifmain, "butOffline");
			gtk_widget_set_sensitive(widget, FALSE);
			widget = lookup_widget(gifmain, "mnuOffline");
			gtk_widget_set_sensitive(widget, FALSE);

			gdk_threads_leave();

			pthread_cancel(pthd);
		}

		gifheader = (gifhdr_t *) malloc(sizeof(gifhdr_t));
		memcpy(gifheader, gifbuffer, HEADER_LENGTH);
		if((gifheader->length) > 0)
		{
			gifdata = (char *) malloc(gifheader->length);
			memcpy(gifdata, (gifbuffer + HEADER_LENGTH), gifheader->length);
		}
		else
                {
			gifdata = NULL;
                }

		switch(gifheader->type)
		{
		case GIF_ADDRLIST_MSG:
		{
			contacts_chat_window_id_t *ptr;
			user_status_t *usrs;
			int i, counter;

			gdk_threads_enter();
			GtkWidget *widget;
			GtkTreeStore *store;
			GtkTreeViewColumn *column;
			GtkCellRenderer *renderer;
			GtkTreeIter parent_iter, child_iter;
			GdkPixbuf *img;
			GtkTreeSelection *select;
			gdk_threads_leave();

			if(gifheader->reserved == 1)
			{
				// removing the tree from the container for refresing
				gdk_threads_enter();
				gtk_container_remove(GTK_CONTAINER(scrolledwindow1), tree);
				gdk_threads_leave();

				while(head != NULL) // freeing the allocated spaces for linked list
				{
					ptr = head;
					head = head->next;
					free(ptr);
				}
			}

			gdk_threads_enter();
			widget = lookup_widget(gifmain, "butConnect");
			gtk_widget_set_sensitive(widget, FALSE);
			widget = lookup_widget(gifmain, "mnuConnect");
			gtk_widget_set_sensitive(widget, FALSE);
			widget = lookup_widget(gifmain, "mnuDisconect");
			gtk_widget_set_sensitive(widget, TRUE);
			widget = lookup_widget(gifmain, "butAdd");
			gtk_widget_set_sensitive(widget, TRUE);
			widget = lookup_widget(gifmain, "mnuAdd");
			gtk_widget_set_sensitive(widget, TRUE);
			widget = lookup_widget(gifmain, "mnuDelete");
			gtk_widget_set_sensitive(widget, TRUE);
			widget = lookup_widget(gifmain, "butConf");
			gtk_widget_set_sensitive(widget, TRUE);
			widget = lookup_widget(gifmain, "butOffline");
			gtk_widget_set_sensitive(widget, TRUE);
			widget = lookup_widget(gifmain, "mnuOffline");
			gtk_widget_set_sensitive(widget, TRUE);
			gdk_threads_leave();

			//creating a model
			gdk_threads_enter();
			store = gtk_tree_store_new(2, G_TYPE_STRING, GDK_TYPE_PIXBUF);
			gdk_threads_leave();

			//creating a view
			gdk_threads_enter();
			tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
			gdk_threads_leave();

			//adding the view to the scrolledwindow
			gdk_threads_enter();
			gtk_container_add(GTK_CONTAINER(scrolledwindow1), tree);
			gdk_threads_leave();

			//creating first column
			gdk_threads_enter();
			renderer = gtk_cell_renderer_pixbuf_new();
			column = gtk_tree_view_column_new_with_attributes("Status", renderer, "pixbuf", STATUS_COLUMN_PIXMAP, NULL);
			gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
			gdk_threads_leave();

			//creating second column
			gdk_threads_enter();
			renderer = gtk_cell_renderer_text_new();
			column = gtk_tree_view_column_new_with_attributes("Contacts", renderer, "text", CONTACTS_COLUMN_TEXT, NULL);
			gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
			gdk_threads_leave();

			//Acquire a top-level iterator
			gdk_threads_enter();
			gtk_tree_store_append(store, &parent_iter, NULL);
			if(gifheader->length != 0)
                        {
                                gtk_tree_store_set(store, &parent_iter, CONTACTS_COLUMN_TEXT, "Available", -1);
                        }
			else
                        {
                                gtk_tree_store_set(store, &parent_iter, CONTACTS_COLUMN_TEXT, "Not Available", -1);
                        }
			gdk_threads_leave();

			i = counter = 0;
			usrs = (user_status_t *) malloc(sizeof(user_status_t));
			while(counter < (gifheader->length))
			{
				contacts_chat_window_id_t *ptr;

				memcpy(usrs, (gifdata + (i * sizeof(user_status_t))), sizeof(user_status_t));

				// setting the window id for each contacts and constructing a linked list
				ptr = (contacts_chat_window_id_t *) malloc(sizeof(contacts_chat_window_id_t));
				strcpy(ptr->contacts_name, usrs->loginid);
				ptr->window_id = i;
				ptr->window_open = 0;
				if(head == NULL)
				{
					head = ptr;
					ptr->next = NULL;
				}
				else
				{
					ptr->next = head;
					head = ptr;
				}

				// setting the status image for online clients and offline clients
				gdk_threads_enter();
				if(usrs->status == 1)
                                {
                                        get_full_path_name(PATHNAME,"ok.png",1,"client/pixmaps");
                                        img = gdk_pixbuf_new_from_file(PATHNAME, NULL);
                                }
				else
                                {
                                        get_full_path_name(PATHNAME,"kill.png",1,"client/pixmaps");
                                        img = gdk_pixbuf_new_from_file(PATHNAME, NULL);
                                }
				gdk_threads_leave();

				//Acquire a child iterator
				gdk_threads_enter();
				gtk_tree_store_append(store, &child_iter, &parent_iter);
				gtk_tree_store_set(store, &child_iter, CONTACTS_COLUMN_TEXT, usrs->loginid, STATUS_COLUMN_PIXMAP, img, -1);
				gdk_threads_leave();

				i++;
				counter = i * sizeof(user_status_t);
			}
			free(usrs);

			gdk_threads_enter();
			gtk_tree_view_expand_all(GTK_TREE_VIEW(tree));
			gtk_widget_show(tree);
			gdk_threads_leave();

			// signal handling for "changed" event
			gdk_threads_enter();
			select = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree));
			gtk_tree_selection_set_mode(select, GTK_SELECTION_SINGLE);
			g_signal_connect(G_OBJECT(select), "changed", G_CALLBACK(gif_call_client_for_chat), NULL);
			gdk_threads_leave();

			if((gifheader->length) != 0)
                        {
                                free(gifdata);
                        }
			free(gifheader);
			free(gifbuffer);

			break;
		}

		case GIF_CHAT_MSG:
		{
			contacts_chat_window_id_t *ptr;
			GtkWidget *display_text;
			GtkTextBuffer *buff;
			GtkTextIter start, end;
			int line_no;

			for(ptr = head; ptr != NULL; ptr = ptr->next)
			{
				if((strcmp(ptr->contacts_name, gifheader->sender)) == 0)
					break;
				else
					continue;
			}

			if(ptr->window_open == 0)
			{
				GtkWidget *widget;
				GtkTextBuffer *buff;
				ptr->window_open = 1;	// since the window is gonna be opened

				gdk_threads_enter();
				chat_window[ptr->window_id] = create_Chat();
				widget =
				        lookup_widget(chat_window[ptr->window_id], "entInput");
				gtk_window_set_focus(GTK_WINDOW
				                     (chat_window[ptr->window_id]), widget);
				gtk_window_set_title(GTK_WINDOW
				                     (chat_window[ptr->window_id]),
				                     gifheader->sender);
				gtk_widget_show(chat_window[ptr->window_id]);
				gdk_threads_leave();

				// creating tags(foreground color) for the buffer
				gdk_threads_enter();
				widget =
				        lookup_widget(chat_window[ptr->window_id], "txtDisplay");
				buff = gtk_text_view_get_buffer(GTK_TEXT_VIEW(widget));
				gtk_text_buffer_create_tag(buff, "red_foreground",
				                           "foreground", "red", NULL);
				gtk_text_buffer_create_tag(buff, "blue_foreground",
				                           "foreground", "blue", NULL);
				gdk_threads_leave();
			}

			gdk_threads_enter();
			display_text =
			        lookup_widget(chat_window[ptr->window_id], "txtDisplay");
			buff = gtk_text_view_get_buffer(GTK_TEXT_VIEW(display_text));
			gtk_text_buffer_insert_at_cursor(buff, gifheader->sender, -1);
			gtk_text_buffer_insert_at_cursor(buff, "  :  ", -1);
			gtk_text_buffer_insert_at_cursor(buff, gifdata, -1);
			gdk_threads_leave();

			// setting the color(blue) for client's name in the display text box
			gdk_threads_enter();
			line_no = gtk_text_buffer_get_line_count(buff);
			gtk_text_buffer_get_iter_at_line(buff, &start, line_no);
			gtk_text_buffer_get_iter_at_line_offset(buff, &end,
			                                        line_no,
			                                        strlen
			                                        (gifheader->sender));
			gtk_text_buffer_apply_tag_by_name(buff,
			                                  "blue_foreground",
			                                  &start, &end);

			gtk_text_buffer_insert_at_cursor(buff, "\n", -1);
			gdk_threads_leave();

			if((gifheader->length) != 0)
				free(gifdata);
			free(gifheader);
			free(gifbuffer);

			break;
		}

		case GIF_SUCCESS_N_ERROR_MSG:
		{
			switch(gifheader->reserved)
			{
			case GIF_ERROR_LOGIN_INCORRECT:
			{
				gdk_threads_enter();
				message_dialog(GTK_MESSAGE_INFO, "Login Incorrect");
				gdk_threads_leave();
				break;
			}

			case GIF_SUCCESS_ADD_CONTACTS:
			{
				gdk_threads_enter();
				message_dialog(GTK_MESSAGE_INFO, "Your new contact has been successfully added");
				gdk_threads_leave();

				break;
			}

			case GIF_ERROR_ADD_CONTACTS:
			{
				gdk_threads_enter();
				message_dialog(GTK_MESSAGE_INFO,"The contact id you entered does not belong to a gchat user");
				gdk_threads_leave();

				break;
			}

			case GIF_SUCCESS_DELETE_CONTACTS:
			{
				gdk_threads_enter();
				message_dialog(GTK_MESSAGE_INFO,"Deleted. See the new list after you re-login");
				gdk_threads_leave();

				break;
			}

			case GIF_ERROR_DELETE_CONTACTS_NOT_A_CONTACT:
			{
				gdk_threads_enter();
				message_dialog(GTK_MESSAGE_INFO,"1. The id you entered is not in your contact list");
				gdk_threads_leave();

				break;
			}

			case GIF_ERROR_DELETE_CONTACTS_NOT_A_MEMBER:
			{
				gdk_threads_enter();
				message_dialog(GTK_MESSAGE_INFO,"2. The id you entered is not in your contact list");
				gdk_threads_leave();

				break;
			}

			}

			if((gifheader->length) != 0)
                        {
                                free(gifdata);
                        }
			free(gifheader);
			free(gifbuffer);

			break;
		}

		case GIF_OFFLINE_MSG:
		{
			int counter;
			char *message;
			offline_msgs_send_t *omsgs_se;

			gdk_threads_enter();
			GtkWidget *widget;
			GtkListStore *store;
			GtkTreeViewColumn *column;
			GtkCellRenderer *renderer;
			GtkTreeIter iter;
			GdkPixbuf *img;
			gdk_threads_leave();

			if(gifheader->reserved == 1) //刷新联系人在线状态
			{
				offline_messages_count = 0;

				//creating a model
				gdk_threads_enter();
				store = gtk_list_store_new(OFFLINE_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
				offline_temp_store = store;
				gdk_threads_leave();

				//creating a view
				gdk_threads_enter();
				offline_tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
				gdk_threads_leave();

				//adding the view to the scrolledwindow
				gdk_threads_enter();
				gtk_container_add(GTK_CONTAINER(scrolledwindow4), offline_tree);
				gdk_threads_leave();

				//creating first column
				gdk_threads_enter();
				renderer = gtk_cell_renderer_pixbuf_new();
				column = gtk_tree_view_column_new_with_attributes("New/Old", renderer, "pixbuf", OFFLINE_NEW_PIXMAP, NULL);
				gtk_tree_view_append_column(GTK_TREE_VIEW(offline_tree), column);
				gdk_threads_leave();

				//creating second column
				gdk_threads_enter();
				renderer = gtk_cell_renderer_text_new();
				g_object_set(G_OBJECT(renderer), "foreground", "red", NULL);
				column = gtk_tree_view_column_new_with_attributes("From", renderer, "text", OFFLINE_SENDER_TEXT, NULL);
				gtk_tree_view_append_column(GTK_TREE_VIEW(offline_tree), column);
				gdk_threads_leave();

				//creating third column
				gdk_threads_enter();
				renderer = gtk_cell_renderer_text_new();
				g_object_set(G_OBJECT(renderer), "foreground", "dark green", NULL);
				column = gtk_tree_view_column_new_with_attributes("Date & Time", renderer, "text",OFFLINE_DATESERIAL_TEXT, NULL);
				gtk_tree_view_append_column(GTK_TREE_VIEW(offline_tree), column);
				gdk_threads_leave();

				//creating fourth column
				gdk_threads_enter();
				renderer = gtk_cell_renderer_text_new();
				column = gtk_tree_view_column_new_with_attributes("Message", renderer, "text", OFFLINE_MSG_TEXT, NULL);
				gtk_tree_view_append_column(GTK_TREE_VIEW(offline_tree), column);
				gdk_threads_leave();
			}
			else
                        {
                                _DEBUG("error: condition");
				pthread_cancel(pthd);
				return;
                        }

			counter = 0;
			omsgs_se =
			        (offline_msgs_send_t *) malloc(sizeof(offline_msgs_send_t));
			while(counter < (gifheader->length))
			{
				gdk_threads_enter();
				widget = lookup_widget(offline, "butOfflineDelete");
				gtk_widget_set_sensitive(widget, TRUE);
				gdk_threads_leave();

				memcpy(omsgs_se, (gifdata + counter),
				       sizeof(offline_msgs_send_t));
				counter = counter + sizeof(offline_msgs_send_t);

				message = (char *) malloc(omsgs_se->length);
				strncpy(message, (gifdata + counter), omsgs_se->length);
				counter = counter + (omsgs_se->length);

				// setting the status image for online clients and offline clients
				gdk_threads_enter();
				if(omsgs_se->new == 1)
                                {
                                        get_full_path_name(PATHNAME,"ok.png",1,"client/pixmaps");
                                        img = gdk_pixbuf_new_from_file(PATHNAME, NULL);
                                }
				else
                                {
                                        get_full_path_name(PATHNAME,"kill.png",1,"client/pixmaps");
                                        img = gdk_pixbuf_new_from_file(PATHNAME, NULL);
                                }
				gdk_threads_leave();

				//Acquire a child iterator
				gdk_threads_enter();
				gtk_list_store_append(store, &iter);
				gtk_list_store_set(store, &iter,
				                   OFFLINE_NEW_PIXMAP, img,
				                   OFFLINE_SENDER_TEXT,
				                   omsgs_se->sender,
				                   OFFLINE_DATESERIAL_TEXT,
				                   omsgs_se->dateserial,
				                   OFFLINE_MSG_TEXT, message, -1);
				gdk_threads_leave();

				offline_messages_count++;

				free(message);
			}
			free(omsgs_se);

			gdk_threads_enter();
			gtk_widget_show(offline_tree);
			gdk_threads_leave();

			if(gifheader->reserved == 1)
			{
				GtkTreeSelection *select;

				// signal handling for "changed" event
				gdk_threads_enter();
				select =
				        gtk_tree_view_get_selection(GTK_TREE_VIEW(offline_tree));
				gtk_tree_selection_set_mode(select, GTK_SELECTION_SINGLE);
				g_signal_connect(G_OBJECT(select), "changed",
				                 G_CALLBACK
				                 (gif_select_offline_messages), NULL);
				gdk_threads_leave();
			}

			if((gifheader->length) != 0)
				free(gifdata);
			free(gifheader);
			free(gifbuffer);

			break;
		}
		}
	}
예제 #22
0
static void
exo_toolbars_editor_update (ExoToolbarsEditor *editor)
{
  GtkAction         *action;
  GtkWidget         *image;
  GtkWidget         *item;
  GList             *children;
  GList             *actions;
  GList             *lp;
  gchar             *stock;
  gchar             *text;
  gint               height;
  gint               width = 4;
  gint               x = 0;
  gint               y = 0;

  if (editor->priv->finalizing)
    return;

  /* remove all existing tool items */
  children = gtk_container_get_children (GTK_CONTAINER (editor->priv->table));
  for (lp = children; lp != NULL; lp = lp->next)
    gtk_container_remove (GTK_CONTAINER (editor->priv->table), lp->data);
  g_list_free (children);

  if (editor->priv->model == NULL || editor->priv->ui_manager == NULL)
    return;

  gtk_widget_set_sensitive (GTK_WIDGET (editor), TRUE);

  actions = exo_toolbars_editor_get_actions (editor, editor->priv->model);
  height = g_list_length (actions) / width + 1;
  gtk_table_resize (GTK_TABLE (editor->priv->table), height, width);
  for (lp = actions; lp != NULL; lp = lp->next)
    {
      action = lp->data;

      g_object_get (G_OBJECT (action),
                    "short-label", &text,
                    "stock-id", &stock,
                    NULL);

      if (G_UNLIKELY (stock == NULL))
        stock = g_strdup (GTK_STOCK_DND);

      image = gtk_image_new_from_icon_name (stock, GTK_ICON_SIZE_LARGE_TOOLBAR);
      item = exo_toolbars_editor_create_item (editor, image, text,
                                              GDK_ACTION_MOVE);
      g_object_set_data (G_OBJECT (item), I_("gtk-action"), action);
      gtk_table_attach_defaults (GTK_TABLE (editor->priv->table),
                                 item, x, x + 1, y, y + 1);

      g_free (stock);
      g_free (text);

      if (++x >= width)
        {
          x= 0; ++y;
        }
    }
  g_list_free (actions);

  image = _exo_toolbars_new_separator_image ();
  item = exo_toolbars_editor_create_item (editor, image,
                                          _("Separator"),
                                          GDK_ACTION_COPY);
  gtk_table_attach_defaults (GTK_TABLE (editor->priv->table),
                             item, x, x + 1, y, y + 1);

  return;
}
예제 #23
0
파일: qe3.cpp 프로젝트: mrwonko/GtkRadiant
void FillBSPMenu(){
	GtkWidget *item, *menu; // menu points to a GtkMenu (not an item)
	epair_t *ep;
	GList *lst;
	int i;

	menu = GTK_WIDGET( g_object_get_data( G_OBJECT( g_qeglobals_gui.d_main_window ), "menu_bsp" ) );

	while ( ( lst = gtk_container_children( GTK_CONTAINER( menu ) ) ) != NULL )
		gtk_container_remove( GTK_CONTAINER( menu ), GTK_WIDGET( lst->data ) );

	if ( g_PrefsDlg.m_bDetachableMenus ) {
		item = gtk_tearoff_menu_item_new();
		gtk_menu_append( GTK_MENU( menu ), item );
		gtk_widget_set_sensitive( item, TRUE );
		gtk_widget_show( item );
	}

	if ( g_qeglobals.bBSPFrontendPlugin ) {
		CString str = g_BSPFrontendTable.m_pfnGetBSPMenu();
		char cTemp[1024];
		strcpy( cTemp, str );
		char* token = strtok( cTemp, ",;" );
		if ( token && *token == ' ' ) {
			while ( *token == ' ' )
				token++;
		}
		i = 0;

		// first token is menu name
		item = gtk_menu_get_attach_widget( GTK_MENU( menu ) );
		gtk_label_set_text( GTK_LABEL( GTK_BIN( item )->child ), token );

		token = strtok( NULL, ",;" );
		while ( token != NULL )
		{
			g_BSPFrontendCommands = g_slist_append( g_BSPFrontendCommands, g_strdup( token ) );
			item = gtk_menu_item_new_with_label( token );
			gtk_widget_show( item );
			gtk_container_add( GTK_CONTAINER( menu ), item );
			gtk_signal_connect( GTK_OBJECT( item ), "activate",
								GTK_SIGNAL_FUNC( HandleCommand ), GINT_TO_POINTER( CMD_BSPCOMMAND + i ) );
			token = strtok( NULL, ",;" );
			i++;
		}
	}
	else
	{
		i = 0;
		for ( ep = g_qeglobals.d_project_entity->epairs; ep; ep = ep->next )
		{
			if ( strncmp( ep->key, "bsp_", 4 ) == 0 ) {
				bsp_commands[i] = ep->key;
				item = gtk_menu_item_new_with_label( ep->key + 4 );
				gtk_widget_show( item );
				gtk_container_add( GTK_CONTAINER( menu ), item );
				gtk_signal_connect( GTK_OBJECT( item ), "activate",
									GTK_SIGNAL_FUNC( HandleCommand ), GINT_TO_POINTER( CMD_BSPCOMMAND + i ) );
				i++;
			}
		}
	}
}
예제 #24
0
static void
remove_widget (GtkWidget *widget, GtkContainer *container)
{
    gtk_container_remove (container, widget);
}
예제 #25
0
static void
wikipad_statusbar_init (WikipadStatusbar *statusbar)
{
  GtkWidget    *ebox, *box, *separator, *label;
  GtkStatusbar *bar = GTK_STATUSBAR (statusbar);
  GList *frame;

  /* init statusbar */
#if ! GTK_CHECK_VERSION(3, 0, 0)
  gtk_statusbar_set_has_resize_grip (bar, TRUE);
#endif

  /* create a new horizontal box */
  box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
  gtk_widget_show (box);

  /* reorder the gtk statusbar */
  frame = gtk_container_get_children (GTK_CONTAINER (bar));
  gtk_frame_set_shadow_type (GTK_FRAME (frame->data), GTK_SHADOW_NONE);
  label = gtk_bin_get_child (GTK_BIN (frame->data));
  g_object_ref (label);
  gtk_container_remove (GTK_CONTAINER (frame->data), label);
  gtk_container_add (GTK_CONTAINER (frame->data), box);
  gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
  g_object_unref (label);
  g_list_free (frame);

  /* separator */
  separator = gtk_separator_new (GTK_ORIENTATION_VERTICAL);
  gtk_box_pack_start (GTK_BOX (box), separator, FALSE, FALSE, 0);
  gtk_widget_show (separator);

  /* language/filetype event box */
  ebox = gtk_event_box_new ();
  gtk_box_pack_start (GTK_BOX (box), ebox, FALSE, TRUE, 0);
  gtk_event_box_set_visible_window (GTK_EVENT_BOX (ebox), FALSE);
  gtk_widget_set_tooltip_text (ebox, _("Choose a filetype"));
  g_signal_connect (G_OBJECT (ebox), "button-press-event", G_CALLBACK (wikipad_statusbar_filetype_clicked), statusbar);
  gtk_widget_show (ebox);

  /* language/filetype */
  statusbar->language = gtk_label_new (_("Filetype: None"));
  gtk_container_add (GTK_CONTAINER (ebox), statusbar->language);
  gtk_widget_show (statusbar->language);

  /* separator */
  separator = gtk_separator_new (GTK_ORIENTATION_VERTICAL);
  gtk_box_pack_start (GTK_BOX (box), separator, FALSE, FALSE, 0);
  gtk_widget_show (separator);

  /* line and column numbers */
  statusbar->position = gtk_label_new (NULL);
  gtk_box_pack_start (GTK_BOX (box), statusbar->position, FALSE, TRUE, 0);
  gtk_widget_show (statusbar->position);

  /* separator */
  separator = gtk_separator_new (GTK_ORIENTATION_VERTICAL);
  gtk_box_pack_start (GTK_BOX (box), separator, FALSE, FALSE, 0);
  gtk_widget_show (separator);

  /* overwrite event box */
  ebox = gtk_event_box_new ();
  gtk_box_pack_start (GTK_BOX (box), ebox, FALSE, TRUE, 0);
  gtk_event_box_set_visible_window (GTK_EVENT_BOX (ebox), FALSE);
  gtk_widget_set_tooltip_text (ebox, _("Toggle the overwrite mode"));
  g_signal_connect (G_OBJECT (ebox), "button-press-event", G_CALLBACK (wikipad_statusbar_overwrite_clicked), statusbar);
  gtk_widget_show (ebox);

  /* overwrite label */
  statusbar->overwrite = gtk_label_new (_("OVR"));
  gtk_container_add (GTK_CONTAINER (ebox), statusbar->overwrite);
  gtk_widget_show (statusbar->overwrite);
}
static void
get_devices_cb (GObject *source_object, GAsyncResult *res, gpointer user_data)
{
  CcPowerPanel *panel;
  CcPowerPanelPrivate *priv;
  gboolean got_primary = FALSE;
  gboolean ups_as_primary_device = FALSE;
  GError *error = NULL;
  gsize n_devices;
  GList *children;
  GList *l;
  GtkWidget *widget;
  guint i;
  guint secondary_devices_cnt = 0;
  GVariant *child;
  GVariant *result;
  GVariant *untuple;
  UpDeviceKind kind;
  UpDeviceState state;

  result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object), res, &error);
  if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
    {
      g_error_free (error);
      return; /* Must exit before accessing freed memory */
    }

  panel = CC_POWER_PANEL (user_data);
  priv = panel->priv;

  /* empty the secondary box */
  widget = WID ("grid_secondary");
  children = gtk_container_get_children (GTK_CONTAINER (widget));
  for (l = children; l != NULL; l = l->next)
    gtk_container_remove (GTK_CONTAINER (widget), l->data);
  g_list_free (children);

  /* hide both panels initially */
  widget = WID ("box_primary");
  gtk_widget_hide (widget);
  widget = WID ("box_secondary");
  gtk_widget_hide (widget);

  if (result == NULL)
    {
      g_printerr ("Error getting devices: %s\n", error->message);
      g_error_free (error);
      return;
    }

  untuple = g_variant_get_child_value (result, 0);
  n_devices = g_variant_n_children (untuple);

  /* first we look for a discharging UPS, which is promoted to the
   * primary device if it's discharging. Otherwise we use the first
   * listed laptop battery as the primary device */
  for (i = 0; i < n_devices; i++)
    {
      child = g_variant_get_child_value (untuple, i);
      g_variant_get (child,
                     "(susdut)",
                     NULL,
                     &kind,
                     NULL,
                     NULL,
                     &state,
                     NULL);
      if (kind == UP_DEVICE_KIND_UPS &&
          state == UP_DEVICE_STATE_DISCHARGING)
        {
          ups_as_primary_device = TRUE;
        }
      g_variant_unref (child);
    }

  /* add the devices now we know the state-of-play */
  for (i = 0; i < n_devices; i++)
    {
      child = g_variant_get_child_value (untuple, i);
      g_variant_get (child,
                     "(susdut)",
                     NULL,
                     &kind,
                     NULL,
                     NULL,
                     NULL,
                     NULL);
      if (kind == UP_DEVICE_KIND_LINE_POWER)
        {
          /* do nothing */
        }
      else if (kind == UP_DEVICE_KIND_UPS && ups_as_primary_device)
        {
          set_device_ups_primary (panel, child);
        }
      else if (kind == UP_DEVICE_KIND_BATTERY && !ups_as_primary_device)
        {
          if (!got_primary)
            {
              set_device_battery_primary (panel, child);
              got_primary = TRUE;
            }
          else
            {
              set_device_battery_additional (panel, child);
            }
        }
      else
        {
          add_device_secondary (panel, child, &secondary_devices_cnt);
        }
      g_variant_unref (child);
    }

  g_variant_unref (untuple);
  g_variant_unref (result);
}
예제 #27
0
파일: gtktoolbutton.c 프로젝트: raja651/gtk
static void
gtk_tool_button_construct_contents (GtkToolItem *tool_item)
{
  GtkToolButton *button = GTK_TOOL_BUTTON (tool_item);
  GtkWidget *child;
  GtkWidget *label = NULL;
  GtkWidget *icon = NULL;
  GtkToolbarStyle style;
  gboolean need_label = FALSE;
  gboolean need_icon = FALSE;
  GtkIconSize icon_size;
  GtkWidget *box = NULL;
  guint icon_spacing;
  GtkOrientation text_orientation = GTK_ORIENTATION_HORIZONTAL;
  GtkSizeGroup *size_group = NULL;
  GtkWidget *parent;

  button->priv->contents_invalid = FALSE;

  gtk_widget_style_get (GTK_WIDGET (tool_item), 
			"icon-spacing", &icon_spacing,
			NULL);

  if (button->priv->icon_widget)
    {
      parent = gtk_widget_get_parent (button->priv->icon_widget);
      if (parent)
        {
          gtk_container_remove (GTK_CONTAINER (parent),
                                button->priv->icon_widget);
        }
    }

  if (button->priv->label_widget)
    {
      parent = gtk_widget_get_parent (button->priv->label_widget);
      if (parent)
        {
          gtk_container_remove (GTK_CONTAINER (parent),
                                button->priv->label_widget);
        }
    }

  child = gtk_bin_get_child (GTK_BIN (button->priv->button));
  if (child)
    {
      /* Note: we are not destroying the label_widget or icon_widget
       * here because they were removed from their containers above
       */
      gtk_widget_destroy (child);
    }

  style = gtk_tool_item_get_toolbar_style (GTK_TOOL_ITEM (button));
  
  if (style != GTK_TOOLBAR_TEXT)
    need_icon = TRUE;

  if (style != GTK_TOOLBAR_ICONS && style != GTK_TOOLBAR_BOTH_HORIZ)
    need_label = TRUE;

  if (style == GTK_TOOLBAR_BOTH_HORIZ &&
      (gtk_tool_item_get_is_important (GTK_TOOL_ITEM (button)) ||
       gtk_tool_item_get_orientation (GTK_TOOL_ITEM (button)) == GTK_ORIENTATION_VERTICAL ||
       gtk_tool_item_get_text_orientation (GTK_TOOL_ITEM (button)) == GTK_ORIENTATION_VERTICAL))
    {
      need_label = TRUE;
    }
  
  if (style != GTK_TOOLBAR_TEXT && button->priv->icon_widget == NULL &&
      button->priv->stock_id == NULL && button->priv->icon_name == NULL)
    {
      need_label = TRUE;
      need_icon = FALSE;
      style = GTK_TOOLBAR_TEXT;
    }

  if (style == GTK_TOOLBAR_TEXT && button->priv->label_widget == NULL &&
      button->priv->stock_id == NULL && button->priv->label_text == NULL)
    {
      need_label = FALSE;
      need_icon = TRUE;
      style = GTK_TOOLBAR_ICONS;
    }

  if (need_label)
    {
      if (button->priv->label_widget)
	{
	  label = button->priv->label_widget;
	}
      else
	{
	  GtkStockItem stock_item;
	  gboolean elide;
	  gchar *label_text;

          G_GNUC_BEGIN_IGNORE_DEPRECATIONS;

	  if (button->priv->label_text)
	    {
	      label_text = button->priv->label_text;
	      elide = button->priv->use_underline;
	    }
	  else if (button->priv->stock_id && gtk_stock_lookup (button->priv->stock_id, &stock_item))
	    {
	      label_text = stock_item.label;
	      elide = TRUE;
	    }
	  else
	    {
	      label_text = "";
	      elide = FALSE;
	    }

          G_GNUC_END_IGNORE_DEPRECATIONS;

	  if (elide)
	    label_text = _gtk_toolbar_elide_underscores (label_text);
	  else
	    label_text = g_strdup (label_text);

	  label = gtk_label_new (label_text);

	  g_free (label_text);
	  
	  gtk_widget_show (label);
	}

      if (GTK_IS_LABEL (label))
        {
          gtk_label_set_ellipsize (GTK_LABEL (label),
			           gtk_tool_item_get_ellipsize_mode (GTK_TOOL_ITEM (button)));
          text_orientation = gtk_tool_item_get_text_orientation (GTK_TOOL_ITEM (button));
          if (text_orientation == GTK_ORIENTATION_HORIZONTAL)
	    {
              gfloat align;

              gtk_label_set_angle (GTK_LABEL (label), 0);
              align = gtk_tool_item_get_text_alignment (GTK_TOOL_ITEM (button));
              if (align < 0.4)
                gtk_widget_set_halign (label, GTK_ALIGN_START);
              else if (align > 0.6)
                gtk_widget_set_halign (label, GTK_ALIGN_END);
              else
                gtk_widget_set_halign (label, GTK_ALIGN_CENTER);
            }
          else
            {
              gfloat align;

              gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_NONE);
	      if (gtk_widget_get_direction (GTK_WIDGET (tool_item)) == GTK_TEXT_DIR_RTL)
	        gtk_label_set_angle (GTK_LABEL (label), -90);
	      else
	        gtk_label_set_angle (GTK_LABEL (label), 90);
              align = gtk_tool_item_get_text_alignment (GTK_TOOL_ITEM (button));
              if (align < 0.4)
                gtk_widget_set_valign (label, GTK_ALIGN_END);
              else if (align > 0.6)
                gtk_widget_set_valign (label, GTK_ALIGN_START);
              else
                gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
            }
        }
    }

  icon_size = gtk_tool_item_get_icon_size (GTK_TOOL_ITEM (button));
  if (need_icon)
    {
      GtkIconSet *icon_set = NULL;

      if (button->priv->stock_id)
        {
          G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
          icon_set = gtk_icon_factory_lookup_default (button->priv->stock_id);
          G_GNUC_END_IGNORE_DEPRECATIONS;
        }

      if (button->priv->icon_widget)
	{
	  icon = button->priv->icon_widget;
	  
	  if (GTK_IS_IMAGE (icon))
	    {
	      g_object_set (button->priv->icon_widget,
			    "icon-size", icon_size,
			    NULL);
	    }
	}
      else if (icon_set != NULL)
	{
          G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
	  icon = gtk_image_new_from_stock (button->priv->stock_id, icon_size);
          G_GNUC_END_IGNORE_DEPRECATIONS;
	  gtk_widget_show (icon);
	}
      else if (button->priv->icon_name)
	{
	  icon = gtk_image_new_from_icon_name (button->priv->icon_name, icon_size);
	  gtk_widget_show (icon);
	}

      if (icon)
	{
          if (text_orientation == GTK_ORIENTATION_HORIZONTAL)
            {
              gfloat align;

              align = gtk_tool_item_get_text_alignment (GTK_TOOL_ITEM (button));
              if (align > 0.6) 
                gtk_widget_set_halign (icon, GTK_ALIGN_START);
              else if (align < 0.4)
                gtk_widget_set_halign (icon, GTK_ALIGN_END);
              else
                gtk_widget_set_halign (icon, GTK_ALIGN_CENTER);
            }
          else
            {
              gfloat align;

              align = gtk_tool_item_get_text_alignment (GTK_TOOL_ITEM (button));
              if (align > 0.6) 
                gtk_widget_set_valign (icon, GTK_ALIGN_END);
              else if (align < 0.4)
                gtk_widget_set_valign (icon, GTK_ALIGN_START);
              else
               gtk_widget_set_valign (icon, GTK_ALIGN_CENTER);
            }

	  size_group = gtk_tool_item_get_text_size_group (GTK_TOOL_ITEM (button));
	  if (size_group != NULL)
	    gtk_size_group_add_widget (size_group, icon);
	}
    }

  switch (style)
    {
    case GTK_TOOLBAR_ICONS:
      if (icon)
        gtk_container_add (GTK_CONTAINER (button->priv->button), icon);
      gtk_style_context_add_class (gtk_widget_get_style_context (button->priv->button), "image-button");
      break;

    case GTK_TOOLBAR_BOTH:
      if (text_orientation == GTK_ORIENTATION_HORIZONTAL)
	box = gtk_box_new (GTK_ORIENTATION_VERTICAL, icon_spacing);
      else
	box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, icon_spacing);
      if (icon)
	gtk_box_pack_start (GTK_BOX (box), icon, TRUE, TRUE, 0);
      gtk_box_pack_end (GTK_BOX (box), label, FALSE, TRUE, 0);
      gtk_container_add (GTK_CONTAINER (button->priv->button), box);
      break;

    case GTK_TOOLBAR_BOTH_HORIZ:
      if (text_orientation == GTK_ORIENTATION_HORIZONTAL)
	{
	  box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, icon_spacing);
	  if (icon)
	    gtk_box_pack_start (GTK_BOX (box), icon, label? FALSE : TRUE, TRUE, 0);
	  if (label)
	    gtk_box_pack_end (GTK_BOX (box), label, TRUE, TRUE, 0);
	}
      else
	{
	  box = gtk_box_new (GTK_ORIENTATION_VERTICAL, icon_spacing);
	  if (icon)
	    gtk_box_pack_end (GTK_BOX (box), icon, label ? FALSE : TRUE, TRUE, 0);
	  if (label)
	    gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
	}
      gtk_container_add (GTK_CONTAINER (button->priv->button), box);
      break;

    case GTK_TOOLBAR_TEXT:
      gtk_container_add (GTK_CONTAINER (button->priv->button), label);
      gtk_style_context_add_class (gtk_widget_get_style_context (button->priv->button), "text-button");
      break;
    }

  if (box)
    gtk_widget_show (box);

  gtk_button_set_relief (GTK_BUTTON (button->priv->button),
			 gtk_tool_item_get_relief_style (GTK_TOOL_ITEM (button)));

  gtk_tool_item_rebuild_menu (tool_item);
  
  gtk_widget_queue_resize (GTK_WIDGET (button));
}
예제 #28
0
GtkWidget * XAP_UnixDialog_Image::_constructWindow ()
{
	const XAP_StringSet * pSS = m_pApp->getStringSet();
	const char * ui_file;

#if defined(EMBEDDED_TARGET) && EMBEDDED_TARGET == EMBEDDED_TARGET_HILDON
    ui_file = "xap_UnixHildonDlg_Image.ui";
#else
#if GTK_CHECK_VERSION(3,0,0)
    ui_file = "xap_UnixDlg_Image.ui";
#else
    ui_file = "xap_UnixDlg_Image-2.ui";
#endif
#endif

    GtkBuilder * builder = newDialogBuilder(ui_file);
	
	mMainWindow = GTK_WIDGET(gtk_builder_get_object(builder, "xap_UnixDlg_Image"));
	m_wHeightSpin = GTK_WIDGET(gtk_builder_get_object(builder, "sbHeight"));
	m_wHeightEntry = GTK_WIDGET(gtk_builder_get_object(builder, "edHeight"));
	m_wWidthSpin = GTK_WIDGET(gtk_builder_get_object(builder, "sbWidth"));
	m_wWidthEntry = GTK_WIDGET(gtk_builder_get_object(builder, "edWidth"));
	m_wAspectCheck = GTK_WIDGET(gtk_builder_get_object(builder, "cbAspect"));

	m_wTitleEntry = GTK_WIDGET(gtk_builder_get_object(builder, "edTitle"));
	m_wDescriptionEntry = GTK_WIDGET(gtk_builder_get_object(builder, "edDescription"));

	m_bAspect = getPreserveAspect();
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (m_wAspectCheck), m_bAspect);
	
	m_oHeightSpin_adj = (GtkAdjustment*)gtk_adjustment_new( 1,-2000, 2000, 1, 1, 10);
   	gtk_widget_set_size_request(m_wHeightSpin,14,-1);  
	gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON(m_wHeightSpin), GTK_ADJUSTMENT(m_oHeightSpin_adj));
	
	m_oWidthSpin_adj = (GtkAdjustment*)gtk_adjustment_new( 1,-2000, 2000, 1, 1, 10);
	gtk_widget_set_size_request(m_wWidthSpin,14,-1);  
	gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON(m_wWidthSpin), GTK_ADJUSTMENT(m_oWidthSpin_adj));
	
    std::string s;
	pSS->getValueUTF8(XAP_STRING_ID_DLG_Image_Title,s);
	abiDialogSetTitle(mMainWindow, "%s", s.c_str());

    localizeLabel(GTK_WIDGET(gtk_builder_get_object(builder, "lbDescTab")), pSS, XAP_STRING_ID_DLG_Image_DescTabLabel);
    localizeLabel(GTK_WIDGET(gtk_builder_get_object(builder, "lbWrapTab")), pSS, XAP_STRING_ID_DLG_Image_WrapTabLabel);
#if defined(EMBEDDED_TARGET) && EMBEDDED_TARGET == EMBEDDED_TARGET_HILDON
    localizeLabel(GTK_WIDGET(gtk_builder_get_object(builder, "lbPlacementTab")), pSS, XAP_STRING_ID_DLG_Image_PlacementTabLabel);
#endif

	localizeLabelMarkup(GTK_WIDGET(gtk_builder_get_object(builder, "lbSize")), pSS, XAP_STRING_ID_DLG_Image_ImageSize);
	localizeLabelMarkup(GTK_WIDGET(gtk_builder_get_object(builder, "lbImageDescription")), pSS, XAP_STRING_ID_DLG_Image_ImageDesc);
	localizeLabelMarkup(GTK_WIDGET(gtk_builder_get_object(builder, "lbTextWrapping")), pSS, XAP_STRING_ID_DLG_Image_TextWrapping);
	localizeLabelMarkup(GTK_WIDGET(gtk_builder_get_object(builder, "lbImagePlacement")), pSS, XAP_STRING_ID_DLG_Image_Placement);
	localizeLabelMarkup(GTK_WIDGET(gtk_builder_get_object(builder, "lbWrapType")), pSS, XAP_STRING_ID_DLG_Image_WrapType);
	
	localizeLabel(GTK_WIDGET(gtk_builder_get_object(builder, "lbHeight")), pSS, XAP_STRING_ID_DLG_Image_Height);
	localizeLabel(GTK_WIDGET(gtk_builder_get_object(builder, "lbWidth")), pSS, XAP_STRING_ID_DLG_Image_Width);
	localizeLabel(GTK_WIDGET(gtk_builder_get_object(builder, "lbTitle")), pSS, XAP_STRING_ID_DLG_Image_LblTitle);
	localizeLabel(GTK_WIDGET(gtk_builder_get_object(builder, "lbDescription")), pSS, XAP_STRING_ID_DLG_Image_LblDescription);

	localizeButton(GTK_WIDGET(gtk_builder_get_object(builder, "rbInLine")), pSS, XAP_STRING_ID_DLG_Image_InLine);
	localizeButton(GTK_WIDGET(gtk_builder_get_object(builder, "rbNone")), pSS, XAP_STRING_ID_DLG_Image_WrappedNone);
	localizeButton(GTK_WIDGET(gtk_builder_get_object(builder, "rbWrappedRight")), pSS, XAP_STRING_ID_DLG_Image_WrappedRight);
	localizeButton(GTK_WIDGET(gtk_builder_get_object(builder, "rbWrappedLeft")), pSS, XAP_STRING_ID_DLG_Image_WrappedLeft);
	localizeButton(GTK_WIDGET(gtk_builder_get_object(builder, "rbWrappedBoth")), pSS, XAP_STRING_ID_DLG_Image_WrappedBoth);

	localizeButton(GTK_WIDGET(gtk_builder_get_object(builder, "rbPlaceParagraph")), pSS, XAP_STRING_ID_DLG_Image_PlaceParagraph);
	localizeButton(GTK_WIDGET(gtk_builder_get_object(builder, "rbPlaceColumn")), pSS, XAP_STRING_ID_DLG_Image_PlaceColumn);
	localizeButton(GTK_WIDGET(gtk_builder_get_object(builder, "rbPlacePage")), pSS, XAP_STRING_ID_DLG_Image_PlacePage);

	localizeButton(GTK_WIDGET(gtk_builder_get_object(builder, "rbSquareWrap")), pSS, XAP_STRING_ID_DLG_Image_SquareWrap);
	localizeButton(GTK_WIDGET(gtk_builder_get_object(builder, "rbTightWrap")), pSS, XAP_STRING_ID_DLG_Image_TightWrap);

	m_wPlaceTable = GTK_WIDGET(gtk_builder_get_object(builder, "tbPlacement"));
	m_wrbInLine = GTK_WIDGET(gtk_builder_get_object(builder, "rbInLine"));
	m_wrbNone = GTK_WIDGET(gtk_builder_get_object(builder, "rbNone"));
	m_wrbWrappedRight = GTK_WIDGET(gtk_builder_get_object(builder, "rbWrappedRight"));
	m_wrbWrappedLeft = GTK_WIDGET(gtk_builder_get_object(builder, "rbWrappedLeft"));
	m_wrbWrappedBoth = GTK_WIDGET(gtk_builder_get_object(builder, "rbWrappedBoth"));

	m_wrbPlaceParagraph = GTK_WIDGET(gtk_builder_get_object(builder, "rbPlaceParagraph"));
	m_wrbPlaceColumn = GTK_WIDGET(gtk_builder_get_object(builder, "rbPlaceColumn"));
	m_wrbPlacePage = GTK_WIDGET(gtk_builder_get_object(builder, "rbPlacePage"));

	m_wWrapTable = GTK_WIDGET(gtk_builder_get_object(builder, "tbWrapTable"));
	m_wrbSquareWrap = GTK_WIDGET(gtk_builder_get_object(builder, "rbSquareWrap"));
	m_wrbTightWrap = GTK_WIDGET(gtk_builder_get_object(builder, "rbTightWrap"));


// the check button already contains a label. We have to remove this
// before we can localize it

	gtk_container_remove(GTK_CONTAINER(m_wAspectCheck), gtk_bin_get_child(GTK_BIN(m_wAspectCheck)));
	pSS->getValueUTF8 (XAP_STRING_ID_DLG_Image_Aspect,s);
	gtk_button_set_label(GTK_BUTTON(m_wAspectCheck), s.c_str());

	m_iWidth = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(m_wWidthSpin));
	m_iHeight = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(m_wHeightSpin));

	gtk_entry_set_text (GTK_ENTRY(m_wTitleEntry), getTitle().utf8_str());
	gtk_entry_set_text (GTK_ENTRY(m_wDescriptionEntry), getDescription().utf8_str());

	_connectSignals ();
	
	g_object_unref(G_OBJECT(builder));

	return mMainWindow;
}
예제 #29
0
void dt_lib_remove_child(GtkWidget *widget, gpointer data)
{
  gtk_container_remove(GTK_CONTAINER(data), widget);
}
예제 #30
0
파일: annots.c 프로젝트: Distrotech/poppler
static void
pgd_annot_view_set_annot (PgdAnnotsDemo *demo,
                          PopplerAnnot  *annot)
{
    GtkWidget  *table;
    gint        row = 0;
    gchar      *text;
    time_t      timet;
    PopplerRectangle rect;

    table = gtk_bin_get_child (GTK_BIN (demo->annot_view));
    if (table) {
        gtk_container_remove (GTK_CONTAINER (demo->annot_view), table);
    }

    if (!annot)
        return;

    table = gtk_grid_new ();
    gtk_widget_set_margin_top (table, 5);
    gtk_widget_set_margin_bottom (table, 5);
#if GTK_CHECK_VERSION(3, 12, 0)
    gtk_widget_set_margin_start (table, 8);
    gtk_widget_set_margin_end (table, 5);
#else
    gtk_widget_set_margin_left (table, 8);
    gtk_widget_set_margin_right (table, 5);
#endif
    gtk_grid_set_column_spacing (GTK_GRID (table), 6);
    gtk_grid_set_row_spacing (GTK_GRID (table), 6);

    text = poppler_annot_get_contents (annot);
    pgd_table_add_property (GTK_GRID (table), "<b>Contents:</b>", text, &row);
    g_free (text);

    text = poppler_annot_get_name (annot);
    pgd_table_add_property (GTK_GRID (table), "<b>Name:</b>", text, &row);
    g_free (text);

    text = poppler_annot_get_modified (annot);
    if (poppler_date_parse (text, &timet)) {
	    g_free (text);
	    text = pgd_format_date (timet);
    }
    pgd_table_add_property (GTK_GRID (table), "<b>Modified:</b>", text, &row);
    g_free (text);

    poppler_annot_get_rectangle (annot, &rect);
    text = g_strdup_printf ("(%.2f;%.2f) (%.2f;%.2f)", rect.x1, rect.y1, rect.x2, rect.y2);
    pgd_table_add_property (GTK_GRID (table), "<b>Coords:</b>", text, &row);
    g_free (text);

    if (POPPLER_IS_ANNOT_MARKUP (annot))
        pgd_annot_view_set_annot_markup (table, POPPLER_ANNOT_MARKUP (annot), &row);

    switch (poppler_annot_get_annot_type (annot))
    {
        case POPPLER_ANNOT_TEXT:
          pgd_annot_view_set_annot_text (table, POPPLER_ANNOT_TEXT (annot), &row);
          break;
        case POPPLER_ANNOT_HIGHLIGHT:
        case POPPLER_ANNOT_UNDERLINE:
        case POPPLER_ANNOT_SQUIGGLY:
        case POPPLER_ANNOT_STRIKE_OUT:
          pgd_annot_view_set_annot_text_markup (table, POPPLER_ANNOT_TEXT_MARKUP (annot), &row);
          break;
        case POPPLER_ANNOT_FREE_TEXT:
          pgd_annot_view_set_annot_free_text (table, POPPLER_ANNOT_FREE_TEXT (annot), &row);
          break;
        case POPPLER_ANNOT_FILE_ATTACHMENT:
	  pgd_annot_view_set_annot_file_attachment (table, POPPLER_ANNOT_FILE_ATTACHMENT (annot), &row);
	  break;
        case POPPLER_ANNOT_MOVIE:
	  pgd_annot_view_set_annot_movie (table, POPPLER_ANNOT_MOVIE (annot), &row);
	  break;
        case POPPLER_ANNOT_SCREEN:
	  pgd_annot_view_set_annot_screen (table, POPPLER_ANNOT_SCREEN (annot), &row);
	  break;
        default:
          break;
    }

    gtk_container_add (GTK_CONTAINER (demo->annot_view), table);
    gtk_widget_show (table);
}